diff options
Diffstat (limited to 'kbarcode')
151 files changed, 34816 insertions, 0 deletions
diff --git a/kbarcode/Makefile.am b/kbarcode/Makefile.am new file mode 100644 index 0000000..665c3f2 --- /dev/null +++ b/kbarcode/Makefile.am @@ -0,0 +1,58 @@ +## Makefile.am for kbarcode + +# set the include path for X, qt and KDE +INCLUDES = -I$(top_srcdir)/src $(all_includes) + +# these are the headers for your project + + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO +KDE_ICON = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kdedcoptest.pot + +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +bin_PROGRAMS = kbarcode + +# the application source, library search path, and link libraries + +kbarcode_LDFLAGS = $(KDE_RPATH) $(all_libraries) +kbarcode_LDADD = $(LIB_KABC) $(LIB_KSPELL) $(LIB_KDEPRINT) \ + $(LIB_KDEUI) -lkjs -lpcre + +noinst_HEADERS = barcodecombo.h barcodedialog.h barcodedialogs.h \ + commands.h configdialog.h confwizard.h csvimportdlg.h databasebrowser.h \ + definition.h definitiondialog.h dsmainwindow.h dsrichtext.h kbarcode.h label.h \ + labeleditor.h labelutils.h mimesources.h multilineeditdlg.h \ + mycanvasitem.h mycanvasview.h mydatatable.h newlabel.h previewdialog.h \ + printersettings.h printlabeldlg.h rectsettingsdlg.h smalldialogs.h sqltables.h \ + tokenprovider.h xmlutils.h zplutils.h measurements.h editoriface.h kbarcodeiface.h \ + batchiface.h kbarcodesettings.h batchprinter.h barcodeitem.h documentitem.h \ + lineitem.h rectitem.h tcanvasitem.h textitem.h imageitem.h documentitemdlg.h \ + propertywidget.h tec.h barcodeprinterdlg.h textlineitem.h textlineedit.h tokendialog.h \ + barkode.h gnubarcode.h barkodeengine.h pixmapbarcode.h batchwizard.h csvfile.h \ + referencecounted.h dstextedit.h encodingcombo.h purepostscript.h tbarcode2.h \ + kactionmap.h + +kbarcode_SOURCES = barcodecombo.cpp barcodedialog.cpp \ + barcodedialogs.cpp commands.cpp configdialog.cpp confwizard.cpp csvimportdlg.cpp \ + databasebrowser.cpp definition.cpp definitiondialog.cpp dsmainwindow.cpp dsrichtext.cpp \ + kbarcode.cpp label.cpp labeleditor.cpp labelutils.cpp main.cpp \ + mimesources.cpp multilineeditdlg.cpp mycanvasitem.cpp mycanvasview.cpp mydatatable.cpp \ + newlabel.cpp previewdialog.cpp printersettings.cpp printlabeldlg.cpp \ + rectsettingsdlg.cpp smalldialogs.cpp sqltables.cpp tokenprovider.cpp xmlutils.cpp \ + zplutils.cpp measurements.cpp editoriface.skel kbarcodeiface.skel batchiface.skel \ + kbarcodesettings.cpp batchprinter.cpp barcodeitem.cpp documentitem.cpp lineitem.cpp \ + rectitem.cpp tcanvasitem.cpp textitem.cpp imageitem.cpp documentitemdlg.cpp \ + propertywidget.cpp tec.cpp barcodeprinterdlg.cpp textlineitem.cpp textlineedit.cpp \ + tokendialog.cpp barkode.cpp gnubarcode.cpp barkodeengine.cpp pixmapbarcode.cpp batchwizard.cpp \ + csvfile.cpp referencecounted.cpp dstextedit.cpp encodingcombo.cpp purepostscript.cpp tbarcode2.cpp \ + kactionmap.cpp + +xdg_apps_DATA = kbarcode.desktop kbarcode-batch.desktop kbarcode-editor.desktop kbarcode-label.desktop kbarcode-single.desktop + +datafiles_DATA = logo.png barcodes.html exampledata.sql labeldefinitions.sql barcode.ps rules.xml +datafilesdir = $(kde_datadir)/kbarcode diff --git a/kbarcode/barcode.ps b/kbarcode/barcode.ps new file mode 100644 index 0000000..686a31a --- /dev/null +++ b/kbarcode/barcode.ps @@ -0,0 +1,3563 @@ +%!PS-Adobe-2.0 +%%Creator: Terry Burton +%%DocumentPaperSizes: a4 +%%EndComments +%%EndProlog + +% Barcode Writer in Pure PostScript - Version 2006-09-26 +% http://www.terryburton.co.uk/barcodewriter/ +% +% Copyright (c) 2006 Terry Burton - tez@terryburton.co.uk +% +% Permission is hereby granted, free of charge, to any +% person obtaining a copy of this software and associated +% documentation files (the "Software"), to deal in the +% Software without restriction, including without +% limitation the rights to use, copy, modify, merge, +% publish, distribute, sublicense, and/or sell copies of +% the Software, and to permit persons to whom the Software +% is furnished to do so, subject to the following +% conditions: +% +% The above copyright notice and this permission notice +% shall be included in all copies or substantial portions +% of the Software. +% +% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +% KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +% THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +% PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +% THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +% DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +% CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +% IN THE SOFTWARE. + +% Uncomment this next line to allow these procedure definitions to +% remain resident within a printer's PostScript virtual machine +% so that the barcode generation capability persists between jobs. + +% serverdict begin 0 exitserver + +% --BEGIN TEMPLATE-- + +% --BEGIN ENCODER ean13-- +% --DESC: EAN-13 +% --EXAM: 977147396801 +/ean13 { + + 0 begin + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includetext false def % Enable/disable text + /textfont /Helvetica def + /textsize 12 def + /textpos -4 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + /barlen barcode length def % Length of the code + + % Add checksum digit to barcode if length is even + barlen 2 mod 0 eq { + /pad barlen 1 add string def % Create pad one bigger than barcode + /checksum 0 def + 0 1 barlen 1 sub { + /i exch def + /barchar barcode i get 48 sub def + i 2 mod 0 eq { + /checksum barchar checksum add def + } { + /checksum barchar 3 mul checksum add def + } ifelse + } for + /checksum 10 checksum 10 mod sub 10 mod def + pad 0 barcode putinterval % Add barcode to the start of the pad + pad barlen checksum 48 add put % Put ascii for checksum at end of pad + /barcode pad def % barcode=pad + /barlen barlen 1 add def % barlen++ + } if + + % Create an array containing the character mappings + /encs + [ (3211) (2221) (2122) (1411) (1132) + (1231) (1114) (1312) (1213) (3112) + (111) (11111) (111) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + + % Digits to mirror on left side + /mirrormaps + [ (000000) (001011) (001101) (001110) (010011) + (011001) (011100) (010101) (010110) (011010) + ] def + + /sbs barlen 1 sub 4 mul 11 add string def + /txt barlen array def + + % Put the start character + sbs 0 encs 10 get putinterval + + % First digit - determine mirrormap by this and show before guard bars + /mirrormap mirrormaps barcode 0 get 48 sub get def + txt 0 [barcode 0 1 getinterval -10 textpos textfont textsize] put + + % Left side - performs mirroring + 1 1 6 { + % Lookup the encoding for the each barcode character + /i exch def + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + mirrormap i 1 sub get 49 eq { % Reverse enc if 1 in this position in mirrormap + /enclen enc length def + /revenc enclen string def + 0 1 enclen 1 sub { + /j exch def + /char enc j get def + revenc enclen j sub 1 sub char put + } for + /enc revenc def + } if + sbs i 1 sub 4 mul 3 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 1 sub 7 mul 4 add textpos textfont textsize] put + } for + + % Put the middle character + sbs 7 1 sub 4 mul 3 add encs 11 get putinterval + + % Right side + 7 1 12 { + % Lookup the encoding for the each barcode character + /i exch def + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + sbs i 1 sub 4 mul 8 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 1 sub 7 mul 8 add textpos textfont textsize] put + } for + + % Put the end character + sbs barlen 1 sub 4 mul 8 add encs 12 get putinterval + + % Return the arguments + /retval 4 dict def + retval (sbs) [sbs {48 sub} forall] put + includetext { + retval (bhs) [height height 12{height .075 sub}repeat height height 12{height .075 sub}repeat height height] put + retval (bbs) [0 0 12{.075}repeat 0 0 12{.075}repeat 0 0] put + retval (txt) txt put + } { + retval (bhs) [30{height}repeat] put + retval (bbs) [30{0}repeat] put + } ifelse + retval (opt) useropts put + retval (guardrightpos) 10 put + retval (borderbottom) 5 put + retval + + end + +} bind def +/ean13 load 0 1 dict put +% --END ENCODER ean13-- + +% --BEGIN ENCODER ean8-- +% --DESC: EAN-8 +% --EXAM: 01335583 +/ean8 { + + 0 begin + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includetext false def % Enable/disable text + /textfont /Helvetica def + /textsize 12 def + /textpos -4 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + % Create an array containing the character mappings + /encs + [ (3211) (2221) (2122) (1411) (1132) + (1231) (1114) (1312) (1213) (3112) + (111) (11111) (111) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + + /barlen barcode length def % Length of the code + /sbs barlen 4 mul 11 add string def + /txt barlen array def + + % Put the start character + sbs 0 encs 10 get putinterval + + % Left side + 0 1 3 { + % Lookup the encoding for the each barcode character + /i exch def + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + sbs i 4 mul 3 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 7 mul 4 add textpos textfont textsize] put + } for + + % Put the middle character + sbs 4 4 mul 3 add encs 11 get putinterval + + % Right side + 4 1 7 { + % Lookup the encoding for the each barcode character + /i exch def + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + sbs i 4 mul 8 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 7 mul 8 add textpos textfont textsize] put + } for + + % Put the end character + sbs barlen 4 mul 8 add encs 12 get putinterval + + % Return the arguments + /retval 4 dict def + retval (sbs) [sbs {48 sub} forall] put + includetext { + retval (bhs) [height height 8{height .075 sub}repeat height height 8{height .075 sub}repeat height height] put + retval (bbs) [0 0 8{.075}repeat 0 0 8{.075}repeat 0 0] put + retval (txt) txt put + } { + retval (bhs) [22{height}repeat] put + retval (bbs) [22{0}repeat] put + } ifelse + retval (opt) useropts put + retval (guardleftpos) 10 put + retval (guardrightpos) 10 put + retval (borderbottom) 5 put + retval + + end + +} bind def +/ean8 load 0 1 dict put +% --END ENCODER ean8-- + +% --BEGIN ENCODER upca-- +% --DESC: UPC-A +% --EXAM: 78858101497 +/upca { + + 0 begin + + /options exch def + /useropts options def + /barcode exch def % We are given a barcode string + + /includetext false def % Enable/disable text + /textfont /Helvetica def + /textsize 12 def + /textpos -4 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + /barlen barcode length def % Length of the code + + % Add checksum digit to barcode if length is odd + barlen 2 mod 0 ne { + /pad barlen 1 add string def % Create pad one bigger than barcode + /checksum 0 def + 0 1 barlen 1 sub { + /i exch def + /barchar barcode i get 48 sub def + i 2 mod 0 ne { + /checksum checksum barchar add def + } { + /checksum checksum barchar 3 mul add def + } ifelse + } for + /checksum 10 checksum 10 mod sub 10 mod def + pad 0 barcode putinterval % Add barcode to the start of the pad + pad barlen checksum 48 add put % Put ascii for checksum at end of pad + /barcode pad def % barcode=pad + /barlen barlen 1 add def % barlen++ + } if + + % Create an array containing the character mappings + /encs + [ (3211) (2221) (2122) (1411) (1132) + (1231) (1114) (1312) (1213) (3112) + (111) (11111) (111) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + + /sbs barlen 4 mul 11 add string def + /txt barlen array def + + % Put the start character + sbs 0 encs 10 get putinterval + + % Left side + 0 1 5 { + % Lookup the encoding for the each barcode character + /i exch def + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + sbs i 4 mul 3 add enc putinterval % Put encoded digit into sbs + i 0 eq { % First digit is before the guard bars + txt 0 [barcode 0 1 getinterval -7 textpos textfont textsize 2 sub] put + } { + txt i [barcode i 1 getinterval i 7 mul 4 add textpos textfont textsize] put + } ifelse + } for + + % Put the middle character + sbs 6 4 mul 3 add encs 11 get putinterval + + % Right side + 6 1 11 { + % Lookup the encoding for the each barcode character + /i exch def + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + sbs i 4 mul 8 add enc putinterval % Put encoded digit into sbs + i 11 eq { % Last digit is after guard bars + txt 11 [barcode 11 1 getinterval 96 textpos textfont textsize 2 sub] put + } { + txt i [barcode i 1 getinterval i 7 mul 8 add textpos textfont textsize] put + } ifelse + } for + + % Put the end character + sbs barlen 4 mul 8 add encs 12 get putinterval + + % Return the arguments + /retval 4 dict def + retval (sbs) [sbs {48 sub} forall] put + includetext { + retval (bhs) [4{height}repeat 10{height .075 sub}repeat height height 10{height .075 sub}repeat 5{height}repeat] put + retval (bbs) [0 0 0 0 10{.075}repeat 0 0 10{.075}repeat 0 0 0 0 0] put + retval (txt) txt put + } { + retval (bhs) [31{height}repeat] put + retval (bbs) [31{0}repeat] put + } ifelse + retval (opt) useropts put + retval (borderbottom) 5 put + retval + + end + +} bind def +/upca load 0 1 dict put +% --END ENCODER upca-- + +% --BEGIN ENCODER upce-- +% --DESC: UPC-E +% --EXAM: 0123456 +/upce { + + 0 begin + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includetext false def % Enable/disable text + /textfont /Helvetica def + /textsize 12 def + /textpos -4 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + /barlen barcode length def % Length of the code + + % Create an array containing the character mappings + /encs + [ (3211) (2221) (2122) (1411) (1132) + (1231) (1114) (1312) (1213) (3112) + (111) (1111111) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + + /mirrormaps + [ (000111) (001011) (001101) (001110) (010011) + (011001) (011100) (010101) (010110) (011010) + ] def + + % Add checksum digit to barcode if length is odd + barlen 2 mod 0 ne { + /pad barlen 1 add string def % Create pad one bigger than barcode + /checksum 0 def + 0 1 barlen 1 sub { + /i exch def + /barchar barcode i get 48 sub def + i 2 mod 0 ne { + /checksum barchar checksum add def + } { + /checksum barchar 3 mul checksum add def + } ifelse + } for + /checksum 10 checksum 10 mod sub 10 mod def + pad 0 barcode putinterval % Add barcode to the start of the pad + pad barlen checksum 48 add put % Put ascii for checksum at end of pad + /barcode pad def % barcode=pad + /barlen barlen 1 add def % barlen++ + } if + /txt barlen array def + txt 0 [barcode 0 1 getinterval -7 textpos textfont textsize 2 sub] put + + % Determine the mirror map based on checksum + /mirrormap mirrormaps barcode barlen 1 sub get 48 sub get def + + % Invert the mirrormap if we are using a non-zero number system + barcode 0 get 48 eq { + /invt mirrormap length string def + 0 1 mirrormap length 1 sub { + /i exch def + mirrormap i get 48 eq { + invt i 49 put + } { + invt i 48 put + } ifelse + } for + /mirrormap invt def + } if + + /sbs barlen 2 sub 4 mul 10 add string def + + % Put the start character + sbs 0 encs 10 get putinterval + + 1 1 6 { + /i exch def + % Lookup the encoding for the each barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + mirrormap i 1 sub get 49 eq { % Reverse enc if 1 in this position in mirrormap + /enclen enc length def + /revenc enclen string def + 0 1 enclen 1 sub { + /j exch def + /char enc j get def + revenc enclen j sub 1 sub char put + } for + /enc revenc def + } if + sbs i 1 sub 4 mul 3 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 1 sub 7 mul 4 add textpos textfont textsize] put + } for + + txt 7 [barcode 7 1 getinterval 6 7 mul 11 add textpos textfont textsize 2 sub] put + + % Put the end character + sbs barlen 2 sub 4 mul 3 add encs 11 get putinterval + + % Return the arguments + /retval 4 dict def + retval (sbs) [sbs {48 sub} forall] put + includetext { + retval (bhs) [height height 12{height .075 sub}repeat height height height] put + retval (bbs) [0 0 12{.075}repeat 0 0 0] put + retval (txt) txt put + } { + retval (bhs) [17{height}repeat] put + retval (bbs) [17{0}repeat] put + } ifelse + retval (opt) useropts put + retval (borderbottom) 5 put + retval + + end + +} bind def +/upce load 0 1 dict put +% --END ENCODER upce-- + +% --BEGIN ENCODER ean5-- +% --DESC: EAN-5 (5 digit addon) +% --EXAM: 0123456 +/ean5 { + + 0 begin + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includetext false def % Enable/disable text + /textfont /Helvetica def + /textsize 12 def + /textpos (unset) def + /height 0.7 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /height height cvr def + textpos (unset) eq { + /textpos height 72 mul 1 add def + } { + /textpos textpos cvr def + } ifelse + + /barlen barcode length def % Length of the code + + % Create an array containing the character mappings + /encs + [ (3211) (2221) (2122) (1411) (1132) + (1231) (1114) (1312) (1213) (3112) + (112) (11) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + + % Determine the mirror map based on mod 10 checksum + /mirrormaps + [ (11000) (10100) (10010) (10001) (01100) + (00110) (00011) (01010) (01001) (00101) + ] def + /checksum 0 def + 0 1 4 { + /i exch def + /barchar barcode i get 48 sub def + i 2 mod 0 eq { + /checksum barchar 3 mul checksum add def + } { + /checksum barchar 9 mul checksum add def + } ifelse + } for + /checksum checksum 10 mod def + /mirrormap mirrormaps checksum get def + + /sbs 31 string def + /txt 5 array def + + 0 1 4 { + /i exch def + + % Prefix with either a start character or separator character + i 0 eq { + sbs 0 encs 10 get putinterval + } { + sbs i 1 sub 6 mul 7 add encs 11 get putinterval + } ifelse + + % Lookup the encoding for the barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + mirrormap i get 49 eq { % Reverse enc if 1 in this position in mirrormap + /enclen enc length def + /revenc enclen string def + 0 1 enclen 1 sub { + /j exch def + /char enc j get def + revenc enclen j sub 1 sub char put + } for + /enc revenc def + } if + sbs i 6 mul 3 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 1 sub 9 mul 13 add textpos textfont textsize] put + } for + + % Return the arguments + /retval 4 dict def + retval (sbs) [sbs {48 sub} forall] put + retval (bhs) [16{height}repeat] put + retval (bbs) [16{0}repeat] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval (guardrightpos) 10 put + retval (guardrightypos) textpos 4 add put + retval (bordertop) 10 put + retval + + end + +} bind def +/ean5 load 0 1 dict put +% --END ENCODER ean5-- + +% --BEGIN ENCODER ean2-- +% --DESC: EAN-2 (2 digit addon) +% --EXAM: 05 +/ean2 { + + 0 begin + + /options exch def % We are given an options string + /useropts options def + /barcode exch def % We are given a barcode string + + /includetext false def % Enable/disable text + /textfont /Helvetica def + /textsize 12 def + /textpos (unset) def + /height 0.7 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /height height cvr def + textpos (unset) eq { + /textpos height 72 mul 1 add def + } { + /textpos textpos cvr def + } ifelse + + /barlen barcode length def % Length of the code + + % Create an array containing the character mappings + /encs + [ (3211) (2221) (2122) (1411) (1132) + (1231) (1114) (1312) (1213) (3112) + (112) (11) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + + % Determine the mirror map based on mod 4 checksum + /mirrormap [(00) (01) (10) (11)] barcode 0 2 getinterval cvi 4 mod get def + + /sbs 13 string def + /txt 2 array def + + 0 1 1 { + /i exch def + + % Prefix with either a start character or separator character + i 0 eq { + sbs 0 encs 10 get putinterval + } { + sbs i 1 sub 6 mul 7 add encs 11 get putinterval + } ifelse + + % Lookup the encoding for the barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + mirrormap i get 49 eq { % Reverse enc if 1 in this position in mirrormap + /enclen enc length def + /revenc enclen string def + 0 1 enclen 1 sub { + /j exch def + /char enc j get def + revenc enclen j sub 1 sub char put + } for + /enc revenc def + } if + sbs i 6 mul 3 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 1 sub 9 mul 13 add textpos textfont textsize] put + } for + + % Return the arguments + /retval 4 dict def + retval (sbs) [sbs {48 sub} forall] put + retval (bhs) [12{height}repeat] put + retval (bbs) [12{0}repeat] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval (guardrightpos) 10 put + retval (guardrightypos) textpos 4 add put + retval (bordertop) 10 put + retval + + end + +} bind def +/ean2 load 0 1 dict put +% --END ENCODER ean2-- + +% --BEGIN ENCODER isbn-- +% --REQUIRES ean13-- +% --DESC: ISBN +% --EXAM: 1-86074-271 +/isbn { + + 0 begin + + /options exch def % We are given an options string + /useropts options def + /isbntxt exch def % We are given the isbn text with dashes + + /includetext false def % Enable/disable ISBN text + /isbnfont /Courier def + /isbnsize 9 def + /isbnpos (unset) def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /isbnfont isbnfont cvlit def + /isbnsize isbnsize cvr def + /height height cvr def + isbnpos (unset) eq { + /isbnpos height 72 mul 3 add def + } { + /isbnpos isbnpos cvr def + } ifelse + + % Read the digits from isbntxt and calculate checksums + /isbn 13 string def + /checksum10 0 def + /checksum13 0 def + /i 0 def /n 0 def + { % loop + /isbnchar isbntxt i get 48 sub def + isbnchar -3 ne { % Ignore dashes + isbn n isbnchar 48 add put + /checksum10 checksum10 10 n sub isbnchar mul add def + n 2 mod 0 eq { + /checksum13 isbnchar checksum13 add def + } { + /checksum13 isbnchar 3 mul checksum13 add def + } ifelse + /n n 1 add def + } if + /i i 1 add def + i isbntxt length eq {exit} if + } loop + + % Add the ISBN header to the isbntxt + n 9 eq n 10 eq or { + /checksum 11 checksum10 11 mod sub 11 mod def + /isbn isbn 0 9 getinterval def + /pad 18 string def + } { + /checksum 10 checksum13 10 mod sub 10 mod def + /isbn isbn 0 12 getinterval def + /pad 22 string def + } ifelse + pad 0 (ISBN ) putinterval + pad 5 isbntxt putinterval % Add isbntxt to the pad + + % Add checksum digit if isbntxt length is 11 or 15 + isbntxt length 11 eq isbntxt length 15 eq or { + pad isbntxt length 5 add 45 put % Put a dash + checksum 10 eq { + pad isbntxt length 6 add checksum 78 add put % Check digit for 10 is X + } { + pad isbntxt length 6 add checksum 48 add put % Put check digit + } ifelse + } if + /isbntxt pad def % isbntxt=pad + + % Convert ISBN digits to EAN-13 + /barcode 12 string def + isbn length 9 eq { + barcode 0 (978) putinterval + barcode 3 isbn putinterval + } { + barcode 0 isbn putinterval + } ifelse + + % Get the result of encoding with ean13 + /args barcode options ean13 def + + % Add the ISBN text + includetext { + isbn length 9 eq { + /isbnxpos -1 def + } { + /isbnxpos -12 def + } ifelse + args (txt) known { + /txt args (txt) get def + /newtxt txt length 1 add array def + newtxt 0 txt putinterval + newtxt newtxt length 1 sub [isbntxt isbnxpos isbnpos isbnfont isbnsize] put + args (txt) newtxt put + } { + args (txt) [ [isbntxt isbnxpos isbnpos isbnfont isbnsize] ] put + } ifelse + } if + + args (opt) useropts put + args + + end + +} bind def +/isbn load 0 1 dict put +% --END ENCODER isbn-- + +% --BEGIN ENCODER code128-- +% --DESC: Code 128 +% --EXAM: ^104^102Count^0990123456789^101! +/code128 { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includetext false def % Enable/disable text + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + % Create an array containing the character mappings + /encs + [ (212222) (222122) (222221) (121223) (121322) (131222) (122213) + (122312) (132212) (221213) (221312) (231212) (112232) (122132) + (122231) (113222) (123122) (123221) (223211) (221132) (221231) + (213212) (223112) (312131) (311222) (321122) (321221) (312212) + (322112) (322211) (212123) (212321) (232121) (111323) (131123) + (131321) (112313) (132113) (132311) (211313) (231113) (231311) + (112133) (112331) (132131) (113123) (113321) (133121) (313121) + (211331) (231131) (213113) (213311) (213131) (311123) (311321) + (331121) (312113) (312311) (332111) (314111) (221411) (431111) + (111224) (111422) (121124) (121421) (141122) (141221) (112214) + (112412) (122114) (122411) (142112) (142211) (241211) (221114) + (413111) (241112) (134111) (111242) (121142) (121241) (114212) + (124112) (124211) (411212) (421112) (421211) (212141) (214121) + (412121) (111143) (111341) (131141) (114113) (114311) (411113) + (411311) (113141) (114131) (311141) (411131) (211412) (211214) + (211232) (2331112) + ] def + + % Create a string of the available characters for alphabets A and B + /barchars ( !"#$%&'\(\)*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~) def + /barlen barcode length def % Length of the code + /sbs barlen 6 mul string def % sbs is 6 times length of barcode + /txt barlen array def + + /mode -1 def % A=0, B=1, C=2 + /checksum barcode 1 3 getinterval cvi def % Initialise the checksum + + /i 0 def /j 0 def + { % loop + i barlen eq {exit} if + barcode i 1 getinterval (^) eq { + % indx is given by the next three characters + /indx barcode i 1 add 3 getinterval cvi def + txt j [( ) j 11 mul textpos textfont textsize] put + /i i 4 add def + } { + % indx depends on the mode + mode 2 eq { + /indx barcode i 2 getinterval cvi def + txt j [barcode i 2 getinterval j 11 mul textpos textfont textsize] put + /i i 2 add def + } { + barchars barcode i 1 getinterval search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + txt j [barchars indx 1 getinterval j 11 mul textpos textfont textsize] put + /i i 1 add def + } ifelse + } ifelse + /enc encs indx get def % Get the indxth encoding + sbs j 6 mul enc putinterval % Put encoded digit into sbs + + % Update the mode + indx 101 eq indx 103 eq or {/mode 0 def} if + indx 100 eq indx 104 eq or {/mode 1 def} if + indx 99 eq indx 105 eq or {/mode 2 def} if + + /checksum indx j mul checksum add def % checksum+=indx*j + /j j 1 add def + } loop + + % Put the checksum character + /checksum checksum 103 mod def + sbs j 6 mul encs checksum get putinterval + + % Put the end character + sbs j 6 mul 6 add encs 106 get putinterval + + % Shrink sbs and txt to fit exactly + /sbs sbs 0 j 6 mul 13 add getinterval def + /txt txt 0 j getinterval def + + % Return the arguments + /retval 1 dict def + retval (sbs) [sbs {48 sub} forall] put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/code128 load 0 1 dict put +% --END ENCODER code128-- + +% --BEGIN ENCODER code39-- +% --DESC: Code 39 +% --EXAM: THIS IS CODE 39 +/code39 { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includecheck false def % Enable/disable checkdigit + /includetext false def + /includecheckintext false def + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + % Create an array containing the character mappings + /encs + [ (1113313111) (3113111131) (1133111131) (3133111111) (1113311131) + (3113311111) (1133311111) (1113113131) (3113113111) (1133113111) + (3111131131) (1131131131) (3131131111) (1111331131) (3111331111) + (1131331111) (1111133131) (3111133111) (1131133111) (1111333111) + (3111111331) (1131111331) (3131111311) (1111311331) (3111311311) + (1131311311) (1111113331) (3111113311) (1131113311) (1111313311) + (3311111131) (1331111131) (3331111111) (1311311131) (3311311111) + (1331311111) (1311113131) (3311113111) (1331113111) (1313131111) + (1313111311) (1311131311) (1113131311) (1311313111) + ] def + + % Create a string of the available characters + /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*) def + + /barlen barcode length def % Length of the code + + includecheck { + /sbs barlen 10 mul 30 add string def + /txt barlen 3 add array def + } { + /sbs barlen 10 mul 20 add string def + /txt barlen 2 add array def + } ifelse + + /checksum 0 def + + % Put the start character + sbs 0 encs 43 get putinterval + txt 0 [(*) 0 textpos textfont textsize] put + + 0 1 barlen 1 sub { + /i exch def + % Lookup the encoding for the each barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + sbs i 10 mul 10 add enc putinterval % Put encoded digit into sbs + txt i 1 add [barcode i 1 getinterval i 1 add 16 mul textpos textfont textsize] put + /checksum checksum indx add def + } for + + % Put the checksum and end characters + includecheck { + /checksum checksum 43 mod def + sbs barlen 10 mul 10 add encs checksum get putinterval + includecheckintext { + txt barlen 1 add [barchars checksum 1 getinterval barlen 1 add 16 mul textpos textfont textsize] put + } { + txt barlen 1 add [() barlen 1 add 16 mul textpos textfont textsize] put + } ifelse + sbs barlen 10 mul 20 add encs 43 get putinterval + txt barlen 2 add [(*) barlen 2 add 16 mul textpos textfont textsize] put + } { + sbs barlen 10 mul 10 add encs 43 get putinterval + txt barlen 1 add [(*) barlen 1 add 16 mul textpos textfont textsize] put + } ifelse + + % Return the arguments + /retval 2 dict def + retval (sbs) [sbs {48 sub} forall] put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/code39 load 0 1 dict put +% --END ENCODER code39-- + +% --BEGIN ENCODER code93-- +% --DESC: Code 93 +% --EXAM: THIS IS CODE 93 +/code93 { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includecheck false def % Enable/disable checkdigit + /includetext false def % Enable/disable text + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + /encs + [ (131112) (111213) (111312) (111411) (121113) + (121212) (121311) (111114) (131211) (141111) + (211113) (211212) (211311) (221112) (221211) + (231111) (112113) (112212) (112311) (122112) + (132111) (111123) (111222) (111321) (121122) + (131121) (212112) (212211) (211122) (211221) + (221121) (222111) (112122) (112221) (122121) + (123111) (121131) (311112) (311211) (321111) + (112131) (113121) (211131) (121221) (312111) + (311121) (122211) (111141) (1111411) + ] def + + % Create a string of the available characters + /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def + + /barlen barcode length def % Length of the code + barcode { + (^) search false eq {pop exit} if + pop pop /barlen barlen 3 sub def + } loop + + includecheck { + /sbs barlen 6 mul 25 add string def + } { + /sbs barlen 6 mul 13 add string def + } ifelse + /txt barlen array def + + % Put the start character + sbs 0 encs 47 get putinterval + + /checksum1 0 def /checksum2 0 def + + /i 0 def /j 0 def + { % loop + j barlen eq {exit} if + barcode i 1 getinterval (^) eq { + % indx is given by the next three characters + /indx barcode i 1 add 3 getinterval cvi def + txt j [( ) j 9 mul 9 add textpos textfont textsize] put + /i i 4 add def + } { + barchars barcode i 1 getinterval search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + txt j [barchars indx 1 getinterval j 9 mul 9 add textpos textfont textsize] put + /i i 1 add def + } ifelse + /enc encs indx get def % Get the indxth encoding + sbs j 6 mul 6 add enc putinterval % Put encoded digit into sbs + /checksum1 checksum1 barlen j sub 1 sub 20 mod 1 add indx mul add def + /checksum2 checksum2 barlen j sub 15 mod 1 add indx mul add def + /j j 1 add def + } loop + + includecheck { + % Put the first checksum character + /checksum1 checksum1 47 mod def + /checksum2 checksum2 checksum1 add 47 mod def + sbs j 6 mul 6 add encs checksum1 get putinterval + sbs j 6 mul 12 add encs checksum2 get putinterval + % Put the end character + sbs j 6 mul 18 add encs 48 get putinterval + } { + % Put the end character + sbs j 6 mul 6 add encs 48 get putinterval + } ifelse + + % Return the arguments + /retval 1 dict def + retval (sbs) [sbs {48 sub} forall] put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/code93 load 0 1 dict put +% --END ENCODER code93-- + +% --BEGIN ENCODER interleaved2of5-- +% --DESC: Interleaved 2 of 5 (ITF) +% --EXAM: 24012345678905 +/interleaved2of5 { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includecheck false def % Enable/disable checkdigit + /includetext false def % Enable/disable text + /includecheckintext false def + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + /barlen barcode length def % Length of the code + + % Prefix 0 to barcode if length is even and including checkdigit + % or length is odd and not including checkdigit + barlen 2 mod 0 eq includecheck and % even & includecheck + barlen 2 mod 0 ne includecheck not and or { % odd & !includecheck + /pad barlen 1 add string def % Create pad one bigger than barcode + pad 0 48 put % Put ascii 0 at start of pad + pad 1 barcode putinterval % Add barcode to the end of pad + /barcode pad def % barcode=pad + /barlen barlen 1 add def % barlen++ + } if + + % Add checksum to end of barcode + includecheck { + /checksum 0 def + 0 1 barlen 1 sub { + /i exch def + i 2 mod 0 eq { + /checksum checksum barcode i get 48 sub 3 mul add def + } { + /checksum checksum barcode i get 48 sub add def + } ifelse + } for + /checksum 10 checksum 10 mod sub 10 mod def + /pad barlen 1 add string def % Create pad one bigger than barcode + pad 0 barcode putinterval % Add barcode to the start of pad + pad barlen checksum 48 add put % Add checksum to end of pad + /barcode pad def % barcode=pad + /barlen barlen 1 add def % barlen++ + } if + + % Create an array containing the character mappings + /encs + [ (11331) (31113) (13113) (33111) (11313) + (31311) (13311) (11133) (31131) (13131) + (1111) (3111) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + /sbs barlen 5 mul 8 add string def + /txt barlen array def + + % Put the start character + sbs 0 encs 10 get putinterval + + 0 2 barlen 1 sub { + /i exch def + % Lookup the encodings for two consecutive barcode characters + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enca encs indx get def % Get the indxth encoding + + barcode i 1 add 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /encb encs indx get def % Get the indxth encoding + + % Interleave the two character encodings + /intl enca length 2 mul string def + 0 1 enca length 1 sub { + /j exch def + /achar enca j get def + /bchar encb j get def + intl j 2 mul achar put + intl j 2 mul 1 add bchar put + } for + + sbs i 5 mul 4 add intl putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 9 mul 4 add textpos textfont textsize] put + includecheck includecheckintext not and barlen 2 sub i eq and { + txt i 1 add [( ) i 1 add 9 mul 4 add textpos textfont textsize] put + } { + txt i 1 add [barcode i 1 add 1 getinterval i 1 add 9 mul 4 add textpos textfont textsize] put + } ifelse + } for + + % Put the end character + sbs barlen 5 mul 4 add encs 11 get putinterval + + % Return the arguments + /retval 1 dict def + retval (sbs) [sbs {48 sub} forall] put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/interleaved2of5 load 0 1 dict put +% --END ENCODER interleaved2of5-- + +% --BEGIN ENCODER rss14-- +% --DESC: Reduced Space Symbology 14 (RSS-14) +% --EXAM: 24012345678905 +/rss14 { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /height 1 def + /linkage false def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /height height cvr def + + /getRSSwidths { + /mw exch def + /nm exch def + /val exch def + /j 0 def /i 0 def { + /v () def + mw 1 ne {/v i mw 4 string cvrs def} if + 0 v {48 sub add} forall 4 add nm eq { + j val eq {exit} if + /j j 1 add def + } if + /i i 1 add def + } loop + [4 {1} repeat v {47 sub} forall] v length 4 getinterval + } bind def + + /binval [barcode {48 sub} forall] def + /binval [linkage {1} {0} ifelse binval 0 13 getinterval {} forall] def + + 0 1 12 { + /i exch def + binval i 1 add 2 copy get binval i get 4537077 mod 10 mul add put + binval i binval i get 4537077 idiv put + } for + /right binval 13 get 4537077 mod def + binval 13 2 copy get 4537077 idiv put + + /left 0 def + /i true def + 0 1 13 { + /j exch def + binval j get + dup 0 eq i and { + pop + } { + /i false def + /left left 3 -1 roll 10 13 j sub exp cvi mul add def + } ifelse + } for + + /d1 left 1597 idiv def + /d2 left 1597 mod def + /d3 right 1597 idiv def + /d4 right 1597 mod def + + /tab164 [ + 160 0 12 4 8 1 161 1 + 960 161 10 6 6 3 80 10 + 2014 961 8 8 4 5 31 34 + 2714 2015 6 10 3 6 10 70 + 2840 2715 4 12 1 8 1 126 + ] def + + /tab154 [ + 335 0 5 10 2 7 4 84 + 1035 336 7 8 4 5 20 35 + 1515 1036 9 6 6 3 48 10 + 1596 1516 11 4 8 1 81 1 + ] def + + /i 0 def { + d1 tab164 i get le { + tab164 i 1 add 7 getinterval {} forall + /d1te exch def /d1to exch def + /d1mwe exch def /d1mwo exch def + /d1ele exch def /d1elo exch def + /d1gs exch def + exit + } if + /i i 8 add def + } loop + + /i 0 def { + d2 tab154 i get le { + tab154 i 1 add 7 getinterval {} forall + /d2te exch def /d2to exch def + /d2mwe exch def /d2mwo exch def + /d2ele exch def /d2elo exch def + /d2gs exch def + exit + } if + /i i 8 add def + } loop + + /i 0 def { + d3 tab164 i get le { + tab164 i 1 add 7 getinterval {} forall + /d3te exch def /d3to exch def + /d3mwe exch def /d3mwo exch def + /d3ele exch def /d3elo exch def + /d3gs exch def + exit + } if + /i i 8 add def + } loop + + /i 0 def { + d4 tab154 i get le { + tab154 i 1 add 7 getinterval {} forall + /d4te exch def /d4to exch def + /d4mwe exch def /d4mwo exch def + /d4ele exch def /d4elo exch def + /d4gs exch def + exit + } if + /i i 8 add def + } loop + + /d1wo d1 d1gs sub d1te idiv d1elo d1mwo getRSSwidths def + /d1we d1 d1gs sub d1te mod d1ele d1mwe getRSSwidths def + /d2wo d2 d2gs sub d2to mod d2elo d2mwo getRSSwidths def + /d2we d2 d2gs sub d2to idiv d2ele d2mwe getRSSwidths def + /d3wo d3 d3gs sub d3te idiv d3elo d3mwo getRSSwidths def + /d3we d3 d3gs sub d3te mod d3ele d3mwe getRSSwidths def + /d4wo d4 d4gs sub d4to mod d4elo d4mwo getRSSwidths def + /d4we d4 d4gs sub d4to idiv d4ele d4mwe getRSSwidths def + + /d1w 8 array def + 0 1 3 { + /i exch def + d1w i 2 mul d1wo i get put + d1w i 2 mul 1 add d1we i get put + } for + + /d2w 8 array def + 0 1 3 { + /i exch def + d2w 7 i 2 mul sub d2wo i get put + d2w 6 i 2 mul sub d2we i get put + } for + + /d3w 8 array def + 0 1 3 { + /i exch def + d3w 7 i 2 mul sub d3wo i get put + d3w 6 i 2 mul sub d3we i get put + } for + + /d4w 8 array def + 0 1 3 { + /i exch def + d4w i 2 mul d4wo i get put + d4w i 2 mul 1 add d4we i get put + } for + + /widths [ + d1w {} forall + d2w {} forall + d3w {} forall + d4w {} forall + ] def + + /checkweights [ + 1 3 9 27 2 6 18 54 + 58 72 24 8 29 36 12 4 + 74 51 17 32 37 65 48 16 + 64 34 23 69 49 68 46 59 + ] def + + /checkwidths [ + 3 8 2 1 1 3 5 5 1 1 3 3 7 1 1 + 3 1 9 1 1 2 7 4 1 1 2 5 6 1 1 + 2 3 8 1 1 1 5 7 1 1 1 3 9 1 1 + ] def + + /checksum 0 def + 0 1 31 { + /i exch def + /checksum checksum widths i get checkweights i get mul add def + } for + /checksum checksum 79 mod def + checksum 8 ge {/checksum checksum 1 add def} if + checksum 72 ge {/checksum checksum 1 add def} if + /checklt checkwidths checksum 9 idiv 5 mul 5 getinterval def + /checkrtrev checkwidths checksum 9 mod 5 mul 5 getinterval def + /checkrt 5 array def + 0 1 4 { + /i exch def + checkrt i checkrtrev 4 i sub get put + } for + + /sbs [ + 1 d1w {} forall checklt {} forall d2w {} + forall d4w {} forall checkrt {} forall d3w {} forall 1 1 + ] def + + % Return the arguments + /retval 1 dict def + retval (sbs) sbs put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + retval (opt) useropts put + retval + + end + +} bind def +/rss14 load 0 1 dict put +% --END ENCODER rss14-- + +% --BEGIN ENCODER rsslimited-- +% --DESC: Reduced Space Symbology Limited (RSS-Limited) +% --EXAM: 00978186074271 +/rsslimited { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /height height cvr def + + /getRSSwidths { + /el exch def + /mw exch def + /nm exch def + /val exch def + /j 0 def /i 0 def { + /v () def + mw 1 ne {/v i mw el string cvrs def} if + 0 v {48 sub add} forall el add nm eq { + j val eq {exit} if + /j j 1 add def + } if + /i i 1 add def + } loop + [el {1} repeat v {47 sub} forall] v length el getinterval + } bind def + + /binval [barcode {48 sub} forall] def + /binval [binval 0 13 getinterval {} forall] def + + 0 1 11 { + /i exch def + binval i 1 add 2 copy get binval i get 2013571 mod 10 mul add put + binval i binval i get 2013571 idiv put + } for + /d2 binval 12 get 2013571 mod def + binval 12 2 copy get 2013571 idiv put + + /d1 0 def + /i true def + 0 1 12 { + /j exch def + binval j get + dup 0 eq i and { + pop + } { + /i false def + /d1 d1 3 -1 roll 10 12 j sub exp cvi mul add def + } ifelse + } for + + /tab267 [ + 183063 0 17 9 6 3 6538 28 + 820063 183064 13 13 5 4 875 728 + 1000775 820064 9 17 3 6 28 6454 + 1491020 1000776 15 11 5 4 2415 203 + 1979844 1491021 11 15 4 5 203 2408 + 1996938 1979845 19 7 8 1 17094 1 + 2013570 1996939 7 19 1 8 1 16632 + ] def + + /i 0 def { + d1 tab267 i get le { + tab267 i 1 add 7 getinterval {} forall + /d1te exch def /d1to exch def + /d1mwe exch def /d1mwo exch def + /d1ele exch def /d1elo exch def + /d1gs exch def + exit + } if + /i i 8 add def + } loop + + /i 0 def { + d2 tab267 i get le { + tab267 i 1 add 7 getinterval {} forall + /d2te exch def /d2to exch def + /d2mwe exch def /d2mwo exch def + /d2ele exch def /d2elo exch def + /d2gs exch def + exit + } if + /i i 8 add def + } loop + + /d1wo d1 d1gs sub d1te idiv d1elo d1mwo 7 getRSSwidths def + /d1we d1 d1gs sub d1te mod d1ele d1mwe 7 getRSSwidths def + /d2wo d2 d2gs sub d2te idiv d2elo d2mwo 7 getRSSwidths def + /d2we d2 d2gs sub d2te mod d2ele d2mwe 7 getRSSwidths def + + /d1w 14 array def + 0 1 6 { + /i exch def + d1w i 2 mul d1wo i get put + d1w i 2 mul 1 add d1we i get put + } for + + /d2w 14 array def + 0 1 6 { + /i exch def + d2w i 2 mul d2wo i get put + d2w i 2 mul 1 add d2we i get put + } for + + /widths [ + d1w {} forall + d2w {} forall + ] def + + /checkweights [ + 1 3 9 27 81 65 17 51 64 14 42 37 22 66 + 20 60 2 6 18 54 73 41 34 13 39 28 84 74 + ] def + + /checkseq [ + 0 1 43 {} for + 45 52 57 + 63 1 66 {} for + 73 1 79 {} for + 82 + 126 1 130 {} for + 132 + 141 1 146 {} for + 210 1 217 {} for + 220 + 316 1 323 {} for + 326 337 + ] def + + /checksum 0 def + 0 1 27 { + /i exch def + /checksum checksum widths i get checkweights i get mul add def + } for + /checksum checksum 89 mod def + /seq checkseq checksum get def + /swidths seq 21 idiv 8 3 6 getRSSwidths def + /bwidths seq 21 mod 8 3 6 getRSSwidths def + + /checkwidths [0 0 0 0 0 0 0 0 0 0 0 0 1 1] def + 0 1 5 { + /i exch def + checkwidths i 2 mul swidths i get put + checkwidths i 2 mul 1 add bwidths i get put + } for + + /sbs [ + 1 d1w {} forall checkwidths {} forall d2w {} forall 1 1 + ] def + + % Return the arguments + /retval 1 dict def + retval (sbs) sbs put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + retval (opt) useropts put + retval + + end + +} bind def +/rsslimited load 0 1 dict put +% --END ENCODER rsslimited-- + +% --BEGIN ENCODER rssexpanded-- +% --DESC: Reduced Space Symbology Expanded (RSS-Expanded) +% --EXAM: 000000010011001010100001000000010000 +/rssexpanded { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /height height cvr def + + /getRSSwidths { + /mw exch def + /nm exch def + /val exch def + /j 0 def /i 0 def { + /v () def + mw 1 ne {/v i mw 4 string cvrs def} if + 0 v {48 sub add} forall 4 add nm eq { + j val eq {exit} if + /j j 1 add def + } if + /i i 1 add def + } loop + [4 {1} repeat v {47 sub} forall] v length 4 getinterval + } bind def + + /binval [barcode {48 sub} forall] def + /datalen binval length 12 idiv def + + /tab174 [ + 347 0 12 5 7 2 87 4 + 1387 348 10 7 5 4 52 20 + 2947 1388 8 9 4 5 30 52 + 3987 2948 6 11 3 6 10 104 + 4191 3988 4 13 1 8 1 204 + ] def + + /dxw datalen array def + + 0 1 datalen 1 sub { + + /x exch def + + /d binval x 12 mul 12 getinterval def + /d 0 0 1 11 {/j exch def 2 11 j sub exp cvi d j get mul add} for def + + /j 0 def { + d tab174 j get le { + tab174 j 1 add 7 getinterval {} forall + /dte exch def /dto exch def + /dmwe exch def /dmwo exch def + /dele exch def /delo exch def + /dgs exch def + exit + } if + /j j 8 add def + } loop + + /dwo d dgs sub dte idiv delo dmwo getRSSwidths def + /dwe d dgs sub dte mod dele dmwe getRSSwidths def + + /dw 8 array def + x 2 mod 0 eq { + 0 1 3 { + /j exch def + dw 7 j 2 mul sub dwo j get put + dw 6 j 2 mul sub dwe j get put + } for + } { + 0 1 3 { + /j exch def + dw j 2 mul dwo j get put + dw j 2 mul 1 add dwe j get put + } for + } ifelse + + dxw x dw put + + } for + + /widths [ + dxw {{} forall} forall + ] def + + /checkweights [ + 77 96 32 81 27 9 3 1 + 20 60 180 118 143 7 21 63 + 205 209 140 117 39 13 145 189 + 193 157 49 147 19 57 171 91 + 132 44 85 169 197 136 186 62 + 185 133 188 142 4 12 36 108 + 50 87 29 80 97 173 128 113 + 150 28 84 41 123 158 52 156 + 166 196 206 139 187 203 138 46 + 76 17 51 153 37 111 122 155 + 146 119 110 107 106 176 129 43 + 16 48 144 10 30 90 59 177 + 164 125 112 178 200 137 116 109 + 70 210 208 202 184 130 179 115 + 190 204 68 93 31 151 191 134 + 148 22 66 198 172 94 71 2 + 40 154 192 64 162 54 18 6 + 120 149 25 75 14 42 126 167 + 175 199 207 69 23 78 26 79 + 103 98 83 38 114 131 182 124 + 159 53 88 170 127 183 61 161 + 55 165 73 8 24 72 5 15 + 89 100 174 58 160 194 135 45 + ] def + + /checksum 0 def + 0 1 widths length 1 sub { + /i exch def + /checksum checksum widths i get checkweights i get mul add def + } for + /checksum checksum 211 mod datalen 3 sub 211 mul add def + + /i 0 def { + checksum tab174 i get le { + tab174 i 1 add 7 getinterval {} forall + /cte exch def /cto exch def + /cmwe exch def /cmwo exch def + /cele exch def /celo exch def + /cgs exch def + exit + } if + /i i 8 add def + } loop + + /cwo checksum cgs sub cte idiv celo cmwo getRSSwidths def + /cwe checksum cgs sub cte mod cele cmwe getRSSwidths def + + /cw 8 array def + 0 1 3 { + /i exch def + cw i 2 mul cwo i get put + cw i 2 mul 1 add cwe i get put + } for + + /finderwidths [ + 1 8 4 1 1 1 1 4 8 1 + 3 6 4 1 1 1 1 4 6 3 + 3 4 6 1 1 1 1 6 4 3 + 3 2 8 1 1 1 1 8 2 3 + 2 6 5 1 1 1 1 5 6 2 + 2 2 9 1 1 1 1 9 2 2 + ] def + + /finderseq [ + [0 1] + [0 3 2] + [0 5 2 7] + [0 9 2 7 4] + [0 9 2 7 6 11] + [0 9 2 7 8 11 10] + [0 1 2 3 4 5 6 7] + [0 1 2 3 4 5 6 9 8] + [0 1 2 3 4 5 6 9 10 11] + [0 1 2 3 4 7 6 9 8 11 10] + ] def + + /seq finderseq datalen 2 add 2 idiv 2 sub get def + /fxw seq length array def + 0 1 seq length 1 sub { + /x exch def + fxw x finderwidths seq x get 5 mul 5 getinterval put + } for + + /sbs [ + 1 + cw {} forall + 0 1 datalen 1 sub { + /i exch def + i 2 mod 0 eq {fxw i 2 idiv get {} forall} if + dxw i get {} forall + } for + 1 1 + ] def + + % Return the arguments + /retval 1 dict def + retval (sbs) sbs put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + retval (opt) useropts put + retval + + end + +} bind def +/rssexpanded load 0 1 dict put +% --END ENCODER rssexpanded-- + +% --BEGIN ENCODER code2of5-- +% --DESC: Code 25 +% --EXAM: 01234567 +/code2of5 { + + % Thanks to Michael Landers + + 0 begin % Confine variable to local scope + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includecheck false def + /includetext false def % Enable/disable text + /includecheckintext false def + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + % Create an array containing the character mappings + /encs + [ (1111313111) (3111111131) (1131111131) (3131111111) + (1111311131) (3111311111) (1131311111) (1111113131) + (3111113111) (1131113111) (313111) (311131) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + + /barlen barcode length def % Length of the code + + includecheck { + /sbs barlen 10 mul 22 add string def + /txt barlen 1 add array def + } { + /sbs barlen 10 mul 12 add string def + /txt barlen array def + } ifelse + + % Put the start character + sbs 0 encs 10 get putinterval + + /checksum 0 def + + 0 1 barlen 1 sub { + /i exch def + % Lookup the encoding for the each barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + sbs i 10 mul 6 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 14 mul 10 add textpos textfont textsize] put + barlen i sub 2 mod 0 eq { + /checksum checksum indx add def + } { + /checksum checksum indx 3 mul add def + } ifelse + } for + + % Put the checksum and end characters + includecheck { + /checksum 10 checksum 10 mod sub 10 mod def + sbs barlen 10 mul 6 add encs checksum get putinterval + sbs barlen 10 mul 16 add encs 11 get putinterval + includecheckintext { + txt barlen [barchars checksum 1 getinterval barlen 14 mul 10 add textpos textfont textsize] put + } { + txt barlen [( ) barlen 14 mul 10 add textpos textfont textsize] put + } ifelse + } { + sbs barlen 10 mul 6 add encs 11 get putinterval + } ifelse + + % Return the arguments + /retval 1 dict def + retval (sbs) [sbs {48 sub} forall] put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/code2of5 load 0 1 dict put +% --END ENCODER code2of5-- + +% --BEGIN ENCODER code11-- +% --DESC: Code 11 +% --EXAM: 0123456789 +/code11 { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includecheck false def + /includetext false def + /includecheckintext false def + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + % Create an array containing the character mappings + /encs + [ (111131) (311131) (131131) (331111) (113131) + (313111) (133111) (111331) (311311) (311111) + (113111) (113311) + ] def + + % Create a string of the available characters + /barchars (0123456789-) def + + /barlen barcode length def % Length of the code + + includecheck { + barlen 10 ge { + /sbs barlen 6 mul 24 add string def + /txt barlen 2 add array def + } { + /sbs barlen 6 mul 18 add string def + /txt barlen 1 add array def + } ifelse + } { + /sbs barlen 6 mul 12 add string def + /txt barlen array def + } ifelse + + % Put the start character + sbs 0 encs 10 get putinterval + + /checksum1 0 def /checksum2 0 def + + /xpos 8 def + 0 1 barlen 1 sub { + /i exch def + % Lookup the encoding for the each barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + sbs i 6 mul 6 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval xpos textpos textfont textsize] put + 0 1 5 { % xpos+=width of the character + /xpos exch enc exch get 48 sub xpos add def + } for + /checksum1 checksum1 barlen i sub 1 sub 10 mod 1 add indx mul add def + /checksum2 checksum2 barlen i sub 9 mod 1 add indx mul add def + } for + + % Put the checksum and end characters + includecheck { + /checksum1 checksum1 11 mod def + barlen 10 ge { + /checksum2 checksum2 checksum1 add 11 mod def + sbs barlen 6 mul 6 add encs checksum1 get putinterval + sbs barlen 6 mul 12 add encs checksum2 get putinterval + includecheckintext { + txt barlen [barchars checksum1 1 getinterval xpos textpos textfont textsize] put + /enc encs checksum1 get def + 0 1 5 { % xpos+=width of the character + /xpos exch enc exch get 48 sub xpos add def + } for + txt barlen 1 add [barchars checksum2 1 getinterval xpos textpos textfont textsize] put + } { + txt barlen [() xpos textpos textfont textsize] put + txt barlen 1 add [() xpos textpos textfont textsize] put + } ifelse + sbs barlen 6 mul 18 add encs 11 get putinterval + } { + sbs barlen 6 mul 6 add encs checksum1 get putinterval + includecheckintext { + txt barlen [barchars checksum1 1 getinterval xpos textpos textfont textsize] put + } { + txt barlen [() xpos textpos textfont textsize] put + } ifelse + sbs barlen 6 mul 12 add encs 11 get putinterval + } ifelse + } { + sbs barlen 6 mul 6 add encs 11 get putinterval + } ifelse + + % Return the arguments + /retval 1 dict def + retval (sbs) [sbs {48 sub} forall] put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/code11 load 0 1 dict put +% --END ENCODER code11-- + +% --BEGIN ENCODER rationalizedCodabar-- +% --DESC: Rationalized Codabar +% --EXAM: A0123456789B +/rationalizedCodabar { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includecheck false def % Enable/disable checkdigit + /includetext false def % Enable/disable text + /includecheckintext false def + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + % Create an array containing the character mappings + /encs + [ (11111331) (11113311) (11131131) (33111111) (11311311) + (31111311) (13111131) (13113111) (13311111) (31131111) + (11133111) (11331111) (31113131) (31311131) (31313111) + (11313131) (11331311) (13131131) (11131331) (11133311) + ] def + + % Create a string of the available characters + /barchars (0123456789-$:/.+ABCD) def + + /barlen barcode length def % Length of the code + + includecheck { + /sbs barlen 8 mul 8 add string def + /txt barlen 1 add array def + } { + /sbs barlen 8 mul string def + /txt barlen array def + } ifelse + + /checksum 0 def + /xpos 0 def + 0 1 barlen 2 sub { + /i exch def + % Lookup the encoding for the each barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + sbs i 8 mul enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval xpos textpos textfont textsize] put + 0 1 7 { % xpos+=width of the character + /xpos exch enc exch get 48 sub xpos add def + } for + /checksum checksum indx add def + } for + + % Find index of last character + barcode barlen 1 sub 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + + includecheck { + % Put the checksum character + /checksum checksum indx add def + /checksum 16 checksum 16 mod sub 16 mod def + sbs barlen 8 mul 8 sub encs checksum get putinterval + includecheckintext { + txt barlen 1 sub [barchars checksum 1 getinterval xpos textpos textfont textsize] put + } { + txt barlen 1 sub [( ) xpos textpos textfont textsize] put + } ifelse + 0 1 7 { % xpos+=width of the character + /xpos exch encs checksum get exch get 48 sub xpos add def + } for + % Put the end character + /enc encs indx get def % Get the indxth encoding + sbs barlen 8 mul enc putinterval % Put encoded digit into sbs + txt barlen [barcode barlen 1 sub 1 getinterval xpos textpos textfont textsize] put + } { + % Put the end character + /enc encs indx get def % Get the indxth encoding + sbs barlen 8 mul 8 sub enc putinterval % Put encoded digit into sbs + txt barlen 1 sub [barcode barlen 1 sub 1 getinterval xpos textpos textfont textsize] put + } ifelse + + % Return the arguments + /retval 1 dict def + retval (sbs) [sbs {48 sub} forall] put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/rationalizedCodabar load 0 1 dict put +% --END ENCODER rationalizedCodabar-- + +% --BEGIN ENCODER onecode-- +% --DESC: United States Postal Service OneCode +% --EXAM: 0123456709498765432101234567891 +/onecode { + + 0 begin + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /height 0.175 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /height height cvr def + + /barlen barcode length def + + /normalize { + /base exch def + /num exch def + num length 1 sub -1 1 { + /i exch def + num i 1 sub 2 copy get num i get base idiv add put + num i num i get base mod put + } for + { %loop - extend input as necessary + num 0 get base lt {exit} if + /num [0 num {} forall] def + num 0 num 0 get num 1 get base idiv add put + num 1 num 1 get base mod put + } loop + % Trim leading zeros + /num [/i true def num {dup 0 eq i and {pop} {/i false def} ifelse} forall] def + num length 0 eq {/num [0] def} if + num + } bind def + + /bigadd { + 2 copy length exch length + 2 copy sub abs /offset exch def + lt {exch} if + /a exch def /b exch def + 0 1 b length 1 sub { + dup a exch offset add 2 copy get b 5 -1 roll get add put + } for + a + } bind def + + % Conversion of data fields into binary data + barlen 20 eq {[0]} if + barlen 25 eq {[1]} if + barlen 29 eq {[1 0 0 0 0 1]} if + barlen 31 eq {[1 0 0 0 1 0 0 0 0 1]} if + /binval exch [barcode 20 barlen 20 sub getinterval {48 sub} forall] bigadd def + /binval [binval {} forall barcode 0 get 48 sub] def + /binval [binval {5 mul} forall] [barcode 1 get 48 sub] bigadd 10 normalize def + /binval [binval {} forall barcode 2 18 getinterval {48 sub} forall] def + + % Conversion of binary data into byte array + /bytes 13 array def + /bintmp [binval {} forall] def + 12 -1 0 { + /i exch def + 0 1 bintmp length 2 sub { + /j exch def + bintmp j 1 add 2 copy get bintmp j get 256 mod 10 mul add put + bintmp j bintmp j get 256 idiv put + } for + bytes i bintmp bintmp length 1 sub get 256 mod put + bintmp bintmp length 1 sub 2 copy get 256 idiv put + } for + + % Generation of 11-bit CRC on byte array + /fcs 2047 def + /dat bytes 0 get 5 bitshift def + 6 { + fcs dat xor 1024 and 0 ne { + /fcs fcs 1 bitshift 3893 xor def + } { + /fcs fcs 1 bitshift def + } ifelse + /fcs fcs 2047 and def + /dat dat 1 bitshift def + } repeat + 1 1 12 { + bytes exch get 3 bitshift /dat exch def + 8 { + fcs dat xor 1024 and 0 ne { + /fcs fcs 1 bitshift 3893 xor def + } { + /fcs fcs 1 bitshift def + } ifelse + /fcs fcs 2047 and def + /dat dat 1 bitshift def + } repeat + } for + + % Conversion from binary data to codewords + /codewords 10 array def + 9 -1 0 { + /i exch def + i 9 eq { + /b 636 def + } { + /b 1365 def + } ifelse + 0 1 binval length 2 sub { + /j exch def + binval j 1 add 2 copy get binval j get b mod 10 mul add put + binval j binval j get b idiv put + } for + codewords i binval binval length 1 sub get b mod put + binval binval length 1 sub 2 copy get b idiv put + } for + + % Inserting additional information into codewords + codewords 9 codewords 9 get 2 mul put + fcs 1024 and 0 ne { + codewords 0 codewords 0 get 659 add put + } if + + % Conversion from codewords to characters + /tab513 1287 dict def + /lo 0 def + /hi 1286 def + 0 1 8191 { + { % no loop - provides common exit point + /i exch def + /onbits 0 def + 0 1 12 { + i exch 1 exch bitshift and 0 ne { + /onbits onbits 1 add def + } if + } for + onbits 5 ne {exit} if + /j i def + /rev 0 def + 16 { + /rev rev 1 bitshift j 1 and or def + /j j -1 bitshift def + } repeat + /rev rev -3 bitshift def + rev i lt {exit} if + rev i eq { + tab513 hi i put + /hi hi 1 sub def + } { + tab513 lo i put + tab513 lo 1 add rev put + /lo lo 2 add def + } ifelse + exit + } loop + } for + + /tab213 78 dict def + /lo 0 def + /hi 77 def + 0 1 8191 { + { % no loop - provides common exit point + /i exch def + /onbits 0 def + 0 1 12 { + i exch 1 exch bitshift and 0 ne { + /onbits onbits 1 add def + } if + } for + onbits 2 ne {exit} if + /j i def + /rev 0 def + 16 { + /rev rev 1 bitshift j 1 and or def + /j j -1 bitshift def + } repeat + /rev rev -3 bitshift def + rev i lt {exit} if + rev i eq { + tab213 hi i put + /hi hi 1 sub def + } { + tab213 lo i put + tab213 lo 1 add rev put + /lo lo 2 add def + } ifelse + exit + } loop + } for + + /chars 10 array def + 0 1 9 { + /i exch def + codewords i get dup 1286 le { + tab513 exch get + } { + tab213 exch 1287 sub get + } ifelse + chars i 3 -1 roll put + } for + + 9 -1 0 { + /i exch def + 2 i exp cvi fcs and 0 ne { + chars i chars i get 8191 xor put + } if + } for + + % Conversion from characters to the OneCode encoding + /barmap [ + 7 2 4 3 1 10 0 0 9 12 2 8 5 5 6 11 8 9 3 1 + 0 1 5 12 2 5 1 8 4 4 9 11 6 3 8 10 3 9 7 6 + 5 11 1 4 8 5 2 12 9 10 0 2 7 1 6 7 3 6 4 9 + 0 3 8 6 6 4 2 7 1 1 9 9 7 10 5 2 4 0 3 8 + 6 2 0 4 8 11 1 0 9 8 3 12 2 6 7 7 5 1 4 10 + 1 12 6 9 7 3 8 0 5 8 9 7 4 6 2 10 3 4 0 5 + 8 4 5 7 7 11 1 9 6 0 9 6 0 6 4 8 2 1 3 2 + 5 9 8 12 4 11 6 1 9 5 7 4 3 3 1 2 0 7 2 0 + 1 3 4 1 6 10 3 5 8 7 9 4 2 11 5 6 0 8 7 12 + 4 2 8 1 5 10 3 0 9 3 0 9 6 5 2 4 7 8 1 7 + 5 0 4 5 2 3 0 10 6 12 9 2 3 11 1 6 8 8 7 9 + 5 4 0 11 1 5 2 2 9 1 4 12 8 3 6 6 7 0 3 7 + 4 7 7 5 0 12 1 11 2 9 9 0 6 8 5 3 3 10 8 2 + ] def + + /bbs 65 array def + /bhs 65 array def + 0 1 64 { + /i exch def + /dec chars barmap i 4 mul get get 2 barmap i 4 mul 1 add get exp cvi and 0 ne def + /asc chars barmap i 4 mul 2 add get get 2 barmap i 4 mul 3 add get exp cvi and 0 ne def + dec not asc not and { + bbs i 3 height mul 8 div put + bhs i 2 height mul 8 div put + } if + dec not asc and { + bbs i 3 height mul 8 div put + bhs i 5 height mul 8 div put + } if + dec asc not and { + bbs i 0 height mul 8 div put + bhs i 5 height mul 8 div put + } if + dec asc and { + bbs i 0 height mul 8 div put + bhs i 8 height mul 8 div put + } if + } for + + /retval 4 dict def + retval (bbs) bbs put + retval (bhs) bhs put + retval (sbs) [bhs length 1 sub {1.44 1.872} repeat 1.44] put + retval (opt) useropts put + retval + + end + +} bind def +/onecode load 0 1 dict put +% --END ENCODER onecode-- + +% --BEGIN ENCODER postnet-- +% --DESC: United States Postal Service Postnet +% --EXAM: 012345 +/postnet { + + % Thanks to Ross McFarland + + 0 begin + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includetext false def % Enable/disable text + /includecheckintext false def + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 0.125 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + /barlen barcode length def + + % Create an array containing the character mappings + /encs + [ (55222) (22255) (22525) (22552) (25225) + (25252) (25522) (52225) (52252) (52522) + (5) (5) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + + /bhs barlen 5 mul 7 add array def + /txt barlen 1 add array def + + % Put start character + /enc encs 10 get def + /heights enc length array def + 0 1 enc length 1 sub { + /j exch def + heights j enc j 1 getinterval cvi height mul 5 div put + } for + bhs 0 heights putinterval % Put encoded digit into sbs + + /checksum 0 def + 0 1 barlen 1 sub { + /i exch def + % Lookup the encoding for the each barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + /heights enc length array def + 0 1 enc length 1 sub { + /j exch def + heights j enc j 1 getinterval cvi height mul 5 div put + } for + bhs i 5 mul 1 add heights putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 5 mul 1 add 3.312 mul textpos textfont textsize] put + /checksum checksum indx add def % checksum+=indx + } for + + % Put the checksum character + /checksum 10 checksum 10 mod sub 10 mod def + /enc encs checksum get def + /heights enc length array def + 0 1 enc length 1 sub { + /j exch def + heights j enc j 1 getinterval cvi height mul 5 div put + } for + bhs barlen 5 mul 1 add heights putinterval + + includecheckintext { + txt barlen [barchars checksum 1 getinterval barlen 5 mul 1 add 3.312 mul textpos textfont textsize] put + } { + txt barlen [( ) barlen 5 mul 1 add 72 mul 25 div textpos textfont textsize] put + } ifelse + + % Put end character + /enc encs 11 get def + /heights enc length array def + 0 1 enc length 1 sub { + /j exch def + heights j enc j 1 getinterval cvi height mul 5 div put + } for + bhs barlen 5 mul 6 add heights putinterval + + /retval 1 dict def + retval (bhs) bhs put + retval (bbs) [bhs length {0} repeat] put + retval (sbs) [bhs length 1 sub {1.44 1.872} repeat 1.44] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/postnet load 0 1 dict put +% --END ENCODER postnet-- + +% --BEGIN ENCODER royalmail-- +% --DESC: Royal Mail 4 State Customer Code (RM4SCC) +% --EXAM: LE28HS9Z +/royalmail { + + 0 begin + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includetext false def % Enable/disable text + /includecheckintext false def + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 0.175 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + % Create an array containing the character mappings + /encs + [ (3300) (2211) (2301) (2310) (3201) (3210) + (1122) (0033) (0123) (0132) (1023) (1032) + (1302) (0213) (0303) (0312) (1203) (1212) + (1320) (0231) (0321) (0330) (1221) (1230) + (3102) (2013) (2103) (2112) (3003) (3012) + (3120) (2031) (2121) (2130) (3021) (3030) + (2) (3) + ] def + + % Create a string of the available characters + /barchars (ZUVWXY501234B6789AHCDEFGNIJKLMTOPQRS) def + + /barlen barcode length def + /encstr barlen 4 mul 6 add string def + /txt barlen 1 add array def + + % Put start character + encstr 0 encs 36 get putinterval + + /checksumrow 0 def + /checksumcol 0 def + 0 1 barlen 1 sub { + /i exch def + % Lookup the encoding for the each barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + encstr i 4 mul 1 add enc putinterval + txt i [barcode i 1 getinterval i 4 mul 1 add 3.312 mul textpos textfont textsize] put + /checksumrow checksumrow indx 6 idiv add def + /checksumcol checksumcol indx 6 mod add def + } for + + % Put the checksum character + /checksum checksumrow 6 mod 6 mul checksumcol 6 mod add def + /enc encs checksum get def + encstr barlen 4 mul 1 add enc putinterval + includecheckintext { + txt barlen [barchars checksum 1 getinterval barlen 4 mul 1 add 3.312 mul textpos textfont textsize] put + } { + txt barlen [( ) barlen 4 mul 1 add 3.312 mul textpos textfont textsize] put + } ifelse + + % Put end character + encstr barlen 4 mul 5 add encs 37 get putinterval + + /bbs encstr length array def + /bhs encstr length array def + 0 1 encstr length 1 sub { + /i exch def + /enc encstr i 1 getinterval def + enc (0) eq { + bbs i 3 height mul 8 div put + bhs i 2 height mul 8 div put + } if + enc (1) eq { + bbs i 0 height mul 8 div put + bhs i 5 height mul 8 div put + } if + enc (2) eq { + bbs i 3 height mul 8 div put + bhs i 5 height mul 8 div put + } if + enc (3) eq { + bbs i 0 height mul 8 div put + bhs i 8 height mul 8 div put + } if + } for + + /retval 4 dict def + retval (bbs) bbs put + retval (bhs) bhs put + retval (sbs) [bhs length 1 sub {1.44 1.872} repeat 1.44] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/royalmail load 0 1 dict put +% --END ENCODER royalmail-- + +% --BEGIN ENCODER auspost-- +% --DESC: AusPost 4 State Customer Code +% --EXAM: 5956439111ABA 9 +/auspost { + + 0 begin + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includetext false def % Enable/disable text + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 0.175 def + /custinfoenc (character) def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + % Create an array containing the character mappings + /encs + [ (000) (001) (002) (010) (011) (012) (020) (021) + (022) (100) (101) (102) (110) (111) (112) (120) + (121) (122) (200) (201) (202) (210) (211) (212) + (220) (221) (222) (300) (301) (302) (310) (311) + (312) (320) (321) (322) (023) (030) (031) (032) + (033) (103) (113) (123) (130) (131) (132) (133) + (203) (213) (223) (230) (231) (232) (233) (303) + (313) (323) (330) (331) (332) (333) (003) (013) + (00) (01) (02) (10) (11) (12) (20) (21) (22) (30) + (13) (3) + ] def + + % Create a string of the available characters + /barchars (ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz #) def + + /barlen barcode length def + barcode 0 2 getinterval (11) eq {37} if + barcode 0 2 getinterval (59) eq {52} if + barcode 0 2 getinterval (62) eq {67} if + /encstr exch string def + /txt barlen 2 sub array def + + % Put start character + encstr 0 encs 74 get putinterval + + % Encode the FCC + 0 1 1 { + /i exch def + encs barcode i 1 getinterval cvi 64 add get + encstr i 2 mul 2 add 3 2 roll putinterval + } for + + % Encode the DPID + 2 1 9 { + /i exch def + encs barcode i 1 getinterval cvi 64 add get + encstr i 2 mul 2 add 3 2 roll putinterval + txt i 2 sub [barcode i 1 getinterval i 2 sub 2 mul 6 add 3.312 mul textpos textfont textsize] put + } for + + % Encode the customer information + custinfoenc (numeric) eq { + 0 1 barlen 11 sub { + /i exch def + encs barcode i 10 add 1 getinterval cvi 64 add get + encstr i 2 mul 22 add 3 2 roll putinterval + txt i 8 add [barcode i 10 add 1 getinterval i 2 mul 22 add 3.312 mul textpos textfont textsize] put + } for + /ciflen barlen 10 sub 2 mul def + } { + 0 1 barlen 11 sub { + /i exch def + barcode i 10 add 1 getinterval barchars exch search + pop + length /indx exch def + pop pop + /enc encs indx get def + encstr i 3 mul 22 add enc putinterval + txt i 8 add [barcode i 10 add 1 getinterval i 3 mul 22 add 3.312 mul textpos textfont textsize] put + } for + /ciflen barlen 10 sub 3 mul def + } ifelse + + % Add any filler characters + 22 ciflen add 1 encstr length 14 sub { + encstr exch encs 75 get putinterval + } for + + % Create the 64x64 Reed-Solomon table + /rstable 64 64 mul array def + rstable 0 [ 64 {0} repeat ] putinterval + rstable 64 [ 0 1 63 {} for ] putinterval + /prev 1 def + 64 { + /next prev 1 bitshift def + next 64 and 0 ne { + /next next 67 xor def + } if + 0 1 63 { + /j exch def + /nextcell {rstable 64 next mul j add} def + nextcell rstable 64 prev mul j add get 1 bitshift put + nextcell get 64 and 0 ne { + nextcell nextcell get 67 xor put + } if + } for + /prev next def + } repeat + + % Calculate the Reed-Solomon codes for triples + /rscodes encstr length 16 sub 3 idiv 4 add array def + rscodes 0 [ 4 {0} repeat ] putinterval + 2 3 encstr length 16 sub { + /i exch def + rscodes rscodes length i 2 sub 3 idiv sub 1 sub + encstr i 1 getinterval cvi 16 mul + encstr i 1 add 1 getinterval cvi 4 mul add + encstr i 2 add 1 getinterval cvi add + put + } for + rscodes length 5 sub -1 0 { + /i exch def + 0 1 4 { + /j exch def + rscodes i j add rscodes i j add get + rstable 64 [48 17 29 30 1] j get mul rscodes i 4 add get add get + xor put + } for + } for + /checkcode (000000000000) def + 0 1 3 { + /i exch def + /enc rscodes 3 i sub get 4 3 string cvrs def + checkcode i 3 mul 3 enc length sub add enc putinterval + } for + + % Put checkcode and end characters + encstr encstr length 14 sub checkcode putinterval + encstr encstr length 2 sub encs 74 get putinterval + + /bbs encstr length array def + /bhs encstr length array def + 0 1 encstr length 1 sub { + /i exch def + /enc encstr i 1 getinterval def + enc (0) eq { + bbs i 0 height mul 8 div put + bhs i 8 height mul 8 div put + } if + enc (1) eq { + bbs i 3 height mul 8 div put + bhs i 5 height mul 8 div put + } if + enc (2) eq { + bbs i 0 height mul 8 div put + bhs i 5 height mul 8 div put + } if + enc (3) eq { + bbs i 3 height mul 8 div put + bhs i 2 height mul 8 div put + } if + } for + + /retval 4 dict def + retval (bbs) bbs put + retval (bhs) bhs put + retval (sbs) [bhs length 1 sub {1.44 1.872} repeat 1.44] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/auspost load 0 1 dict put +% --END ENCODER auspost-- + +% --BEGIN ENCODER kix-- +% --DESC: Royal Dutch TPG Post KIX 4-State Barcode +% --EXAM: 1231FZ13XHS +/kix { + + 0 begin + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includetext false def % Enable/disable text + /includecheckintext false def + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 0.175 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + % Create an array containing the character mappings + /encs + [ (0033) (0123) (0132) (1023) (1032) (1122) + (0213) (0303) (0312) (1203) (1212) (1302) + (0231) (0321) (0330) (1221) (1230) (1320) + (2013) (2103) (2112) (3003) (3012) (3102) + (2031) (2121) (2130) (3021) (3030) (3120) + (2211) (2301) (2310) (3201) (3210) (3300) + ] def + + % Create a string of the available characters + /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ) def + + /barlen barcode length def + /encstr barlen 4 mul string def + /txt barlen array def + + 0 1 barlen 1 sub { + /i exch def + % Lookup the encoding for the each barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + encstr i 4 mul enc putinterval + txt i [barcode i 1 getinterval i 4 mul 3.312 mul textpos textfont textsize] put + } for + + /bbs encstr length array def + /bhs encstr length array def + 0 1 encstr length 1 sub { + /i exch def + /enc encstr i 1 getinterval def + enc (0) eq { + bbs i 3 height mul 8 div put + bhs i 2 height mul 8 div put + } if + enc (1) eq { + bbs i 0 height mul 8 div put + bhs i 5 height mul 8 div put + } if + enc (2) eq { + bbs i 3 height mul 8 div put + bhs i 5 height mul 8 div put + } if + enc (3) eq { + bbs i 0 height mul 8 div put + bhs i 8 height mul 8 div put + } if + } for + + /retval 4 dict def + retval (bbs) bbs put + retval (bhs) bhs put + retval (sbs) [bhs length 1 sub {1.44 1.872} repeat 1.44] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/kix load 0 1 dict put +% --END ENCODER kix-- + +% --BEGIN ENCODER msi-- +% --DESC: MSI Modified Plessey +% --EXAM: 0123456789 +/msi { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includecheck false def % Enable/disable checkdigit + /includetext false def % Enable/disable text + /includecheckintext false def + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + % Create an array containing the character mappings + /encs + [ (13131313) (13131331) (13133113) (13133131) (13311313) + (13311331) (13313113) (13313131) (31131313) (31131331) + (31) (131) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + + /barlen barcode length def % Length of the code + + includecheck { + /sbs barlen 8 mul 13 add string def + /txt barlen 1 add array def + } { + /sbs barlen 8 mul 5 add string def + /txt barlen array def + } ifelse + + + % Put start character + sbs 0 encs 10 get putinterval + /checksum 0 def + + 0 1 barlen 1 sub { + /i exch def + % Lookup the encoding for the each barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + sbs i 8 mul 2 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 16 mul 4 add textpos textfont textsize] put + barlen i sub 2 mod 0 eq { + /checksum indx checksum add def + } { + /checksum indx 2 mul dup 10 idiv add checksum add def + } ifelse + } for + + % Put the checksum and end characters + includecheck { + /checksum 10 checksum 10 mod sub 10 mod def + sbs barlen 8 mul 2 add encs checksum get putinterval + includecheckintext { + txt barlen [barchars checksum 1 getinterval barlen 16 mul 4 add textpos textfont textsize] put + } { + txt barlen [( ) barlen 16 mul 4 add textpos textfont textsize] put + } ifelse + sbs barlen 8 mul 10 add encs 11 get putinterval + } { + sbs barlen 8 mul 2 add encs 11 get putinterval + } ifelse + + % Return the arguments + /retval 1 dict def + retval (sbs) [sbs {48 sub} forall] put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/msi load 0 1 dict put +% --END ENCODER msi-- + +% --BEGIN ENCODER plessey-- +% --DESC: Plessey +% --EXAM: 01234ABCD +/plessey { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /useropts options def + /barcode exch def % We are given a barcode string + + /includetext false def % Enable/disable text + /includecheckintext false def + /textfont /Courier def + /textsize 10 def + /textpos -7 def + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /textfont textfont cvlit def + /textsize textsize cvr def + /textpos textpos cvr def + /height height cvr def + + % Create an array containing the character mappings + /encs + [ (13131313) (31131313) (13311313) (31311313) + (13133113) (31133113) (13313113) (31313113) + (13131331) (31131331) (13311331) (31311331) + (13133131) (31133131) (13313131) (31313131) + (31311331) (331311313) + ] def + + % Create a string of the available characters + /barchars (0123456789ABCDEF) def + + /barlen barcode length def % Length of the code + /sbs barlen 8 mul 33 add string def + /txt barlen 2 add array def + /checkbits barlen 4 mul 8 add array def + checkbits barlen 4 mul [ 0 0 0 0 0 0 0 0 ] putinterval + + % Put start character + sbs 0 encs 16 get putinterval + + 0 1 barlen 1 sub { + /i exch def + % Lookup the encoding for the each barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + sbs i 8 mul 8 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 16 mul 16 add textpos textfont textsize] put + checkbits i 4 mul [ + indx 1 and + indx -1 bitshift 1 and + indx -2 bitshift 1 and + indx -3 bitshift + ] putinterval + } for + + % Checksum is last 8 bits of a CRC using a salt + /checksalt [ 1 1 1 1 0 1 0 0 1 ] def + 0 1 barlen 4 mul 1 sub { + /i exch def + checkbits i get 1 eq { + 0 1 8 { + /j exch def + checkbits i j add checkbits i j add get checksalt j get xor put + } for + } if + } for + + % Calculate the value of the checksum digits + /checkval 0 def + 0 1 7 { + /i exch def + /checkval checkval 2 7 i sub exp cvi checkbits barlen 4 mul i add get mul add def + } for + + % Put the checksum characters + /checksum1 checkval -4 bitshift def + /checksum2 checkval 15 and def + sbs barlen 8 mul 8 add encs checksum1 get putinterval + sbs barlen 8 mul 16 add encs checksum2 get putinterval + includecheckintext { + txt barlen [barchars checksum1 1 getinterval barlen 16 mul 16 add textpos textfont textsize] put + txt barlen 1 add [barchars checksum2 1 getinterval barlen 1 add 16 mul 16 add textpos textfont textsize] put + } { + txt barlen [( ) barlen 16 mul 16 add textpos textfont textsize] put + txt barlen 1 add [( ) barlen 1 add 16 mul 16 add textpos textfont textsize] put + } ifelse + + % Put end character + sbs barlen 8 mul 24 add encs 17 get putinterval + + % Return the arguments + /retval 1 dict def + retval (sbs) [sbs {48 sub} forall] put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + includetext { + retval (txt) txt put + } if + retval (opt) useropts put + retval + + end + +} bind def +/plessey load 0 1 dict put +% --END ENCODER plessey-- + +% --BEGIN ENCODER raw-- +% --DESC: Raw bar space succession for custom symbologies +% --EXAM: 331132131313411122131311333213114131131221323 +/raw { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /useropts options def + /sbs exch def % We are given a barcode string + + /height 1 def + + % Parse the input options + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + /height height cvr def + + % Return the arguments + /retval 1 dict def + retval (sbs) [sbs {48 sub} forall] put + retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put + retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put + retval (opt) useropts put + retval + + end + +} bind def +/raw load 0 1 dict put +% --END ENCODER raw-- + +% --BEGIN ENCODER symbol-- +% --DESC: Miscellaneous symbols +% --EXAM: fima +/symbol { + + 0 begin % Confine variables to local scope + + /options exch def % We are given an option string + /barcode exch def % We are given a barcode string + + barcode (fima) eq { + /sbs [2.25 2.25 2.25 11.25 2.25 11.25 2.25 2.25 2.25] def + /bhs [.625 .625 .625 .625 .625] def + /bbs [0 0 0 0 0] def + } if + + barcode (fimb) eq { + /sbs [2.25 6.75 2.25 2.25 2.25 6.25 2.25 2.25 2.25 6.75 2.25] def + /bhs [.625 .625 .625 .625 .625 .625] def + /bbs [0 0 0 0 0 0] def + } if + + barcode (fimc) eq { + /sbs [2.25 2.25 2.25 6.75 2.25 6.75 2.25 6.75 2.25 2.25 2.25] def + /bhs [.625 .625 .625 .625 .625 .625] def + /bbs [0 0 0 0 0 0] def + } if + + barcode (fimd) eq { + /sbs [2.25 2.25 2.25 2.25 2.25 6.75 2.25 6.75 2.25 2.25 2.25 2.25 2.25] def + /bhs [.625 .625 .625 .625 .625 .625 .625] def + /bbs [0 0 0 0 0 0 0] def + } if + + % Return the arguments + /retval 4 dict def + retval (sbs) sbs put + retval (bhs) bhs put + retval (bbs) bbs put + retval (opt) options put + retval + + end + +} bind def +/symbol load 0 1 dict put +% --END ENCODER symbol-- + +% --BEGIN RENDERER-- +/barcode { + + 0 begin % Confine variables to local scope + + /args exch def % We are given some arguments + + % Default options + /sbs [] def + /bhs [] def + /bbs [] def + /txt [] def + /barcolor (unset) def + /textcolor (unset) def + /bordercolor (unset) def + /backgroundcolor (unset) def + /inkspread 0.15 def + /width 0 def + /barratio 1 def + /spaceratio 1 def + /showborder false def + /borderleft 10 def + /borderright 10 def + /bordertop 1 def + /borderbottom 1 def + /borderwidth 0.5 def + /guardwhitespace false def + /guardleftpos 0 def + /guardleftypos 0 def + /guardrightpos 0 def + /guardrightypos 0 def + /guardwidth 6 def + /guardheight 7 def + + % Apply the renderer options + args {exch cvlit exch def} forall + + % Parse the user options + opt { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + + /barcolor barcolor cvlit def + /textcolor textcolor cvlit def + /bordercolor bordercolor cvlit def + /backgroundcolor backgroundcolor cvlit def + /inkspread inkspread cvr def + /width width cvr def + /barratio barratio cvr def + /spaceratio spaceratio cvr def + /borderleft borderleft cvr def + /borderright borderright cvr def + /bordertop bordertop cvr def + /borderbottom borderbottom cvr def + /borderwidth borderwidth cvr def + /guardleftpos guardleftpos cvr def + /guardleftypos guardleftypos cvr def + /guardrightpos guardrightpos cvr def + /guardrightypos guardrightypos cvr def + /guardwidth guardwidth cvr def + /guardheight guardheight cvr def + + % Create bar elements and put them into the bars array + /bars sbs length 1 add 2 idiv array def + /x 0.00 def /maxh 0 def + 0 1 sbs length 1 add 2 idiv 2 mul 2 sub { + /i exch def + i 2 mod 0 eq { % i is even + /d sbs i get barratio mul barratio sub 1 add def % d=digit*r-r+1 + /h bhs i 2 idiv get 72 mul def % Height from bhs + /c d 2 div x add def % Centre of the bar = x + d/2 + /y bbs i 2 idiv get 72 mul def % Baseline from bbs + /w d inkspread sub def % bar width = digit - inkspread + bars i 2 idiv [h c y w] put % Add the bar entry + h maxh gt {/maxh h def} if + } { + /d sbs i get spaceratio mul spaceratio sub 1 add def % d=digit*r-r+1 + } ifelse + /x x d add def % x+=d + } for + + gsave + + currentpoint translate + + % Force symbol to given width + width 0 ne { + width 72 mul x div 1 scale + } if + + % Display the border and background + newpath + borderleft neg borderbottom neg moveto + x borderleft add borderright add 0 rlineto + 0 maxh borderbottom add bordertop add rlineto + x borderleft add borderright add neg 0 rlineto + 0 maxh borderbottom add bordertop add neg rlineto + closepath + backgroundcolor (unset) ne { + gsave + (< >) dup 1 backgroundcolor putinterval cvx exec {255 div} forall setrgbcolor + fill + grestore + } if + showborder { + gsave + bordercolor (unset) ne { + (< >) dup 1 bordercolor putinterval cvx exec {255 div} forall setrgbcolor + } if + borderwidth setlinewidth stroke + grestore + } if + + % Display the bars for elements in the bars array + gsave + barcolor (unset) ne { + (< >) dup 1 barcolor putinterval cvx exec {255 div} forall setrgbcolor + } if + bars { + {} forall + newpath setlinewidth moveto 0 exch rlineto stroke + } forall + grestore + + % Display the text for elements in the text array + textcolor (unset) ne { + (< >) dup 1 textcolor putinterval cvx exec {255 div} forall setrgbcolor + } if + /s 0 def /f () def + txt { + {} forall + 2 copy s ne exch f ne or { + 2 copy /s exch def /f exch def + exch findfont exch scalefont setfont + } { + pop pop + } ifelse + moveto show + } forall + + % Display the guard elements + guardwhitespace { + 0.75 setlinewidth + guardleftpos 0 ne { + newpath + guardleftpos neg guardwidth add guardleftypos guardwidth 2 div add moveto + guardwidth neg guardheight -2 div rlineto + guardwidth guardheight -2 div rlineto + stroke + } if + guardrightpos 0 ne { + newpath + guardrightpos x add guardwidth sub guardrightypos guardheight 2 div add moveto + guardwidth guardheight -2 div rlineto + guardwidth neg guardheight -2 div rlineto + stroke + } if + } if + + grestore + + end + +} bind def +/barcode load 0 1 dict put +% --END RENDERER-- + +% --END TEMPLATE-- diff --git a/kbarcode/barcodecombo.cpp b/kbarcode/barcodecombo.cpp new file mode 100644 index 0000000..1aadc7d --- /dev/null +++ b/kbarcode/barcodecombo.cpp @@ -0,0 +1,341 @@ +/*************************************************************************** + barcodecombo.cpp - description + ------------------- + begin : Son Apr 13 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "barcodecombo.h" +#include "barcodedialogs.h" +#include "barkode.h" +#include "tokendialog.h" + +#include <pcre.h> + +// Qt includes +#include <qcheckbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qregexp.h> +#include <qstring.h> +#if QT_VERSION >= 0x030100 + #include <ktextedit.h> +#else + #include <qtextedit.h> +#endif + +// KDE includes +#include <kiconloader.h> +#include <knuminput.h> +#include <klineedit.h> +#include <klocale.h> +#include <kpushbutton.h> + +BarcodeValidator::BarcodeValidator( QObject* parent, const char* name ) + : QValidator( parent, name ) +{ + m_valid = NULL; + m_notValid = NULL; +} + +bool BarcodeValidator::pcreValidate( QString* pattern, const QString & input ) const +{ + const char* error; + const int ovector_size = 12; + int erroffset; + pcre* compiled; + int ovector[ovector_size]; + int result; + + if( !pattern || input.isEmpty() ) + return true; + + if( pattern->isEmpty() ) + return true; + + compiled = pcre_compile( pattern->latin1(), 0, &error, &erroffset, NULL ); + if( !compiled ) // ignore all errors + return true; + + result = pcre_exec( compiled, NULL, input.latin1(), input.length(), 0, 0, ovector, ovector_size ); + + return (result >= 1); +} + +QValidator::State BarcodeValidator::validate( QString & input, int & pos ) const +{ + if( (!m_valid && !m_notValid) || input.isEmpty() ) + return Acceptable; + + if( (m_valid && m_valid->isEmpty()) && (m_notValid && m_notValid->isEmpty()) ) + return Acceptable; + + if( pcreValidate( m_valid, input ) && !pcreValidate( m_notValid, input ) ) + return Acceptable; + else + return Intermediate; + + return Acceptable; +} + +BarcodeCombo::BarcodeCombo(QWidget *parent, const char *name ) + : KComboBox( false, parent, name ) + +{ + this->insertStringList( *Barkode::encodingTypes() ); +} + +BarcodeCombo::~BarcodeCombo() +{ +} + +const char* BarcodeCombo::getEncodingType() +{ + return Barkode::typeFromName( currentText() ); +} + +void BarcodeCombo::setEncodingType( const QString & type ) +{ + const QString name = Barkode::nameFromType( type ); + for( unsigned int z = 0; z < (unsigned int)count(); z++ ) + if( text( z ) == name ) + { + setCurrentItem( z ); + break; + } +} + +BarcodeWidget::BarcodeWidget(QWidget *parent, const char *name ) + : QWidget( parent, name ), m_validator( this ) +{ + m_token = NULL; + + QGridLayout* grid = new QGridLayout( this, 6, 6 ); + + labelStandard = new QLabel( i18n( "&Encoding Type:" ), this ); + grid->addWidget( labelStandard, 1, 0 ); + + comboStandard = new BarcodeCombo( this, "comboStandard" ); + connect( comboStandard, SIGNAL( activated(int) ), this, SLOT( encodingChanged() ) ); + connect( comboStandard, SIGNAL( activated(int) ), this, SLOT( changed() ) ); + grid->addMultiCellWidget( comboStandard, 1, 1, 1, 3 ); + labelStandard->setBuddy( comboStandard ); + + labelData = new QLabel( i18n( "&Value:" ), this ); + grid->addWidget( labelData, 2, 0 ); + + data = new KLineEdit( this, "data" ); + + labelData->setBuddy( data ); + connect( data, SIGNAL( textChanged( const QString & ) ), this, SLOT( changed() ) ); + connect( data, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotValidateValue() ) ); + grid->addMultiCellWidget( data, 2, 2, 1, 3 ); + +#if QT_VERSION >= 0x030100 + multi = new KTextEdit( this ); +#else + multi = new QTextEdit( this ); +#endif + multi->setTextFormat( QTextEdit::PlainText ); + multi->setWordWrap( QTextEdit::NoWrap ); + multi->setEnabled( false ); + multi->setVScrollBarMode( QScrollView::AlwaysOn ); + multi->setHScrollBarMode( QScrollView::AlwaysOn ); + multi->hide(); + connect( multi, SIGNAL( textChanged() ), this, SLOT( changed() ) ); + grid->addMultiCellWidget( multi, 3, 3, 1, 3 ); + + checkText = new QCheckBox( this, "checkText" ); + checkText->setText( i18n( "&Display text" ) ); + checkText->setChecked( true ); + connect( checkText, SIGNAL( clicked() ), this, SLOT( changed() ) ); + grid->addWidget( checkText, 4, 1 ); + + buttonAdvanced = new KPushButton( i18n("&Advanced..."), this ); +// buttonAdvanced->setEnabled( false ); + grid->addWidget( buttonAdvanced, 4, 2 ); + + buttonToken = new KPushButton( i18n("&Insert Data Field..."), this ); + buttonToken->setIconSet( QIconSet( SmallIcon("contents") ) ); + grid->addWidget( buttonToken, 4, 3 ); + + spinMargin = new KIntNumInput( this, "spinMargin" ); + spinMargin->setLabel( i18n( "&Margin:" ), KNumInput::AlignLeft | KNumInput::AlignVCenter ); + spinMargin->setRange( 0, 10000, 1, false ); + spinMargin->setValue( 10 ); + connect( spinMargin, SIGNAL( valueChanged(int) ), this, SLOT( changed() ) ); + grid->addMultiCellWidget( spinMargin, 5, 5, 0, 1 ); + + spinRotation = new KIntNumInput( this ); + spinRotation->setLabel( i18n( "&Rotation:" ), KNumInput::AlignLeft | KNumInput::AlignVCenter ); + spinRotation->setRange( 0, 360, 90, false ); + spinRotation->setValue( 0 ); + connect( spinRotation, SIGNAL( valueChanged(int) ), this, SLOT( changed() ) ); + grid->addMultiCellWidget( spinRotation, 5, 5, 2, 3 ); + + spinScale = new KIntNumInput( spinMargin, 1000, this ); + spinScale->setLabel( i18n("&Scale (in permille):"), KNumInput::AlignLeft | KNumInput::AlignVCenter ); + spinScale->setRange( 100, 10000, 100, false ); + spinScale->setValue( 1000 ); + connect( spinScale, SIGNAL( valueChanged(int) ), this, SLOT( changed() ) ); + grid->addMultiCellWidget( spinScale, 6, 6, 0, 1 ); + + spinCut = new KIntNumInput( spinRotation, 100, this ); + spinCut->setLabel( i18n("&Crop:"), KNumInput::AlignLeft | KNumInput::AlignVCenter ); + spinCut->setRange( 1, 100, 1, false ); + connect( spinCut, SIGNAL( valueChanged(int) ), this, SLOT( changed() ) ); + grid->addMultiCellWidget( spinCut, 6, 6, 2, 3 ); + + connect( buttonAdvanced, SIGNAL( clicked() ), this, SLOT( advanced() ) ); + connect( buttonToken, SIGNAL( clicked() ), this, SLOT( tokens() ) ); + + m_enabledata = true; + m_multi = false; + encodingChanged(); +} + +void BarcodeWidget::getData( Barkode & barcode ) +{ + // make sure all changes are applied to the barcode + // even if not all widgets have emitted their changed SIGNAL yet + this->changed(); + + barcode = m_barcode; +} + +void BarcodeWidget::setData( const Barkode & b ) +{ + comboStandard->setEncodingType( b.type() ); + encodingChanged(); + if( !m_multi ) + data->setText( b.value() ); + else + multi->setText( b.value() ); + + checkText->setChecked( b.textVisible() ); + + spinMargin->setValue( b.quietZone() ); + spinRotation->setValue( b.rotation() ); + spinCut->setValue( int(b.cut()*100) ); + spinScale->setValue( int(b.scaling()*1000) ); + + m_barcode = b; +} + +void BarcodeWidget::setStandardEnabled( bool b ) +{ + labelStandard->setEnabled( b ); + comboStandard->setEnabled( b ); +} + +void BarcodeWidget::setDataEnabled( bool b ) +{ + labelData->setEnabled( b ); + m_enabledata = b; + encodingChanged(); +} + +void BarcodeWidget::defaults() +{ + Barkode b; // get's automatically initialized with default values + setData( b ); +} + +void BarcodeWidget::encodingChanged() +{ + QString* validator; + QString* validatorNot; + + spinCut->setEnabled( Barkode::hasFeature( comboStandard->getEncodingType(), NOCUT ) ? false : true ); + if( !spinCut->isEnabled() ) + spinCut->setValue( 100 ); // TODO: Don't hardcode + + spinScale->setEnabled( Barkode::hasFeature( comboStandard->getEncodingType(), NOSCALE ) ? false : true ); + if( !spinScale->isEnabled() ) + spinScale->setValue( 1000 ); // TODO: Don't hardcode + + checkText->setEnabled( Barkode::hasFeature( comboStandard->getEncodingType(), NOTEXT ) ? false : true ); + + if( Barkode::hasFeature( comboStandard->getEncodingType(), MULTILINE ) ) { + buttonToken->setEnabled( m_enabledata ); + multi->setEnabled( m_enabledata ); + multi->show(); + multi->setFocus(); + data->setEnabled( false ); + m_multi = true; + } else { + buttonToken->setEnabled( m_enabledata ); + data->setEnabled( m_enabledata ); + multi->hide(); + data->setFocus(); + multi->setEnabled( false ); + m_multi = false; + } + + validator = Barkode::validatorFromType( comboStandard->getEncodingType() ); + validatorNot = Barkode::validatorNotFromType( comboStandard->getEncodingType() ); + if( validator || validatorNot ) + { + m_validator.setRegExp( validator, validatorNot ); + data->setValidator( &m_validator ); + } + else + data->setValidator( NULL ); + + slotValidateValue(); +} + +void BarcodeWidget::advanced() +{ + AdvancedBarcodeDialog abd( comboStandard->getEncodingType(), this, "abd" ); + abd.setData( &m_barcode ); + if( abd.exec() == QDialog::Accepted ) + abd.getData( &m_barcode ); +} + +void BarcodeWidget::tokens() +{ + TokenDialog tokendlg( m_token, this, "tokendlg" ); + if( tokendlg.exec() == QDialog::Accepted ) + { + if( data->isEnabled() ) + data->insert( tokendlg.token() ); + else + multi->insert( tokendlg.token() ); + } +} + +void BarcodeWidget::slotValidateValue() +{ + QColor c = data->hasAcceptableInput() ? this->foregroundColor() : Qt::red; + + data->setPaletteForegroundColor( c ); +} + +void BarcodeWidget::changed() +{ + if( !m_multi ) + m_barcode.setValue( data->text() ); + else + m_barcode.setValue( multi->text() ); + + m_barcode.setType( comboStandard->getEncodingType() ); + m_barcode.setTextVisible( checkText->isChecked() ); + + m_barcode.setQuietZone( spinMargin->value() ); + m_barcode.setRotation( spinRotation->value() ); + m_barcode.setCut( (double)spinCut->value()/100.0 ); + m_barcode.setScaling( (double)spinScale->value()/1000.0 ); +} + +#include "barcodecombo.moc" diff --git a/kbarcode/barcodecombo.h b/kbarcode/barcodecombo.h new file mode 100644 index 0000000..48e1cde --- /dev/null +++ b/kbarcode/barcodecombo.h @@ -0,0 +1,144 @@ +/*************************************************************************** + barcodecombo.h - description + ------------------- + begin : Son Apr 13 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef BARCODECOMBO_H +#define BARCODECOMBO_H + +#include <qvalidator.h> +#include <qwidget.h> +#include <kcombobox.h> + +#include "barkode.h" + +/** A validator that takes to QRegExp's to check + * wether a barcode is valid or not. + */ +class BarcodeValidator : public QValidator { + public: + BarcodeValidator( QObject* parent = 0, const char* name = 0 ); + + QValidator::State validate( QString & input, int & pos ) const; + + /** validate a given input string agains a pattern using + * Perl Compatible Regular Expressions + * \param pattern may be NULL + * \returns true if the pattern matches + */ + bool pcreValidate( QString* pattern, const QString & input ) const; + + inline void setRegExp( QString* valid, QString* notValid ) { + m_valid = valid; + m_notValid = notValid; + } + + private: + QString* m_valid; + QString* m_notValid; +}; + +/** A combobox that lists all barcode encodign types + * supported by KBarcode. + */ +class BarcodeCombo : public KComboBox { + Q_OBJECT + public: + BarcodeCombo(QWidget *parent=0, const char *name=0); + ~BarcodeCombo(); + + const char* getEncodingType(); + void setEncodingType( const QString & type ); +}; + +class KIntNumInput; +class KLineEdit; +class KPushButton; +#if QT_VERSION >= 0x030100 + class KTextEdit; +#else + class QTextEdit; +#endif +class QCheckBox; +class QLabel; + +/** This widget is used in BarCodeDialog and BarcodeSettingsDlg and + * allows the user to change the data of a barcodeData struct. This powerful + * widget is always used when the user has to change some property of + * a barcode. + * + * @see BarCodeDialog, @see BarcodeSettingsDlg + * @author Dominik Seichter + */ +class BarcodeWidget : public QWidget { + Q_OBJECT + public: + BarcodeWidget(QWidget *parent=0, const char *name=0); + ~BarcodeWidget() { } + + void getData( Barkode & barkode ); + void setData( const Barkode & b ); + + void setStandardEnabled( bool b ); + void setDataEnabled( bool b ); + + void defaults(); + + inline void setTokenProvider( TokenProvider* token ); + + private slots: + void encodingChanged(); + void advanced(); + void changed(); + void tokens(); + void slotValidateValue(); + + private: + TokenProvider* m_token; + + BarcodeCombo* comboStandard; + KLineEdit* data; + BarcodeValidator m_validator; + +#if QT_VERSION >= 0x030100 + KTextEdit* multi; +#else + QTextEdit* multi; +#endif + + KIntNumInput* spinMargin; + KIntNumInput* spinScale; + KIntNumInput* spinRotation; + KIntNumInput* spinCut; + QCheckBox* checkText; + + KPushButton* buttonAdvanced; + KPushButton* buttonToken; + + QLabel* labelStandard; + QLabel* labelData; + + bool m_enabledata; + bool m_multi; + + Barkode m_barcode; +}; + +void BarcodeWidget::setTokenProvider( TokenProvider* token ) +{ + m_token = token; +} + +#endif diff --git a/kbarcode/barcodedialog.cpp b/kbarcode/barcodedialog.cpp new file mode 100644 index 0000000..ce6f64d --- /dev/null +++ b/kbarcode/barcodedialog.cpp @@ -0,0 +1,218 @@ +/*************************************************************************** + barcodedialog.cpp - description + ------------------- + begin : Son Dez 29 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "barcodedialog.h" +#include "barcodeitem.h" +#include "printersettings.h" +#include "barcodecombo.h" +#include "mimesources.h" +#include "tokenprovider.h" + +// KDE includes +#include <kapplication.h> +#include <kfiledialog.h> +#include <kiconloader.h> +#include <kimageio.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kprinter.h> +#include <kpushbutton.h> + +// Qt includes +#include <qclipboard.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qpainter.h> +#include <qpaintdevicemetrics.h> +#include <qpicture.h> + +BarCodeDialog::BarCodeDialog( QWidget* parent, const char* name ) + : QDialog( parent, name, false) +{ + setCaption( i18n( "Barcode Generator" ) ); + + BarCodeDialogLayout = new QHBoxLayout( this, 11, 6, "BarCodeDialogLayout"); + Layout5 = new QVBoxLayout( 0, 0, 6, "Layout5"); + Layout6 = new QVBoxLayout( 0, 0, 6, "Layout2"); + widget = new BarcodeWidget( this, "widget" ); + + m_token = new TokenProvider( KApplication::desktop() ); + widget->setTokenProvider( m_token ); + + buttonGenerate = new KPushButton( this, "buttonGenerate" ); + buttonGenerate->setText( i18n( "&Generate" ) ); + buttonGenerate->setEnabled( Barkode::haveBarcode() ); + buttonGenerate->setIconSet( SmallIconSet("barcode") ); + + buttonSave = new KPushButton( this, "buttonSave" ); + buttonSave->setText( i18n( "&Save" ) ); + buttonSave->setEnabled( false ); + buttonSave->setIconSet( SmallIconSet("filesave") ); + + buttonCopy = new KPushButton( this, "buttonCopy" ); + buttonCopy->setText( i18n("&Copy") ); + buttonCopy->setEnabled( false ); + buttonCopy->setIconSet( SmallIconSet("editcopy") ); + + buttonPrint = new KPushButton( this ); + buttonPrint->setText( i18n("&Print") ); + buttonPrint->setEnabled( false ); + buttonPrint->setIconSet( SmallIconSet("fileprint") ); + + buttonClose = new KPushButton( this ); + buttonClose->setText( i18n("&Close" ) ); + buttonClose->setIconSet( SmallIconSet("fileclose") ); + + + QScrollView* sv = new QScrollView( this ); + + barcode = new QLabel( sv->viewport(), "barcode" ); + sv->addChild( barcode ); + connect( buttonGenerate, SIGNAL( clicked() ), this, SLOT( generate() ) ); + connect( buttonSave, SIGNAL( clicked() ), this, SLOT( save() ) ); + connect( buttonPrint, SIGNAL( clicked() ), this, SLOT( print() ) ); + connect( buttonCopy, SIGNAL( clicked() ), this, SLOT( copy() ) ); + + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); + + Layout5->addWidget( buttonGenerate ); + Layout5->addWidget( buttonSave ); + Layout5->addWidget( buttonPrint ); + Layout5->addWidget( buttonCopy ); + Layout5->addItem( spacer ); + Layout5->addWidget( buttonClose ); + + Layout6->addWidget( widget ); + Layout6->addWidget( sv ); + + BarCodeDialogLayout->addLayout( Layout6 ); + BarCodeDialogLayout->addLayout( Layout5 ); + BarCodeDialogLayout->setStretchFactor( Layout6, 2 ); + + connect( buttonClose, SIGNAL( clicked() ), this, SLOT( close() ) ); + + buttonGenerate->setDefault( true ); + + show(); +} + +BarCodeDialog::~BarCodeDialog() +{ + delete m_token; +} + +void BarCodeDialog::generate() +{ + Barkode d; + widget->getData( d ); + d.setTokenProvider( m_token ); + d.update( KApplication::desktop() ); + + barcode->setPixmap( d.pixmap() ); + + buttonSave->setEnabled( !barcode->pixmap()->isNull() ); + buttonPrint->setEnabled( !barcode->pixmap()->isNull() ); + buttonCopy->setEnabled( !barcode->pixmap()->isNull() ); +} + +void BarCodeDialog::save() +{ + Barkode bc; + widget->getData( bc ); + + if(!bc.isValid()) + { + KFileDialog fd( ":save_image", KImageIO::pattern( KImageIO::Writing ), this, "fd", true ); + fd.setMode( KFile::File ); + fd.setOperationMode( KFileDialog::Saving ); + if( fd.exec() == QDialog::Accepted ) + { + QString path = fd.selectedURL().path(); + QString extension = KImageIO::type( path ); + + if( extension.isNull() ) + extension = KImageIO::type( fd.currentFilter() ); + + + bc.setTokenProvider( m_token ); + bc.update( KApplication::desktop() ); + + if(!bc.pixmap().save( path, extension, 0 )) + KMessageBox::error( this, i18n("An error occurred during saving the image") ); + } + } +} + +void BarCodeDialog::print() +{ + Barkode d; + widget->getData( d ); + + if( d.isValid() ) + return; + + KPrinter* printer = PrinterSettings::getInstance()->setupPrinter( "kbarcode", this ); + if( !printer ) + return; + + // unless we can center the barcode + printer->setFullPage( false ); + + QPaintDeviceMetrics metrics( printer ); + + double scalex = (double)metrics.logicalDpiX() / (double)QPaintDevice::x11AppDpiX(); + double scaley = (double)metrics.logicalDpiY() / (double)QPaintDevice::x11AppDpiY(); + + QPicture picture; + QPainter p( printer ); + p.scale( scalex, scaley ); + // TODO: center barcode + + TokenProvider tp( printer ); + + d.setTokenProvider( &tp ); + d.update( printer ); + + picture = d.picture(); + p.drawPicture( QPoint( 0, 0 ), picture ); + p.end(); + + delete printer; +} + +void BarCodeDialog::copy() +{ + if( barcode->pixmap()->isNull() ) + return; + + Barkode bc; + widget->getData( bc ); + + BarcodeItem* item = new BarcodeItem( bc ); + DocumentItemList list; + list.append( item ); + DocumentItemDrag* drag = new DocumentItemDrag(); + drag->setDocumentItem( &list ); + +#if QT_VERSION >= 0x030100 + kapp->clipboard()->setData( drag, QClipboard::Clipboard ); +#else + kapp->clipboard()->setData( drag ); +#endif +} + +#include "barcodedialog.moc" diff --git a/kbarcode/barcodedialog.h b/kbarcode/barcodedialog.h new file mode 100644 index 0000000..9490467 --- /dev/null +++ b/kbarcode/barcodedialog.h @@ -0,0 +1,79 @@ +/*************************************************************************** + barcodedialog.h - description + ------------------- + begin : Son Dez 29 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef BARCODEDIALOG_H +#define BARCODEDIALOG_H + +#include <qdialog.h> + +class BarcodeCombo; +class BarcodeWidget; +class KAction; +class KColorButton; +class KMenuBar; +class KToolBar; +class KIntNumInput; +class KLineEdit; +class KPushButton; +class KPopupMenu; +class QCheckBox; +class QLabel; +class QPixmap; +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class TokenProvider; + +/** This class provides a dialog, where the user can create a single barcode + * and print it, copy it to the clipboard or save it in various image formats. + * This dialog can also be seen as a powerful replacement for e.g. xbarcode. + * + * All barcoding features are available for the user. This dialog allows also + * to just experiment a little bit with barcodes. + */ +class BarCodeDialog : public QDialog +{ + Q_OBJECT + + public: + BarCodeDialog( QWidget* parent = 0, const char* name = 0 ); + ~BarCodeDialog(); + + private: + BarcodeWidget* widget; + TokenProvider* m_token; + + KPushButton* buttonGenerate; + KPushButton* buttonPrint; + KPushButton* buttonSave; + KPushButton* buttonCopy; + KPushButton* buttonClose; + QLabel* barcode; + + private slots: + void generate(); + void save(); + void print(); + void copy(); + + protected: + QHBoxLayout* BarCodeDialogLayout; + QVBoxLayout* Layout6; + QVBoxLayout* Layout5; +}; + +#endif // BARCODEDIALOG_H diff --git a/kbarcode/barcodedialogs.cpp b/kbarcode/barcodedialogs.cpp new file mode 100644 index 0000000..28639a4 --- /dev/null +++ b/kbarcode/barcodedialogs.cpp @@ -0,0 +1,506 @@ +/*************************************************************************** + barcodedialogs.cpp - description + ------------------- + begin : Fre Sep 5 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "barcodedialogs.h" +#include "barkode.h" +#include "purepostscript.h" +#include "tbarcode2.h" + +// Qt includes +#include <qbuttongroup.h> +#include <qcheckbox.h> +#include <qgroupbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qmap.h> +#include <qradiobutton.h> +#include <qtooltip.h> +#include <qvbox.h> +#include <qvgroupbox.h> + +// KDE includes +#include <kcombobox.h> +#include <knuminput.h> +#include <klocale.h> +#include <kcolorbutton.h> + + +AdvancedBarcodeDialog::AdvancedBarcodeDialog( QString type, QWidget* parent, const char* name ) + : KDialogBase( KDialogBase::Tabbed, i18n("Barcode Settings"), + KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, parent,name) +{ + list.setAutoDelete( false ); + + if( Barkode::hasFeature( type, PDF417BARCODE ) ) { + QVBox* box = addVBoxPage( i18n("PDF417") ); + PDF417BarcodeDlg* dlg = new PDF417BarcodeDlg( box ); + list.append( (BarcodeDlgBase*)dlg ); + } + + if( Barkode::hasFeature( type, DATAMATRIX ) ) { + QVBox* box = addVBoxPage( i18n("DataMatrix") ); + DataMatrixDlg* dlg = new DataMatrixDlg( box ); + list.append( (BarcodeDlgBase*)dlg ); + } + + if( Barkode::hasFeature( type, TBARCODEADV ) ) { + QVBox* box = addVBoxPage( i18n("TBarcode") ); + TBarcodeDlg* dlg = new TBarcodeDlg( box ); + list.append( (BarcodeDlgBase*)dlg ); + } + + if( Barkode::hasFeature( type, PUREADV ) ) { + QVBox* box = addVBoxPage( i18n("Barcode Writer in Pure Postscript") ); + PurePostscriptDlg* dlg = new PurePostscriptDlg( box ); + list.append( (BarcodeDlgBase*)dlg ); + } + + if( Barkode::hasFeature( type, COLORED ) ) { + QVBox* box = addVBoxPage( i18n("Colors") ); + ColorDlg* dlg = new ColorDlg( box ); + list.append( (BarcodeDlgBase*)dlg ); + } + + QVBox* box = addVBoxPage( i18n("Sequence") ); + SequenceDlg* dlg = new SequenceDlg( box ); + list.append( (BarcodeDlgBase*)dlg ); +} + +AdvancedBarcodeDialog::~AdvancedBarcodeDialog() +{ +} + +void AdvancedBarcodeDialog::setData( Barkode* b ) +{ + for( unsigned int i = 0; i < list.count(); i++ ) { + BarcodeDlgBase* bdb = list.at( i ); + bdb->setData( b ); + } +} + +void AdvancedBarcodeDialog::getData( Barkode* b ) +{ + for( unsigned int i = 0; i < list.count(); i++ ) { + BarcodeDlgBase* bdb = list.at( i ); + bdb->getData( b ); + } +} + +TBarcodeDlg::TBarcodeDlg(QWidget *parent, const char *name ) + : QWidget( parent, name ) +{ + QVBoxLayout* layout = new QVBoxLayout( this, 6, 6 ); + + QGroupBox* gb = new QGroupBox( i18n("TBarcode"), this ); + gb->setColumnLayout(0, Qt::Vertical ); + gb->layout()->setSpacing( 6 ); + gb->layout()->setMargin( 11 ); + gb->setEnabled( Barkode::haveTBarcode() || Barkode::haveTBarcode2() ); + QVBoxLayout* gbLayout = new QVBoxLayout( gb->layout() ); + + spinModule = new KDoubleNumInput( gb ); + spinModule->setLabel( i18n("Module width (mm):"), AlignLeft | AlignVCenter ); + spinModule->setRange( 0.190, 1.500, 0.001, true ); + + spinHeight = new KIntNumInput( gb ); + spinHeight->setLabel( i18n("Barcode Height (mm):"), AlignLeft | AlignVCenter ); + spinHeight->setRange( 1, 1000, 10, false ); + + checkEscape = new QCheckBox( i18n("&Translate escape sequences"), gb ); + checkAbove = new QCheckBox( i18n("&Text above barcode"), gb ); + checkAutoCorrect = new QCheckBox( i18n("&Auto correction"), gb ); + + comboCheckSum = new KComboBox( false, gb ); + + QLabel* label = new QLabel( i18n("&Checksum calculation method:"), gb ); + label->setBuddy( comboCheckSum ); + + QHBoxLayout * hbox = new QHBoxLayout( 0, 6, 6 ); + hbox->addWidget( label ); + hbox->addWidget( comboCheckSum ); + + gbLayout->addWidget( spinModule ); + gbLayout->addWidget( spinHeight ); + gbLayout->addWidget( checkEscape ); + gbLayout->addWidget( checkAbove ); + gbLayout->addWidget( checkAutoCorrect ); + gbLayout->addLayout( hbox ); + + QToolTip::add( spinModule, i18n("<qt>Change the module with used by tbarcode. Take a look into the " + "tbarcode documentation for details. Normaly you do not want to change " + "this value.</qt>") ); + + layout->addWidget( gb ); +} + +void TBarcodeDlg::setData( Barkode* b ) +{ + TBarcodeOptions* options = dynamic_cast<TBarcodeOptions*>( b->engine()->options() ); + + if( options ) + { + spinModule->setValue( options->moduleWidth() ); + spinHeight->setValue( options->height() ); + checkEscape->setChecked( options->escape() ); + checkAbove->setChecked( options->above() ); + checkAutoCorrect->setChecked( options->autocorrect() ); + + map.insert( i18n("No Checksum"), 0 ); + map.insert( i18n("Default Checksum Method"), 1 ); + + if( Barkode::hasFeature( b->type(), MODULOALLCHECK ) || + Barkode::hasFeature( b->type(), MODULO10CHECK ) ) + map.insert( i18n("Modulo 10 Checksum"), 2 ); + + if( Barkode::hasFeature( b->type(), MODULOALLCHECK ) || + b->type() == "b13" || // EAN 13 + b->type() == "b14" || // EAN 13 + b->type() == "b15" || // EAN 13 + b->type() == "b18" ) // CodaBar (2 width) + map.insert( i18n("Module 43 (suggested for Code39 and Logmars, 1 digit)"), 3 ); + + if( Barkode::hasFeature( b->type(), MODULOALLCHECK ) ) + map.insert( i18n("Modula 47 (2 digits)"), 4 ); + + if( b->type() == "b21" ) // Deutsche Post Leitcode + map.insert( i18n("Deutsche Post Leitcode"), 5 ); + + if( b->type() == "b22") // Deutsche Post Identcode + map.insert( i18n("Deutsche Post Identcode"), 6 ); + + if( b->type() == "b1" ) { // Code11 + map.insert( i18n("Code 11 (1 digit)"), 7 ); + map.insert( i18n("Code 11 (2 digits)"), 8 ); + } + + if( Barkode::hasFeature( b->type(), POSTNETCHECK ) ) + map.insert( i18n("USPS Postnet"), 9 ); + + if( b->type() == "b47" ) { // MSI + map.insert( i18n("MSI (1 digit)"), 10 ); + map.insert( i18n("MSI (2 digits)"), 11 ); + } + + if( b->type() == "b46" ) // Plessey + map.insert( i18n("Plessey"), 12 ); + + if( Barkode::hasFeature( b->type(), EAN8CHECK ) ) + map.insert( i18n("EAN 8"), 13 ); + + if( Barkode::hasFeature( b->type(), EAN13CHECK ) ) + map.insert( i18n("EAN 13"), 14 ); + + if( Barkode::hasFeature( b->type(), UPCACHECK ) ) + map.insert( i18n("UPC A"), 15 ); + + if( Barkode::hasFeature( b->type(), UPCECHECK ) ) + map.insert( i18n("UPC E"), 16 ); + + if( b->type() == "b16" ) // EAN 128 + map.insert( i18n("EAN 128"), 17 ); + + if( Barkode::hasFeature( b->type(), CODE128CHECK ) ) + map.insert( i18n("Code 128"), 18 ); + + if( b->type() == "b70" ) // Royal Mail 4 State + map.insert( i18n("Royal Mail 4 State"), 19 ); + + comboCheckSum->insertStringList( map.keys() ); + + QMap<QString,int>::Iterator it; + for ( it = map.begin(); it != map.end(); ++it ) { + if( it.data() == options->checksum() ) { + for( int i = 0; i < comboCheckSum->count(); i++ ) + if( comboCheckSum->text( i ) == it.key() ) { + comboCheckSum->setCurrentItem( i ); + break; + } + break; + } + } + } +} + +void TBarcodeDlg::getData( Barkode* b ) const +{ + TBarcodeOptions* options = dynamic_cast<TBarcodeOptions*>( b->engine()->options() ); + + if( options ) + { + options->setModuleWidth( spinModule->value() ); + options->setEscape( checkEscape->isChecked() ); + options->setAbove( checkAbove->isChecked() ); + options->setAutocorrect( checkAutoCorrect->isChecked() ); + options->setCheckSum( map[comboCheckSum->currentText()] ); + options->setHeight( spinHeight->value() ); + } +} + +PDF417BarcodeDlg::PDF417BarcodeDlg(QWidget *parent, const char *name ) + : QWidget( parent, name ) +{ + QVBoxLayout* layout = new QVBoxLayout( this, 6, 6 ); + + QGroupBox* gpdf = new QGroupBox( i18n("PDF417"), this ); + gpdf->setColumnLayout(0, Qt::Vertical ); + gpdf->layout()->setSpacing( 6 ); + gpdf->layout()->setMargin( 11 ); + gpdf->setEnabled( Barkode::haveTBarcode() || Barkode::havePDFBarcode() ); + QVBoxLayout* gpdfLayout = new QVBoxLayout( gpdf->layout() ); + + spinRow = new KIntNumInput( gpdf ); + spinRow->setLabel( i18n("Rows:"), AlignLeft | AlignVCenter ); + spinRow->setRange( 0, 90, 1, true ); + + spinCol = new KIntNumInput( spinRow, 0, gpdf ); + spinCol->setLabel( i18n("Columns:"), AlignLeft | AlignVCenter ); + spinCol->setRange( 0, 30, 1, true ); + + spinErr = new KIntNumInput( spinCol, 0, gpdf ); + spinErr->setLabel( i18n("Error correction level:"), AlignLeft | AlignVCenter ); + spinErr->setRange( 1, 8, 1, true ); + + gpdfLayout->addWidget( spinRow ); + gpdfLayout->addWidget( spinCol ); + gpdfLayout->addWidget( spinErr ); + layout->addWidget( gpdf ); +} + +void PDF417BarcodeDlg::setData( Barkode* b ) +{ + PDF417Options* options = dynamic_cast<PDF417Options*>( b->engine()->options() ); + + if( options ) + { + spinRow->setValue( options->row() ); + spinCol->setValue( options->col() ); + spinErr->setValue( options->err() ); + } +} + +void PDF417BarcodeDlg::getData( Barkode* b ) const +{ + PDF417Options* options = dynamic_cast<PDF417Options*>( b->engine()->options() ); + + if( options ) + { + options->setRow( spinRow->value() ); + options->setCol( spinCol->value() ); + options->setErr( spinErr->value() ); + } +} + +DataMatrixDlg::DataMatrixDlg(QWidget *parent, const char *name ) + : QWidget( parent, name ) +{ + QHBoxLayout* datamLayout = new QHBoxLayout( this, 6, 6 ); + + comboDataMatrix = new KComboBox( false, this ); + + datamLayout->addWidget( new QLabel( i18n("Data Matrix symbol sizes (rows x cols):"), this ) ); + datamLayout->addWidget( comboDataMatrix ); + datamLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Minimum ) ); + + comboDataMatrix->insertItem( i18n("Automatic calculation" ) ); + comboDataMatrix->insertItem( "10 x 10" ); + comboDataMatrix->insertItem( "12 x 12" ); + comboDataMatrix->insertItem( "14 x 14" ); + comboDataMatrix->insertItem( "16 x 16" ); + comboDataMatrix->insertItem( "18 x 18" ); + comboDataMatrix->insertItem( "20 x 20" ); + comboDataMatrix->insertItem( "22 x 22" ); + comboDataMatrix->insertItem( "24 x 24" ); + comboDataMatrix->insertItem( "26 x 26" ); + comboDataMatrix->insertItem( "32 x 32" ); + comboDataMatrix->insertItem( "36 x 36" ); + comboDataMatrix->insertItem( "40 x 40" ); + comboDataMatrix->insertItem( "44 x 44" ); + comboDataMatrix->insertItem( "48 x 48" ); + comboDataMatrix->insertItem( "52 x 52" ); + comboDataMatrix->insertItem( "64 x 64" ); + comboDataMatrix->insertItem( "72 x 72" ); + comboDataMatrix->insertItem( "80 x 80" ); + comboDataMatrix->insertItem( "88 x 88" ); + comboDataMatrix->insertItem( "96 x 96" ); + comboDataMatrix->insertItem( "104 x 104" ); + comboDataMatrix->insertItem( "120 x 120" ); + comboDataMatrix->insertItem( "132 x 132" ); + comboDataMatrix->insertItem( "144 x 144" ); + comboDataMatrix->insertItem( "8 x 18" ); + comboDataMatrix->insertItem( "8 x 32" ); + comboDataMatrix->insertItem( "12 x 26" ); + comboDataMatrix->insertItem( "12 x 36" ); + comboDataMatrix->insertItem( "16 x 36" ); + comboDataMatrix->insertItem( "16 x 48" ); +} + +void DataMatrixDlg::setData( Barkode* b ) +{ + comboDataMatrix->setCurrentItem( b->datamatrixSize()); +} + +void DataMatrixDlg::getData( Barkode* b ) const +{ + b->setDatamatrixSize( comboDataMatrix->currentItem() ); +} + +SequenceDlg::SequenceDlg( QWidget *parent, const char *name ) + : QWidget( parent, name ) +{ + QVBoxLayout* main = new QVBoxLayout( this, 6, 6 ); + + QButtonGroup* group = new QButtonGroup( i18n("Sequence"), this ); + group->setColumnLayout(0, Qt::Vertical ); + group->layout()->setSpacing( 6 ); + group->layout()->setMargin( 11 ); + QVBoxLayout* layout = new QVBoxLayout( group->layout() ); + + checkSequence = new QCheckBox( i18n("&Enable sequence"), group ); + + radioNumbers = new QRadioButton( i18n("Iterate over numbers 0-9"), group ); + radioAlpha = new QRadioButton( i18n("Iterate over characters A-Z"), group ); + radioAlphaNum = new QRadioButton( i18n("Iterate over A-Z, 0-9"), group ); + + spinStep = new KIntNumInput( group ); + spinStep->setLabel( i18n("Step:"), AlignLeft | AlignVCenter ); + spinStep->setRange( -100, 100, 1, false ); + + spinStart = new KIntNumInput( spinStep, 1, group ); + spinStart->setLabel( i18n("Start:"), AlignLeft | AlignVCenter ); + spinStart->setRange( -100000, 100000, 1, false ); + + layout->addWidget( checkSequence ); + layout->addWidget( radioNumbers ); + layout->addWidget( radioAlpha ); + layout->addWidget( radioAlphaNum ); + layout->addWidget( spinStep ); + layout->addWidget( spinStart ); + + main->addWidget( group ); + + connect( checkSequence, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioNumbers, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioAlpha, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioAlphaNum, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); +} + +void SequenceDlg::setData( Barkode* b ) +{ + checkSequence->setChecked( b->sequenceEnabled() ); + spinStep->setValue( b->sequenceStep() ); + spinStart->setValue( b->sequenceStart() ); + + if( b->sequenceMode() == NUM ) + radioNumbers->setChecked( true ); + else if( b->sequenceMode() == ALPHA ) + radioAlpha->setChecked( true ); + else if( b->sequenceMode() == ALPHANUM ) + radioAlphaNum->setChecked( true ); + + enableControls(); +} + +void SequenceDlg::getData( Barkode* b ) const +{ + b->setSequenceEnabled( checkSequence->isChecked() ); + + b->setSequenceStep( spinStep->value() ); + b->setSequenceStart( spinStart->value() ); + + if( radioNumbers->isChecked() ) + b->setSequenceMode( NUM ); + else if( radioAlpha->isChecked() ) + b->setSequenceMode( ALPHA ); + else if( radioAlphaNum->isChecked() ) + b->setSequenceMode( ALPHANUM ); +} + +void SequenceDlg::enableControls() +{ + radioNumbers->setEnabled( checkSequence->isChecked() ); + radioAlpha->setEnabled( checkSequence->isChecked() ); + radioAlphaNum->setEnabled( false ); //checkSequence->isChecked() ); + spinStep->setEnabled( checkSequence->isChecked() ); + spinStart->setEnabled( checkSequence->isChecked() && radioNumbers->isChecked() ); +} + +ColorDlg::ColorDlg(QWidget *parent, const char *name) + : QVBox( parent, name ) +{ + QGroupBox* gb = new QGroupBox( i18n("Colors"), this ); + gb->setColumnLayout(0, Qt::Vertical ); + gb->layout()->setSpacing( 6 ); + gb->layout()->setMargin( 11 ); + gb->setEnabled( Barkode::havePurePostscriptBarcode() ); + QGridLayout* gbLayout = new QGridLayout( gb->layout() ); + + buttonBarColor = new KColorButton( gb ); + buttonBackColor = new KColorButton( gb ); + buttonTextColor = new KColorButton( gb ); + + gbLayout->addWidget( new QLabel( i18n("Bar Color:"), gb ), 0, 0 ); + gbLayout->addWidget( new QLabel( i18n("Background Color:"), gb ), 1, 0 ); + gbLayout->addWidget( new QLabel( i18n("Text Color:"), gb ), 2, 0 ); + gbLayout->addWidget( buttonBarColor, 0, 1 ); + gbLayout->addWidget( buttonBackColor, 1, 1 ); + gbLayout->addWidget( buttonTextColor, 2, 1 ); +} + +void ColorDlg::setData( Barkode* b ) +{ + buttonBarColor->setColor( b->foreground() ); + buttonBackColor->setColor( b->background() ); + buttonTextColor->setColor( b->textColor() ); +} + +void ColorDlg::getData( Barkode* b ) const +{ + b->setForeground( buttonBarColor->color() ); + b->setBackground( buttonBackColor->color() ); + b->setTextColor( buttonTextColor->color() ); +} + +PurePostscriptDlg::PurePostscriptDlg(QWidget *parent, const char *name) + : QVBox( parent, name ) +{ + QVGroupBox* gb = new QVGroupBox( i18n("Barcode Writer in Pure Postscript"), this ); + gb->setEnabled( Barkode::havePurePostscriptBarcode() ); + + checkChecksum = new QCheckBox( i18n("Enable &Checksum"), gb ); +} + +void PurePostscriptDlg::setData( Barkode* b ) +{ + PurePostscriptOptions* options = dynamic_cast<PurePostscriptOptions*>( b->engine()->options() ); + + if( options ) + { + checkChecksum->setChecked( options->checksum() ); + checkChecksum->setEnabled( Barkode::hasFeature( b->type(), MODULOALLCHECK ) ); + } +} + +void PurePostscriptDlg::getData( Barkode* b ) const +{ + PurePostscriptOptions* options = dynamic_cast<PurePostscriptOptions*>( b->engine()->options() ); + + if( options ) + options->setChecksum( checkChecksum->isChecked() ); +} + + +#include "barcodedialogs.moc" diff --git a/kbarcode/barcodedialogs.h b/kbarcode/barcodedialogs.h new file mode 100644 index 0000000..56e3a58 --- /dev/null +++ b/kbarcode/barcodedialogs.h @@ -0,0 +1,180 @@ +/*************************************************************************** + barcodedialogs.h - description + ------------------- + begin : Fre Sep 5 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef BARCODEDIALOGS_H +#define BARCODEDIALOGS_H + +#include <qmap.h> +#include <qptrlist.h> +#include <qwidget.h> +#include <qvbox.h> +#include <kdialogbase.h> + +class Barkode; +class KColorButton; +class KComboBox; +class KDoubleNumInput; +class KIntNumInput; +class QCheckBox; +class QRadioButton; + +/** A base class for all widgets, that will be used in AdvancedBarcodeDialog + * to modify the settings of a barcode. The API is simple. You can only set the + * current barcode settings and retrieve them after the user modified them. + * + * @author Dominik Seichter + */ +class BarcodeDlgBase { + public: + virtual void setData( Barkode* b ) = 0; + virtual void getData( Barkode* b ) const = 0; +}; + +/** + * A configuration dialog for advanced barcode settings. + * Used in BarcodeWidget. It loads the wigets below into tabs. + * @see TBarcodeDlg + * @see PDF417BarcodeDlg + * @see DataMatrixDlg + * @seeSequenceDlg + * + * @author Dominik Seichter + */ +class AdvancedBarcodeDialog : public KDialogBase { + Q_OBJECT + public: + AdvancedBarcodeDialog( QString type, QWidget* parent = 0, const char* name = 0 ); + ~AdvancedBarcodeDialog(); + + void setData( Barkode* b ); + void getData( Barkode* b ); + + private: + QPtrList<BarcodeDlgBase> list; +}; + +/** A configuration widget for TBarcode settings. + * @author Dominik Seichter + */ +class TBarcodeDlg : public QWidget, public BarcodeDlgBase { + Q_OBJECT + public: + TBarcodeDlg(QWidget *parent=0, const char *name=0); + + void setData( Barkode* b ); + void getData( Barkode* b ) const; + + private: + KDoubleNumInput* spinModule; + KIntNumInput* spinHeight; + QCheckBox* checkEscape; + QCheckBox* checkAbove; + QCheckBox* checkAutoCorrect; + KComboBox* comboCheckSum; + + QMap<QString,int> map; +}; + +/** A configuration Dialog for PDF417 settings. + * @author Dominik Seichter + */ +class PDF417BarcodeDlg : public QWidget, public BarcodeDlgBase { + Q_OBJECT + public: + PDF417BarcodeDlg(QWidget *parent=0, const char *name=0); + + void setData( Barkode* b ); + void getData( Barkode* b ) const; + + private: + KIntNumInput* spinRow; + KIntNumInput* spinCol; + KIntNumInput* spinErr; +}; + +/** A configuration widget for DataMatrix settings. + * @author Dominik Seichter + */ +class DataMatrixDlg : public QWidget, public BarcodeDlgBase { + Q_OBJECT + public: + DataMatrixDlg(QWidget *parent=0, const char *name=0); + + void setData( Barkode* b ); + void getData( Barkode* b ) const; + + private: + KComboBox* comboDataMatrix; +}; + +/** A configuration widget for barcode sequences. + * @author Dominik Seichter + */ +class SequenceDlg : public QWidget, public BarcodeDlgBase { + Q_OBJECT + public: + SequenceDlg(QWidget *parent=0, const char *name=0); + + void setData( Barkode* b ); + void getData( Barkode* b ) const; + + private slots: + void enableControls(); + + private: + QCheckBox* checkSequence; + QRadioButton* radioNumbers; + QRadioButton* radioAlpha; + QRadioButton* radioAlphaNum; + + KIntNumInput* spinStep; + KIntNumInput* spinStart; +}; + +/** A configuration widget for colors in pure postscript barcodes + * @author Dominik Seichter + */ +class ColorDlg : public QVBox, public BarcodeDlgBase { + Q_OBJECT + public: + ColorDlg(QWidget *parent=0, const char *name=0); + + void setData( Barkode* b ); + void getData( Barkode* b ) const; + + private: + KColorButton* buttonBarColor; + KColorButton* buttonBackColor; + KColorButton* buttonTextColor; +}; + +/** A configuration widget for colors in pure postscript barcodes + * @author Dominik Seichter + */ +class PurePostscriptDlg : public QVBox, public BarcodeDlgBase { + Q_OBJECT + public: + PurePostscriptDlg(QWidget *parent=0, const char *name=0); + + void setData( Barkode* b ); + void getData( Barkode* b ) const; + + private: + QCheckBox* checkChecksum; +}; + +#endif diff --git a/kbarcode/barcodeitem.cpp b/kbarcode/barcodeitem.cpp new file mode 100644 index 0000000..f2fbe4c --- /dev/null +++ b/kbarcode/barcodeitem.cpp @@ -0,0 +1,253 @@ +/*************************************************************************** + barcodeitem.cpp - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#include "barcodeitem.h" +#include "tcanvasitem.h" + +#include <qdom.h> +#include <qpainter.h> +#include <qpaintdevicemetrics.h> + +BarcodeItem::BarcodeItem() + : Barkode(), DocumentItem() +{ + init(); +} + +BarcodeItem::BarcodeItem( const Barkode & bcode ) + : Barkode( bcode ), DocumentItem() +{ + init(); +} + +QMap<QString,QString> BarcodeItem::legacy; + +void BarcodeItem::init() +{ + // read barcodes saved by kbarcode < 1.3.0 + /* + // disable legacy code as it is really old + // and conflicts with tbarcode2 support + + if( !legacy.count() ) { + legacy.insert( "0", "any" ); + legacy.insert( "1", "ean" ); + legacy.insert( "2", "upc" ); + legacy.insert( "3", "isbn" ); + legacy.insert( "4", "code39" ); + legacy.insert( "5", "code128" ); + legacy.insert( "6", "code128c" ); + legacy.insert( "7", "code128b" ); + legacy.insert( "8", "i25" ); + legacy.insert( "9", "i28raw" ); + legacy.insert( "10", "cbr" ); + legacy.insert( "11", "msi" ); + legacy.insert( "12", "pls" ); + legacy.insert( "13", "code93" ); + legacy.insert( "14", "msi" ); + legacy.insert( "15", "code39 -c" ); + legacy.insert( "16", "i25 -c" ); + } + */ + setBorder( false ); + setRect( QRect( 0, 0, 100, 100 ) ); + + updateBarcode(); +} + +void BarcodeItem::loadXML (QDomElement* element) +{ + // TODO: default() should be called first and the current values should be used + // instead of the now hardcoded values + // i.e: setQuietZone( element->attribute("margin", QString::number( quietZone() ) ).toInt() ); + + setQuietZone( element->attribute("margin", "10" ).toInt() ); + setRotation( element->attribute("rotation", "0" ).toInt() ); + setScaling( element->attribute("scale", "1000" ).toDouble() / 1000 ); + setCut( element->attribute("cut", "1.0" ).toDouble() ); + setType( element->attribute("type", "code39" ) ); + + /* + * check for encoding types saved by kbarcode <= 1.2.0 + */ + if( legacy.contains( type() ) ) + setType( legacy[type()] ); + + setTextVisible( element->attribute("text", "0" ).toInt() ); + setDatabaseMode( element->attribute("caption", "Static" ) ); + + if( engine()->options() ) + engine()->options()->load( element ); + + setDatamatrixSize( element->attribute( "datamatrix.size", "0" ).toInt() ); + + setSequenceEnabled( element->attribute( "sequenceenabled", "0" ).toInt() ); + if( sequenceEnabled() ) + { + setSequenceMode( (ESequence)element->attribute( "sequencemode", "0" ).toInt() ); + setSequenceStep( element->attribute( "sequencestep", "1" ).toInt() ); + setSequenceStart( element->attribute( "sequencestart", "0" ).toInt() ); + } + + QDomNode n = element->firstChild(); + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + if( e.tagName() == "value" ) + setValue( e.text() ); + + n = n.nextSibling(); + } + + DocumentItem::loadXML( element ); + + updateBarcode(); +} + +void BarcodeItem::saveXML (QDomElement* element) +{ + element->setAttribute( "margin", quietZone() ); + element->setAttribute( "rotation", rotation() ); + element->setAttribute( "cut", cut() ); + element->setAttribute( "caption", databaseMode() ); + + /* + * This values are only needed for !cache and for sequences + */ + element->setAttribute( "sequenceenabled", sequenceEnabled() ); + if( sequenceEnabled() ) + { + element->setAttribute( "sequencemode", (int)sequenceMode() ); + element->setAttribute( "sequencestep", sequenceStep() ); + element->setAttribute( "sequencestart", sequenceStart() ); + } + + element->setAttribute( "type", type() ); + element->setAttribute( "text", textVisible() ); + element->setAttribute( "scale", scaling()*1000 ); + + if( engine()->options() ) + engine()->options()->save( element ); + + element->setAttribute( "datamatrix.size", datamatrixSize() ); + + QDomElement texttag = element->ownerDocument().createElement( "value" ); + texttag.appendChild( element->ownerDocument().createTextNode( value() ) ); + + element->appendChild( texttag ); + + DocumentItem::saveXML( element ); +} + +void BarcodeItem::draw (QPainter* painter) +{ + if( DocumentItem::paintDevice() && DocumentItem::paintDevice()->isExtDev() ) + { + painter->save(); + + /* + QPaintDeviceMetrics metrics( DocumentItem::paintDevice() ); + double scalex = (double)metrics.logicalDpiX() / (double)QPaintDevice::x11AppDpiX(); + double scaley = (double)metrics.logicalDpiY() / (double)QPaintDevice::x11AppDpiY(); + painter->scale( 1.0 / scalex, 1.0 / scaley ); + */ + + //painter->drawPixmap( rect().x(), rect().y(), m_pixmap ); + drawBarcode( *painter, rect().x(), rect().y() ); + painter->restore(); + } + else + { + painter->save(); + drawBarcode( *painter, rect().x(), rect().y() ); + painter->restore(); + + TCanvasItem* citem = canvasItem(); + if( citem ) + { + citem->setSize( Barkode::size().width(), Barkode::size().height() ); + } + // TODO: do a bitBlt when device is screen + //painter->drawPixmap( rect().x(), rect().y(), m_pixmap ); + //bitBlt( painter->device(), rect().x(), rect().y(), &m_pixmap, 0, 0, rect().width(), rect().height(), Qt::CopyROP ); + } + DocumentItem::drawBorder( painter ); +} + +void BarcodeItem::drawZpl( QTextStream* stream ) +{ + QString encoding = ZPLUtils::encoding( type() ); + if( encoding.isNull() ) + { + qDebug( "ERROR: No ZPL barcode found"); + return; + } + + *stream << ZPLUtils::fieldOrigin( rect().x(), rect().y() ); + *stream << "^B" << encoding; + *stream << ZPLUtils::fieldData( value() ); +} + +void BarcodeItem::drawIpl( QTextStream* stream, IPLUtils* utils ) +{ + QString encoding = utils->encoding( type() ); + + if( encoding.isEmpty() ) + { + qDebug( "ERROR: No IPL barcode found"); + return; + } + + int counter = utils->counter(); + QString s = QString("B%1;").arg( counter ); // field number + + s += utils->fieldOrigin( rect().x(), rect().y() ); + s += QString("c%1;").arg( encoding ); // encoding type + s += QString("h%1;").arg( rect().height() ); // height of barcode + s += QString("w%1;").arg( 3 ); // width of barcode (per line) + s += QString("d0,%1;").arg( value().length() ); // max length of data + + *stream << utils->field( s ); + utils->addValue( value() ); +} + +void BarcodeItem::drawEPcl( QTextStream* stream ) +{ + QString encoding = EPCLUtils::encoding( type() ); + if( encoding.isEmpty() ) + { + qDebug( "ERROR: No EPCL barcode found"); + return; + } + + // Coordinates cannot start at zero + QString s = QString("B %1").arg( rect().x()+1 ); + s += QString(" %1 0").arg( rect().y() + rect().height() ); + s += QString(" %1 1 4").arg( encoding ); + s += QString(" %1 1").arg( rect().height() ); + s += QString(" %1").arg( value() ); + + *stream << EPCLUtils::field( s ); +} + +void BarcodeItem::updateBarcode() +{ + Barkode::setTokenProvider( tokenProvider() ); + Barkode::update( DocumentItem::paintDevice() ); + setSize( Barkode::size().width(), Barkode::size().height() ); +} + diff --git a/kbarcode/barcodeitem.h b/kbarcode/barcodeitem.h new file mode 100644 index 0000000..0faafc2 --- /dev/null +++ b/kbarcode/barcodeitem.h @@ -0,0 +1,57 @@ +/*************************************************************************** + barcodeitem.h - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#ifndef BARCODEITEM_H +#define BARCODEITEM_H + +#include <qmap.h> +#include <qpixmap.h> + +#include "barkode.h" +#include "gnubarcode.h" +#include "documentitem.h" + +/** + * Class BarcodeItem + * A barcode on the screen or printer. + */ +class BarcodeItem : public Barkode, public DocumentItem { +public: + BarcodeItem(); + BarcodeItem( const Barkode & bcode ); + + void updateBarcode(); + + int rtti() const { return eRtti_Barcode;} + + void loadXML (QDomElement* element); + void saveXML (QDomElement* element); + void draw (QPainter* painter); + void drawZpl( QTextStream* stream ); + void drawIpl( QTextStream* stream, IPLUtils* utils ); + void drawEPcl( QTextStream* stream ); + +private: + void init(); + +private: + static QMap<QString,QString> legacy; + + QPixmap m_pixmap; +}; +#endif //BARCODEITEM_H + diff --git a/kbarcode/barcodeprinterdlg.cpp b/kbarcode/barcodeprinterdlg.cpp new file mode 100644 index 0000000..3488a97 --- /dev/null +++ b/kbarcode/barcodeprinterdlg.cpp @@ -0,0 +1,125 @@ +/*************************************************************************** + barcodeprinterdlg.cpp - description + ------------------- + begin : Fri Oct 01 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "barcodeprinterdlg.h" +#include "printersettings.h" + +#include <kcombobox.h> +#include <klocale.h> +#include <kurlrequester.h> + +#include <qcheckbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qvbuttongroup.h> + +BarcodePrinterDlg::BarcodePrinterDlg(QWidget *parent, const char *name) + : KDialogBase( KDialogBase::Plain, i18n("Barcode Printer"), + KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, parent,name) +{ + QGridLayout* layout = new QGridLayout( plainPage(), 6, 6 ); + + QLabel* label = new QLabel( i18n("&Output Format:"), plainPage() ); + comboFormat = new KComboBox( false, plainPage() ); + label->setBuddy( comboFormat ); + + checkFile = new QCheckBox( i18n("&Print to File"), plainPage() ); + + label2 = new QLabel( i18n("&Filename:"), plainPage() ); + requester = new KURLRequester( plainPage() ); + label2->setBuddy( requester ); + + label3 = new QLabel( i18n("&Device:"), plainPage() ); + comboDevice = new KComboBox( true, plainPage() ); + label3->setBuddy( comboDevice ); + + layout->addWidget( label, 0, 0 ); + layout->addMultiCellWidget( comboFormat, 0, 0, 1, 2 ); + layout->addMultiCellWidget( checkFile, 1, 1, 1, 2 ); + layout->addWidget( label2, 2, 0 ); + layout->addWidget( requester, 2, 1 ); + layout->addWidget( label3, 3, 0 ); + layout->addMultiCellWidget( comboDevice, 3, 3, 1, 2 ); + + comboFormat->insertItem( i18n("TEC Printer (TEC)") ); + comboFormat->insertItem( i18n("Zebra Printer (ZPL)") ); + comboFormat->insertItem( i18n("Intermec Printer (IPL)") ); + comboFormat->insertItem( i18n("EPCL Printer (EPCL)") ); + + // do not translate unix devicenames... + comboDevice->insertItem( "/dev/lp0" ); + comboDevice->insertItem( "/dev/lp1" ); + comboDevice->insertItem( "/dev/lp2" ); + comboDevice->insertItem( "/dev/usb/lp0" ); + comboDevice->insertItem( "/dev/usb/lp1" ); + comboDevice->insertItem( "/dev/usb/lp2" ); + + connect( checkFile, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + +// KFileDialog fd( QString::null, "*.zpl|Zebra Printer Language (*.zpl)\n*.ipl|Intermec Printer Language (*.ipl)", this, "fd", true ); + + enableControls(); +} + + +BarcodePrinterDlg::~BarcodePrinterDlg() +{ +} + +void BarcodePrinterDlg::enableControls() +{ + bool b = checkFile->isChecked(); + label2->setEnabled( b ); + requester->setEnabled( b ); + + label3->setEnabled( !b ); + comboDevice->setEnabled( !b ); +} + +int BarcodePrinterDlg::outputFormat() const +{ + switch( comboFormat->currentItem() ) + { + case 0: + return PrinterSettings::TEC; + case 1: + return PrinterSettings::ZEBRA; + case 2: + return PrinterSettings::INTERMEC; + case 3: + return PrinterSettings::EPCL; + default: + return -1; + } +} + +bool BarcodePrinterDlg::printToFile() const +{ + return checkFile->isChecked(); +} + +const QString BarcodePrinterDlg::deviceName() const +{ + return comboDevice->currentText(); +} + +const QString BarcodePrinterDlg::fileName() const +{ + return requester->url(); +} + +#include "barcodeprinterdlg.moc" diff --git a/kbarcode/barcodeprinterdlg.h b/kbarcode/barcodeprinterdlg.h new file mode 100644 index 0000000..fe0e6e3 --- /dev/null +++ b/kbarcode/barcodeprinterdlg.h @@ -0,0 +1,55 @@ +/*************************************************************************** + barcodeprinterdlg.h - description + ------------------- + begin : Fri Oct 01 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef BARCODEPRINTERDLG_H +#define BARCODEPRINTERDLG_H + +#include <kdialogbase.h> + +class KComboBox; +class KURLRequester; +class QCheckBox; +class QLabel; + +/** +@author Dominik Seichter +*/ +class BarcodePrinterDlg : public KDialogBase +{ + Q_OBJECT + public: + BarcodePrinterDlg(QWidget *parent = 0, const char *name = 0); + ~BarcodePrinterDlg(); + + int outputFormat() const; + bool printToFile() const; + const QString deviceName() const; + const QString fileName() const; + + private slots: + void enableControls(); + + private: + KComboBox* comboFormat; + KComboBox* comboDevice; + KURLRequester* requester; + + QCheckBox* checkFile; + QLabel* label2; + QLabel* label3; +}; + +#endif diff --git a/kbarcode/barcodes.html b/kbarcode/barcodes.html new file mode 100644 index 0000000..3e64951 --- /dev/null +++ b/kbarcode/barcodes.html @@ -0,0 +1,868 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<title>kbarcode</title> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> +</head> + +<body> +<a name="top"></a> +<p><a href="http://www.kbarcode.net" target="_blank"> + <font face="Verdana, Arial, Helvetica, sans-serif"> <b>kbarcode </b> - The Barcode Solution for KDE </font> + </a></p> + +<p><strong>kbarcode</strong> has right now support following barcodes. Please check + the requirements and limitations:</p> + +<ul> + <li> <a href="#EAN">ean (EAN 8 or EAN 13)</a></li> + <li> <a href="#upc">upc (UPC-A or UPC-E)</a></li> + <li> <a href="#isbn">isbn</a></li> + <li> <a href="#code39">code39</a></li> + <li><a href="#code128"> code128</a></li> + <li> <a href="#code128c">code128c</a></li> + <li><a href="#code128b"> code128b</a></li> + <li> <a href="#codei25">Interleave 2 of 5</a></li> + <li> <a href="#code128raw">code 128 raw</a></li> + <li> <a href="#cbr">Codabar</a></li> + <li> <a href="#msi">msi</a></li> + <li> <a href="#pls">Plessey</a></li> + <li> <a href="#code93">code93</a></li> +</ul> +<p><strong><a name="EAN" id="EAN"></a>EAN 8</strong>:</p> + + +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>ean</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td>numbers (0....9)</td> + </tr> + <tr> + <td nowrap>lenght</td> + <td>7 + 1 Checkum Digit = 8</td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td><ul> + <li>when the number is 7 digits long, kbarcode will create a checksum + (the 8. digits)</li> + <li>when the number is 8 digits long, kbarcode will check the checksum + and deny printing if wrong</li> + </ul></td> + </tr> + <tr> + <td nowrap>Size</td> + <td><p>fixed, but scalable<br> + Standard: 26.73mm x 21.64mm</p></td> + </tr> + <tr> + <td nowrap>Remark</td> + <td><p>possible scaling:</p> + <table width="80%" border="1" align="center" cellpadding="0" cellspacing="0"> + <tr> + <td width="20%"><div align="center">Size</div></td> + <td width="20%"><div align="center">Factor</div></td> + <td width="20%"><p align="center">width<br> + <p align="center">[mm]</p></td> + <td width="20%"><p align="center">height</p> + <p align="center">[mm]</p></td> + </tr> + <tr> + <td><div align="center">SC0</div></td> + <td><div align="center">0.818</div></td> + <td><div align="center">21.87</div></td> + <td><div align="center">17.70</div></td> + </tr> + <tr> + <td><div align="center">SC1</div></td> + <td><div align="center">0.90</div></td> + <td><div align="center">24.06</div></td> + <td><div align="center">19.48</div></td> + </tr> + <tr> + <td><div align="center"><strong>SC2</strong></div></td> + <td><div align="center"><strong>1.00</strong></div></td> + <td><div align="center"><strong>26.73</strong></div></td> + <td><div align="center"><strong>21.64</strong></div></td> + </tr> + <tr> + <td><div align="center">SC3</div></td> + <td><div align="center">1.10</div></td> + <td><div align="center">29.40</div></td> + <td><div align="center">23.80</div></td> + </tr> + <tr> + <td><div align="center">SC4</div></td> + <td><div align="center">1.20</div></td> + <td><div align="center">32.08</div></td> + <td><div align="center">25.97</div></td> + </tr> + <tr> + <td><div align="center">SC5</div></td> + <td><div align="center">1.35</div></td> + <td><div align="center">36.09</div></td> + <td><div align="center">29.21</div></td> + </tr> + <tr> + <td><div align="center">SC6</div></td> + <td><div align="center">1.50</div></td> + <td><div align="center">40.10</div></td> + <td><div align="center">32.46</div></td> + </tr> + <tr> + <td><div align="center">SC7</div></td> + <td><div align="center">1.65</div></td> + <td><div align="center">44.10</div></td> + <td><div align="center">35.71</div></td> + </tr> + <tr> + <td><div align="center">SC8</div></td> + <td><div align="center">1.85</div></td> + <td><div align="center">49.45</div></td> + <td><div align="center">40.03</div></td> + </tr> + <tr> + <td><div align="center">SC9</div></td> + <td><div align="center">2.00</div></td> + <td><div align="center">53.46</div></td> + <td><div align="center">43.28</div></td> + </tr> + </table><p> </p></td> + </tr> +</table> + + +<p> + <a href="#top"> TOP </a> +</p> + + +<p><strong>EAN 13</strong>:</p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>ean</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td>numbers (0.....9)</td> + </tr> + <tr> + <td nowrap>lenght</td> + <td>12 + 1 checksum digitt = 13</td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td><ul> + <li>when the number is 12 digits long, kbarcode will create a checksum + (the 13. digits)</li> + <li>when the number is 13 digits long, kbarcode will check the checksum + and deny printing if wrong</li> + </ul></td> + </tr> + <tr> + <td nowrap>Size</td> + <td><p>fixed, but scalable<br> + Standard: 37.29 x 26.26mm</p></td> + </tr> + <tr> + <td nowrap>Remark</td> + <td><p>possible scaling:</p> + <table width="80%" border="1" align="center" cellpadding="0" cellspacing="0"> + + <tr> + <td width="20%"><div align="center">Size</div></td> + <td width="20%"><div align="center">Factor</div></td> + <td width="20%"><p align="center">width<br> + <p align="center">[mm]</p></td> + <td width="20%"><p align="center">height</p> + <p align="center">[mm]</p></td> + </tr> + <tr> + <td><div align="center">SC0</div></td> + <td><div align="center">0.818</div></td> + <td><div align="center">30.50</div></td> + <td><div align="center">21.48</div></td> + </tr> + <tr> + <td><div align="center">SC1</div></td> + <td><div align="center">0.90</div></td> + <td><div align="center">33.56</div></td> + <td><div align="center">23.63</div></td> + </tr> + <tr> + <td><div align="center"><strong>SC2</strong></div></td> + <td><div align="center"><strong>1.00</strong></div></td> + <td><div align="center">37.29</div></td> + <td><div align="center">26.26</div></td> + </tr> + <tr> + <td><div align="center">SC3</div></td> + <td><div align="center">1.10</div></td> + <td><div align="center">41.02</div></td> + <td><div align="center">28.89</div></td> + </tr> + <tr> + <td><div align="center">SC4</div></td> + <td><div align="center">1.20</div></td> + <td><div align="center">44.75</div></td> + <td><div align="center">31.51</div></td> + </tr> + <tr> + <td><div align="center">SC5</div></td> + <td><div align="center">1.35</div></td> + <td><div align="center">50.34</div></td> + <td><div align="center">35.45</div></td> + </tr> + <tr> + <td><div align="center">SC6</div></td> + <td><div align="center">1.50</div></td> + <td><div align="center">55.94</div></td> + <td><div align="center">39.39</div></td> + </tr> + <tr> + <td><div align="center">SC7</div></td> + <td><div align="center">1.65</div></td> + <td><div align="center">61.35</div></td> + <td><div align="center">43.33</div></td> + </tr> + <tr> + <td><div align="center">SC8</div></td> + <td><div align="center">1.85</div></td> + <td><div align="center">68.99</div></td> + <td><div align="center">48.58</div></td> + </tr> + <tr> + <td><div align="center">SC9</div></td> + <td><div align="center">2.00</div></td> + <td><div align="center">74.58</div></td> + <td><div align="center">52.52</div></td> + </tr> + </table><p> </p></td> + </tr> +</table> + + +<p> + <a href="#top"> TOP </a> +</p> + + + +<p><strong><a name="upc"></a>UPC-A</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>UPC</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td>numbers (0....9)</td> + </tr> + <tr> + <td nowrap>lenght</td> + <td>11 + 1 checksum digit = 12</td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td><ul> + <li>when the number is 11 digits long, kbarcode will create a checksum + (the 12. digits)</li> + <li>when the number is 12 digits long, kbarcode will check the checksum + and deny printing if wrong</li> + </ul></td> + </tr> + <tr> + <td nowrap>Size</td> + <td><p>fixed, but scalable<br> + Standard: 37.29 x 26.26mm</p></td> + </tr> + <tr> + <td nowrap>Remark</td> + <td><p> </p> + <table width="80%" border="1" align="center" cellpadding="0" cellspacing="0"> + + <tr> + <td width="20%"><div align="center">Size</div></td> + <td width="20%"><div align="center">Factor</div></td> + <td width="20%"><p align="center">width<br> + <p align="center">[mm]</p></td> + <td width="20%"><p align="center">height</p> + <p align="center">[mm]</p></td> + </tr> + <tr> + <td><div align="center">SC0</div></td> + <td><div align="center">0.818</div></td> + <td><div align="center">30.50</div></td> + <td><div align="center">21.48</div></td> + </tr> + <tr> + <td><div align="center">SC1</div></td> + <td><div align="center">0.90</div></td> + <td><div align="center">33.56</div></td> + <td><div align="center">23.63</div></td> + </tr> + <tr> + <td><div align="center"><strong>SC2</strong></div></td> + <td><div align="center"><strong>1.00</strong></div></td> + <td><div align="center">37.29</div></td> + <td><div align="center">26.26</div></td> + </tr> + <tr> + <td><div align="center">SC3</div></td> + <td><div align="center">1.10</div></td> + <td><div align="center">41.02</div></td> + <td><div align="center">28.89</div></td> + </tr> + <tr> + <td><div align="center">SC4</div></td> + <td><div align="center">1.20</div></td> + <td><div align="center">44.75</div></td> + <td><div align="center">31.51</div></td> + </tr> + <tr> + <td><div align="center">SC5</div></td> + <td><div align="center">1.35</div></td> + <td><div align="center">50.34</div></td> + <td><div align="center">35.45</div></td> + </tr> + <tr> + <td><div align="center">SC6</div></td> + <td><div align="center">1.50</div></td> + <td><div align="center">55.94</div></td> + <td><div align="center">39.39</div></td> + </tr> + <tr> + <td><div align="center">SC7</div></td> + <td><div align="center">1.65</div></td> + <td><div align="center">61.35</div></td> + <td><div align="center">43.33</div></td> + </tr> + <tr> + <td><div align="center">SC8</div></td> + <td><div align="center">1.85</div></td> + <td><div align="center">68.99</div></td> + <td><div align="center">48.58</div></td> + </tr> + <tr> + <td><div align="center">SC9</div></td> + <td><div align="center">2.00</div></td> + <td><div align="center">74.58</div></td> + <td><div align="center">52.52</div></td> + </tr> + </table> + <p> </p></td> + </tr> +</table> + +<p> + <a href="#top"> TOP </a> +</p> + + +<p><strong>UPC-E</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>upc</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td>numbers (0....9)</td> + </tr> + <tr> + <td nowrap>lenght</td> + <td>Systemcode 0 + 6 + 1 Checkum Digit = 8</td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td><ul> + <li>when the number is 7 digits long, kbarcode will create a checksum + (the 8. digits)</li> + <li>when the number is 8 digits long, kbarcode will check the checksum + and deny printing if wrong</li> + </ul></td> + </tr> + <tr> + <td nowrap>Size</td> + <td> </td> + </tr> + <tr> + <td nowrap>Remark</td> + <td> +<p> </p></td> + </tr> +</table> + + + +<p> + <a href="#top"> TOP </a> +</p> + + + +<p><strong><a name="isbn"></a>ISBN</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>ISBN</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td> </td> + </tr> + <tr> + <td nowrap>lenght</td> + <td> </td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td> </td> + </tr> + <tr> + <td nowrap>Size</td> + <td> </td> + </tr> + <tr> + <td nowrap>Remark</td> + <td> ISBN numbers are encoded as EAN-13 symbols, with an optional add-5 + trailer. The ISBN frontend of the library accepts real ISBN + numbers and deals with any hyphen and, if present, the ISBN checksum character + before encoding data. Valid representations for ISBN strings are for example: + "1-56592-292-1", "3-89721-122-X" and "3-89721-122-X + 06900".</p></td> + </tr> +</table> + + +<p> + <a href="#top"> TOP </a> +</p> + + + +<p><strong><a name="code128b"></a>code 128-B</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>code 128-B</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td> </td> + </tr> + <tr> + <td nowrap>lenght</td> + <td> </td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td> </td> + </tr> + <tr> + <td nowrap>Size</td> + <td> </td> + </tr> + <tr> + <td nowrap>Remark</td> + <td> This encoding can represent all of the printing ASCII characters, from + the space (32) to DEL (127). The checksum digit is mandatory i + n this encoding.</td> + </tr> +</table> + + +<p> + <a href="#top"> TOP </a> +</p> + + +<p><strong><a name="code128c"></a>code 128-C</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>code 128-C</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td> </td> + </tr> + <tr> + <td nowrap>lenght</td> + <td> </td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td> </td> + </tr> + <tr> + <td nowrap>Size</td> + <td> </td> + </tr> + <tr> + <td nowrap>Remark</td> + <td> + The "C" variation of Code-128 uses Code-128 symbols to represent + two digits at a time (Code-128 is made up of 104 symbols whose<br> + interpretation is controlled by the start symbol being used). Code 128-C + is thus the most compact way to represent any even number of digits. The + encoder refuses to deal with an odd number of digits because the caller + is expected to provide proper padding to an even number of digits. (Since + Code-128 includes control symbols to switch charset, it is theoretically + possible to represent the odd digit as a Code 128-A or 128-B symbol, but + this tool doesn't currently implement this option).</p></td> + </tr> +</table> + + +<p> + <a href="#top"> TOP </a> +</p> + + +<p><strong><a name="code128raw"></a>code 128 raw</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>code 128 raw</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td> </td> + </tr> + <tr> + <td nowrap>lenght</td> + <td> </td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td> </td> + </tr> + <tr> + <td nowrap>Size</td> + <td> </td> + </tr> + <tr> + <td nowrap>Remark</td> + <td> Code-128 output represented symbol-by-symbol in the input string. + To override part of the problems outlined below in specifying<br> + code128 symbols, this pseudo-encoding allows the used to specify a list + of code128 symbols separated by spaces. Each symbol is represented by + a number in the range 0-105. The list should include the leading character.The + checksum and the stop character are automatically added by the library. + Most likely this pseudo-encoding will be used with BARCODE_NO_ASCII and + some external program to supply the printed text.</p></td> + </tr> +</table> + + +<p> + <a href="#top"> TOP </a> +</p> + + +<p><strong><a name="code39"></a>code 39</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>code 39</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td> </td> + </tr> + <tr> + <td nowrap>lenght</td> + <td> </td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td> </td> + </tr> + <tr> + <td nowrap>Size</td> + <td> </td> + </tr> + <tr> + <td nowrap>Remark</td> + <td> The code-39 standard can encode uppercase letters, digits, the blank + space, plus, minus, dot, star, dollar, slash, percent. Any<br> + string that is only composed of such characters is accepted by the code-39 + encoder. To avoid loosing information, the encoder refuses to encode mixed-case + strings (a lowercase string is nonetheless accepted as a shortcut, but is + encoded as uppercase).</td> + </tr> +</table> + + +<p> + <a href="#top"> TOP </a> +</p> + + +<p><strong><a name="codei25"></a>interleaved 2 of 5</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>interleaved 2 of 5</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td> </td> + </tr> + <tr> + <td nowrap>lenght</td> + <td> </td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td> </td> + </tr> + <tr> + <td nowrap>Size</td> + <td> </td> + </tr> + <tr> + <td nowrap>Remark</td> + <td> + This encoding can only represent an even number of digits (odd digits + are represented by bars, and even digits by the interleaving<br> + spaces). The name stresses the fact that two of the five items (bars or + spaces) allocated to each symbol are wide, while the rest are narrow. + The checksum digit is optional (can be disabled via BARCODE_NO_CHECKSUM). + Since the number of digits, including the checksum, must be even, a leading + zero is inserted in the string being encoded if needed (this is specifically + stated in the specs I have access to).</p></td> + </tr> +</table> + + +<p> + <a href="#top"> TOP </a> +</p> + + +<p><strong><a name="code128"></a>code 128</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>code 128</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td> </td> + </tr> + <tr> + <td nowrap>lenght</td> + <td> </td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td> </td> + </tr> + <tr> + <td nowrap>Size</td> + <td> </td> + </tr> + <tr> + <td nowrap>Remark</td> + <td> Automatic selection between alphabet A, B and C of the Code-128 standard. + This encoding can represent all ASCII symbols, from 0<br> + (NUL) to 127 (DEL), as well as four special symbols, named F1, F2, F3, + F4. The set of symbols available in this encoding is not easily represented + as input to the barcode library, so the following convention is used. + In the input string, which is a C-language null- terminated string, the + NUL char is represented by the value 128 (0x80, 0200) and the F1-F4 characters + are represented by the values 193-196 (0xc1-0xc4, 0301-0304). The values + have been chosen to ease their representation as escape sequences.</p> + <p>Since the shell doesn't seem to interpret escape sequences on the command + line, the "-b" option cannot be easily used to designate the + strings to be encoded. As a workaround you can resort to the command echo, + either within back-ticks or used separately to create a file that is then + fed to the standard-input of barcode - assuming your echo command processes + escape sequences. The newline character is especially though to encode + (but not impossible unless you use a csh variant. </p> + <p>These problems only apply to the command-line tool; the use of library + functions doesn't give any problem. In needed, you can use the "code + 128 raw" pseudo-encoding to represent code128 symbols by their numerical + value. This encoding is used late in the auto- selection mechanism because + (almost) any input string can be represented using code128.</p> +</td> +</tr> +</table> + + +<p> + <a href="#top"> TOP </a> +</p> + + +<p><strong><a name="cbr"></a>Codabar</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>Codabar</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td> </td> + </tr> + <tr> + <td nowrap>lenght</td> + <td> </td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td> </td> + </tr> + <tr> + <td nowrap>Size</td> + <td> </td> + </tr> + <tr> + <td nowrap>Remark</td> + <td> + Codabar can encode the ten digits and a few special symbols (minus, plus, + dollar, colon, bar, dot). The characters "A", "B", + "C" and<br> + "D" are used to represent four different start/stop characters. + The input string to the barcode library can include the start and stop + characters or not include them (in which case "A" is used as + start and "B" as stop). Start and stop characters in the input + string can be either all lowercase or all uppercase and are always printed + as uppercase.</p></td> + </tr> +</table> + + +<p> + <a href="#top"> TOP </a> +</p> + + +<p><strong><a name="pls"></a>Plessey</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>Plessey</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td> </td> + </tr> + <tr> + <td nowrap>lenght</td> + <td> </td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td> </td> + </tr> + <tr> + <td nowrap>Size</td> + <td> </td> + </tr> + <tr> + <td nowrap>Remark</td> + <td> Plessey barcodes can encode all the hexadecimal digits. Alphabetic + digits in the input string must either be all lowercase or all<br> + uppercase. The output text is always uppercase.</p></td> + </tr> +</table> + + +<p> + <a href="#top"> TOP </a> +</p> + + +<p><strong><a name="msi"></a>MSI</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>MSI</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td> </td> + </tr> + <tr> + <td nowrap>lenght</td> + <td> </td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td> </td> + </tr> + <tr> + <td nowrap>Size</td> + <td> </td> + </tr> + <tr> + <td nowrap>Remark</td> + <td> + MSI can only encode the decimal digits. While the standard specifies either + one or two check digits, the current implementation in<br> + this library only generates one check digit.</p></td> + </tr> +</table> + +<p> + <a href="#top"> TOP </a> +</p> + + +<p><strong><a name="code93"></a>code 93</strong></p> +<table width = "100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td nowrap>kbarcode Setting</td> + <td>code 93</td> + </tr> + <tr> + <td nowrap>valid character set</td> + <td> </td> + </tr> + <tr> + <td nowrap>lenght</td> + <td> </td> + </tr> + <tr> + <td nowrap>Checksum</td> + <td> </td> + </tr> + <tr> + <td nowrap>Size</td> + <td> </td> + </tr> + <tr> + <td nowrap>Remark</td> + <td>The code-93 standard can natively encode 48 different characters, including + uppercase letters, digits, the blank space, plus, minus,<br> + dot, star, dollar, slash, percent, as well as five special characters: + a start/stop delimiter and four "shift characters" used for + extended encoding. Using this "extended encoding" method, any + standard 7-bit ASCII character can be encoded, but it takes up two symbol + lengths in barcode if the character is not natively supported (one of + the 48). The encoder here fully implements the code 93 encoding standard. + Any characters natively supported (A-Z, 0-9, ".+-/$&%") + will be encoded as such - for any other characters (such as lower case + letters, brackets, parentheses, etc.), the encoder will revert to extended + encoding. As a note, the option to exclude the checksum will eliminate + the two modulo-47 checksums (called C and K) from the barcode, but this + probably will make it unreadable by 99% of all scanning systems. These + checksums are specified to be used at the firmware level, and their absence + will be interpreted as an invalid barcode.</p></td> + </tr> +</table> + + +<p> + <a href="#top"> TOP </a> +</p> +</body> +</html> diff --git a/kbarcode/barkode.cpp b/kbarcode/barkode.cpp new file mode 100644 index 0000000..7ec5c84 --- /dev/null +++ b/kbarcode/barkode.cpp @@ -0,0 +1,968 @@ +/* Copyright (C) 2004 Dominik Seichter <domseichter@web.de> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "barkode.h" +#include "barkodeengine.h" +#include "gnubarcode.h" +#include "pixmapbarcode.h" +#include "purepostscript.h" +#include "tbarcode2.h" +#include "tokenprovider.h" + +#ifdef _ENABLE_NATIVE_GNU_BARCODE +# include <barcode.h> +#else +#define BARCODE_DEFAULT_FLAGS 0x00000000 + +#define BARCODE_ENCODING_MASK 0x000000ff /* 256 possibilites... */ +#define BARCODE_NO_ASCII 0x00000100 /* avoid text in output */ +#define BARCODE_NO_CHECKSUM 0x00000200 /* avoid checksum in output */ + +#define BARCODE_OUTPUT_MASK 0x000ff000 /* 256 output types */ +#define BARCODE_OUT_EPS 0x00001000 +#define BARCODE_OUT_PS 0x00002000 +#define BARCODE_OUT_PCL 0x00004000 /* by Andrea Scopece */ +/* PCL_III 0x00008000 */ +#define BARCODE_OUT_PCL_III 0x0000C000 +#define BARCODE_OUT_NOHEADERS 0x00100000 /* no header nor footer */ + +// include our own defines from barcode.h +enum { + BARCODE_ANY = 0, /* choose best-fit */ + BARCODE_EAN, + BARCODE_UPC, /* upc == 12-digit ean */ + BARCODE_ISBN, /* isbn numbers (still EAN13) */ + BARCODE_39, /* code 39 */ + BARCODE_128, /* code 128 (a,b,c: autoselection) */ + BARCODE_128C, /* code 128 (compact form for digits) */ + BARCODE_128B, /* code 128, full printable ascii */ + BARCODE_I25, /* interleaved 2 of 5 (only digits) */ + BARCODE_128RAW, /* Raw code 128 (by Leonid A. Broukhis) */ + BARCODE_CBR, /* Codabar (by Leonid A. Broukhis) */ + BARCODE_MSI, /* MSI (by Leonid A. Broukhis) */ + BARCODE_PLS, /* Plessey (by Leonid A. Broukhis) */ + BARCODE_93 /* code 93 (by Nathan D. Holmes) */ +}; +#endif // _ENABLE_NATIVE_GNU_BARCODE + +#include <qdom.h> +#include <qfile.h> +#include <qpainter.h> +#include <qpicture.h> +#include <qpixmap.h> +#include <qsize.h> + +#include <klocale.h> +#include <kstandarddirs.h> + +QValueList<tBarcodeInfo> Barkode::s_info; +QStringList* Barkode::s_encoding = NULL; +bool Barkode::s_haveGnuBarcode = false; +bool Barkode::s_havePdfEncode = false; +bool Barkode::s_haveTBarcode = false; +bool Barkode::s_haveTBarcode2 = false; +bool Barkode::s_havePurePostscript = false; + +Barkode::Barkode() +{ + initInfo(); + m_engine = NULL; + m_token = NULL; + + defaults(); +} + +Barkode::Barkode( const Barkode & barkode ) +{ + initInfo(); + m_engine = NULL; + m_token = NULL; + + *this = barkode; +} + +Barkode::~Barkode() +{ + if( m_engine ) + delete m_engine; +} + +void Barkode::setTokenProvider( TokenProvider* token ) +{ + m_token = token; +} + +void Barkode::defaults() +{ + m_valid = false; + m_text_visible = true; + + m_background = Qt::white; + m_foreground = Qt::black; + m_textcolor = Qt::black; + + m_quietzone = 0; + m_bar_height = 80; + m_fontsize = 12; + + m_rotation = 0; + m_scaling = 1.0; + m_cut = 1.0; + m_datamatrix_size = 0; + + m_type = "code39"; + m_value = "KBARCODE"; + m_database_mode = "static"; + + m_index = 0; + m_sequence = false; + m_esequence = NUM; + m_sequence_start = 1; + m_sequence_step = 1; + + updateEngine(); + + BarkodeEngineOptions* options = m_engine ? m_engine->options() : NULL; + if( options ) + options->defaults(); +} + +void Barkode::setData( const Barkode & barkode ) +{ + this->m_valid = barkode.m_valid; + this->m_text_visible = barkode.m_text_visible; + + this->m_background = barkode.m_background; + this->m_foreground = barkode.m_foreground; + this->m_textcolor = barkode.m_textcolor; + + this->m_quietzone = barkode.m_quietzone; + this->m_bar_height = barkode.m_bar_height; + this->m_fontsize = barkode.m_fontsize; + this->m_rotation = barkode.m_rotation; + this->m_scaling = barkode.m_scaling; + this->m_cut = barkode.m_cut; + + this->m_type = barkode.m_type; + this->m_value = barkode.m_value; + this->m_database_mode = barkode.m_database_mode; + + this->m_index = barkode.m_index; + this->m_sequence = barkode.m_sequence; + this->m_esequence = barkode.m_esequence; + this->m_sequence_start = barkode.m_sequence_start; + this->m_sequence_step = barkode.m_sequence_step; + + updateEngine(); + + *m_engine = *(barkode.engine()); + + this->m_datamatrix_size = barkode.m_datamatrix_size; +} + +void Barkode::operator=( const Barkode & barkode ) +{ + setData( barkode ); +} + +bool Barkode::operator==( const Barkode & barkode ) const +{ + bool b = true; +#warning "operator== is incomplete" + + // colors + b = ( this->m_background == barkode.m_background && this->m_foreground == barkode.m_foreground ) && b; + + // sizes + b = ( this->m_quietzone == barkode.m_quietzone && this->m_bar_height == barkode.m_bar_height && this->m_fontsize == barkode.m_fontsize ) && b; + + // values + b = ( this->m_type == barkode.m_type && this->m_value == barkode.m_value ) && b; + + return b; +} + +const QPicture Barkode::picture() +{ + QPicture pic; + QPainter painter( &pic ); + + painter.fillRect( 0, 0, size().width(), size().height(), m_background ); + + // sub classes do the real drawing + drawBarcode( painter ); + + return pic; +} + +void Barkode::drawInvalid( QPainter & painter, int x, int y ) +{ + QRect rect( x, y, size().width(), size().height() ); + painter.save(); + painter.fillRect( rect, Qt::white ); + painter.setPen( QPen( Qt::red, 2 ) ); + painter.drawRect( rect ); + painter.drawLine( x, y, x + size().width(), y + size().height() ); + painter.drawLine( x, y + size().height(), x + size().width(), y ); + painter.restore(); +} + +const QSize Barkode::size() const +{ + return m_engine ? m_engine->size() : QSize( 0, 0 ); +} + +const QPixmap Barkode::pixmap( double scalex, double scaley ) +{ + QPixmap pixmap( (int)(size().width() * scalex), (int)(size().height() * scaley) ); + if( !pixmap.isNull() ) + { + QPainter painter( &pixmap ); + painter.scale( scalex, scaley ); + painter.fillRect( 0, 0, size().width(), size().height(), m_background ); + drawBarcode( painter ); + } + + return pixmap; +} + +const QString Barkode::parsedValue() +{ + QString text = m_token ? m_token->parse( m_value ) : m_value; + + if( !sequenceEnabled() ) + return text; + + if( m_value.contains( '#' ) <= 0 ) + return text; + + int pos = 0, counter = 1; + + pos = text.find("#", pos); + pos++; + while( text[pos] == '#' ) { + text.remove(pos, 1); + counter++; + } + + pos = text.find("#", 0); + QString temp; + + if( sequenceMode() == NUM ) { + int v = sequenceStart() + m_index*sequenceStep(); + temp.sprintf("%0*i", counter, v ); + } else { + for( int i = 0; i < counter; i++ ) + temp.append( "A" ); + + unsigned int z = 0; + for( int p = temp.length(); p >= 0; p--, z++ ) { + if( sequenceMode() == ALPHA ) { + int v = 'A' + m_index*sequenceStep(); + v -= z*('Z'-'A'); + + if( v <= 'Z' ) { + temp[p] = QChar(v); + break; + } else if( v > 'Z' ) + v = 'Z'; + temp[p] = QChar(v); + } else if( sequenceMode() == ALPHANUM ) { + qDebug("NOT IMPLEMENTED"); +/* char array[36]; + for( unsigned int i = 'A'; i <= 'Z'; i++ ) + array[i-'A'] = i; + for( unsigned int i = '0'; i <= '9'; i++ ) + array['Z'-'A'+i-'0'] = i; + + int z = m_index*barcode.sequence.step; + if( z < sizeof(array) ) + temp[] + int v = array[ ]*/ + } + } + } + + text.replace( pos, 1, temp); + return text; +} + +EEngine Barkode::engineForType( const QString & type ) +{ + EEngine engine = NONE; + + for( unsigned int i=0;i<s_info.count();i++) + if( s_info[i].xml == type ) + { + engine = s_info[i].engine; + break; + } + + return engine; +} + +void Barkode::updateEngine() +{ + EEngine engine = engineForType( type() ); + + if( m_engine && engine != m_engine->engine() ) + { + // switch to another engine + delete m_engine; + m_engine = NULL; + } + + if( !m_engine ) + { + if( engine == GNU_BARCODE ) +#ifdef _ENABLE_NATIVE_GNU_BARCODE + m_engine = new GnuBarcode(); +#else + m_engine = new PixmapBarcode(); +#endif // _ENABLE_NATIVE_GNU_BARCODE + else if( engine == TBARCODE ) + m_engine = new PixmapBarcode(); + else if( engine == TBARCODE2 ) + m_engine = new TBarcode2(); + else if( engine == PDF417 ) + m_engine = new PixmapBarcode(); + else if( engine == PURE_POSTSCRIPT ) + m_engine = new PurePostscriptBarcode(); + else + m_engine = new EmptyEngine(); + + m_engine->setBarkode( this ); + } +} + +void Barkode::drawBarcode( QPainter & painter, int x, int y ) +{ + if( m_engine ) + m_engine->drawBarcode( painter, x, y ); +} + +void Barkode::update( const QPaintDevice* device ) +{ + if( m_engine ) + m_engine->update( device ); +} + +//////////////////////////////////////////////////////////// +// Get attributes // +//////////////////////////////////////////////////////////// + +bool Barkode::isValid() const +{ + return m_valid; +} + +const QColor & Barkode::background() const +{ + return m_background; +} + +const QColor & Barkode::foreground() const +{ + return m_foreground; +} + +const QColor & Barkode::textColor() const +{ + return m_textcolor; +} + +const unsigned int Barkode::fontsize() const +{ + return m_fontsize; +} + +const unsigned int Barkode::quietZone() const +{ + return m_quietzone; +} + +const unsigned int Barkode::barHeight() const +{ + return m_bar_height; +} + +const QString & Barkode::type() const +{ + return m_type; +} + +const QString & Barkode::value() const +{ + return m_value; +} + +const unsigned int Barkode::index() const +{ + return m_index; +} + +const bool Barkode::sequenceEnabled() const +{ + return m_sequence; +} + +const ESequence Barkode::sequenceMode() const +{ + return m_esequence; +} + +const int Barkode::sequenceStart() const +{ + return m_sequence_start; +} + +const int Barkode::sequenceStep() const +{ + return m_sequence_step; +} + +const QString & Barkode::databaseMode() const +{ + return m_database_mode; +} + +const bool Barkode::textVisible() const +{ + return m_text_visible; +} + +const int Barkode::rotation() const +{ + return m_rotation; +} + +const double Barkode::scaling() const +{ + return m_scaling; +} + +const double Barkode::cut() const +{ + return m_cut; +} + +const int Barkode::datamatrixSize() const +{ + return m_datamatrix_size; +} + +//////////////////////////////////////////////////////////// +// Set attributes // +//////////////////////////////////////////////////////////// + +void Barkode::setBackground( const QColor & c ) +{ + m_background = c; +} + +void Barkode::setForeground( const QColor & c ) +{ + m_foreground = c; +} + +void Barkode::setTextColor( const QColor & c ) +{ + m_textcolor = c; +} + +void Barkode::setFontsize( unsigned int f ) +{ + m_fontsize = f; +} + +void Barkode::setQuietZone( const unsigned int q ) +{ + m_quietzone = q; +} + +void Barkode::setBarHeight( unsigned int h ) +{ + m_bar_height = h; +} + +void Barkode::setType( const QString & type ) +{ + m_type = type.lower(); + updateEngine(); +} + +void Barkode::setValue( const QString & value ) +{ + m_value = value; +} + +void Barkode::setIndex( const unsigned int i ) +{ + m_index = i; +} + +void Barkode::setSequenceEnabled( bool b ) +{ + m_sequence = b; +} + +void Barkode::setSequenceMode( ESequence e ) +{ + m_esequence = e; +} + +void Barkode::setSequenceStart( int s ) +{ + m_sequence_start = s; +} + +void Barkode::setSequenceStep( int s ) +{ + m_sequence_step = s; +} + +void Barkode::setDatabaseMode( const QString & mode ) +{ + m_database_mode = mode; +} + +void Barkode::setTextVisible( const bool b ) +{ + m_text_visible = b; +} + +void Barkode::setRotation( const int r ) +{ + m_rotation = r; +} + +void Barkode::setScaling( const double d ) +{ + m_scaling = d; +} + +void Barkode::setCut( const double c ) +{ + m_cut = c; +} + +void Barkode::setDatamatrixSize( int s ) +{ + m_datamatrix_size = s; +} + +//////////////////////////////////////////////////////////// +// Fill the s_info structure +//////////////////////////////////////////////////////////// + +bool Barkode::hasFeature( const QString & type, unsigned int feature ) +{ + for( unsigned int i = 0; i < s_info.count(); i++ ) + if( s_info[i].xml == type ) + return (s_info[i].features & feature) == feature; + + return false; +} + +int Barkode::internalType( const QString & type ) +{ + for( unsigned int i = 0; i < s_info.count(); i++ ) + if( s_info[i].xml == type ) + return s_info[i].internal; + + return false; +} + +const QStringList* Barkode::encodingTypes() +{ + if( !s_encoding ) + { + s_encoding = new QStringList; + for( unsigned int i = 0; i < s_info.count(); i++ ) + s_encoding->append( s_info[i].name ); + //s_encoding->sort(); + } + + return s_encoding; +} + +const char* Barkode::typeFromName( const QString & name ) +{ + for( unsigned int i = 0; i < s_info.count(); i++ ) + if( s_info[i].name == name ) + return s_info[i].xml; + + return NULL; +} + +const char* Barkode::nameFromType( const QString & type ) +{ + for( unsigned int i = 0; i < s_info.count(); i++ ) + if( s_info[i].xml == type ) + return s_info[i].name; + + return NULL; +} + +QString* Barkode::validatorFromType( const QString & type ) +{ + for( unsigned int i = 0; i < s_info.count(); i++ ) + if( s_info[i].xml == type ) + return &(s_info[i].validator); + + return NULL; +} + +QString* Barkode::validatorNotFromType( const QString & type ) +{ + for( unsigned int i = 0; i < s_info.count(); i++ ) + if( s_info[i].xml == type ) + return &(s_info[i].validatorNot); + + return NULL; +} + +tBarcodeInfo Barkode::createInfo( const char* xml, const QString & name, const EEngine engine, + const unsigned int features, const int internal ) +{ + tBarcodeInfo info; + QString strengine; + + switch( engine ) + { + case GNU_BARCODE: + strengine = i18n(" [GNU Barcode]"); + break; + case PDF417: + strengine = i18n(" [PDF 417]"); + break; + case TBARCODE: + strengine = i18n(" [TBarcode]"); + break; + case TBARCODE2: + strengine = i18n(" [TBarcode2]"); + break; + case PURE_POSTSCRIPT: + strengine = i18n(" [Barcode Writer in Pure Postscript]"); + break; + case NONE: + default: + // does not need to be translated as it should not visible anytime ever + strengine = " [NONE]"; + break; + } + + info.xml = xml; + info.name = name + strengine; + info.engine = engine; + info.features = features; + info.internal = internal; + + return info; +} + +void Barkode::initInfo() +{ + if( s_info.count() ) + return; + + PurePostscriptBarcode::init(); + + s_haveGnuBarcode = !KStandardDirs::findExe( "barcode" ).isNull(); + s_havePdfEncode = !KStandardDirs::findExe( "pdf417_enc" ).isNull(); + s_haveTBarcode = false; //!KStandardDirs::findExe( "tbarcodeclient" ).isNull(); +// TODO: do not yet enable TBarcode2 support + s_haveTBarcode2 = !KStandardDirs::findExe( "tbarcode" ).isNull(); + s_havePurePostscript = !KStandardDirs::findExe( "gs" ).isNull() + && PurePostscriptBarcode::hasPurePostscriptBarcode(); + + if( s_haveGnuBarcode ) + { + s_info.append( createInfo( "128raw", i18n("Raw code 128"), GNU_BARCODE, 0, BARCODE_128RAW ) ); + s_info.append( createInfo( "cbr", i18n("Codabar"), GNU_BARCODE, 0, BARCODE_CBR ) ); + s_info.append( createInfo( "cbr -c", i18n("Codabar (no checksum)"), GNU_BARCODE, 0, BARCODE_CBR ) ); + s_info.append( createInfo( "code128", i18n("Code 128 (a,b,c: autoselection)"), GNU_BARCODE, 0, BARCODE_128 ) ); + s_info.append( createInfo( "code128b", i18n("Code 128B, full printable ascii"), GNU_BARCODE, 0, BARCODE_128B ) ); + s_info.append( createInfo( "code128c", i18n("Code 128C (compact form digits)"), GNU_BARCODE, 0, BARCODE_128C ) ); + s_info.append( createInfo( "code39 -c", i18n("Code 39 (no checksum)"), GNU_BARCODE, 0, BARCODE_39 | BARCODE_NO_CHECKSUM ) ); + s_info.append( createInfo( "code39", i18n("Code 39"), GNU_BARCODE, 0, BARCODE_39 ) ); + s_info.append( createInfo( "code93", i18n("Code 93"), GNU_BARCODE, 0, BARCODE_93 ) ); + s_info.append( createInfo( "ean", i18n("EAN (EAN 8 or EAN 13)"), GNU_BARCODE, 0, BARCODE_EAN ) ); + s_info.append( createInfo( "i25 -c", i18n("interleaved 2 of 5 (only digits, no checksum)"), GNU_BARCODE, 0, BARCODE_I25 | BARCODE_NO_CHECKSUM ) ); + s_info.append( createInfo( "i25", i18n("interleaved 2 of 5 (only digits)"), GNU_BARCODE, 0, BARCODE_I25 ) ); + s_info.append( createInfo( "isbn", i18n("ISBN (still EAN13)"), GNU_BARCODE, NOCUT, BARCODE_ISBN ) ); + s_info.append( createInfo( "msi", i18n("MSI"), GNU_BARCODE, 0, BARCODE_MSI ) ); + s_info.append( createInfo( "pls", i18n("Plessey"), GNU_BARCODE, 0, BARCODE_PLS ) ); + s_info.append( createInfo( "upc", i18n("UPC (12-digit EAN; UPCA and UPCB)"), GNU_BARCODE, 0, BARCODE_UPC ) ); + } + + if( s_havePdfEncode ) + { + s_info.append( createInfo( "pdf417", i18n("pdf 417 2D Barcode"), PDF417, BARCODE2D | PDF417BARCODE ) ); + } + + if( s_havePurePostscript ) + { + // add a leading "ps_" so that they do not conflict with GNU Barcode types + PurePostscriptBarcode::initInfo( &s_info ); + + /* + s_info.append( createInfo( "ps_auspost", i18n("Australian Post"), PURE_POSTSCRIPT, PUREADV | COLORED | NOCUT ) ); + s_info.append( createInfo( "ps_code11", i18n("Code 11"), PURE_POSTSCRIPT, PUREADV | COLORED ) ); + s_info.append( createInfo( "ps_code128", i18n("Code 128"), PURE_POSTSCRIPT, PUREADV | COLORED ) ); + s_info.append( createInfo( "ps_code2of5", i18n("Code 2 of 5"), PURE_POSTSCRIPT, PUREADV | COLORED ) ); + s_info.append( createInfo( "ps_code39", i18n("Code 39"), PURE_POSTSCRIPT, PUREADV | COLORED | MODULOALLCHECK ) ); + s_info.append( createInfo( "ps_code93", i18n("Code 93"), PURE_POSTSCRIPT, PUREADV | COLORED ) ); + s_info.append( createInfo( "ps_ean13", i18n("EAN 13"), PURE_POSTSCRIPT, PUREADV | COLORED ) ); + s_info.append( createInfo( "ps_ean2", i18n("EAN 2"), PURE_POSTSCRIPT, PUREADV | COLORED | NOCUT ) ); + s_info.append( createInfo( "ps_ean5", i18n("EAN 5"), PURE_POSTSCRIPT, PUREADV | COLORED | NOCUT ) ); + s_info.append( createInfo( "ps_ean8", i18n("EAN 8"), PURE_POSTSCRIPT, PUREADV | COLORED ) ); + s_info.append( createInfo( "ps_interleaved2of5", i18n("Interleaved 2 of 5"), PURE_POSTSCRIPT, PUREADV | COLORED | MODULOALLCHECK ) ); + s_info.append( createInfo( "ps_isbn", i18n("ISBN"), PURE_POSTSCRIPT, PUREADV | COLORED ) ); + s_info.append( createInfo( "ps_kix", i18n("Kix (Dutch Postal)"), PURE_POSTSCRIPT, PUREADV | COLORED | NOCUT ) ); + s_info.append( createInfo( "ps_msi", i18n("MSI"), PURE_POSTSCRIPT, PUREADV | COLORED | MODULOALLCHECK ) ); + s_info.append( createInfo( "ps_plessey", i18n("Plessey"), PURE_POSTSCRIPT, PUREADV | COLORED ) ); + s_info.append( createInfo( "ps_postnet", i18n("Postnet"), PURE_POSTSCRIPT, PUREADV | COLORED | NOCUT ) ); + s_info.append( createInfo( "ps_rationalizedCodabar", i18n("Rationalized Codabar"), PURE_POSTSCRIPT, PUREADV | COLORED | MODULOALLCHECK ) ); + s_info.append( createInfo( "ps_royalmail", i18n("Royal Mail"), PURE_POSTSCRIPT, PUREADV | COLORED | NOCUT ) ); + s_info.append( createInfo( "ps_symbol", i18n("Symbol"), PURE_POSTSCRIPT, PUREADV | COLORED ) ); + s_info.append( createInfo( "ps_upca", i18n("UPCA"), PURE_POSTSCRIPT, PUREADV | COLORED ) ); + s_info.append( createInfo( "ps_upce", i18n("UPCE"), PURE_POSTSCRIPT, PUREADV | COLORED ) ); + */ + } + + if( s_haveTBarcode ) + { + s_info.append( createInfo( "b1", "Code 11", TBARCODE, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "b2", "Code 2 of 5 (Standard)", TBARCODE, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "b3", "Interleaved 2 of 5 Standard", TBARCODE, TBARCODEADV ) ); + s_info.append( createInfo( "b4", "Code 2 of 5 IATA", TBARCODE, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "b5", "Code 2 of 5 Matrix", TBARCODE, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "b6", "Code 2 of 5 Data Logic", TBARCODE, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "b7", "Code 2 of 5 Industrial", TBARCODE, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "b8", "Code 3 of 9 (Code 39)", TBARCODE, TBARCODEADV | MODULOALLCHECK ) ); + s_info.append( createInfo( "b9", "Code 3 of 9 (Code 39) ASCII", TBARCODE, TBARCODEADV | MODULOALLCHECK ) ); + s_info.append( createInfo( "b10", "EAN8", TBARCODE, TBARCODEADV | EAN8CHECK | MODULO10CHECK ) ); + s_info.append( createInfo( "b11", "EAN8 - 2 digits add on", TBARCODE, NOCUT | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) ); + s_info.append( createInfo( "b12", "EAN8 - 5 digits add on", TBARCODE, NOCUT | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) ); + s_info.append( createInfo( "b13", "EAN13", TBARCODE, TBARCODEADV | EAN13CHECK | MODULO10CHECK ) ); + s_info.append( createInfo( "b14", "EAN13 - 2 digits add on", TBARCODE, NOCUT | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) ); + s_info.append( createInfo( "b15", "EAN13 - 5 digits add on", TBARCODE, NOCUT | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) ); + s_info.append( createInfo( "b16", "EAN128 (supports AIS)", TBARCODE, TBARCODEADV | MODULOALLCHECK ) ); + s_info.append( createInfo( "b17", "UPC 12 Digits", TBARCODE, TBARCODEADV | MODULOALLCHECK ) ); + s_info.append( createInfo( "b18", "CodaBar (2 width)", TBARCODE, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "b19", "CodaBar (18 widths)", TBARCODE, TBARCODEADV ) ); + s_info.append( createInfo( "b20", "Code128", TBARCODE, TBARCODEADV ) ); + s_info.append( createInfo( "b21", "Deutsche Post Leitcode", TBARCODE, TBARCODEADV ) ); + s_info.append( createInfo( "b22", "Deutsche Post Identcode", TBARCODE, TBARCODEADV ) ); + s_info.append( createInfo( "b25", "Code 93", TBARCODE, TBARCODEADV ) ); + s_info.append( createInfo( "b26", "Identical to eBC_UPCA", TBARCODE, TBARCODEADV ) ); + s_info.append( createInfo( "b33", "UCC128 (= EAN128)", TBARCODE, TBARCODEADV ) ); + s_info.append( createInfo( "b34", "UPC A", TBARCODE, TBARCODEADV | TBARCODEADV | UPCACHECK ) ); + s_info.append( createInfo( "b35", "UPC A - 2 digit add on", TBARCODE, TBARCODEADV | UPCACHECK ) ); + s_info.append( createInfo( "b36", "UPC A - 5 digit add on", TBARCODE, TBARCODEADV | UPCACHECK ) ); + s_info.append( createInfo( "b37", "UPC E", TBARCODE, TBARCODEADV | UPCECHECK ) ); + s_info.append( createInfo( "b38", "UPC E - 2 digit add on", TBARCODE, TBARCODEADV | UPCECHECK ) ); + s_info.append( createInfo( "b39", "UPC E - 5 digit add on", TBARCODE, TBARCODEADV | UPCECHECK ) ); + s_info.append( createInfo( "b40", "PostNet ZIP (5d.)", TBARCODE, NOCUT | TBARCODEADV | POSTNETCHECK ) ); + s_info.append( createInfo( "b41", "PostNet ZIP (5d.+CD)", TBARCODE, NOCUT | TBARCODEADV | POSTNETCHECK ) ); + s_info.append( createInfo( "b42", "PostNet ZIP (8d.)", TBARCODE, NOCUT | TBARCODEADV | POSTNETCHECK ) ); + s_info.append( createInfo( "b43", "PostNet ZIP+4 (5d.+4d.+CD)", TBARCODE, NOCUT | TBARCODEADV | POSTNETCHECK ) ); + s_info.append( createInfo( "b44", "PostNet DPBC (5d.+4d.+2d.)", TBARCODE, NOCUT | TBARCODEADV | POSTNETCHECK ) ); + s_info.append( createInfo( "b45", "PostNet DPBC (5d.+4d.+2d.+CD)", TBARCODE, NOCUT | TBARCODEADV | POSTNETCHECK ) ); + s_info.append( createInfo( "b46", "Plessey Code", TBARCODE, TBARCODEADV ) ); + s_info.append( createInfo( "b47", "MSI Code", TBARCODE, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "b50", "LOGMARS", TBARCODE, TBARCODEADV | MODULOALLCHECK ) ); + s_info.append( createInfo( "b55", "PDF417 - 2D bar code", TBARCODE, BARCODE2D | PDF417BARCODE ) ); + s_info.append( createInfo( "b56", "PDF417 Truncated - 2D bar code", TBARCODE, BARCODE2D | PDF417BARCODE ) ); + s_info.append( createInfo( "b57", "MaxiCode - 2D-bar code (Postscript only)", TBARCODE, BARCODE2D ) ); + s_info.append( createInfo( "b58", "QR-Code", TBARCODE, BARCODE2D ) ); + s_info.append( createInfo( "b59", "Code128 (CharSet A)", TBARCODE, TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) ); + s_info.append( createInfo( "b60", "Code128 (CharSet B)", TBARCODE, TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) ); + s_info.append( createInfo( "b61", "Code128 (CharSet C)", TBARCODE, TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) ); + s_info.append( createInfo( "b62", "Code 93 Ascii", TBARCODE, TBARCODEADV | MODULOALLCHECK ) ); + s_info.append( createInfo( "b63", "Australian Post Standard Customer", TBARCODE, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "b64", "Australian Post Customer 2", TBARCODE, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "b65", "Australian Post Customer 3", TBARCODE, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "b66", "Australian Post Reply Paid", TBARCODE, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "b67", "Australian Post Routing", TBARCODE, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "b68", "Australian Post Redirection", TBARCODE, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "b69", "ISBN Code (=EAN13P5)", TBARCODE, TBARCODEADV ) ); + s_info.append( createInfo( "b70", "Royal Mail 4 State (RM4SCC)", TBARCODE, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "b71", "Data Matrix", TBARCODE, DATAMATRIX | BARCODE2D | NOSCALE ) ); + } + + if( s_haveTBarcode2 ) + { + s_info.append( createInfo( "1", "Code 11", TBARCODE2, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "2", "Code 2 of 5 (Standard)", TBARCODE2, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "3", "Interleaved 2 of 5 Standard", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "4", "Code 2 of 5 IATA", TBARCODE2, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "5", "Code 2 of 5 Matrix", TBARCODE2, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "6", "Code 2 of 5 Data Logic", TBARCODE2, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "7", "Code 2 of 5 Industrial", TBARCODE2, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "8", "Code 3 of 9 (Code 39)", TBARCODE2, TBARCODEADV | MODULOALLCHECK ) ); + s_info.append( createInfo( "9", "Code 3 of 9 (Code 39) ASCII", TBARCODE2, TBARCODEADV | MODULOALLCHECK ) ); + s_info.append( createInfo( "10", "EAN8", TBARCODE2, TBARCODEADV | EAN8CHECK | MODULO10CHECK ) ); + s_info.append( createInfo( "11", "EAN8 - 2 digits add on", TBARCODE2, NOCUT | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) ); + s_info.append( createInfo( "12", "EAN8 - 5 digits add on", TBARCODE2, NOCUT | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) ); + s_info.append( createInfo( "13", "EAN13", TBARCODE2, TBARCODEADV | EAN13CHECK | MODULO10CHECK ) ); + s_info.append( createInfo( "14", "EAN13 - 2 digits add on", TBARCODE2, NOCUT | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) ); + s_info.append( createInfo( "15", "EAN13 - 5 digits add on", TBARCODE2, NOCUT | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) ); + s_info.append( createInfo( "16", "EAN128", TBARCODE2, TBARCODEADV | MODULOALLCHECK ) ); + s_info.append( createInfo( "17", "UPC 12 Digits", TBARCODE2, TBARCODEADV | MODULOALLCHECK ) ); + s_info.append( createInfo( "18", "CodaBar (2 width)", TBARCODE2, TBARCODEADV | MODULO10CHECK ) ); + //s_info.append( createInfo( "19", "CodaBar (18 widths)", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "20", "Code128", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "21", "Deutsche Post Leitcode", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "22", "Deutsche Post Identcode", TBARCODE2, TBARCODEADV ) ); + //s_info.append( createInfo( "23", "Code 16K", TBARCODE2, TBARCODEADV ) ); + //s_info.append( createInfo( "24", "Code 49", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "25", "Code 93", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "26", "UPC 25 (Identical to UPCA)", TBARCODE2, TBARCODEADV ) ); + //s_info.append( createInfo( "27", "UPCD1", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "28", "Flattermarken", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "29", "RSS-14", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "30", "RSS Limited", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "31", "RSS Expanded", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "32", "Telepen Alpha", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "33", "UCC128 (= EAN128)", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "34", "UPC A", TBARCODE2, TBARCODEADV | TBARCODEADV | UPCACHECK ) ); + s_info.append( createInfo( "35", "UPC A - 2 digit add on", TBARCODE2, TBARCODEADV | UPCACHECK ) ); + s_info.append( createInfo( "36", "UPC A - 5 digit add on", TBARCODE2, TBARCODEADV | UPCACHECK ) ); + s_info.append( createInfo( "37", "UPC E", TBARCODE2, TBARCODEADV | UPCECHECK ) ); + s_info.append( createInfo( "38", "UPC E - 2 digit add on", TBARCODE2, TBARCODEADV | UPCECHECK ) ); + s_info.append( createInfo( "39", "UPC E - 5 digit add on", TBARCODE2, TBARCODEADV | UPCECHECK ) ); + s_info.append( createInfo( "40", "PostNet5", TBARCODE2, NOCUT | TBARCODEADV | POSTNETCHECK ) ); + s_info.append( createInfo( "41", "PostNet6 (5+CD)", TBARCODE2, NOCUT | TBARCODEADV | POSTNETCHECK ) ); + s_info.append( createInfo( "42", "PostNet9 (5+4)", TBARCODE2, NOCUT | TBARCODEADV | POSTNETCHECK ) ); + s_info.append( createInfo( "43", "PostNet10 (5+4+CD)", TBARCODE2, NOCUT | TBARCODEADV | POSTNETCHECK ) ); + s_info.append( createInfo( "44", "PostNet11 (5+4+2)", TBARCODE2, NOCUT | TBARCODEADV | POSTNETCHECK ) ); + s_info.append( createInfo( "45", "PostNet12 (5+4+2+CD)", TBARCODE2, NOCUT | TBARCODEADV | POSTNETCHECK ) ); + s_info.append( createInfo( "46", "Plessey Code", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "47", "MSI Code", TBARCODE2, TBARCODEADV | MODULO10CHECK ) ); + s_info.append( createInfo( "48", "SSCC18", TBARCODE2, TBARCODEADV ) ); + //s_info.append( createInfo( "49", "FIM", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "50", "LOGMARS", TBARCODE2, TBARCODEADV | MODULOALLCHECK ) ); + s_info.append( createInfo( "51", "Pharmacode One-Track", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "52", "Pharmacentralnumber", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "53", "Pharmacode Two-Track", TBARCODE2, TBARCODEADV ) ); + //s_info.append( createInfo( "54", "General Parcel", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "55", "PDF417 - 2D bar code", TBARCODE2, BARCODE2D | PDF417BARCODE ) ); + s_info.append( createInfo( "56", "PDF417 Truncated - 2D bar code", TBARCODE2, BARCODE2D | PDF417BARCODE ) ); + s_info.append( createInfo( "57", "MaxiCode - 2D-bar code (Postscript only)", TBARCODE2, BARCODE2D ) ); + s_info.append( createInfo( "58", "QR-Code", TBARCODE2, BARCODE2D ) ); + s_info.append( createInfo( "59", "Code128 (CharSet A)", TBARCODE2, TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) ); + s_info.append( createInfo( "60", "Code128 (CharSet B)", TBARCODE2, TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) ); + s_info.append( createInfo( "61", "Code128 (CharSet C)", TBARCODE2, TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) ); + s_info.append( createInfo( "62", "Code 93 Ascii", TBARCODE2, TBARCODEADV | MODULOALLCHECK ) ); + s_info.append( createInfo( "63", "Australian Post Standard Customer", TBARCODE2, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "64", "Australian Post Customer 2", TBARCODE2, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "65", "Australian Post Customer 3", TBARCODE2, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "66", "Australian Post Reply Paid", TBARCODE2, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "67", "Australian Post Routing", TBARCODE2, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "68", "Australian Post Redirection", TBARCODE2, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "69", "ISBN Code (=EAN13P5)", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "70", "Royal Mail 4 State (RM4SCC)", TBARCODE2, NOCUT | TBARCODEADV ) ); + s_info.append( createInfo( "71", "Data Matrix", TBARCODE2, DATAMATRIX | BARCODE2D | NOSCALE ) ); + s_info.append( createInfo( "72", "EAN-14", TBARCODE2, TBARCODEADV ) ); + //s_info.append( createInfo( "73", "Codablock-E", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "74", "Codablock-F", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "75", "NVE-18", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "76", "Japanese Postal Code", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "77", "Korean Postal", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "78", "RSS-14 Truncated", TBARCODE2, BARCODE2D ) ); + s_info.append( createInfo( "79", "RSS-14 Stacked", TBARCODE2, BARCODE2D ) ); + s_info.append( createInfo( "80", "RSS-14 Stacked Omnidirektional", TBARCODE2, BARCODE2D ) ); + s_info.append( createInfo( "81", "RSS Expanded Stacked", TBARCODE2, BARCODE2D ) ); + s_info.append( createInfo( "82", "Planet 12 digits", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "83", "Planet 14 digits", TBARCODE2, TBARCODEADV ) ); + s_info.append( createInfo( "84", "MicroPDF417", TBARCODE2, BARCODE2D ) ); + } + + Barkode::initValidators(); +} + +void Barkode::initValidators() +{ + QString path; + const char* rules = "/usr/share/libpostscriptbarcode/rules.xml"; + if( QFile::exists( rules ) ) + path = rules; + else + path = locate( "data", "kbarcode/rules.xml" ); + + QFile xml( path ); + QDomDocument doc; + QDomElement root; + QDomNode n; + QString id; + QString* regular; + QString* regularNot; + + if( !xml.open( IO_ReadOnly ) ) + { + qDebug( "Cannot read validation rules from %s\n", path.latin1() ); + return; + } + + doc.setContent( &xml ); + root = doc.documentElement(); + n = root.firstChild(); + + while( !n.isNull() ) + { + QDomElement e = n.toElement(); + if( !e.isNull() && e.tagName() == "encoder" ) + { + id = e.attribute( "id" ); + id.prepend( "ps_" ); + regular = Barkode::validatorFromType( id ); + regularNot = Barkode::validatorNotFromType( id ); + + QDomNode child = e.firstChild(); + while( !child.isNull() ) + { + QDomElement e = child.toElement(); + QString pattern = QString::null; + + if( child.firstChild().isCDATASection() ) + { + pattern = child.firstChild().toCDATASection().data().stripWhiteSpace(); + } + + + if( !e.isNull() && e.tagName() == "pattern" ) + { + QString sense = e.attribute( "sense", "true" ); + if( sense == "true" ) + *regular = pattern; + else + *regularNot = pattern; + } + + child = child.nextSibling(); + } + } + + n = n.nextSibling(); + } + + xml.close(); +} + diff --git a/kbarcode/barkode.h b/kbarcode/barkode.h new file mode 100644 index 0000000..4d7004b --- /dev/null +++ b/kbarcode/barkode.h @@ -0,0 +1,297 @@ +/* This file is part of the KDE project + Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef BARKODE_H +#define BARKODE_H + + +#include <qcolor.h> +#include <qstring.h> + +#include "barkodeengine.h" + +/** + * Enumeration values for sequence modes + */ +typedef enum { NUM, ALPHA, ALPHANUM } ESequence; + +/** This values are used to indicate the feature supported by a + * certain barcode typedef + */ +enum { NOCUT = 0x00001, MULTILINE = 0x00002, NOTEXT = 0x00004, NOSCALE = 0x00008, + /** + * Different advanced option modes. + */ + PDF417BARCODE = 0x00100, TBARCODEADV = 0x00200, PUREADV = 0x00400, DATAMATRIX = 0x00800, + COLORED = 0x00010, + + /** + * Checksum ID's + */ + POSTNETCHECK = 0x01000, CODE128CHECK = 0x02000, EAN8CHECK = 0x04000, EAN13CHECK = 0x08000, + UPCACHECK = 0x10000, UPCECHECK = 0x20000, MODULOALLCHECK = 0x40000, MODULO10CHECK = 0x80000, + + /** + * Short cut's + */ + BARCODE2D = NOCUT | MULTILINE | NOTEXT }; + +/** This structure holds information about a supported barcode encoding typedef + */ +typedef struct tBarcodeInfo +{ + /** the name which is stored for identification in the xml file + * and used as commandline parameter for external tools + */ + QString xml; + /** the user visible name of this typedef + */ + QString name; + /** the barcode engine to use + */ + EEngine engine; + /** features supported by this type orred together + */ + unsigned int features; + + /** internal value (e.g. identifier of GNU Barcode) + */ + int internal; + + /** A regular expression that validates + * a value for this barcode. + */ + QString validator; + QString validatorNot; +}; + +typedef QValueList<tBarcodeInfo> TBarcodeInfoList; + +class BarkodeEngine; +class QPainter; +class QPicture; +class QSize; +class QPaintDevice; +class TokenProvider; + +class Barkode { + public: + Barkode(); + Barkode( const Barkode & barkode ); + virtual ~Barkode(); + + /** set a TokenProvider for data field parsing + */ + void setTokenProvider( TokenProvider* token ); + + /** restore default values + */ + void defaults(); + + /** call this method after you changed a property + * to update the internal structures + */ + void update( const QPaintDevice* device ); + + /** get the barcode value after all sequences and datafields have + * been parsed + */ + const QString parsedValue(); + + const QPixmap pixmap( double scalex = 1.0, double scaley = 1.0 ); + const QPicture picture(); + const QSize size() const; + bool isValid() const; + + const QColor & background() const; + const QColor & foreground() const; + const QColor & textColor() const; + const unsigned int fontsize() const; + const unsigned int quietZone() const; + const unsigned int barHeight() const; + const QString & type() const; + const QString & value() const; + const bool sequenceEnabled() const; + const ESequence sequenceMode() const; + const int sequenceStart() const; + const int sequenceStep() const; + const QString & databaseMode() const; + const bool textVisible() const; + const int rotation() const; + const double scaling() const; + const unsigned int index() const; + const double cut() const; + const int datamatrixSize() const; + + void setBackground( const QColor & c ); + void setForeground( const QColor & c ); + void setTextColor( const QColor & c ); + void setFontsize ( unsigned int f ); + void setQuietZone( unsigned int q ); + void setBarHeight( unsigned int h ); + void setType( const QString & type ); + void setValue( const QString & value ); + void setTextVisible( const bool b ); + /** Set the index of the barcodes for barcode sequences. + */ + void setIndex( unsigned int i ); + void setSequenceEnabled( bool b ); + void setSequenceMode( ESequence e ); + void setSequenceStart( int s ); + void setSequenceStep( int s ); + void setDatabaseMode( const QString & mode ); + void setRotation( const int r ); + void setScaling( const double d ); + void setCut( const double c ); + void setDatamatrixSize( int s ); + + /** Sets the barcodes data structures + * the same as operator= + */ + void setData( const Barkode & barkode ); + void operator=( const Barkode & barkode ); + bool operator==( const Barkode & barkode ) const; + + inline BarkodeEngine* engine(); + inline const BarkodeEngine* engine() const; + + /** Test if the encodingType @p type has a certain + * @p feature, as defined in the codes QValueList. + */ + static bool hasFeature( const QString & type, unsigned int feature ); + /** Returns the internal value for the encoding type @p typedef + */ + static int internalType( const QString & type ); + /** Returns all supported encoding types + * ready for displaying them to the user + */ + static const QStringList* encodingTypes(); + /** Convert the uservisible encoding type @p name + * to the internal identifier + */ + static const char* typeFromName( const QString & name ); + /** Convert the internal identifier @p type + * to the user visible encoding name + */ + static const char* nameFromType( const QString & type ); + + static QString* validatorFromType( const QString & type ); + static QString* validatorNotFromType( const QString & type ); + + /** return the barcode generation engine for type @p typedef + */ + + static EEngine engineForType( const QString & type ); + /** Draw an invalid barcode sign to QPainter @p painter + */ + void drawInvalid( QPainter & painter, int x = 0, int y = 0 ); + + /** returns wether barcode functionallity + * is available + */ + static bool haveBarcode() { + Barkode::initInfo(); + return ( s_haveGnuBarcode || s_havePdfEncode || s_haveTBarcode || s_havePurePostscript ); + } + static bool haveGNUBarcode() { + Barkode::initInfo(); + return s_haveGnuBarcode; + } + static bool haveTBarcode() { + Barkode::initInfo(); + return s_haveTBarcode; + } + static bool haveTBarcode2() { + Barkode::initInfo(); + return s_haveTBarcode2; + } + static bool havePDFBarcode() { + Barkode::initInfo(); + return s_havePdfEncode; + } + static bool havePurePostscriptBarcode() { + Barkode::initInfo(); + return s_havePurePostscript; + } + + static tBarcodeInfo createInfo( const char* xml, const QString & name, const EEngine engine, + const unsigned int features = 0, const int internal = 0 ); + + protected: + void drawBarcode( QPainter & painter, int x = 0, int y = 0 ); + + private: + static void initInfo(); + static void initValidators(); + + void updateEngine(); + + protected: + BarkodeEngine* m_engine; + TokenProvider* m_token; + + bool m_valid; + bool m_sequence; + ESequence m_esequence; + int m_sequence_start; + int m_sequence_step; + bool m_text_visible; + + QColor m_background; + QColor m_foreground; + QColor m_textcolor; + + unsigned int m_quietzone; + unsigned int m_bar_height; + unsigned int m_fontsize; + unsigned int m_index; + int m_datamatrix_size; + int m_rotation; + + double m_scaling; + double m_cut; // temporarly used for the pixmap engines + // won't be needed for the Barkode engine + + QString m_type; + QString m_value; + QString m_database_mode; + + static TBarcodeInfoList s_info; + static QStringList* s_encoding; + + static bool s_haveGnuBarcode; + static bool s_haveTBarcode; + static bool s_haveTBarcode2; + static bool s_havePdfEncode; + static bool s_havePurePostscript; +}; + +BarkodeEngine* Barkode::engine() +{ + return m_engine; +} + +const BarkodeEngine* Barkode::engine() const +{ + return m_engine; +} + +#endif // BARKODE_H + + diff --git a/kbarcode/barkodeengine.cpp b/kbarcode/barkodeengine.cpp new file mode 100644 index 0000000..f05440e --- /dev/null +++ b/kbarcode/barkodeengine.cpp @@ -0,0 +1,55 @@ +/*************************************************************************** + barkodeengine.cpp - description + ------------------- + begin : Fri Nov 05 2004 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "barkodeengine.h" +#include "barkode.h" + +BarkodeEngine::BarkodeEngine() +{ + m_valid = false; + barkode = NULL; +} + +BarkodeEngine::~BarkodeEngine() +{ +} + +BarkodeEngineOptions* BarkodeEngine::options() +{ + return NULL; +} + +EmptyEngine::EmptyEngine() + : BarkodeEngine() +{ +} + +void EmptyEngine::update( const QPaintDevice* ) +{ + // Do nothing +} + +const QSize EmptyEngine::size() const +{ + return QSize( 150, 80 ); +} + +void EmptyEngine::drawBarcode( QPainter & painter, int x, int y ) +{ + barkode->drawInvalid( painter, x, y ); +} + diff --git a/kbarcode/barkodeengine.h b/kbarcode/barkodeengine.h new file mode 100644 index 0000000..037667c --- /dev/null +++ b/kbarcode/barkodeengine.h @@ -0,0 +1,103 @@ +/*************************************************************************** + barkodeengine.h - description + ------------------- + begin : Fri Nov 05 2004 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef BARKODEENGINE_H +#define BARKODEENGINE_H + +/** + * The different generator backends / engines + */ +typedef enum { GNU_BARCODE, PDF417, TBARCODE, TBARCODE2, PIXMAP, PURE_POSTSCRIPT, NONE } EEngine; + +class Barkode; +class QDomElement; +class QPainter; + +/** An interface for additional special options + * supported by a BarkodeEngine + */ +class BarkodeEngineOptions { + public: + BarkodeEngineOptions() {}; + virtual ~BarkodeEngineOptions() {}; + + virtual void defaults() = 0; + + virtual void load( const QDomElement* tag ) = 0; + virtual void save( QDomElement* tag ) = 0; +}; + +#include <qsize.h> + +/** + * Inherit from this class if you want to create a + * (barkode engine) for use with KBarcode. + * @author Dominik Seichter + */ +class BarkodeEngine{ + public: + BarkodeEngine(); + virtual ~BarkodeEngine(); + + virtual const BarkodeEngine & operator=( const BarkodeEngine & rhs ) = 0; + + virtual EEngine engine() const = 0; + virtual void update( const QPaintDevice* device ) = 0; + virtual const QSize size() const = 0; + + void setBarkode( Barkode* b ) { barkode = b; } + virtual void drawBarcode( QPainter & painter, int x, int y ) = 0; + + /** @returns a pointer to a BarkodeEngineOptions object + * if this BarkodeEngine has one. Otherwise null is returned. + * The returned object has to be casted down to the concrete object + * you want to use, before setting any of the options. + */ + virtual BarkodeEngineOptions* options(); + + protected: + Barkode* barkode; + QSize m_size; + + bool m_valid; +}; + +/** A barcode engine with implemented empty and does + * nothing + */ +class EmptyEngine : public BarkodeEngine { + public: + EmptyEngine(); + + virtual inline const BarkodeEngine & operator=( const BarkodeEngine & rhs ); + virtual inline EEngine engine() const; + virtual void update( const QPaintDevice* device ); + virtual const QSize size() const; + virtual void drawBarcode( QPainter & painter, int x, int y ); +}; + +const BarkodeEngine & EmptyEngine::operator=( const BarkodeEngine & ) +{ + return *this; +} + +EEngine EmptyEngine::engine() const +{ + return NONE; +} + +#endif diff --git a/kbarcode/batchiface.h b/kbarcode/batchiface.h new file mode 100644 index 0000000..6eb6586 --- /dev/null +++ b/kbarcode/batchiface.h @@ -0,0 +1,46 @@ +/*************************************************************************** + batchiface.h - description + ------------------- + begin : Sat Dec 27 23:54:28 CET 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef BATCHIFACE_H +#define BATCHIFACE_H + +#include <dcopobject.h> +#include <qstringlist.h> +#include "batchprinter.h" + +class BatchIface : virtual public DCOPObject +{ + K_DCOP + + public: + k_dcop: + virtual void setFilename( const QString & url ) = 0; + virtual void setImportCsvFile( const QString & filename ) = 0; + virtual void setImportSqlQuery( const QString & query ) = 0; + virtual void setNumLabels( const int n ) = 0; + virtual void setOutputFormat( const int e ) = 0; + virtual void setSerialNumber( const QString & val, int inc ) = 0; + + virtual bool addItem( const QString & article, const QString & group, int count = 1, bool msg = true ) = 0; + virtual bool existsArticle( const QString & article ) = 0; + virtual void loadFromFile( const QString & url ) = 0; + virtual void loadFromClipboard() = 0; + virtual void printNow( const QString & printer, bool bUserInteraction = true ) = 0; +}; + +#endif /* BATCHIFACE_H */ + diff --git a/kbarcode/batchprinter.cpp b/kbarcode/batchprinter.cpp new file mode 100644 index 0000000..9ca66c3 --- /dev/null +++ b/kbarcode/batchprinter.cpp @@ -0,0 +1,542 @@ +/*************************************************************************** + batchprinter.cpp - description + ------------------- + begin : Sat Jan 10 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "batchprinter.h" + +#include "definition.h" +#include "kbarcode.h" +#include "label.h" +#include "printersettings.h" +#include "zplutils.h" +#include "tec.h" + +// Qt includes +#include <qfile.h> +#include <qpainter.h> +#include <qpaintdevicemetrics.h> +#include <qprogressdialog.h> + +// KDE includes +#include <kabc/addressee.h> +#include <kabc/addresseelist.h> +#include <kapplication.h> +#include <kconfig.h> +#include <kimageio.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kprinter.h> + +// Other includes +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <krun.h> +#define MAXDATASIZE 32550 + +BatchPrinter::BatchPrinter( KPrinter* p, QWidget* _parent ) + : printer( p ), parent( _parent ) +{ + m_events = true; + m_data = NULL; + m_vardata = NULL; + m_addrdata = NULL; + + m_cur_data_count = 0; + + m_paintDevice = p; +} + +BatchPrinter::BatchPrinter( const QString & path, QWidget* p ) + : m_path( path ), parent( p ) +{ + m_data = NULL; + m_vardata = NULL; + m_addrdata = NULL; + m_move = 0; + m_image_filename = E_BARCODE; + + m_cur_data_count = 0; + + m_paintDevice = p; +} + +BatchPrinter::BatchPrinter( const QString & path, int format, QWidget* _parent ) + : m_path( path ), m_bcp_format( format ), parent( _parent ) +{ + m_data = NULL; + m_vardata = NULL; + m_addrdata = NULL; + m_move = 0; + m_image_filename = E_BARCODE; + + m_cur_data_count = 0; + + m_paintDevice = _parent; +} + +BatchPrinter::~BatchPrinter() +{ + delete m_data; + delete m_vardata; + delete m_addrdata; +} + +void BatchPrinter::start() +{ + painter = new QPainter( printer ); + m_cur_data_count = 0; + + QPaintDeviceMetrics pdm( painter->device() ); + + pageh = pdm.height(); // in pixel + + curw = 0; + curh = 0; + c_h = 0; + c_w = 0; + + QProgressDialog* progress = createProgressDialog( i18n("Printing...") ); + + m_measure = def->getMeasurements(); + + moveLabels(); + if( m_data ) + startPrintData( progress ); + else if( m_vardata || m_addrdata ) + startPrintVarData( progress ); + + painter->end(); + delete progress; + delete painter; +} + +void BatchPrinter::startPrintData( QProgressDialog* progress ) +{ + labelprinterdata* lpdata = PrinterSettings::getInstance()->getData(); + + unsigned int index = 0; // counter gets increased for every label, but not for + // labels like article_no etc. (those who are created + // by events. + + for( unsigned int i = 0; i < m_data->count(); i++ ) + { + Label l( def, buffer, m_name, printer, m_customer, + (*m_data)[i].article_no, (*m_data)[i].group ); + l.setSerial( m_serial, m_increment ); + + bool newgroup = false; + if( i == 0 ) + newgroup = true; + else { + if( (*m_data)[i].group != (*m_data)[i-1].group ) + newgroup = true; + } + + if( !curw ) + curw = m_measure.gapLeft( printer ); + + if( !curh ) + curh = m_measure.gapTop( printer ); + + if( m_events ) { + if( newgroup ) { + proccessEvents( lpdata->groupEvent1, i18n("Group : ") + (*m_data)[i].group, &l ); + proccessEvents( lpdata->groupEvent2, i18n("Group : ") + (*m_data)[i].group, &l ); + proccessEvents( lpdata->groupEvent3, i18n("Group : ") + (*m_data)[i].group, &l ); + proccessEvents( lpdata->groupEvent4, i18n("Group : ") + (*m_data)[i].group, &l ); + } + proccessEvents( lpdata->articleEvent1, i18n("Article No. : ") + (*m_data)[i].article_no, &l ); + proccessEvents( lpdata->articleEvent2, i18n("Article No. : ") + (*m_data)[i].article_no, &l ); + proccessEvents( lpdata->articleEvent3, i18n("Article No. : ") + (*m_data)[i].article_no, &l ); + proccessEvents( lpdata->articleEvent4, i18n("Article No. : ") + (*m_data)[i].article_no, &l ); + } + + for( int z = 0; z < (*m_data)[i].number; z++ ) { + changeLine(); + checkForNewPage( &l ); + + painter->setClipRect((int)curw, (int)curh, (int)m_measure.width( printer ), (int)m_measure.height( printer )); + l.setIndex( index ); + l.setRow( c_w ); + l.setCol( c_h ); + painter->save(); + l.draw( painter, (int)curw, (int)curh ); + painter->restore(); + + //painter->drawPicture( (int)curw, (int)curh, *l.picture() ); + index++; + painter->setClipping( false ); + + drawBorders(); + + curw += m_measure.gapH( printer ); + c_h++; + + if( !checkProgressDialog( progress) ) { + printer->abort(); + painter->end(); + return; + } + } + } +} + +void BatchPrinter::startPrintVarData( QProgressDialog* progress ) +{ + Label* l; + while( ( l = initLabel() ) != NULL ) + { + if( !curw ) + curw = m_measure.gapLeft( printer ); + + if( !curh ) + curh = m_measure.gapTop( printer ); + + changeLine(); + checkForNewPage( l ); + + painter->setClipRect((int)curw, (int)curh, (int)m_measure.width( printer ), (int)m_measure.height( printer )); + + painter->save(); + l->draw( painter, (int)curw, (int)curh ); + delete l; + painter->restore(); + + painter->setClipping( false ); + + drawBorders(); + + curw += m_measure.gapH( printer ); + c_h++; + + if( !checkProgressDialog( progress) ) + { + printer->abort(); + painter->end(); + return; + } + } +} + +Label* BatchPrinter::initLabel( int* number ) +{ + Label* l = NULL; + + if( (m_vardata && m_cur_data_count >= m_vardata->count() ) || + (m_data && m_cur_data_count >= m_data->count() ) || + (m_addrdata && m_cur_data_count >= m_addrdata->count() ) ) + return NULL; + + if( number ) + *number = 1; + + if( m_vardata ) + { + l = new Label( def, buffer, m_name, m_paintDevice ); + l->setUserVars( (*m_vardata)[m_cur_data_count] ); + } + else if( m_data ) + { + l = new Label( def, buffer, m_name, m_paintDevice, m_customer, + (*m_data)[m_cur_data_count].article_no, (*m_data)[m_cur_data_count].group ); + if( number ) + *number = (*m_data)[m_cur_data_count].number; + } + else if( m_addrdata ) + { + l = new Label( def, buffer, m_name, m_paintDevice ); + l->setAddressee( &((*m_addrdata)[m_cur_data_count]) ); + } + + l->setSerial( m_serial, m_increment ); + l->setIndex( m_cur_data_count ); + m_cur_data_count++; + + return l; +} + +void BatchPrinter::startImages() +{ + QProgressDialog* progress = createProgressDialog( i18n("Creating Images...") ); + + int number = 0; + m_cur_data_count = 0; + + Measurements measure = def->getMeasurements(); + Label* l = NULL; + painter = new QPainter(); + QPixmap pixmap( (int)measure.width( parent ), (int)measure.height( parent ) ); + while( (l = initLabel( &number ) ) != NULL ) + { + for( int i = 0; i < number; i++ ) + { + pixmap.fill( Qt::white ); + painter->begin( &pixmap ); + l->setIndex( i ); + l->setRow( 0 ); + l->setCol( 0 ); + l->draw( painter, 0, 0 ); + + painter->end(); + + QString name = m_path + "/"; + if( m_image_filename == E_ARTICLE ) + name += m_data ? (*m_data)[m_cur_data_count].article_no : QString::number( m_cur_data_count ); + else if( m_image_filename == E_BARCODE ) + name += l->barcodeNo(); + else + name += m_image_custom_filename; + + QString filename = name + QString("_%1.").arg( i ) + KImageIO::suffix( m_image_format ); + + unsigned int c = 0; + while( QFile::exists( filename ) ) { + filename += "." + QString::number( c ); + c++; + } + + pixmap.save( filename, m_image_format ); + + if( !checkProgressDialog( progress ) ) + { + delete l; + delete progress; + delete painter; + return; + } + } + + delete l; + } + + delete progress; + delete painter; + + new KRun( m_path ); +} + +void BatchPrinter::startBCP() +{ + int number = 0; + QFile file( m_path ); + if( !file.open( IO_WriteOnly ) ) // | IO_Raw ) ) + { + KMessageBox::error( parent, QString( i18n("<qt>Can't open the file or device <b>%1</b></qt>.") ).arg( m_path ) ); + return; + } + + QProgressDialog* progress = createProgressDialog( i18n("Printing...") ); + + if( m_bcp_format == PrinterSettings::ZEBRA ) + // Zebra printers are printed at 304dpi, this should + // be user defined, though + m_paintDevice = new BarcodePrinterDevice( 304.0, 304.0 ); + else if( m_bcp_format == PrinterSettings::INTERMEC ) + m_paintDevice = new BarcodePrinterDevice( 300.0, 300.0 ); + else if( m_bcp_format == PrinterSettings::TEC ) + // don't know which resolution is used for tec printers + // so we use a factor to convert everything to mm + // this is not accurate as QPaintDevice supports only integers + m_paintDevice = new BarcodePrinterDevice( 25.4000508001016, 25.4000508001016 ); + else if( m_bcp_format == PrinterSettings::EPCL ) + m_paintDevice = new BarcodePrinterDevice( 304.0, 304.0 ); + + + QTextStream stream( &file ); + Label* l; + while( ( l = initLabel( &number ) ) != NULL ) + { + for( int i = 0; i < number; i++ ) + { + switch( m_bcp_format ) + { + case PrinterSettings::TEC: + // TODO: normally you should not care about the number or counter + // KBarcode will ensure that the label is printed often enough + if( m_data ) + stream << tec452(m_name, (*m_data)[m_cur_data_count].number, (*m_data)[m_cur_data_count].article_no, (*m_data)[m_cur_data_count].group, m_customer); + else + /* TODO */; + #warning "TEC requires Old KBarcode SQL tables for printing" + qDebug( "TEC requires Old KBarcode SQL tables for printing" ); + break; + case PrinterSettings::ZEBRA: + l->zpl( &stream ); + break; + case PrinterSettings::INTERMEC: + l->ipl( &stream ); + break; + case PrinterSettings::EPCL: + l->epcl( &stream ); + break; + default: + break; + } + + if( !checkProgressDialog( progress ) ) + { + delete l; + delete progress; + delete m_paintDevice; + m_paintDevice = NULL; + + file.close(); + + return; + } + } + delete l; + } + + delete progress; + delete m_paintDevice; + m_paintDevice = NULL; + + file.close(); +} + +void BatchPrinter::checkForNewPage( Label* label ) +{ + if( curh + m_measure.height( printer ) > pageh || c_w == m_measure.numV() ) { + printer->newPage(); + label->setPage( label->page() + 1 ); + curh = m_measure.gapTop( printer ); + curw = m_measure.gapLeft( printer ); + c_w = 0; + } +} + +void BatchPrinter::drawBorders() +{ + if( PrinterSettings::getInstance()->getData()->border ) { + painter->setPen( QPen( Qt::black, 1 ) ); + painter->drawRect( (int)curw, (int)curh, + (int)m_measure.width( painter->device() ), + (int)m_measure.height( painter->device() ) ); + } +} + +void BatchPrinter::changeLine() +{ + if( c_h >= m_measure.numH() ) { + c_h = 0; + curw = m_measure.gapLeft( printer ); + curh += m_measure.gapV( printer ); + c_w++; + } +} + +void BatchPrinter::proccessEvents( int lb, QString value, Label* label ) +{ + if( lb == NEW_PAGE ) { + if( curh > m_measure.gapTop( printer ) || curw > m_measure.gapLeft( printer ) ) { + printer->newPage(); + label->setPage( label->page() + 1 ); + curh = m_measure.gapTop( printer ); + curw = m_measure.gapLeft( printer ); + c_h = 0; + c_w = 0; + } + } + + if( lb == LINE_BREAK ) + changeLine(); + + if( lb == ARTICLE_GROUP_NO ) + printXLabel( lb, label, value ); + + + if( lb == LABEL_X ) + printXLabel( lb, label, QString::null ); +} + +void BatchPrinter::printXLabel( int lb, Label* label, const QString & value ) +{ + changeLine(); + checkForNewPage( label ); + + Label::getXLabel( curw, curh, m_measure.width( printer ), m_measure.height( printer ), painter, lb, value ); + + drawBorders(); + + curw += + m_measure.gapH( printer ); + c_h++; +} + +void BatchPrinter::moveLabels() +{ + for( unsigned int i = 0; i < m_move; i++ ) + { + if( !curw ) + curw = m_measure.gapLeft( printer ); + + if( !curh ) + curh = m_measure.gapTop( printer ); + + changeLine(); + + if( curh + m_measure.height( printer ) > pageh || c_w == m_measure.numV() ) + { + c_w = 0; + curh = m_measure.gapTop( printer ); + curw = m_measure.gapLeft( printer ); + } + + curw += m_measure.gapH( printer ); + c_h++; + } +} + +QProgressDialog* BatchPrinter::createProgressDialog( const QString & caption ) +{ + QProgressDialog* progress = new QProgressDialog( caption, i18n("&Cancel"), m_labels+1, parent ); + progress->setProgress( 0 ); + progress->show(); + return progress; +} + +bool BatchPrinter::checkProgressDialog( QProgressDialog* progress ) +{ + kapp->processEvents( 0 ); + progress->setProgress( progress->progress() + 1 ); + if( progress->wasCancelled() ) { + delete progress; + return false; + } + return true; +} + +void BatchPrinter::setData( QValueList<data>* list ) +{ + if( m_data ) + delete m_data; + m_data = list; +} + +void BatchPrinter::setData( TVariableList* list ) +{ + if( m_vardata ) + delete m_vardata; + m_vardata = list; +} + +void BatchPrinter::setData( KABC::AddresseeList* list ) +{ + if( m_addrdata ) + delete m_addrdata; + m_addrdata = list; +} + diff --git a/kbarcode/batchprinter.h b/kbarcode/batchprinter.h new file mode 100644 index 0000000..c189183 --- /dev/null +++ b/kbarcode/batchprinter.h @@ -0,0 +1,212 @@ +/*************************************************************************** + batchprinter.h - description + ------------------- + begin : Sat Jan 10 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef BATCHPRINTER_H +#define BATCHPRINTER_H + +#include "measurements.h" + +#include <qmap.h> +#include <qvaluelist.h> + +namespace KABC { + class AddresseeList; +} + +class Definition; +class Label; +class KPrinter; +class Measurements; +class QBuffer; +class QPainter; +class QProgressDialog; +class QWidget; +class QPaintDevice; + +typedef QValueList< QMap<QString,QString> > TVariableList; +/** + This class is responsible for batch printing of articles. + It is also responsible for creating images of all articles. + @author Dominik Seichter +*/ +class BatchPrinter +{ + public: + typedef enum EOutputFormat { POSTSCRIPT = 0, IMAGE, BCP }; + enum EImageFileName { E_ARTICLE, E_BARCODE, E_CUSTOM }; + + struct data { + int number; + QString article_no; + QString group; + }; + + /** Use this constructor if you want to print to + * a printer. + */ + BatchPrinter( KPrinter* p, QWidget* _parent ); + /** This constructor is used in image gernaration mode. + * @p path is the path to an existing directory where + * the images are saved. + */ + BatchPrinter( const QString & path, QWidget* p ); + + /** Use this constructor to print to a barcode printer @p path + * with format @p format + */ + BatchPrinter( const QString & path, int format, QWidget* _parent ); + + ~BatchPrinter(); + + inline void setBuffer( QBuffer* b ) { buffer = b; } + void setCustomer( const QString & s ) { m_customer = s; } + + /** Specify the label on which is printed first on the page. + * The first label on the page (top/left) has the index 1, + * the second label is index 2 ... + */ + inline void setMove( int m ) { + m_move = m > 0 ? --m : 0; + } + + /** set the sql data for the batchprinter + * @p list will be deleted by the batchprinter + */ + void setData( QValueList<data>* list ); + + /** set the variable data for the batchprinter + * @p list will be deleted by the batchprinter + */ + void setData( TVariableList* list ); + + /** set the address data for the batchprinter + * @p list will be deleted by the batchprinter + */ + void setData( KABC::AddresseeList* list ); + + inline void setImageFilename( const EImageFileName e ) { m_image_filename = e; } + inline void setImageCustomFilename( const QString & name ) { m_image_custom_filename = name; }; + inline void setImageFormat( const QString & f ) { m_image_format = f; } + inline void setSerial( const QString & s, unsigned int inc ) { m_serial = s; m_increment = inc; } + inline void setName( const QString & s ) { m_name = s; } + inline void setDefinition( Definition* d ) { def = d; } + inline void setLabels( int l ) { m_labels = l; } + inline void setEvents( bool b ) { m_events = b; } + + /** start the batch printing on a printer + */ + void start(); + /** start image generation + */ + void startImages(); + /** start printing to a barcode printer + */ + void startBCP(); + private: + /** create a label which gets intialized either with m_vardata or m_data + * @p number is set to the number of times this label should be printed. + */ + Label* initLabel( int* number = NULL ); + + /** starts a new page on the printer, if the + * current label does not fit anymore on the current pageh + */ + void checkForNewPage( Label* label ); + /** draw a border around the current label using QPainter @p painter + */ + void drawBorders(); + /** start a "new line" on the printer, + * i.e. beginn the second row of labels + * on the page. + */ + void changeLine(); + void proccessEvents( int lb, QString value = QString::null, Label* label = 0 ); + void printXLabel( int lb, Label* label, const QString & value ); + void moveLabels(); + + /** print the labels using data from the m_data structure + */ + void startPrintData( QProgressDialog* progress ); + /** print the labels using data from the m_vardata or m_addrdata structure + */ + void startPrintVarData( QProgressDialog* progress ); + + /** Create and return a progressdialog + */ + QProgressDialog* createProgressDialog( const QString & caption ); + bool checkProgressDialog( QProgressDialog* progress ); + + Definition* def; + Measurements m_measure; + QValueList<data>* m_data; + TVariableList* m_vardata; + KABC::AddresseeList* m_addrdata; + + QString m_serial; + QString m_name; + QString m_customer; + /** Path for image output + * or device for bcp output + */ + QString m_path; + /** defines the image format to be used + */ + QString m_image_format; + + unsigned int m_cur_data_count; + + /** format for bcp output + */ + int m_bcp_format; + + /** defines the format of the filename for images + */ + EImageFileName m_image_filename; + + /** prefix for custom filenames if m_image_filename = E_CUSTOM + */ + QString m_image_custom_filename; + + /** enable/disable events + */ + bool m_events; + + unsigned int m_increment; + unsigned int m_move; + /** number of labels to print for the progress dialog + */ + unsigned int m_labels; + + /** height of the current page in pixel. + */ + double pageh; + double curw; + double curh; + int c_h; + int c_w; + + QPaintDevice* m_paintDevice; + + QBuffer* buffer; + KPrinter* printer; + QPainter* painter; + /** parent for dialogs + */ + QWidget* parent; +}; + +#endif diff --git a/kbarcode/batchwizard.cpp b/kbarcode/batchwizard.cpp new file mode 100644 index 0000000..defcca8 --- /dev/null +++ b/kbarcode/batchwizard.cpp @@ -0,0 +1,1263 @@ +/*************************************************************************** + batchwizard.cpp - description + ------------------- + begin : Sun Mar 20 2005 + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "batchwizard.h" +#include "batchwizard.moc" +#include "barcodeprinterdlg.h" +#include "batchprinter.h" +#include "csvfile.h" +#include "definition.h" +#include "encodingcombo.h" +#include "printersettings.h" +#include "printlabeldlg.h" +#include "smalldialogs.h" +#include "sqltables.h" +#include "tokenprovider.h" +#include "xmlutils.h" + +#include <qbuffer.h> +#include <qcheckbox.h> +#include <qclipboard.h> +#include <qcursor.h> +#include <qdom.h> +#include <qheader.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qradiobutton.h> +#include <qsqlselectcursor.h> +#include <qtooltip.h> +#include <qvbuttongroup.h> +#include <qwidgetstack.h> + +#include <kabc/addressee.h> +#include <kabc/addresseelist.h> +#include <kabc/addressbook.h> +#include <kabc/stdaddressbook.h> +#include <kapplication.h> +#include <kcombobox.h> +#include <kcompletion.h> +#include <kfiledialog.h> +#include <kiconloader.h> +#include <kimageio.h> +#include <klineedit.h> +#include <klistbox.h> +#include <klistview.h> +#include <kmessagebox.h> +#include <knuminput.h> +#include <kpopupmenu.h> +#include <kpushbutton.h> +#include <kurlrequester.h> +#include <qtable.h> +#include <qvbox.h> + +#define PNG_FORMAT "PNG" + +class AddressListViewItem : public KListViewItem { +public: + AddressListViewItem(QListView *parent, KABC::Addressee & addr ) + : KListViewItem( parent ), m_address( addr ) + { + this->setText( 0, m_address.givenName() ); + this->setText( 1, m_address.familyName() ); + this->setText( 2, m_address.preferredEmail() ); + } + + const KABC::Addressee & address() const { + return m_address; + } + +private: + KABC::Addressee m_address; + +}; + +BatchWizard::BatchWizard( QWidget* parent, const char* name ) + : DCOPObject("BatchPrinting"), + KWizard( parent, name ) +{ + setupPage1(); + setupPage2(); + setupPage3(); + setupPage4(); + setupPage5(); + setupPage10(); + + compGroup = new KCompletion(); + + enableControls(); + setupSql(); + + show(); +} + +BatchWizard::~BatchWizard() +{ + delete compGroup; +} + +void BatchWizard::setupPage1() +{ + page1 = new QWidget( this, "page1" ); + QVBoxLayout* pageLayout = new QVBoxLayout( page1, 11, 6, "pageLayout"); + + QLabel* label = new QLabel( i18n("<qt>This wizard will guide you through the process " + "of printing many labels with KBarcode.<br>The first step " + "is to select the KBarcode label file you want to print.</qt>"), page1 ); + pageLayout->addWidget( label ); + + m_url = new KURLRequester( page1 ); + m_url->setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly ); + m_url->setFilter( "*.kbarcode" ); + + label = new QLabel( i18n("&Filename:"), page1 ); + label->setBuddy( m_url ); + + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); + + pageLayout->addWidget( label ); + pageLayout->addWidget( m_url ); + pageLayout->addItem( spacer ); + + addPage( page1, i18n("File Selection") ); + + connect( m_url, SIGNAL( textChanged( const QString & ) ), this, SLOT( enableControls() ) ); +} + +void BatchWizard::setupPage2() +{ + page2 = new QWidget( this, "page2" ); + QVBoxLayout* pageLayout = new QVBoxLayout( page2, 11, 6, "pageLayout"); + + QVButtonGroup* group = new QVButtonGroup( page2 ); + + radioSimple = new QRadioButton( i18n("Print &labels without data"), group ); + radioSqlArticles = new QRadioButton( i18n("Print &articles from KBarcodes SQL database"), group ); + radioVarImport = new QRadioButton( i18n("Import &variables and print"), group ); + radioAddressBook = new QRadioButton( i18n("Print &contacts from your addressbook"), group ); + radioSimple->setChecked( true ); + + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); + pageLayout->addWidget( group ); + pageLayout->addItem( spacer ); + + connect( radioSimple, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioSqlArticles, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioVarImport, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioAddressBook, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + + addPage( page2, i18n("Data Source") ); +} + +void BatchWizard::setupPage3() +{ + page3 = new QWidgetStack( this, "page3" ); + + setupStackPage1(); + setupStackPage2(); + setupStackPage3(); + setupStackPage4(); + + addPage( page3, i18n("Print Data") ); +} + +void BatchWizard::setupPage4() +{ + page4 = new QVBox( this, "page4" ); + page4->setSpacing( 5 ); + + QHBox* hbox = new QHBox( page4 ); + hbox->setSpacing( 5 ); + + buttonTableInsert = new KPushButton( i18n("Insert Row"), hbox ); + buttonTableInsert->setIconSet( BarIconSet( "edit" ) ); + buttonTableRemove = new KPushButton( i18n("Delete Row"), hbox ); + buttonTableRemove->setIconSet( BarIconSet( "editdelete") ); + + m_varTable = new QTable( page4 ); + m_varTable->setReadOnly( false ); + m_varTable->setSelectionMode( QTable::SingleRow ); + + addPage( page4, i18n("Import Variables") ); + + connect( buttonTableInsert, SIGNAL( clicked() ), this, SLOT( slotTableInsert() ) ); + connect( buttonTableRemove, SIGNAL( clicked() ), this, SLOT( slotTableRemove() ) ); +} + +void BatchWizard::setupPage5() +{ + TokenProvider serial( this ); + + page5 = new QVBox( this, "page5" ); + + new QLabel( i18n( "<qt>KBarcode has support for placing serial numbers on labels. " + "If you did not use the [serial] token on your label in " + "a text field or a barcode, you can skip this page.<br>" + "Serial start is a free form start value containing at least one " + "number. This number is increased for every printed label on the " + "print out.</qt>"), page5 ); + + QHBox* hbox = new QHBox( page5 ); + hbox->setSpacing( 5 ); + + new QLabel( i18n( "Serial start:" ), hbox ); + serialStart = new KLineEdit( serial.serial(), hbox ); + + serialInc = new KIntNumInput( 1, hbox ); + serialInc->setLabel( i18n( "Serial increment:" ), KNumInput::AlignLeft | KNumInput::AlignVCenter ); + serialInc->setRange( 1, 10000, 1, false ); + + addPage( page5, i18n("Serial Number") ); +} + +void BatchWizard::setupPage10() +{ + page10 = new QWidget( this, "page10" ); + QVBoxLayout* pageLayout = new QVBoxLayout( page10, 11, 6, "pageLayout"); + + QVButtonGroup* group = new QVButtonGroup( page10 ); + + radioPrinter = new QRadioButton( i18n("&Print to a system printer or to a file"), group ); + radioImage = new QRadioButton( i18n("&Create images"), group ); + + imageBox = new QVBox( group ); + imageBox->setMargin( 10 ); + + radioBarcode = new QRadioButton( i18n("Print to a special &barcode printer"), group ); + + QHBox* directoryBox = new QHBox( imageBox ); + directoryBox->setSpacing( 5 ); + QLabel* label = new QLabel( i18n("Output &Directory:"), directoryBox ); + imageDirPath = new KURLRequester( directoryBox ); + imageDirPath->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly ); + label->setBuddy( directoryBox ); + + QHBox* formatBox = new QHBox( imageBox ); + label = new QLabel( i18n("Output File &Format:"), formatBox ); + + QStringList formats = KImageIO::types( KImageIO::Writing ); + comboFormat = new KComboBox( false, formatBox ); + comboFormat->insertStringList( formats ); + if( formats.contains( PNG_FORMAT ) ) + comboFormat->setCurrentItem( formats.findIndex( PNG_FORMAT ) ); + label->setBuddy( comboFormat ); + + QVButtonGroup* imageNameGroup = new QVButtonGroup( i18n("&Filename:"), imageBox ); + radioImageFilenameArticle = new QRadioButton( i18n("Use &article number for filename"), imageNameGroup ); + radioImageFilenameBarcode = new QRadioButton( i18n("Use &barcode number for filename"), imageNameGroup ); + radioImageFilenameCustom = new QRadioButton( i18n("Use &custom filename:"), imageNameGroup ); + editImageFilename = new KLineEdit( imageNameGroup ); + radioImageFilenameBarcode->setChecked( true ); + + labelInfo = new QLabel( page10 ); + + radioPrinter->setChecked( true ); + + checkKeepOpen = new QCheckBox( i18n("&Keep window open after printing."), page10 ); + + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); + pageLayout->addWidget( group ); + pageLayout->addItem( spacer ); + pageLayout->addWidget( labelInfo ); + pageLayout->addWidget( checkKeepOpen ); + + connect( radioPrinter, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioImage, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioBarcode, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + + connect( radioImageFilenameArticle, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioImageFilenameBarcode, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioImageFilenameCustom, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + + connect( imageDirPath, SIGNAL( textChanged( const QString & ) ), this, SLOT( enableControls() ) ); + + addPage( page10, i18n("Output Device") ); +} + +void BatchWizard::setupStackPage1() +{ + stack1 = new QVBox( page3, "stack1" ); + stack1->setSpacing( 5 ); + + QHBox* hbox = new QHBox( stack1 ); + hbox->setSpacing( 5 ); + + new QLabel( i18n( "Customer name and no.:" ), hbox ); + customerName = new KComboBox( false, hbox ); + customerId = new KComboBox( false, hbox ); + + QHBox* hButtonBox = new QHBox( stack1 ); + hButtonBox->setSpacing( 5 ); + + buttonAdd = new KPushButton( i18n( "&Add..." ), hButtonBox ); + buttonImport = new KPushButton( i18n("&Import..."), hButtonBox ); + buttonEdit = new KPushButton( i18n( "&Edit..." ), hButtonBox ); + buttonRemove = new KPushButton( i18n("&Remove" ), hButtonBox ); + buttonRemoveAll = new KPushButton( i18n("R&emove All"), hButtonBox ); + + KPopupMenu* mnuImport = new KPopupMenu( this ); + mnuImport->insertItem( i18n("Import from File ..."), this, SLOT( loadFromFile() ) ); + mnuImport->insertItem( i18n("Import from Clipboard ..."), this, SLOT( loadFromClipboard() ) ); + mnuImport->insertItem( i18n("Import barcode_basic"), this, SLOT( addAllItems() ) ); + buttonImport->setPopup( mnuImport ); + + sqlList = new KListView( stack1 ); + sqlList->addColumn( i18n("Index") ); + sqlList->addColumn( i18n("Number of Labels") ); + sqlList->addColumn( i18n("Article Number") ); + sqlList->addColumn( i18n("Group") ); + sqlList->setAllColumnsShowFocus( true ); + connect( sqlList, SIGNAL(doubleClicked(QListViewItem*,const QPoint &,int)), + this, SLOT(changeItem(QListViewItem*,const QPoint &,int))); + + connect( customerName, SIGNAL( activated(int) ), this, SLOT( customerNameChanged(int) ) ); + connect( customerId, SIGNAL( activated(int) ), this, SLOT( customerIdChanged(int) ) ); + connect( buttonAdd, SIGNAL( clicked() ), this, SLOT( addItem() ) ); + connect( buttonEdit, SIGNAL( clicked() ), this, SLOT( editItem() ) ); + connect( buttonRemove, SIGNAL( clicked() ), this, SLOT( removeItem() ) ); + connect( buttonRemoveAll, SIGNAL( clicked() ), sqlList, SLOT( clear() ) ); + connect( buttonRemoveAll, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + + page3->addWidget( stack1 ); +} + +void BatchWizard::setupStackPage2() +{ + stack2 = new QHBox( page3, "stack2" ); + stack2->setSpacing( 5 ); + + QVButtonGroup* group = new QVButtonGroup( stack2 ); + radioImportManual = new QRadioButton( i18n("Enter &data manually"), group ); + radioImportSql = new QRadioButton( i18n("Import variables from a &SQL table"), group ); + labelSqlQuery = new QLabel( i18n("Please enter a sql &query:"), group ); + importSqlQuery = new KLineEdit( group ); + labelSqlQuery->setBuddy( importSqlQuery ); + + radioImportCSV = new QRadioButton( i18n("Import from a &CSV file"), group ); + labelCsvFile= new QLabel( i18n("Please select a csv &file:"), group ); + importCsvFile = new KURLRequester( group ); + labelCsvFile->setBuddy( importCsvFile ); + labelEncoding = new QLabel( i18n("&Encoding:"), group ); + comboEncoding = new EncodingCombo( group ); + labelEncoding->setBuddy( comboEncoding ); + + radioImportManual->setChecked( true ); + + QVBox* box = new QVBox( stack2 ); + box->setSpacing( 5 ); + + new QLabel( i18n("Available Variables:"), box ); + m_varList = new KListBox( box ); + + connect( radioImportManual, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioImportSql, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioImportCSV, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( importSqlQuery, SIGNAL( textChanged( const QString & ) ), this, SLOT( enableControls() ) ); + connect( importCsvFile, SIGNAL( textChanged( const QString & ) ), this, SLOT( enableControls() ) ); + + page3->addWidget( stack2 ); +} + +void BatchWizard::setupStackPage3() +{ + stack3 = new QVBox( page3, "stack3" ); + + numLabels = new KIntNumInput( 1, stack3 ); + numLabels->setRange( 1, 100000, 1, true ); + numLabels->setLabel( i18n("&Number of labels to print:"), AlignLeft | AlignVCenter ); + + page3->addWidget( stack3 ); +} + +void BatchWizard::setupStackPage4() +{ + stack4 = new QWidget( page3, "stack4" ); + + QHBoxLayout* mainLayout = new QHBoxLayout( stack4 ); + + QVBox* list1 = new QVBox( stack4 ); + QVBox* list2 = new QVBox( stack4 ); + + QFrame* buttons = new QFrame( stack4 ); + buttons->setMargin( 10 ); + + QVBoxLayout* layout = new QVBoxLayout( buttons ); + QSpacerItem* spacer1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); + QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); + + buttonAddAllAddress = new KPushButton( buttons ); + buttonAddAddress = new KPushButton( buttons ); + buttonRemoveAddress = new KPushButton( buttons );; + buttonRemoveAllAddress = new KPushButton( buttons ); + + buttonAddAllAddress->setIconSet( BarIconSet( "2rightarrow" ) ); + buttonAddAddress->setIconSet( BarIconSet( "1rightarrow" ) ); + buttonRemoveAddress->setIconSet( BarIconSet( "1leftarrow" ) ); + buttonRemoveAllAddress->setIconSet( BarIconSet( "2leftarrow" ) ); + + QToolTip::add( buttonAddAllAddress, i18n("Add all contacts to the list of contacts which will be printed.") ); + QToolTip::add( buttonAddAddress, i18n("Add selected contacts to the list of contacts which will be printed.") ); + QToolTip::add( buttonRemoveAddress, i18n("Remove selected contacts from the list of contacts which will be printed.") ); + QToolTip::add( buttonRemoveAllAddress, i18n("Remove all contacts from the list of contacts which will be printed.") ); + + layout->addItem( spacer1 ); + layout->addWidget( buttonAddAllAddress ); + layout->addWidget( buttonAddAddress ); + layout->addWidget( buttonRemoveAddress ); + layout->addWidget( buttonRemoveAllAddress ); + layout->addItem( spacer2 ); + + mainLayout->addWidget( list1 ); + mainLayout->addWidget( buttons ); + mainLayout->addWidget( list2 ); + + mainLayout->setStretchFactor( list1, 2 ); + mainLayout->setStretchFactor( list2, 2 ); + + new QLabel( i18n("All Addresses"), list1 ); + new QLabel( i18n("Selected Addresses"), list2 ); + + listAddress = new KListView( list1 ); + listAddress->addColumn( i18n("Given Name"), 0 ); + listAddress->addColumn( i18n("Family Name"), 1 ); + listAddress->addColumn( i18n("Email Address"), 2 ); + listAddress->setMultiSelection( true ); + listAddress->setAllColumnsShowFocus( true ); + + listAddress->setColumnWidthMode( 0, QListView::Maximum ); + listAddress->setColumnWidthMode( 1, QListView::Maximum ); + listAddress->setColumnWidthMode( 2, QListView::Maximum ); + + listSelectedAddress = new KListView( list2 ); + listSelectedAddress->addColumn( i18n("Given Name"), 0 ); + listSelectedAddress->addColumn( i18n("Family Name"), 1 ); + listSelectedAddress->addColumn( i18n("Email Address"), 2 ); + listSelectedAddress->setMultiSelection( true ); + listSelectedAddress->setAllColumnsShowFocus( true ); + + listSelectedAddress->setColumnWidthMode( 0, QListView::Maximum ); + listSelectedAddress->setColumnWidthMode( 1, QListView::Maximum ); + listSelectedAddress->setColumnWidthMode( 2, QListView::Maximum ); + + connect( buttonAddAddress, SIGNAL( clicked() ), this, SLOT( slotAddAddress() ) ); + connect( buttonRemoveAddress, SIGNAL( clicked() ), this, SLOT( slotRemoveAddress() ) ); + connect( buttonAddAllAddress, SIGNAL( clicked() ), this, SLOT( slotAddAllAddress() ) ); + connect( buttonRemoveAllAddress, SIGNAL( clicked() ), this, SLOT( slotRemoveAllAddress() ) ); + + page3->addWidget( stack4 ); +} + +void BatchWizard::setupSql() +{ + SqlTables* tables = SqlTables::getInstance(); + if( !tables->isConnected() ) + return; + + QSqlCursor cur( TABLE_CUSTOMER ); + cur.select(); + customerId->clear(); + customerName->clear(); + while ( cur.next() ) { + customerId->insertItem( cur.value("customer_no" ).toString() ); + customerName->insertItem( cur.value("customer_name" ).toString() ); + } +} + +void BatchWizard::enableControls() +{ + setAppropriate( page4, radioVarImport->isChecked() ); + + radioSqlArticles->setEnabled( SqlTables::getInstance()->isConnected() ); + radioImportSql->setEnabled( SqlTables::getInstance()->isConnected() ); + + importCsvFile->setEnabled( radioImportCSV->isChecked() ); + labelCsvFile->setEnabled( radioImportCSV->isChecked() ); + importSqlQuery->setEnabled( radioImportSql->isChecked() ); + labelSqlQuery->setEnabled( radioImportSql->isChecked() ); + labelEncoding->setEnabled( radioImportCSV->isChecked() ); + comboEncoding->setEnabled( radioImportCSV->isChecked() ); + + buttonRemove->setEnabled( sqlList->childCount() ); + buttonRemoveAll->setEnabled(sqlList->childCount() ); + buttonEdit->setEnabled( sqlList->childCount() ); + + imageBox->setEnabled( radioImage->isChecked() ); + + if( radioImportSql->isChecked() ) + setNextEnabled( page3, !importSqlQuery->text().isEmpty() ); + else if( radioImportCSV->isChecked() ) + setNextEnabled( page3, !importCsvFile->url().isEmpty() ); + else if( radioImportManual->isChecked() ) + setNextEnabled( page3, true ); + + editImageFilename->setEnabled( radioImageFilenameCustom->isChecked() ); + radioImageFilenameArticle->setEnabled( radioSqlArticles->isChecked() ); + + setNextEnabled( page1, !m_url->url().isEmpty() ); + + if( radioAddressBook->isChecked() ) + setNextEnabled( page3, listSelectedAddress->childCount() ); + + if( radioImage->isChecked() ) + setFinishEnabled( page10, !imageDirPath->url().isEmpty() ); + else + setFinishEnabled( page10, true ); +} + +void BatchWizard::showPage( QWidget* p ) +{ + if( p == page3 ) + { + if( radioSqlArticles->isChecked() ) + page3->raiseWidget( stack1 ); + else if( radioVarImport->isChecked() ) + { + page3->raiseWidget( stack2 ); + fillVarList(); + } + else if( radioSimple->isChecked() ) + page3->raiseWidget( stack3 ); + else if( radioAddressBook->isChecked() ) + { + page3->raiseWidget( stack4 ); + fillAddressList(); + } + } + else if( p == page4 ) + if( !fillVarTable() ) + return; + + + KWizard::showPage( p ); +} + +void BatchWizard::accept() +{ + printNow( QString::null ); +} + +void BatchWizard::printNow( const QString & printer, bool bUserInteraction ) +{ + BatchPrinter* batch = NULL; + KPrinter* prn = NULL; + int batchType = 0; + + // let's check if the label file does even exist! + if( !QFile::exists( m_url->url() ) ) + { + KMessageBox::error( this, QString( i18n("The label file %1 was not found") ).arg( m_url->url()) ); + return; + } + + if( radioPrinter->isChecked() ) + { + int move = 0; + if( bUserInteraction ) + { + PrintLabelDlg pld( this, "pld" ); + pld.setLabelsEnabled( false ); + if( pld.exec() != QDialog::Accepted ) + return; + + move = pld.position(); + PrinterSettings::getInstance()->getData()->border = pld.border(); + } + + prn = PrinterSettings::getInstance()->setupPrinter( m_url->url(), this, !printer.isEmpty(), printer ); + if( !prn ) + return; + + batch = new BatchPrinter( prn, this ); + batch->setMove( move ); + + batchType = BatchPrinter::POSTSCRIPT; + } + else if( radioBarcode->isChecked() ) + { + BarcodePrinterDlg dlg(this); + if( dlg.exec() != QDialog::Accepted ) + return; + + batch = new BatchPrinter( dlg.printToFile() ? dlg.fileName() : dlg.deviceName(), + dlg.outputFormat(), this ); + batchType = BatchPrinter::BCP; + } + else if( radioImage->isChecked() ) + { + batch = new BatchPrinter( imageDirPath->url(), this ); + if( radioImageFilenameArticle->isChecked() ) + batch->setImageFilename( BatchPrinter::E_ARTICLE ); + else if( radioImageFilenameBarcode->isChecked() ) + batch->setImageFilename( BatchPrinter::E_BARCODE ); + else if( radioImageFilenameCustom->isChecked() ) + { + batch->setImageFilename( BatchPrinter::E_CUSTOM ); + batch->setImageCustomFilename( editImageFilename->text() ); + } + + batchType = BatchPrinter::IMAGE; + } + + if( !checkKeepOpen->isChecked() ) + KWizard::accept(); + + KApplication::setOverrideCursor( QCursor( Qt::ArrowCursor ), true ); + setupBatchPrinter( batch, batchType ); + KApplication::restoreOverrideCursor(); + + delete prn; + delete batch; +} + +void BatchWizard::setupBatchPrinter( BatchPrinter* batch, int m ) +{ + Definition* def = NULL; + QString description; + bool kbarcode18; + + fillByteArray(); + QDomDocument doc( "KBarcodeLabel" ); + if ( !doc.setContent( m_bytearray ) ) + return; + + XMLUtils util; + util.readXMLHeader( &doc, description, kbarcode18, &def ); + + QBuffer buffer( m_bytearray ); + if( !buffer.open( IO_ReadOnly ) ) + return; + + batch->setBuffer( &buffer ); + batch->setSerial( serialStart->text(), serialInc->value() ); + batch->setName( m_url->url() ); + batch->setDefinition( def ); + batch->setImageFormat( comboFormat->currentText() ); + + if( radioSqlArticles->isChecked() ) + { + int labels = 0; + batch->setCustomer( customerId->currentText() ); + + // sort by group + sqlList->setSorting( 3, true ); + sqlList->sort(); + + QValueList<BatchPrinter::data>* dlist = new QValueList<BatchPrinter::data>; + QListViewItem* item = sqlList->firstChild(); + while( item ) + { + BatchPrinter::data m_data; + m_data.number = item->text( 1 ).toInt(); + labels += m_data.number; + m_data.article_no = item->text( 2 ); + m_data.group = item->text( 3 ); + + dlist->append( m_data ); + item = item->nextSibling(); + }; + + batch->setData( dlist ); + batch->setLabels( labels ); + } + else if( radioSimple->isChecked() ) + { + batch->setLabels( numLabels->value() ); + + // do a dirty drick, TODO: refactor BatchPrinter in the future + QValueList<BatchPrinter::data>* dlist = new QValueList<BatchPrinter::data>; + BatchPrinter::data m_data; + m_data.number = numLabels->value(); + dlist->append( m_data ); + + batch->setData( dlist ); + } + else if( radioVarImport->isChecked() ) + { + TVariableList* tVariableList = new TVariableList; + for( int i=0; i<m_varTable->numRows(); i++ ) + { + QMap<QString, QString> map; + for( int z=0; z<m_varTable->numCols(); z++ ) + map[ m_varTable->horizontalHeader()->label( z ) ] = m_varTable->text( i, z ); + tVariableList->append( map ); + } + + batch->setData( tVariableList ); + } + else if( radioAddressBook->isChecked() ) + { + KABC::AddresseeList* list = new KABC::AddresseeList; + QListViewItem* item = listSelectedAddress->firstChild(); + while( item ) + { + list->append( static_cast<AddressListViewItem*>(item)->address() ); + item = item->nextSibling(); + } + + batch->setData( list ); + } + + if( m == BatchPrinter::POSTSCRIPT ) + batch->start(); + else if( m == BatchPrinter::IMAGE ) + batch->startImages(); + else if( m == BatchPrinter::BCP ) + batch->startBCP(); + + delete def; +} + + +void BatchWizard::addItem() +{ + DSSmallDialogs::AddItemsDialog aid( this, "aid" ); + aid.setGroupCompletion( compGroup ); + connect( &aid, SIGNAL( add( const QString &, const QString &, int) ), + this, SLOT( slotAddItem( const QString &, const QString &, int) ) ); + + aid.exec(); +} + +bool BatchWizard::slotAddItem( const QString & article, const QString & group, int count ) +{ + return this->addItem( article, group, count, true ); +} + +bool BatchWizard::addItem( const QString & article, const QString & group, int count, bool msg ) +{ + if( !article.isEmpty() && !existsArticle( article ) ) { + if( msg ) + KMessageBox::error( this, i18n("Please enter a valid article ID") ); + return false; + } + + QString temp; + temp.sprintf("%0*i", 5, sqlList->childCount() + 1 ); + + KListViewItem* item = new KListViewItem( sqlList, temp, QString( "%1" ).arg( count ), + article, group ); + sqlList->insertItem( item ); + + addGroupCompletion( group ); + enableControls(); + + return true; +} + +void BatchWizard::addGroupCompletion( const QString & group ) +{ + if( !group.isEmpty() ) + { + QStringList slist = compGroup->items(); + if(!slist.contains( group ) ) + compGroup->addItem( group ); + } +} + +bool BatchWizard::existsArticle( const QString & article ) +{ + if( article.isEmpty() ) + return false; + + QSqlQuery query( "select uid from barcode_basic where article_no='" + article + "'" ); + while ( query.next() ) + return true; + + return false; +} + +void BatchWizard::editItem() +{ + QListViewItem* item = sqlList->selectedItem(); + if( item ) + changeItem( item, QPoint(0,0), 0 ); +} + +void BatchWizard::changeItem( QListViewItem* item, const QPoint &, int ) +{ + if(!item) + return; + + DSSmallDialogs::AddItemsDialog aid( item->text( 2 ), item->text( 3 ), + item->text( 1 ).toInt(), this, "aid" ); + aid.setGroupCompletion( compGroup ); + + if( aid.exec() == QDialog::Accepted ) + { + item->setText( 1, QString::number( aid.count() ) ); + item->setText( 2, aid.articleNo() ); + item->setText( 3, aid.groupName() ); + addGroupCompletion( aid.groupName() ); + enableControls(); + } +} + +void BatchWizard::removeItem() +{ + QListViewItem* item = sqlList->firstChild(); + while( item ) + { + if( item->isSelected() ) + { + QListViewItem* it = item->nextSibling(); + delete item; + + while( it ) + { + int a = it->text( 0 ).toInt(); + QString temp; + temp.sprintf("%0*i", 5, a - 1 ); + it->setText( 0, temp ); + it = it->nextSibling(); + } + + break; + } else + item = item->nextSibling(); + } + + enableControls(); +} + +void BatchWizard::customerIdChanged( int index ) +{ + customerName->setCurrentItem( index ); + enableControls(); +} + +void BatchWizard::customerNameChanged( int index ) +{ + customerId->setCurrentItem( index ); + enableControls(); +} + +void BatchWizard::addAllItems() +{ + DSSmallDialogs::AddAllDialog* dlg = new DSSmallDialogs::AddAllDialog( this, "dlg" ); + if( dlg->exec() == QDialog::Accepted ) + { + QString temp; + QString group = dlg->groupName(); + const QString num = QString::number( dlg->numberLabels() ); + + QSqlQuery query("SELECT article_no FROM " TABLE_BASIC ); + while( query.next() ) + { + temp.sprintf("%0*i", 5, sqlList->childCount() + 1 ); + new KListViewItem( sqlList, temp, num, query.value( 0 ).toString(), group ); + } + + enableControls(); + } +} + +void BatchWizard::loadFromFile() +{ + QString f = KFileDialog::getOpenFileName( 0, 0, this ); + if( !f.isEmpty() ) + loadFromFile( f ); +} + +void BatchWizard::loadFromClipboard() +{ + QClipboard *cb = KApplication::clipboard(); + loadData( cb->text() ); +} + +void BatchWizard::loadFromFile( const QString & url ) +{ + QByteArray data; + QFile file( url ); + + if( !file.open( IO_ReadOnly ) ) + { + qDebug("Unable to open file: %s", url.latin1() ); + return; + } + + data = file.readAll(); + + loadData( QString( data ) ); +} + +void BatchWizard::loadData( const QString & data ) +{ + labelprinterdata* lpdata = PrinterSettings::getInstance()->getData(); + if( lpdata->separator.isEmpty() ) + { + KMessageBox::sorry( this, i18n("Separator is empty. Please set it to a value.") ); + return; + } + + // new config entry!!! + KConfig* config = kapp->config(); + config->setGroup("FileFormat"); + int pos[3] = { config->readNumEntry("Data0", 0 ), + config->readNumEntry("Data1", 1 ), + config->readNumEntry("Data2", 2 ) }; + + bool custom_article_no = lpdata->useCustomNo; + QBuffer buf( data.utf8() ); + CSVFile file( buf ); + + QStringList list, dropped; + QString article, quantity, group; + + while( file.isValid() && !file.isEof() ) + { + list = file.readNextLine(); + while( list.count() < 3 ) + list.append( QString::null ); + + if( pos[0] == 0 ) + quantity = list[0]; + else if( pos[0] == 1 ) + article = list[0]; + else + group = list[0]; + + if( pos[1] == 0 ) + quantity = list[1]; + else if( pos[1] == 1 ) + article = list[1]; + else + group = list[1]; + + if( pos[2] == 0 ) + quantity = list[2]; + else if( pos[2] == 1 ) + article = list[2]; + else + group = list[2]; + + // data[0] == quantity + // data[1] == article_no + // data[2] == group + + bool qint = false; + (void)quantity.toInt( &qint ); + + if( qint && custom_article_no ) { + qint = false; + QSqlQuery query("SELECT article_no FROM customer_text WHERE article_no_customer='" + article + "'" ); + while( query.next() ) { + article = query.value( 0 ).toString(); + qint = true; + break; + } + } + + if( qint ) // && existsArticle( article ) + { + if( !addItem( QString( article ), QString( group ), quantity.toInt(), false ) ) + dropped.append( quantity + lpdata->separator + article + lpdata->separator + group ); + } + } + + if( !dropped.isEmpty() ) +#if QT_VERSION >= 0x030100 + KMessageBox::informationList( this, i18n("<qt>The following items can not be added:" )+ "</qt>", dropped ); +#else + KMessageBox::questionYesNoList( this, i18n("<qt>The following items can not be added:" )+ "</qt>", dropped ); +#endif + + enableControls(); +} + +void BatchWizard::fillByteArray() +{ + if( m_bytearray_filename != m_url->url() ) + { + QFile f( m_url->url() ); + if ( !f.open( IO_ReadOnly ) ) + { + m_bytearray_filename = QString::null; + m_bytearray.resize( 0 ); + return ; + } + + m_bytearray = f.readAll(); + f.close(); + } +} + +void BatchWizard::fillVarList() +{ + fillByteArray(); + QDomDocument doc( "KBarcodeLabel" ); + if ( !doc.setContent( m_bytearray ) ) + return; + + XMLUtils util; + DocumentItemList list; + list.setAutoDelete( true ); + + TokenProvider token( this ); + Definition* def = NULL; + + QString description; + bool kbarcode18; + util.readXMLHeader( &doc, description, kbarcode18, &def ); + util.readDocumentItems( &list, &doc, &token, kbarcode18 ); + + token.setCurrentDocumentItems( list ); + + QStringList vars = token.listUserVars(); + m_varList->clear(); + m_varList->insertStringList( vars ); + m_varTable->setNumCols( vars.count() ); + for( unsigned int i = 0; i < vars.count(); i++ ) + { + vars[i] = vars[i].right( vars[i].length() - 1 ); + m_varTable->horizontalHeader()->setLabel( i, vars[i] ); + } + + delete def; +} + +void BatchWizard::fillAddressList() +{ + KABC::AddressBook* ab = KABC::StdAddressBook::self(); + listAddress->clear(); + + KABC::AddressBook::Iterator it; + listAddress->setUpdatesEnabled( false ); + for ( it = ab->begin(); it != ab->end(); ++it ) + new AddressListViewItem( listAddress, *it ); + listAddress->setUpdatesEnabled( true ); +} + +bool BatchWizard::fillVarTable() +{ + // Clear the table + m_varTable->setNumRows( 0 ); + + if( radioImportSql->isChecked() ) + { + int y = 0; + int x; + QSqlSelectCursor query( importSqlQuery->text(), SqlTables::getInstance()->database() ); + query.select(); + if( query.lastError().type() != QSqlError::None ) + { + KMessageBox::error( this, i18n("<qt>Can't execute SQL query:<br>") + query.lastError().text() + "</qt>" ); + return false; + } + + if( m_varTable->numRows() < query.size() ) + m_varTable->setNumRows( query.size() ); + + while( query.next() ) + { + for( x=0;x<m_varTable->numRows();x++ ) + m_varTable->setText( y, x, query.value( m_varTable->horizontalHeader()->label( x ) ).toString() ); + + y++; + } + } + else if( radioImportCSV->isChecked() ) + { + CSVFile file( importCsvFile->url() ); + file.setEncoding( comboEncoding->currentText() ); + + QStringList heading; + QStringList data; + int i = 0; + + file.setCSVFile(true); + if( !file.isValid() ) + { + KMessageBox::error( this, QString( i18n("Can't open file: %1") ).arg( importCsvFile->url() ) ); + return false; + } + + while( !file.isEof() ) + { + if( heading.isEmpty() ) + heading = file.readNextLine(); + else + { + data = file.readNextLine(); + + // add 100 rows to get a reasonable speed + if( m_varTable->numRows() <= i ) + m_varTable->setNumRows( i + 100 ); + + printf("datacount=%i\n", data.count() ); + for( unsigned int z = 0; z < data.count(); z++ ) + { + printf("numRows=%i\n", m_varTable->numCols() ); + for( int x = 0; x < m_varTable->numCols(); x++ ) + { + printf("horizontal header=%s\n", m_varTable->horizontalHeader()->label( x ).lower().latin1() ); + printf("heading=%s\n", heading[z].lower().latin1() ); + if( m_varTable->horizontalHeader()->label( x ).lower() == heading[z].lower() ) + { + printf("Reading: (%s)\n", data[z].latin1()); + m_varTable->setText( i, x, data[z] ); + break; + } + } + } + + if( data.count() ) + i++; + } + } + + m_varTable->setNumRows( i ); + } + + return true; +} + +void BatchWizard::slotTableInsert() +{ + m_varTable->insertRows( m_varTable->numRows(), 1 ); +} + +void BatchWizard::slotTableRemove() +{ + QTableSelection sel = m_varTable->selection( m_varTable->currentSelection() ); + m_varTable->removeRow( sel.topRow() ); +} + +void BatchWizard::setFilename( const QString & url ) +{ + m_url->setURL( url ); + enableControls(); +} + +void BatchWizard::setImportSqlQuery( const QString & query ) +{ + radioImportCSV->setChecked( false ); + radioImportManual->setChecked( false ); + radioImportSql->setChecked( true ); + + radioVarImport->setChecked( true ); + radioSqlArticles->setChecked( false ); + radioSimple->setChecked( false ); + + importSqlQuery->setText( query ); + + enableControls(); + + showPage( page3 ); + showPage( page4 ); +} + +void BatchWizard::setImportCsvFile( const QString & filename ) +{ + radioImportCSV->setChecked( true ); + radioImportManual->setChecked( false ); + radioImportSql->setChecked( false ); + + radioVarImport->setChecked( true ); + radioSqlArticles->setChecked( false ); + radioSimple->setChecked( false ); + + importCsvFile->setURL( filename ); + + enableControls(); + + showPage( page3 ); + showPage( page4 ); +} + +void BatchWizard::setNumLabels( const int n ) +{ + numLabels->setValue( n ); + radioSimple->setChecked( true ); + radioSqlArticles->setChecked( false ); + radioVarImport->setChecked( false ); + enableControls(); +} + +void BatchWizard::setOutputFormat( const int e ) +{ + radioBarcode->setChecked( false ); + radioImage->setChecked( false ); + radioPrinter->setChecked( false ); + + switch( e ) + { + case BatchPrinter::BCP: + radioBarcode->setChecked( true ); + break; + case BatchPrinter::IMAGE: + radioImage->setChecked( true ); + break; + default: + case BatchPrinter::POSTSCRIPT: + radioPrinter->setChecked( true ); + break; + } + + enableControls(); +} + +void BatchWizard::setSerialNumber( const QString & val, int inc ) +{ + serialInc->setValue( inc ); + serialStart->setText( val ); + + // Not needed here: enableControls(); +} + +void BatchWizard::slotAddAddress() +{ + moveAddress( listAddress, listSelectedAddress ); + enableControls(); +} + +void BatchWizard::slotAddAllAddress() +{ + moveAddress( listAddress, listSelectedAddress, true ); + enableControls(); +} + +void BatchWizard::slotRemoveAddress() +{ + moveAddress( listSelectedAddress, listAddress ); + enableControls(); +} + +void BatchWizard::slotRemoveAllAddress() +{ + moveAddress( listSelectedAddress, listAddress, true ); + enableControls(); +} + +void BatchWizard::moveAddress( QListView* src, QListView* dst, bool bAll ) +{ + QListViewItem* item = src->firstChild(); + QListViewItem* cur; + + while( item ) + { + if( bAll || item->isSelected() ) + { + cur = item; + item = item->nextSibling(); + + src->takeItem( cur ); + dst->insertItem( cur ); + cur->setSelected( false ); + } + else + item = item->nextSibling(); + } +} diff --git a/kbarcode/batchwizard.h b/kbarcode/batchwizard.h new file mode 100644 index 0000000..e736a6f --- /dev/null +++ b/kbarcode/batchwizard.h @@ -0,0 +1,266 @@ +/*************************************************************************** + batchwizard.h - description + ------------------- + begin : Sun Mar 20 2005 + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef BATCHWIZARD_H +#define BATCHWIZARD_H + +#include <kwizard.h> +#include "batchiface.h" + +class BatchPrinter; +class EncodingCombo; +class KComboBox; +class KCompletion; +class KIntNumInput; +class KLineEdit; +class KListBox; +class KListView; +class KPushButton; +class KURLRequester; +class QCheckBox; +class QHBox; +class QLabel; +class QListView; +class QListViewItem; +class QRadioButton; +class QTable; +class QVBox; +class QWidgetStack; + +class BatchWizard : public KWizard, public BatchIface { + Q_OBJECT + public: + BatchWizard( QWidget* parent = NULL, const char* name = NULL ); + ~BatchWizard(); + + /** reimplemented DCOP method from BatchIface + * Allow the user to add an article to print to KBarcode + * @p article article number to add + * @p group use group as group name for this article + * @p count number of labels to print for this article + * @p msgbox show a messagebox if adding the item fails + */ + bool addItem( const QString & article, const QString & group, int count, bool msgbox = true ); + + /** reimplemented DCOP method from BatchIface + * tests wether the arctile is existing in KBarcodes database + * @p article article number to test for + */ + virtual bool existsArticle( const QString & article ); + + /** reimplemented DCOP method from BatchIface + * import articles from a file. The user is asked for the filename + */ + virtual void loadFromFile( const QString & url ); + + /** reimplemented DCOP method from BatchIface + * print immediately with current settings + * @p printer print to this printer (must be known to the system) + * @p bUserInteraction if false no dialog will pop up besides the printer dialog + */ + virtual void printNow( const QString & printer, bool bUserInteraction = true ); + + /** reimplemented DCOP method from BatchIface + * to allow the user to set the label to be used + * @p url path of the label which shall get printed + */ + virtual void setFilename( const QString & url ); + + /** reimplemented DCOP method from BatchIface + * Set the batchwizards mode to print from imported data + * and import the data from the csv file @p filname + * @p filename csv file to import + */ + virtual void setImportCsvFile( const QString & filename ); + + /** reimplemented DCOP method from BatchIface + * Set the batchwizards mode to print from imported data + * and import the data from the sql query @p query + * @p query sql query to execute to get on user defined variables + */ + virtual void setImportSqlQuery( const QString & query ); + + /** reimplemented DCOP method from BatchIface + * set the numbers of labels to print. + * the option to print without data import is activated too using + * this option + * @p n number of labels to print + */ + virtual void setNumLabels( const int n ); + + /** reimplemented DCOP method from BatchIface + * sets wether the user wants to print to a postscript printer, + * a barcode printer or to image files. + * @p e is of datatype BatchPrinter::EOutputFormat + */ + virtual void setOutputFormat( const int e ); + + /** reimplemented DCOP method from BatchIface + * allow the user to set the value and start value for + * the serial number that can be used on labels using the [serial] token + * @p val value of the serial number (e.g. TEST0002) + * @p inc the serial number is increased that much for every label + */ + virtual void setSerialNumber( const QString & val, int inc ); + + public slots: + /** reimplemented DCOP method from BatchIface + * import articles from the clipboard + */ + virtual void loadFromClipboard(); + + + private slots: + void addAllItems(); + void enableControls(); + void customerIdChanged( int index ); + void customerNameChanged( int index ); + void addItem(); + bool slotAddItem( const QString & article, const QString & group, int count ); + void changeItem( QListViewItem* item, const QPoint &, int ); + void editItem(); + void removeItem(); + + void slotTableInsert(); + void slotTableRemove(); + void loadFromFile(); + + void slotAddAddress(); + void slotAddAllAddress(); + void slotRemoveAddress(); + void slotRemoveAllAddress(); + + private: + void moveAddress( QListView* src, QListView* dst, bool bAll = false ); + + void fillByteArray(); + void fillVarList(); + bool fillVarTable(); + void fillAddressList(); + + void setupPage1(); + void setupPage2(); + void setupPage3(); + void setupPage4(); + void setupPage5(); + void setupPage10(); + + void setupStackPage1(); + void setupStackPage2(); + void setupStackPage3(); + void setupStackPage4(); + + void setupSql(); + void setupBatchPrinter( BatchPrinter* batch, int m ); + + void addGroupCompletion( const QString & group ); + void loadData( const QString & data ); + + protected: + void accept(); + void showPage( QWidget* w ); + + private: + /** m_bytearray_filename is set whenever + * the kbarcide label file has been read into + * the buffer m_bytearray. Therefore we have only + * to re-read the bytearray when the filename was + * changed by the user. + */ + QString m_bytearray_filename; + QByteArray m_bytearray; + + QWidget* page1; + QWidget* page2; + QWidgetStack* page3; + QVBox* page4; + QVBox* page5; + QWidget* page10; + + QVBox* stack1; + QHBox* stack2; + QVBox* stack3; + QWidget* stack4; + + QVBox* imageBox; + + QLabel* labelInfo; + QLabel* labelSqlQuery; + QLabel* labelCsvFile; + QLabel* labelEncoding; + + QRadioButton* radioSqlArticles; + QRadioButton* radioVarImport; + QRadioButton* radioSimple; + QRadioButton* radioAddressBook; + + QRadioButton* radioPrinter; + QRadioButton* radioImage; + QRadioButton* radioBarcode; + + QRadioButton* radioImportSql; + QRadioButton* radioImportCSV; + QRadioButton* radioImportManual; + + QRadioButton* radioImageFilenameArticle; + QRadioButton* radioImageFilenameBarcode; + QRadioButton* radioImageFilenameCustom; + KLineEdit* editImageFilename; + KURLRequester* imageDirPath; + + KLineEdit* importSqlQuery; + KURLRequester* importCsvFile; + + KComboBox* customerName; + KComboBox* customerId; + KComboBox* comboFormat; + EncodingCombo* comboEncoding; + + KCompletion* compGroup; + + KIntNumInput* serialInc; + KIntNumInput* numLabels; + + QTable* m_varTable; + KListBox* m_varList; + + KListView* listAddress; + KListView* listSelectedAddress; + + KListView* sqlList; + KLineEdit* serialStart; + + QCheckBox* checkKeepOpen; + + KPushButton* buttonAddAddress; + KPushButton* buttonRemoveAddress; + KPushButton* buttonAddAllAddress; + KPushButton* buttonRemoveAllAddress; + + KPushButton* buttonAdd; + KPushButton* buttonImport; + KPushButton* buttonEdit; + KPushButton* buttonRemove; + KPushButton* buttonRemoveAll; + + KPushButton* buttonTableInsert; + KPushButton* buttonTableRemove; + + KURLRequester* m_url; +}; + +#endif // BATCHWIZARD_H diff --git a/kbarcode/commands.cpp b/kbarcode/commands.cpp new file mode 100644 index 0000000..a11c01b --- /dev/null +++ b/kbarcode/commands.cpp @@ -0,0 +1,604 @@ +/*************************************************************************** + commands.cpp - description + ------------------- + begin : Don Dez 19 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "commands.h" +#include "mycanvasview.h" + +#include "barkode.h" +#include "tcanvasitem.h" +#include "rectitem.h" +#include "textitem.h" +#include "imageitem.h" +#include "barcodeitem.h" +#include "lineitem.h" +//NY26 +#include "textlineitem.h" +//NY26 + + +// KDE includes +#include <kapplication.h> + +QPoint getFreePos( QCanvas* c ) +{ + MyCanvas* canvas = (MyCanvas*)c; + + if( !c->width() && !c->height() ) + return QPoint( canvas->rect().x(), canvas->rect().y() ); + + // TODO: fix for positions on label + int x = KApplication::random() % canvas->rect().width() - 20; + int y = KApplication::random() % canvas->rect().height() - 20; + + if( x > 0 && y > 0 ) + return QPoint( canvas->rect().x() + x, canvas->rect().y() + y ); + else + return QPoint( canvas->rect().x(), canvas->rect().y() ); +} + +CommandUtils::CommandUtils(TCanvasItem* item) + : QObject() +{ + m_canvas_item = item; + m_canvas_item->addRef(); + + c = m_canvas_item->canvas(); + /* NOT NEEDED: + if( m_canvas_item && m_canvas_item->item() ) + connect( m_canvas_item->item(), SIGNAL( destroyed() ), this, SLOT( documentItemDeleted() ) ); + */ +} + +CommandUtils::~CommandUtils() +{ + m_canvas_item->remRef(); +} + +bool CommandUtils::canvasHasItem() +{ + if( m_canvas_item && c ) + { + QCanvasItemList list = c->allItems(); + for( unsigned int i=0;i<list.count();i++) + if( m_canvas_item == list[i] ) + return true; + } + + return false; +} + + +void CommandUtils::documentItemDeleted() +{ + /** the document item got deleted, so that we can assume the TCanvasItem + * was deleted to (as it usually deltes the document item) + */ + /* NOT NEEDED + m_canvas_item = NULL; + c = NULL; + + qDebug("Document item removed from list!"); + delete this; + */ +} + +NewItemCommand::NewItemCommand( MyCanvasView* view, const QString & name ) + : QObject(), KCommand() +{ + cv = view; + m_name = name; + m_point = getFreePos( cv->canvas() ); + m_item = NULL; + m_object = NULL; +} + +NewItemCommand::~NewItemCommand() +{ + m_item->remRef(); +} + +void NewItemCommand::execute() +{ + if( !m_item ) + { + create(); + + if( m_object ) + { + m_item = new TCanvasItem( cv ); + m_item->setItem( m_object ); + m_item->move( m_point.x(), m_point.y() ); + m_item->addRef(); + + /* NOT NEEDED: + connect( m_object, SIGNAL( destroyed() ), this, SLOT( documentItemDeleted() ) ); + */ + } + } + + if( m_item ) + { + m_item->setCanvas( cv->canvas() ); + m_item->show(); + m_item->update(); + cv->setCurrent( m_item ); + } +} + +void NewItemCommand::unexecute() +{ + if( m_item ) { + m_item->setCanvas( NULL ); + m_item->hide(); + } +} + +void NewItemCommand::documentItemDeleted() +{ + /** the document item got deleted, so that we can assume the TCanvasItem + * was deleted to (as it usually deltes the document item) + */ + + /* NOT NEEDED: + m_item = NULL; + m_object = NULL; + + qDebug("NewItemCommand: Document item removed from list!"); + delete this; + */ +} + + +void ResizeCommand::setRect( int cx, int cy, int cw, int ch ) +{ + // make sure that the item cannot + // be resized to a negative value + if( cw <= 0 ) + cw = orect.width(); + + if( ch <= 0 ) + ch = orect.height(); + + rect = QRect( cx, cy, cw, ch ); +} + +void ResizeCommand::execute() +{ + if( canvasHasItem() ) { + if( m_shift && rect.width() ) { + double r = (double)orect.height() / (double)orect.width(); + rect.setWidth( int(rect.height() / r) ); + } + + m_canvas_item->moveMM( rect.x(), rect.y() ); + m_canvas_item->setSizeMM( rect.width(), rect.height() ); + m_canvas_item->update(); + + if( m_canvas_item->item()->rtti() == eRtti_Image ) + { + ImageItem* item = static_cast<ImageItem*>(m_canvas_item->item()); + item->updateImage(); + } + } +} + +void ResizeCommand::unexecute() +{ + if( canvasHasItem() ) { + m_canvas_item->moveMM( orect.x(), orect.y() ); + m_canvas_item->setSizeMM( orect.width(), orect.height() ); + m_canvas_item->update(); + + if( m_canvas_item->item()->rtti() == eRtti_Image ) + { + ImageItem* item = static_cast<ImageItem*>(m_canvas_item->item()); + item->updateImage(); + } + } +} + +void MoveCommand::execute() +{ + if( canvasHasItem() ) + { + m_canvas_item->moveByMM( x, y ); + m_canvas_item->update(); + } +} + +void MoveCommand::unexecute() +{ + if( canvasHasItem() ) + { + m_canvas_item->moveByMM( -x, -y ); + m_canvas_item->update(); + } +} + +ChangeZCommand::ChangeZCommand( int z, TCanvasItem* it ) + : CommandUtils( it ) +{ + m_z = z; + m_oldz = (int)m_canvas_item->z(); +} + +void ChangeZCommand::execute() +{ + if( canvasHasItem() ) + { + m_canvas_item->setZ( m_z ); + m_canvas_item->update(); + } +} + +void ChangeZCommand::unexecute() +{ + if( canvasHasItem() ) + { + m_canvas_item->setZ( m_oldz ); + m_canvas_item->update(); + } +} + +void LockCommand::execute() +{ + if( canvasHasItem() ) + { + m_canvas_item->item()->setLocked( m_locked ); + m_canvas_item->update(); + } +} + +void LockCommand::unexecute() +{ + if( canvasHasItem() ) + { + m_canvas_item->item()->setLocked( !m_locked ); + m_canvas_item->update(); + } +} + +PictureCommand::PictureCommand( double r, bool mh, bool mv, EImageScaling s, ImageItem* it ) + : CommandUtils( it->canvasItem() ) +{ + rotate = r; + mirrorv = mv; + mirrorh = mh; + scaling = s; + + orotate = it->rotation(); + omirrorv = it->mirrorVertical(); + omirrorh = it->mirrorHorizontal(); + oscaling = it->scaling(); + + oexpression = it->expression(); + opixmap = it->pixmap(); + opixserial = opixmap.serialNumber(); + + oldsize.setWidth( it->rect().width() ); + oldsize.setHeight( it->rect().height() ); + + m_item = it; +} + +void PictureCommand::setExpression( const QString & expr ) +{ + expression = expr; +} + +void PictureCommand::setPixmap( const QPixmap & pix ) +{ + pixmap = pix; + pixserial = pixmap.serialNumber(); +} + +void PictureCommand::execute() +{ + if( canvasHasItem() ) { + m_item->setRotation( rotate ); + m_item->setMirrorVertical( mirrorv ); + m_item->setMirrorHorizontal( mirrorh ); + m_item->setScaling( scaling ); + m_item->setExpression( expression ); + m_item->setPixmap( pixmap ); + + if( !pixmap.isNull() && pixserial != opixserial ) + m_item->canvasItem()->setSize( pixmap.width(), pixmap.height() ); + } +} + +void PictureCommand::unexecute() +{ + if( canvasHasItem() ) { + m_item->setRotation( orotate ); + m_item->setMirrorVertical( omirrorv ); + m_item->setMirrorHorizontal( omirrorh ); + m_item->setScaling( oscaling ); + m_item->setExpression( oexpression ); + m_item->setPixmap( opixmap ); + m_item->canvasItem()->setSize( oldsize.width(), oldsize.height() ); + } +} + +TextChangeCommand::TextChangeCommand( TextItem* it, QString t ) + : CommandUtils( it->canvasItem() ) +{ + m_item = it; + text = t; + oldtext = m_item->text(); +} + +void TextChangeCommand::execute() +{ + if( canvasHasItem() ) + m_item->setText( text ); +} + +void TextChangeCommand::unexecute() +{ + if( canvasHasItem() ) + m_item->setText( oldtext ); +} + +TextRotationCommand::TextRotationCommand( double rot, TextItem* t ) + : CommandUtils( t->canvasItem() ), m_item( t ) +{ + rot1 = rot; + rot2 = t->rotation(); +} + +void TextRotationCommand::execute() +{ + m_item->setRotation( rot1 ); +} + +void TextRotationCommand::unexecute() +{ + m_item->setRotation( rot2 ); +} + +//NY24 +TextLineChangeCommand::TextLineChangeCommand( TextLineItem* it, QString t, int font , int magvert, int maghor) + : CommandUtils( it->canvasItem() ) +{ + m_item = it; + text = t; + oldtext = m_item->text(); + m_font = font; + m_mag_vert = magvert; + m_mag_hor = maghor; +} + +void TextLineChangeCommand::execute() +{ + if( canvasHasItem() ){ + m_item->setText( text ); + m_item->setFont(m_font); + m_item->setMagVert(m_mag_vert); + m_item->setMagHor(m_mag_hor); + } +} + +void TextLineChangeCommand::unexecute() +{ + if( canvasHasItem() ) + m_item->setText( oldtext ); +} +//NY24 + +BarcodeCommand::BarcodeCommand( BarcodeItem* bcode, Barkode* d ) + : CommandUtils( bcode->canvasItem() ) +{ + m_item = bcode; + olddata = *bcode; + data = d; +} + +void BarcodeCommand::execute() +{ + if( canvasHasItem() ) { + m_item->setData( *data ); + m_item->updateBarcode(); + } +} + +void BarcodeCommand::unexecute() +{ + if( canvasHasItem() ) { + m_item->setData( olddata ); + m_item->updateBarcode(); + } +} + +void NewPictureCommand::create() +{ + ImageItem* r = new ImageItem(); + m_object = r; +} + +NewRectCommand::NewRectCommand( MyCanvasView* v, bool circle ) + : NewItemCommand( v, i18n("New Rectangle") ) +{ + m_circle = circle; +} + +void NewRectCommand::create() +{ + RectItem* r = new RectItem(); + r->setCircle( m_circle ); + + m_object = r; +} + +NewLineCommand::NewLineCommand( MyCanvasView* v ) + : NewItemCommand( v, i18n("New Line") ) +{ +} + +void NewLineCommand::create() +{ + m_object = new LineItem(); +} + +NewTextCommand::NewTextCommand( QString t, MyCanvasView* v, TokenProvider* token ) + : NewItemCommand( v, i18n("New Text") ), + m_token( token ) +{ + text = t; +} + +void NewTextCommand::create() +{ + TextItem* t = new TextItem(); + t->setTokenProvider( m_token ); + t->setText( text ); + + m_object = t; +} + +//NY25 +NewTextLineCommand::NewTextLineCommand( QString t, MyCanvasView* v, TokenProvider* token ) + : NewItemCommand( v, i18n("New TextLine") ), + m_token( token ) +{ + text = t; +} + +void NewTextLineCommand::create() +{ + TextLineItem* t = new TextLineItem(); + t->setTokenProvider( m_token ); + t->setText( text ); + + m_object = t; +} +//NY25 + +NewBarcodeCommand::NewBarcodeCommand( MyCanvasView* v, TokenProvider* token ) + : NewItemCommand( v, i18n("New Barcode") ), + m_token( token ) +{ +} + +void NewBarcodeCommand::create() +{ + m_object = new BarcodeItem(); + m_object->setTokenProvider( m_token ); +} + +DeleteCommand::~DeleteCommand() +{ + if( m_canvas_item && canvasHasItem() && m_canvas_item->canvas() == 0 ) + { + DocumentItem* item = m_canvas_item->item(); + if( item ) + item->disconnect( item, SIGNAL( destroyed() ), this, 0 ); + delete m_canvas_item; + } +} + +void DeleteCommand::execute() +{ + if( canvasHasItem() ) { + m_canvas_item->setCanvas( 0 ); + m_canvas_item->hide(); + } +} + +void DeleteCommand::unexecute() +{ + // canvasHasItem won't work here + if( m_canvas_item ) { + m_canvas_item->setCanvas( c ); + m_canvas_item->show(); + } +} + +BorderCommand::BorderCommand( bool border, const QPen & pen, DocumentItem* item ) + : CommandUtils( item->canvasItem() ) +{ + m_new_border = border; + m_new_pen = pen; + m_item = item; +} + +void BorderCommand::execute() +{ + if( canvasHasItem() ) + { + m_old_border = m_item->border(); + m_old_pen = m_item->pen(); + m_item->setBorder( m_new_border ); + m_item->setPen( m_new_pen ); + + m_canvas_item->update(); + } +} + +void BorderCommand::unexecute() +{ + if( canvasHasItem() ) + { + m_item->setBorder( m_old_border ); + m_item->setPen( m_old_pen ); + + m_canvas_item->update(); + } +} + +FillCommand::FillCommand( QColor c, RectItem* r ) + : CommandUtils( r->canvasItem() ) +{ + fill = c; + m_item = r; +} + +void FillCommand::execute() +{ + if( canvasHasItem() ) { + fill2 = m_item->color(); + m_item->setColor( fill ); + } +} + +void FillCommand::unexecute() +{ + if( canvasHasItem() ) { + m_item->setColor( fill2 ); + } +} + +void ScriptCommand::execute() +{ + if( canvasHasItem() ) + { + m_old_script = m_canvas_item->item()->visibilityScript(); + m_canvas_item->item()->setVisibilityScript( m_script ); + m_canvas_item->update(); + } +} + +void ScriptCommand::unexecute() +{ + if( canvasHasItem() ) + { + m_canvas_item->item()->setVisibilityScript( m_old_script ); + m_canvas_item->update(); + } +} + +#include "commands.moc" diff --git a/kbarcode/commands.h b/kbarcode/commands.h new file mode 100644 index 0000000..e9eb001 --- /dev/null +++ b/kbarcode/commands.h @@ -0,0 +1,433 @@ +/*************************************************************************** + commands.h - description + ------------------- + begin : Don Dez 19 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef COMMANDS_H +#define COMMANDS_H + +#include "mycanvasitem.h" + +#include <qobject.h> + +#include <kcommand.h> +#include <klocale.h> + +#include "barcodeitem.h" +#include "tcanvasitem.h" +#include "imageitem.h" + +struct barcodeData; +class RectItem; +class MyCanvasLine; +class MyCanvasRectangle; +class MyCanvasView; +class CanvasBarcode; +class PictureRectangle; +class QCanvasItem; +class QColor; +class QFont; +class QImage; +class QPen; +class QPixmap; +class QPoint; +class QString; +class TextItem; +//NY29 +class TextLineItem; +//NY29 +class TokenProvider; + +// Stuff for undo redo + +class CommandUtils : public QObject { + Q_OBJECT + public: + CommandUtils(TCanvasItem* item); + ~CommandUtils(); + + bool canvasHasItem(); + + private slots: + void documentItemDeleted(); + + protected: + QCanvas* c; + TCanvasItem* m_canvas_item; +}; + +/** + * NewItemCommand is the base class for all classes + * that create a new item in the label editor (e.g. a + * barcode or a text element). + * You have to implement void create() which creates + * a QCanvasItem in item. + * NewItemCommand takes care about possitioning and + * undo/redo (because of KCommand). + * + * @author Dominik Seichter + */ +class NewItemCommand : public QObject, public KCommand { + Q_OBJECT + public: + NewItemCommand( MyCanvasView* view, const QString & name ); + virtual ~NewItemCommand(); + + void execute(); + void unexecute(); + QString name() const { + return m_name; + }; + + /** @returns a pointer to the TCanvasItem created by this class + */ + inline TCanvasItem* createdItem() const { return m_item; } + + private slots: + void documentItemDeleted(); + + protected: + /** This function has to be reimplemented in all subclasses + * and has to create a QCanvasItem and store a pointer to it + * in item. Otherwise KBarcode is going to crash. + * + * Example: + * + * <pre> + * void create() { + * DrawingRect* r = new DrawingRect( 0 ); // Drawing rect is a subclass of QCanvasItem + * r->setCircle( m_circle ); // Do something with r + * item = r; // save r into item, so that NewItemCommand knows about it + * } + * </pre> + */ + virtual void create() = 0; + + MyCanvasView* cv; + TCanvasItem* m_item; + DocumentItem* m_object; + QPoint m_point; + QString m_name; +}; + +class ResizeCommand : public KCommand, CommandUtils { + public: + ResizeCommand( TCanvasItem* it, bool shift = false ) + : CommandUtils( it ) + { + orect = rect = m_canvas_item->item()->rectMM(); + m_shift = shift; + } + ~ResizeCommand() {} + + void setRect( int cx, int cy, int cw, int ch ); + + void execute(); + void unexecute(); + QString name() const { + return i18n("Resized Item"); + } + + protected: + QRect orect; + QRect rect; + bool m_shift; +}; + +/** Move a TCanvasItem on the canvas + */ +class MoveCommand : public KCommand, CommandUtils { + public: + /** + * @param cx move in x direction cx mm + * @param cy move in y direction cy mm + */ + MoveCommand( int cx, int cy, TCanvasItem* it ) + : CommandUtils( it ) + { + x = cx; + y = cy; + } + ~MoveCommand() {} + + void execute(); + void unexecute(); + QString name() const { + return i18n("Moved Item"); + } + + protected: + int x; + int y; +}; + +class ChangeZCommand : public KCommand, CommandUtils { + public: + ChangeZCommand( int z, TCanvasItem* it ); + + void execute(); + void unexecute(); + QString name() const { + return i18n("Raised or lowered an item"); + } + + protected: + int m_z, m_oldz; +}; + +class LockCommand : public KCommand, CommandUtils { + public: + LockCommand( bool lock, TCanvasItem* it ) + : CommandUtils( it ) + { + m_locked = lock; + } + + void execute(); + void unexecute(); + QString name() const { + return i18n("Protected Item"); + } + + protected: + bool m_locked; +}; + +class PictureCommand : public KCommand, CommandUtils { + public: + PictureCommand( double r, bool mirrorh, bool mirrorv, EImageScaling s, ImageItem* it ); + ~PictureCommand() {} + + void setExpression( const QString & expr ); + void setPixmap( const QPixmap & pix ); + + void execute(); + void unexecute(); + QString name() const { + return i18n("Changed Settings"); + } + protected: + double rotate, orotate; + bool mirrorv, omirrorv; + bool mirrorh, omirrorh; + QString expression, oexpression; + EImageScaling scaling, oscaling; + QPixmap pixmap, opixmap; + QSize oldsize; + int pixserial, opixserial; + + ImageItem* m_item; +}; + +class TextChangeCommand : public KCommand, CommandUtils { + public: + TextChangeCommand( TextItem* it, QString t ); + ~TextChangeCommand() { } + + void execute(); + void unexecute(); + QString name() const { + return i18n("Changed Text"); + } + protected: + QString oldtext, text; + TextItem* m_item; +}; + +class TextRotationCommand : public KCommand, protected CommandUtils { + public: + TextRotationCommand( double rot, TextItem* t ); + + void execute(); + void unexecute(); + QString name() const { + return i18n("Rotated Text"); + } + + protected: + double rot1, rot2; + TextItem* m_item; +}; + + +//NY28 +class TextLineChangeCommand : public KCommand, CommandUtils { + public: + TextLineChangeCommand( TextLineItem* it, QString t, int font, int magvert, int maghor ); + ~TextLineChangeCommand() { } + + void execute(); + void unexecute(); + QString name() const { + return i18n("Changed Text"); + } + protected: + QString oldtext, text; + TextLineItem* m_item; + int m_font; + int m_mag_vert; + int m_mag_hor; +}; +//NY28 + +class BarcodeCommand : public KCommand, CommandUtils { + public: + BarcodeCommand( BarcodeItem* bcode, Barkode* d ); + ~BarcodeCommand() { + delete data; + } + + void execute(); + void unexecute(); + QString name() const { + return i18n("Changed Barcode"); + } + protected: + Barkode olddata; + Barkode* data; + BarcodeItem* m_item; +}; + +class NewPictureCommand : public NewItemCommand { + public: + NewPictureCommand( MyCanvasView* v ) + : NewItemCommand( v, i18n("New Picture") ) + { + } + + protected: + void create(); +}; + +class NewTextCommand : public NewItemCommand { + public: + NewTextCommand( QString t, MyCanvasView* v, TokenProvider* token ); + + protected: + void create(); + QString text; + TokenProvider* m_token; +}; + +//NY27 +class NewTextLineCommand : public NewItemCommand { + public: + NewTextLineCommand( QString t, MyCanvasView* v, TokenProvider* token ); + + protected: + void create(); + QString text; + TokenProvider* m_token; +}; +//NY27 + +class NewRectCommand : public NewItemCommand { + public: + NewRectCommand( MyCanvasView* v, bool circle = false ); + + protected: + void create(); + bool m_circle; +}; + +class NewLineCommand : public NewItemCommand { + public: + NewLineCommand( MyCanvasView* v ); + + protected: + void create(); +}; + +class NewBarcodeCommand : public NewItemCommand { + public: + NewBarcodeCommand( MyCanvasView* v, TokenProvider* token ); + + protected: + void create(); + + private: + TokenProvider* m_token; +}; + +class DeleteCommand : public KCommand, CommandUtils { + public: + DeleteCommand( TCanvasItem* it ) + : CommandUtils( it ) + { + } + ~DeleteCommand(); + + void execute(); + void unexecute(); + QString name() const { + return i18n("Delete Item"); + } +}; + +class BorderCommand : public KCommand, protected CommandUtils { + public: + BorderCommand( bool border, const QPen & pen, DocumentItem* item ); + + void execute(); + void unexecute(); + QString name() const { + return i18n("Modified Border"); + } + + protected: + bool m_new_border; + bool m_old_border; + QPen m_new_pen; + QPen m_old_pen; + + DocumentItem* m_item; +}; + +class FillCommand : public KCommand, protected CommandUtils { + public: + FillCommand( QColor c, RectItem* r ); + + void execute(); + void unexecute(); + QString name() const { + return i18n("Modified Rectangle or Ellipse"); + } + + protected: + QColor fill, fill2; + RectItem* m_item; +}; + +class ScriptCommand : public KCommand, CommandUtils { + public: + ScriptCommand( const QString & script, TCanvasItem* it ) + : CommandUtils( it ) + { + m_script = script; + } + ~ScriptCommand() {} + + void execute(); + void unexecute(); + QString name() const { + return i18n("Changed visibility JavaScript"); + } + + protected: + QString m_script; + QString m_old_script; +}; + +#endif diff --git a/kbarcode/configdialog.cpp b/kbarcode/configdialog.cpp new file mode 100644 index 0000000..787a560 --- /dev/null +++ b/kbarcode/configdialog.cpp @@ -0,0 +1,351 @@ +/*************************************************************************** + configdialog.cpp - description + ------------------- + begin : Fre Apr 26 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "configdialog.h" +#include "printersettings.h" +#include "sqltables.h" + +// Qt includes +#include <qbuttongroup.h> +#include <qcheckbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qpaintdevicemetrics.h> +#include <qradiobutton.h> +#include <qsqldatabase.h> +#include <qtooltip.h> + +// KDE includes +#include <kabc/addressee.h> +#include <kapplication.h> +#include <kconfig.h> +#include <kcolorbutton.h> +#include <kiconloader.h> +#include <kimageio.h> +#include <klineedit.h> +#include <klocale.h> +#include <kcombobox.h> +#include <knuminput.h> +#include <kmessagebox.h> +#include <kpushbutton.h> + +const QString cached = I18N_NOOP("There are currently %1 cached barcodes."); +using namespace KABC; + +ConfigDialog::ConfigDialog( QWidget* parent ) + : KDialogBase( IconList, i18n("Configure KBarcode"), KDialogBase::Ok|KDialogBase::Cancel, + KDialogBase::Ok, parent, "", true, true ) +{ + setupTab2(); // Printer + setupTab1(); // SQL + setupTab4(); // label editor + setupTab3(); // import + setupTab5(); // on new +} + +ConfigDialog::~ConfigDialog() +{ +} + +void ConfigDialog::setupTab1( ) +{ + QFrame* box = addPage( i18n("SQL Settings"), "", BarIcon("connect_no") ); + QVBoxLayout* layout = new QVBoxLayout( box, 6, 6 ); + QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding ); + + sqlwidget = new SqlWidget( false, box, "sqlwidget" ); + + layout->addWidget( sqlwidget ); + layout->addItem( spacer ); +} + +void ConfigDialog::setupTab2() +{ + labelprinterdata* lb = PrinterSettings::getInstance()->getData(); + + QFrame* box = addPage( i18n("Print Settings"), "", BarIcon("fileprint") ); + + QVBoxLayout* tabLayout = new QVBoxLayout( box, 11, 6 ); + QHBoxLayout* Layout0 = new QHBoxLayout( 0, 6, 6 ); + QHBoxLayout* Layout1 = new QHBoxLayout( 0, 6, 6 ); + QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding ); + + printerQuality = new KComboBox( false, box ); + printerQuality->insertItem( i18n("Medium Resolution (300dpi)") ); + printerQuality->insertItem( i18n("High Resolution (600dpi)") ); + printerQuality->insertItem( i18n("Very High Resolution (1200dpi)") ); + + switch( lb->quality ) { + case PrinterSettings::Middle: + printerQuality->setCurrentItem( 0 ); + break; + case PrinterSettings::High: + printerQuality->setCurrentItem( 1 ); + break; + case PrinterSettings::VeryHigh: + printerQuality->setCurrentItem( 2 ); + break; + default: + break; + } + + pageFormat = new KComboBox( false, box ); + PrinterSettings::getInstance()->insertPageFormat( pageFormat ); + pageFormat->setCurrentItem( lb->format ); + + Layout0->addWidget( new QLabel( i18n("Printer Resolution:"), box ) ); + Layout0->addWidget( printerQuality ); + Layout1->addWidget( new QLabel( i18n("Preview Page Format:"), box ) ); + Layout1->addWidget( pageFormat ); + tabLayout->addLayout( Layout0 ); + tabLayout->addLayout( Layout1 ); + tabLayout->addItem( spacer ); +} + +void ConfigDialog::setupTab3() +{ + labelprinterdata* lb = PrinterSettings::getInstance()->getData(); + + QFrame* box = addPage( i18n("Import"), "", BarIcon("fileimport") ); + QGridLayout* grid = new QGridLayout( box, 2, 2 ); + + QLabel* label = new QLabel( box ); + label->setText( i18n("Comment:") ); + grid->addWidget( label, 0, 0 ); + + comment = new KLineEdit( lb->comment, box ); + grid->addWidget( comment, 0, 1 ); + + label = new QLabel( box ); + label->setText( i18n( "Separator:" ) ); + grid->addWidget( label, 1, 0 ); + + separator = new KLineEdit( lb->separator, box ); + grid->addWidget( separator, 1, 1 ); + + label = new QLabel( box ); + label->setText( i18n("Quote Character:") ); + grid->addWidget( label, 2, 0 ); + + quote = new KLineEdit( lb->quote, box ); + grid->addWidget( quote, 2, 1 ); + + checkUseCustomNo = new QCheckBox( i18n("&Use customer article no. for import"), box ); + checkUseCustomNo->setChecked( lb->useCustomNo ); + + grid->addMultiCellWidget( checkUseCustomNo, 3, 3, 0, 2 ); + + QHBoxLayout* Layout1 = new QHBoxLayout( 0, 6, 6 ); + Layout1->addWidget( new QLabel( i18n("File Format:"), box ) ); + + combo1 = new KComboBox( box ); + combo1->insertItem( i18n("Quantity") ); + combo1->insertItem( i18n("Article Number") ); + combo1->insertItem( i18n("Group") ); + Layout1->addWidget( combo1 ); + + combo2 = new KComboBox( box ); + combo2->insertItem( i18n("Quantity") ); + combo2->insertItem( i18n("Article Number") ); + combo2->insertItem( i18n("Group") ); + Layout1->addWidget( combo2 ); + + combo3 = new KComboBox( box ); + combo3->insertItem( i18n("Quantity") ); + combo3->insertItem( i18n("Article Number") ); + combo3->insertItem( i18n("Group") ); + Layout1->addWidget( combo3 ); + + grid->addMultiCellLayout( Layout1, 4, 4, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + grid->addItem( spacer, 5, 0 ); + + KConfig* config = kapp->config(); + config->setGroup("FileFormat"); + combo1->setCurrentItem( config->readNumEntry("Data0", 0 ) ); + combo2->setCurrentItem( config->readNumEntry("Data1", 1 ) ); + combo3->setCurrentItem( config->readNumEntry("Data2", 2 ) ); +} + +void ConfigDialog::setupTab4() +{ + QFrame* box = addPage( i18n("Label Editor"), "", BarIcon("kbarcode") ); + QGridLayout* tabLayout = new QGridLayout( box, 11, 6 ); + + checkNewDlg = new QCheckBox( box ); + checkNewDlg->setText( i18n("&Create a new label on startup") ); + + date = new KLineEdit( box ); + labelDate = new QLabel( box ); + + connect( date, SIGNAL( textChanged( const QString & ) ), this, SLOT( updateDatePreview() ) ); + + spinGrid = new KIntNumInput( 0, box ); + spinGrid->setLabel( i18n("Grid:" ), AlignLeft | AlignVCenter ); + spinGrid->setRange(2, 100, 1, false ); + + colorGrid = new KColorButton( box ); + + tabLayout->addWidget( checkNewDlg, 0, 0 ); + tabLayout->addMultiCellWidget( spinGrid, 1, 1, 0, 2 ); + tabLayout->addWidget( new QLabel( i18n("Grid Color:"), box ), 2, 0 ); + tabLayout->addWidget( colorGrid, 2, 1 ); + tabLayout->addWidget( new QLabel( i18n("Date Format:"), box ), 3, 0 ); + tabLayout->addWidget( date, 3, 1 ); + tabLayout->addWidget( labelDate, 3, 2 ); +} + +void ConfigDialog::setupTab5() +{ + labelprinterdata* lb = PrinterSettings::getInstance()->getData(); + QFrame* box = addPage( i18n("On New"), "", BarIcon("filenew") ); + + QVBoxLayout* tabLayout = new QVBoxLayout( box, 11, 6 ); + + QButtonGroup* bg = new QButtonGroup( i18n("On New Article"), box ); + bg->setColumnLayout(0, Qt::Vertical ); + bg->layout()->setSpacing( 6 ); + bg->layout()->setMargin( 11 ); + QGridLayout* bgLayout = new QGridLayout( bg->layout() ); + + QStringList alist, glist; + alist.append( i18n("No Line Break") ); + alist.append( i18n("Line Break") ); + alist.append( i18n("Insert Label X") ); + alist.append( i18n("New Page") ); + alist.append( i18n("Article No.") ); + + glist.append( i18n("No Line Break") ); + glist.append( i18n("Line Break") ); + glist.append( i18n("Insert Label X") ); + glist.append( i18n("New Page") ); + glist.append( i18n("Group Name") ); + + onNewArticle1 = new KComboBox( false, bg ); + onNewArticle2 = new KComboBox( false, bg ); + onNewArticle3 = new KComboBox( false, bg ); + onNewArticle4 = new KComboBox( false, bg ); + + onNewArticle1->insertStringList( alist ); + onNewArticle2->insertStringList( alist ); + onNewArticle3->insertStringList( alist ); + onNewArticle4->insertStringList( alist ); + + bgLayout->setColStretch( 1, 3 ); + + bgLayout->addWidget( new QLabel( "1.", bg ), 0, 0 ); + bgLayout->addWidget( new QLabel( "2.", bg ), 1, 0 ); + bgLayout->addWidget( new QLabel( "3.", bg ), 2, 0 ); + bgLayout->addWidget( new QLabel( "4.", bg ), 3, 0 ); + + bgLayout->addWidget( onNewArticle1, 0, 1 ); + bgLayout->addWidget( onNewArticle2, 1, 1 ); + bgLayout->addWidget( onNewArticle3, 2, 1 ); + bgLayout->addWidget( onNewArticle4, 3, 1 ); + + QButtonGroup* bg2 = new QButtonGroup( i18n("On New Group"), box ); + bg2->setColumnLayout(0, Qt::Vertical ); + bg2->layout()->setSpacing( 6 ); + bg2->layout()->setMargin( 11 ); + QGridLayout* bg2Layout = new QGridLayout( bg2->layout() ); + + onNewGroup1 = new KComboBox( false, bg2 ); + onNewGroup2 = new KComboBox( false, bg2 ); + onNewGroup3 = new KComboBox( false, bg2 ); + onNewGroup4 = new KComboBox( false, bg2 ); + + onNewGroup1->insertStringList( glist ); + onNewGroup2->insertStringList( glist ); + onNewGroup3->insertStringList( glist ); + onNewGroup4->insertStringList( glist ); + + bg2Layout->setColStretch( 1, 3 ); + + bg2Layout->addWidget( new QLabel( "1.", bg2 ), 0, 0 ); + bg2Layout->addWidget( new QLabel( "2.", bg2 ), 1, 0 ); + bg2Layout->addWidget( new QLabel( "3.", bg2 ), 2, 0 ); + bg2Layout->addWidget( new QLabel( "4.", bg2 ), 3, 0 ); + + bg2Layout->addWidget( onNewGroup1, 0, 1 ); + bg2Layout->addWidget( onNewGroup2, 1, 1 ); + bg2Layout->addWidget( onNewGroup3, 2, 1 ); + bg2Layout->addWidget( onNewGroup4, 3, 1 ); + + tabLayout->addWidget( bg ); + tabLayout->addWidget( bg2 ); + + onNewArticle1->setCurrentItem( lb->articleEvent1 ); + onNewArticle2->setCurrentItem( lb->articleEvent2 ); + onNewArticle3->setCurrentItem( lb->articleEvent3 ); + onNewArticle4->setCurrentItem( lb->articleEvent4 ); + + onNewGroup1->setCurrentItem( lb->groupEvent1 ); + onNewGroup2->setCurrentItem( lb->groupEvent2 ); + onNewGroup3->setCurrentItem( lb->groupEvent3 ); + onNewGroup4->setCurrentItem( lb->groupEvent4 ); +} + +void ConfigDialog::accept() +{ + KConfig* config = kapp->config(); + config->setGroup("FileFormat"); + config->writeEntry("Data0", combo1->currentItem() ); + config->writeEntry("Data1", combo2->currentItem() ); + config->writeEntry("Data2", combo3->currentItem() ); + + sqlwidget->save(); + + labelprinterdata* lpdata = PrinterSettings::getInstance()->getData(); + lpdata->comment = comment->text(); + lpdata->separator = separator->text(); + lpdata->quote = quote->text(); + lpdata->format = pageFormat->currentItem(); + + lpdata->articleEvent1 = onNewArticle1->currentItem(); + lpdata->articleEvent2 = onNewArticle2->currentItem(); + lpdata->articleEvent3 = onNewArticle3->currentItem(); + lpdata->articleEvent4 = onNewArticle4->currentItem(); + + lpdata->groupEvent1 = onNewGroup1->currentItem(); + lpdata->groupEvent2 = onNewGroup2->currentItem(); + lpdata->groupEvent3 = onNewGroup3->currentItem(); + lpdata->groupEvent4 = onNewGroup4->currentItem(); + lpdata->useCustomNo = checkUseCustomNo->isChecked(); + + switch( printerQuality->currentItem() ) { + case 0: + lpdata->quality = PrinterSettings::Middle; + break; + case 1: + lpdata->quality = PrinterSettings::High; + break; + case 2: + lpdata->quality = PrinterSettings::VeryHigh; + break; + default: + break; + } + + QDialog::accept(); +} + +void ConfigDialog::updateDatePreview() +{ + labelDate->setText( i18n("Preview: ") + QDateTime::currentDateTime().toString( date->text() ) ); +} + +#include "configdialog.moc" diff --git a/kbarcode/configdialog.h b/kbarcode/configdialog.h new file mode 100644 index 0000000..5838f78 --- /dev/null +++ b/kbarcode/configdialog.h @@ -0,0 +1,95 @@ +/*************************************************************************** + configdialog.h - description + ------------------- + begin : Fre Apr 26 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef CONFIGDIALOG_H +#define CONFIGDIALOG_H + +#include <kdialogbase.h> + +struct labelprinterdata; +struct mysqldata; +class KComboBox; +class KColorButton; +class KIntNumInput; +class KDoubleNumInput; +class KLineEdit; +class KPushButton; +class QRadioButton; +class QCheckBox; +class QLabel; +class QString; +class QWidget; +class SqlWidget; +/** KBarcodes configuration dialog for advanced settings. + */ + +class ConfigDialog : public KDialogBase { + Q_OBJECT + public: + ConfigDialog( QWidget* parent ); + ~ConfigDialog(); + + KLineEdit* comment; + KLineEdit* separator; + KLineEdit* quote; + KLineEdit* date; + + KIntNumInput* spinGrid; + + KComboBox* printerQuality; + KComboBox* pageFormat; + + QLabel* labelDate; + + QCheckBox* checkNewDlg; + QCheckBox* checkUseCustomNo; + + KComboBox* combo1; + KComboBox* combo2; + KComboBox* combo3; + + KComboBox* onNewArticle1; + KComboBox* onNewArticle2; + KComboBox* onNewArticle3; + KComboBox* onNewArticle4; + + KComboBox* onNewGroup1; + KComboBox* onNewGroup2; + KComboBox* onNewGroup3; + KComboBox* onNewGroup4; + + KColorButton* colorGrid; + + private: + void accept(); + + void setupTab1(); + void setupTab2(); + void setupTab3(); + void setupTab4(); + void setupTab5(); + + private slots: + void updateDatePreview(); + + protected: + KComboBox* comboDataMatrix; + + SqlWidget* sqlwidget; +}; + +#endif diff --git a/kbarcode/confwizard.cpp b/kbarcode/confwizard.cpp new file mode 100644 index 0000000..7809c6c --- /dev/null +++ b/kbarcode/confwizard.cpp @@ -0,0 +1,255 @@ +/*************************************************************************** + confwizard.cpp - description + ------------------- + begin : Son Jun 16 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "confwizard.h" +#include "sqltables.h" +#include "printersettings.h" +#include "dsmainwindow.h" + +// Qt includes +#include <qbuttongroup.h> +#include <qcheckbox.h> +#include <qcursor.h> +#include <qlayout.h> +#include <qsqldatabase.h> +#include <qradiobutton.h> +#include <qprinter.h> +#include <qtextbrowser.h> + +// KDE includes +#include <kapplication.h> +#include <kcombobox.h> +#include <klineedit.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kpushbutton.h> +#include <kurllabel.h> +#include <kstandarddirs.h> + + +const char* description = I18N_NOOP( + "KBarcode is a barcode and label printing application for KDE 3. It can " + "be used to print every thing from simple business cards up to complex " + "labels with several barcodes (e.g. article descriptions). KBarcode " + "comes with an easy to use WYSIWYG label designer, a setup wizard, " + "batch import of labels (directly from the delivery note), thousands " + "of predefined labels, database management tools and translations " + "in many languages. Even printing more than 10.000 labels in one go is " + "no problem for KBarcode. Additionally it is a simply xbarcode " + "replacement for the creation of barcodes. All major types of barcodes " + "like EAN, UPC, CODE39 and ISBN are supported." ); + +ConfWizard::ConfWizard( QWidget* parent, const char* name, bool modal ) + : KWizard( parent, name, modal ) +{ + setCaption( i18n( "Configure KBarcode" ) ); + + setupPage1(); + setupPage0(); + setupPage2(); + setupPage3(); + + setNextEnabled( page_2, false ); + helpButton()->hide(); + + connect( buttonCreate, SIGNAL( clicked() ), this, SLOT( create() ) ); + connect( buttonExample, SIGNAL( clicked() ), this, SLOT( example() ) ); + connect( checkDatabase, SIGNAL( clicked() ), this, SLOT( useDatabase() ) ); +} + +ConfWizard::~ConfWizard() +{ } + +void ConfWizard::accept() +{ + sqlwidget->save( checkDatabase->isChecked() ); + + KWizard::accept(); +} + +void ConfWizard::setupPage1() +{ + page = new QWidget( this, "page" ); + pageLayout = new QVBoxLayout( page, 11, 6, "pageLayout"); + + Layout8 = new QHBoxLayout( 0, 0, 6, "Layout8"); + + Layout7 = new QVBoxLayout( 0, 0, 6, "Layout7"); + + logo = new QLabel( page, "logo" ); + logo->setPixmap( locate("data", "kbarcode/logo.png") ); + QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); + pageLayout->addWidget( logo ); + Layout7->addItem( spacer ); + Layout8->addLayout( Layout7 ); + + TextLabel2_2 = new QLabel( page, "TextLabel2_2" ); + TextLabel2_2->setText( i18n( "<qt><h1>Welcome to KBarcode</h1><br><br>") + + i18n( description ) + "</qt>" ); + Layout8->addWidget( TextLabel2_2 ); + + pageLayout->addLayout( Layout8 ); + + KURLLabel1 = new KURLLabel( page, "KURLLabel1" ); + KURLLabel1->setText( "http://www.kbarcode.net" ); + KURLLabel1->setURL("http://www.kbarcode.net"); + pageLayout->addWidget( KURLLabel1 ); + addPage( page, i18n( "Welcome" ) ); +} + +void ConfWizard::setupPage0() +{ + QWidget* page_0 = new QWidget( this, "page_0" ); + QVBoxLayout* pageLayout = new QVBoxLayout( page_0, 11, 6, "pageLayout"); + + QTextBrowser* b = new QTextBrowser( page_0, "b" ); + b->setText( DSMainWindow::systemCheck() ); + + pageLayout->addWidget( b ); + + addPage( page_0, i18n("System Check") ); +} + +void ConfWizard::setupPage2() +{ + page_2 = new QWidget( this, "page_2" ); + pageLayout_2 = new QVBoxLayout( page_2, 11, 6, "pageLayout_2"); + + checkDatabase = new QCheckBox( page_2 ); + checkDatabase->setText( i18n("&Use database with KBarcode") ); + checkDatabase->setChecked( true ); + + sqlwidget = new SqlWidget( true, page_2, "sqlwidget" ); + connect( sqlwidget, SIGNAL( databaseWorking( bool ) ), this, SLOT( testSettings( bool ) ) ); + + QSpacerItem* spacer_5 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); + pageLayout_2->addWidget( checkDatabase ); + pageLayout_2->addWidget( sqlwidget ); + pageLayout_2->addItem( spacer_5 ); + + addPage( page_2, i18n( "Database" ) ); +} + +void ConfWizard::setupPage3() +{ + page_3 = new QWidget( this, "page_3" ); + pageLayout_3 = new QVBoxLayout( page_3, 11, 6, "pageLayout_3"); + + TextLabel1_2 = new QLabel( page_3, "TextLabel1_2" ); + TextLabel1_2->setText( i18n( "KBarcode can create the required SQL tables for you.<br>KBarcode will add also some Label Definitions to the tables.<br>After that you can fill the tables with some example data." ) ); + TextLabel1_2->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) ); + pageLayout_3->addWidget( TextLabel1_2 ); + + Layout5_2 = new QVBoxLayout( 0, 0, 6, "Layout5_2"); + + buttonCreate = new KPushButton( page_3, "buttonCreate" ); + buttonCreate->setText( i18n( "&Create Tables" ) ); + Layout5_2->addWidget( buttonCreate ); + + buttonExample = new KPushButton( page_3, "buttonExample" ); + buttonExample->setEnabled( FALSE ); + buttonExample->setText( i18n( "&Add Example Data" ) ); + Layout5_2->addWidget( buttonExample ); + QSpacerItem* spacer_6 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout5_2->addItem( spacer_6 ); + pageLayout_3->addLayout( Layout5_2 ); + addPage( page_3, i18n( "Create Tables" ) ); +} + +void ConfWizard::testSettings( bool b ) +{ + setNextEnabled( page_2, b ); +} + +void ConfWizard::create() +{ + KApplication::setOverrideCursor( Qt::WaitCursor ); + if(!SqlTables::getInstance()->newTables( sqlwidget->username(), sqlwidget->password(), sqlwidget->hostname(), sqlwidget->database(), sqlwidget->driver() ) ) + { + KApplication::restoreOverrideCursor(); + return; + } + else + KApplication::restoreOverrideCursor(); + + QSqlDatabase* db = QSqlDatabase::addDatabase( sqlwidget->driver() ); + db->setDatabaseName( sqlwidget->database() ); + db->setUserName( sqlwidget->username() ); + db->setPassword( sqlwidget->password() ); + db->setHostName( sqlwidget->hostname() ); + + if( !db->open() ) + KMessageBox::error( this, i18n("<qt>Connection failed:<br>") + sqlwidget->database(), + db->lastError().databaseText() + "</qt>" ); + + if( db->open() ) { + KApplication::setOverrideCursor( Qt::WaitCursor ); + SqlTables::getInstance()->importData( + locate("appdata", "labeldefinitions.sql"), db ); + buttonExample->setEnabled( true ); + KApplication::restoreOverrideCursor(); + } + + db->close(); +} + +void ConfWizard::example() +{ + QSqlDatabase* db = QSqlDatabase::addDatabase( sqlwidget->driver() ); + db->setDatabaseName( sqlwidget->database() ); + db->setUserName( sqlwidget->username() ); + db->setPassword( sqlwidget->password() ); + db->setHostName( sqlwidget->hostname() ); + + if( !db->open() ) + KMessageBox::error( this, i18n("<qt>Connection failed:<br>") + sqlwidget->database(), + db->lastError().databaseText() + "</qt>" ); + + + SqlTables::getInstance()->importData( + locate("appdata", "exampledata.sql"), db ); + KMessageBox::information( this, i18n("Example data has been imported.") ); + + db->close(); +} + +void ConfWizard::showPage( QWidget* page ) +{ + QWizard::showPage(page); + + if( page == page_2 && !sqlwidget->driverCount() ) { + KMessageBox::information( this, i18n( + "There are no Qt SQL drivers installed. " + "KBarcode needs those drivers to access the different SQL databases. " + "This drivers are part of the Qt Source distribution and should also be part of " + "your distribution. Please install them first.") ); + } + + if ( page == page_3 ) + finishButton()->setEnabled( true ); +} + +void ConfWizard::useDatabase() +{ + setFinishEnabled( page_2, !checkDatabase->isChecked() ); + setNextEnabled( page_2, false ); + setFinishEnabled( page_3, checkDatabase->isChecked() ); + sqlwidget->setEnabled( checkDatabase->isChecked() ); +} + + +#include "confwizard.moc" diff --git a/kbarcode/confwizard.h b/kbarcode/confwizard.h new file mode 100644 index 0000000..c1bfc20 --- /dev/null +++ b/kbarcode/confwizard.h @@ -0,0 +1,101 @@ +/*************************************************************************** + confwizard.h - description + ------------------- + begin : Son Jun 16 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef CONFWIZARD_H +#define CONFWIZARD_H + +#include <kwizard.h> + +class QButtonGroup; +class QCheckBox; +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QRadioButton; +class KComboBox; +class KLineEdit; +class KPushButton; +class KURLLabel; +class QLabel; +class QWidget; +class SqlWidget; +/** KBarcodes configuration wizard. + */ +class ConfWizard : public KWizard +{ + Q_OBJECT + + public: + ConfWizard( QWidget* parent = 0, const char* name = 0, bool modal = true ); + ~ConfWizard(); + + void showPage( QWidget* page ); + + // used in dsmainwindow.cpp + // not a clean API, but I am lazy :-( + QCheckBox* checkDatabase; + + private slots: + void testSettings( bool b ); + void create(); + void example(); + void useDatabase(); + + protected slots: + void accept(); + + private: + void setupPage1(); + void setupPage0(); + void setupPage2(); + void setupPage3(); + + SqlWidget* sqlwidget; + + QWidget* page; + QLabel* logo; + QLabel* TextLabel2_2; + KURLLabel* KURLLabel1; + QWidget* page_2; + QLabel* TextLabel1; + QLabel* TextLabel2; + QLabel* TextLabel3; + QLabel* TextLabel4; + QLabel* TextLabel5; + QLabel* TextLabel6; + KPushButton* buttonTest; + QWidget* page_3; + QLabel* TextLabel1_2; + KPushButton* buttonCreate; + KPushButton* buttonExample; + QButtonGroup* groupDatabase; + + protected: + QVBoxLayout* pageLayout; + QHBoxLayout* Layout8; + QVBoxLayout* Layout7; + QVBoxLayout* pageLayout_2; + QVBoxLayout* pageLayout_4; + QHBoxLayout* Layout5; + QVBoxLayout* Layout3; + QVBoxLayout* Layout4; + QVBoxLayout* Layout6; + QVBoxLayout* pageLayout_3; + QVBoxLayout* Layout5_2; +}; + +#endif // CONFWIZARD_H diff --git a/kbarcode/csvfile.cpp b/kbarcode/csvfile.cpp new file mode 100644 index 0000000..f8cc81f --- /dev/null +++ b/kbarcode/csvfile.cpp @@ -0,0 +1,168 @@ +/*************************************************************************** + csvfile.h - description + ------------------- + begin : Mon Mar 28 2005 + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "csvfile.h" + +#include "printersettings.h" + +#include <qbuffer.h> +#include <qtextcodec.h> + +CSVFile::CSVFile( const QString & filename ) +{ + m_eof = false; + m_csv = true; + + m_quote = PrinterSettings::getInstance()->getData()->quote; + m_separator = PrinterSettings::getInstance()->getData()->separator; + m_comment = PrinterSettings::getInstance()->getData()->comment; + + m_file.setName( filename ); + m_file.open( IO_ReadOnly ); + + if( m_file.isOpen() ) + m_stream.setDevice( &m_file ); +} + +CSVFile::CSVFile( QBuffer & buf ) +{ + m_eof = false; + m_csv = true; + + m_quote = PrinterSettings::getInstance()->getData()->quote; + m_separator = PrinterSettings::getInstance()->getData()->separator; + m_comment = PrinterSettings::getInstance()->getData()->comment; + + buf.open( IO_ReadOnly ); + + if( buf.isOpen() ) + m_stream.setDevice( &buf ); +} + +CSVFile::~CSVFile() +{ + if( m_stream.device() && m_stream.device()->isOpen() ) + m_stream.device()->close(); +} + +QStringList CSVFile::readNextLine() +{ + QString line; + + if( !m_stream.device() ) + return QStringList(); + + if( !m_stream.device()->isOpen() ) + return QStringList(); + + // walk through the lines until a line containing valid data + for( ;; ) + { + line = m_stream.readLine(); + line = line.stripWhiteSpace(); + + // check for eof + if( line.isNull() ) + { + m_eof = true; + return QStringList(); + } + + // ignore comments and empty lines + if( (!m_comment.isEmpty() && line.startsWith( m_comment )) || line.isEmpty() ) + continue; + + break; + } + + return m_csv ? readCsvLine( line ) : readFixedLine( line ); +} + +QStringList CSVFile::readCsvLine( const QString & l ) +{ + QString line( l ); + QStringList sections; + unsigned int start = 0; + unsigned int end = 0; + unsigned int len; + bool quoted = false; + bool quote_empty; + + // if line does not end with separator, add one + if( !line.endsWith( m_separator ) ) + line.append( m_separator ); + + // we have to handle here the case, + // that the separator is included + // in a quoted field + len = line.length(); // cache for better speed + quote_empty = m_quote.isEmpty(); + while( end < len ) + { + if( !quote_empty && line.right( len - end ).startsWith( m_quote ) ) + quoted = !quoted; + else if( !quoted && line.right( len - end ).startsWith( m_separator ) ) + { + sections << removeQuote( line.mid( start, end-start ) ); + + start = end; + ++start; + } + else if( line[end] == '\n' ) + break; + + ++end; + } + + return sections; +} + +QStringList CSVFile::readFixedLine( const QString & line ) +{ + QString data( line ); + QStringList list; + + for( unsigned int i=0;i<m_width.count();i++ ) + { + list << data.left( m_width[i] ); + data = data.right( data.length() - m_width[i] ); + } + + return list; +} + +QString CSVFile::removeQuote( const QString & text ) +{ + QString line = text.stripWhiteSpace(); + + if( m_quote.isEmpty() ) + return text; + + if( line.startsWith( m_quote ) ) + line = line.right( line.length() - m_quote.length() ); + + if( line.endsWith( m_quote ) ) + line = line.left( line.length() - m_quote.length() ); + + return line; +} + +void CSVFile::setEncoding( const QString & enc ) +{ + m_stream.setCodec( QTextCodec::codecForName( enc.latin1() ) ); +} + diff --git a/kbarcode/csvfile.h b/kbarcode/csvfile.h new file mode 100644 index 0000000..8049d58 --- /dev/null +++ b/kbarcode/csvfile.h @@ -0,0 +1,151 @@ +/*************************************************************************** + csvfile.h - description + ------------------- + begin : Mon Mar 28 2005 + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef CSVFILE_H +#define CSVFILE_H + +#include <qfile.h> +#include <qstringlist.h> +#include <qtextstream.h> + +class QBuffer; + +/** This class makes it very easy to parse a comma separated value file + */ +class CSVFile { + public: + CSVFile( const QString & filename ); + CSVFile( QBuffer & buf ); + ~CSVFile(); + + /** reads the next line from the CSV file and returns + * the line split into sections. Comments are ignored by this + * line. + */ + QStringList readNextLine(); + + /** returns true when the CSVFile object is valid. + * returns false incase of an error + */ + inline bool isValid() const; + + /** returns true when the end of file was reached + */ + inline bool isEof() const; + + /** set the encoding to use for the data + */ + void setEncoding( const QString & enc ); + + /** set the separator to use for the data + */ + inline void setSeparator( const QString & sep ); + + /** set the quoting character + */ + inline void setQuote( const QString & quote ); + + /** set the comment character + */ + inline void setComment( const QString & comment ); + + /** set the field widths for fixed field width files + */ + inline void setFieldWidth( const QValueList<int> & width ); + + /** sets wether this is a CSV file or + * a file with fixed field width. + * \param b if true this is a CSV file (default) + */ + inline void setCSVFile( bool b ); + + /** + * \returns true if this is a CSV file + */ + inline bool isCSVFile() const; + + private: + /** removes quoting characters as defined in lpdata from the + * string @p text + */ + QString removeQuote( const QString & text ); + + QStringList readCsvLine( const QString & line ); + + QStringList readFixedLine( const QString & line ); + + private: + /** the filehandle which is used to access the file + */ + QFile m_file; + QTextStream m_stream; + + QString m_quote; + QString m_separator; + QString m_comment; + + QValueList<int> m_width; + + bool m_csv; + bool m_eof; +}; + +bool CSVFile::isValid() const +{ + if( !m_stream.device() ) + return false; + + return m_stream.device()->isOpen(); +} + +bool CSVFile::isEof() const +{ + return m_eof; +} + +void CSVFile::setCSVFile( bool b ) +{ + m_csv = b; +} + +bool CSVFile::isCSVFile() const +{ + return m_csv; +} + +void CSVFile::setSeparator( const QString & sep ) +{ + m_separator = sep; +} + +void CSVFile::setQuote( const QString & quote ) +{ + m_quote = quote; +} + +void CSVFile::setComment( const QString & comment ) +{ + m_comment = comment; +} + +void CSVFile::setFieldWidth( const QValueList<int> & width ) +{ + m_width = width; +} + + +#endif // CSVFILE_H diff --git a/kbarcode/csvimportdlg.cpp b/kbarcode/csvimportdlg.cpp new file mode 100644 index 0000000..3da1899 --- /dev/null +++ b/kbarcode/csvimportdlg.cpp @@ -0,0 +1,430 @@ +/*************************************************************************** + csvimportdlg.cpp - description + ------------------- + begin : Don Aug 21 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "csvimportdlg.h" +#include "printersettings.h" +#include "sqltables.h" +#include "encodingcombo.h" + +// Qt includes +#include <qcheckbox.h> +#include <qcursor.h> +#include <qfile.h> +#include <qframe.h> +#include <qgroupbox.h> +#include <qhbuttongroup.h> +#include <qheader.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qlistbox.h> +#include <qprogressdialog.h> +#include <qsqlquery.h> +#include <qtable.h> +#include <qradiobutton.h> +#include <qtextstream.h> +#include <qvbox.h> + +// KDE includes +#include <kapplication.h> +#include <kcombobox.h> +#include <klineedit.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <knuminput.h> +#include <kpushbutton.h> +#include <kurlrequester.h> +#include "csvfile.h" + +// import from labelprinter.cpp +extern QString removeQuote( QString text, QString quote ); + +const char* NOFIELD = "<NONE>"; + +CSVImportDlg::CSVImportDlg(QWidget *parent, const char *name ) + : KDialogBase( KDialogBase::Tabbed, i18n("Import"), + KDialogBase::Ok | KDialogBase::Close, KDialogBase::Ok, parent,name,false,true) +{ + setButtonOKText( i18n("&Import"), i18n("Import the selected file into your tables.") ); + + createPage1(); + createPage2(); + + connect( requester, SIGNAL( textChanged( const QString & ) ), this, SLOT( settingsChanged() ) ); + connect( buttonSet, SIGNAL( clicked() ), this, SLOT( setCol() ) ); + connect( comboSQL, SIGNAL( activated( int ) ), this, SLOT( updateFields() ) ); + connect( databaseName, SIGNAL( textChanged( const QString & ) ), this, SLOT( updateFields() ) ); + connect( comboEncoding, SIGNAL( activated( int ) ), this, SLOT( settingsChanged() ) ); + connect( table->horizontalHeader(), SIGNAL( clicked( int ) ), this, SLOT( updateCol( int ) ) ); + connect( radioCSVFile, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioFixedFile, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( buttonAdd, SIGNAL( clicked() ), this, SLOT( addWidth() ) ); + connect( buttonRemove,SIGNAL( clicked() ), this, SLOT( removeWidth() ) ); + connect( comment, SIGNAL( textChanged( const QString & ) ), this, SLOT( settingsChanged() ) ); + connect( quote, SIGNAL( textChanged( const QString & ) ), this, SLOT( settingsChanged() ) ); + connect( separator, SIGNAL( textChanged( const QString & ) ), this, SLOT( settingsChanged() ) ); + connect( checkLoadAll, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + + updateFields(); + enableControls(); + + show(); +} + +CSVImportDlg::~CSVImportDlg() +{ +} + +void CSVImportDlg::createPage1() +{ + QFrame* box = addPage( i18n("&Import Data") ); + QVBoxLayout* layout = new QVBoxLayout( box, 6, 6 ); + QGridLayout* grid = new QGridLayout( 2 ); + + requester = new KURLRequester( box ); + comboEncoding = new EncodingCombo( box ); + comboSQL = new KComboBox( false, box ); + comboSQL->insertItem( TABLE_BASIC ); + comboSQL->insertItem( TABLE_CUSTOMER ); + comboSQL->insertItem( TABLE_CUSTOMER_TEXT ); + comboSQL->insertItem( TABLE_LABEL_DEF ); + comboSQL->insertItem( i18n("Other table...") ); + + databaseName = new KLineEdit( box ); + checkLoadAll = new QCheckBox( i18n("&Load complete file into preview"), box ); + spinLoadOnly = new KIntNumInput( box ); + spinLoadOnly->setLabel( i18n("Load only a number of datasets:"), AlignLeft | AlignVCenter ); + spinLoadOnly->setRange( 0, 10000, 1, false ); + checkLoadAll->setChecked( true ); + + table = new QTable( box ); + table->setReadOnly( true ); + + frame = new QFrame( box ); + QHBoxLayout* layout2 = new QHBoxLayout( frame, 6, 6 ); + + spinCol = new KIntNumInput( frame ); + spinCol->setLabel( i18n("Column:"), AlignLeft | AlignVCenter ); + spinCol->setRange( 0, 0, 0, false ); + + comboField = new KComboBox( false, frame ); + buttonSet = new KPushButton( i18n("Set"), frame ); + + layout2->addWidget( spinCol ); + layout2->addWidget( new QLabel( i18n("Database field to use for this column:"), frame ) ); + layout2->addWidget( comboField ); + layout2->addWidget( buttonSet ); + + grid->addWidget( new QLabel( i18n("File to import:"), box ), 0, 0 ); + grid->addWidget( requester, 0, 1 ); + grid->addWidget( new QLabel( i18n("Encoding:"), box ), 1, 0 ); + grid->addWidget( comboEncoding, 1, 1 ); + grid->addWidget( new QLabel( i18n("Import into table:"), box ), 2, 0 ); + grid->addWidget( comboSQL, 2, 1 ); + grid->addWidget( new QLabel( i18n("Table Name:"), box ), 3, 0 ); + grid->addWidget( databaseName, 3, 1 ); + grid->addWidget( checkLoadAll, 4, 0 ); + grid->addWidget( spinLoadOnly, 4, 1 ); + + layout->addLayout( grid ); + layout->addWidget( table ); + layout->setStretchFactor( table, 2 ); + layout->addWidget( frame ); +} + +void CSVImportDlg::createPage2() +{ + labelprinterdata* lb = PrinterSettings::getInstance()->getData(); + QFrame* mainBox = addPage( i18n("&Import Settings") ); + QVBoxLayout* layout = new QVBoxLayout( mainBox, 6, 6 ); + QSpacerItem* spacer1 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + + QHButtonGroup* buttonGroup = new QHButtonGroup( i18n("File Format:"), mainBox ); + radioCSVFile = new QRadioButton( i18n("&CSV File"), buttonGroup ); + radioFixedFile = new QRadioButton( i18n("File with &fixed field width"), buttonGroup ); + + QHBox* hboxFrame = new QHBox( mainBox ); + + groupCSV = new QGroupBox( i18n("CSV File"), hboxFrame ); + groupFixed = new QGroupBox( i18n("Fixed Field Width File"), hboxFrame ); + + groupCSV->setColumnLayout(0, Qt::Vertical ); + groupCSV->layout()->setSpacing( 6 ); + groupCSV->layout()->setMargin( 11 ); + + QVBoxLayout* vbox = new QVBoxLayout( groupCSV->layout() ); + QGridLayout* grid = new QGridLayout( 2, 2 ); + grid->setSpacing( 6 ); + grid->setMargin( 11 ); + + QLabel* label = new QLabel( groupCSV ); + label->setText( i18n("Comment:") ); + grid->addWidget( label, 0, 0 ); + + comment = new KLineEdit( lb->comment, groupCSV ); + grid->addWidget( comment, 0, 1 ); + + label = new QLabel( groupCSV ); + label->setText( i18n( "Separator:" ) ); + grid->addWidget( label, 1, 0 ); + + separator = new KLineEdit( lb->separator, groupCSV ); + grid->addWidget( separator, 1, 1 ); + + label = new QLabel( groupCSV ); + label->setText( i18n("Quote Character:") ); + grid->addWidget( label, 2, 0 ); + + quote = new KLineEdit( lb->quote, groupCSV ); + grid->addWidget( quote, 2, 1 ); + + vbox->addLayout( grid ); + vbox->addItem( spacer1 ); + + groupFixed->setColumnLayout(0, Qt::Horizontal ); + groupFixed->layout()->setSpacing( 6 ); + groupFixed->layout()->setMargin( 11 ); + QHBoxLayout* groupFixedLayout = new QHBoxLayout( groupFixed->layout() ); + groupFixedLayout->setAlignment( Qt::AlignTop ); + + listWidth = new KListBox( groupFixed ); + + buttonAdd = new KPushButton( groupFixed ); + buttonAdd->setText( i18n( "&Add Field" ) ); + + buttonRemove = new KPushButton( groupFixed ); + buttonRemove->setText( i18n( "&Remove Field" ) ); + + spinNumber = new KIntNumInput( groupFixed ); + spinNumber->setMinValue( 0 ); + spinNumber->setValue( 1 ); + spinNumber->setFocus(); + + QVBoxLayout* layout2 = new QVBoxLayout( 0, 6, 6 ); + layout2->addWidget( buttonAdd ); + layout2->addWidget( buttonRemove ); + layout2->addWidget( spinNumber ); + layout2->addItem( spacer2 ); + + groupFixedLayout->addWidget( listWidth ); + groupFixedLayout->addLayout( layout2 ); + + layout->addWidget( buttonGroup ); + layout->addWidget( hboxFrame ); + + radioCSVFile->setChecked( true ); +} + +void CSVImportDlg::settingsChanged() +{ + CSVFile file( requester->url() ); + QStringList list; + + int i = 0; + unsigned int z; + + initCsvFile( &file ); + + table->setNumCols( 0 ); + table->setNumRows( 0 ); + + if( !file.isValid() ) + return; + + while( !file.isEof() ) + { + list = file.readNextLine(); + + if( table->numCols() < (int)list.count() ) + table->setNumCols( list.count() ); + + if( table->numRows() <= i ) + // add 100 rows to get a reasonable speed + table->setNumRows( i + 100 ); + + for( z = 0; z < list.count(); z++ ) + table->setText( i, z, list[z] ); + + if( !checkLoadAll->isChecked() && i > spinLoadOnly->value() ) + break; + + i++; + } + + table->setNumRows( i ); + spinCol->setRange( 1, table->numCols(), 1, false ); + + enableControls(); +} + +void CSVImportDlg::setCol() +{ + QString text = comboField->currentText(); + int v = spinCol->value() - 1; + if( text == NOFIELD ) + table->horizontalHeader()->setLabel( v, QString::number( v + 1 ) ); + else { + for( int i = 0; i < table->horizontalHeader()->count(); i++ ) + if( table->horizontalHeader()->label( i ) == text ) + table->horizontalHeader()->setLabel( i, QString::number( i + 1 ) ); + + table->horizontalHeader()->setLabel( v, text ); + } +} + +QString CSVImportDlg::getDatabaseName() +{ + bool b = comboSQL->currentItem() == (comboSQL->count()-1); + + databaseName->setEnabled( b ); + return b ? databaseName->text() : comboSQL->currentText(); +} + +void CSVImportDlg::updateFields() +{ + // also enables databaseName if necessary + QString name = getDatabaseName(); + + comboField->clear(); + comboField->insertItem( NOFIELD ); + QSqlQuery query( SqlTables::getInstance()->driver()->showColumns( name ) ); + while( query.next() ) + comboField->insertItem( query.value( 0 ).toString() ); + + for( int i = 0; i < table->horizontalHeader()->count(); i++ ) + table->horizontalHeader()->setLabel( i, QString::number( i + 1 ) ); +} + +void CSVImportDlg::enableControls() +{ + bool b = table->numRows() && table->numCols(); + + groupCSV->setEnabled( radioCSVFile->isChecked() ); + groupFixed->setEnabled( radioFixedFile->isChecked() ); + + spinLoadOnly->setEnabled( !checkLoadAll->isChecked() ); + + enableButtonOK( b ); + frame->setEnabled( b ); +} + +void CSVImportDlg::updateCol( int c ) +{ + spinCol->setValue( ++c ); +} + +void CSVImportDlg::accept() +{ + CSVFile file( requester->url() ); + QHeader* h = table->horizontalHeader(); + QValueList<int> headers; + QStringList list; + QString name = getDatabaseName(); + int i = 0; + + QString q = "INSERT INTO " + name + " ("; + for( int c = 0; c < table->horizontalHeader()->count(); c++ ) { + bool ok = true; + h->label( c ).toInt( &ok ); + if( !ok ) { + q = q + table->horizontalHeader()->label( c ) + ","; + headers << c; + } + } + + // remove last "," + if( q.right( 1 ) == "," ) + q = q.left( q.length() - 1 ); + + q = q + ") VALUES ("; + + initCsvFile( &file ); + if( !file.isValid() ) + KMessageBox::error( this, i18n("Cannot load data from the file:") + requester->url() ); + + + + KApplication::setOverrideCursor( QCursor( Qt::WaitCursor) ); + while( !file.isEof() ) + { + list = file.readNextLine(); + + QString line = q; + for( unsigned int c = 0; c < headers.count(); c++ ) + line.append( "'" + list[ headers[c] ] + "'" + "," ); + + // remove last "," + if( line.right( 1 ) == "," ) + line = line.left( line.length() - 1 ); + + line = line + ");"; + + QSqlQuery query; + if( !query.exec( line ) ) + qDebug( i18n("Could not import the following line:") + line ); + //KMessageBox::error( this, i18n("Could not import the following line:") + line ); + } + + KApplication::restoreOverrideCursor(); + KMessageBox::information( this, i18n("Data was imported successfully.") ); + KDialogBase::accept(); +} + +void CSVImportDlg::addWidth() +{ + listWidth->insertItem( QString("%1").arg(spinNumber->value()), -1 ); + settingsChanged(); +} + +void CSVImportDlg::removeWidth() +{ + unsigned int i = 0; + do { + if(listWidth->isSelected( i )) { + listWidth->removeItem( i ); + listWidth->setSelected( i-1, true ); + return; + } else + i++; + } while( i < listWidth->count() ); + settingsChanged(); +} + +QValueList<int> CSVImportDlg::getFieldWidth() +{ + QValueList<int> list; + + for( unsigned int i=0;i<listWidth->count();i++ ) + list << listWidth->text( i ).toInt(); + + return list; +} + +void CSVImportDlg::initCsvFile( CSVFile* file ) +{ + QValueList<int> width = getFieldWidth(); + + file->setEncoding( comboEncoding->currentText() ); + file->setCSVFile( radioCSVFile->isChecked() ); + file->setComment( comment->text() ); + file->setSeparator( separator->text() ); + file->setQuote( quote->text() ); + file->setFieldWidth( width ); +} + + +#include "csvimportdlg.moc" diff --git a/kbarcode/csvimportdlg.h b/kbarcode/csvimportdlg.h new file mode 100644 index 0000000..b586880 --- /dev/null +++ b/kbarcode/csvimportdlg.h @@ -0,0 +1,127 @@ +/*************************************************************************** + csvimportdlg.h - description + ------------------- + begin : Don Aug 21 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef CSVIMPORTDLG_H +#define CSVIMPORTDLG_H + +#include <qwidget.h> +#include <kdialogbase.h> + +class CSVFile; +class EncodingCombo; +class KComboBox; +class KIntNumInput; +class KLineEdit; +class KPushButton; +class KURLRequester; +class QCheckBox; +class QFrame; +class QGroupBox; +class QTable; +class QRadioButton; + +/** Import a CSV (comma separated value) file into + * a SQL table. CSV files can be generated by almost + * any spreadsheet application. + * This dialog is also available as a separate application + * KESI ( http://kesi.sf.net ). + * This class makes importing data in KBarcode very easy + * for the user. + * + * @author Dominik Seichter + */ +class CSVImportDlg : public KDialogBase { + Q_OBJECT + public: + CSVImportDlg(QWidget *parent=0, const char *name=0); + ~CSVImportDlg(); + + private slots: + void settingsChanged(); + void setCol(); + void updateFields(); + void updateCol( int c ); + void addWidth(); + void removeWidth(); + + void enableControls(); + + private: + /** + * Returns the current database name which can be + * user specified or internal to KBarcode. + * It also enables the correct GUI items for + * a user specified or internal database. + * + * \returns the name of the current database table. + */ + QString getDatabaseName(); + + /** Get the field with from listWidth + * as an integer list. + */ + QValueList<int> getFieldWidth(); + + /** Create the first tab of the dialog + * to set the import data. + */ + void createPage1(); + + /** Create the first tab of the dialog + * to set the import settings. + */ + void createPage2(); + + /** Initialize a CSVFile with the settings + * from the GUI. + */ + void initCsvFile( CSVFile* file ); + + private: + KComboBox* comboSQL; + KComboBox* comboField; + EncodingCombo* comboEncoding; + KIntNumInput* spinCol; + KPushButton* buttonSet; + KURLRequester* requester; + QFrame* frame; + QTable* table; + KLineEdit* databaseName; + + QRadioButton* radioCSVFile; + QRadioButton* radioFixedFile; + + KLineEdit* comment; + KLineEdit* quote; + KLineEdit* separator; + + QGroupBox* groupCSV; + QGroupBox* groupFixed; + + KListBox* listWidth; + KPushButton* buttonAdd; + KPushButton* buttonRemove; + KIntNumInput* spinNumber; + + QCheckBox* checkLoadAll; + KIntNumInput* spinLoadOnly; + + protected slots: + void accept(); +}; + +#endif diff --git a/kbarcode/databasebrowser.cpp b/kbarcode/databasebrowser.cpp new file mode 100644 index 0000000..50af772 --- /dev/null +++ b/kbarcode/databasebrowser.cpp @@ -0,0 +1,204 @@ +/*************************************************************************** + databasebrowser.cpp - description + ------------------- + begin : Mit Mai 15 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "databasebrowser.h" +#include "mydatatable.h" +#include "definition.h" +#include "sqltables.h" +#include "csvimportdlg.h" + +// Qt includes +#include <qclipboard.h> + +// KDE includes +#include <kaction.h> +#include <kapplication.h> +#include <keditcl.h> +#include <klocale.h> +#include <kmenubar.h> +#include <kpopupmenu.h> +#include <kstatusbar.h> + +#define CUR_TABLE_ID 6666 + +DatabaseBrowser::DatabaseBrowser( QString _database, QWidget *parent, const char *name ) + : DSMainWindow(parent,name) +{ + m_direction = m_case = false; + + table = new MyDataTable(this ); + setCentralWidget( table ); + + statusBar()->insertItem( i18n("Current Table: <b>" ) + _database, CUR_TABLE_ID, 0, true ); + statusBar()->setSizeGripEnabled( true ); + statusBar()->show(); + + database = _database; + + connect( table, SIGNAL( cursorChanged( QSql::Op ) ), + SqlTables::getInstance(), SIGNAL( tablesChanged() ) ); + + connect( this, SIGNAL( connectedSQL() ), this, SLOT( setupSql() ) ); + + findDlg = 0; + + setupActions(); + show(); + + setupSql(); +} + +DatabaseBrowser::~DatabaseBrowser() +{ + // update sql label definitions + // because they may have changed + // TODO: + // add selction here to only update + // if neccessary! + Definition::updateProducer(); + DSMainWindow::saveConfig(); + + if( findDlg ) + delete findDlg; +} + +void DatabaseBrowser::setupActions() +{ + DSMainWindow::setupActions(); + KPopupMenu* editMenu = new KPopupMenu( this ); + + KAction* acut = KStdAction::cut( this, SLOT( cut() ), actionCollection() ); + KAction* acopy = KStdAction::copy( this, SLOT( copy() ), actionCollection() ); + KAction* apaste = KStdAction::paste( this, SLOT( paste() ), actionCollection() ); + KAction* afind = KStdAction::find( this, SLOT( find() ), actionCollection() ); + menuBar()->insertItem( i18n("&Edit"), editMenu, -1, 1 ); + + acut->plug( editMenu ); + acopy->plug( editMenu ); + apaste->plug( editMenu ); + + editMenu->insertSeparator(); + afind->plug( editMenu ); + KStdAction::findNext( this, SLOT( findNext() ), actionCollection() )->plug( editMenu ); + editMenu->insertSeparator(); + KAction* aimport = new KAction( i18n("&Import CSV File..."), "", + 0, this, SLOT(import()), actionCollection(), "import" ); + aimport->plug( editMenu ); + + acut->plug( toolBar() ); + acopy->plug( toolBar() ); + apaste->plug( toolBar() ); + + toolBar()->insertSeparator(); + afind->plug( toolBar() ); + + DSMainWindow::loadConfig(); +} + +void DatabaseBrowser::setupSql() +{ + QSqlCursor* cur = new QSqlCursor( database, true ); + cur->select(); + unsigned int i = 0; + unsigned int c = 0; + while ( cur->next() ) { + for( c = 0; c < cur->count(); c++ ) { + table->setText( i, c, cur->value( c ).toString() ); + table->horizontalHeader()->setLabel( c, cur->fieldName( c ) ); + } + i++; + } + + table->setNumCols( c ); + table->setNumRows( i ); + + table->setSqlCursor( cur, true, true ); + table->setSorting( true ); + table->setConfirmDelete( true ); + table->setAutoEdit( true ); + table->refresh( QDataTable::RefreshAll ); +} + +void DatabaseBrowser::find() +{ + if( !findDlg ) + findDlg = new KEdFind( this, "findDlg", false ); + + findDlg->setText( m_find ); + findDlg->setDirection( m_direction ); + findDlg->setCaseSensitive( m_case ); + connect( findDlg, SIGNAL( search() ), this, SLOT( findNext() ) ); + + findDlg->exec(); + +} + +void DatabaseBrowser::findNext() +{ + if( findDlg ) { + m_find = findDlg->getText(); + m_direction = findDlg->get_direction(); + m_case = findDlg->case_sensitive(); + } else + find(); + + table->find( m_find, m_case, m_direction ); +} + +void DatabaseBrowser::cut() +{ + QString text = table->value( table->currentRow(), table->currentColumn() ).toString(); + if( !text.isEmpty() ) { + kapp->clipboard()->setText( text ); + + QSqlRecord* buffer = table->sqlCursor()->primeUpdate(); + if( buffer ) { + buffer->setValue( table->horizontalHeader()->label( table->currentColumn() ), "" ); + table->sqlCursor()->update(); + table->refresh(); + } + + } +} + +void DatabaseBrowser::copy() +{ + QString text = table->value( table->currentRow(), table->currentColumn() ).toString(); + if( !text.isEmpty() ) + kapp->clipboard()->setText( text ); +} + +void DatabaseBrowser::paste() +{ + QString text = kapp->clipboard()->text(); + if( !text.isEmpty() ) { + QSqlRecord* buffer = table->sqlCursor()->primeUpdate(); + if( buffer ) { + buffer->setValue( table->horizontalHeader()->label( table->currentColumn() ), text ); + table->sqlCursor()->update(); + table->refresh(); + } + } + +} + +void DatabaseBrowser::import() +{ + new CSVImportDlg( this ); +} + +#include "databasebrowser.moc" diff --git a/kbarcode/databasebrowser.h b/kbarcode/databasebrowser.h new file mode 100644 index 0000000..1968f88 --- /dev/null +++ b/kbarcode/databasebrowser.h @@ -0,0 +1,69 @@ +/*************************************************************************** + databasebrowser.h - description + ------------------- + begin : Mit Mai 15 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DATABASEBROWSER_H +#define DATABASEBROWSER_H + +#include "dsmainwindow.h" + +class KAction; +class KEdFind; +class KMenuBar; +class KToolBar; +class KPushButton; +class KPopupMenu; +class MyDataTable; +/** A database browser widget. Allows small changes to SQL tables + * and is mostly used for having a quick look on the tables. + */ +class DatabaseBrowser : public DSMainWindow{ + Q_OBJECT + public: + DatabaseBrowser( QString _database, QWidget *parent=0, const char *name=0); + ~DatabaseBrowser(); + + private: + void setupActions(); + + private slots: + void setupSql(); + + void cut(); + void copy(); + void paste(); + + void find(); + void findNext(); + + void import(); + + protected: + QString database; + MyDataTable* table; + + KAction* undoAct; + KAction* deleteAct; + KAction* newAct; + + KEdFind* findDlg; + + QString m_find; + bool m_direction; + bool m_case; +}; + +#endif diff --git a/kbarcode/definition.cpp b/kbarcode/definition.cpp new file mode 100644 index 0000000..675a36d --- /dev/null +++ b/kbarcode/definition.cpp @@ -0,0 +1,579 @@ +/*************************************************************************** + definition.cpp - description + ------------------- + begin : Mit Nov 20 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "definition.h" +#include "sqltables.h" + +// Qt includes +#include <qtextstream.h> +#include <qsqlquery.h> +#include <qregexp.h> + +// KDE includes +#include <kapplication.h> +#include <kfiledialog.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kstandarddirs.h> +#include <qprogressdialog.h> + +// a simple helper function +// that copies a file +bool filecopy( const char* src, const char* dest ) +{ + FILE* s; + FILE* d; + int c; + + d = fopen(dest, "w"); + if( d == NULL ) + return false; + + s = fopen(src, "r"); + if( s == NULL ) { + fclose( d ); + remove( dest ); + return false; + } + + while(( c = getc( s )) != EOF ) + putc( c, d ); + + fclose( s ); + fclose( d ); + return true; +} + +class PrivateParser { + public: + PrivateParser( QString line, bool all = true ); + ~PrivateParser(); + + const QString & getId() const { return m_label_def_id; } + const QString & getProducer() const { return m_producer; } + const QString & getType() const { return m_type; } + const Measurements & getMeasurements() const { return m_measure; }; + + private: + QString removeQuote( const QString & q ); + + QString m_label_def_id; + QString m_producer; + QString m_type; + + Measurements m_measure; +}; + +PrivateParser::PrivateParser( QString line, bool all ) +{ + line = line.stripWhiteSpace(); + int pos = line.find("("); + line = line.mid( pos + 1, line.length() - pos - 1 ); + + m_label_def_id = line.section( ",", 0, 0 ).stripWhiteSpace(); + m_producer = removeQuote( line.section( ",", 1, 1 ) ); + m_type = removeQuote( line.section( ",", 2, 2 ) ); + + if( all ) { + m_measure.setGapTopMM( line.section( ",", 4, 4 ).toDouble() ); + m_measure.setGapLeftMM( line.section( ",", 5, 5 ).toDouble() ); + m_measure.setHeightMM( line.section( ",", 6, 6 ).toDouble() ); + m_measure.setWidthMM( line.section( ",", 7, 7 ).toDouble() ); + m_measure.setGapVMM( line.section( ",", 8, 8 ).toDouble() ); + m_measure.setGapHMM( line.section( ",", 9, 9 ).toDouble() ); + m_measure.setNumH( line.section( ",", 10, 10 ).toInt() ); + m_measure.setNumV( line.section( ",", 11, 11 ).toInt() ); + + // fix broken label definitions + // with numh and numv = 0 + if( !m_measure.numH() ) + m_measure.setNumH( 1 ); + + if( !m_measure.numV() ) + m_measure.setNumV( 1 ); + } +} + +PrivateParser::~PrivateParser() +{ } + +QString PrivateParser::removeQuote( const QString & q ) +{ + QString quote = q.stripWhiteSpace(); + + if( quote.startsWith("'") ) + quote = quote.mid( 1, quote.length() - 1 ); + + if( quote.endsWith("'") ) + quote = quote.left( quote.length() - 1 ); + + return quote; +} + + +/***************************************************************************/ + +Definition::Definition( QWidget* parent ) + : m_parent( parent ) +{ + id = -1; +} + +Definition::Definition( int label_def_id, QWidget* parent ) + : m_parent( parent ) +{ + init( QString("%1").arg( label_def_id ) ); +} + +Definition::Definition( const QString & label_def_id, QWidget* parent ) + : m_parent( parent ) +{ + init( label_def_id ); +} + +Definition::Definition( const QString & producer, const QString & type, QWidget* parent ) + : m_parent( parent ) +{ + if( SqlTables::isConnected() ) { + QSqlQuery query( + "select label_no from " TABLE_LABEL_DEF " WHERE manufacture='" + producer + "' AND type='" + type + "'"); + while( query.next() ) + init( query.value( 0 ).toString() ); + } else { + if(!openFile()) + return; + + initProgress(); + + QString s; + while( file->readLine( s, 1000 ) != -1 ) { + if( s.isEmpty() || s.left( 1 ) == "#" ) + continue; + + increaseProgress(); + + PrivateParser p( s ); + if( p.getProducer() ==producer && p.getType() == type ) { + init( p.getId() ); + break; + } + } + + destroyProgress(); + } + +} + +Definition::~Definition() +{ +} + +QFile* Definition::file = 0; +QByteArray* Definition::array = 0; +QStringList* Definition::listProducers = 0; +QMap<QString,QStringList> Definition::mapTypes; +QProgressDialog* Definition::m_progress = 0; + +void Definition::initProgress() +{ +/* + if(!m_progress) + m_progress = new QProgressDialog( i18n("Loading Label Definitions..."), QString::null, 0, NULL, "m_progress", true ); + + m_progress->setTotalSteps( 1000 ); + m_progress->show(); +*/ +// m_progress->reparent( m_parent, m_progress->pos(), true ); +} + +void Definition::increaseProgress() +{ +/* + if( m_progress ) + m_progress->setProgress( m_progress->progress() + 1 ); +*/ +} + +void Definition::destroyProgress() +{ +/* + if( m_progress ) + delete m_progress; + m_progress = NULL; +*/ +} + +void Definition::setId( const QString & label_def_id ) +{ + init( label_def_id ); +} + +void Definition::setId( int label_def_id ) +{ + init( QString("%1").arg( label_def_id ) ); +} + +void Definition::init( const QString & label_def_id ) +{ + if( SqlTables::isConnected() ) { + QSqlQuery* query = new QSqlQuery( + "select number_h, number_v, gap_left, gap_top, gap_v, gap_h, width, height, manufacture, type from " TABLE_LABEL_DEF + " WHERE label_no = " + label_def_id ); + + while( query->next() ) { + m_measure.setNumH( query->value( 0 ).toInt() ); + m_measure.setNumV( query->value( 1 ).toInt() ); + m_measure.setGapLeftMM( query->value( 2 ).toDouble() ); + m_measure.setGapTopMM( query->value( 3 ).toDouble() ); + m_measure.setGapVMM( query->value( 4 ).toDouble() ); + m_measure.setGapHMM( query->value( 5 ).toDouble() ); + m_measure.setWidthMM( query->value( 6 ).toDouble() ); + m_measure.setHeightMM( query->value( 7 ).toDouble() ); + producer = query->value( 8 ).toString(); + type = query->value( 9 ).toString(); + } + } else { + getFileMeasurements( label_def_id ); + } + + id = label_def_id.toInt(); + +} + +const Measurements & Definition::getMeasurements() const +{ + return m_measure; +} + +void Definition::getFileMeasurements( const QString & label_def_id ) +{ + if(!openFile()) { + m_measure = Measurements(); + return; + } + + initProgress(); + + QTextStream stream(*array, IO_ReadOnly ); + while( !stream.atEnd() ) { + QString s = stream.readLine(); + if( s.isEmpty() || s.startsWith( "#" ) ) + continue; + + increaseProgress(); + + PrivateParser p( s ); + if( p.getId() != label_def_id ) + continue; + + producer = p.getProducer(); + type = p.getType(); + m_measure = p.getMeasurements(); + break; + } + + destroyProgress(); +} + +bool Definition::openFile() +{ + if( file ) { + file->at( 0 ); + return true; + } + + QString f = locateLocal( "data", "kbarcode/labeldefinitions.sql" ); + if( !QFile::exists( f ) ) { + KConfig* config = kapp->config(); + config->setGroup( "Definitions" ); + + // copy file to new location + QString fname = config->readEntry( "defpath", locate( "data", "kbarcode/labeldefinitions.sql" ) ); + if( !QFile::exists( fname ) || fname.isEmpty() ) + return ( showFileError() ? openFile() : false ); + + if(!filecopy( (const char*)fname, (const char*)f )) + return ( showFileError() ? openFile() : false ); + } + + file = new QFile( f ); + if( !file->open( IO_ReadOnly ) ) { + delete file; + file = 0; + return ( showFileError() ? openFile() : false ); + } + + // keeping this array around + // increases speed quite a lot + // but does also cost lot's of memory + array = new QByteArray(); + *array = file->readAll(); + file->at( 0 ); + + return true; +} + +const QStringList Definition::getProducers() +{ + if( listProducers ) + return *listProducers; + + listProducers = new QStringList(); + + if( SqlTables::isConnected() ) { + QSqlQuery query("SELECT manufacture FROM " TABLE_LABEL_DEF " GROUP by manufacture;"); + while( query.next() ) + listProducers->append( query.value( 0 ).toString() ); + } else { + if(!openFile() ) + return *listProducers; + + initProgress(); + + QTextStream stream(*array, IO_ReadOnly ); + while( !stream.atEnd() ) { + QString s = stream.readLine(); + if( s.isEmpty() || s.startsWith( "#" ) ) + continue; + + increaseProgress(); + + PrivateParser p( s, false ); + if( !listProducers->contains( p.getProducer() ) ) + listProducers->append( p.getProducer() ); + } + + destroyProgress(); + } + + return *listProducers; +} + +const QStringList Definition::getTypes( QString producer ) +{ + if( mapTypes.contains( producer ) ) { + return mapTypes[producer]; + } + + QStringList list; + + if( SqlTables::isConnected() ) { + QSqlQuery query("SELECT type FROM " TABLE_LABEL_DEF " WHERE manufacture='" + producer + "'" ); + while( query.next() ) + if( !list.contains( query.value( 0 ).toString() ) ) + list.append( query.value( 0 ).toString() ); + } else { + if(!openFile()) + return list; + + initProgress(); + + QTextStream stream(*array, IO_ReadOnly ); + while( !stream.atEnd() ) { + QString s = stream.readLine(); + if( s.isEmpty() || s.startsWith( "#" ) ) + continue; + + increaseProgress(); + + PrivateParser p( s, false ); + if( p.getProducer() == producer ) + if( !list.contains( p.getType() ) ) + list.append( p.getType() ); + } + + destroyProgress(); + } + + mapTypes.insert( producer, list ); + + return list; +} + +void Definition::updateProducer() +{ + // TODO: check wether this function is + // correct! w/ SQL and without + if( listProducers ) { + delete listProducers; + listProducers = 0; + + if( array ) { + delete array; + array = 0; + } + + if( file ) { + file->close(); + delete file; + file = 0; + } + mapTypes.clear(); + } +} + +int Definition::write( const Measurements & c, QString type, QString producer ) +{ + int r = -1; + if( SqlTables::isConnected() ) + r = Definition::writeSQL( c, type, producer ); + else + r = Definition::writeFile( c, type, producer ); + + Definition::updateProducer(); + return r; +} + +int Definition::writeFile( const Measurements & c, QString type, QString producer ) +{ + if( !openFile() ) + return -1; + + QStringList data; + bool datawritten = false; + int index = 0; + QString entry = ", '" + + producer + "', '" + type + "', 'C',"+ I2S(c.gapTopMM()) + + ", " + I2S(c.gapLeftMM()) + ", " + + I2S(c.heightMM()) + ", " + I2S(c.widthMM()) + ", " + + I2S(c.gapVMM()) + ", " + I2S(c.gapHMM()) + ", " + + I2S(c.numH()) + ", " + I2S(c.numV()) + ", NULL, NULL )"; + + QString s; + while( file->readLine( s, 1000 ) != -1 ) { + if( s.isEmpty() || s.left( 1 ) == "#" ) { + data.append( s ); + continue; + } + + PrivateParser p( s ); + if( p.getId().toInt() > index ) + index = p.getId().toInt(); + + if( p.getType() == type && p.getProducer() == producer ) { + // update an item already present in the list + entry = entry.prepend( "INSERT INTO " TABLE_LABEL_DEF " VALUES (" + I2S(p.getId().toInt()) ); + data.append( entry ); + datawritten = true; + } else + data.append( s ); + } + + if( !datawritten ) { + entry = entry.prepend( "INSERT INTO " TABLE_LABEL_DEF " VALUES (" + I2S(index+1) ); + data.append( entry ); + } + + file->close(); + if( !file->open( IO_WriteOnly ) ) { + file->open( IO_ReadOnly ); + return -1; + } + + QTextStream t( file ); + for( unsigned int i = 0; i < data.count(); i++ ) + t << data[i].replace( QRegExp("\\n"), "" ) << "\n"; + + // get the file back to the normal stage + file->close(); + file->open( IO_ReadOnly ); + + return index + 1; +} + +int Definition::writeSQL( const Measurements & c, QString type, QString producer ) +{ + bool newitem = true; + QSqlQuery q( "SELECT manufacture, type FROM " TABLE_LABEL_DEF ); + // TODO: use a more inteligent query using where= + while( q.next() ) + if( q.value( 0 ) == producer && + q.value( 1 ) == type ) + newitem = false; + + if( newitem ) { + QSqlQuery query( + "INSERT INTO " TABLE_LABEL_DEF " (manufacture, type, gap_top, gap_left, " + "width, height, gap_v, gap_h, number_h, number_v) VALUES ('" + + producer + "', '" + type + "', '"+ I2S( c.gapTopMM() ) + + "', '" + I2S( c.gapLeftMM() ) + "', '" + + I2S( c.widthMM() ) + "', '" + I2S( c.heightMM() ) + "', '" + + I2S( c.gapVMM() ) + "', '" + I2S( c.gapHMM() ) + "', '" + + I2S( c.numH() ) + "', '" + I2S( c.numV() ) + "')" + ); + + if(!query.isValid()) + qDebug("Query to insert values not valid!"); + } else { + QSqlQuery query( "UPDATE " TABLE_LABEL_DEF " SET " + "gap_top = " + I2S( c.gapTopMM() ) + " ,gap_left = " + I2S( c.gapLeftMM() ) + + " ,width = " + I2S( c.widthMM() ) + " ,height = " + I2S( c.heightMM() ) + + " ,gap_v = " + I2S( c.gapVMM() ) + " ,gap_h = " + I2S( c.gapHMM() ) + + " ,number_h = " + I2S( c.numH() ) + " ,number_v = " + I2S( c.numV() ) + + " WHERE manufacture = '" + producer + "' AND" + " type = '" + type + "'" ); + + if(!query.isValid()) + qDebug("Query to update values not valid!\n%s\n", query.lastQuery().latin1() ); + } + + QSqlQuery qi("SELECT label_no FROM " TABLE_LABEL_DEF " WHERE manufacture='" + producer + "' AND type='" + type + "'" ); + while( qi.next() ) + return qi.value( 0 ).toInt(); + + return -1; +} + + +bool Definition::nodefmsg = true; +bool Definition::showFileError() +{ + if( nodefmsg ) { + KMessageBox::information( 0, + i18n("KBarcode is unable to find its label definitions." + "Please make sure that the file $KDEDIR/share/apps/kbarcode/labeldefinitions.sql " + "does exist. This file is part of the KBarcode distribution. " + "You will be prompted now to select the file containing the labeldefinitions."), + "", "NoDefinitionsFound" ); + + QString f = KFileDialog::getOpenFileName( QString::null, QString::null, 0 ); + if( !f.isEmpty() && QFile::exists( f ) ) { + KConfig* config = kapp->config(); + config->setGroup( "Definitions" ); + config->writeEntry( "defpath", f ); + config->sync(); + } + nodefmsg = false; + return openFile(); + } else + qDebug("No label definitions found. Please install them."); + + return false; +} + +int Definition::getClosest( const QString & producer, const QString & type ) +{ + QStringList t = Definition::getTypes(producer); + for( unsigned int z = 0; z < t.count(); z++ ) { + if( t[z] == type ) { + Definition d( producer, type ); + return d.getId(); + } + } + + return -1; +} diff --git a/kbarcode/definition.h b/kbarcode/definition.h new file mode 100644 index 0000000..a853a67 --- /dev/null +++ b/kbarcode/definition.h @@ -0,0 +1,101 @@ +/*************************************************************************** + definition.h - description + ------------------- + begin : Mit Nov 20 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#ifndef DEFINITION_H +#define DEFINITION_H + +#include "measurements.h" +#include "labelutils.h" +#include <qmap.h> +#include <qstring.h> + +#ifndef I2S + #define I2S(x) QString::number(x) +#endif // I2S + +class QWidget; +class QFile; +class QPaintDevice; +class QString; +class QStringList; +class QSqlQuery; +class Measurements; +class QProgressDialog; +/** @short A label definition; + * + * Represents a label definition. The definition is either read from + * a SQL database or from a text file on the harddisk. + * This class supports also writing new label definitions. + * After you selected a definition, you can retrieve its measurements. + * + * @author Dominik Seichter + */ +class Definition : private LabelUtils { + public: + Definition( QWidget* parent = 0 ); + Definition( int label_def_id, QWidget* parent = 0 ); + Definition( const QString & label_def_id, QWidget* parent = 0 ); + Definition( const QString & producer, const QString & type, QWidget* parent = 0 ); + ~Definition(); + + void setId( const QString & label_def_id ); + void setId( int label_def_id ); + + const Measurements & getMeasurements() const; + + static int write( const Measurements & c, QString type, QString producer ); + static int getClosest( const QString & producer, const QString & type ); + + static const QStringList getProducers(); + static const QStringList getTypes( QString producer ); + /** reread the list of producers, because it has changed + * mapType is also cleared and reread when necessary. + */ + static void updateProducer(); + + int getId() const { return id; } + const QString getProducer() const { return producer; } + const QString getType() const { return type; } + + private: + void init( const QString & label_def_id ); + void getFileMeasurements( const QString & label_def_id ); + static void initProgress(); + static void increaseProgress(); + static void destroyProgress(); + + static int writeSQL( const Measurements & c, QString type, QString producer ); + static int writeFile( const Measurements & c, QString type, QString producer ); + + static bool showFileError(); + static bool openFile(); + static QStringList* listProducers; + static QMap<QString,QStringList> mapTypes; + static QFile* file; + static QByteArray* array; + static QProgressDialog* m_progress; + + QWidget* m_parent; + int id; + QString producer; + QString type; + Measurements m_measure; + bool locked; + static bool nodefmsg; +}; + +#endif diff --git a/kbarcode/definitiondialog.cpp b/kbarcode/definitiondialog.cpp new file mode 100644 index 0000000..d8f9484 --- /dev/null +++ b/kbarcode/definitiondialog.cpp @@ -0,0 +1,428 @@ +/*************************************************************************** + definitiondialog.cpp - description + ------------------- + begin : Don Apr 18 12:34:56 CEST 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "definitiondialog.h" +#include "printersettings.h" +#include "labelutils.h" +#include "definition.h" + +#include <kcombobox.h> +#include <kpushbutton.h> +#include <krestrictedline.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qpainter.h> + +// KDE includes +#include <klocale.h> + +LabelPreview::LabelPreview( QWidget* parent, const char* name ) + : QWidget( parent, name) +{ + // For old DIN A4 preview + PrinterSettings* ps = PrinterSettings::getInstance(); + setFixedSize( QSize( ((int)ps->pageWidth() + 20)/2, ((int)ps->pageHeight() + 20)/2 ) ); + m_prv_enabled = true; +} + +LabelPreview::~LabelPreview() +{ } + +void LabelPreview::paintEvent( QPaintEvent* ) +{ + QPainter p( this ); + p.fillRect( 0, 0, width(), height(), QBrush( Qt::white ) ); + p.setPen( QPen( Qt::black ) ); + p.translate( 10, 10 ); + + p.fillRect( 0, 0, 210/2, 297/2, QBrush( Qt::gray ) ); + p.drawRect( 0, 0, 210/2, 297/2 ); + + if(!m_prv_enabled) + return; + +// int numv = measure.num_v > 0 ? measure.num_v : 1; + for( int v = 0; v < measure.numV(); v++ ) { + for( int h = 0; h < measure.numH(); h++ ) { + if( !v && !h ) + p.setPen( QPen( Qt::red ) ); + else + p.setPen( QPen( Qt::black ) ); + + p.fillRect( int(measure.gapLeftMM() + (measure.gapHMM() * h)) / 2, + int(measure.gapTopMM() + (measure.gapVMM() * v)) / 2 , + (int)measure.widthMM() / 2 , (int)measure.heightMM() / 2, QBrush( Qt::white ) ); + + p.drawRect( int(measure.gapLeftMM() + (measure.gapHMM() * h)) / 2, + int(measure.gapTopMM() + (measure.gapVMM() * v)) / 2, + (int)measure.widthMM() / 2, (int)measure.heightMM() / 2 ); + } + } +} + +/*****************************************/ +DefinitionDialog::DefinitionDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, fl ) +{ + resize( 465, 345 ); + setCaption( i18n( "Add Label Definition" ) ); + QHBoxLayout* layout = new QHBoxLayout( this, 6, 6 ); + DefinitionDialogLayout = new QVBoxLayout( 0, 11, 6, "DefinitionDialogLayout"); + + Layout17 = new QHBoxLayout( 0, 0, 6, "Layout17"); + + Layout13 = new QVBoxLayout( 0, 0, 6, "Layout13"); + + TextLabel1 = new QLabel( this, "TextLabel1" ); + TextLabel1->setText( i18n( "Producer:" ) ); + Layout13->addWidget( TextLabel1 ); + + TextLabel2 = new QLabel( this, "TextLabel2" ); + TextLabel2->setText( i18n( "Type:" ) ); + Layout13->addWidget( TextLabel2 ); + + TextLabel3 = new QLabel( this, "TextLabel3" ); + TextLabel3->setText( QString( i18n( "Width (in %1):" ) ).arg( Measurements::system() ) ); + Layout13->addWidget( TextLabel3 ); + + TextLabel4 = new QLabel( this, "TextLabel4" ); + TextLabel4->setText( QString( i18n( "Height (in %1):" ) ).arg( Measurements::system() ) ); + Layout13->addWidget( TextLabel4 ); + + TextLabel5 = new QLabel( this, "TextLabel5" ); + TextLabel5->setText( i18n( "Horizontal Gap:" ) ); + Layout13->addWidget( TextLabel5 ); + + TextLabel6 = new QLabel( this, "TextLabel6" ); + TextLabel6->setText( i18n( "Vertical Gap:" ) ); + Layout13->addWidget( TextLabel6 ); + + TextLabel7 = new QLabel( this, "TextLabel7" ); + TextLabel7->setText( i18n( "Top Gap:" ) ); + Layout13->addWidget( TextLabel7 ); + + TextLabel8 = new QLabel( this, "TextLabel8" ); + TextLabel8->setText( i18n( "Left Gap:" ) ); + Layout13->addWidget( TextLabel8 ); + + TextLabel9 = new QLabel( this, "TextLabel9" ); + TextLabel9->setText( i18n("Number Horizontal:") ); + Layout13->addWidget( TextLabel9 ); + + TextLabel10 = new QLabel( this, "TextLabel10" ); + TextLabel10->setText( i18n("Number Vertical:") ); + Layout13->addWidget( TextLabel10 ); + + Layout17->addLayout( Layout13 ); + Layout14 = new QVBoxLayout( 0, 0, 6, "Layout14"); + + comboProducer = new KComboBox( FALSE, this, "comboProducer" ); + comboProducer->setEditable( TRUE ); + Layout14->addWidget( comboProducer ); + + comboType = new KComboBox( FALSE, this, "type" ); + comboType->setEditable( TRUE ); + Layout14->addWidget( comboType ); + + editWidth = new KRestrictedLine( this, "editWidth" ); + editWidth->setText( i18n( "0" ) ); + editWidth->setValidChars( i18n( "0123456789." ) ); + Layout14->addWidget( editWidth ); + + editHeight = new KRestrictedLine( this, "editHeight" ); + editHeight->setText( i18n( "0" ) ); + editHeight->setValidChars( i18n( "0123456789." ) ); + Layout14->addWidget( editHeight ); + + editHGap = new KRestrictedLine( this, "editHGap" ); + editHGap->setText( i18n( "0" ) ); + editHGap->setValidChars( i18n( "0123456789." ) ); + Layout14->addWidget( editHGap ); + + editVGap = new KRestrictedLine( this, "editVGap" ); + editVGap->setText( i18n( "0" ) ); + editVGap->setValidChars( i18n( "0123456789." ) ); + Layout14->addWidget( editVGap ); + + editTGap = new KRestrictedLine( this, "editTGap" ); + editTGap->setText( i18n( "0" ) ); + editTGap->setValidChars( i18n( "0123456789." ) ); + Layout14->addWidget( editTGap ); + + editLGap = new KRestrictedLine( this, "editLGap" ); + editLGap->setText( i18n( "0" ) ); + editLGap->setValidChars( i18n( "0123456789." ) ); + Layout14->addWidget( editLGap ); + + editNumH = new KRestrictedLine( this, "editNumH" ); + editNumH->setText( i18n( "0" ) ); + editNumH->setValidChars( "0123456789" ); + Layout14->addWidget( editNumH ); + + editNumV = new KRestrictedLine( this, "editNumV" ); + editNumV->setText( i18n( "0" ) ); + editNumV->setValidChars( "0123456789" ); + Layout14->addWidget( editNumV ); + + Layout17->addLayout( Layout14 ); + QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + Layout17->addItem( spacer ); + DefinitionDialogLayout->addLayout( Layout17 ); + QSpacerItem* spacer_2 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); + DefinitionDialogLayout->addItem( spacer_2 ); + + Layout16 = new QHBoxLayout( 0, 0, 6, "Layout16"); + buttonInfo = new KPushButton( i18n("More &Information"), this ); + Layout16->addWidget( buttonInfo ); + + QSpacerItem* spacer_3 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + Layout16->addItem( spacer_3 ); + + buttonAdd = new KPushButton( this, "buttonAdd" ); + buttonAdd->setText( i18n( "&Add" ) ); + Layout16->addWidget( buttonAdd ); + + buttonCancel = new KPushButton( this, "buttonCancel" ); + buttonCancel->setText( i18n( "&Cancel" ) ); + Layout16->addWidget( buttonCancel ); + DefinitionDialogLayout->addLayout( Layout16 ); + + preview = new LabelPreview( this ); + layout->addLayout( DefinitionDialogLayout ); + layout->addWidget( preview ); + + l = new QLabel( this ); + setExtension( l ); + setOrientation( Vertical ); + + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( buttonAdd, SIGNAL( clicked() ), this, SLOT( add() ) ); + + connect( editWidth, SIGNAL( textChanged(const QString &) ), this, SLOT( updatePreview() ) ); + connect( editHeight, SIGNAL( textChanged(const QString &) ), this, SLOT( updatePreview() ) ); + connect( editHGap, SIGNAL( textChanged(const QString &) ), this, SLOT( updatePreview() ) ); + connect( editVGap, SIGNAL( textChanged(const QString &) ), this, SLOT( updatePreview() ) ); + connect( editTGap, SIGNAL( textChanged(const QString &) ), this, SLOT( updatePreview() ) ); + connect( editLGap, SIGNAL( textChanged(const QString &) ), this, SLOT( updatePreview() ) ); + connect( editNumH, SIGNAL( textChanged(const QString &) ), this, SLOT( updatePreview() ) ); + connect( editNumV, SIGNAL( textChanged(const QString &) ), this, SLOT( updatePreview() ) ); + + comboProducer->setInsertionPolicy( QComboBox::NoInsertion ); + comboType->setInsertionPolicy( QComboBox::NoInsertion ); + + comboProducer->clear(); + QStringList list = Definition::getProducers(); + comboProducer->insertStringList( list ); + + types = new QStringList[list.count()]; + for( unsigned int i = 0; i < list.count(); i++ ) + types[i] = Definition::getTypes( list[i] ); + + connect( comboProducer, SIGNAL( textChanged(const QString &) ), this, SLOT( updateType() ) ); + connect( comboType, SIGNAL( textChanged(const QString &) ), this, SLOT( updateText() ) ); + connect( buttonInfo, SIGNAL( clicked() ), this, SLOT( toggleExtension() ) ); + + drawGraphic(); + updateType(); + + showExtension( false ); +} + +DefinitionDialog::~DefinitionDialog() +{ + delete [] types; +} + +void DefinitionDialog::add() +{ + Definition::write( getCurrentMeasure(), comboType->currentText(), comboProducer->currentText() ); + + accept(); +} + +void DefinitionDialog::updateType() +{ + comboType->clear(); + if( comboProducer->currentText() == comboProducer->text( comboProducer->currentItem() ) ) + if( comboProducer->currentItem() < comboProducer->count()) + comboType->insertStringList( types[ comboProducer->currentItem() ] ); + comboType->insertItem( i18n( "Custom" ), 0 ); +} + +const Measurements DefinitionDialog::getCurrentMeasure() +{ + Measurements m; + m.setGapLeft( editLGap->text().toDouble() ); + m.setGapTop( editTGap->text().toDouble() ); + m.setWidth( editWidth->text().toDouble() ); + m.setHeight( editHeight->text().toDouble() ); + m.setGapV( editVGap->text().toDouble() ); + m.setGapH( editHGap->text().toDouble() ); + m.setNumH( editNumH->text().toInt() ); + m.setNumV( editNumV->text().toInt() ); + + return m; +} + +void DefinitionDialog::updateText() +{ + Definition d( comboProducer->currentText(), comboType->currentText() ); + Measurements m = d.getMeasurements(); + + editTGap->setText( I2S( m.gapTop() ) ); + editLGap->setText( I2S( m.gapLeft() ) ); + editWidth->setText( I2S( m.width() ) ); + editHeight->setText( I2S( m.height() ) ); + editVGap->setText( I2S( m.gapV() ) ); + editHGap->setText( I2S( m.gapH() ) ); + editNumH->setText( I2S( m.numH() ) ); + editNumV->setText( I2S( m.numV() ) ); + + updatePreview(); +} + +void DefinitionDialog::updatePreview() +{ + Measurements m = getCurrentMeasure(); + + editHeight->setPaletteForegroundColor( Qt::black ); + editWidth->setPaletteForegroundColor( Qt::black ); + editVGap->setPaletteForegroundColor( Qt::black ); + editHGap->setPaletteForegroundColor( Qt::black ); + editTGap->setPaletteForegroundColor( Qt::black ); + editLGap->setPaletteForegroundColor( Qt::black ); + editNumH->setPaletteForegroundColor( Qt::black ); + editNumV->setPaletteForegroundColor( Qt::black ); + + // Mark errors in Red + if( m.heightMM() > PrinterSettings::getInstance()->pageHeight() ) + editHeight->setPaletteForegroundColor( Qt::red ); + + if( m.widthMM() > PrinterSettings::getInstance()->pageWidth() ) + editWidth->setPaletteForegroundColor( Qt::red ); + + if( m.gapVMM() < m.heightMM() ) + editVGap->setPaletteForegroundColor( Qt::red ); + + if( m.gapHMM() < m.widthMM() ) + editHGap->setPaletteForegroundColor( Qt::red ); + + if( m.gapTopMM() > PrinterSettings::getInstance()->pageHeight() - m.heightMM() ) + editTGap->setPaletteForegroundColor( Qt::red ); + + if( m.gapLeftMM() > PrinterSettings::getInstance()->pageWidth() - m.widthMM() ) + editLGap->setPaletteForegroundColor( Qt::red ); + + if( m.gapLeftMM() + m.numH() * m.gapHMM() > PrinterSettings::getInstance()->pageWidth() ) + editNumH->setPaletteForegroundColor( Qt::red ); + + if( m.gapTopMM() + m.numV() * m.gapVMM() > PrinterSettings::getInstance()->pageHeight() ) + editNumV->setPaletteForegroundColor( Qt::red ); + + preview->setRect( QRect( (int)m.gapLeftMM(), (int)m.gapTopMM(), (int)m.widthMM(), (int)m.heightMM() ) ); + preview->setMeasurements( m ); + preview->repaint(); +} + +void DefinitionDialog::drawGraphic() +{ + QWMatrix wm; + wm.rotate( 90 ); + + QPixmap pic( 450, 330 ); + pic.fill( Qt::gray ); + + QPainter p( &pic ); + p.setPen( Qt::black ); + + p.fillRect( 60, 60, 450, 330, QColor( 255, 254, 217 ) ); + p.drawRect( 60, 60, 450, 330 ); + p.setBrush( Qt::white ); + + p.setPen( Qt::DotLine ); + p.drawRoundRect( 90, 90, 150, 90 ); + p.drawRoundRect( 270, 90, 150, 90 ); + + p.drawRoundRect( 90, 210, 150, 90 ); + p.drawRoundRect( 270, 210, 150, 90 ); + + // Draw width + p.setPen( QPen( Qt::red, 2 ) ); + p.drawLine( 90, 150, 240, 150 ); + + // Draw numh + p.drawLine( 90, 270, 450, 270 ); + + // Draw Gap Top + p.setPen( QPen( Qt::red, 2, Qt::DotLine ) ); + p.drawLine( 0, 60, 90, 60 ); + p.drawLine( 0, 90, 90, 90 ); + + // draw Gap V + p.drawLine( 0, 210, 90, 210 ); + + // Draw height + p.setPen( QPen( Qt::green, 2 ) ); + p.drawLine( 150, 90, 150, 180 ); + + + // Draw numv + p.drawLine( 330, 90, 330, 330 ); + + // Draw Gap Left + p.setPen( QPen( Qt::green, 2, Qt::DotLine ) ); + p.drawLine( 60, 0, 60, 90 ); + p.drawLine( 90, 0, 90, 90 ); + + // draw Gap H + p.drawLine( 270, 0, 270, 90 ); + + // draw Texts: + p.setPen( Qt::black ); + p.drawText( 100, 140, i18n("Width") ); + p.drawText( 160, 120, i18n("Height") ); + p.drawText( 100, 260, i18n("Number of horizontal Labels") ); + + QPixmap* pix = LabelUtils::drawString( i18n("Number of vertical Labels") ); + p.drawPixmap( 340, 110, pix->xForm( wm ) ); + delete pix; + + p.drawText( 5, 80, i18n("Gap Top") ); + + pix = LabelUtils::drawString( i18n("Gap Left") ); + + p.drawPixmap( 60, 5, pix->xForm( wm ) ); + delete pix; + + p.drawText( 5, 150, i18n("Vertical Gap") ); + p.drawText( 150, 50, i18n("Horizontal Gap") ); + + p.end(); + + l->setPixmap( pic ); +} + +void DefinitionDialog::toggleExtension() +{ + if( l->isVisible() ) { + showExtension( false ); + } else + showExtension( true ); +} + + +#include "definitiondialog.moc" diff --git a/kbarcode/definitiondialog.h b/kbarcode/definitiondialog.h new file mode 100644 index 0000000..701ce6f --- /dev/null +++ b/kbarcode/definitiondialog.h @@ -0,0 +1,99 @@ +#ifndef DEFINITIONDIALOG_H +#define DEFINITIONDIALOG_H + +#include <qwidget.h> +#include <qdialog.h> +#include "measurements.h" + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class KComboBox; +class KPushButton; +class KRestrictedLine; +class QLabel; +class QStringList; +class QRect; +class QPaintEvent; +/** Displays a preview of the given label measurements. + * The current page size setting of the user is used. + * The labels are drawn using QPainter. Only one page is previewed. + */ +class LabelPreview : public QWidget { + Q_OBJECT + public: + LabelPreview( QWidget* parent = 0, const char* name = 0 ); + ~LabelPreview(); + + void setRect( QRect label ) { size = label; } + void setMeasurements( const Measurements & m ) { measure = m; } + + void setPrvEnabled( bool b ) { m_prv_enabled = b; } + + protected: + void paintEvent( QPaintEvent* ); + QRect size; + Measurements measure; + + bool m_prv_enabled; +}; + +/** A dialog which allows the user to create his/her own + * label definitions easily. + */ +class DefinitionDialog : public QDialog +{ + Q_OBJECT + +public: + DefinitionDialog( QWidget* parent = 0, const char* name = 0, bool modal = true, WFlags fl = 0 ); + ~DefinitionDialog(); +private: + const Measurements getCurrentMeasure(); + +private slots: + void add(); + void updateType(); + void updateText(); + void updatePreview(); + void toggleExtension(); + void drawGraphic(); + +protected: + QLabel* l; + QLabel* TextLabel1; + QLabel* TextLabel2; + QLabel* TextLabel3; + QLabel* TextLabel4; + QLabel* TextLabel5; + QLabel* TextLabel6; + QLabel* TextLabel7; + QLabel* TextLabel8; + QLabel* TextLabel9; + QLabel* TextLabel10; + KComboBox* comboProducer; + KComboBox* comboType; + KRestrictedLine* editWidth; + KRestrictedLine* editHeight; + KRestrictedLine* editHGap; + KRestrictedLine* editVGap; + KRestrictedLine* editTGap; + KRestrictedLine* editLGap; + KRestrictedLine* editNumH; + KRestrictedLine* editNumV; + KPushButton* buttonAdd; + KPushButton* buttonCancel; + KPushButton* buttonInfo; + + QStringList* types; + LabelPreview* preview; + +protected: + QVBoxLayout* DefinitionDialogLayout; + QHBoxLayout* Layout17; + QVBoxLayout* Layout13; + QVBoxLayout* Layout14; + QHBoxLayout* Layout16; +}; + +#endif // DEFINITIONDIALOG_H diff --git a/kbarcode/documentitem.cpp b/kbarcode/documentitem.cpp new file mode 100644 index 0000000..8d85eeb --- /dev/null +++ b/kbarcode/documentitem.cpp @@ -0,0 +1,245 @@ +/*************************************************************************** + documentitem.cpp - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#include "documentitem.h" +#include "tcanvasitem.h" + +#include "labelutils.h" + +#include <kapplication.h> + +#include <qpen.h> +#include <qpaintdevicemetrics.h> +#include <qpainter.h> +#include <qdom.h> + +DocumentItem::DocumentItem() + : QObject(), XMLUtils() +{ + init(); +} + +void DocumentItem::init() +{ + m_canvasitem = NULL; + m_token = NULL; + m_device = KApplication::desktop(); + + m_z = 0; + m_border = true; + m_locked = false; + m_pen = QPen( Qt::black, 1, Qt::SolidLine ); + m_rect = QRect( 0, 0, 0, 0 ); + m_visibilityScript = "true"; +} + +void DocumentItem::drawBorder(QPainter* painter) +{ + if( m_border ) + { + painter->save(); + painter->setPen( m_pen ); + painter->drawRect( rect() ); + painter->restore(); + } +} + +void DocumentItem::loadXML (QDomElement* element) +{ + LabelUtils l; + m_rect.setX( element->attribute( "x_mm", "0" ).toInt() ); + m_rect.setY( element->attribute( "y_mm", "0" ).toInt() ); + m_rect.setWidth( element->attribute( "width_mm", "-1" ).toInt() ); + m_rect.setHeight( element->attribute( "height_mm", "-1" ).toInt() ); + + m_pen.setColor( readXMLColor( element, "line-color", Qt::black ) ); + m_pen.setStyle( (Qt::PenStyle)element->attribute( "line-style", "0" ).toInt() ); + m_pen.setWidth( element->attribute( "line-width", "1" ).toInt() ); + m_border = (bool)element->attribute( "line-visible", "1" ).toInt(); + m_z = element->attribute( "z", "0" ).toInt(); + m_locked = (bool)element->attribute( "locked", "0" ).toInt(); + m_visibilityScript = element->attribute( "visibilityScript", "true" ); +} + +void DocumentItem::saveXML (QDomElement* element) +{ + element->setAttribute( "x_mm", m_rect.x() ); + element->setAttribute( "y_mm", m_rect.y() ); + element->setAttribute( "width_mm", m_rect.width() ); + element->setAttribute( "height_mm", m_rect.height() ); + + writeXMLColor( element, "line-color", m_pen.color() ); + element->setAttribute( "line-style", (Qt::PenStyle)m_pen.style() ); + element->setAttribute( "line-width", m_pen.width() ); + element->setAttribute( "line-visible", (int)m_border ); + element->setAttribute( "z", m_z ); + element->setAttribute( "locked", (int)m_locked ); + element->setAttribute( "visibilityScript", m_visibilityScript ); +} + +void DocumentItem::move( int x, int y ) +{ + LabelUtils l; + moveMM( (int)(l.pixelToMm( x, m_device, LabelUtils::DpiX ) * 1000.0 ), + (int)(l.pixelToMm( y, m_device, LabelUtils::DpiY ) * 1000.0 ) ); +} + +void DocumentItem::moveMM( int x, int y ) +{ +// Move is not relative! +/* m_rect.setX( m_rect.x() + x ); + m_rect.setY( m_rect.y() + y );*/ + m_rect = QRect( x, y, m_rect.width(), m_rect.height() ); +} + +void DocumentItem::setSize( int w, int h ) +{ + LabelUtils l; + setSizeMM( (int)(l.pixelToMm( w, m_device, LabelUtils::DpiX ) * 1000.0 ), + (int)(l.pixelToMm( h, m_device, LabelUtils::DpiY ) * 1000.0 ) ); +} + +void DocumentItem::setSizeMM( int w, int h ) +{ + m_rect.setWidth( w ); + m_rect.setHeight( h ); +} + +void DocumentItem::setBoundingRect( const QRect & rect ) +{ + QRect r; + LabelUtils l; + r.setX( (int)(l.pixelToMm( rect.x(), m_device, LabelUtils::DpiX ) * 1000.0 ) ); + r.setY( (int)(l.pixelToMm( rect.y(), m_device, LabelUtils::DpiY ) * 1000.0 ) ); + r.setWidth( (int)(l.pixelToMm( rect.width(), m_device, LabelUtils::DpiX ) * 1000.0 ) ); + r.setHeight( (int)(l.pixelToMm( rect.height(), m_device, LabelUtils::DpiY ) * 1000.0 ) ); + + // avoid resizing to negative values + setRectMM( r.normalize() ); +} + +QRect DocumentItem::boundingRect() const +{ + QRect r; + + LabelUtils l; + r.setX( (int)(l.mmToPixel( m_rect.x(), m_device, LabelUtils::DpiX ) / 1000.0 ) ); + r.setY( (int)(l.mmToPixel( m_rect.y(), m_device, LabelUtils::DpiY ) / 1000.0 ) ); + r.setWidth( (int)(l.mmToPixel( m_rect.width(), m_device, LabelUtils::DpiX ) / 1000.0 ) ); + r.setHeight( (int)(l.mmToPixel( m_rect.height(), m_device, LabelUtils::DpiY ) / 1000.0 ) ); + +// qDebug("bounding rect %i %i %i %i", r.x(), r.y(), r.width(), r.height() ); + + return r; +} + +void DocumentItem::setRect( const QRect & rect) +{ + // avoid resizing to negative values + QRect r = rect.normalize(); + setBoundingRect( QRect( r.x() - m_pen.width(), r.y() - m_pen.width(), r.width() + 2 * m_pen.width(), r.height() + 2 * m_pen.width() ) ); +} + +QRect DocumentItem::rect() const +{ + QRect bound = boundingRect(); + QRect r( bound.x() + m_pen.width(), bound.y() + m_pen.width(), bound.width() - 2 * m_pen.width(), bound.height() - 2 * m_pen.width() ); +// qDebug("rect %i %i %i %i", r.x(), r.y(), r.width(), r.height() ); + return r; +} + +void DocumentItem::setRectMM( const QRect & rect ) +{ + // avoid resizing to negative values + m_rect = rect.normalize(); +} + +QRect DocumentItem::rectMM() const +{ + return m_rect; +} + +void DocumentItem::setBorder (bool b) +{ + m_border = b; +} + +bool DocumentItem::border () const +{ + return m_border; +} + +void DocumentItem::setPen( const QPen & pen ) +{ + m_pen = pen; +} + +QPen DocumentItem::pen() const +{ + return m_pen; +} + +void DocumentItem::setCanvasItem( TCanvasItem* item ) +{ + m_canvasitem = item; +} + +TCanvasItem* DocumentItem::canvasItem() const +{ + return m_canvasitem; +} + +int DocumentItem::z() const +{ + return m_z; +} + +void DocumentItem::setZ( int z ) +{ + m_z = z; +} + +void DocumentItem::setPaintDevice( QPaintDevice* device ) +{ + m_device = device; +} + +QPaintDevice* DocumentItem::paintDevice() const +{ + return m_device; +} + +void DocumentItem::setTokenProvider( TokenProvider* token ) +{ + m_token = token; +} + +TokenProvider* DocumentItem::tokenProvider() const +{ + return m_token; +} + +void DocumentItem::setLocked( bool locked ) +{ + m_locked = locked; +} + +const bool DocumentItem::locked() const +{ + return m_locked; +} + diff --git a/kbarcode/documentitem.h b/kbarcode/documentitem.h new file mode 100644 index 0000000..ff528d3 --- /dev/null +++ b/kbarcode/documentitem.h @@ -0,0 +1,230 @@ +/*************************************************************************** + documentitem.h - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#ifndef DOCUMENTITEM_H +#define DOCUMENTITEM_H + +#include <xmlutils.h> +#include <qobject.h> +#include <qsortedlist.h> +#include <qstring.h> +#include <qtextstream.h> + +#include <qcolor.h> +#include <qpen.h> + +#include "zplutils.h" + +enum ERtti { + eRtti_Barcode, + eRtti_Image, + eRtti_Line, + eRtti_Rect, + eRtti_Text, + //NY33 + eRtti_TextLine + //NY33 +}; + +class QDomElement; +class QPainter; +class QPaintDevice; +class QTextStream; +class TCanvasItem; +class TokenProvider; + +/** + * Class DocumentItem + * Every object which can be placed on a document has to be a subclass of this class. + */ +class DocumentItem : public QObject, protected XMLUtils { +public: + DocumentItem ( ); + virtual ~DocumentItem() { }; + + /** + * + * @param element + */ + virtual void loadXML (QDomElement* element); + + + /** + * save this item to XML + */ + virtual void saveXML (QDomElement* element); + + + /** + * Draws the item + */ + virtual void draw (QPainter* painter) = 0; + + + /** + * Draw a border around the item, has to be reimplemented for round items or barcodes which do not allow borders. + */ + virtual void drawBorder (QPainter* painter); + + virtual int rtti () const = 0; + + /** + * Write a ZPL string for drawing this item onto a zebra printer to a QTextStream + */ + virtual void drawZpl( QTextStream* stream ) = 0; + + /** + * Write a IPL string for drawing this item onto a zebra printer to a QTextStream + */ + virtual void drawIpl( QTextStream* stream, IPLUtils* utils ) = 0; + + /** + * Write a EPCL string for drawing this item onto a zebra printer to a QTextStream + */ + virtual void drawEPcl( QTextStream* stream ) = 0; + + void setCanvasItem( TCanvasItem* item ); + TCanvasItem* canvasItem() const; + + void setPaintDevice( QPaintDevice* device ); + QPaintDevice* paintDevice() const; + + void setTokenProvider( TokenProvider* token ); + TokenProvider* tokenProvider() const; + + /** + * + * @param b + */ + void setBorder (bool b); + bool border () const; + + void setPen( const QPen& pen ); + QPen pen() const; + + /** move the documentitem using pixel coordinates on the current + * paint device + */ + void move( int x, int y ); + /** move the documentitem using 1/1000th of a millimeter coordinates + */ + void moveMM( int x, int y ); + + /** set the width and height of this item using pixel coordinates + * of the current paint device + */ + void setSize( int w, int h ); + /** set the width and height of this item using 1/1000th of a + * millimeter coordinates + */ + void setSizeMM( int w, int h ); + + /** The bounding rectangle. I.e. the rectangle including + * the border width + */ + void setBoundingRect( const QRect & rect ); + /** The bounding rectangle. I.e. the rectangle including + * the border width + */ + QRect boundingRect() const; + + /** The drawing rectangle. I.e. the rectangle with the + * border width substracted + */ + void setRect( const QRect & rect ); + /** The drawing rectangle. I.e. the rectangle with the + * border width substracted + */ + QRect rect() const; + + /** the bounding rectangle including the border in 1/1000mm + */ + void setRectMM( const QRect & rect ); + /** the bounding rectangle including the border in 1/1000mm + */ + QRect rectMM() const; + + /** set the item to be locked in the label editor + * i.e protect it from being move or resized by the user + */ + void setLocked( bool locked ); + const bool locked() const; + + /** set a javascript script for this item which is evaluate + * to determine wether this item should be printed (only in Label + * as items are always shown in the labeleditor. + * The script shall return true if the item should be visible. + * If script returns false the item will not be printed. + */ + inline void setVisibilityScript( const QString & script ); + inline const QString visibilityScript() const; + + int z() const; + void setZ( int z ); + + /** Only the z index is compared + */ + bool operator<( const DocumentItem & docitem ) + { + return m_z < docitem.m_z; + } + + /** Only the z index is compared + */ + bool operator==( const DocumentItem & docitem ) + { + return m_z == docitem.m_z; + } +private: + void init(); + +private: + /** + * Defines wether this item has a border or not + */ + bool m_border; + QPen m_pen; + QRect m_rect; + int m_z; + bool m_locked; + + /** + * Background color of this document item + */ + QColor m_background; + + QString m_visibilityScript; + + QPaintDevice* m_device; + TCanvasItem* m_canvasitem; + TokenProvider* m_token; +}; + +void DocumentItem::setVisibilityScript( const QString & script ) +{ + m_visibilityScript = script; +} + +const QString DocumentItem::visibilityScript() const +{ + return m_visibilityScript; +} + +typedef QSortedList<DocumentItem> DocumentItemList; + +#endif //DOCUMENTITEM_H + diff --git a/kbarcode/documentitemdlg.cpp b/kbarcode/documentitemdlg.cpp new file mode 100644 index 0000000..9055de4 --- /dev/null +++ b/kbarcode/documentitemdlg.cpp @@ -0,0 +1,121 @@ +/*************************************************************************** + documentitemdlg.cpp - description + ------------------- + begin : Do Sep 10 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#include "documentitemdlg.h" +#include "tokenprovider.h" + +#include <qvbox.h> + +#include <kcommand.h> +#include <klocale.h> + +DocumentItemDlg::DocumentItemDlg( TokenProvider* token, DocumentItem* item, KCommandHistory* history, QWidget* parent ) + : KDialogBase( Tabbed, i18n("Properties"), KDialogBase::Ok|KDialogBase::Cancel, + KDialogBase::Ok, parent, 0, true, true ) +{ + m_item = item; + m_history = history; + //m_list.setAutoDelete( false ); + + QVBox* boxBorder = addVBoxPage(i18n("&Position && Size"), QString::null, QPixmap() ); + addPage( new PropertySize( boxBorder ) ); + + boxBorder = addVBoxPage(i18n("&Border"), QString::null, QPixmap() ); + addPage( new PropertyBorder( boxBorder ) ); + + if( m_item->rtti() == eRtti_Rect ) + { + boxBorder = addVBoxPage(i18n("&Fill Color"), QString::null, QPixmap() ); + addPage( new PropertyFill( boxBorder) ); + } + else if ( m_item->rtti() == eRtti_Barcode ) + { + boxBorder = addVBoxPage(i18n("&Barcode"), QString::null, QPixmap() ); + addPage( new PropertyBarcode( token, boxBorder) ); + } + else if ( m_item->rtti() == eRtti_Text ) + { + boxBorder = addVBoxPage(i18n("&Rotation"), QString::null, QPixmap() ); + addPage( new PropertyRotation( boxBorder ) ); + + boxBorder = addVBoxPage(i18n("&Text"), QString::null, QPixmap() ); + addPage( new PropertyText( token, boxBorder) ); + } + else if( m_item->rtti() == eRtti_Image ) + { + boxBorder = addVBoxPage(i18n("&Image"), QString::null, QPixmap() ); + addPage( new PropertyImage( token, boxBorder) ); + } +//NY19 + else if ( m_item->rtti() == eRtti_TextLine ) + { + boxBorder = addVBoxPage(i18n("&Text"), QString::null, QPixmap() ); + addPage( new PropertyTextLine( token, boxBorder) ); + } +//NY19 + + showPage( pageIndex( boxBorder ) ); + + // Add it after the call to showPage + // so that this page is not always shown + // as default page + if( TokenProvider::hasJavaScript() ) + { + boxBorder = addVBoxPage(i18n("&Visibility"), QString::null, QPixmap() ); + addPage( new PropertyVisible( boxBorder ) ); + } + + std::list<PropertyWidget*>::iterator it; + for( it=m_list.begin();it!=m_list.end();it++) + { + (*it)->initSettings( m_item ); + } + + resize( configDialogSize("DocumentItemDlg") ); +} + +DocumentItemDlg::~DocumentItemDlg() +{ + saveDialogSize("DocumentItemDlg"); + + std::list<PropertyWidget*>::iterator it; + for( it=m_list.begin();it!=m_list.end();it++) + { + delete (*it); + } +} + +void DocumentItemDlg::addPage( PropertyWidget* widget ) +{ + m_list.push_back( widget ); +} + +void DocumentItemDlg::accept() +{ + KMacroCommand* mc = new KMacroCommand( i18n("Property changed") ); + std::list<PropertyWidget*>::iterator it; + for( it=m_list.begin();it!=m_list.end();it++) + { + (*it)->applySettings( m_item, mc ); + } + + m_history->addCommand( mc, false ); + + KDialogBase::accept(); +} + +#include "documentitemdlg.moc" diff --git a/kbarcode/documentitemdlg.h b/kbarcode/documentitemdlg.h new file mode 100644 index 0000000..732432e --- /dev/null +++ b/kbarcode/documentitemdlg.h @@ -0,0 +1,47 @@ +/*************************************************************************** + documentitemdlg.h - description + ------------------- + begin : Do Sep 10 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#ifndef DOCUMENTITEMDLG_H +#define DOCUMENTITEMDLG_H + +#include <kdialogbase.h> +#include "documentitem.h" +#include "propertywidget.h" +#include <list> + +class KCommandHistory; + +class DocumentItemDlg : public KDialogBase +{ + Q_OBJECT + public: + DocumentItemDlg( TokenProvider* token, DocumentItem* item, KCommandHistory* history, QWidget* parent ); + ~DocumentItemDlg(); + + void addPage( PropertyWidget* widget ); + + protected slots: + void accept(); + + private: + DocumentItem* m_item; + std::list<PropertyWidget*> m_list; + + KCommandHistory* m_history; +}; + +#endif diff --git a/kbarcode/dsmainwindow.cpp b/kbarcode/dsmainwindow.cpp new file mode 100644 index 0000000..0e30c4d --- /dev/null +++ b/kbarcode/dsmainwindow.cpp @@ -0,0 +1,268 @@ +/*************************************************************************** + dsmainwindow.cpp - description + ------------------- + begin : Fri Jan 17 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "dsmainwindow.h" +#include "sqltables.h" +#include "confwizard.h" +#include "printersettings.h" +#include "kbarcodesettings.h" +#include "kactionmap.h" +#include "barkode.h" + +// Qt includes +#include <qcheckbox.h> +#include <qtextbrowser.h> +#include <qsqldatabase.h> + +// KDE includes +#include <kaction.h> +#include <kapplication.h> +#include <kconfig.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kmenubar.h> +#include <kmessagebox.h> +#include <kpopupmenu.h> +#include <kstandarddirs.h> +#include <krun.h> + +bool DSMainWindow::autoconnect = true; +bool DSMainWindow::startwizard = true; + +DSMainWindow::DSMainWindow(QWidget *parent, const char *name, WFlags f) + : KMainWindow(parent,name,f) +{ + connectAct = 0; + first = false; + loadConfig(); + + setAutoSaveSettings( QString("Window") + name, true ); + connect( kapp, SIGNAL( aboutToQuit() ), this, SLOT( saveConfig() ) ); + + if( first && startwizard ) { + wizard(); + startwizard = false; + } + +} + +DSMainWindow::~DSMainWindow() +{ +} + +void DSMainWindow::setupActions() +{ + KAction* quitAct = KStdAction::quit(kapp, SLOT(quit()), actionCollection()); + KAction* closeAct = KStdAction::close( this, SLOT( close() ), actionCollection(), "close" ); + KAction* configureAct = KStdAction::preferences( KBarcodeSettings::getInstance(), SLOT(configure()), actionCollection() ); + KAction* wizardAct = new KAction( i18n("&Start Configuration Wizard..."), BarIcon("wizard"), 0, this, + SLOT(wizard()), actionCollection(), "wizard" ); + connectAct = new KAction(i18n("&Connect to Database"), BarIcon("connect_no"), 0, this, SLOT(connectMySQL()), + actionCollection(),"connect" ); + + + KAction* newTablesAct = new KAction( i18n("&Create Tables"), "", 0, this, + SLOT(newTables()), actionCollection(), "tables" ); + + importLabelDefAct = new KAction( i18n("&Import Label Definitions"), "", 0, SqlTables::getInstance(), + SLOT(importLabelDef()), actionCollection(), "import" ); + + importExampleAct = new KAction( i18n("&Import Example Data"), "", 0, SqlTables::getInstance(), + SLOT(importExampleData()), actionCollection(), "import" ); + + KPopupMenu* file = new KPopupMenu( this ); + KPopupMenu* settings = new KPopupMenu( this ); + KPopupMenu* hlpMenu = helpMenu(); + int helpid = hlpMenu->idAt( 0 ); + hlpMenu->removeItem( helpid ); + hlpMenu->insertItem( SmallIconSet("contents"), i18n("&Help"), + this, SLOT(appHelpActivated()), Key_F1, -1, 0 ); + hlpMenu->insertSeparator(-1); + hlpMenu->insertItem( i18n("&Action Map..."), this, SLOT( slotFunctionMap() ), 0, -1, 0 ); + hlpMenu->insertSeparator(-2); + hlpMenu->insertItem( SmallIconSet("system"), i18n("&System Check..."), this, SLOT(showCheck() ), 0, -1, 0 ); + hlpMenu->insertItem( SmallIconSet("barcode"), i18n("&Barcode Help..."), this, SLOT( startInfo() ), 0, -1, 0 ); + hlpMenu->insertItem( i18n("&Donate..."), this, SLOT( donations() ), 0, -1, 0 ); + + menuBar()->insertItem( i18n("&File"), file ); + menuBar()->insertItem( i18n("&Settings"), settings ); + menuBar()->insertItem( i18n("&Help"), hlpMenu ); + + closeAct->plug( file ); + quitAct->plug( file ); + + configureAct->plug( settings ); + wizardAct->plug( settings ); + connectAct->plug( settings ); + (new KActionSeparator( this ))->plug( settings ); + newTablesAct->plug( settings ); + importLabelDefAct->plug( settings ); + importExampleAct->plug( settings ); + + SqlTables* tables = SqlTables::getInstance(); + if( tables->getData().autoconnect && autoconnect && !first ) { + tables->connectMySQL(); + autoconnect = false; + } + + connectAct->setEnabled( !SqlTables::isConnected() ); + importLabelDefAct->setEnabled( !connectAct->isEnabled() ); + importExampleAct->setEnabled( !connectAct->isEnabled() ); +} + +void DSMainWindow::loadConfig() +{ + KConfig* config = kapp->config(); + + config->setGroup("Wizard"); + first = config->readBoolEntry("firststart2", true ); + + SqlTables* tables = SqlTables::getInstance(); + if( tables->getData().autoconnect && !first && autoconnect && connectAct ) { + connectAct->setEnabled( !tables->connectMySQL() ); + importLabelDefAct->setEnabled( !connectAct->isEnabled() ); + importExampleAct->setEnabled( !connectAct->isEnabled() ); + + autoconnect = false; + } + + KBarcodeSettings::getInstance()->loadConfig(); +} + +void DSMainWindow::saveConfig() +{ + KConfig* config = kapp->config(); + + config->setGroup("Wizard"); + config->writeEntry("firststart2", false ); + + PrinterSettings::getInstance()->saveConfig(); + SqlTables::getInstance()->saveConfig(); + KBarcodeSettings::getInstance()->saveConfig(); + + config->sync(); +} + +void DSMainWindow::wizard() +{ + ConfWizard* wiz = new ConfWizard( 0, "wiz", true ); + if( wiz->exec() == QDialog::Accepted && wiz->checkDatabase->isChecked() ) + SqlTables::getInstance()->connectMySQL(); + + delete wiz; +} + +void DSMainWindow::connectMySQL() +{ + connectAct->setEnabled( !SqlTables::getInstance()->connectMySQL() ); + importLabelDefAct->setEnabled( !connectAct->isEnabled() ); + importExampleAct->setEnabled( !connectAct->isEnabled() ); + + if( !connectAct->isEnabled() ) + emit connectedSQL(); +} + +void DSMainWindow::appHelpActivated() +{ + KMessageBox::information( this, i18n( + "<qt>The KBarcode documentation is avaible as PDF for download on our webpage.<br><br>") + + "<a href=\"http://www.kbarcode.net/17.0.html\">" + + i18n("Download Now") + "</a></qt>", + QString::null, QString::null, KMessageBox::AllowLink ); +} + +void DSMainWindow::showCheck() +{ + QTextBrowser* b = new QTextBrowser( 0, "b" ); + b->setText( DSMainWindow::systemCheck() ); + b->resize( 320, 240 ); + b->show(); +} + +void DSMainWindow::startInfo() +{ + QString info = locate("appdata", "barcodes.html"); + if( !info.isEmpty() ) + kapp->invokeBrowser( info ); +} + +bool DSMainWindow::newTables() +{ + return SqlTables::getInstance()->newTables(); +} + +void DSMainWindow::donations() +{ + // orig =https://www.paypal.com/xclick/business=domseichter%40web.de&item_name=Support+KBarcode+Development&item_number=0&image_url=http%3A//www.kbarcode.net/themes/DeepBlue/images/logo.gif&no_shipping=1&return=http%3A//www.kbarcode.net&cancel_return=http%3A//www.kbarcode.net&cn=Suggestions%2C+Comments%3F&tax=0¤cy_code=EUR + QString url = "https://www.paypal.com/xclick/business=domseichter@web.de&item_name=Support+KBarcode+Development&item_number=0&image_url=www.kbarcode.net/themes/DeepBlue/images/logo.gif&no_shipping=1&return=www.kbarcode.net&cancel_return=www.kbarcode.net&cn=Suggestions,+Comments,&tax=0¤cy_code=EUR"; + + KMessageBox::information( this, i18n( + "<qt>It is possible to support the further development of KBarcode through donations. " + "PayPal will be used for processing the donation.<br><br>" ) + + "<a href=\"" + url + "\">" + + i18n("Donate Now") + "</a></qt>", QString::null, QString::null, KMessageBox::AllowLink ); +} + +QString DSMainWindow::systemCheck() +{ + bool gnubarcode = !Barkode::haveGNUBarcode(); + bool pdf = !Barkode::havePDFBarcode(); + bool tbarcode = !Barkode::haveTBarcode(); + bool tbarcode2 = !Barkode::haveTBarcode2(); + bool pure = !Barkode::havePurePostscriptBarcode(); + + QString text; + + text.append( i18n("<p><h3>Barcode Support</h3></p>") ); + text.append( "<p>GNU Barcode: "); + text.append( gnubarcode ? i18n("<b>No</b><br />") : i18n("<b>Found</b><br />") ); + text.append( "PDF417 Encode: "); + text.append( pdf ? i18n("<b>No</b><br />") : i18n("<b>Found</b><br />") ); + text.append( "TBarcode: "); + text.append( tbarcode ? i18n("<b>No</b><br />") : i18n("<b>Found</b><br />") ); + text.append( "TBarcode2: "); + text.append( tbarcode2 ? i18n("<b>No</b><br />") : i18n("<b>Found</b><br />") ); + text.append( "Pure Postscript Barcode Writer: "); + text.append( pure ? i18n("<b>No</b><br />") : i18n("<b>Found</b><br />") ); + + if( gnubarcode && tbarcode && pdf ) + text.append( i18n("<p>To get <b>barcode support</b> you have to either install <i>GNU Barcode</i>, <i>TBarcode</i> or <i>PDF417 Enc</i>.</p>") ); + + text.append( i18n("<p><h3>Database Support</h3></p>") ); + + QStringList list = QSqlDatabase::drivers(); + + if( list.count() ) { + text.append( "<ul>" ); + QStringList::Iterator it = list.begin(); + while( it != list.end() ) { + text.append( i18n("<li>Driver found: ") + *it + "</li>" ); + ++it; + } + text.append( "</ul>" ); + } else + text.append( i18n("<p><b>No database drivers found. SQL database support is disabled.</b></p>") ); + + return text; +} + +void DSMainWindow::slotFunctionMap() +{ + new KActionMapDlg( actionCollection(), this ); +} + +#include "dsmainwindow.moc" diff --git a/kbarcode/dsmainwindow.h b/kbarcode/dsmainwindow.h new file mode 100644 index 0000000..c43959b --- /dev/null +++ b/kbarcode/dsmainwindow.h @@ -0,0 +1,90 @@ +/*************************************************************************** + dsmainwindow.h - description + ------------------- + begin : Fre Jan 17 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DSMAINWINDOW_H +#define DSMAINWINDOW_H + +#include <qwidget.h> +#include <kmainwindow.h> + +class KAction; +class KPopupMenu; +/** The base class of all main windows of KBarcode. It provides standard menu items + * for database connections, preferences, help, the first start wizard and donations. + * It checks also if this is the first start of KBarcode and if the configuration wizard + * should be started. + * + * @author Dominik Seichter + */ +class DSMainWindow : public KMainWindow { + Q_OBJECT + public: + DSMainWindow(QWidget *parent=0, const char *name=0, WFlags f = WType_TopLevel | WDestructiveClose ); + ~DSMainWindow(); + + /** Is this the first start of KBarcode ? + * If true, the configuration wizard will + * be started automatically. + */ + bool isFirstStart() const { + return first; + } + + + /** Do a system check and return a text + * informing the user about missing, programs + * and drivers for barcode support and database + * access. + */ + static QString systemCheck(); + + public slots: + void wizard(); + + signals: + void connectedSQL(); + + private slots: + void connectMySQL(); + void appHelpActivated(); + void startInfo(); + bool newTables(); + void donations(); + void showCheck(); + void slotFunctionMap(); + + protected slots: + void loadConfig(); + void saveConfig(); + + protected: + void setupActions(); + + static bool autoconnect; + static bool startwizard; + + bool first; + + KAction* connectAct; + KAction* importLabelDefAct; + KAction* importExampleAct; + + KPopupMenu* file; + KPopupMenu* settings; + KPopupMenu* hlpMenu; +}; +#endif diff --git a/kbarcode/dsrichtext.cpp b/kbarcode/dsrichtext.cpp new file mode 100644 index 0000000..01f7182 --- /dev/null +++ b/kbarcode/dsrichtext.cpp @@ -0,0 +1,427 @@ +/*************************************************************************** + dsrichtext.cpp - description + ------------------- + begin : Fre Okt 17 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "dsrichtext.h" + +#ifdef QT_TEXT_BUG + +// Qt includes +#include <qfontmetrics.h> +#include <qpainter.h> +#include <qregexp.h> + +// for DSREPLACE +#include "sqltables.h" + +/* +EXAMPLE TEXT: + "<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:10pt;font-family:Nimbus Sans l\">" + "<p>A little bit <span style=\"font-style:italic;font-weight:600\">formated</span><span style=\"color:#4400ff\"> " + "richtext</span> which should be printed to a <span style=\"font-weight:600\">QPrinter</span> with <span style=\"text-decoration:underline\">QSimpleRichText</span>. </p>" + "<p><span style=\"font-family:Times New Roman;font-size:16pt\">Printing should work in ScreenResolution as well as in HighResolution, but as you can see it will only work in ScreenResolution.</span></p>" + "</body></html>"; + +Another example +<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Nimbus Sans l"> +<p align="center"><span style="font-size:12pt;font-weight:600;text-decoration:underline">Text test </span><span style="font-size:12pt;font-weight:600;text-decoration:underline;color:#ff0000">label</span></p> +<p>Resolution <span style="font-weight:600">formated</span> 108dpi. This text & text should now overlap with the first line. 4 < 6a</p> +<p><span style="font-family:Nimbus Sans L;font-weight:600">A</span><span style="font-family:Nimbus Sans L"> longer paragraph with some text, so that I can test wether wordwrap is working. Another "line" to test line spacing without a bigger font (like the one found in the next sentence) messing up the spacing.</span><span style="font-family:Courier [Adobe];font-size:16pt"> Some text "in" a bigger courier font.</span><span style="font-family:Nimbus Sans L"> Also this paragraph should be justified as blockquote.</span><span style="font-family:Nimbus Sans L;color:#ff0004"> I hope it works</span><span style="font-family:Nimbus Sans L"> and KBarcodes text redering will be better than the one found in Qt.</span></p> +</body></html> + +*/ + +DSRichText::DSRichText( const QString & t ) + : text( t ) +{ + if( text.find("<html>") == -1 ) + text = "<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:10pt;font-family:Nimbus Sans l\"><p>" + + t + "</p></body></html>"; + + //qDebug( text ); + + start = end = pos = 0; + x = y = 0; + sx = sy = 1.0; + m_base = QFont(); + + QString tmp = parse( text, "<body ", ">", 0 ); + if( !tmp.isNull() ) { + pos += tmp.length(); + tmp = tmp.left( tmp.length() - 1 ); + tmp = tmp.mid( 5, tmp.length() - 5 ); + m_base = parseStyle( parse( tmp, "style=\"", "\"", pos ), &m_color ); + } + + pos = text.find( "<p", 0 ); // initalize pos correctly + while( parseParagraph() ); // empty while loop +} + +DSRichText::~DSRichText() +{ +} + +void DSRichText::initFormat( formated_word* f, int alignment ) +{ + f->text = QString::null; + f->line = false; + f->alignment = alignment; + f->font = m_base; + f->color = m_color; +} + +void DSRichText::initLine( QValueList<formated_line>* l ) +{ + formated_line li; + li.width = 0; + li.ascent = 0; + li.leading = 0; + li.lineSpacing = 0; + li.line = false; + l->append( li ); +} + +void DSRichText::updateSpacing( QValueList<formated_line>* l, QFontMetrics* fm ) +{ + l->last().lineSpacing = (l->last().lineSpacing < fm->lineSpacing()) ? fm->lineSpacing() : l->last().lineSpacing; + l->last().ascent = (l->last().ascent < fm->ascent()) ? fm->ascent() : l->last().ascent; + l->last().leading = (l->last().leading < fm->leading()) ? fm->leading() : l->last().leading; +} + +void DSRichText::fillLines() +{ + for( unsigned int z = 0; z < word_p.count(); z++ ) { + WordList words = word_p[z]; + LineList lines; + initLine( &lines ); + for( unsigned int i = 0; i < words.count(); i++ ) { + formated_word word = words[i]; + lines.last().line = lines.last().line | word.line; + + QFontMetrics fm( word.font ); + updateSpacing( &lines, &fm ); + + int tw = fm.width( word.text ); + // word does not fit in the current line, create a new one + if( lines.last().width + tw >= w ) + initLine( &lines ); + + // TODO: check here for words longer than one line + lines.last().formats.append( word ); + lines.last().width += tw; + } + line_p.append( lines ); + } +} + +void DSRichText::draw( QPainter* p ) +{ + /* don't try to draw if there is no space to draw */ + if( !w || !h ) + return; + + fillLines(); + + painter = p; + painter->save(); + painter->setClipRect( xpos, ypos, int(w*sx), int(h*sy), QPainter::CoordPainter ); + + for( unsigned int z = 0; z < line_p.count(); z++ ) { + LineList lines = line_p[z]; + if( lines.count() && z ) + y += int( lines[0].lineSpacing * 0.5); + + for( unsigned int i = 0; i < lines.count(); i++ ) { + formated_line l = lines[i]; + + if( l.formats.count() && l.formats[0].alignment == Qt::AlignJustify && i != lines.count() - 1 ) { + // last line in a paragraph is not justified (in blocksatz mode)! + drawJustified( &l ); + } else { + for( unsigned int z = 0; z < l.formats.count(); z++ ) { + formated_word f = l.formats[z]; + + painter->setFont( f.font ); + painter->setPen( QPen( f.color ) ); + + int a = f.alignment; + if( a == Qt::AlignRight ) { + a = Qt::AlignLeft; + if( !x ) + x = w - l.width; + } else if( a == Qt::AlignHCenter ) { + a = Qt::AlignLeft; + if( !x ) + x = ( w - l.width ) / 2; + } + + int ya = yDeviation( &l ); + painter->drawText( xpos + int(x*sx), ypos + int((y+ya)*sy), int(l.width*sx), int(l.lineSpacing * sy), a, f.text ); + x += painter->fontMetrics().width( f.text ); + } + } + + x = 0; + y += l.lineSpacing; + } + } + + painter->restore(); +} + +void DSRichText::drawJustified( formated_line* line ) +{ + int all = 0; + for( unsigned int z = 0; z < line->formats.count(); z++ ) { + line->formats[z].text = line->formats[z].text.stripWhiteSpace(); + QFontMetrics fm( line->formats[z].font ); + all += fm.width( line->formats[z].text ); + } + + int x = 0; + int space = (w - all) / (line->formats.count() - 1); + for( unsigned int z = 0; z < line->formats.count(); z++ ) { + painter->setFont( line->formats[z].font ); + painter->setPen( QPen( line->formats[z].color ) ); + + int ya = yDeviation( line ); + int tw = painter->fontMetrics().width(line->formats[z].text); + painter->drawText( int(x*sx), int((y+ya)*sy), int(tw*sx), int(line->lineSpacing * sy), Qt::AlignAuto, line->formats[z].text ); + x += tw; + x += space; + } + +} + +bool DSRichText::parseParagraph() +{ + int alignment = 0; + formated_word f; + QString d = parse( text, "<p", "</p>", pos ); + //qDebug("D=" + d ); + //qDebug("POS=%i", pos ); + + pos += d.length(); + if( d.isNull() ) + return false; + + d = parseParagraphTag( d, &alignment ); + + WordList words; + QString data; + initFormat( &f, alignment ); + + if( d.isEmpty() ) { + // found empty paragraph + words.append( f ); + word_p.append( words ); + return true; + } + + for( unsigned int i = 0; i < d.length(); ) { + if( d[i] == '<' || i == (d.length() - 1) ) { + if( i == (d.length() - 1) ) + data.append( d[i] ); + + parseWords( data, &f, &words ); + initFormat( &f, alignment ); + data = QString::null; + + // bail out now, otherwise there is + // and endless loop for e.g. <p>a</p> + if( i == (d.length() - 1) ) + break; + + if( d[i] == '<' ) { + QString span = d.mid( i, d.find( ">", i ) - i + 1 ); + i += span.length(); + + if( span.startsWith( "<span " ) ) { + initFormat( &f, alignment ); + f.font = parseStyle( parse( span, "style=\"", "\"", 0 ), &f.color ); + } + } + } else { + data.append( d[i] ); + i++; + } + } + + word_p.append( words ); + return true; +} + +QFont DSRichText::parseStyle( const QString & s, QColor* color ) +{ + QString style = QString( s ); + + style = style.left( style.length() - 1 ); + if( style.startsWith("style=\"" ) ) + style = style.mid( 7, style.length() - 7 ); + + QFont f = m_base; + *color = m_color; + + for ( int i = 0; i < style.contains(';')+1; i++ ) { + QString s = style.section( ';', i, i ); + if( s.isEmpty() ) + continue; + + if ( s.startsWith("font-size:" ) ) { + f.setPointSize( s.mid(10, s.length() - 12).toInt() ); + } else if ( s.startsWith("font-family:" ) ) { + f.setFamily( s.right( s.length() - 12 ) ); + } else if( s.startsWith( "color:" ) ) { + color->setNamedColor( s.right( s.length() - 6 ) ); + } else if( s.startsWith("text-decoration:") ) { + if( s.endsWith( "underline" ) ) + f.setUnderline( true ); +/*#if QT_VERSION >= 0x030200 + else if( s.endsWith( "overline" ) ) + f.setOverline( true ); +#endif */ + else if( s.endsWith( "line-through" ) ) + f.setStrikeOut( true ); + } else if( s.startsWith( "font-style:") ) { + if( s.endsWith( "italic" ) || s.endsWith( "oblique" ) ) + f.setItalic( true ); + } else if( s.startsWith( "font-weight:" ) ) { + bool ok = false; + int n = s.right( s.length() - 12 ).toInt( &ok ); + if( s.endsWith( "bold" ) ) + f.setBold( true ); + else if( ok ) + f.setWeight( n / 8 ); // convert CSS values to Qt values + } + } + + return f; +} + +QString DSRichText::parse( const QString & t, const QString & find, const QString & find2, int start ) +{ + int s = t.find( find, start ); + if( s == -1 || s < start ) + return QString::null; + + int pend = t.find( find2, s + find.length() ); + if( pend == -1 || pend < (signed int)(s + find.length()) ) + return QString::null; + + QString text = t.mid( s, pend - s + find2.length() ); + return text; +} + +void DSRichText::setX( int x ) +{ + xpos = x; +} + +void DSRichText::setY( int y ) +{ + ypos = y; +} + +void DSRichText::setWidth( int width ) +{ + w = width; +} + +void DSRichText::setHeight( int height ) +{ + h = height; +} + +int DSRichText::parseAlignment( const QString & align ) +{ + QString a = QString( align ); + if( a.endsWith("\"") ) + a = a.left( a.length() - 1 ); + + if( a.startsWith("align=\"") ) + a = a.mid( 7, a.length() - 7 ); + + if( a == "left" ) + return Qt::AlignLeft; + else if( a == "center" ) + return Qt::AlignHCenter; + else if( a == "right" ) + return Qt::AlignRight; + else if( a == "justify" ) + return Qt::AlignJustify; + + return 0; +} + +void DSRichText::parseWords( const QString & t, formated_word* w, WordList* words ) +{ + unsigned int p = 0; + for( unsigned int i = 0; i < t.length(); i++ ) { + if( (t[i].isSpace() && p != i) || i == t.length() - 1 ) { + formated_word word = *w; + + word.text = replaceEscapeSequences( t.mid( p, i + 1 - p ) ); + + p = i + 1; + words->append( word ); + } + } +} + +inline int DSRichText::yDeviation( const formated_line* line ) +{ + // leading = 1 (almost ever) + // linespacing = leading + height + // height = ascent + descent + 1 + if( line->lineSpacing != painter->fontMetrics().lineSpacing() ) { + return line->ascent + line->leading - painter->fontMetrics().ascent() - painter->fontMetrics().leading(); + } else { + return 0; + } +} + +QString DSRichText::replaceEscapeSequences( const QString & t ) +{ + QString tmp = QString( t ); + tmp = tmp.replace( DSREPLACE( "<" ), "<" ); + tmp = tmp.replace( DSREPLACE( ">" ), ">" ); + tmp = tmp.replace( DSREPLACE( "&" ), "&" ); + tmp = tmp.replace( DSREPLACE( """ ), "\"" ); + return tmp; +} + +QString DSRichText::parseParagraphTag( const QString &t, int* alignment ) +{ + QString d = QString( t ); + if( d.startsWith("<p>") ) { + d = d.mid( 3, d.length() - 3 ); + } else if( d.startsWith("<p ") ) { + *alignment = parseAlignment( parse( d, "align=\"", "\"", 0 ) ); + if( d.contains( ">" ) ) { + int x = d.find(">" ) + 1; + d = d.mid( x, d.length() - x ); + } + } + + if( d.endsWith("</p>") ) + d = d.left( d.length() - 4 ); // strlen("</p>"); + + return d; +} + +#endif // QT_TEXT_BUG + + diff --git a/kbarcode/dsrichtext.h b/kbarcode/dsrichtext.h new file mode 100644 index 0000000..5da22b1 --- /dev/null +++ b/kbarcode/dsrichtext.h @@ -0,0 +1,193 @@ +/*************************************************************************** + dsrichtext.h - description + ------------------- + begin : Fre Okt 17 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DSRICHTEXT_H +#define DSRICHTEXT_H + +#define QT_TEXT_BUG +/*#undef QT_TEXT_BUG*/ +#ifdef QT_TEXT_BUG + +#include <qcolor.h> +#include <qfont.h> +#include <qstring.h> +#include <qvaluelist.h> + +class DSRichText; + +/** This class represents one word, + * formated with a font, a color and an + * alignment. + */ +struct formated_word { + QString text; + QFont font; + QColor color; + int alignment; + bool line; +}; + +typedef QValueList<formated_word> WordList; + +/** This structure represents a single line. + * Every line contains a list of formated_words. + * Wordwrapping has been applied before the line + * was created. + * lineSpacing, ascent and leading come from the + * biggest font in the line. + */ +struct formated_line { + int width; + int lineSpacing; + int ascent; + int leading; + bool line; + + WordList formats; +}; +typedef QValueList<formated_line> LineList; + +class QColor; +class QPainter; + +/** A richtext rendering class, which draws a piece + * of HTML formated richtext on any QPainter. + * This class works with all printer resolutions compared + * to the buggy QSimpleRichText + * + * rendering the richtext happens in 3 steps: + * <ul> + * <li> the HTML data is parsed into text_format structures. Each + * of these text_format structures may represend multiple lines, but + * also single words. This depends on how long a formated text is. + * this step happens in the constructor and in parseParagraph()</li> + * <li> the text_format structures are parsed into line structures. + * In this step the wordwrapping is calculated. Each line structure + * has again text_format structures. This is necessary because a line + * of text may of course contain different formattings. A line struct is always + * a single line of drawn text, not more and not less. + * happens in draw() and fillLines()</li> + * <li> the line structure is drawn line by line using QPainter. + * happens in draw()</li> + * </ul> + * + * Printing to the screen is easy and the usage does not differ from + * QSimpleRichText. Drawing on QPrinter is a little bit more complicated. + * The most important thing is that you may not use QPainter::scale(). + * A small example on how to print on a QPrinter: + * <pre> + * QPrinter printer( QPrinter::HighResolution ); + * QPainter painter( &printer ); + * QPaintDeviceMetrics metrics( &printer ); + * double scalex = (double)metrics.logicalDpiX() / (double)QPaintDevice::x11AppDpiX(); + * double scaley = (double)metrics.logicalDpiY() / (double)QPaintDevice::x11AppDpiY(); + * + * DSRichText dsr( "<html><p>Hallo World</p></html>" ); + * dsr.setWidth( 200 ); // in screenresolution coordinates + * dsr.setHeight( 80 ); // in screenresolution coordinates + * painter.translate( 10 * scalex, 10 * scaley ); // draw at 10, 10 instead of 0, 0 + * dsr.scale( scalex, scaley ); + * dsr.draw( &painter ); + * </pre> + * + *@author Dominik Seichter + */ +class DSRichText { + public: + /** construct a DSRichText object. @p t is formated text as produces by QTextEdit. + */ + DSRichText( const QString & t ); + ~DSRichText(); + + void setX( int x ); + void setY( int y ); + + /** draw the formated text on the QPainter* @p p + */ + void draw( QPainter* p ); + /** set the width of the clipping rectangle + */ + void setWidth( int width ); + /** set the height of the clipping rectangle + */ + void setHeight( int height ); + /** scale everything. This is necessary to print on devices + * with another resolution than the screen. QPainter::scale() won't work. + */ + void setScale( double x, double y ) { + sx = x; sy = y; + }; + + private: + /** parse a single pare of <p></p> elements + */ + bool parseParagraph(); + /** remove <p> and </p> from the QString @p t and return it. + * This function is also responsible for getting the + * correct alignment of the paragraph. + */ + QString parseParagraphTag( const QString & t, int* alignment ); + /** parse the align attribute of a <p> tag and return the corresponding Qt alignment value. + */ + int parseAlignment( const QString & align ); + /** parse the css style attribute of a <span> tag and return a matching QFont for these + * style. The font color is saved in the QColor* @p color. + */ + QFont parseStyle( const QString & s, QColor* color ); + QString parse( const QString & t, const QString & find, const QString & end, int start ); + void parseWords( const QString & t, formated_word* w, WordList* words ); + void initFormat( formated_word* f, int alignment ); + void initLine( QValueList<formated_line>* l ); + void updateSpacing( QValueList<formated_line>* l, QFontMetrics* fm ); + /** draw the line @p line justified as blockquote + */ + void drawJustified( formated_line* line ); + /** calculate the y-deviation needed, because of different font sizes in this line + */ + inline int yDeviation( const formated_line* line ); + /** replace HTML escape sequences such as < to their real character meaning (i.e. < ) + */ + QString replaceEscapeSequences( const QString & t ); + + /** fill the line structures with data + */ + void fillLines(); + + int pos; // current position in text + int start; // start of a tag + int end; // end of a tag + int x; // x position + int y; // y position + int w; // width of the text element + int h; // height of the text element + int xpos; // x position at the beginning + int ypos; // y position at the beginning + + double sx; + double sy; + + QString text; + QFont m_base; + QColor m_color; + QPainter* painter; + + QValueList<LineList> line_p; + QValueList<WordList> word_p; +}; + +#endif // QT_TEXT_BUG +#endif diff --git a/kbarcode/dstextedit.cpp b/kbarcode/dstextedit.cpp new file mode 100644 index 0000000..e059e96 --- /dev/null +++ b/kbarcode/dstextedit.cpp @@ -0,0 +1,147 @@ +/*************************************************************************** + dstextedit.cpp - description + ------------------- + begin : Sam Jun 04 2005 + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "dstextedit.h" +#include "dstextedit.moc" +#include <qregexp.h> + +DSTextEdit::DSTextEdit( QWidget* parent, const char* name ) + : TextEditBase( parent, name ) +{ + connect( this, SIGNAL( textChanged() ), this, SLOT( fixParagraphs() ) ); +} + +void DSTextEdit::fixParagraphs() +{ + struct { + QFont font; + QColor color; + int alignment; + } tFormattings; + + QString t; + int pos = 0; + int count = 0; + int i; + int para, index; // needed to save the cursor position + int paraFrom, indexFrom, paraTo, indexTo; // needed to save the selection + QValueList<int> chars; + QRegExp reg("<p[^>]*>"); + + for( i = 0; i < paragraphs(); i++ ) + chars.append( paragraphLength( i ) ); + + // disconnect us first as we change the text here + disconnect( this, SIGNAL( textChanged() ), this, SLOT( fixParagraphs() ) ); + + getCursorPosition( ¶, &index ); + getSelection( ¶From, &indexFrom, ¶To, &indexTo ); + + if( !para && !index ) + setCursorPosition( 0, index+1 ); + + t = this->text(); + tFormattings.font = this->currentFont(); + tFormattings.color = this->color(); + tFormattings.alignment = this->alignment(); + + while( pos != -1 ) + { + pos = reg.search( t, pos ); + if( pos != -1 ) + { + if( count && count == para ) + { + for( i = 0; i < count; i++ ) + index += chars[i]; + ++index; // count the new <br> that is inserted later + } + + ++count; + + if( count > 1 ) //&& pos != -1 ) + t = t.remove( pos, reg.matchedLength() ); + else + pos += reg.matchedLength(); + } + } + + pos = t.length(); + count = 0; + + while( pos != -1 ) + { + pos = t.findRev( "</p>", pos ); + if( pos != -1 ) + { + ++count; + + if( count > 1 ) //&& pos != -1 ) + t = t.replace( pos, 4, "<br />" ); + else + pos -= 4; + } + } + + this->setText( t ); + this->setCursorPosition( 0, index ); + this->setCurrentFont( tFormattings.font ); + this->setColor( tFormattings.color ); + this->setAlignment( tFormattings.alignment ); + this->setSelection( paraFrom, indexFrom, paraTo, indexTo ); + + + connect( this, SIGNAL( textChanged() ), this, SLOT( fixParagraphs() ) ); +} + +/* +void DSTextEdit::moveCursor( CursorAction action, bool select ) +{ + do { + TextEditBase::moveCursor( action, select ); + } while( cursorIsInToken() ); +} + +bool DSTextEdit::cursorIsInToken() +{ + int para, index; + int firstopen, firstclose; + QString data; + + getCursorPosition( ¶, &index ); + + data = text( para ); + + qDebug("data=" + data ); + --index; + firstopen = data.findRev( "[", index ); + firstclose = data.findRev( "]", index ); + ++index; + + if( firstopen != -1 && firstopen > firstclose ) + { + firstopen = data.find( "[", index ); + firstclose = data.find( "]", index ); + if( ( firstclose != -1 && firstopen != -1 && firstclose < firstopen ) || + ( firstclose != -1 && firstopen == -1 ) ) + return true; + } + + return false; +} + +*/ diff --git a/kbarcode/dstextedit.h b/kbarcode/dstextedit.h new file mode 100644 index 0000000..15192a3 --- /dev/null +++ b/kbarcode/dstextedit.h @@ -0,0 +1,55 @@ +/*************************************************************************** + dstextedit.h - description + ------------------- + begin : Sam Jun 04 2005 + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef _DS_TEXT_EDIT_H_ +#define _DS_TEXT_EDIT_H_ + +#include <qnamespace.h> + +#if QT_VERSION >= 0x030100 + #include <ktextedit.h> +#else + #include <qtextedit.h> +#endif + +// Otherwise moc will complain +#if QT_VERSION >= 0x030100 + #define TextEditBase KTextEdit +#else + #define TextEditBase QTextEdit +#endif + +class DSTextEdit : public TextEditBase { + Q_OBJECT + + public: + DSTextEdit( QWidget* parent, const char* name = 0 ); + + //virtual void moveCursor( CursorAction action, bool select ); + private slots: + void fixParagraphs(); + + private: + /** + * returns true if the cursor is currently inside + * of a token of the form [value]. + */ + //bool cursorIsInToken(); +}; + +#endif // _DS_TEXT_EDIT_H_ + diff --git a/kbarcode/editoriface.h b/kbarcode/editoriface.h new file mode 100644 index 0000000..a568879 --- /dev/null +++ b/kbarcode/editoriface.h @@ -0,0 +1,55 @@ +/*************************************************************************** + editoriface.h - description + ------------------- + begin : Sat Dec 27 09:53:28 CET 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef EDITORIFACE_H +#define EDITORIFACE_H + +#include <dcopobject.h> + +class EditorIface : virtual public DCOPObject +{ + K_DCOP + + public: + k_dcop: + + virtual const QString fileName() const = 0; + virtual bool isChanged() = 0; + virtual void print() = 0; + virtual bool newLabel() = 0; + + virtual void insertBarcode() = 0; + virtual void insertPicture() = 0; + virtual void insertText() = 0; + virtual void insertRect() = 0; + virtual void insertCircle() = 0; + virtual void insertLine() = 0; + + virtual void changeDes() = 0; + virtual void changeSize() = 0; + + virtual void preview() = 0; + virtual void toggleGrid() = 0; + + virtual void closeLabel() = 0; + + virtual bool openUrl( const QString & url ) = 0; + virtual bool save( QString url ) = 0; + +}; + +#endif /* EDITORIFACE_H */ diff --git a/kbarcode/encodingcombo.cpp b/kbarcode/encodingcombo.cpp new file mode 100644 index 0000000..52f7a21 --- /dev/null +++ b/kbarcode/encodingcombo.cpp @@ -0,0 +1,47 @@ +/*************************************************************************** + encodingcombo.h - description + ------------------- + begin : Fri Dec 23 2005 + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "encodingcombo.h" + +#include <kcharsets.h> +#include <kglobal.h> +#include <klocale.h> +#include <qtextcodec.h> + +EncodingCombo::EncodingCombo( QWidget* parent ) + : KComboBox( parent ) +{ + QString sEncoding = QString( KGlobal::locale()->encoding() ); + QStringList encodings (KGlobal::charsets()->availableEncodingNames()); + + this->insertStringList( encodings ); + + for (int i=0; i < encodings.count(); i++) + { + bool found = false; + QTextCodec *codecForEnc = KGlobal::charsets()->codecForName(encodings[i], found); + if (found && ( (codecForEnc->name() == sEncoding) || (encodings[i] == sEncoding) ) ) + { + this->setCurrentItem(i); + break; + } + } +} + +EncodingCombo::~EncodingCombo() +{ +} diff --git a/kbarcode/encodingcombo.h b/kbarcode/encodingcombo.h new file mode 100644 index 0000000..f6e0762 --- /dev/null +++ b/kbarcode/encodingcombo.h @@ -0,0 +1,35 @@ +/*************************************************************************** + encodingcombo.h - description + ------------------- + begin : Fri Dec 23 2005 + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef _ENCODING_COMBO_H_ +#define _ENCODING_COMBO_H_ + +#include <kcombobox.h> + +class EncodingCombo : public KComboBox { + Q_OBJECT + public: + EncodingCombo( QWidget* parent ); + ~EncodingCombo(); + + + + +}; + +#endif // _ENCODING_COMBO_H_ + diff --git a/kbarcode/exampledata.sql b/kbarcode/exampledata.sql new file mode 100644 index 0000000..2afcfe8 --- /dev/null +++ b/kbarcode/exampledata.sql @@ -0,0 +1,10 @@ +INSERT INTO barcode_basic VALUES (1,'art1001','Test1','1000001','ean','field0','field1','field2','field3','field4','field5','field6','field7','field8','field9') +INSERT INTO barcode_basic VALUES (2,'art1002','Test1','1000002','ean','field0','field1','field2','field3','field4','field5','field6','field7','field8','field9') +INSERT INTO barcode_basic VALUES (3,'art1003','Test1','1000003','ean','field0','field1','field2','field3','field4','field5','field6','field7','field8','field9') +INSERT INTO barcode_basic VALUES (4,'art1004','Test1','1000004','ean','field0','field1','field2','field3','field4','field5','field6','field7','field8','field9') +INSERT INTO barcode_basic VALUES (5,'art1005','Test1','1000005','ean','field0','field1','field2','field3','field4','field5','field6','field7','field8','field9') +INSERT INTO barcode_basic VALUES (6,'art1006','Test1','1000006','ean','field0','field1','field2','field3','field4','field5','field6','field7','field8','field9') +INSERT INTO customer VALUES (1,'EURO222','Europe') +INSERT INTO customer VALUES (2,'613203','USA') +INSERT INTO customer_text VALUES (1,'EURO222','code39','art1001','custom1001','2323232','EURO222-Line0','EURO222-Line1','EURO222-Line2','EURO222-Line3','EURO222-Line4','EURO222-Line5','EURO222-Line6','EURO222-Line7','EURO222-Line8','EURO222-Line9') +INSERT INTO customer_text VALUES (2,'613203','code39','art1003','custom1002','11111','test-Line0','test-Line1','test-Line2','test-Line3','test-Line4','test-Line5','test-Line6','test-Line7','test-Line8','test-Line9') diff --git a/kbarcode/gnubarcode.cpp b/kbarcode/gnubarcode.cpp new file mode 100644 index 0000000..6f69644 --- /dev/null +++ b/kbarcode/gnubarcode.cpp @@ -0,0 +1,348 @@ +/*************************************************************************** + gnubarcode.cpp - description + ------------------- + begin : + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "gnubarcode.h" + +#ifdef _ENABLE_NATIVE_GNU_BARCODE + +#include <barcode.h> +#include "barkode.h" +#include <string.h> +#include <ctype.h> + +#include <qfont.h> +#include <qpainter.h> +#include <qpaintdevicemetrics.h> + +#include <klocale.h> + +#define FONT_SPACE (2*m_scaley) +#define SHRINK_AMOUNT 0.15 +#define MUL_FACTOR 10 + +GnuBarcode::GnuBarcode() + : BarkodeEngine() +{ + m_item = NULL; + m_size = QSize( 0, 0 ); + + m_scalex = 1.0; + m_scaley = 1.0; + + m_font_size = 10; +} + +GnuBarcode::~GnuBarcode() +{ + if( m_item ) + Barcode_Delete( m_item ); +} + +void GnuBarcode::update( const QPaintDevice* device ) +{ + QString val = barkode->parsedValue(); + m_valid = false; + + if( m_item ) + { + qDebug("Deleting"); + Barcode_Delete( m_item ); + m_item = NULL; + } + + if( val.isEmpty() ) + return; + + char* value = new char[val.length()+1]; + strncpy( value, val.latin1(), val.length()+1 ); + value[val.length()] = '\0'; + + m_item = Barcode_Create( value ); + if( !m_item ) + { + Barcode_Delete( m_item ); + m_item = NULL; + delete [] value; + return; + } + + if( Barcode_Encode( m_item, Barkode::internalType( barkode->type() ) ) == -1 ) + { + Barcode_Delete( m_item ); + m_item = NULL; + + delete [] value; + return; + } + + delete [] value; + + QPaintDeviceMetrics metrics( device ); + m_scalex = (double)metrics.logicalDpiX() / (double)QPaintDevice::x11AppDpiX(); + m_scaley = (double)metrics.logicalDpiY() / (double)QPaintDevice::x11AppDpiY(); + + // 72.0 is the postscript resolution generated by GNU barcode + m_scale_ps_x = (double)metrics.logicalDpiX() / 72.0; + m_scale_ps_y = (double)metrics.logicalDpiY() / 72.0; + +/* m_scalex *= m_scale_ps_x; + m_scaley *= m_scale_ps_y;*/ + + m_font_size = (int)(barkode->fontsize() * barkode->scaling() * m_scaley); + setupSize(); + m_valid = true; +} + +const QSize GnuBarcode::size() const +{ + if( m_size.isNull() ) + return QSize( 100, 80 ); + else + return m_size; +} + +void GnuBarcode::drawBarcode( QPainter & painter, int x, int y ) +{ + int dx = x + barkode->quietZone(); + int dy = y + barkode->quietZone(); + + if( !m_item ) + { + barkode->drawInvalid( painter, x, y ); + return; + } + + painter.save(); + painter.scale( m_scalex, m_scaley ); + + // based on David J. Humphreys barcode-svg + // Draw the bars + drawBars( &painter, (int)(dx/m_scalex), (int)(dy/m_scaley) ); + + // Only scale for the bars, text should be scaled + // correctly by Qt on Qt >= 3.3.2 + painter.restore(); + + // draw the text + if( barkode->textVisible() ) + drawText( &painter, dx, dy ); +} + +void GnuBarcode::setupSize() +{ + m_bar_height = (int)(barkode->barHeight() * barkode->scaling() * barkode->cut()); + m_barcode_height = m_bar_height; + if( barkode->textVisible() ) + m_barcode_height += (int)(m_font_size/2 + FONT_SPACE*2); + + unsigned int width = drawBars( 0 , 0, 0 ); + unsigned int twidth = drawText( 0, 0, 0 ); + + //if(m_item->height == 0) + m_item->height = m_barcode_height + (2 * barkode->quietZone()); + + width = ( width > twidth ? width : twidth ); + width += 2* barkode->quietZone(); + + //if(m_item->width == 0) + m_item->width = width; + + m_size.setWidth( (int)(m_item->width * m_scalex) ); + m_size.setHeight( (int)(m_item->height * m_scaley) ); +} + +int GnuBarcode::drawBars( QPainter* painter, int x, int y ) +{ +#if 0 + int height = 0; // height of the bar to draw + int xpos = 0; // Where the current box is drawn + int current = 0; + unsigned int i = 0; + + qDebug("Partial=%s\n", m_item->partial ); + for( i = 0; i < strlen(m_item->partial); i++) + { + current = (int)m_item->partial[i] - ASCII_ZERO; + /* Guide bar */ + if(current > 9) + { + height = m_barcode_height; + current = (int)m_item->partial[++i] - ASCII_ZERO; + i++; /* Skip the following 'a' */ + } + else + height = m_bar_height; + + current *= barkode->scaling(); + + if( current < 0 ) + { + qDebug("current < 0: %i", current ); + current = 0; + break; + } + + if( i % 2) + { + painter.fillRect( x + xpos, y, current, height, barkode->foreground() ); + } + + xpos += current; + } +#endif + int xpos; + int mode = '-'; // text below bars + char *ptr; + int i, j; + int x0, yr, y0; + + xpos = m_item->partial[0]-'0'; + + for (ptr = m_item->partial+1, i=1; *ptr; ptr++, i++) + { + /* special cases: '+' and '-' */ + if (*ptr == '+' || *ptr == '-') + { + mode = *ptr; /* don't count it */ i++; continue; + } + /* j is the width of this bar/space */ + if (isdigit (*ptr)) + j = *ptr-'0'; + else + j = *ptr-'a'+1; + + j = (int)( j * barkode->scaling() ); + if (i%2) + { + x0 = xpos + j/2; + y0 = y; + yr = m_barcode_height; + + if( barkode->textVisible() ) + { + // leave space for text + if (mode == '-') + { + // text below bars + if( isdigit( *ptr ) ) + yr = m_bar_height; + else + yr = m_barcode_height; + } else { /* '+' */ + // text above bars + // TODO: this needs testing and a GUI + if( isdigit( *ptr ) ) + yr = m_bar_height; + else + { + yr = m_barcode_height; + y0 += (m_barcode_height - m_bar_height); + } + } + } + + if( painter ) + { + painter->fillRect( x + x0, y0, j, yr, barkode->foreground() ); + } + //qDebug("Bar = %i", j ); + } + xpos += j; + } + + return xpos; +} + +int GnuBarcode::drawText( QPainter* painter, int x, int y ) +{ +#if 0 + unsigned int infosz = strlen( m_item->textinfo ); + unsigned int correction = 0; // This correction seems to be needed to align text properly + unsigned int j = 0; + unsigned int i = 0; + int prev_x = 0; + int xpos = 0; + + double dub1, fsize; + char printer; + char *temp_info = new char[infosz+1]; + + painter.setFont( QFont( "Helvetica", 12 ) ); + while(i < infosz) + { + for(j = 0; m_item->textinfo[i + j + 1] != ' ' && + m_item->textinfo[i + j + 1] != '\0';j++); /* Empty loop, just increment j */ + j ++; + strncpy(temp_info, (m_item->textinfo + i),j); + sscanf(temp_info, "%lf:%lf:%c", &dub1, &fsize, &printer); + i += j; + + xpos = (int)dub1; + //if((xpos - prev_x) >= 10) + //correction += 2; + + prev_x = xpos; + painter.drawText( x + ((xpos-correction) * m_scalex), + y + ((m_bar_height + (unsigned int)(barkode->fontsize()/ 2) + FONT_SPACE) * m_scaley), + QChar( printer ) ); + } + delete [] temp_info; +#endif + + double f1, f2; + int y0; + char* ptr; + char c; + + int mode = '-'; + for (ptr = m_item->textinfo; ptr; ptr = strchr(ptr, ' ')) + { + while (*ptr == ' ') + ptr++; + if (!*ptr) + break; + if (*ptr == '+' || *ptr == '-') + { + mode = *ptr; continue; + } + + if (sscanf(ptr, "%lf:%lf:%c", &f1, &f2, &c) != 3) + { + fprintf(stderr, "barcode: impossible data: %s\n", ptr); + continue; + } + + if( mode == '-' ) + { + // text below bars + y0 = y + (int)(m_bar_height * m_scaley + m_font_size - FONT_SPACE); + } + else + y0 = (int)(y + FONT_SPACE); + + if( painter ) + { + painter->setFont( QFont( "Helvetica", m_font_size ) ); + painter->drawText( x + (int)(f1 * m_scalex * barkode->scaling() ), y0, QChar( c ) ); + } + } + + return x; +} + +#endif // _ENABLE_NATIVE_GNU_BARCODE + diff --git a/kbarcode/gnubarcode.h b/kbarcode/gnubarcode.h new file mode 100644 index 0000000..afdec8e --- /dev/null +++ b/kbarcode/gnubarcode.h @@ -0,0 +1,75 @@ +/*************************************************************************** + gnubarcode.h - description + ------------------- + begin : + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef GNU_BARCODE_H +#define GNU_BARCODE_H + +// #define _ENABLE_NATIVE_GNU_BARCODE + +#ifdef _ENABLE_NATIVE_GNU_BARCODE + +#include "barkodeengine.h" + +struct Barcode_Item; + +class GnuBarcode : public BarkodeEngine { + public: + GnuBarcode(); + ~GnuBarcode(); + + inline EEngine engine() const; + + const QSize size() const; + void update( const QPaintDevice* device ); + void drawBarcode( QPainter & painter, int x, int y ); + + private: + /** Draws the barcodes bars if @p painter is not 0. + * Otherwise only the required width is returned. + */ + int drawBars( QPainter* painter, int x, int y ); + + /** Draws the text if @p painter is not 0. + * Otherwise only the required width is returned. + */ + int drawText( QPainter* painter, int x, int y ); + + /** Fill m_size with the needed space + */ + void setupSize(); + + private: + int m_bar_height; + int m_barcode_height; + int m_font_size; + + double m_scalex; + double m_scaley; + double m_scale_ps_x; + double m_scale_ps_y; + + Barcode_Item* m_item; + QSize m_size; +}; + +EEngine GnuBarcode::engine() const +{ + return GNU_BARCODE; +} + +#endif // _ENABLE_NATIVE_GNU_BARCODE +#endif /* GNU_BARCODE_H */ diff --git a/kbarcode/gnubarkodeengine.cpp b/kbarcode/gnubarkodeengine.cpp new file mode 100644 index 0000000..486c453 --- /dev/null +++ b/kbarcode/gnubarkodeengine.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + gnubarkodeengine.cpp - description + ------------------- + begin : Fri Nov 05 2004 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "gnubarkodeengine.h" +#include <barcode.h> + +GnuBarkodeEngine::GnuBarkodeEngine() + : BarkodeEngine( "libbarcode.so" ) +{ +} + +void GnuBarkodeEngine::init() +{ + if( !m_loaded ) + { + (void*)Barcode_Create = dlsym(m_handle, "Barcode_Create"); + (void*)Barcode_Delete = dlsym(m_handle, "Barcode_Delete"); + (void*)Barcode_Encode = dlsym(m_handle, "Barcode_Encode"); + + m_loaded = true; + } +} + +GnuBarkodeEngine gnuBarkodeEngine; diff --git a/kbarcode/gnubarkodeengine.h b/kbarcode/gnubarkodeengine.h new file mode 100644 index 0000000..323553c --- /dev/null +++ b/kbarcode/gnubarkodeengine.h @@ -0,0 +1,46 @@ +/*************************************************************************** + gnubarkodeengine.h - description + ------------------- + begin : Fri Nov 05 2004 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef GNUBARKODEENGINE_H +#define GNUBARKODEENGINE_H + +#include <barkodeengine.h> + +struct Barcode_Item; + +/** + * Loads GNU Barcode lib dynamically when needed, + * so that KBarcode does not have to link against + * it and works even without lib gnu barcode. + * @author Dominik Seichter + */ +class GnuBarkodeEngine : public BarkodeEngine +{ + public: + GnuBarkodeEngine(); + + struct Barcode_Item* (*Barcode_Create)(char* text); + int (*Barcode_Delete)(struct Barcode_Item* bc); + int (*Barcode_Encode)(struct Barcode_Item *bc, int flags); + + + protected: + void init(); +}; + +extern GnuBarkodeEngine gnuBarkodeEngine; +#endif diff --git a/kbarcode/hi16-action-barcode.png b/kbarcode/hi16-action-barcode.png Binary files differnew file mode 100644 index 0000000..c238610 --- /dev/null +++ b/kbarcode/hi16-action-barcode.png diff --git a/kbarcode/hi16-action-kbarcodeellipse.png b/kbarcode/hi16-action-kbarcodeellipse.png Binary files differnew file mode 100644 index 0000000..ba683c3 --- /dev/null +++ b/kbarcode/hi16-action-kbarcodeellipse.png diff --git a/kbarcode/hi16-action-kbarcodegrid.png b/kbarcode/hi16-action-kbarcodegrid.png Binary files differnew file mode 100644 index 0000000..1bcbd32 --- /dev/null +++ b/kbarcode/hi16-action-kbarcodegrid.png diff --git a/kbarcode/hi16-action-kbarcodelinetool.png b/kbarcode/hi16-action-kbarcodelinetool.png Binary files differnew file mode 100644 index 0000000..80cd7e4 --- /dev/null +++ b/kbarcode/hi16-action-kbarcodelinetool.png diff --git a/kbarcode/hi16-app-kbarcode.png b/kbarcode/hi16-app-kbarcode.png Binary files differnew file mode 100644 index 0000000..08b115d --- /dev/null +++ b/kbarcode/hi16-app-kbarcode.png diff --git a/kbarcode/hi22-action-barcode.png b/kbarcode/hi22-action-barcode.png Binary files differnew file mode 100644 index 0000000..68db3b4 --- /dev/null +++ b/kbarcode/hi22-action-barcode.png diff --git a/kbarcode/hi32-action-barcode.png b/kbarcode/hi32-action-barcode.png Binary files differnew file mode 100644 index 0000000..5b4b3f3 --- /dev/null +++ b/kbarcode/hi32-action-barcode.png diff --git a/kbarcode/hi32-action-kbarcoderect.png b/kbarcode/hi32-action-kbarcoderect.png Binary files differnew file mode 100644 index 0000000..9c2768f --- /dev/null +++ b/kbarcode/hi32-action-kbarcoderect.png diff --git a/kbarcode/hi32-app-kbarcode.png b/kbarcode/hi32-app-kbarcode.png Binary files differnew file mode 100644 index 0000000..54facc9 --- /dev/null +++ b/kbarcode/hi32-app-kbarcode.png diff --git a/kbarcode/hi64-app-kbarcode.png b/kbarcode/hi64-app-kbarcode.png Binary files differnew file mode 100644 index 0000000..2f15c83 --- /dev/null +++ b/kbarcode/hi64-app-kbarcode.png diff --git a/kbarcode/imageitem.cpp b/kbarcode/imageitem.cpp new file mode 100644 index 0000000..139504f --- /dev/null +++ b/kbarcode/imageitem.cpp @@ -0,0 +1,307 @@ +/*************************************************************************** + imageitem.h - description + ------------------- + begin : Do Sep 9 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#include "imageitem.h" +#include "tokenprovider.h" + +#include <qbuffer.h> +#include <qdom.h> +#include <qimage.h> +#include <qpaintdevicemetrics.h> +#include <qpainter.h> + +#include <klocale.h> +#include <kmdcodec.h> + +ImageItem::ImageItem() + : DocumentItem() +{ + init(); +} + +ImageItem::~ImageItem() +{ +} + +void ImageItem::init() +{ + m_rotation = 0.0; + m_mirror_h = false; + m_mirror_v = false; + m_scaling = eImage_Original; + setBorder( false ); + + setRect( QRect( 0, 0, 20, 20 ) ); +} + +void ImageItem::draw(QPainter* painter) +{ + createImage(); + + painter->save(); + painter->drawPixmap( rect().x(), rect().y(), m_tmp ); + painter->restore(); + DocumentItem::drawBorder(painter); +} + +void ImageItem::drawZpl( QTextStream* stream ) +{ + createImage(); + + QBuffer buffer; + if( buffer.open( IO_WriteOnly ) ) + { + // TODO: bmp???? + QImageIO io( &buffer, "PNG" ); + QImage image = m_tmp.convertToImage(); + // create a black and white image + io.setImage( image.convertDepth( 1 ) ); + io.write(); + buffer.close(); + + QByteArray data = buffer.buffer(); + *stream << ZPLUtils::fieldOrigin( rect().x(), rect().y() ); + *stream << "~DYD,p,P," << QString::number( data.size() ) + ",0,"; + for( unsigned int i=0;i<data.size();i++) + *stream << data[i]; + } +} + +void ImageItem::drawIpl( QTextStream*, IPLUtils* ) +{ + qDebug("ImageItem is not implemented for IPL!"); +} + +void ImageItem::drawEPcl( QTextStream* stream ) +{ + createImage(); + + // you can access m_tmp (which is a QPixmap now) + // m_tmp is an image which has all transformations + // (i.e. rotation, scaling, flipping) already apllied + + QImage si = m_tmp.convertToImage(); + int width = si.width(); + int height = si.height(); + int c; + char out; + + for( int buf=0; buf < 3; buf++ ){ + *stream << QString("GS %1 32 %1 %1 %1 %1 ") + .arg(buf).arg(rect().x()).arg(rect().y()).arg(width).arg(height); + + for( int i=width-1; i >= 0; i-- ){ + for( int j=0; j < height; j++ ){ + if( buf == 0 ) + c = qBlue(si.pixel(i,j)); // Yellow + else if( buf == 1 ) + c = qGreen(si.pixel(i,j)); // Magenta + else if( buf == 2 ) + c = qRed(si.pixel(i,j)); // Cyan + + // printer has 5-bits per color - drop 3 + // we also need to subtract from 255 to convert from RGB to CMY + out = (0xff - c) >> 3; + *stream << out; + } + } + + *stream << "\r\n"; + } +} + +void ImageItem::loadXML(QDomElement* element) +{ + QByteArray out; + if( !element->text().isEmpty() ) + { + KCodecs::base64Decode( element->text().utf8(), out ); + m_pixmap.loadFromData( out, "PNG" ); + } + + m_expression = element->attribute( "expression", QString::null ); + m_scaling = (EImageScaling)element->attribute( "scaling", "0" ).toInt(); + m_mirror_h = (bool)element->attribute("mirror_horizontal", "0" ).toInt(); + m_mirror_v = (bool)element->attribute("mirror_vertical", "0" ).toInt(); + m_rotation = element->attribute("rotation", "0.0").toDouble(); + DocumentItem::loadXML(element); + + updateImage(); +} + +void ImageItem::saveXML(QDomElement* element) +{ + QBuffer buf; + if( !m_pixmap.isNull() ) + { + if(!buf.open( IO_WriteOnly )) + return; + + m_pixmap.save( &buf, "PNG" ); + buf.close(); + + element->appendChild( element->ownerDocument().createCDATASection( KCodecs::base64Encode( buf.buffer(), true ) ) ); + } + + element->setAttribute( "expression", m_expression ); + element->setAttribute( "scaling", (int)m_scaling ); + element->setAttribute( "mirror_horizontal", m_mirror_h ); + element->setAttribute( "mirror_vertical", m_mirror_v ); + element->setAttribute( "rotation", m_rotation ); + + DocumentItem::saveXML(element); +} + +void ImageItem::setExpression( const QString & ex ) +{ + m_expression = ex; + updateImage(); +} + +void ImageItem::setPixmap( const QPixmap & pix ) +{ + m_pixmap = pix; + updateImage(); +} + +const QPixmap & ImageItem::pixmap() +{ + return m_pixmap; +} + +void ImageItem::setScaling( EImageScaling scaling ) +{ + m_scaling = scaling; + updateImage(); +} + +EImageScaling ImageItem::scaling() const +{ + return m_scaling; +} + +void ImageItem::updateImage() +{ + m_tmp.resize( QSize(0,0) ); +} + +void ImageItem::createImage() +{ + if( m_tmp.isNull() ) + { + QImage img; + + if( m_pixmap.isNull() ) + img.load( tokenProvider() ? tokenProvider()->parse( m_expression ) : m_expression ); + else + img = m_pixmap.convertToImage(); + + if( !img.isNull() ) + { + if( m_rotation != 0.0 ) + { + QWMatrix matrix; + matrix.rotate( m_rotation ); + img = img.xForm( matrix ); + } + + // scale with high quality on the printer + // but use faster scaling for onscreen operations + if( m_scaling != eImage_Original ) + { + if( DocumentItem::paintDevice()->isExtDev() ) + img = img.smoothScale( rect().width(), rect().height(), + (m_scaling == eImage_Scaled ? QImage::ScaleMin : QImage::ScaleFree) ); + else + img = img.scale( rect().width(), rect().height(), + (m_scaling == eImage_Scaled ? QImage::ScaleMin : QImage::ScaleFree) ); + } + else + { + // we have to scale because of the bigger printer resolution + if( DocumentItem::paintDevice()->isExtDev() ) + { + QPaintDeviceMetrics metrics( DocumentItem::paintDevice() ); + + img = img.smoothScale( (int)(img.width() * ((double)metrics.logicalDpiX()/QPaintDevice::x11AppDpiX())), + (int)(img.height() * ((double)metrics.logicalDpiY()/QPaintDevice::x11AppDpiY())), + QImage::ScaleMin ); + } + } + + if( m_mirror_h || m_mirror_v ) + img = img.mirror( m_mirror_h, m_mirror_v ); + + m_tmp.convertFromImage( img ); + } + else + { + // The expression does not return a valid image path + // or the user did not specify a image to load + + // make sure that we do not get a 0 0 0 0 rectangle + QRect myrect( 0, 0, rect().width() ? rect().width() : 100 , rect().height() ? rect().height() : 80 ); + m_tmp.resize( rect().width(), rect().height() ); + + QPainter painter( &m_tmp ); + painter.fillRect( myrect, Qt::white ); + painter.setPen( QPen( Qt::red, 2 ) ); + painter.drawRect( myrect ); + painter.drawLine( 0, 0, myrect.width(), myrect.height() ); + painter.drawLine( 0, myrect.height(), myrect.width(), 0 ); + painter.setPen( Qt::black ); + painter.drawText( 0, painter.fontMetrics().lineSpacing(), i18n("Expression: ") + m_expression ); + painter.end(); + } + } +} + +void ImageItem::setRotation( double rot ) +{ + if( m_rotation <= 360.0 && m_rotation >= -360.0 ) + { + m_rotation = rot; + updateImage(); + } +} + +double ImageItem::rotation() const +{ + return m_rotation; +} + +void ImageItem::setMirrorHorizontal( bool b ) +{ + m_mirror_h = b; + updateImage(); +} + +bool ImageItem::mirrorHorizontal() const +{ + return m_mirror_h; +} + +void ImageItem::setMirrorVertical( bool b ) +{ + m_mirror_v = b; + updateImage(); +} + +bool ImageItem::mirrorVertical() const +{ + return m_mirror_v; +} diff --git a/kbarcode/imageitem.h b/kbarcode/imageitem.h new file mode 100644 index 0000000..d3f4194 --- /dev/null +++ b/kbarcode/imageitem.h @@ -0,0 +1,79 @@ +/*************************************************************************** + imageitem.h - description + ------------------- + begin : Do Sep 9 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ +#ifndef IMAGEITEM_H +#define IMAGEITEM_H + +#include "documentitem.h" + +#include <qpixmap.h> + +enum EImageScaling { eImage_Original = 0, eImage_Scaled, eImage_Zoomed }; + +/** +@author Dominik Seichter +*/ +class ImageItem : public DocumentItem +{ + public: + ImageItem(); + ~ImageItem(); + + void setExpression( const QString & ex ); + inline QString expression() const { return m_expression; }; + + void setPixmap( const QPixmap & pix ); + const QPixmap & pixmap(); + + void setScaling( EImageScaling scaling ); + EImageScaling scaling() const; + + void setRotation( double rot ); + double rotation() const; + + void setMirrorHorizontal( bool b ); + bool mirrorHorizontal() const; + + void setMirrorVertical( bool b ); + bool mirrorVertical() const; + + virtual int rtti() const { return eRtti_Image;} + virtual void draw(QPainter* painter); + virtual void drawZpl( QTextStream* stream ); + virtual void drawIpl( QTextStream* stream, IPLUtils* utils ); + virtual void drawEPcl( QTextStream* stream ); + virtual void loadXML(QDomElement* element); + virtual void saveXML(QDomElement* element); + + void updateImage(); + void createImage(); + + private: + void init(); + + private: + QString m_expression; + QPixmap m_pixmap; + QPixmap m_tmp; + + double m_rotation; + bool m_mirror_v; + bool m_mirror_h; + + EImageScaling m_scaling; +}; + +#endif diff --git a/kbarcode/kactionmap.cpp b/kbarcode/kactionmap.cpp new file mode 100644 index 0000000..7ef48ce --- /dev/null +++ b/kbarcode/kactionmap.cpp @@ -0,0 +1,188 @@ +/*************************************************************************** + kactionmap.cpp - description + ------------------- + begin : Fri Mai 19 2006 + copyright : (C) 2006 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kactionmap.h" + +#include <qimage.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qmenubar.h> +#include <qmenudata.h> +#include <qpixmap.h> +#include <qpopupmenu.h> +#include <qregexp.h> +#include <qvbox.h> + +#include <kaction.h> +#include <kapplication.h> +#include <klistview.h> +#if KDE_VERSION >= 0x030500 +#include <klistviewsearchline.h> +#endif +#include <klocale.h> + +class KListViewActionItem : public KListViewItem { +public: + KListViewActionItem( KListView* parent, KAction* action ) + : KListViewItem( parent ), m_action( action ) + { + QPixmap pix; + QSize size = QIconSet::iconSize( QIconSet::Large ); + QIconSet iconset = m_action->iconSet( KIcon::Panel, KIcon::SizeLarge ); + QRegExp regtag( "<[^>]*>" ); + + pix = iconset.pixmap( QIconSet::Large, QIconSet::Normal ); // m_action->isEnabled() ? QIconSet::Normal : QIconSet::Disabled ); + if( pix.isNull() ) + { + pix.resize( size ); + pix.fill( backgroundColor() ); + } + else + { + if( pix.size() != size ) + { + pix = pix.convertToImage().smoothScale( size ); + } + } + + setText( 0, m_action->plainText() ); + setText( 1, m_action->shortcutText() ); + // replace HTML tags in What's this help + setText( 2, m_action->whatsThis().replace( regtag, "" ) ); + setPixmap( 0, pix ); + } + + void paintCell( QPainter *p, const QColorGroup &cg, + int column, int width, int alignment ) + { + QColorGroup _cg( cg ); + QColor c = _cg.text(); + if( m_action && !m_action->isEnabled() ) + _cg.setColor( QColorGroup::Text, Qt::gray ); + + KListViewItem::paintCell( p, _cg, column, width, alignment ); + _cg.setColor( QColorGroup::Text, c ); + } + + inline KAction* action() const + { + return m_action; + } + +private: + KAction* m_action; +}; + +KActionMapDlg::KActionMapDlg( KActionCollection* actions, QWidget* parent, const char* name ) + : KDialogBase( parent, name, false, i18n("Action Map"), KDialogBase::Close, KDialogBase::Close ) +{ + QVBox *page = makeVBoxMainWidget(); + + new QLabel( i18n("Find and execute actions."), page ); + m_map = new KActionMap( actions, page ); + + show(); +} + +void KActionMapDlg::updateEnabledState() +{ + m_map->updateEnabledState(); +} + +KActionMap::KActionMap( KActionCollection* actions, QWidget* parent, const char* name ) + : QWidget( parent, name ), m_actions( actions ), m_showMenuTree( true ), m_grayOutItems( false ) +{ + QVBoxLayout* layout = new QVBoxLayout( this ); + + m_listView = new KListView( this ); +#if KDE_VERSION >= 0x030500 + m_searchLine = new KListViewSearchLineWidget( m_listView, this ); +#endif + + m_listView->addColumn( i18n("Action") ); + m_listView->addColumn( i18n("Shortcut") ); + m_listView->addColumn( i18n("Description") ); + m_listView->setColumnWidthMode( 0, QListView::Maximum ); + m_listView->setColumnWidthMode( 1, QListView::Maximum ); + m_listView->setColumnWidthMode( 2, QListView::Manual ); + m_listView->setSorting( 0 ); + m_listView->setAllColumnsShowFocus( true ); + +#if KDE_VERSION >= 0x030500 + layout->addWidget( m_searchLine ); +#endif + layout->addWidget( m_listView ); + + connect( m_listView, SIGNAL( executed( QListViewItem* ) ), this, SLOT( slotExecuteAction( QListViewItem* ) ) ); + connect( actions, SIGNAL( inserted( KAction* ) ), this, SLOT( slotActionCollectionChanged() ) ); + connect( actions, SIGNAL( removed( KAction* ) ), this, SLOT( slotActionCollectionChanged() ) ); + slotActionCollectionChanged(); +} + +KActionMap::~KActionMap() +{ + +} + +void KActionMap::slotActionCollectionChanged() +{ + KActionPtrList actions; + KActionPtrList::const_iterator it; + + m_listView->clear(); + + if( !m_actions ) + return; + + actions = m_actions->actions(); + it = actions.begin(); + + while( it != actions.end() ) + { + /* + if( m_showMenuTree ) + { + } + */ + + new KListViewActionItem( m_listView, (*it) ); + + connect( *it, SIGNAL( enabled(bool) ), this, SLOT( updateEnabledState() ) ); + + ++it; + } + +} + +void KActionMap::slotExecuteAction( QListViewItem* item ) +{ + KListViewActionItem* action = dynamic_cast<KListViewActionItem*>(item); + if( !action ) + return; + + if( !action->action()->isEnabled() ) + return; + + action->action()->activate(); +} + +void KActionMap::updateEnabledState() +{ + m_listView->repaintContents(); +} + +#include "kactionmap.moc" diff --git a/kbarcode/kactionmap.h b/kbarcode/kactionmap.h new file mode 100644 index 0000000..a8d687b --- /dev/null +++ b/kbarcode/kactionmap.h @@ -0,0 +1,101 @@ +/*************************************************************************** + kactionmap.h - description + ------------------- + begin : Fri Mai 19 2006 + copyright : (C) 2006 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef _KACTION_MAP_H_ +#define _KACTION_MAP_H_ + +#include <qwidget.h> +#include <kdeversion.h> +#include <kdialogbase.h> + +class KActionCollection; +class KActionMap; +#if KDE_VERSION >= 0x030500 +class KListViewSearchLineWidget; +#endif +class KListView; +class QListViewItem; + +/** Open a simple dialog containing an action map. + */ +class KActionMapDlg : public KDialogBase { + public: + KActionMapDlg( KActionCollection* actions, QWidget* parent = NULL, const char* name = NULL ); + + /** Call this function whenever you changed the enabled/disalbed state of an action + * in your application. + */ + void updateEnabledState(); + + private: + KActionMap* m_map; +}; + +/** + * + * This class is an implementation of an Action Map for KDE. + * + * + * What is an Action Map? + * + * Almost every web page has a site map. According to Wikipedia, + * a site map "helps visitors, and search engine robots, to find + * pages on the site". Similar an Action Map should help the + * user to find actions (i.e. functions or menu items) in an application. + * + * More concrete an Action Map is a dialog with a list of all + * actions (i.e. make text bold, save file or insert image) + * that can be performed in the application at its current state. + * Additionally there is a search box at the top of the list so + * that the user can search the list easily for a special action. + * The action is executed by clicking on it. Disabled actions are + * grayed out and cannot be clicked. The dialog is modeless so that + * it can always be open and the normal usage of the application is not disturbed. + */ +class KActionMap : public QWidget { + Q_OBJECT + public: + /** Creates a new KActionMap widget + * @param action all actions from this KActionCollection are displayed. + * @param parent the parent + * @param name the name + */ + KActionMap( KActionCollection* actions, QWidget* parent = NULL, const char* name = NULL ); + ~KActionMap(); + + public slots: + /** Call this function whenever you changed the enabled/disalbed state of an action + * in your application. + */ + void updateEnabledState(); + + private slots: + void slotActionCollectionChanged(); + void slotExecuteAction( QListViewItem* item ); + + private: + KActionCollection* m_actions; + KListView* m_listView; +#if KDE_VERSION >= 0x030500 + KListViewSearchLineWidget* m_searchLine; +#endif + + bool m_showMenuTree; + bool m_grayOutItems; +}; + +#endif // _KACTION_MAP_H_ diff --git a/kbarcode/kbarcode-batch.desktop b/kbarcode/kbarcode-batch.desktop new file mode 100644 index 0000000..dc67d1b --- /dev/null +++ b/kbarcode/kbarcode-batch.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Application +Exec=kbarcode --batch +Icon=kbarcode.png +DocPath=kbarcode/index.html +Comment=Barcode and label printing tool (batch printing mode) +Comment[de]=Werkzeug zum Barcode und Etiketten Druck (Stapelverarbeitung) +Terminal=false +Name=KBarcode Batch Printing +Name[de]=KBarcode Batch Druck +Categories=Qt;KDE;Office; diff --git a/kbarcode/kbarcode-editor.desktop b/kbarcode/kbarcode-editor.desktop new file mode 100644 index 0000000..1b47d01 --- /dev/null +++ b/kbarcode/kbarcode-editor.desktop @@ -0,0 +1,14 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Application +Exec=kbarcode --label +Icon=kbarcode.png +DocPath=kbarcode/index.html +Comment=Barcode and label printing tool (editor) +Comment[de]=Werkzeug zum Barcode und Etiketten Druck (Editor) +Terminal=false +Name=KBarcode Label Editor +Name[de]=KBarcode Label Editor +Categories=Qt;KDE;Office; + + diff --git a/kbarcode/kbarcode-label.desktop b/kbarcode/kbarcode-label.desktop new file mode 100644 index 0000000..d90caef --- /dev/null +++ b/kbarcode/kbarcode-label.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=MimeType +Comment=KBarcode Label +Encoding=UTF-8 +Icon=kbarcode +MimeType=application/kbarcode-label +Name[de]=kbarcode-label.desktop +Patterns=*.kbarcode;*.KBARCODE; + diff --git a/kbarcode/kbarcode-single.desktop b/kbarcode/kbarcode-single.desktop new file mode 100644 index 0000000..22e9880 --- /dev/null +++ b/kbarcode/kbarcode-single.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Application +Exec=kbarcode --barcode +Icon=kbarcode.png +DocPath=kbarcode/index.html +Comment=Barcode generation tool +Comment[de]=Barcode Erstellung +Terminal=0 +Name=KBarcode Barcode Generator +Name[de]=KBarcode Barcode Generator +Categories=Qt;KDE;Office; diff --git a/kbarcode/kbarcode.cpp b/kbarcode/kbarcode.cpp new file mode 100644 index 0000000..773c975 --- /dev/null +++ b/kbarcode/kbarcode.cpp @@ -0,0 +1,292 @@ +/*************************************************************************** + kbarcode.cpp - description + ------------------- + begin : Mit Jan 15 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kbarcode.h" +#include "barkode.h" +#include "barcodedialog.h" +#include "batchwizard.h" +#include "labeleditor.h" +#include "databasebrowser.h" +#include "csvimportdlg.h" +#include "sqltables.h" +#include "kbarcodesettings.h" + +// Qt includes +#include <qgroupbox.h> +#include <qlayout.h> + +// KDE includes +#include <kaction.h> +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kpopupmenu.h> +#include <kpushbutton.h> +#include <kmessagebox.h> + +KBarcode::KBarcode( QWidget *parent, const char *name, WFlags f) + : DCOPObject("KBarcode"), + DSMainWindow( parent, name, f ) +{ + QGroupBox* w = new QGroupBox( this ); + w->setColumnLayout(0, Qt::Vertical ); + QVBoxLayout* layout = new QVBoxLayout( w->layout() ); + setCentralWidget( w ); + + buttonSingle = new KPushButton( i18n("Barcode &Generator..."), w ); + buttonSingle->setEnabled( Barkode::haveBarcode() ); + buttonEditor = new KPushButton( i18n("&Label Editor..."), w ); + buttonBatch = new KPushButton( i18n("&Batch Printing..."), w ); + buttonData = new KPushButton( i18n("Edit SQL &Tables..."), w ); + buttonData->setEnabled( false ); + + buttonSingle->setIconSet( BarIconSet( "barcode" ) ); + buttonEditor->setIconSet( BarIconSet( "edit" ) ); + buttonBatch->setIconSet( BarIconSet( "fileprint" ) ); + + layout->addWidget( buttonSingle ); + layout->addWidget( buttonEditor ); + layout->addWidget( buttonBatch ); + layout->addWidget( buttonData ); + + connect( buttonSingle, SIGNAL( clicked() ), this, SLOT( startBarcode() ) ); + connect( buttonEditor, SIGNAL( clicked() ), this, SLOT( startLabelEditor() ) ); + connect( buttonBatch, SIGNAL( clicked() ), this, SLOT( startBatchPrint() ) ); + connect( SqlTables::getInstance(), SIGNAL( connectedSQL() ), this, SLOT( enableData() ) ); + + setupActions(); + show(); + + KAction* editLabelDefAct = new KAction(i18n("&Edit Label Definitions"), "", + 0, this, SLOT(editLabelDef()), actionCollection(), "design" ); + + KAction* editArticleAct = new KAction(i18n("&Edit Articles"), "", + 0, this, SLOT(editArticles()), actionCollection(), "design" ); + + KAction* editCustomerAct = new KAction(i18n("&Edit Customers"), "", + 0, this, SLOT(editCustomers()), actionCollection(), "design" ); + + KAction* editCustomerTextAct = new KAction(i18n("&Edit Customer Text"), "", + 0, this, SLOT(editCustomerText()), actionCollection() ); + + KAction* importCSVAct = new KAction(i18n("&Import CSV File..."), "", + 0, this, SLOT(importCSV()), actionCollection() ); + + KPopupMenu* data = new KPopupMenu( buttonData ); + editLabelDefAct->plug( data ); + editArticleAct->plug( data ); + editCustomerAct->plug( data ); + editCustomerTextAct->plug( data ); + buttonData->setPopup( data ); + data->insertSeparator(); + importCSVAct->plug( data ); + + enableData(); +} + +KBarcode::~KBarcode() +{ + DSMainWindow::saveConfig(); +} + +void KBarcode::setupActions() +{ + DSMainWindow::setupActions(); +} + +void KBarcode::startBarcode() +{ + new BarCodeDialog(); +} + +void KBarcode::startLabelEditor() +{ + LabelEditor* ed = new LabelEditor( NULL, QString::null, "LabelEditorWindow" ); + ed->startupDlg( LabelEditor::eCreateNewLabel, QString::null ); +} + +void KBarcode::startBatchPrint() +{ + new BatchWizard( this ); +} + +void KBarcode::editArticles() +{ + new DatabaseBrowser( TABLE_BASIC, NULL, "basicbrowser" ); +} + +void KBarcode::editCustomers() +{ + new DatabaseBrowser( TABLE_CUSTOMER, NULL, "customerbrowser" ); +} + +void KBarcode::editCustomerText() +{ + new DatabaseBrowser( TABLE_CUSTOMER_TEXT, NULL, "customertextbrowser" ); +} + +void KBarcode::editLabelDef() +{ + new DatabaseBrowser( TABLE_LABEL_DEF, NULL, "defbrowser" ); +} + +void KBarcode::enableData() +{ + buttonData->setEnabled( SqlTables::getInstance()->isConnected() ); +} + +bool KBarcode::parseCmdLine() +{ + enum { BARCODE, LABEL, BATCH, NONE } mode = NONE; + + KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); + + BatchPrinter::EOutputFormat eFormat = BatchPrinter::POSTSCRIPT; + LabelEditor* pEdit = NULL; + QString serial; + QString sqlquery = QString::null; + QString csvfile = QString::null; + QString printer = QString::null; + + bool bPrintNow = args->isSet("print"); + int serialinc = 0; + int numlabels = -1; + + QString format = args->getOption("output"); + if( format.upper() == "BARCODE" ) + eFormat = BatchPrinter::BCP; + else if( format.upper() == "IMAGE" ) + eFormat = BatchPrinter::IMAGE; + else if( format.upper() == "POSTSCRIPT" ) + eFormat = BatchPrinter::POSTSCRIPT; + else + { + KMessageBox::error( this, i18n("%1 is no valid output format for --output. Valid values are POSTSCRIPT, IMAGE and BARCODE.").arg( format ) ); + } + + if( args->isSet("barcode") ) + { + mode = BARCODE; + startBarcode(); + } + + if( args->isSet("batch") ) + mode = BATCH; + + if( args->isSet("label") ) + mode = LABEL; + + if( args->isSet("serialnumber") ) + { + serial = args->getOption("serialnumber"); + if( args->isSet("serialinc") ) + serialinc = args->getOption("serialinc").toInt(); + } + + if( args->isSet("numlabels") ) + numlabels = args->getOption("numlabels").toInt(); + + if( args->isSet("importsql") ) + sqlquery = args->getOption("importsql"); + + if( args->isSet("importcsv") ) + csvfile = args->getOption("importcsv"); + + if( args->isSet("printer") ) + printer = args->getOption("printer"); + + for( int i = 0; i < args->count(); i++) + if( mode == BATCH ) + { + BatchWizard* b = new BatchWizard(); + b->setFilename( args->url( i ).path() ); + b->setOutputFormat( eFormat ); + b->setSerialNumber( serial, serialinc ); + if( !sqlquery.isEmpty() ) + b->setImportSqlQuery( sqlquery ); + + if( !csvfile.isEmpty() ) + b->setImportCsvFile( csvfile ); + + if( numlabels != -1 ) + b->setNumLabels( numlabels ); + + if( bPrintNow ) + { + b->printNow( printer, false ); + delete b; + } + } + else + { + pEdit = new LabelEditor( 0, args->url( i ).path() ); + if( bPrintNow ) + // TODO: use the printer set by the printer commandline option + pEdit->print(); + } + + if( !args->count() && mode == LABEL ) + { + pEdit = new LabelEditor(); + if( bPrintNow ) + // TODO: use the printer set by the printer commandline option + pEdit->print(); + + } + + int argc = args->count(); + args->clear(); // Free some memory + + // close after printing + if( bPrintNow && argc ) + { + // TODO: really close the whole application + this->close(); + return true; + } + else + return false; +} + +void KBarcode::importCSV() +{ + new CSVImportDlg( this, "csvimportdlg" ); +} + +bool KBarcode::isSQLConnected() const +{ + return SqlTables::isConnected(); +} + +bool KBarcode::connectSQL() +{ + return SqlTables::getInstance()->connectMySQL(); +} + +void KBarcode::showWizard() +{ + DSMainWindow::wizard(); +} + +void KBarcode::showConfigure() +{ + KBarcodeSettings::getInstance()->configure(); +} + + +#include "kbarcode.moc" diff --git a/kbarcode/kbarcode.desktop b/kbarcode/kbarcode.desktop new file mode 100644 index 0000000..7a10cc1 --- /dev/null +++ b/kbarcode/kbarcode.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Application +Exec=kbarcode -caption "%c" %i %m %f +Icon=kbarcode.png +MimeType=application/kbarcode-label +DocPath=kbarcode/index.html +Comment=Barcode and label printing tool +Comment[de]=Werkzeug zum Barcode und Etiketten Druck +Terminal=0 +Name=KBarcode +Name[de]=KBarcode +Categories=Qt;KDE;Office; diff --git a/kbarcode/kbarcode.h b/kbarcode/kbarcode.h new file mode 100644 index 0000000..f00c6d8 --- /dev/null +++ b/kbarcode/kbarcode.h @@ -0,0 +1,98 @@ +/*************************************************************************** + kbarcode.h - description + ------------------- + begin : Don Apr 18 12:34:56 CEST 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KBARCODE_H +#define KBARCODE_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <qstring.h> + +enum linebreak { + NO_BREAK, + LINE_BREAK, + LABEL_X, + NEW_PAGE, + ARTICLE_GROUP_NO +}; + +#include "dsmainwindow.h" +#include "kbarcodeiface.h" + +class KAction; +class KPushButton; +/** The main window of KBarcode. All submodules + * are started from here. Submodules are the LabelEditor + * LabelPrinter (Batchprinting), DatabaseBrowser and BarcodeDialog. + * There are also a few smaller modules. + */ +class KBarcode: public DSMainWindow, public KBarcodeIface { + Q_OBJECT + public: + KBarcode( QWidget *parent=0, const char *name="kbarcode", WFlags f = WType_TopLevel | WDestructiveClose ); + ~KBarcode(); + + /** Parse all commandline options and start batchprinting + * if necessary. + * \returns true if the application should exit after this function + */ + bool parseCmdLine(); + + private slots: + void startBarcode(); + void startLabelEditor(); + void startBatchPrint(); + + void editArticles(); + void editCustomers(); + void editCustomerText(); + void editLabelDef(); + + void enableData(); + + void importCSV(); + + private: + void setupActions(); + + /** allow the DCOP interface + * to check for an SQL connection. + */ + bool isSQLConnected() const; + /** allow the DCOP interface + * to connect to the databases. + */ + bool connectSQL(); + /** allow DCOP interface + * to start the configuration wizard. + */ + void showWizard(); + /** show preferences from DCOP. + */ + void showConfigure(); + + + KAction* connectAct; + KPushButton* buttonSingle; + KPushButton* buttonEditor; + KPushButton* buttonBatch; + KPushButton* buttonData; +}; + +#endif diff --git a/kbarcode/kbarcodeiface.h b/kbarcode/kbarcodeiface.h new file mode 100644 index 0000000..b53f260 --- /dev/null +++ b/kbarcode/kbarcodeiface.h @@ -0,0 +1,46 @@ +/*************************************************************************** + kbarcodeiface.h - description + ------------------- + begin : Sat Dec 27 23:53:28 CET 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KBARCODEIFACE_H +#define KBARCODEIFACE_H + +#include <dcopobject.h> + +class KBarcodeIface : virtual public DCOPObject +{ + K_DCOP + + public: + k_dcop: + virtual void startBarcode() = 0; + virtual void startLabelEditor() = 0; + virtual void startBatchPrint() = 0; + + virtual void editArticles() = 0; + virtual void editCustomers() = 0; + virtual void editCustomerText() = 0; + virtual void editLabelDef() = 0; + + virtual void importCSV() = 0; + + virtual bool isSQLConnected() const = 0; + virtual bool connectSQL() = 0; + virtual void showWizard() = 0; + virtual void showConfigure() = 0; +}; + +#endif /* KBARCODEIFACE_H */ diff --git a/kbarcode/kbarcodesettings.cpp b/kbarcode/kbarcodesettings.cpp new file mode 100644 index 0000000..aaa33d0 --- /dev/null +++ b/kbarcode/kbarcodesettings.cpp @@ -0,0 +1,106 @@ +/*************************************************************************** + kbarcodesettings.h - description + ------------------- + begin : Sat Jan 10 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kbarcodesettings.h" +#include "configdialog.h" +#include "sqltables.h" +#include "printersettings.h" + +// KDE includes +#include <kapplication.h> +#include <kcolorbutton.h> +#include <kconfig.h> +#include <klineedit.h> +#include <knuminput.h> + +// QT includes +#include <qcheckbox.h> + +KBarcodeSettings* KBarcodeSettings::m_instance = 0; +int KBarcodeSettings::gridsize = 30; +bool KBarcodeSettings::newdlg = true; +QColor KBarcodeSettings::gridcolor = Qt::black; +QString KBarcodeSettings::dateFormat = ""; + +KBarcodeSettings* KBarcodeSettings::getInstance() +{ + if( !m_instance ) + m_instance = new KBarcodeSettings(); + + return m_instance; +} + +KBarcodeSettings::KBarcodeSettings() +{ + +} + +KBarcodeSettings::~KBarcodeSettings() +{ + +} + +void KBarcodeSettings::saveConfig() +{ + KConfig* config = kapp->config(); + + config->setGroup("LabelEditor"); + config->writeEntry("grid", gridsize ); + config->writeEntry("gridcolor", gridcolor ); + config->writeEntry("AskNewDlg", newdlg ); + config->writeEntry("DateFormat", dateFormat ); +} + +void KBarcodeSettings::loadConfig() +{ + KConfig* config = kapp->config(); + + QColor tmpc( Qt::lightGray ); + config->setGroup("LabelEditor"); + gridsize = config->readNumEntry("grid", 5); + gridcolor = config->readColorEntry("gridcolor", &tmpc ); + newdlg = config->readBoolEntry("AskNewDlg", true ); + dateFormat = config->readEntry("DateFormat", "dd-MM-yyyy" ); +} + +void KBarcodeSettings::configure() +{ + ConfigDialog* cd = new ConfigDialog( 0 ); + cd->spinGrid->setValue( gridsize ); + cd->colorGrid->setColor( gridcolor ); + cd->checkNewDlg->setChecked( newdlg ); + cd->date->setText( dateFormat ); + if( cd->exec() == QDialog::Accepted ) { + PrinterSettings::getInstance()->saveConfig(); + SqlTables::getInstance()->saveConfig(); + + int oldgrid = gridsize; + QColor oldcolor = gridcolor; + gridsize = cd->spinGrid->value(); + gridcolor = cd->colorGrid->color(); + // gridsize or gridcolor has been changed + if( oldgrid != gridsize || oldcolor != gridcolor ) + emit updateGrid( gridsize ); + + newdlg = cd->checkNewDlg->isChecked(); + dateFormat = cd->date->text(); + + saveConfig(); + } +} + +#include "kbarcodesettings.moc" diff --git a/kbarcode/kbarcodesettings.h b/kbarcode/kbarcodesettings.h new file mode 100644 index 0000000..7a4cfea --- /dev/null +++ b/kbarcode/kbarcodesettings.h @@ -0,0 +1,65 @@ +/*************************************************************************** + kbarcodesettings.h - description + ------------------- + begin : Sat Jan 10 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KBARCODESETTINGS_H +#define KBARCODESETTINGS_H + +#include <qobject.h> + +/** + A singleton which is responsible for loading and saving KBarcodes settings. + It emits also signals when some properties change. + + @author Dominik Seichter +*/ +class KBarcodeSettings : public QObject +{ + Q_OBJECT + public: + static KBarcodeSettings* getInstance(); + + static const QString getDateFormat() { + return dateFormat; + } + + int gridSize() const { return gridsize; } + const QColor & gridColor() const { return gridcolor; } + bool newDialog() const { return newdlg; } + public slots: + void loadConfig(); + void saveConfig(); + void configure(); + + signals: + /** Emitted when the user changes the grid size + */ + void updateGrid( int ); + + private: + KBarcodeSettings(); + ~KBarcodeSettings(); + + static KBarcodeSettings* m_instance; + + // LabelEditor settings: + static int gridsize; + static bool newdlg; + static QColor gridcolor; + static QString dateFormat; +}; + +#endif diff --git a/kbarcode/label.cpp b/kbarcode/label.cpp new file mode 100644 index 0000000..2537fcb --- /dev/null +++ b/kbarcode/label.cpp @@ -0,0 +1,303 @@ +/*************************************************************************** + label.cpp - description + ------------------- + begin : Mon Apr 29 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "label.h" +#include "measurements.h" +#include "kbarcode.h" +#include "printersettings.h" +#include "sqltables.h" +#include "documentitem.h" +#include "barcodeitem.h" +#include "rectitem.h" +#include "lineitem.h" +#include "imageitem.h" +#include "textitem.h" + +// Qt includes +#include <qimage.h> +#include <qiodevice.h> +#include <qpaintdevicemetrics.h> +#include <qpainter.h> +#include <qpen.h> +#include <qsqlcursor.h> +#include <qxml.h> + +// KDE includes +#include <kapplication.h> +#include <klocale.h> +#include <kprinter.h> + +Label::Label( Definition* _def, QIODevice* device, QString labelname, QPaintDevice* _printer, QString customer_id, QString _article_no, QString _group ) + : TokenProvider( _printer ) +{ + m_sequence = false; + m_printer = _printer; + + setCustomerNo( customer_id ); + setArticleNo( _article_no ); + setGroup( _group ); + setLabelName( labelname.right( labelname.length() - labelname.findRev( "/" ) - 1 ) ); + + d = _def; + + load( device ); +} + +Label::Label( Definition* _def, QIODevice* device, QString labelname, QPaintDevice* _printer ) + : TokenProvider( _printer ) +{ + m_sequence = false; + m_printer = _printer; + + setLabelName( labelname.right( labelname.length() - labelname.findRev( "/" ) - 1 ) ); + + d = _def; + + load( device ); +} + +Label::~Label() +{ +} + +void Label::epcl( QTextStream* stream ) +{ + *stream << EPCLUtils::header(); + + DocumentItem* item; + for( item = m_list.first();item;item=m_list.next()) + if( drawThisItem( item ) ) + item->drawEPcl( stream ); + + *stream << EPCLUtils::footer(); +} + +void Label::ipl( QTextStream* stream ) +{ + IPLUtils utils; + *stream << utils.header(); + + DocumentItem* item; + for( item = m_list.first();item;item=m_list.next()) + if( drawThisItem( item ) ) + item->drawIpl( stream, &utils ); + + *stream << utils.footer(); +} + + +void Label::zpl( QTextStream* stream ) +{ + *stream << ZPLUtils::header(); + + DocumentItem* item; + for( item = m_list.first();item;item=m_list.next()) + if( drawThisItem( item ) ) + item->drawZpl( stream ); + + *stream << ZPLUtils::footer(); +} + +void Label::InitBarcodes() +{ + bool firstbarcode = true; + + DocumentItem* item; + for( item = m_list.first();item;item=m_list.next()) + { + if( item->rtti() == eRtti_Barcode ) + { + /* + TODO: I am not sure wether this should be done + if( !drawThisItem( item ) ) + continue; + */ + + BarcodeItem* bc = static_cast<BarcodeItem*>(item); + bc->setIndex( index() ); + setBarcodeValue( bc ); + bc->updateBarcode(); + + if( firstbarcode ) + { + // set some values of the first barcode + firstbarcode = false; + + m_sequence = bc->sequenceEnabled() || m_sequence; + setBarcodeNo( bc->parsedValue() ); + setEncodingTypeName( bc->type() ); + } + } + } + + updateDone(); +} + +void Label::draw( QPainter* painter, int x, int y ) +{ + QSize label( (int)d->getMeasurements().width( painter->device() ), + (int)d->getMeasurements().height( painter->device() ) ); + + InitBarcodes(); + + DocumentItem* item; + for( item = m_list.first();item;item=m_list.next()) + if( drawThisItem( item ) ) + { + // add x and y to clip coordinates + // as clip has its top left corner + // at (0,0) + QRect clip( item->boundingRect() ); + if( x + clip.x() < x ) + clip.setX( 0 ); + + if( y + clip.y() < y ) + clip.setY( 0 ); + + if( clip.x() + clip.width() > label.width() ) + clip.setWidth( label.width() - clip.x() ); + + if( clip.y() + clip.height() > label.height() ) + clip.setHeight( label.height() - clip.y() ); + + painter->save(); + painter->translate( x,y ); + painter->setClipRect( clip, QPainter::CoordPainter ); + item->draw( painter ); + painter->restore(); + } +} + +void Label::setBarcodeValue( Barkode* barcode ) +{ + // use the same i18n() for static as in BarcodeSettingsDlg + if( barcode->databaseMode().lower() != "static" && barcode->databaseMode().lower() != i18n("Static") ) + { + QString encoding_type = getTypeFromCaption( barcode->databaseMode() ); + QString mode = getModeFromCaption( barcode->databaseMode() ); + + QSqlQuery query( "select barcode_no, encoding_type from " TABLE_BASIC + " where article_no = '" + articleNo() + "'" ); + while ( query.next() ) + { + barcode->setValue( query.value(0).toString() ); + barcode->setType( query.value(1).toString() ); + } + + if( mode.lower() != "main" ) + { + QSqlQuery query1( "select barcode_no from " TABLE_CUSTOMER_TEXT " where customer_no ='"+ mode + + "' and article_no='" + articleNo() + "'" ); + while ( query1.next() ) + { + if( !query1.value(0).toString().isEmpty() ) + { + barcode->setValue( query.value(0).toString() ); + barcode->setType( encoding_type ); + } + } + } + } +} + +void Label::load( QIODevice* device ) +{ + if( !device ) return; + + if( !device->isOpen() ) + device->open( IO_ReadOnly ); + + QDomDocument doc( "KBarcodeLabel" ); + doc.setContent( device ); + + bool kbarcode18; + QString description; + Definition* definition = NULL; + readXMLHeader( &doc, description, kbarcode18, &definition ); + delete definition; + + readDocumentItems( &m_list, &doc, NULL, kbarcode18 ); + m_list.setAutoDelete( true ); + + // sort the list by z index + m_list.sort(); + + DocumentItem* item; + for( item = m_list.first();item;item=m_list.next()) + { + // set the paint device for all items + item->setPaintDevice( m_printer ); + item->setTokenProvider( this ); + } + + device->close(); +} + +void Label::getXLabel( double x, double y, double width, double height, QPainter* painter, int mode, QString value ) +{ + painter->save(); + if( mode == LABEL_X ) { + painter->setPen( QPen( Qt::black, 5) ); + painter->drawLine( (int)x, (int)y, int(x+width), int(y+height) ); + painter->drawLine( (int)x, int(y+height), int(x+width), (int)y ); + } else if( mode == ARTICLE_GROUP_NO ) { + painter->setPen( QPen( QPen::black, 1 ) ); + QFont f( "helvetica", 15 ); + int w = 0; + do { + f.setPointSize( f.pointSize() - 1 ); + painter->setFont( f ); + w = painter->fontMetrics().width( value ); + } while( w > width && f.pointSize() > 0 ); + + painter->drawText( int(x + (width-w)/2), int(y + (height-f.pointSize())/2), value); + } + + painter->restore(); + return; +} + +int Label::getId() const +{ + if( d ) + return d->getId(); + + return -1; +}; + +bool Label::drawThisItem( const DocumentItem* item ) +{ + QString script = item->visibilityScript(); + + // make things go faster if the script is just "true" + if( script.isEmpty() || script == "true" ) + return true; + + script = parse( script ); + + return jsParseToBool( script ); +} + +bool Label::update() +{ + DocumentItem* item; + for( item = m_list.first();item;item=m_list.next()) + if( !item->visibilityScript().isEmpty() && item->visibilityScript() != "true" ) + return true; + + return TokenProvider::update(); +} diff --git a/kbarcode/label.h b/kbarcode/label.h new file mode 100644 index 0000000..698b861 --- /dev/null +++ b/kbarcode/label.h @@ -0,0 +1,77 @@ +/*************************************************************************** + label.h - description + ------------------- + begin : Mon Apr 29 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef LABEL_H +#define LABEL_H + +#include <qfont.h> +#include <qpicture.h> +#include "labelutils.h" +#include "xmlutils.h" +#include "definition.h" +#include "tokenprovider.h" + +class BarCode; +class Barkode; +class QDomDocument; +class QIODevice; +class QString; +class QPainter; +class QPaintDevice; +class QTextStream; +class KPrinter; +/** Creates a QPicture from the XML KBarcode file. If a SQL connections is available + * the data from the SQL tables will be used, too. + */ +class Label : private LabelUtils, private XMLUtils, public TokenProvider { + public: + Label( Definition* _def, QIODevice* device, QString labelname, QPaintDevice* _printer, QString customer_id, QString _article_no, QString _group = "" ); + Label( Definition* _def, QIODevice* device, QString labelname, QPaintDevice* _printer ); + ~Label(); + + void epcl( QTextStream* stream ); + void ipl( QTextStream* stream ); + void zpl( QTextStream* stream ); + + void draw( QPainter* painter,int x, int y ); + + int getId() const; + static void getXLabel( double x, double y, double width, double height, QPainter* painter, int mode, QString value = "" ); + + //void setPrinter( KPrinter* p ) { m_printer = p; } + + /** reimplemented from TokenProvider + * returns wether this label has to be regenerated everytime + */ + bool update(); + + private: + void load( QIODevice* device ); + void setBarcodeValue( Barkode* barcode ); + void InitBarcodes(); + bool drawThisItem( const DocumentItem* item ); + + protected: + DocumentItemList m_list; + + Definition* d; + QPaintDevice* m_printer; + + bool m_sequence; +}; + +#endif diff --git a/kbarcode/labeldefinitions.sql b/kbarcode/labeldefinitions.sql new file mode 100644 index 0000000..5f022a3 --- /dev/null +++ b/kbarcode/labeldefinitions.sql @@ -0,0 +1,1710 @@ +INSERT INTO label_def VALUES (1,'Avery A4','C2050 Video Spine','S',18.43,31.34,20.0,147.32,20.0,147.32,1,13, NULL, NULL ) +INSERT INTO label_def VALUES (2,'Avery A4','C2050 Video Face','S',8.72,24.99,46.57,78.74,46.57,81.28,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (3,'Avery A4','C2070 Transfer Film for Mouse Pad','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (4,'Avery A4','C2080 Transfer Film for Puzzle','S',20.0,26.0,170.0,245.0,170.0,245.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (5,'Avery A4','C2090 T-Shirt Transfer Set','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (6,'Avery A4','C2160 Avery Inkjet Label','S',15.15,7.2,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (7,'Avery A4','C2163 Avery Inkjet Label','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (8,'Avery A4','C2165 Large Labels','S',13.04,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (9,'Avery A4','C2166 Avery 3.5\" Disk Label (Face only)','S',33.6,31.9,52.0,70.0,59.27,76.2,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (10,'Avery A4','C2241 Avery Rectangle Sticker','S',37.38,26.26,31.75,76.2,38.1,81.28,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (11,'Avery A4','C2243 Avery Small Round Sticker','S',27.85,22.05,38.1,38.1,50.8,42.6,4,5, NULL, NULL ) +INSERT INTO label_def VALUES (12,'Avery A4','C2244 Avery Big Round Sticker','S',33.81,29.66,71.95,71.95,78.72,78.74,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (13,'Avery A4','C2246 Avery Full Page Sticker','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (14,'Avery A4','C2265 Disk Labels','S',21.43,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (15,'Avery A4','C2341 Embossed Cards A5 (Cover)','S',20.0,168.5,170.0,108.5,170.0,108.5,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (16,'Avery A4','C2341 Embossed Cards A5 (Inside)','S',0.0,148.5,210.0,148.5,210.0,148.5,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (17,'Avery A4','C2342 Embossed cards A6 (Coverl)','S',14.0,119.0,120.5,77.0,148.5,77.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (18,'Avery A4','C2342 Embossed Cards A6 (Inside)','S',0.0,105.0,148.5,105.0,148.5,105.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (19,'Avery A4','C2351 Avery A5 Greeting Card','S',0.0,0.0,210.0,148.5,210.0,148.5,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (20,'Avery A4','C2352 Avery A6 Greeting Card','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (21,'Avery A4','C2353 Avery Postcard','S',31.75,31.75,110.4,146.5,123.1,146.5,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (22,'Avery A4','C2354 Avery Biz Card','S',34.27,22.5,50.8,80.37,59.22,85.13,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (23,'Avery A4','C2355 Avery Note Cards','S',25.4,22.45,120.72,82.55,125.48,82.55,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (24,'Avery A4','C2356 Avery Full Page Card','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (25,'Avery A4','C2357 Compliment Cards','S',0.0,0.0,99.0,210.0,99.0,210.0,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (26,'Avery A4','C2361 Greeting Cards (A6)','S',0.0,0.0,148.0,105.0,148.0,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (27,'Avery A4','C2364 Marbled Business Cards','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (28,'Avery A4','C2365 Marbled Business Cards','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (29,'Avery A4','C2366 Marbled Business Cards','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (30,'Avery A4','C2367 Marbled Business Cards','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (31,'Avery A4','C2370 A4 Coated Paper -110gsm','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (32,'Avery A4','C2371 A4 Coated Paper -160gsm','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (33,'Avery A4','C2374 Marbled Paper','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (34,'Avery A4','C2375 Marbled Paper','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (35,'Avery A4','C2376 Marbled Paper','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (36,'Avery A4','C2377 Marbled Paper','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (37,'Avery A4','C2378 A4 Colour Laser Paper','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (38,'Avery A4','C2379 A4 Bright White','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (39,'Avery A4','C2410 Avery Self-Laminating Card','S',30.5,107.0,50.0,81.5,93.0,81.5,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (40,'Avery A4','C2420 Avery Self-Laminating Bookmark','S',16.0,30.0,178.0,38.0,178.0,89.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (41,'Avery A4','C2546 Windows Decals','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (42,'Avery A4','C2547 Fantastic Plastic','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (43,'Avery A4','C2651 Avery Inkjet Mini Label','S',10.9,4.67,21.17,38.1,21.17,40.64,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (44,'Avery A4','C6353 Photo Quality Gloss 4 x 6 Cards','S',0.0,0.0,101.6,152.4,101.6,152.4,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (45,'Avery A4','C9146 Photo Quality Label (Full Page)','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (46,'Avery A4','C9151 Photo Quality Label','S',28.5,15.0,40.0,30.0,50.0,37.5,5,5, NULL, NULL ) +INSERT INTO label_def VALUES (47,'Avery A4','C9169 Photo Quality Label (4 per page)','S',4.63,9.5,99.1,139.0,101.64,139.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (48,'Avery A4','C9312 Clean Edge(TM) Business Card','S',31.5,17.0,54.0,85.0,60.0,91.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (49,'Avery A4','C9351 Photo Quality Gloss A5 Greeting Card','S',0.0,0.0,210.0,148.5,210.0,148.5,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (50,'Avery A4','C9352 Greeting Cards Glossy A6','S',25.4,22.45,120.72,82.55,125.48,82.55,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (51,'Avery A4','C9353 Photo Quality Gloss Postcards','S',31.75,31.75,110.4,146.5,123.1,146.5,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (52,'Avery A4','C9354 Photo Quality Gloss Business Cards','S',34.27,22.25,50.8,80.4,59.22,85.13,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (53,'Avery A4','C9355 Post Cards','S',36.0,31.0,105.0,148.0,120.0,148.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (54,'Avery A4','C9356 Photo Quality A4 Card Sheet','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (55,'Avery A4','C9362 Business Cards Glossy','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (56,'Avery A4','C9372 Photo Paper Glossy 9 x 13','S',12.5,17.5,90.0,129.5,95.0,132.5,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (57,'Avery A4','C9373 Photo Gloss Paper','S',24.25,30.0,100.0,150.0,148.5,150.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (58,'Avery A4','C9374 Photo Quality Glossy Inkjet Card','S',17.5,15.0,129.5,180.0,132.5,180.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (59,'Avery A4','C9405 Avery T-Shirt Transfer Sheets','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (60,'Avery A4','C9406 Avery T-Shirt Transfer Sheets','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (61,'Avery A4','C9430 Photo Quality Glossy A4 Inkjet Paper','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (62,'Avery A4','C9431 Photo Quality Glossy Paper - 160gsm','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (63,'Avery A4','C9433 Inkjet Glossy Double Sided Paper','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (64,'Avery A4','C9434 Photo Cards Glossy','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (65,'Avery A4','C9612 CD-R Business Card','S',23.75,15.0,56.0,84.0,64.5,96.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (66,'Avery A4','C9660 Full Face CD/DVD Labels','S',21.5,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (67,'Avery A4','COPT210 Copier Transparency','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (68,'Avery A4','IJT310 Inkjet Transparency - 90microns','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (69,'Avery A4','IJT311 Inkjet Transparency - 120 microns','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (70,'Avery A4','J40063 Address','S',23.45,55.45,38.1,99.1,63.5,99.1,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (71,'Avery A4','J40065 Parcel','S',40.4,5.9,67.7,99.1,67.7,99.1,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (72,'Avery A4','J400DK 3.5\" Diskette - Face Only','S',48.25,35.0,52.0,70.0,52.0,70.0,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (73,'Avery A4','J400SL 35mm Slide','S',17.94,13.0,11.11,46.0,33.84,46.0,4,4, NULL, NULL ) +INSERT INTO label_def VALUES (74,'Avery A4','J400VF Video Face','S',15.15,66.9,46.4,76.2,71.8,76.2,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (75,'Avery A4','J400VS Video Spine','S',21.2,32.5,17.0,145.0,29.7,145.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (76,'Avery A4','J8156 Address','S',14.1,6.46,17.8,58.0,17.8,69.54,3,15, NULL, NULL ) +INSERT INTO label_def VALUES (77,'Avery A4','J8157 Address','S',14.0,6.46,24.3,64.0,24.3,66.54,3,11, NULL, NULL ) +INSERT INTO label_def VALUES (78,'Avery A4','J8158 Address','S',14.0,6.46,26.7,64.0,26.7,66.54,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (79,'Avery A4','J8159 Address','S',13.06,6.46,33.86,64.0,33.86,66.54,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (80,'Avery A4','J8160 Address','S',15.15,7.2,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (81,'Avery A4','J8161 Address','S',8.82,7.21,46.56,63.5,46.56,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (82,'Avery A4','J8162 Address','S',13.02,4.67,33.87,99.06,33.87,101.6,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (83,'Avery A4','J8163 Address','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (84,'Avery A4','J8164 Address','S',4.57,7.21,71.97,63.5,71.97,66.04,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (85,'Avery A4','J8165 Parcel','S',13.04,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (86,'Avery A4','J8166 Parcel','S',8.81,4.67,93.13,99.06,93.13,101.6,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (87,'Avery A4','J8167 Shipping','S',3.98,5.2,289.05,199.6,289.05,199.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (88,'Avery A4','J8168 Shipping','S',4.97,5.2,143.53,199.6,143.53,199.6,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (89,'Avery A4','J8169 Parcel','S',4.63,9.5,99.1,139.0,101.64,139.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (90,'Avery A4','J8170 Collect/Filing','S',16.5,38.0,11.0,134.0,11.0,134.0,1,24, NULL, NULL ) +INSERT INTO label_def VALUES (91,'Avery A4','J8171 Lever Arch Labels - White','S',5.0,28.5,200.0,60.0,200.0,60.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (92,'Avery A4','J8173 Address','S',6.0,4.67,57.0,99.06,57.0,101.6,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (93,'Avery A4','J8359 Address','S',13.06,6.46,33.86,64.0,33.86,66.54,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (94,'Avery A4','J8360 Address','S',15.15,7.2,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (95,'Avery A4','J8361 Address','S',8.82,7.21,46.56,63.5,46.56,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (96,'Avery A4','J8362 Address','S',13.02,4.67,33.87,99.06,33.87,101.6,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (97,'Avery A4','J8363 Address','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (98,'Avery A4','J8364 Address','S',4.57,7.21,71.97,63.5,71.97,66.04,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (99,'Avery A4','J8365 Parcel','S',13.04,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (100,'Avery A4','J8366 Parcel','S',8.81,4.67,93.13,99.06,93.13,101.6,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (101,'Avery A4','J8367 Shipping','S',3.98,5.2,289.05,199.6,289.05,199.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (102,'Avery A4','J8368 Shipping','S',4.97,5.2,143.53,199.6,143.53,199.6,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (103,'Avery A4','J8369 Parcel','S',4.63,9.5,99.1,139.0,101.64,139.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (104,'Avery A4','J8371 Lever Arch','S',5.0,28.5,200.0,60.0,200.0,60.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (105,'Avery A4','J8414 Clean Edge (TM) Business Card','S',21.5,15.0,50.8,87.0,50.8,93.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (106,'Avery A4','J8415 Greeting Cards Maxi (A6)','S',27.0,40.5,156.0,108.0,156.0,108.0,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (107,'Avery A4','J8423 Name Card','S',31.0,25.0,43.75,160.0,63.75,160.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (108,'Avery A4','J8431 CD Case Insert - Cover','S',44.5,27.5,121.0,121.0,121.0,121.0,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (109,'Avery A4','J8432 CD Case Insert - Tray','S',22.5,29.5,117.0,151.0,135.0,151.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (110,'Avery A4','J8433 CD Envelope','S',24.5,43.0,124.0,124.0,124.0,124.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (111,'Avery A4','J8434 Inkjet CD Inserts - Cover Section','S',24.0,59.5,121.0,121.0,121.0,121.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (112,'Avery A4','J8434 Inkjet CD Inserts - Tray Section','S',155.0,29.5,118.0,151.0,118.0,151.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (113,'Avery A4','J8435 CD Case Insert Cover Section','S',24.0,59.5,121.0,121.0,121.0,121.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (114,'Avery A4','J8435 CD Case Insert Tray Section','S',155.0,29.5,118.0,151.0,118.0,151.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (115,'Avery A4','J8436 CD Case Spine Labels','S',16.43,47.85,5.5,114.3,5.5,114.3,1,48, NULL, NULL ) +INSERT INTO label_def VALUES (116,'Avery A4','J8440 Zip(TM) Disk Card Insert - Panels','S',56.5,46.5,97.0,98.5,97.0,105.5,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (117,'Avery A4','J8560 Clear Address','S',15.15,7.2,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (118,'Avery A4','J8562 Clear Address','S',13.02,4.67,33.87,99.06,33.87,101.6,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (119,'Avery A4','J8563 Clear Address','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (120,'Avery A4','J8565 Clear Parcel','S',13.04,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (121,'Avery A4','J8567 Clear A4 Labels','S',6.5,5.2,284.0,199.6,284.0,199.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (122,'Avery A4','J8570 Full Face CD/DVD Labels - Clear Inkjet','S',21.5,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (123,'Avery A4','J8587 Inkjet Transparencies','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (124,'Avery A4','J8612 CD-R Business Card','S',23.75,15.0,56.0,84.0,64.5,96.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (125,'Avery A4','J8651 Mini Address','S',10.9,4.67,21.17,38.1,21.17,40.64,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (126,'Avery A4','J8654 Miini Address','S',21.43,9.75,25.4,45.72,25.4,48.26,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (127,'Avery A4','J8655 Audio Cassette','S',22.5,14.73,42.0,89.0,42.0,91.54,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (128,'Avery A4','J8656 35 mm Slide','S',15.95,6.0,11.11,46.0,12.7,50.67,4,21, NULL, NULL ) +INSERT INTO label_def VALUES (129,'Avery A4','J8657 35 mm Slides/Small Items','S',60.4,31.33,11.11,46.0,12.7,50.67,3,14, NULL, NULL ) +INSERT INTO label_def VALUES (130,'Avery A4','J8658 Mini Labels - Removable','S',13.43,8.48,10.0,25.4,10.0,27.94,7,27, NULL, NULL ) +INSERT INTO label_def VALUES (131,'Avery A4','J8659 Mini Labels - Removable','S',13.43,4.67,10.0,17.78,10.0,20.32,10,27, NULL, NULL ) +INSERT INTO label_def VALUES (132,'Avery A4','J8666 3.5\" Diskette - Face Only','S',18.5,23.35,52.0,70.0,52.0,93.3,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (133,'Avery A4','J8667 Mini Disk Label - Face','S',13.5,9.25,52.0,35.5,54.5,39.0,5,5, NULL, NULL ) +INSERT INTO label_def VALUES (134,'Avery A4','J8667 Mini Disk Label - Spine','S',13.5,5.75,52.0,3.5,54.5,39.0,6,5, NULL, NULL ) +INSERT INTO label_def VALUES (135,'Avery A4','J8668 Labels for Zip (TM.) Disk','S',21.0,14.0,51.0,59.0,51.0,61.5,3,5, NULL, NULL ) +INSERT INTO label_def VALUES (136,'Avery A4','J8671 Video Face','S',9.3,27.53,46.4,76.2,46.4,78.74,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (137,'Avery A4','J8674 Video Spine','S',13.04,32.61,16.93,144.78,16.93,144.78,1,16, NULL, NULL ) +INSERT INTO label_def VALUES (138,'Avery A4','J8676 Full Face CD/DVD Labels','S',21.5,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (139,'Avery A4','J8701 Lever Arch','S',9.0,24.5,192.0,62.0,192.0,62.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (140,'Avery A4','J8702 Lever Arch','S',9.0,12.0,192.0,39.0,192.0,39.0,7,1, NULL, NULL ) +INSERT INTO label_def VALUES (141,'Avery A4','J8766 3.5\" Diskette - Face Only','S',18.5,23.35,52.0,70.0,52.0,93.3,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (142,'Avery A4','J8770 Full Face CD/DVD Labels','S',21.5,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (143,'Avery A4','J8771 Video Face','S',9.3,27.53,46.4,76.2,46.4,78.74,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (144,'Avery A4','J8774 Video Spine','S',13.04,32.61,16.93,144.78,16.93,144.78,1,16, NULL, NULL ) +INSERT INTO label_def VALUES (145,'Avery A4','J8776 Full Face CD/DVD Labels - Holographic','S',21.5,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (146,'Avery A4','J8777 Full Face CD/DVD Labels - Silver','S',21.5,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (147,'Avery A4','J8778 Full Face CD/DVD Labels - Gold','S',21.5,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (148,'Avery A4','J8867 Printable Magnets - Full Sheet','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (149,'Avery A4','J8871 Printable Magnets','S',22.5,24.5,28.0,78.0,28.0,83.0,2,9, NULL, NULL ) +INSERT INTO label_def VALUES (150,'Avery A4','J8875 Printable Magnets','S',8.5,5.0,140.0,50.0,140.0,50.0,4,2, NULL, NULL ) +INSERT INTO label_def VALUES (151,'Avery A4','J9124 Inkjet Labels Glossy','S',18.43,16.0,127.0,178.0,133.0,178.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (152,'Avery A4','L30063 Address','S',23.45,55.45,38.1,99.1,63.5,99.1,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (153,'Avery A4','L30065 Parcel','S',40.4,5.9,67.7,99.1,67.7,99.1,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (154,'Avery A4','L300DK 3.5\" Diskette - Face Only','S',48.25,35.0,52.0,70.0,52.0,70.0,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (155,'Avery A4','L300SL 35mm Slide','S',17.94,13.0,11.11,46.0,33.84,46.0,4,4, NULL, NULL ) +INSERT INTO label_def VALUES (156,'Avery A4','L300VF Video Face','S',15.15,66.9,46.4,76.2,71.8,76.2,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (157,'Avery A4','L300VS Video Spine','S',21.2,32.5,17.0,145.0,29.7,145.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (158,'Avery A4','L6008 Silver Heavy Duty Labels','S',13.43,8.48,10.0,25.4,10.0,27.94,7,27, NULL, NULL ) +INSERT INTO label_def VALUES (159,'Avery A4','L6009 Silver Heavy Duty Labels','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (160,'Avery A4','L6011 Silver Heavy Duty Labels','S',15.1,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (161,'Avery A4','L6012 Silver Heavy Duty Labels','S',21.43,7.73,50.8,96.0,50.8,98.54,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (162,'Avery A4','L6112 Anti Tamper Labels','S',13.43,16.0,40.0,40.0,46.0,46.0,4,6, NULL, NULL ) +INSERT INTO label_def VALUES (163,'Avery A4','L6113 Anti Tamper Labels','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (164,'Avery A4','L6114 Anti Tamper Labels','S',15.1,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (165,'Avery A4','L7051 Heavy Duty Labels Mini','S',10.9,4.67,21.17,38.1,21.17,40.64,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (166,'Avery A4','L7060 White Heavy Duty Labels','S',15.15,7.2,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (167,'Avery A4','L7063 White Heavy Duty Labels','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (168,'Avery A4','L7067 White Heavy Duty Labels','S',1.0,0.5,295.0,209.0,295.0,209.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (169,'Avery A4','L7068 White Heavy Duty Labels','S',4.97,5.2,143.53,199.6,143.53,199.6,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (170,'Avery A4','L7069 White Heavy Duty Labels','S',4.63,9.5,99.1,139.0,101.64,139.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (171,'Avery A4','L7156 Address','S',14.1,6.46,17.8,58.0,17.8,69.54,3,15, NULL, NULL ) +INSERT INTO label_def VALUES (172,'Avery A4','L7157 Address','S',14.0,6.46,24.3,64.0,24.3,66.54,3,11, NULL, NULL ) +INSERT INTO label_def VALUES (173,'Avery A4','L7158 Address','S',14.0,6.46,26.7,64.0,26.7,66.54,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (174,'Avery A4','L7159 Address','S',13.06,6.46,33.86,64.0,33.86,66.54,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (175,'Avery A4','L7160 Address','S',15.15,7.2,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (176,'Avery A4','L7161 Address','S',8.82,7.21,46.56,63.5,46.56,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (177,'Avery A4','L7162 Address','S',13.02,4.67,33.87,99.06,33.87,101.6,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (178,'Avery A4','L7163 Address','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (179,'Avery A4','L7164 Address','S',4.57,7.21,71.97,63.5,71.97,66.04,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (180,'Avery A4','L7165 Parcel','S',13.04,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (181,'Avery A4','L7166 Parcel','S',8.81,4.67,93.13,99.06,93.13,101.6,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (182,'Avery A4','L7167 Shipping','S',3.98,5.2,289.05,199.6,289.05,199.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (183,'Avery A4','L7168 Shipping','S',4.97,5.2,143.53,199.6,143.53,199.6,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (184,'Avery A4','L7169 Parcel','S',4.63,9.5,99.1,139.0,101.64,139.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (185,'Avery A4','L7170 Eurofolio','S',16.5,38.0,11.0,134.0,11.0,134.0,1,24, NULL, NULL ) +INSERT INTO label_def VALUES (186,'Avery A4','L7171 Lever Arch - White','S',5.0,28.5,200.0,60.0,200.0,60.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (187,'Avery A4','L7171B Lever Arch Labels - Blue','S',5.0,28.5,200.0,60.0,200.0,60.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (188,'Avery A4','L7171G Lever Arch Labels - Green','S',5.0,28.5,200.0,60.0,200.0,60.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (189,'Avery A4','L7171R Lever Arch Labels - Red','S',5.0,28.5,200.0,60.0,200.0,60.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (190,'Avery A4','L7172 Ring Binder','S',13.5,3.73,30.0,100.0,30.0,102.54,2,9, NULL, NULL ) +INSERT INTO label_def VALUES (191,'Avery A4','L7173 Shipping','S',6.0,4.67,57.0,99.06,57.0,101.6,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (192,'Avery A4','L7176 Labels for 60mm Box File','S',19.15,5.0,41.0,100.0,43.54,100.0,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (193,'Avery A4','L7177 Address','S',21.44,4.67,42.33,99.06,42.33,101.6,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (194,'Avery A4','L7178 Labels for 40mm Box File','S',18.0,54.5,29.0,101.0,29.0,101.0,1,9, NULL, NULL ) +INSERT INTO label_def VALUES (195,'Avery A4','L7179 Labels for 25mm Box File','S',22.76,49.5,17.0,111.0,19.54,111.0,1,13, NULL, NULL ) +INSERT INTO label_def VALUES (196,'Avery A4','L7263 Fluorescent Yellow Address','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (197,'Avery A4','L7363 Address','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (198,'Avery A4','L7400 Suspended Files (Cupboard)','S',23.1,79.25,6.3,138.5,6.3,138.5,1,26, NULL, NULL ) +INSERT INTO label_def VALUES (199,'Avery A4','L7408 Suspended Files (Drawer)','S',23.1,10.0,6.3,277.0,6.3,277.0,1,26, NULL, NULL ) +INSERT INTO label_def VALUES (200,'Avery A4','L7409 Suspension Tab Card Inserts','S',21.0,19.5,15.0,57.0,15.0,57.0,3,17, NULL, NULL ) +INSERT INTO label_def VALUES (201,'Avery A4','L7410-5 IndexMaker 5 part - Labels','S',46.9,25.4,12.7,55.02,21.17,104.19,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (202,'Avery A4','L7410-5 IndexMaker 5 part - Contents Sheet','S',4.75,105.0,57.5,92.0,57.5,92.0,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (203,'Avery A4','L7410-6 IndexMaker 6 part - Labels','S',49.02,30.48,12.7,44.93,16.93,104.11,2,12, NULL, NULL ) +INSERT INTO label_def VALUES (204,'Avery A4','L7410-6 IndexMaker 6 part - Contents Sheet','S',5.0,105.0,47.5,92.0,47.5,92.0,1,6, NULL, NULL ) +INSERT INTO label_def VALUES (205,'Avery A4','L7410-10 IndexMaker 10 part - Labels','S',46.9,19.91,12.7,25.4,21.17,48.26,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (206,'Avery A4','L7410-10 IndexMaker 10 part - Contents Sheet','S',4.25,105.0,28.85,92.0,28.85,92.0,1,10, NULL, NULL ) +INSERT INTO label_def VALUES (207,'Avery A4','L7410-12 IndexMaker 12 part - Labels','S',49.02,25.42,12.7,22.0,16.93,45.72,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (208,'Avery A4','L7410-12 IndexMaker 12 part - Contents Sheet','S',5.1,105.0,23.9,92.0,23.9,92.0,1,12, NULL, NULL ) +INSERT INTO label_def VALUES (209,'Avery A4','L7411-5 ReadyIndex 1-5 Index - Contents Sheet','S',4.33,109.5,57.67,100.0,57.67,100.0,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (210,'Avery A4','L7411-6 ReadyIndex 1-6 Index - Contents Sheet','S',4.5,109.5,48.0,100.0,48.0,100.0,1,6, NULL, NULL ) +INSERT INTO label_def VALUES (211,'Avery A4','L7411-10 ReadyIndex 1-10 Index - Contents Sheet','S',4.25,109.5,28.85,100.0,28.85,100.0,1,10, NULL, NULL ) +INSERT INTO label_def VALUES (212,'Avery A4','L7411-12 ReadyIndex 1-12 Index - Contents Sheet','S',5.1,109.5,23.9,100.0,23.9,100.0,1,12, NULL, NULL ) +INSERT INTO label_def VALUES (213,'Avery A4','L7411-15 ReadyIndex 1-15 Index - Contents Sheet','S',18.0,109.5,17.4,100.0,17.4,100.0,1,15, NULL, NULL ) +INSERT INTO label_def VALUES (214,'Avery A4','L7411-20 ReadyIndex 1-20 Index - Contents Sheet','S',15.0,109.5,13.35,100.0,13.35,100.0,1,20, NULL, NULL ) +INSERT INTO label_def VALUES (215,'Avery A4','L7411-31 ReadyIndex 1-31 Index - Contents Sheet','S',15.0,109.5,8.61,100.0,8.61,100.0,1,31, NULL, NULL ) +INSERT INTO label_def VALUES (216,'Avery A4','L7411-AZ ReadyIndex A-Z Index - Contents Sheet','S',15.0,109.5,13.35,100.0,13.35,100.0,1,20, NULL, NULL ) +INSERT INTO label_def VALUES (217,'Avery A4','L7411-JD ReadyIndex Jan-Dec Index - Contents Sheet','S',4.5,109.5,24.0,100.0,24.0,100.0,1,12, NULL, NULL ) +INSERT INTO label_def VALUES (218,'Avery A4','L7412-5 Insertable Tab Dividers - 5 Tabs','S',47.3,25.4,12.7,55.0,21.15,105.0,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (219,'Avery A4','L7412-6 Insertable Tab Dividers - 6 Tabs','S',47.3,25.4,12.7,47.0,21.15,104.2,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (220,'Avery A4','L7412-8 Insertable Tab Dividers - 8 Tabs','S',47.3,25.4,12.7,43.0,21.15,104.2,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (221,'Avery A4','L7412-10 Insertable Tab Dividers - 10 Tabs','S',47.3,19.8,12.7,25.4,21.15,48.2,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (222,'Avery A4','L7412-12 Insertable Tab Dividers - 12 Tabs','S',47.3,19.8,12.7,25.4,21.15,48.2,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (223,'Avery A4','L7413 Business Card','S',21.5,15.0,50.8,90.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (224,'Avery A4','L7414 Business Card','S',18.5,15.0,52.0,90.0,52.0,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (225,'Avery A4','L7415 Business Card','S',18.5,15.0,52.0,90.0,52.0,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (226,'Avery A4','L7416-5 IndexMaker 5 part (Unpunched) - Labels','S',46.9,25.4,12.7,55.02,21.17,104.18,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (227,'Avery A4','L7416-5 IndexMaker 5 part (Unpunched) - Contents Sheet','S',4.33,105.0,57.67,92.0,57.67,92.0,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (228,'Avery A4','L7416-6 IndexMaker 6 part - Extra Wide - Labels','S',49.02,30.48,12.7,44.93,16.93,104.11,2,12, NULL, NULL ) +INSERT INTO label_def VALUES (229,'Avery A4','L7416-6 IndexMaker 6 part - Extra Wide - Contents Sheet','S',4.5,105.0,48.0,92.0,48.0,92.0,1,6, NULL, NULL ) +INSERT INTO label_def VALUES (230,'Avery A4','L7416-10 IndexMaker 10 part (Unpunched) - Labels','S',46.9,19.91,12.7,25.4,21.17,48.26,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (231,'Avery A4','L7416-10 IndexMaker 10 part (Unpunched) - Contents Sheet','S',4.25,105.0,28.85,92.0,28.85,92.0,1,10, NULL, NULL ) +INSERT INTO label_def VALUES (232,'Avery A4','L7416-12 IndexMaker 12 part - Extra Wide - Labels','S',49.02,25.42,12.7,22.0,16.93,45.72,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (233,'Avery A4','L7416-12 IndexMaker 12 part - Extra Wide - Contents Sheet','S',4.5,105.0,24.0,92.0,24.0,92.0,1,12, NULL, NULL ) +INSERT INTO label_def VALUES (234,'Avery A4','L7417 Business Card','S',13.5,15.0,54.0,90.0,54.0,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (235,'Avery A4','L7418 Name Badge','S',38.5,19.0,55.0,86.0,55.0,86.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (236,'Avery A4','L7419 Business Card','S',13.5,15.0,54.0,90.0,54.0,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (237,'Avery A4','L7420-5 Direct Print Dividers','S',10.0,192.0,55.4,13.0,55.4,13.0,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (238,'Avery A4','L7420-6 Direct Print Dividers','S',10.0,192.0,46.22,13.0,46.22,13.0,1,6, NULL, NULL ) +INSERT INTO label_def VALUES (239,'Avery A4','L7420-8 Direct Print Dividers','S',10.0,192.0,34.64,13.0,34.64,13.0,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (240,'Avery A4','L7421 Post Card','S',7.71,9.13,97.29,139.37,97.29,139.37,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (241,'Avery A4','L7422 Suspension Tab Card Inserts','S',58.0,19.0,6.0,173.0,12.0,173.0,1,15, NULL, NULL ) +INSERT INTO label_def VALUES (242,'Avery A4','L7423 Delegate Card - Embossed','S',10.38,11.5,53.5,187.0,74.25,187.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (243,'Avery A4','L7424 Lever Arch Labels','S',9.0,30.43,192.0,59.0,192.0,59.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (244,'Avery A4','L7425 Lever Arch Labels','S',9.0,12.43,192.0,34.0,192.0,34.0,8,1, NULL, NULL ) +INSERT INTO label_def VALUES (245,'Avery A4','L7426 Note Card','S',8.28,0.0,139.37,105.0,139.37,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (246,'Avery A4','L7451-5 ReadyIndex 5 Index (Unnumbered) - Contents','S',4.33,109.5,57.67,100.0,57.67,100.0,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (247,'Avery A4','L7451-10 ReadyIndex 10 Index (Unnumbered) - Contents','S',4.25,109.5,28.85,100.0,28.85,100.0,1,10, NULL, NULL ) +INSERT INTO label_def VALUES (248,'Avery A4','L7551 Clear Mini Address','S',10.9,4.67,21.17,38.1,21.17,40.64,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (249,'Avery A4','L7552 Clear Mini','S',46.9,25.4,12.7,55.02,21.17,104.18,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (250,'Avery A4','L7553 Clear Mini','S',49.02,25.42,12.7,22.0,16.93,45.72,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (251,'Avery A4','L7560 Clear Address','S',15.15,7.2,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (252,'Avery A4','L7562 Clear Address','S',13.02,4.67,33.87,99.06,33.87,101.6,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (253,'Avery A4','L7563 Clear Address','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (254,'Avery A4','L7565 Clear Parcel','S',13.04,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (255,'Avery A4','L7567 Clear A4 Labels','S',6.5,5.2,284.0,199.6,284.0,199.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (256,'Avery A4','L7568 Clear A5 Labels','S',4.98,5.2,143.53,199.6,143.53,199.6,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (257,'Avery A4','L7587 Laser Transparencies','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (258,'Avery A4','L7630 Circular','S',14.75,5.25,63.5,63.5,68.0,68.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (259,'Avery A4','L7650 Circular','S',14.75,5.25,63.5,63.5,68.0,68.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (260,'Avery A4','L7651 Mini Address','S',10.9,4.67,21.17,38.1,21.17,40.64,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (261,'Avery A4','L7651/PF Mini Address','S',10.9,4.67,21.17,38.1,21.17,40.64,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (262,'Avery A4','L7651/YF Mini Address','S',10.9,4.67,21.17,38.1,21.17,40.64,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (263,'Avery A4','L7652 Miini Address','S',12.99,9.75,16.93,45.72,16.93,48.26,4,16, NULL, NULL ) +INSERT INTO label_def VALUES (264,'Avery A4','L7653 Mini','S',49.02,25.42,12.7,22.0,16.93,45.72,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (265,'Avery A4','L7654 Miini Address','S',21.43,9.75,25.4,45.72,25.4,48.26,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (266,'Avery A4','L7655 Audio Cassette','S',22.5,14.73,42.0,89.0,42.0,91.54,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (267,'Avery A4','L7656 35 mm Slide','S',15.95,6.0,11.11,46.0,12.7,50.67,4,21, NULL, NULL ) +INSERT INTO label_def VALUES (268,'Avery A4','L7657 Mini Labels - Removable - Laser','S',13.43,4.67,10.0,17.78,10.0,20.32,10,27, NULL, NULL ) +INSERT INTO label_def VALUES (269,'Avery A4','L7658 Mini Labels - Removable - Laser','S',13.43,8.48,10.0,25.4,10.0,27.94,7,27, NULL, NULL ) +INSERT INTO label_def VALUES (270,'Avery A4','L7663 5.25\" Diskette','S',13.48,45.31,33.76,119.38,33.76,119.38,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (271,'Avery A4','L7664 3.5\" Diskette - Wraparound','S',4.57,17.93,71.97,70.0,71.97,104.14,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (272,'Avery A4','L7665 Mini Data Cartridge','S',21.6,22.0,21.15,72.0,21.15,94.0,2,12, NULL, NULL ) +INSERT INTO label_def VALUES (273,'Avery A4','L7666 3.5\" Diskette - Face Only','S',18.5,23.35,52.0,70.0,52.0,93.3,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (274,'Avery A4','L7667 Standard Data Cartridge','S',15.26,38.5,29.61,133.0,29.61,133.0,1,9, NULL, NULL ) +INSERT INTO label_def VALUES (275,'Avery A4','L7668 Labels for Zip(TM) Disk','S',21.0,14.0,51.0,59.0,51.0,61.5,3,5, NULL, NULL ) +INSERT INTO label_def VALUES (276,'Avery A4','L7669 Labels for SuperDisk (TM )','S',23.5,39.0,61.0,54.0,63.0,78.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (277,'Avery A4','L7670 Circular - Fluorescent Yellow','S',14.75,5.25,63.5,63.5,68.0,68.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (278,'Avery A4','L7671 Video Face','S',9.3,27.53,46.4,76.2,46.4,78.74,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (279,'Avery A4','L7674 Video Spine','S',13.04,32.61,16.93,144.78,16.93,144.78,1,16, NULL, NULL ) +INSERT INTO label_def VALUES (280,'Avery A4','L7675 4mm Data Cartridge','S',26.0,10.25,35.0,61.5,35.0,64.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (281,'Avery A4','L7676 Full Face CD/DVD Labels - Black & White','S',21.5,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (282,'Avery A4','L7680 Mini Address - Gold','S',10.9,4.67,21.17,38.1,21.17,40.64,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (283,'Avery A4','L7701 Lever Arch','S',9.0,24.5,192.0,62.0,192.0,62.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (284,'Avery A4','L7702 Lever Arch','S',9.0,12.0,192.0,39.0,192.0,39.0,7,1, NULL, NULL ) +INSERT INTO label_def VALUES (285,'Avery A4','L7760 Full Face CD/DVD Labels - Colour Laser','S',21.5,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (286,'Avery A4','L7765 Presentation/Photo - Glossy Colour Laser','S',13.04,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (287,'Avery A4','L7767 Presentation/Photo - Glossy Colour Laser','S',1.0,0.5,295.0,209.0,295.0,209.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (288,'Avery A4','L7768 Presentation/Photo - Glossy Colour Laser','S',4.97,5.2,143.53,199.6,143.53,199.6,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (289,'Avery A4','L7769 Presentation/Photo - Glossy Colour Laser','S',4.63,9.5,99.1,139.0,101.64,139.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (290,'Avery A4','L7901 Organizer Page','S',0.0,0.0,170.0,95.0,170.0,95.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (291,'Avery A4','L7902 Organizer Page (A5)','S',0.0,0.0,210.0,148.5,210.0,148.5,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (292,'Avery A4','L7905 Compliment Slip','S',9.0,0.0,93.0,210.0,93.0,210.0,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (293,'Avery A4','LPT110 Laser/Copier Transparency - 100micron','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (294,'Avery A4','LPT111 Laser/Copier Transparency - 100micron','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (295,'Avery A4/Asia','C2412 Laminated Cards large','S',18.0,18.5,85.0,123.0,85.0,137.0,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (296,'Avery A4/Asia','C2413 Laminated Cards','S',20.5,107.0,60.0,91.0,98.0,91.0,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (297,'Avery A4/Asia','C2414 Laminated Cards','S',18.5,107.0,50.0,81.5,70.0,81.5,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (298,'Avery A4/Asia','C24412 Laminated Cards large','S',24.0,12.5,85.0,123.0,85.0,123.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (299,'Avery A4/Asia','C25446 A5 Sheet','S',0.0,0.0,210.0,148.0,210.0,148.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (300,'Avery A4/Asia','C25447 A5 Sheet','S',0.0,0.0,210.0,148.0,210.0,148.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (301,'Avery A4/Asia','C2546 Windows Decals','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (302,'Avery A4/Asia','C2547 Fantastic Plastic','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (303,'Avery A4/Asia','C91131 Business Cards','S',11.0,14.0,55.0,91.0,55.0,91.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (304,'Avery A4/Asia','C91149 Business Cards','S',25.0,15.0,55.0,91.0,64.0,99.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (305,'Avery A4/Asia','C9167 A4 Sheet','S',3.98,5.2,289.05,199.6,289.05,199.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (306,'Avery A4/Asia','C9169 Glossy Photo Quality Labels','S',4.63,9.5,99.1,139.0,101.64,139.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (307,'Avery A4/Asia','C9356 Photo Quality A4 Card Sheet','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (308,'Avery A4/Asia','J21013 Business Cards','S',11.0,14.0,55.0,91.0,55.0,91.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (309,'Avery A4/Asia','J21015 Business Cards','S',11.0,14.0,55.0,91.0,55.0,91.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (310,'Avery A4/Asia','J21016 Business Cards','S',11.0,14.0,55.0,91.0,55.0,91.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (311,'Avery A4/Asia','J21031 Business Cards','S',25.0,15.0,55.0,91.0,64.0,99.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (312,'Avery A4/Asia','J21033 Business Cards','S',11.0,14.0,55.0,91.0,55.0,91.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (313,'Avery A4/Asia','J21131 Business Cards','S',11.0,14.0,55.0,91.0,55.0,91.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (314,'Avery A4/Asia','J21141 Greeting Cards','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (315,'Avery A4/Asia','J21149 Business Cards','S',25.0,15.0,55.0,91.0,64.0,99.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (316,'Avery A4/Asia','J2356 A4 Sheet','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (317,'Avery A4/Asia','J8359 Address','S',13.06,6.46,33.86,64.0,33.86,66.54,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (318,'Avery A4/Asia','J8360 Address','S',15.15,7.2,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (319,'Avery A4/Asia','J8361 Address','S',8.82,7.21,46.56,63.5,46.56,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (320,'Avery A4/Asia','J8362 Address','S',13.02,4.67,33.87,99.06,33.87,101.6,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (321,'Avery A4/Asia','J8363 Address','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (322,'Avery A4/Asia','J8365 Address','S',13.04,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (323,'Avery A4/Asia','J8367 Shipping A4','S',3.98,5.2,289.05,199.6,289.05,199.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (324,'Avery A4/Asia','J8368 Shipping A5','S',4.97,5.2,143.53,199.6,143.53,199.6,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (325,'Avery A4/Asia','J8369 Parcel','S',4.63,9.5,99.1,139.0,101.64,139.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (326,'Avery A4/Asia','J8371 Lever Arch','S',5.0,28.5,200.0,60.0,200.0,60.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (327,'Avery A4/Asia','J8751 Mini Address','S',10.9,4.67,21.17,38.1,21.17,40.64,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (328,'Avery A4/Asia','J8756 35 mm Slide','S',15.95,6.0,11.11,46.0,12.7,50.67,4,21, NULL, NULL ) +INSERT INTO label_def VALUES (329,'Avery A4/Asia','J8766 3.5\" Diskette','S',18.5,23.35,52.0,70.0,52.0,93.3,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (330,'Avery A4/Asia','J8771 Video Face','S',9.3,27.53,46.4,76.2,46.4,78.74,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (331,'Avery A4/Asia','J8774 Video Spine','S',13.04,32.61,16.93,144.78,16.93,144.78,1,16, NULL, NULL ) +INSERT INTO label_def VALUES (332,'Avery A4/Asia','J88911 Address','S',25.0,10.0,48.0,89.0,48.0,91.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (333,'Avery A4/Asia','J88915 Address','S',21.5,19.3,42.3,83.8,42.3,87.6,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (334,'Avery A4/Asia','J88919 Address','S',21.2,18.6,42.3,86.4,42.3,86.4,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (335,'Avery A4/Asia','J88923 Address','S',0.0,0.0,42.43,70.0,42.43,70.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (336,'Avery A4/Asia','J88927 Address','S',21.2,0.0,42.3,70.0,42.3,70.0,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (337,'Avery A4/Asia','J88935 Address','S',12.7,0.0,33.9,70.0,33.9,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (338,'Avery A4/Asia','L7159 Address','S',13.06,6.46,33.86,64.0,33.86,66.54,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (339,'Avery A4/Asia','L7160 Address','S',15.15,7.2,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (340,'Avery A4/Asia','L7161 Address','S',8.82,7.21,46.56,63.5,46.56,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (341,'Avery A4/Asia','L7162 Address','S',13.02,4.67,33.87,99.06,33.87,101.6,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (342,'Avery A4/Asia','L7163 Address','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (343,'Avery A4/Asia','L7164 Address','S',4.57,7.21,71.97,63.5,71.97,66.04,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (344,'Avery A4/Asia','L7165 Parcel','S',13.04,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (345,'Avery A4/Asia','L7166 Parcel','S',8.81,4.67,93.13,99.06,93.13,101.6,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (346,'Avery A4/Asia','L7167 Shipping','S',3.98,5.2,289.05,199.6,289.05,199.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (347,'Avery A4/Asia','L7168 Shipping','S',4.97,5.2,143.53,199.6,143.53,199.6,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (348,'Avery A4/Asia','L7169 Parcel','S',4.63,9.5,99.1,139.0,101.64,139.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (349,'Avery A4/Asia','L7170 Eurofolio','S',16.5,38.0,11.0,134.0,11.0,134.0,1,24, NULL, NULL ) +INSERT INTO label_def VALUES (350,'Avery A4/Asia','L7171 Lever Arch','S',5.0,28.5,200.0,60.0,200.0,60.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (351,'Avery A4/Asia','L7172 Ring Binder','S',13.5,3.73,30.0,100.0,30.0,102.54,2,9, NULL, NULL ) +INSERT INTO label_def VALUES (352,'Avery A4/Asia','L7173 Address','S',6.0,4.67,57.0,99.06,57.0,101.6,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (353,'Avery A4/Asia','L7651 Mini Adress','S',10.9,4.67,21.17,38.1,21.17,40.64,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (354,'Avery A4/Asia','L7656 35 mm Slide','S',15.95,6.0,11.11,46.0,12.7,50.67,4,21, NULL, NULL ) +INSERT INTO label_def VALUES (355,'Avery A4/Asia','L7664 3.5\" Diskette - Wraparound','S',4.57,17.93,71.97,70.0,71.97,104.14,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (356,'Avery A4/Asia','L7665 Mini Data Cartridge','S',21.6,22.0,21.15,72.0,21.15,94.0,2,12, NULL, NULL ) +INSERT INTO label_def VALUES (357,'Avery A4/Asia','L7666 3.5\" Diskette','S',18.5,23.35,52.0,70.0,52.0,93.3,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (358,'Avery A4/Asia','L7667 Standard Data Cartridge','S',15.26,38.5,29.61,133.0,29.61,133.0,1,9, NULL, NULL ) +INSERT INTO label_def VALUES (359,'Avery A4/Asia','L7668 Labels for Zip(TM) Disk','S',21.0,14.0,51.0,59.0,51.0,61.5,3,5, NULL, NULL ) +INSERT INTO label_def VALUES (360,'Avery A4/Asia','L7671 Video Face','S',9.3,27.53,46.4,76.2,46.4,78.74,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (361,'Avery A4/Asia','L7674 Video Spine','S',13.04,32.61,16.93,144.78,16.93,144.78,1,16, NULL, NULL ) +INSERT INTO label_def VALUES (362,'Avery A4/Asia','L78382 Address','S',21.2,18.6,42.3,86.4,42.3,86.4,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (363,'Avery A4/Asia','L78383 Address','S',0.0,0.0,42.43,70.0,42.43,70.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (364,'Avery A4/Asia','L78384 Address','S',21.2,0.0,42.3,70.0,42.3,70.0,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (365,'Avery A4/Asia','L78386 Address','S',12.7,0.0,33.9,70.0,33.9,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (366,'Avery A4/Asia','L78387 Address','S',21.2,18.6,50.8,86.4,50.8,86.4,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (367,'Avery A4/Asia','L78388 Address','S',8.8,8.4,25.4,48.3,25.4,48.3,4,11, NULL, NULL ) +INSERT INTO label_def VALUES (368,'Avery A4/Asia','M21131 Business Cards','S',11.0,14.0,55.0,91.0,55.0,91.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (369,'Avery A4/Asia','M8167 A4 Sheet','S',3.98,5.2,289.05,199.6,289.05,199.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (370,'Avery A4/Asia','M88173 Address','S',23.3,7.1,44.5,96.5,44.5,99.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (371,'Avery A4/Asia','M88175 Address','S',20.0,20.4,42.3,83.8,42.3,87.6,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (372,'Avery A4/Asia','M88177 Address','S',25.0,10.0,48.0,89.0,48.0,91.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (373,'Avery A4/Asia','M88179 Address','S',23.0,20.0,42.0,84.0,42.0,86.0,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (374,'Avery A4/Asia','M88183 Address','S',21.5,19.3,42.3,83.8,42.3,87.6,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (375,'Avery A4/Asia','M88185 Address','S',21.5,0.0,42.3,70.0,42.3,70.0,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (376,'Avery A4/Asia','M88187 Address','S',22.5,20.0,42.0,84.0,42.0,86.0,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (377,'Avery A4/Asia','M88315 Address','S',23.5,7.0,33.9,64.0,33.9,64.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (378,'Avery A4/Asia','P78204 Address','S',0.0,0.0,74.25,42.0,74.25,42.0,5,4, NULL, NULL ) +INSERT INTO label_def VALUES (379,'Avery A4/Asia','P78261 Address','S',10.5,10.0,69.0,38.0,69.0,38.0,5,4, NULL, NULL ) +INSERT INTO label_def VALUES (380,'Avery A4/Asia','P78270 Address','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (381,'Avery A4/Asia','P78275 Address','S',22.5,20.0,42.0,85.0,42.0,85.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (382,'Avery Letter Size','5167 Return Address','S',12.7,7.14,12.7,44.45,12.7,52.4,4,20, NULL, NULL ) +INSERT INTO label_def VALUES (383,'Avery Letter Size','5267 Return Address','S',12.7,7.14,12.7,44.45,12.7,52.4,4,20, NULL, NULL ) +INSERT INTO label_def VALUES (384,'Avery Letter Size','5160 Address','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (385,'Avery Letter Size','5260 Address','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (386,'Avery Letter Size','5960 Address','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (387,'Avery Letter Size','5159 Address','S',6.35,3.96,38.1,101.6,38.1,106.38,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (388,'Avery Letter Size','5161 Address','S',12.7,3.96,25.4,101.6,25.4,106.36,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (389,'Avery Letter Size','5261 Address','S',12.7,3.96,25.4,101.6,25.4,106.36,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (390,'Avery Letter Size','5961 Address','S',12.7,3.96,25.4,101.6,25.4,106.36,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (391,'Avery Letter Size','5162 Address','S',21.17,3.96,33.87,101.6,33.87,106.36,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (392,'Avery Letter Size','5262 Address','S',21.17,3.96,33.87,101.6,33.87,106.36,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (393,'Avery Letter Size','5922 Address','S',21.17,3.96,33.87,101.6,33.87,106.36,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (394,'Avery Letter Size','5962 Address','S',21.17,3.96,33.87,101.6,33.87,106.36,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (395,'Avery Letter Size','5163 Address / Shipping','S',12.7,3.96,50.8,101.6,50.8,106.36,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (396,'Avery Letter Size','5263 Address / Shipping','S',12.7,3.96,50.8,101.6,50.8,106.36,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (397,'Avery Letter Size','5963 Address / Shipping','S',12.7,3.96,50.8,101.6,50.8,106.36,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (398,'Avery Letter Size','5164 Address / Shipping','S',12.7,3.96,84.67,101.6,84.67,106.36,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (399,'Avery Letter Size','5264 Address / Shipping','S',12.7,3.96,84.67,101.6,84.67,106.36,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (400,'Avery Letter Size','5168 Shipping','S',12.7,12.7,127.0,88.9,127.0,101.6,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (401,'Avery Letter Size','5667 Clear Return Address','S',12.7,7.62,12.7,44.45,12.7,52.07,4,20, NULL, NULL ) +INSERT INTO label_def VALUES (402,'Avery Letter Size','5660 Clear Address','S',12.7,0.0,25.4,71.96,25.4,71.97,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (403,'Avery Letter Size','5930 Clear Address','S',12.7,0.0,25.4,71.96,25.4,71.97,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (404,'Avery Letter Size','5661 Clear Address','S',12.7,0.0,25.4,107.95,25.4,107.95,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (405,'Avery Letter Size','5662 Clear Address','S',21.21,0.0,33.86,107.95,33.86,107.95,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (406,'Avery Letter Size','5663 Clear Address','S',12.7,0.0,50.8,107.95,50.8,107.95,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (407,'Avery Letter Size','5664 Clear Address / Shipping','S',12.7,0.0,84.66,107.95,84.67,107.95,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (408,'Avery Letter Size','5165 Full Sheet','S',0.0,0.0,279.4,215.9,0.0,0.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (409,'Avery Letter Size','5265 Full Sheet','S',0.0,0.0,279.4,215.9,0.0,0.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (410,'Avery Letter Size','5266 File Folder-Assorted','S',12.7,13.49,13.74,87.33,17.15,101.6,2,15, NULL, NULL ) +INSERT INTO label_def VALUES (411,'Avery Letter Size','5066 File Folder-Red','S',12.7,13.49,13.74,87.33,17.15,101.6,2,15, NULL, NULL ) +INSERT INTO label_def VALUES (412,'Avery Letter Size','5166 File Folder-Orange','S',15.88,13.49,13.74,87.33,16.93,101.6,2,15, NULL, NULL ) +INSERT INTO label_def VALUES (413,'Avery Letter Size','5366 File Folder-White','S',12.7,13.49,16.92,87.33,16.92,101.6,2,15, NULL, NULL ) +INSERT INTO label_def VALUES (414,'Avery Letter Size','5666 File Folder-Purple','S',15.88,13.49,13.74,87.33,16.93,101.6,2,15, NULL, NULL ) +INSERT INTO label_def VALUES (415,'Avery Letter Size','5766 File Folder-Blue','S',12.7,13.49,13.74,87.33,17.15,101.6,2,15, NULL, NULL ) +INSERT INTO label_def VALUES (416,'Avery Letter Size','5866 File Folder-Green','S',12.7,13.49,13.74,87.33,17.15,101.6,2,15, NULL, NULL ) +INSERT INTO label_def VALUES (417,'Avery Letter Size','5966 File Folder-Yellow','S',12.7,13.49,13.74,87.33,17.15,101.6,2,15, NULL, NULL ) +INSERT INTO label_def VALUES (418,'Avery Letter Size','5293 Round','S',12.7,11.13,41.28,50.8,42.34,50.8,4,6, NULL, NULL ) +INSERT INTO label_def VALUES (419,'Avery Letter Size','5294 Round','S',12.7,6.35,63.5,69.85,63.5,69.85,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (420,'Avery Letter Size','5196 3-1/2\" Diskette - White','S',12.7,3.18,69.85,69.85,76.2,69.85,3,3, NULL, NULL ) +INSERT INTO label_def VALUES (421,'Avery Letter Size','5096 3-1/2\" Diskette - Red','S',38.1,3.18,44.45,69.85,76.2,69.85,3,3, NULL, NULL ) +INSERT INTO label_def VALUES (422,'Avery Letter Size','5896 3-1/2\" Diskette - Blue','S',38.1,3.18,44.45,69.85,76.2,69.85,3,3, NULL, NULL ) +INSERT INTO label_def VALUES (423,'Avery Letter Size','5197 5-1/4 Diskette - White','S',25.4,3.96,38.1,101.6,38.1,106.36,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (424,'Avery Letter Size','5198 Audio Cassette','S',12.7,12.7,42.34,88.9,42.33,101.6,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (425,'Avery Letter Size','5199 Video Cassette Face','S',23.29,27.15,46.56,77.8,46.57,83.82,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (426,'Avery Letter Size','5199 Video Cassette Spine','S',12.7,34.14,16.93,147.65,16.93,147.65,1,15, NULL, NULL ) +INSERT INTO label_def VALUES (427,'Avery Letter Size','5925 White Laser Labels for Zip Disks (bottom spine)','S',87.88,60.33,7.14,95.25,83.82,95.25,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (428,'Avery Letter Size','5925 White Laser Labels for Zip Disks (face)','S',16.69,32.26,50.8,59.56,84.12,91.82,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (429,'Avery Letter Size','5925 White Laser Labels for Zip Disks (top spine)','S',73.66,60.33,7.14,95.25,83.82,95.25,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (430,'Avery Letter Size','5931 White CD/DVD Labels for Lasers (face)','S',17.46,49.21,117.48,117.48,127.0,0.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (431,'Avery Letter Size','5931 White CD/DVD Labels for Lasers (spines)','S',18.64,12.55,119.08,5.56,123.06,11.91,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (432,'Avery Letter Size','5970 Fluorescent Laser - Magenta','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (433,'Avery Letter Size','5971 Fluorescent Laser - Green','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (434,'Avery Letter Size','5972 Fluorescent Laser - Yellow','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (435,'Avery Letter Size','5975 Fluorescent Laser - Full Sheet Assorted','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (436,'Avery Letter Size','5979 Fluorescent Laser - Assorted','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (437,'Avery Letter Size','5980 Pastel Laser - Blue','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (438,'Avery Letter Size','5997 Videotape Face','S',23.29,27.15,46.56,77.8,46.57,83.82,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (439,'Avery Letter Size','5997 Videotape Spine','S',12.7,34.14,16.93,147.65,16.93,147.65,1,15, NULL, NULL ) +INSERT INTO label_def VALUES (440,'Avery Letter Size','5998 Audio Tape','S',12.7,12.7,42.34,88.9,42.33,101.6,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (441,'Avery Letter Size','5395 Name Badge - White','S',14.82,17.48,59.26,85.73,63.5,95.25,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (442,'Avery Letter Size','5095 Name Badge - Red','S',20.65,22.23,51.32,77.79,63.5,95.25,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (443,'Avery Letter Size','5895 Name Badge - Blue','S',20.64,22.23,51.32,77.79,63.5,95.25,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (444,'Avery Letter Size','5371 Business Card - White','S',12.7,19.05,50.8,88.9,50.8,88.9,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (445,'Avery Letter Size','5871 Laser Business Card','S',12.7,19.05,50.8,88.9,50.8,88.9,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (446,'Avery Letter Size','5376 Business Card - Ivory','S',12.7,19.05,50.8,88.9,50.8,88.9,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (447,'Avery Letter Size','5377 Business Card - Gray','S',12.7,19.05,50.8,88.9,50.8,88.9,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (448,'Avery Letter Size','5911 Business Card','S',12.7,19.05,50.8,88.9,50.8,88.9,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (449,'Avery Letter Size','5383 Name Tag Kit','S',29.63,19.05,55.03,88.9,55.03,88.9,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (450,'Avery Letter Size','5390 Name Tag Refill','S',29.63,19.05,55.03,88.9,55.03,88.9,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (451,'Avery Letter Size','5883 Name Tag Kit - Blue','S',36.51,25.4,42.86,76.2,55.56,88.9,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (452,'Avery Letter Size','5384 Name Tag Kit','S',25.4,6.35,76.2,101.6,76.2,101.6,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (453,'Avery Letter Size','5392 Name Tag Refill','S',25.4,6.35,76.2,101.6,76.2,101.6,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (454,'Avery Letter Size','5385 Rotary Card - Small','S',29.63,6.35,55.03,101.6,55.03,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (455,'Avery Letter Size','5386 Rotary Card - Large','S',25.4,44.45,76.2,127.0,76.2,127.0,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (456,'Avery Letter Size','5388 Index Card','S',25.4,44.45,76.2,127.0,76.2,127.0,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (457,'Avery Letter Size','5389 Post Card','S',38.1,31.75,101.6,152.4,101.6,152.4,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (458,'Avery Letter Size','5305 Laser Tent Cards Med.','S',22.23,9.53,107.95,196.85,127.0,215.9,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (459,'Avery Letter Size','5309 Laser Tent Cards Large','S',28.58,9.53,158.75,260.35,177.8,279.4,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (460,'Avery Letter Size','5315 Laser Note Cards','S',0.0,0.0,215.9,139.7,0.0,139.7,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (461,'Avery Letter Size','5361 Laminated ID Cards','S',21.17,109.54,50.8,82.55,93.13,82.55,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (462,'Avery Letter Size','5361 Laminated ID Cards-Single Card','S',21.17,109.54,50.8,82.55,50.8,82.55,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (463,'Avery Letter Size','5362 Laminated Name Badges','S',21.17,109.54,50.8,82.55,93.13,82.55,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (464,'Avery Letter Size','5362 Laminated N. Badges-Single Card','S',21.17,109.54,50.8,82.55,50.8,82.55,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (465,'Avery Letter Size','5364 Laminated Rotary Index Cards','S',20.64,109.54,52.39,98.43,93.13,98.43,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (466,'Avery Letter Size','5364 Laminated Rotary Index-Single Card','S',20.64,109.54,52.39,98.43,52.4,98.43,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (467,'Avery Letter Size','74520 Name Badge Inserts - 3\" x 4\"','S',25.4,6.35,76.2,101.6,76.2,0.0,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (468,'Avery Letter Size','74540 Name Badge Inserts - 3\" x 4\"','S',25.4,6.35,76.2,101.6,76.2,101.6,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (469,'Avery Letter Size','74541 Name Badge Inserts - 3\" x 4\"','S',25.4,6.35,76.2,101.6,76.2,101.6,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (470,'Avery Letter Size','74550 Name Badge Inserts - 2 1/4\" x 3 1/2\"','S',26.99,9.53,56.36,88.9,56.36,0.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (471,'Avery Letter Size','74552 Name Badge Inserts - 2\" x 3\"','S',14.29,31.75,50.01,76.2,50.01,76.2,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (472,'Avery Letter Size','74558 Name Badge Inserts - 2\" x 3\"','S',15.9,31.75,50.01,76.2,50.01,76.2,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (473,'Avery Letter Size','74650 Name Badge Inserts - 2 1/4\" x 3 1/2\"','S',24.61,9.53,56.36,88.9,56.36,0.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (474,'Avery Letter Size','74651 Name Badge Inserts - 2 1/4\" x 3 1/2\"','S',26.99,9.53,56.36,88.9,56.36,0.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (475,'Avery Letter Size','8160 Ink Jet Address','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (476,'Avery Letter Size','8460 Ink Jet Address','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (477,'Avery Letter Size','8461 Ink Jet Address','S',12.7,3.96,25.4,101.6,25.4,106.38,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (478,'Avery Letter Size','8161 Ink Jet Address','S',12.7,3.96,25.4,101.6,25.4,106.36,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (479,'Avery Letter Size','8162 Ink Jet Address','S',21.17,3.96,33.87,101.6,33.87,106.36,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (480,'Avery Letter Size','8462 Ink Jet Address','S',21.17,3.96,33.87,101.6,33.87,106.36,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (481,'Avery Letter Size','8163 Ink Jet Address / Shipping','S',12.7,3.96,50.8,101.6,50.8,106.36,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (482,'Avery Letter Size','8463 Ink Jet Address / Shipping','S',12.7,3.96,50.8,101.6,50.8,106.36,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (483,'Avery Letter Size','8464 Ink Jet Address / Shipping','S',12.7,3.96,84.67,101.6,84.67,106.36,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (484,'Avery Letter Size','8923 Ink Jet Address / Shipping','S',12.7,3.96,50.8,101.6,50.8,106.36,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (485,'Avery Letter Size','8164 Ink Jet Address / Shipping','S',12.7,3.96,84.67,101.6,84.67,106.36,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (486,'Avery Letter Size','8165 Ink Jet Full Sheet','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (487,'Avery Letter Size','8465 Ink Jet Full Sheet','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (488,'Avery Letter Size','8166 Ink Jet File Folder-Assorted','S',12.7,13.49,13.74,87.33,17.15,101.6,2,15, NULL, NULL ) +INSERT INTO label_def VALUES (489,'Avery Letter Size','8366 Ink Jet File Folder-White','S',12.7,13.49,16.94,87.33,16.94,101.6,2,15, NULL, NULL ) +INSERT INTO label_def VALUES (490,'Avery Letter Size','8167 Ink Jet Return Address','S',12.7,7.14,12.7,44.45,12.7,52.4,4,20, NULL, NULL ) +INSERT INTO label_def VALUES (491,'Avery Letter Size','8196 Ink Jet 3-1/2\" Diskette','S',12.7,3.18,69.85,69.85,76.2,69.85,3,3, NULL, NULL ) +INSERT INTO label_def VALUES (492,'Avery Letter Size','8250 Ink Jet Label for Color Printing','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (493,'Avery Letter Size','8252 Ink Jet Label for Color Printing','S',21.17,3.96,33.87,101.6,33.87,106.36,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (494,'Avery Letter Size','8253 Ink Jet Label for Color Printing','S',12.7,4.32,50.8,101.6,50.8,105.66,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (495,'Avery Letter Size','8254 Ink Jet Label for Color Printing','S',12.7,3.96,84.67,101.6,84.67,106.36,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (496,'Avery Letter Size','8255 Ink Jet Label for Color Printing ','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (497,'Avery Letter Size','8257 Ink Jet Return Address for Color Printing','S',15.88,9.53,19.05,57.15,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (498,'Avery Letter Size','8309 Tent Card Large','S',31.75,12.7,152.4,254.0,177.8,279.4,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (499,'Avery Letter Size','8315 Ink Jet Note Cards','S',0.0,0.0,215.9,139.7,0.0,139.7,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (500,'Avery Letter Size','8316 Ink Jet Greeting Card (Portrait)*','S',0.0,0.0,139.7,215.9,139.7,215.9,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (501,'Avery Letter Size','8316 Ink Jet Greeting Card (Landscape)*','S',0.0,0.0,215.9,139.7,215.9,139.7,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (502,'Avery Letter Size','8324 Ink Jet Brochures','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (503,'Avery Letter Size','8371 Ink Jet Business Card','S',12.7,19.05,50.8,88.9,50.8,88.9,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (504,'Avery Letter Size','8385 Rotary Card - Small','S',29.63,6.35,55.04,101.6,55.04,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (505,'Avery Letter Size','8387 Ink Jet Postcard - 4-up','S',0.0,0.0,107.95,139.7,107.95,139.7,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (506,'Avery Letter Size','8388 Index Card','S',25.4,44.45,76.2,127.0,76.2,127.0,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (507,'Avery Letter Size','8871 Clean Edge Business Cards (IJ)','S',12.7,19.05,50.8,88.9,50.8,88.9,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (508,'Avery Letter Size','8376 Ink Jet Business Card - Ivory','S',12.7,19.05,50.8,88.9,50.8,88.9,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (509,'Avery Letter Size','8377 Ink Jet Business Card - Gray','S',12.7,19.05,50.8,88.9,50.8,88.9,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (510,'Avery Letter Size','8660 Ink Jet Clear Address','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (511,'Avery Letter Size','8662 Ink Jet Clear Address','S',21.17,3.96,33.87,101.6,33.87,106.36,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (512,'Avery Letter Size','8663 Ink Jet Clear Address/Shipping','S',12.7,3.96,50.8,101.6,50.8,106.36,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (513,'Avery Letter Size','8665 Ink Jet Clear Full Sheet','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (514,'Avery Letter Size','8667 Ink Jet Clear Address Labels','S',12.7,7.14,12.7,44.45,12.7,52.4,4,20, NULL, NULL ) +INSERT INTO label_def VALUES (515,'Avery Letter Size','8925 White Inkjet Labels for Zip Disks (bottom spine)','S',87.88,60.33,7.14,95.25,83.82,95.25,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (516,'Avery Letter Size','8925 White Inkjet Labels for Zip Disks (face)','S',16.69,32.26,50.8,59.56,84.12,91.82,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (517,'Avery Letter Size','8925 White Inkjet Labels for Zip Disks (top spine)','S',73.66,60.33,7.14,95.25,83.82,95.25,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (518,'Avery Letter Size','8931 White CD/DVD Jewel Case Insert (spines)','S',15.88,33.34,117.48,6.35,117.48,142.88,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (519,'Avery Letter Size','8931 White CD/DVD Jewel Case Inserts (cover)','S',142.88,47.63,120.65,120.65,120.65,120.65,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (520,'Avery Letter Size','8931 White CD/DVD Jewel Case Inserts (tray)','S',15.88,39.69,117.48,136.53,117.48,136.53,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (521,'Avery Letter Size','8931 White CD/DVD Labels for Inkjet Printers','S',17.46,49.21,117.48,117.48,127.0,0.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (522,'Avery Letter Size','11161 Ready Index ExtraWide 5 Tab','S',15.88,127.0,47.63,76.2,50.8,76.2,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (523,'Avery Letter Size','11163 Ready Index ExtraWide 8 Tab','S',22.23,127.0,28.58,76.2,30.96,76.2,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (524,'Avery Letter Size','11165 Ready Index ExtraWide 10 Tab','S',15.88,127.0,22.23,76.2,25.4,76.2,1,10, NULL, NULL ) +INSERT INTO label_def VALUES (525,'Avery Letter Size','11526 Direct Print Custom Dividers 5 Tab Single Set','S',6.35,12.7,12.7,44.45,12.7,52.39,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (526,'Avery Letter Size','11527 Direct Print Custom Dividers 8 Tab Single Set','S',6.35,12.7,12.7,28.58,12.7,32.2,8,1, NULL, NULL ) +INSERT INTO label_def VALUES (527,'Avery Letter Size','11171 Easy Edit Ready Index - 5 Tabs','S',15.88,127.0,47.63,76.2,50.8,76.2,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (528,'Avery Letter Size','11172 Easy Edit Ready Index - 8 Tabs','S',22.1,127.0,28.58,76.2,30.86,76.2,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (529,'Avery Letter Size','11173 Easy Edit Ready Index - 10 Tabs','S',15.88,127.0,22.23,76.2,25.4,76.2,1,10, NULL, NULL ) +INSERT INTO label_def VALUES (530,'Avery Letter Size','11251 Clear Label/Index Maker Presentation Kit 5 Tab','S',12.7,7.62,12.7,44.45,12.7,52.07,4,20, NULL, NULL ) +INSERT INTO label_def VALUES (531,'Avery Letter Size','11251 Clear Label/Index Maker Spine Label 1/4\" or 5/16\"','S',50.8,9.83,6.35,92.08,6.35,104.14,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (532,'Avery Letter Size','11251 Clear Label/Index Maker Spine Label 3/8\" or 1/2\"','S',88.9,9.83,9.53,92.08,9.53,104.14,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (533,'Avery Letter Size','11251 Clear Label/Index Maker Spine Label 5/8\" or 3/4\"','S',133.35,9.83,15.88,92.08,15.88,104.14,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (534,'Avery Letter Size','11251 Clear Label/Index Maker Spine Label 1\" or Larger','S',190.5,9.83,25.4,92.08,25.4,104.14,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (535,'Avery Letter Size','11253 Clear Label/Index Maker Narrow 5 Tab','S',12.7,7.62,6.35,44.45,12.7,52.07,4,20, NULL, NULL ) +INSERT INTO label_def VALUES (536,'Avery Letter Size','11253 Clear Label/Index Maker Spine Label 1/4\" or 5/16\"','S',50.8,9.83,6.35,92.08,6.35,104.14,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (537,'Avery Letter Size','11253 Clear Label/Index Maker Spine Label 3/8\" or 1/2\"','S',88.9,9.83,9.53,92.08,9.53,104.14,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (538,'Avery Letter Size','11253 Clear Label/Index Maker Spine Label 5/8\" or 3/4\"','S',133.35,9.83,15.88,92.08,15.88,104.14,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (539,'Avery Letter Size','11253 Clear Label/Index Maker Spine Label 1\" or Larger','S',190.5,9.83,25.4,92.08,25.4,104.14,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (540,'Avery Letter Size','11260 Ready Index Landscape - 5 Tabs','S',30.48,35.56,29.97,83.31,35.56,83.31,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (541,'Avery Letter Size','11261 Ready Index Landscape - 8 Tabs','S',30.48,33.02,17.02,88.9,22.1,88.9,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (542,'Avery Letter Size','12260 Ready Index Landscape - 5 Tabs','S',30.48,35.56,29.97,83.31,35.56,83.31,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (543,'Avery Letter Size','12261 Ready Index Landscape - 8 Tabs','S',30.48,33.02,17.02,88.9,22.1,88.9,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (544,'Avery Letter Size','Index Maker 3 Tab','S',12.7,12.7,12.7,79.38,12.7,111.13,2,20, NULL, NULL ) +INSERT INTO label_def VALUES (545,'Avery Letter Size','Index Maker 5 Tab','S',12.7,7.62,12.7,44.45,12.7,52.07,4,20, NULL, NULL ) +INSERT INTO label_def VALUES (546,'Avery Letter Size','Index Maker 8 Tab','S',12.7,12.7,12.7,28.58,12.7,53.98,4,20, NULL, NULL ) +INSERT INTO label_def VALUES (547,'Avery Letter Size','Hidden Tab 5 Tab','S',15.88,127.0,47.63,76.2,50.8,76.2,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (548,'Avery Letter Size','Hidden Tab 8 Tab','S',22.23,127.0,28.58,76.2,30.96,76.2,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (549,'Avery Letter Size','Hidden Tab 10 Tab','S',15.88,127.0,22.23,76.2,25.4,76.2,1,10, NULL, NULL ) +INSERT INTO label_def VALUES (550,'Avery Letter Size','Prof. Ready Index Spine Insert 1\"','S',25.4,19.05,15.88,241.3,15.88,241.3,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (551,'Avery Letter Size','Prof. Ready Index Spine Insert 1 1/2\"','S',50.8,19.05,22.23,241.3,22.23,241.3,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (552,'Avery Letter Size','Prof. Ready Index Spine Insert 2\"','S',87.31,19.05,31.75,241.3,31.75,241.3,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (553,'Avery Letter Size','Prof. Ready Index Spine Insert 3\"','S',134.94,19.05,50.8,241.3,50.8,241.3,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (554,'Avery Letter Size','Ready Index 5 Tab','S',15.88,127.0,47.63,76.2,50.8,76.2,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (555,'Avery Letter Size','Ready Index 8 Tab','S',22.23,127.0,28.58,76.2,30.96,76.2,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (556,'Avery Letter Size','Ready Index 10 Tab','S',15.88,127.0,22.23,76.2,25.4,76.2,1,10, NULL, NULL ) +INSERT INTO label_def VALUES (557,'Avery Letter Size','Ready Index 12 Tab','S',12.7,127.0,21.27,76.2,21.27,76.2,1,12, NULL, NULL ) +INSERT INTO label_def VALUES (558,'Avery Letter Size','Ready Index 15 Tab','S',23.81,127.0,11.91,76.2,15.88,76.2,1,15, NULL, NULL ) +INSERT INTO label_def VALUES (559,'Avery Letter Size','WorkSaver Divider 5 Tabs','S',29.63,57.15,8.47,50.8,8.47,50.8,2,26, NULL, NULL ) +INSERT INTO label_def VALUES (560,'Avery Letter Size','WorkSaver Divider 8 Tabs','S',29.63,69.85,8.47,38.1,8.47,38.1,2,26, NULL, NULL ) +INSERT INTO label_def VALUES (561,'Avery Letter Size','WorkSaver Inserts 1/3 Cut','S',25.4,19.05,12.7,177.8,12.7,177.8,1,10, NULL, NULL ) +INSERT INTO label_def VALUES (562,'Avery Letter Size','WorkSaver Inserts 1/5 Cut','S',25.4,6.35,12.7,101.6,12.7,101.6,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (563,'Avery Letter Size','Self Adhesive Index Tab 1\"','S',12.7,25.4,8.64,50.8,8.64,50.8,1,15, NULL, NULL ) +INSERT INTO label_def VALUES (564,'Avery Letter Size','Self Adhesive Index Tab 1 1/2\"','S',12.7,12.7,8.64,76.2,8.64,76.2,1,15, NULL, NULL ) +INSERT INTO label_def VALUES (565,'Avery Letter Size','Self Adhesive Index Tab 2\"','S',12.7,3.18,8.64,101.6,8.64,101.6,1,15, NULL, NULL ) +INSERT INTO label_def VALUES (566,'Avery Letter Size','Protect n Tab - 5 Tab','S',19.05,136.53,16.54,53.98,16.54,53.98,1,15, NULL, NULL ) +INSERT INTO label_def VALUES (567,'Avery Letter Size','Protect n Tab - 8 Tab','S',7.94,152.4,16.54,34.93,16.54,34.93,1,16, NULL, NULL ) +INSERT INTO label_def VALUES (568,'Avery Letter Size','TitleFrames Asst.Spines Insert 1\"','S',25.4,19.05,15.88,241.3,15.88,241.3,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (569,'Avery Letter Size','TitleFrames Asst.Spines Insert 1 1/2\"','S',50.8,19.05,22.23,241.3,22.23,241.3,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (570,'Avery Letter Size','TitleFrames Asst.Spines Insert 2\"','S',87.31,19.05,31.75,241.3,31.75,241.3,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (571,'Avery Letter Size','TitleFrames Asst. Spines Insert 3\"','S',134.94,19.05,50.8,241.3,50.8,241.3,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (572,'Avery Letter Size','TitleFrames Cover - 1\"','S',12.7,12.7,254.0,190.5,254.0,190.5,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (573,'Avery Letter Size','TitleFrames Spine - 1\"','S',36.53,12.7,15.88,254.0,25.4,254.0,1,6, NULL, NULL ) +INSERT INTO label_def VALUES (574,'Avery Letter Size','TitleFrames Cover - 1 1/2\"','S',12.7,12.7,254.0,190.5,254.0,190.5,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (575,'Avery Letter Size','TitleFrames Spine - 1 1/2\"','S',39.7,12.7,22.23,254.0,38.1,254.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (576,'Avery Letter Size','2160 Addressing','S',12.7,20.57,25.4,66.8,25.4,66.8,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (577,'Avery Letter Size','2162 Addressing','S',12.7,3.18,33.87,101.6,33.87,101.6,1,6, NULL, NULL ) +INSERT INTO label_def VALUES (578,'Avery Letter Size','2163 Address/Shipping','S',12.7,3.18,50.8,101.6,50.8,101.6,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (579,'Avery Letter Size','2164 Shipping','S',21.43,3.18,84.14,101.6,127.0,101.6,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (580,'Avery Letter Size','2180 File Folder-Assorted','S',12.7,10.29,13.74,87.38,17.15,87.38,1,12, NULL, NULL ) +INSERT INTO label_def VALUES (581,'Avery Letter Size','2181 File Folder-White','S',12.7,10.29,16.92,87.38,17.15,87.38,1,12, NULL, NULL ) +INSERT INTO label_def VALUES (582,'Avery Letter Size','2186 3.5\" Diskette-White','S',12.7,19.05,50.8,69.85,50.8,69.85,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (583,'Avery Letter Size','6490 Remove Em 3.5\" Diskette-Face Only Labels','S',12.7,3.18,50.8,68.26,50.8,70.66,3,5, NULL, NULL ) +INSERT INTO label_def VALUES (584,'Avery Letter Size','6466 Remove Em File Folder Labels','S',12.7,13.49,16.94,87.33,16.94,101.6,2,15, NULL, NULL ) +INSERT INTO label_def VALUES (585,'Avery Letter Size','6460 Remove Em Address Labels','S',12.7,4.78,25.4,66.68,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (586,'Avery Letter Size','6464 Remove Em Shipping Labels','S',12.7,3.96,84.66,101.6,84.67,106.36,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (587,'Avery Letter Size','6465 Removable Laser - Full Sheet','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (588,'Avery Letter Size','6467 Removable Laser - Small Multi-Purpose','S',12.7,7.14,12.7,44.45,12.7,52.4,4,20, NULL, NULL ) +INSERT INTO label_def VALUES (589,'Avery Letter Size','6503 Remove em white laser 8 1/2\" x 11\"','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (590,'Avery Letter Size','5824 CD-Recordable Labels','S',12.7,50.8,114.3,114.3,139.7,114.3,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (591,'Avery Letter Size','5836 MtgCreator Portfolio Label','S',12.7,19.05,50.8,88.9,50.8,88.9,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (592,'Avery Letter Size','5836 MtgCreator Divider 5 Tab','S',12.7,7.62,12.7,44.45,12.7,52.07,4,20, NULL, NULL ) +INSERT INTO label_def VALUES (593,'Avery Letter Size','3111 Square Stickers','S',31.75,7.95,63.5,63.5,76.2,68.26,3,3, NULL, NULL ) +INSERT INTO label_def VALUES (594,'Avery Letter Size','3112 Small Round Stickers','S',19.05,12.7,38.1,38.1,50.8,50.8,4,5, NULL, NULL ) +INSERT INTO label_def VALUES (595,'Avery Letter Size','3114 Full Page Stickers','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (596,'Avery Letter Size','3248 Glossy Photo Quality Postcard','S',31.75,31.75,101.6,152.4,114.3,152.4,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (597,'Avery Letter Size','3251 Feather Edge Greeting Card','S',0.0,0.0,139.7,215.9,139.7,215.9,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (598,'Avery Letter Size','3252 Vellum Overlay Greeting Card','S',0.0,0.0,139.7,215.9,139.7,215.9,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (599,'Avery Letter Size','3254 Glossy Photo Quality Print-to-the-Edge Greeting Card','S',15.88,20.64,123.83,174.63,123.83,174.63,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (600,'Avery Letter Size','3256 White Embossed Note Cards','S',12.7,12.7,114.3,82.55,139.7,107.95,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (601,'Avery Letter Size','3259 Ivory Embossed Note Card','S',12.7,12.7,114.3,82.55,139.7,107.95,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (602,'Avery Letter Size','3260 Ivory Embossed Half-Fold Card','S',19.05,19.05,101.6,177.8,139.7,177.8,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (603,'Avery Letter Size','3261 White Large Labels','S',28.58,9.53,31.75,95.25,38.1,101.6,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (604,'Avery Letter Size','3261 White Small Labels','S',28.58,9.53,31.75,60.33,38.1,68.26,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (605,'Avery Letter Size','3261 White Return Address Labels','S',15.88,9.53,19.05,57.15,25.4,69.85,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (606,'Avery Letter Size','3263 White Postcard','S',0.0,0.0,107.95,139.7,107.95,139.7,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (607,'Avery Letter Size','3265 White Half-Fold Card','S',0.0,0.0,139.7,215.9,139.7,215.9,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (608,'Avery Letter Size','3266 White Quarter-Fold Card','S',0.0,0.0,139.7,107.95,139.7,107.95,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (609,'Avery Letter Size','3268 White Note Card','S',0.0,0.0,139.7,107.95,139.7,107.95,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (610,'Avery Letter Size','3274 White Big Round Stickers','S',31.75,7.94,63.5,63.5,76.2,68.26,3,3, NULL, NULL ) +INSERT INTO label_def VALUES (611,'Avery Letter Size','3274 White Small Round Stickers','S',19.05,12.7,38.1,38.1,50.8,50.8,4,5, NULL, NULL ) +INSERT INTO label_def VALUES (612,'Avery Letter Size','3274 White Square Stickers','S',31.75,7.94,63.5,63.5,76.2,68.26,3,3, NULL, NULL ) +INSERT INTO label_def VALUES (613,'Avery Letter Size','3269 Glossy Photo Quality Half-Fold Cards','S',0.0,0.0,139.7,215.9,139.7,215.9,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (614,'Avery Letter Size','8313 Glossy Photo Quality 4\" x 6\" Card','S',0.0,0.0,101.6,152.4,101.6,152.4,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (615,'Avery Letter Size','8314 Glossy Photo Quality 8-1/2\" x 11\" Card','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (616,'Avery Letter Size','8373 Glossy Photo Quality Business Card','S',19.05,12.7,50.8,88.9,63.5,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (617,'Avery Letter Size','8389 Glossy Photo Quality Postcard','S',31.75,31.75,101.6,152.4,114.3,152.4,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (618,'Avery Letter Size','8763 Glossy Photo Quality Labels','S',12.7,3.96,50.8,101.6,50.8,106.38,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (619,'Avery Letter Size','8769 Glossy Photo Quality Labels','S',28.58,9.53,31.75,95.25,38.1,101.6,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (620,'Avery Letter Size','3273 White Print-to-the-Edge Greeting Cards','S',15.88,20.64,123.83,174.63,123.83,174.63,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (621,'Avery Letter Size','3277 Textured Canvas for Ink Jet Printers','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (622,'Avery Letter Size','8317 Embossed Ink Jet Note Card - Ivory','S',12.7,12.7,114.3,82.55,139.7,107.95,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (623,'Avery Letter Size','8384 Photo Quality Brochures','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (624,'Avery Letter Size','53220 Glossy 4x6 Photo Paper','S',31.75,31.75,101.6,152.4,114.3,152.4,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (625,'Avery Letter Size','53221 Glossy 5x7 Photo Paper','S',6.35,20.65,123.83,174.63,128.59,174.63,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (626,'Avery Letter Size','5881 Color Laser Business Cards','S',19.05,12.7,50.8,88.9,63.5,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (627,'Avery Letter Size','5884 Glossy Color Laser Brochures','S',0.0,0.0,279.4,215.9,279.4,215.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (628,'Avery Letter Size','5889 Color Laser Postcards','S',31.75,31.75,101.6,152.4,114.3,152.4,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (629,'Avery Letter Size','8877 Ink Jet Business Card - Gray','S',12.7,19.05,50.8,88.9,50.8,88.9,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (630,'Avery Letter Size','6873 Color Laser Address Labels','S',28.58,9.53,50.8,95.25,57.15,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (631,'Avery Letter Size','6879 Color Laser Address Labels','S',28.58,9.53,31.75,95.25,38.1,101.6,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (632,'Avery Letter Size','4207 Price Marking','C',0.0,12.7,9.53,38.1,12.7,40.64,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (633,'Avery Letter Size','4144 Address','C',0.0,21.59,23.81,63.5,25.4,66.04,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (634,'Avery Letter Size','4021 Address','C',0.0,11.43,23.81,76.2,25.4,78.74,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (635,'Avery Letter Size','4145 Address','C',0.0,12.7,23.81,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (636,'Avery Letter Size','4013 Address','C',0.0,9.53,23.81,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (637,'Avery Letter Size','R-4013 Address','C',0.0,9.53,23.81,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (638,'Avery Letter Size','4030 Address','C',0.0,11.43,23.81,88.9,25.4,91.44,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (639,'Avery Letter Size','4031 Address','C',0.0,8.89,23.81,88.9,25.4,91.44,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (640,'Avery Letter Size','4029 Address','C',0.0,11.43,23.81,88.9,25.4,91.44,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (641,'Avery Letter Size','4060 Address','C',0.0,9.53,36.51,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (642,'Avery Letter Size','4065 Address','C',0.0,12.7,23.81,101.6,25.4,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (643,'Avery Letter Size','4143 Address','C',0.0,16.51,23.81,101.6,25.4,104.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (644,'Avery Letter Size','4066 Address','C',0.0,8.89,23.81,101.6,25.4,104.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (645,'Avery Letter Size','4146 Address','C',0.0,9.53,36.51,101.6,38.1,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (646,'Avery Letter Size','4014 Address','C',0.0,9.53,36.51,101.6,38.1,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (647,'Avery Letter Size','4032 Address','C',0.0,8.89,36.51,101.6,38.1,104.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (648,'Avery Letter Size','4033 Address','C',0.0,8.89,36.51,101.6,38.1,104.14,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (649,'Avery Letter Size','4022 Address','C',0.0,12.7,49.21,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (650,'Avery Letter Size','4162 Address-Clear','C',0.0,9.53,23.81,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (651,'Avery Letter Size','4601 Address-Clear','C',0.0,9.53,23.81,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (652,'Avery Letter Size','4161 Shipping-Red Border','C',0.0,9.53,74.61,101.6,76.2,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (653,'Avery Letter Size','4088 Shipping','C',0.0,9.53,74.61,107.95,76.2,107.95,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (654,'Avery Letter Size','4076 Shipping','C',0.0,9.53,74.61,127.0,76.2,127.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (655,'Avery Letter Size','4110 Shipping','C',0.0,9.53,74.61,146.05,76.2,146.05,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (656,'Avery Letter Size','4027 File Folder / Address','C',0.0,9.53,11.11,88.9,12.7,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (657,'Avery Letter Size','4255 File Folder','C',0.0,12.7,11.11,88.9,12.7,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (658,'Avery Letter Size','4266 File Folder-Assorted','C',0.0,12.7,11.11,88.9,12.7,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (659,'Avery Letter Size','4163 Piggyback','C',0.0,9.53,23.81,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (660,'Avery Letter Size','4160 Name Badge','C',0.0,9.53,61.91,88.9,63.5,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (661,'Avery Letter Size','4241 3-1/2\" Diskette','C',0.0,22.23,69.85,69.85,76.2,69.85,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (662,'Avery Letter Size','4166 Index Card','C',0.0,12.7,76.2,127.0,76.2,127.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (663,'Avery Letter Size','4167 Post Card','C',0.0,12.7,88.9,152.4,88.9,152.4,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (664,'Avery Letter Size','4037 Address','C',0.0,8.89,23.81,63.5,25.4,66.04,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (665,'Avery Letter Size','4020 Address','C',0.0,12.7,23.81,76.2,25.4,76.2,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (666,'Avery Letter Size','4109 Address','C',0.0,16.51,23.81,83.82,25.4,86.36,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (667,'Avery Letter Size','4018 Address - Removable','C',0.0,9.53,23.81,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (668,'Avery Letter Size','4062 Address','C',0.0,8.89,36.51,88.9,38.1,91.44,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (669,'Avery Letter Size','4035 Address','C',0.0,9.53,49.21,88.9,50.8,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (670,'Avery Letter Size','4052 Data Storage','C',0.0,9.53,46.04,98.43,50.8,98.43,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (671,'Avery Letter Size','4067 Address','C',0.0,8.89,23.81,101.6,25.4,104.14,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (672,'Avery Letter Size','4019 Address - Removable','C',0.0,9.53,36.51,101.6,38.1,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (673,'Avery Letter Size','4015 Address','C',0.0,12.7,23.81,127.0,25.4,127.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (674,'Avery Letter Size','4090 Address','C',0.0,12.7,49.21,127.0,50.8,127.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (675,'Avery Letter Size','4043 Shipping','C',0.0,12.7,77.79,139.7,84.67,139.7,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (676,'Avery Zweckform','2493 Inkjet-Photo-Papier blanko','S',12.5,17.5,90.0,129.5,95.0,132.5,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (677,'Avery Zweckform','2494 Inkjet-Photo-Papier blanko','S',24.25,30.0,100.0,150.0,148.5,150.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (678,'Avery Zweckform','2495 Inkjet-Photo-Papier blanko','S',17.5,15.0,129.5,180.0,132.5,180.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (679,'Avery Zweckform','32010 Visitenkarten blanko','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (680,'Avery Zweckform','32011 Visitenkarten blanko schnittgestanzt','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (681,'Avery Zweckform','32012 Visitenkarten blanko schnittgestanzt','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (682,'Avery Zweckform','32014 Inkjet-Visitenkarten blanko','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (683,'Avery Zweckform','32017 Doppel-Visitenkarten blanko','S',13.5,20.0,54.0,170.0,54.0,170.0,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (684,'Avery Zweckform','32020 Visitenkarten marmoriert','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (685,'Avery Zweckform','32021 Visitenkarten marmoriert','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (686,'Avery Zweckform','32022 Visitenkarten marmoriert','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (687,'Avery Zweckform','32023 Visitenkarten marmoriert','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (688,'Avery Zweckform','32029 Visitenkarten blanko Glossy','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (689,'Avery Zweckform','32030 Visitenkarten Blue Wave','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (690,'Avery Zweckform','32031 Visitenkarten Paradise','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (691,'Avery Zweckform','32032 Visitenkarten Sahara','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (692,'Avery Zweckform','32036 Visitenkarten Cosmic','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (693,'Avery Zweckform','32040 Visitenkarten blanko','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (694,'Avery Zweckform','32060 Inkjet Bütten-Papier Cream','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (695,'Avery Zweckform','32061 Inkjet Bütten-Papier Aqua','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (696,'Avery Zweckform','32062 Inkjet Bütten-Papier Jade','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (697,'Avery Zweckform','32063 Inkjet Bütten-Papier Sand','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (698,'Avery Zweckform','32064 Inkjet-Papier Leinenstruktur','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (699,'Avery Zweckform','32065 Inkjet-Papier Hammerschlag','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (700,'Avery Zweckform','32080 Marmoriertes Papier','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (701,'Avery Zweckform','32081 Marmoriertes Papier','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (702,'Avery Zweckform','32082 Marmoriertes Papier','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (703,'Avery Zweckform','32083 Marmoriertes Papier','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (704,'Avery Zweckform','32098 Urkunde marmoriert Text rot','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (705,'Avery Zweckform','32099 Urkunde marmoriert Text gold','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (706,'Avery Zweckform','32250 CD-Einleger blanko','S',24.0,29.5,249.0,151.0,249.0,151.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (707,'Avery Zweckform','32251 Inkjet-CD-Einleger','S',24.0,29.5,249.0,151.0,249.0,151.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (708,'Avery Zweckform','32252 Postkarte blanko','S',0.0,0.0,105.0,148.5,105.0,148.5,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (709,'Avery Zweckform','32253 Tischkarte blanko','S',25.0,38.5,80.0,110.0,80.0,110.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (710,'Avery Zweckform','32254 Karteikarte blanko','S',8.5,0.0,70.0,105.0,70.0,105.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (711,'Avery Zweckform','32255 Cassetten-Einleger blanko','S',27.0,23.75,156.0,101.0,156.0,101.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (712,'Avery Zweckform','32256 Video-Einleger blanko','S',10.0,19.5,190.0,258.0,190.0,258.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (713,'Avery Zweckform','32257 Tischkarte lang blanko','S',8.5,0.0,140.0,210.0,140.0,210.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (714,'Avery Zweckform','32258 Regalschilder','S',15.5,0.0,38.0,105.0,38.0,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (715,'Avery Zweckform','32286 Inkjet-Glückwunschkarten blanko','S',0.0,0.0,210.0,297.0,210.0,297.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (716,'Avery Zweckform','32287 Inkjet-Glückwunschkarten blanko','S',0.0,0.0,148.5,210.0,148.5,210.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (717,'Avery Zweckform','32288 Inkjet-Glückwunschkarten blanko','S',27.0,40.5,156.0,216.0,156.0,216.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (718,'Avery Zweckform','32289 Inkjet-Glückwunschkarten blanko','S',0.0,0.0,210.0,297.0,210.0,297.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (719,'Avery Zweckform','C9312 Glossy Visitenkarten schnittgestanzt','S',31.5,17.0,54.0,85.0,60.0,91.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (720,'Avery Zweckform','3415 Kreise','S',13.43,16.0,40.0,40.0,46.0,46.0,4,6, NULL, NULL ) +INSERT INTO label_def VALUES (721,'Avery Zweckform','3416 Kreise','S',17.93,8.0,60.0,60.0,67.0,67.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (722,'Avery Zweckform','3418 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,296.86,200.0,296.86,200.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (723,'Avery Zweckform','3420 Inkjet+Laser+Kopier-Etiketten','S',4.78,0.0,16.9,70.0,16.9,70.0,3,17, NULL, NULL ) +INSERT INTO label_def VALUES (724,'Avery Zweckform','3421 Inkjet+Laser+Kopier-Etiketten','S',8.73,0.0,25.4,70.0,25.4,70.0,3,11, NULL, NULL ) +INSERT INTO label_def VALUES (725,'Avery Zweckform','3422 Inkjet+Laser+Kopier-Etiketten','S',8.43,0.0,35.0,70.0,35.0,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (726,'Avery Zweckform','3423 Inkjet+Laser+Kopier-Etiketten','S',8.43,0.0,35.0,105.0,35.0,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (727,'Avery Zweckform','3424 Inkjet+Laser+Kopier-Etiketten','S',4.43,0.0,48.0,105.0,48.0,105.0,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (728,'Avery Zweckform','3425 Inkjet+Laser+Kopier-Etiketten','S',5.93,0.0,57.0,105.0,57.0,105.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (729,'Avery Zweckform','3426 Inkjet+Laser+Kopier-Etiketten','S',8.43,0.0,70.0,105.0,70.0,105.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (730,'Avery Zweckform','3427 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,74.2,105.0,74.2,105.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (731,'Avery Zweckform','3448 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,37.1,70.0,37.1,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (732,'Avery Zweckform','3449 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,37.1,70.0,37.1,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (733,'Avery Zweckform','3450 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,37.1,70.0,37.1,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (734,'Avery Zweckform','3451 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,37.1,70.0,37.1,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (735,'Avery Zweckform','3452 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,37.1,105.0,37.1,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (736,'Avery Zweckform','3453 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,37.1,105.0,37.1,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (737,'Avery Zweckform','3454 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,37.1,105.0,37.1,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (738,'Avery Zweckform','3455 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,37.1,105.0,37.1,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (739,'Avery Zweckform','3456 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,105.0,148.43,105.0,148.43,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (740,'Avery Zweckform','3457 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,105.0,148.43,105.0,148.43,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (741,'Avery Zweckform','3458 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,105.0,148.43,105.0,148.43,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (742,'Avery Zweckform','3459 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,105.0,148.43,105.0,148.43,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (743,'Avery Zweckform','3470 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (744,'Avery Zweckform','3471 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (745,'Avery Zweckform','3472 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (746,'Avery Zweckform','3473 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (747,'Avery Zweckform','3474 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,37.1,70.0,37.1,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (748,'Avery Zweckform','3475 Inkjet+Laser+Kopier-Etiketten','S',4.43,0.0,36.0,70.0,36.0,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (749,'Avery Zweckform','3477 Inkjet+Laser+Kopier-Etiketten','S',4.93,0.0,41.0,105.0,41.0,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (750,'Avery Zweckform','3478 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (751,'Avery Zweckform','3479 Inkjet+Laser+Kopier-Etiketten','S',4.43,0.0,32.0,70.0,32.0,70.0,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (752,'Avery Zweckform','3481 Inkjet+Laser+Kopier-Etiketten','S',4.93,0.0,41.0,70.0,41.0,70.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (753,'Avery Zweckform','3483 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,105.0,148.43,105.0,148.43,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (754,'Avery Zweckform','3484 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,37.1,105.0,37.1,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (755,'Avery Zweckform','3489 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,29.69,70.0,29.69,70.0,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (756,'Avery Zweckform','3490 Inkjet+Laser+Kopier-Etiketten','S',4.43,0.0,36.0,70.0,36.0,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (757,'Avery Zweckform','3651 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,29.69,52.5,29.69,52.5,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (758,'Avery Zweckform','3652 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,42.41,70.0,42.41,70.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (759,'Avery Zweckform','3653 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,42.41,105.0,42.41,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (760,'Avery Zweckform','3654 CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (761,'Avery Zweckform','3655 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,148.43,210.0,148.43,210.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (762,'Avery Zweckform','3657 Inkjet+Laser+Kopier-Etiketten','S',21.43,8.0,25.4,48.5,25.4,48.5,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (763,'Avery Zweckform','3658 Inkjet+Laser+Kopier-Etiketten','S',13.23,8.1,33.8,64.6,33.8,64.6,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (764,'Avery Zweckform','3659 Inkjet+Laser+Kopier-Etiketten','S',21.53,8.0,42.3,97.0,42.3,97.0,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (765,'Avery Zweckform','3660 Inkjet+Laser+Kopier-Etiketten','S',13.03,8.0,67.7,97.0,67.7,97.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (766,'Avery Zweckform','3661 Inkjet+Laser+Kopier-Etiketten','S',13.03,0.0,67.7,70.0,67.7,70.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (767,'Avery Zweckform','3662 Ordnerrücken-Etiketten schmal','S',9.0,12.43,192.0,34.0,192.0,34.0,8,1, NULL, NULL ) +INSERT INTO label_def VALUES (768,'Avery Zweckform','3663 Ordnerrücken-Etiketten breit','S',9.0,30.43,192.0,59.0,192.0,59.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (769,'Avery Zweckform','3664 Inkjet+Laser+Kopier-Etiketten','S',13.23,0.0,33.8,70.0,33.8,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (770,'Avery Zweckform','3665 Inkjet+Laser+Kopier-Etiketten','S',13.23,0.0,33.8,105.0,33.8,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (771,'Avery Zweckform','3666 Inkjet+Laser+Kopier-Etiketten','S',10.63,9.75,21.2,38.1,21.2,38.1,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (772,'Avery Zweckform','3667 Inkjet+Laser+Kopier-Etiketten','S',13.23,8.0,16.9,48.5,16.9,48.5,4,16, NULL, NULL ) +INSERT INTO label_def VALUES (773,'Avery Zweckform','3668 Inkjet+Laser+Kopier-Etiketten','S',0.0,0.0,21.2,52.5,21.2,52.5,4,14, NULL, NULL ) +INSERT INTO label_def VALUES (774,'Avery Zweckform','3669 Inkjet+Laser+Kopier-Etiketten','S',21.43,0.0,50.8,70.0,50.8,70.0,3,5, NULL, NULL ) +INSERT INTO label_def VALUES (775,'Avery Zweckform','3674 Computer-Etiketten','S',1.22,14.36,14.5,25.4,16.93,27.94,3,12, NULL, NULL ) +INSERT INTO label_def VALUES (776,'Avery Zweckform','3675 Computer-Etiketten','S',1.2,15.63,23.0,38.1,25.4,40.64,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (777,'Avery Zweckform','3676 Computer-Etiketten','S',1.23,13.03,18.7,48.2,21.17,50.74,2,9, NULL, NULL ) +INSERT INTO label_def VALUES (778,'Avery Zweckform','3677 Computer-Etiketten für 3 5\" Disk.','S',1.19,19.25,69.6,71.5,71.97,71.5,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (779,'Avery Zweckform','3684 Computer-Etiketten für 3 5\" Disk.','S',1.19,19.25,69.6,71.5,71.97,71.5,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (780,'Avery Zweckform','3685 Computer-Etiketten für 3 5\" Disk.','S',1.19,19.25,69.6,71.5,71.97,71.5,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (781,'Avery Zweckform','3686 Computer-Etiketten für 3 5\" Disk.','S',1.19,19.25,69.6,71.5,71.97,71.5,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (782,'Avery Zweckform','3687 Computer-Etiketten für 3 5\" Disk.','S',1.19,19.25,69.6,71.5,71.97,71.5,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (783,'Avery Zweckform','3688 Ordnerrücken-Etiketten breit','S',9.0,26.43,192.0,61.0,192.0,61.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (784,'Avery Zweckform','3689 Ordnerrücken-Etiketten schmal','S',9.0,15.43,192.0,38.0,192.0,38.0,7,1, NULL, NULL ) +INSERT INTO label_def VALUES (785,'Avery Zweckform','3691 Ordnerrücken-Etiketten breit','S',9.0,26.43,192.0,61.0,192.0,61.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (786,'Avery Zweckform','3692 Ordnerrücken-Etiketten breit','S',9.0,26.43,192.0,61.0,192.0,61.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (787,'Avery Zweckform','3693 Ordnerrücken-Etiketten breit','S',9.0,26.43,192.0,61.0,192.0,61.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (788,'Avery Zweckform','3694 Ordnerrücken-Etiketten breit','S',9.0,26.43,192.0,61.0,192.0,61.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (789,'Avery Zweckform','3696 Ordnerrücken-Etiketten schmal','S',9.0,15.43,192.0,38.0,192.0,38.0,7,1, NULL, NULL ) +INSERT INTO label_def VALUES (790,'Avery Zweckform','3697 Ordnerrücken-Etiketten schmal','S',9.0,15.43,192.0,38.0,192.0,38.0,7,1, NULL, NULL ) +INSERT INTO label_def VALUES (791,'Avery Zweckform','3698 Ordnerrücken-Etiketten schmal','S',9.0,15.43,192.0,38.0,192.0,38.0,7,1, NULL, NULL ) +INSERT INTO label_def VALUES (792,'Avery Zweckform','3699 Ordnerrücken-Etiketten schmal','S',9.0,15.43,192.0,38.0,192.0,38.0,7,1, NULL, NULL ) +INSERT INTO label_def VALUES (793,'Avery Zweckform','4720 Transparente Etiketten','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (794,'Avery Zweckform','4721 Transparente Etiketten','S',15.1,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (795,'Avery Zweckform','4722 Transparente Etiketten','S',21.43,7.73,50.8,96.0,50.8,98.54,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (796,'Avery Zweckform','4723 Transparente Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (797,'Avery Zweckform','4730 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',13.43,4.67,10.0,17.78,10.0,20.32,10,27, NULL, NULL ) +INSERT INTO label_def VALUES (798,'Avery Zweckform','4731 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',13.43,8.48,10.0,25.4,10.0,27.94,7,27, NULL, NULL ) +INSERT INTO label_def VALUES (799,'Avery Zweckform','4732 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',12.99,11.02,16.93,35.56,16.93,38.1,5,16, NULL, NULL ) +INSERT INTO label_def VALUES (800,'Avery Zweckform','4733 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',0.0,0.0,105.0,148.43,105.0,148.43,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (801,'Avery Zweckform','4734 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',0.0,0.0,148.43,210.0,148.43,210.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (802,'Avery Zweckform','4735 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (803,'Avery Zweckform','4736 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (804,'Avery Zweckform','4737 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',15.1,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (805,'Avery Zweckform','4738 Disketten-Etiketten Stick+Lift','S',21.43,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (806,'Avery Zweckform','4739 Disketten-Etiketten Stick+Lift','S',21.43,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (807,'Avery Zweckform','4740 Disketten-Etiketten Stick+Lift','S',12.97,25.0,67.73,70.0,67.73,90.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (808,'Avery Zweckform','4741 Disketten-Etiketten Stick+Lift','S',12.97,25.0,67.73,70.0,67.73,90.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (809,'Avery Zweckform','4742 Video-Etiketten Stick+Lift','S',8.72,24.99,46.57,78.74,46.57,81.28,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (810,'Avery Zweckform','4743 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',21.44,7.73,42.33,96.0,42.33,98.54,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (811,'Avery Zweckform','4744 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',21.43,7.73,50.8,96.0,50.8,98.54,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (812,'Avery Zweckform','4745 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',21.43,7.73,63.5,96.0,63.5,98.54,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (813,'Avery Zweckform','4746 Video-Etiketten Stick+Lift','S',18.43,31.34,20.0,147.32,20.0,147.32,1,13, NULL, NULL ) +INSERT INTO label_def VALUES (814,'Avery Zweckform','4747 Etiketten für ZIP-Disketten','S',23.43,13.96,50.0,59.0,50.0,61.54,3,5, NULL, NULL ) +INSERT INTO label_def VALUES (815,'Avery Zweckform','4748 Ordnerrücken-Etiketten schmal','S',0.0,10.0,296.86,38.0,296.86,38.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (816,'Avery Zweckform','4749 Ordnerrücken-Etiketten schmal','S',0.0,10.0,296.86,38.0,296.86,38.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (817,'Avery Zweckform','4750 Ordnerrücken-Etiketten schmal','S',0.0,10.0,296.86,38.0,296.86,38.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (818,'Avery Zweckform','4751 Ordnerrücken-Etiketten schmal','S',0.0,10.0,296.86,38.0,296.86,38.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (819,'Avery Zweckform','4752 Ordnerrücken-Etiketten breit','S',0.0,13.5,296.86,61.0,296.86,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (820,'Avery Zweckform','4753 Ordnerrücken-Etiketten breit','S',0.0,13.5,296.86,61.0,296.86,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (821,'Avery Zweckform','4754 Ordnerrücken-Etiketten breit','S',0.0,13.5,296.86,61.0,296.86,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (822,'Avery Zweckform','4755 Ordnerrücken-Etiketten breit','S',0.0,13.5,296.86,61.0,296.86,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (823,'Avery Zweckform','4756 Hängeordner-Etiketten schmal','S',0.0,20.0,296.86,34.0,296.86,34.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (824,'Avery Zweckform','4757 Hängeordner-Etiketten breit','S',0.0,10.5,296.86,63.0,296.86,63.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (825,'Avery Zweckform','4758 Ordnerrücken-Etiketten schmal','S',0.0,10.0,296.86,38.0,296.86,38.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (826,'Avery Zweckform','4759 Ordnerrücken-Etiketten breit','S',0.0,13.5,296.86,61.0,296.86,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (827,'Avery Zweckform','4760 Ordnerrücken-Etiketten schmal','S',9.0,15.43,192.0,38.0,192.0,38.0,7,1, NULL, NULL ) +INSERT INTO label_def VALUES (828,'Avery Zweckform','4761 Ordnerrücken-Etiketten breit','S',9.0,26.43,192.0,61.0,192.0,61.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (829,'Avery Zweckform','4762 Ordnerrücken-Etiketten schmal','S',9.0,15.43,192.0,38.0,192.0,38.0,7,1, NULL, NULL ) +INSERT INTO label_def VALUES (830,'Avery Zweckform','4763 Ordnerrücken-Etiketten schmal','S',9.0,15.43,192.0,38.0,192.0,38.0,7,1, NULL, NULL ) +INSERT INTO label_def VALUES (831,'Avery Zweckform','4764 Ordnerrücken-Etiketten schmal','S',9.0,15.43,192.0,38.0,192.0,38.0,7,1, NULL, NULL ) +INSERT INTO label_def VALUES (832,'Avery Zweckform','4765 Ordnerrücken-Etiketten schmal','S',9.0,15.43,192.0,38.0,192.0,38.0,7,1, NULL, NULL ) +INSERT INTO label_def VALUES (833,'Avery Zweckform','4766 Ordnerrücken-Etiketten breit','S',9.0,26.43,192.0,61.0,192.0,61.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (834,'Avery Zweckform','4767 Ordnerrücken-Etiketten breit','S',9.0,26.43,192.0,61.0,192.0,61.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (835,'Avery Zweckform','4768 Ordnerrücken-Etiketten breit','S',9.0,26.43,192.0,61.0,192.0,61.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (836,'Avery Zweckform','4769 Ordnerrücken-Etiketten breit','S',9.0,26.43,192.0,61.0,192.0,61.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (837,'Avery Zweckform','4770 Transparente Etiketten','S',21.43,8.0,25.4,48.5,25.4,48.5,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (838,'Avery Zweckform','4771 Transparente Etiketten','S',0.0,0.0,37.1,70.0,37.1,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (839,'Avery Zweckform','4772 Transparente Etiketten','S',21.53,8.0,42.3,97.0,42.3,97.0,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (840,'Avery Zweckform','4773 Wetterfeste Etiketten','S',13.23,8.1,33.8,64.6,33.8,64.6,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (841,'Avery Zweckform','4774 Wetterfeste Etiketten','S',0.0,0.0,105.0,148.43,105.0,148.43,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (842,'Avery Zweckform','4775 Wetterfeste Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (843,'Avery Zweckform','4776 Wetterfeste Etiketten','S',21.53,8.0,42.3,97.0,42.3,97.0,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (844,'Avery Zweckform','4777 Transparente Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (845,'Avery Zweckform','4780 Inkjet+Laser+Kopier-Etiketten','S',21.43,8.0,25.4,48.5,25.4,48.5,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (846,'Avery Zweckform','4781 Inkjet+Laser+Kopier-Etiketten','S',21.53,8.0,42.3,97.0,42.3,97.0,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (847,'Avery Zweckform','4782 Inkjet+Laser+Kopier-Etiketten','S',13.03,8.0,67.7,97.0,67.7,97.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (848,'Avery Zweckform','4784 Namens-Etiketten','S',15.1,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (849,'Avery Zweckform','4790 Inkjet-Etiketten rund','S',13.43,16.0,40.0,40.0,46.0,46.0,4,6, NULL, NULL ) +INSERT INTO label_def VALUES (850,'Avery Zweckform','4791 Inkjet-Etiketten','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (851,'Avery Zweckform','4792 Inkjet-Etiketten','S',15.1,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (852,'Avery Zweckform','4793 Inkjet-Etiketten','S',21.44,7.73,42.33,96.0,42.33,98.54,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (853,'Avery Zweckform','4794 Inkjet-Etiketten','S',21.43,7.73,63.5,96.0,63.5,98.54,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (854,'Avery Zweckform','4795 Inkjet-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (855,'Avery Zweckform','4798 Disketten-Etiketten Photo-Qualität','S',21.43,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (856,'Avery Zweckform','4799 Inkjet-Etiketten oval','S',15.09,7.73,63.5,96.0,67.73,98.54,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (857,'Avery Zweckform','6002 Neon-Etiketten','S',17.93,8.0,60.0,60.0,67.0,67.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (858,'Avery Zweckform','6003 Neon-Etiketten','S',15.1,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (859,'Avery Zweckform','6004 Neon-Etiketten','S',15.1,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (860,'Avery Zweckform','6005 Neon-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (861,'Avery Zweckform','6006 Neon-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (862,'Avery Zweckform','6008 Typenschild-Etiketten','S',13.43,8.48,10.0,25.4,10.0,27.94,7,27, NULL, NULL ) +INSERT INTO label_def VALUES (863,'Avery Zweckform','6009 Typenschild-Etiketten','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (864,'Avery Zweckform','6011 Typenschild-Etiketten','S',15.1,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (865,'Avery Zweckform','6012 Typenschild-Etiketten','S',21.43,7.73,50.8,96.0,50.8,98.54,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (866,'Avery Zweckform','6013 Typenschild-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (867,'Avery Zweckform','6014 Etiketten für CD-Hüllen','S',16.43,47.85,5.5,114.3,5.5,114.3,1,48, NULL, NULL ) +INSERT INTO label_def VALUES (868,'Avery Zweckform','6015 CD-Etiketten incl. Zentrierhilfe','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (869,'Avery Zweckform','6019 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',16.43,11.1,10.0,10.0,12.7,12.7,15,21, NULL, NULL ) +INSERT INTO label_def VALUES (870,'Avery Zweckform','6020 Dia-Etiketten Stick+Lift','S',12.91,14.83,8.47,43.18,8.47,45.72,4,32, NULL, NULL ) +INSERT INTO label_def VALUES (871,'Avery Zweckform','6021 Sichtreiter-Etiketten Stick+Lift','S',12.99,9.75,16.93,45.72,16.93,48.26,4,16, NULL, NULL ) +INSERT INTO label_def VALUES (872,'Avery Zweckform','6022 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',12.91,7.21,8.47,63.5,8.47,66.04,3,32, NULL, NULL ) +INSERT INTO label_def VALUES (873,'Avery Zweckform','6023 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',15.08,7.21,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (874,'Avery Zweckform','6024 Inkjet+Laser+Kopier-Etiketten Stick+Lift ','S',10.87,7.21,42.33,63.5,46.56,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (875,'Avery Zweckform','6025 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',8.72,7.21,46.57,63.5,46.57,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (876,'Avery Zweckform','6026 Disketten-Etiketten Stick+Lift','S',21.43,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (877,'Avery Zweckform','6029 Disketten-Etiketten Stick+Lift','S',21.43,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (878,'Avery Zweckform','6030 Cassetten-Etiketten Stick+Lift','S',21.53,14.73,42.3,89.0,42.3,91.54,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (879,'Avery Zweckform','6031 Inkjet+Laser+Kopier-Etiketten Stick+Lift','S',12.99,7.73,16.93,96.0,16.93,98.54,2,16, NULL, NULL ) +INSERT INTO label_def VALUES (880,'Avery Zweckform','6036 Inkjet+Laser+Kopier-Etiketten','S',13.43,8.48,10.0,25.4,10.0,27.94,7,27, NULL, NULL ) +INSERT INTO label_def VALUES (881,'Avery Zweckform','6037 Inkjet+Laser+Kopier-Etiketten','S',13.43,8.48,10.0,25.4,10.0,27.94,7,27, NULL, NULL ) +INSERT INTO label_def VALUES (882,'Avery Zweckform','6038 Inkjet+Laser+Kopier-Etiketten','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (883,'Avery Zweckform','6039 Inkjet+Laser+Kopier-Etiketten','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (884,'Avery Zweckform','6040 Inkjet+Laser+Kopier-Etiketten','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (885,'Avery Zweckform','6041 Inkjet+Laser+Kopier-Etiketten','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (886,'Avery Zweckform','6043 CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (887,'Avery Zweckform','6044 CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (888,'Avery Zweckform','6045 CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (889,'Avery Zweckform','6046 CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (890,'Avery Zweckform','6047 CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (891,'Avery Zweckform','6058 Ordnerrücken-Etiketten schmal','S',0.0,20.0,296.86,34.0,296.86,34.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (892,'Avery Zweckform','6059 Ordnerrücken-Etiketten breit','S',0.0,16.5,296.86,59.0,296.86,59.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (893,'Avery Zweckform','6060 Ordnerrücken-Etiketten schmal','S',9.0,12.43,192.0,34.0,192.0,34.0,8,1, NULL, NULL ) +INSERT INTO label_def VALUES (894,'Avery Zweckform','6061 Ordnerrücken-Etiketten breit','S',9.0,30.43,192.0,59.0,192.0,59.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (895,'Avery Zweckform','6074 Inkjet-Glossy-CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (896,'Avery Zweckform','6077 Inkjet-Glossy-Etiketten','S',13.56,19.32,88.9,127.0,93.98,131.23,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (897,'Avery Zweckform','6078 Inkjet-Glossy-Etiketten','S',18.43,16.0,127.0,178.0,133.0,178.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (898,'Avery Zweckform','6079 Inkjet-Glossy-Etiketten oval','S',10.87,7.21,42.33,63.5,46.56,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (899,'Avery Zweckform','6080 Inkjet-Glossy-Etiketten','S',23.55,7.21,46.57,63.5,50.8,66.04,3,5, NULL, NULL ) +INSERT INTO label_def VALUES (900,'Avery Zweckform','6081 Inkjet-Glossy-Etiketten','S',15.09,13.56,63.5,88.9,67.73,93.98,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (901,'Avery Zweckform','6082 Inkjet-Glossy-CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (902,'Avery Zweckform','6083 Inkjet-Glossy-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (903,'Avery Zweckform','6090 Korrektur- und Abdeck-Etiketten','S',13.23,8.0,16.9,48.5,16.9,48.5,4,16, NULL, NULL ) +INSERT INTO label_def VALUES (904,'Avery Zweckform','6091 Korrektur- und Abdeck-Etiketten','S',13.23,8.1,33.8,64.6,33.8,64.6,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (905,'Avery Zweckform','6092 Korrektur- und Abdeck-Etiketten','S',21.53,8.0,42.3,97.0,42.3,97.0,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (906,'Avery Zweckform','6093 Korrektur- und Abdeck-Etiketten','S',0.0,0.0,105.0,148.43,105.0,148.43,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (907,'Avery Zweckform','6094 Korrektur- und Abdeck-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (908,'Avery Zweckform','6102 Farbige Folien-Etiketten','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (909,'Avery Zweckform','6103 Farbige Folien-Etiketten','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (910,'Avery Zweckform','6104 Farbige Folien-Etiketten','S',15.1,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (911,'Avery Zweckform','6105 Farbige Folien-Etiketten','S',15.1,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (912,'Avery Zweckform','6106 Farbige Folien-Etiketten','S',21.44,7.73,42.33,96.0,42.33,98.54,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (913,'Avery Zweckform','6107 Farbige Folien-Etiketten','S',21.44,7.73,42.33,96.0,42.33,98.54,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (914,'Avery Zweckform','6108 Farbige Folien-Etiketten','S',0.0,0.0,74.22,210.0,74.22,210.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (915,'Avery Zweckform','6109 Farbige Folien-Etiketten','S',0.0,0.0,74.22,210.0,74.22,210.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (916,'Avery Zweckform','6110 Farbige Folien-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (917,'Avery Zweckform','6111 Farbige Folien-Etiketten','S',0.0,0.0,296.86,210.0,296.86,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (918,'Avery Zweckform','6112 Sicherheits-Etiketten','S',13.43,16.0,40.0,40.0,46.0,46.0,4,6, NULL, NULL ) +INSERT INTO label_def VALUES (919,'Avery Zweckform','6113 Sicherheits-Etiketten','S',21.41,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (920,'Avery Zweckform','6114 Sicherheits-Etiketten','S',15.1,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (921,'Avery Zweckform','6115 CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (922,'Avery Zweckform','6116 MiniDisc-Etiketten','S',13.5,5.75,52.0,35.5,54.5,35.5,5,5, NULL, NULL ) +INSERT INTO label_def VALUES (923,'Avery Zweckform','6117 CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (924,'Avery Zweckform','6118 CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (925,'Avery Zweckform','L7767 Farblaser-Glossy-Etiketten','S',1.0,0.5,295.0,209.0,295.0,209.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (926,'Avery Zweckform','L7768 Farblaser-Glossy-Etiketten','S',5.0,5.2,143.5,199.6,143.5,199.6,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (927,'Avery Zweckform','L7769 Farblaser-Glossy-Etiketten','S',9.5,4.63,139.0,99.1,139.0,101.64,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (928,'Avery Zweckform','L7765 Farblaser-Glossy-Etiketten','S',13.04,4.67,67.7,99.1,67.7,101.64,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (929,'Avery Zweckform','C9660 SuperSize Inkjet-Glossy-CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (930,'Avery Zweckform','L7760 SuperSize Farblaser-Glossy-CD-Etiketten','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (931,'Avery Zweckform','J8776 Inkjet-Stardust-CD-Etiketten*','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (932,'Avery Zweckform','J8871 Inkjet-Magnet-Schilder**','S',22.43,24.5,28.0,78.0,28.0,78.0,2,9, NULL, NULL ) +INSERT INTO label_def VALUES (933,'Avery Zweckform','J8875 Inkjet-Magnet-Schilder**','S',5.0,8.43,50.0,140.0,50.0,140.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (934,'Avery Zweckform','J8867 Inkjet-Magnet-Schilder**','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (935,'Avery Zweckform','C2166 Etikett rechteckig','S',33.6,31.9,52.0,70.0,59.27,76.2,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (936,'Avery Zweckform','C2243 Etikett rund klein','S',27.85,22.05,38.1,38.1,50.8,42.6,4,5, NULL, NULL ) +INSERT INTO label_def VALUES (937,'Avery Zweckform','C2351 Glückwunschkarten A5','S',0.0,0.0,210.0,297.0,210.0,297.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (938,'Avery Zweckform','C2354 Visitenkarten bis zum Rand','S',34.27,22.5,50.8,80.37,59.22,85.13,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (939,'Avery Zweckform','C2355 Glückwunschkarten Standard','S',25.4,22.45,120.72,165.1,125.48,165.1,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (940,'Avery Zweckform','C2410 Clubkarten laminiert','S',30.5,107.0,50.0,81.5,93.0,81.5,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (941,'Avery Zweckform','C2651 Etikett rechteckig klein','S',10.9,4.67,21.17,38.1,21.17,40.64,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (942,'Avery Zweckform','C9405 T-Shirt Transferfolie','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (943,'Avery Zweckform','C2547 Fantastic Plastic','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (944,'Avery Zweckform','C2070 Transfer-Folie für Mousepad','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (945,'Avery Zweckform','C2090 T-Shirt Transfer-Folie','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (946,'Avery Zweckform','C2080 Transfer-Folie für Puzzles','S',20.0,26.0,170.0,245.0,170.0,245.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (947,'Avery Zweckform','J8416 Einladungskarten mit Klebeverschluss','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (948,'Avery Zweckform','C2546 Fensterbilder','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (949,'Avery Zweckform','C9660 CD-Etiketten glossy Super-Size','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (950,'Avery Zweckform','J8770 CD-Etiketten Super-Ssize','S',21.43,46.5,117.0,117.0,137.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (951,'Avery Zweckform','C2050 Video-Etiketten seitlich','S',18.43,31.34,20.0,147.32,20.0,147.32,1,13, NULL, NULL ) +INSERT INTO label_def VALUES (952,'Avery Zweckform','C2050 Video-Etiketten oben','S',8.72,24.99,46.57,78.74,46.57,81.28,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (953,'Avery Zweckform','J8666 Disketten-Etiketten','S',18.5,23.35,52.0,70.0,52.0,93.3,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (954,'Avery Zweckform','J9124 Photo-Etiketten 13 x 18','S',17.5,15.0,129.5,180.0,132.5,180.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (955,'Avery Zweckform','L7424 Ordner-Etiketten breit','S',9.0,30.43,192.0,59.0,192.0,59.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (956,'Avery Zweckform','L7425 Ordner-Etiketten schmal','S',9.0,12.43,192.0,34.0,192.0,34.0,8,1, NULL, NULL ) +INSERT INTO label_def VALUES (957,'Avery Zweckform','J8587 Inkjet-Folie','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (958,'Avery Zweckform','L7587 Laser-Folie','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (959,'Avery Zweckform','C9431 Photo-Papier glossy','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (960,'Avery Zweckform','C9434 Photo-Karton glossy','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (961,'Avery Zweckform','C9372 Photo-Papier glossy 9 x 13','S',12.5,17.5,90.0,129.5,95.0,132.5,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (962,'Avery Zweckform','C2371 Inkjet-Papier','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (963,'Avery Zweckform','C2370 Inkjet-Papier','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (964,'Avery Zweckform','C2374 Marmoriertes Papier','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (965,'Avery Zweckform','C2375 Marmoriertes Papier','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (966,'Avery Zweckform','C2376 Marmoriertes Papier','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (967,'Avery Zweckform','C2377 Marmoriertes Papier','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (968,'Avery Zweckform','C9355 Postkarten Vorderseite','S',36.0,31.0,105.0,148.0,120.0,148.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (969,'Avery Zweckform','C9355 Postkarten Rückseite','S',36.0,31.0,105.0,148.0,120.0,148.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (970,'Avery Zweckform','J8435 CD-Einleger','S',24.0,29.5,249.0,151.0,249.0,151.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (971,'Avery Zweckform','C9362 Visitenkarten glossy','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (972,'Avery Zweckform','C2364 Marmorierte Visitenkarten','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (973,'Avery Zweckform','C2365 Marmorierte Visitenkarten','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (974,'Avery Zweckform','C2366 Marmorierte Visitenkarten','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (975,'Avery Zweckform','C2367 Marmorierte Visitenkarten','S',13.5,15.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (976,'Avery Zweckform','C9352 Glückwunschkarten A6 glossy','S',25.4,22.45,120.72,82.55,125.48,82.55,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (977,'Avery Zweckform','L7159 Laser-Etiketten','S',13.06,6.46,33.9,64.0,33.9,66.54,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (978,'Avery Zweckform','L7160 Laser-Etiketten','S',15.15,7.2,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (979,'Avery Zweckform','L7161 Laser-Etiketten','S',8.82,7.21,46.6,63.5,46.6,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (980,'Avery Zweckform','L7162 Laser-Etiketten','S',13.02,4.67,46.6,63.5,46.6,66.04,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (981,'Avery Zweckform','L7163 Laser-Etiketten','S',15.15,4.67,38.1,99.1,38.1,101.64,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (982,'Avery Zweckform','L7164 Laser-Etiketten','S',4.57,7.21,72.0,63.5,72.0,66.04,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (983,'Avery Zweckform','L7165 Laser-Etiketten','S',13.04,4.67,67.7,99.1,67.7,101.64,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (984,'Avery Zweckform','L7166 Laser-Etiketten','S',8.8,4.67,93.1,99.1,93.1,101.64,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (985,'Avery Zweckform','L7167 Laser-Etiketten','S',3.97,5.2,289.1,199.6,289.1,199.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (986,'Avery Zweckform','L7168 Laser-Etiketten','S',4.97,5.2,143.5,199.6,143.5,199.6,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (987,'Avery Zweckform','L7169 Laser-Etiketten','S',4.63,9.5,139.0,99.1,139.0,101.64,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (988,'Avery Zweckform','L7173 Laser-Etiketten','S',6.0,4.67,57.0,99.1,57.0,101.64,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (989,'Avery Zweckform','L7651 Laser-Etiketten','S',10.89,4.67,21.2,38.1,21.2,40.64,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (990,'Avery Zweckform','L7410-10 Etiketten Register - Etikettenbogen 10','S',46.9,19.91,12.7,25.4,21.17,48.26,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (991,'Avery Zweckform','L7410-10 Etiketten Register - Inhaltsblatt 10-t','S',4.25,110.0,28.85,100.0,28.85,100.0,1,10, NULL, NULL ) +INSERT INTO label_def VALUES (992,'Avery Zweckform','L7410-12 Etiketten Register - Etikettenbogen 12','S',49.02,25.42,12.7,22.0,16.93,45.72,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (993,'Avery Zweckform','L7410-12 Etiketten Register - Inhaltsblatt 12-t','S',5.1,110.0,23.9,100.0,23.9,100.0,1,12, NULL, NULL ) +INSERT INTO label_def VALUES (994,'Avery Zweckform','L7410-5 Etiketten Register - Etikettenbogen 5-t','S',46.9,25.4,12.7,55.02,21.17,104.19,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (995,'Avery Zweckform','L7410-5 Etiketten Register - Inhaltsblatt 5-tei','S',4.75,110.0,57.5,100.0,57.5,100.0,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (996,'Avery Zweckform','L7411-10 Zahlen Register - Inhaltsblatt 1-10','S',4.25,110.0,28.85,100.0,28.85,100.0,1,10, NULL, NULL ) +INSERT INTO label_def VALUES (997,'Avery Zweckform','L7411-12 Zahlen Register - Inhaltsblatt 1-12','S',5.1,110.0,23.9,100.0,23.9,100.0,1,12, NULL, NULL ) +INSERT INTO label_def VALUES (998,'Avery Zweckform','L7411-15 Zahlen Register - Inhaltsblatt 1-15','S',0.0,110.0,19.8,100.0,19.8,100.0,1,15, NULL, NULL ) +INSERT INTO label_def VALUES (999,'Avery Zweckform','L7411-20 Zahlen Register - Inhaltsblatt 1-20','S',15.0,110.0,13.35,100.0,13.35,100.0,1,20, NULL, NULL ) +INSERT INTO label_def VALUES (1000,'Avery Zweckform','L7411-31 Zahlen Register - Inhaltsblatt 1-31','S',15.0,110.0,8.61,100.0,8.61,100.0,1,31, NULL, NULL ) +INSERT INTO label_def VALUES (1001,'Avery Zweckform','L7411-5 Zahlen Register - Inhaltsblatt 1-5','S',4.75,110.0,57.5,100.0,57.5,100.0,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (1002,'Avery Zweckform','L7411-AZ A-Z Register - Inhaltsblatt','S',15.0,110.0,13.35,100.0,13.35,100.0,1,20, NULL, NULL ) +INSERT INTO label_def VALUES (1003,'Avery Zweckform','L7411-JD Monats Register - Inhaltsblatt Jan - D','S',5.1,110.0,23.9,100.0,23.9,100.0,1,12, NULL, NULL ) +INSERT INTO label_def VALUES (1004,'Avery Zweckform','L7412-10 Einsteckschilder für Register 10-teilig','S',47.3,10.0,21.16,39.5,21.16,48.4,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (1005,'Avery Zweckform','L7412-12 Einsteckschilder für Register 12-teilig','S',47.3,12.5,21.16,34.5,21.16,48.4,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (1006,'Avery Zweckform','L7412-5 Einsteckschilder für Register 5-teilig','S',47.3,13.2,21.16,71.0,21.16,104.4,2,10, NULL, NULL ) +INSERT INTO label_def VALUES (1007,'Avery Zweckform','5129061 Trennstreifen ','S',0.0,0.0,105.0,240.0,105.0,240.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1008,'Avery Zweckform','3600 Computer-Etikett','C',0.0,10.55,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1009,'Avery Zweckform','3601 Computer-Etikett','C',0.0,10.55,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1010,'Avery Zweckform','3602 Computer-Etikett','C',0.0,10.55,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1011,'Avery Zweckform','3603 Computer-Etikett','C',0.0,10.55,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1012,'Avery Zweckform','3604 Computer-Etikett','C',0.0,16.9,14.5,25.4,16.93,27.94,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1013,'Avery Zweckform','3605 Computer-Etikett','C',0.0,14.4,14.5,40.6,16.93,43.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1014,'Avery Zweckform','3606 Computer-Etikett','C',0.0,14.3,18.7,48.2,21.17,50.74,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1015,'Avery Zweckform','3607 Computer-Etikett','C',0.0,16.9,23.0,38.1,25.4,40.64,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1016,'Avery Zweckform','3608 Computer-Etikett','C',0.0,10.55,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1017,'Avery Zweckform','3609 Computer-Etikett','C',0.0,13.15,10.3,73.7,12.7,73.7,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1018,'Avery Zweckform','3610 Computer-Etikett','C',0.0,10.55,23.0,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1019,'Avery Zweckform','3611 Computer-Etikett','C',0.0,12.43,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1020,'Avery Zweckform','3612 Computer-Etikett','C',0.0,13.35,35.7,101.6,38.1,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1021,'Avery Zweckform','3613 Computer-Etikett','C',0.0,10.8,48.4,106.7,50.8,106.7,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1022,'Avery Zweckform','3614 Computer-Etikett','C',0.0,11.19,48.4,114.3,50.8,114.3,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1023,'Avery Zweckform','3615 Computer-Etikett','C',0.0,12.43,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1024,'Avery Zweckform','3617 Computer-Etikett','C',0.0,13.35,48.4,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1025,'Avery Zweckform','3620 Computer-Etikett','C',0.0,12.15,35.7,101.6,38.1,104.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1026,'Avery Zweckform','3621 Computer-Etikett','C',0.0,11.82,35.7,43.18,38.1,45.72,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1027,'Avery Zweckform','3623 Computer-Etikett','C',0.0,12.15,48.4,101.6,50.8,104.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1028,'Avery Zweckform','3633 Computer-Etikett','C',0.0,14.45,35.7,73.7,38.1,76.24,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1029,'Avery Zweckform','3634 Computer-Etikett schnittgestanzt','C',0.0,10.55,38.1,95.0,38.1,95.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1030,'Avery Zweckform','3635 Computer-Etikett','C',0.0,12.43,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1031,'Avery Zweckform','3643 Computer-Etikett','C',0.0,28.5,23.0,30.5,25.4,35.58,6,1, NULL, NULL ) +INSERT INTO label_def VALUES (1032,'Avery Zweckform','3645 Computer-Etikett','C',0.0,10.55,23.0,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1033,'Avery Zweckform','3646 Computer-Etikett','C',0.0,10.55,48.4,88.9,50.8,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1034,'Avery Zweckform','3647 Computer-Etikett','C',0.0,11.8,10.3,43.2,12.7,45.74,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1035,'Avery Zweckform','3648 Computer-Etikett ablösbar','C',0.0,10.55,23.0,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1036,'Avery Zweckform','3674 Computer-Etikett','C',0.0,16.9,14.5,25.4,16.93,27.94,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1037,'Avery Zweckform','3675 Computer-Etikett','C',0.0,16.9,23.0,38.1,25.4,40.64,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1038,'Avery Zweckform','3676 Computer-Etikett','C',0.0,14.3,18.7,48.2,21.17,50.74,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1039,'Avery Zweckform','5100 Computer-Etikett','C',0.0,13.15,10.3,73.7,12.7,73.7,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1040,'Avery Zweckform','5101 Computer-Etikett','C',0.0,10.55,23.0,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1041,'Avery Zweckform','5103 Computer-Etikett','C',0.0,12.43,48.4,88.9,50.8,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1042,'Avery Zweckform','5104 Computer-Etikett','C',0.0,13.35,10.3,101.6,12.7,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1043,'Avery Zweckform','5105 Computer-Etikett','C',0.0,13.35,23.0,101.6,25.4,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1044,'Avery Zweckform','5106 Computer-Etikett','C',0.0,13.35,35.7,101.6,38.1,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1045,'Avery Zweckform','5107 Computer-Etikett','C',0.0,13.35,48.4,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1046,'Avery Zweckform','5108 Computer-Etikett','C',0.0,10.8,35.7,106.7,38.1,106.7,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1047,'Avery Zweckform','5109 Computer-Etikett','C',0.0,10.8,48.4,106.7,50.8,106.7,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1048,'Avery Zweckform','5110 Computer-Etikett','C',0.0,11.19,48.4,114.3,50.8,114.3,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1049,'Avery Zweckform','5111 Computer-Etikett','C',0.0,11.5,23.0,127.0,25.4,127.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1050,'Avery Zweckform','5112 Computer-Etikett','C',0.0,11.5,35.7,127.0,38.1,127.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1051,'Avery Zweckform','5121 Computer-Etikett','C',0.0,10.55,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1052,'Avery Zweckform','5122 Computer-Etikett','C',0.0,10.55,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1053,'Avery Zweckform','5123 Computer-Etikett','C',0.0,10.55,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1054,'Avery Zweckform','5124 Computer-Etikett','C',0.0,10.55,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1055,'Avery Zweckform','5130 Computer-Etikett','C',0.0,13.6,35.7,88.9,38.1,91.44,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1056,'Avery Zweckform','5131 Computer-Etikett','C',0.0,13.6,48.4,88.9,50.8,91.44,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1057,'Avery Zweckform','5132 Computer-Etikett','C',0.0,12.15,35.7,101.6,38.1,104.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1058,'Avery Zweckform','5133 Computer-Etikett','C',0.0,12.15,48.4,101.6,50.8,104.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1059,'Avery Zweckform','5137 Computer-Etikett','C',0.0,11.7,23.0,50.8,25.4,53.34,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1060,'Avery Zweckform','5140 Computer-Etikett','C',0.0,12.54,10.3,43.2,12.7,45.74,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1061,'Avery Zweckform','5141 Computer-Etikett','C',0.0,16.65,23.0,88.9,25.4,91.44,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1062,'Avery Zweckform','5142 Computer-Etikett','C',0.0,16.65,35.7,88.9,38.1,91.44,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1063,'Avery Zweckform','5143 Computer-Etikett','C',0.0,16.65,48.4,88.9,50.8,91.44,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1064,'Avery Zweckform','5145 Computer-Etikett','C',0.0,12.6,35.7,101.6,38.1,104.14,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1065,'Avery Zweckform','5146 Computer-Etikett','C',0.0,14.95,35.7,106.7,38.1,109.24,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1066,'Avery Zweckform','5147 Computer-Etikett','C',0.0,14.95,48.4,106.7,50.8,109.24,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1067,'Avery Zweckform','5160 Computer-Etikett','C',0.0,15.5,23.0,63.5,25.4,66.04,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (1068,'Avery Zweckform','5161 Computer-Etikett','C',0.0,17.6,35.7,73.7,38.1,76.24,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (1069,'Avery Zweckform','5162 Computer-Etikett','C',0.0,14.9,23.0,81.3,25.4,83.84,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (1070,'Avery Zweckform','5163 Computer-Etikett','C',0.0,14.9,35.7,81.3,38.1,83.84,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (1071,'Avery Zweckform','5164 Computer-Etikett','C',0.0,20.2,35.3,80.0,38.1,85.0,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (1072,'Avery Zweckform','5170 Computer-Etikett','C',0.0,18.75,23.0,63.5,25.4,66.04,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (1073,'Avery Zweckform','5171 Computer-Etikett','C',0.0,18.75,35.7,63.5,35.95,63.74,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1074,'Herlitz','083200/6 Adressetikett','C',1.0,9.0,35.7,89.0,38.0,89.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1075,'Herlitz','083200/6 Adressetikett','C',1.0,9.0,35.7,89.0,38.0,89.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1076,'Herlitz','083203/0 Adressetikett','C',1.0,11.0,48.4,89.0,50.8,89.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1077,'Herlitz','083204/8 Adressetikett','C',1.0,9.0,35.7,101.6,38.0,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1078,'Herlitz','083205/5 Diskettenetikett','C',3.0,18.5,69.6,70.0,76.2,70.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1079,'Herlitz','083207/1 Adressetikett','C',1.0,11.0,35.7,89.0,38.0,89.0,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1080,'Herlitz','083215/4 Diskettenetikett','S',21.4,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1081,'Herlitz','083216/2 CD-ROM-Etikett','S',16.0,46.5,117.0,117.0,148.0,117.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1082,'Herlitz','083217/0 Adressetikett','S',4.4,0.0,36.0,70.0,36.0,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1083,'Herlitz','083219/6 Adressetikett','S',21.4,7.7,50.8,96.0,50.8,98.5,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1084,'Herlitz','083220/4 Adressetikett Laser','S',0.0,0.0,37.1,70.0,37.1,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1085,'Herlitz','083221/2 Adressetikett Laser','S',0.0,0.0,42.4,105.0,42.4,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1086,'Herlitz','083222/0 Adressetikett Laser','S',0.0,0.0,42.4,70.0,42.4,70.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1087,'Herlitz','083224/6 Diskettenetikett Laser','S',8.5,0.0,70.0,70.0,70.0,70.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1088,'Herlitz','083230/3 Adressetikett Inkjet','S',0.0,0.0,37.1,70.0,37.1,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1089,'Herlitz','083231/1 Adressetikett Inkjet','S',0.0,0.0,42.4,105.0,42.4,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1090,'Herlitz','083234/5 Diskettenetikett Inkjet','S',8.5,0.0,70.0,70.0,70.0,70.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1091,'Herlitz','083240/2 Adressetik. Laser+InkJet','S',0.0,0.0,37.1,70.0,37.1,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1092,'Herlitz','083244/4 Diskettenetik.Laser+InkJet','S',8.5,0.0,70.0,70.0,70.0,70.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1093,'Herlitz','083250/1 Adressetiketten','S',10.76,7.7,42.3,96.0,42.3,98.6,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (1094,'Herlitz','083251/9 Ordner-Etiketten 8 cm','S',13.21,10.0,61.0,190.0,61.0,190.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1095,'Herlitz','083252/7 Ordner-Etiketten 5 cm','S',17.21,10.0,38.0,190.0,38.0,190.0,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (1096,'Herlitz','083253/5 Neonetiketten','S',10.76,7.7,42.3,96.0,42.3,98.6,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (1097,'Herlitz','083254/3 Transparente Etiketten','S',10.76,7.7,42.3,96.0,42.3,98.6,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (1098,'Herlitz','083255/0 Diskettenetiketten','S',6.51,25.0,67.7,70.0,67.7,90.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1099,'Herlitz','83256/8a Videoetiketten 0','S',27.61,25.0,46.6,78.7,46.6,81.3,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1100,'Herlitz','83256/8b Videoetiketten 0','S',15.06,31.35,16.9,147.3,16.9,147.3,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1101,'Herlitz','083257/6 Diaetiketten','S',14.21,10.0,10.0,45.7,10.0,48.2,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (1102,'Herlitz','083258/4 Farbdruck-Etiketten','S',10.76,7.7,42.3,96.0,42.3,98.6,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (1103,'Herlitz','502041/7 Visitenkarten','S',14.0,14.0,54.0,85.0,54.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1104,'Herlitz','083271/7 Ordnerrückeneinsteckschilder','S',16.0,10.0,53.0,190.0,53.0,190.0,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (1105,'Herma','4097 Laser A4 Silberfolie','S',21.5,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (1106,'Herma','4098 Laser A4 Silberfolie','S',15.15,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (1107,'Herma','4099 Laser A4 Silberfolie','S',21.5,7.73,50.8,96.0,50.8,98.54,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1108,'Herma','4100 Laser A4 Goldfolie','S',13.03,7.21,16.93,30.48,16.93,33.02,6,16, NULL, NULL ) +INSERT INTO label_def VALUES (1109,'Herma','4101 Laser A4 Goldfolie','S',10.0,18.64,10.3,43.18,12.7,43.18,4,22, NULL, NULL ) +INSERT INTO label_def VALUES (1110,'Herma','4102 Laser A4 Goldfolie','S',8.8,8.4,25.4,48.3,25.4,48.3,4,11, NULL, NULL ) +INSERT INTO label_def VALUES (1111,'Herma','4103 Laser A4 Goldfolie','S',15.15,7.21,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1112,'Herma','4104 Laser A4 Goldfolie','S',13.03,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1113,'Herma','4105 Laser A4 Goldfolie Kreise 60 mm','S',18.0,8.0,60.0,60.0,67.0,67.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1114,'Herma','4106 Laser A4 Goldfolie oval','S',10.93,12.29,42.33,58.42,46.56,63.5,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (1115,'Herma','4107 Laser A4 Goldfolie A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1116,'Herma','4108 Laser A4 Goldfolie','S',13.5,8.48,10.0,25.4,10.0,27.94,7,27, NULL, NULL ) +INSERT INTO label_def VALUES (1117,'Herma','4109 Laser A4 Goldfolie oval','S',17.27,16.1,25.4,40.64,29.63,45.72,4,9, NULL, NULL ) +INSERT INTO label_def VALUES (1118,'Herma','4110 Laser A4 Silberfolie','S',13.03,7.21,16.93,30.48,16.93,33.02,6,16, NULL, NULL ) +INSERT INTO label_def VALUES (1119,'Herma','4111 Laser A4 Silberfolie','S',10.0,18.64,10.3,43.18,12.7,43.18,4,22, NULL, NULL ) +INSERT INTO label_def VALUES (1120,'Herma','4112 Laser A4 Silberfolie','S',8.8,8.48,25.4,48.26,25.4,48.26,4,11, NULL, NULL ) +INSERT INTO label_def VALUES (1121,'Herma','4113 Laser A4 Silberfolie','S',15.15,7.21,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1122,'Herma','4114 Laser A4 Silberfolie','S',13.03,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1123,'Herma','4115 Laser A4 Silberfolie Kreise 60 mm','S',18.0,8.0,60.0,60.0,67.0,67.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1124,'Herma','4116 Laser A4 Silberfolie oval','S',10.93,12.29,42.33,58.42,46.56,63.5,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (1125,'Herma','4117 Laser A4 Silberfolie A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1126,'Herma','4118 Laser A4 Silberfolie','S',13.5,8.48,10.0,25.4,10.0,27.94,7,27, NULL, NULL ) +INSERT INTO label_def VALUES (1127,'Herma','4119 Laser A4 Silberfolie','S',13.03,7.21,16.93,63.5,16.93,66.04,3,16, NULL, NULL ) +INSERT INTO label_def VALUES (1128,'Herma','4200 Laser/Inkjet A4 weiß','S',13.02,8.4,33.87,48.3,33.87,48.3,4,8, NULL, NULL ) +INSERT INTO label_def VALUES (1129,'Herma','4201 Laser/Inkjet A4 Sichtreiteretiketten weiß','S',13.06,9.75,16.93,45.72,16.93,48.26,4,16, NULL, NULL ) +INSERT INTO label_def VALUES (1130,'Herma','4202 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',12.98,7.21,8.47,63.5,8.47,66.04,3,32, NULL, NULL ) +INSERT INTO label_def VALUES (1131,'Herma','4203 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',8.82,7.21,46.56,63.5,46.56,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (1132,'Herma','4204 Laser/Inkjet A4 3 5\"-Disketten gelb','S',21.5,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1133,'Herma','4205 Laser/Inkjet A4 3 5\"-Disketten rot','S',21.5,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1134,'Herma','4206 Laser/Inkjet A4 3 5\"-Disketten blau','S',21.5,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1135,'Herma','4207 Laser/Inkjet A4 3 5\"-Disketten grün','S',21.5,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1136,'Herma','4208 Laser/Inkjet A4 Musik-Cassetten weiß','S',21.5,14.75,42.33,89.0,42.33,91.54,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1137,'Herma','4209 Laser/Inkjet A4 weiß z.B. für Regalbeschriftung ablösbar','S',13.06,7.73,16.93,96.0,16.93,98.54,2,16, NULL, NULL ) +INSERT INTO label_def VALUES (1138,'Herma','4210 Laser/Inkjet A4 weiß ablösbar','S',8.8,9.75,12.7,38.1,12.7,38.1,5,22, NULL, NULL ) +INSERT INTO label_def VALUES (1139,'Herma','4211 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',13.06,8.48,16.93,25.4,16.93,27.94,7,16, NULL, NULL ) +INSERT INTO label_def VALUES (1140,'Herma','4212 Laser/Inkjet A4 weiß ablösbar','S',10.7,9.75,21.2,38.1,21.2,38.1,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (1141,'Herma','4226 SuperPrint weiß deckend','S',13.06,8.48,16.93,48.26,16.93,48.26,4,16, NULL, NULL ) +INSERT INTO label_def VALUES (1142,'Herma','4227 SuperPrint weiß deckend','S',13.03,8.1,33.87,64.6,33.87,64.6,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1143,'Herma','4228 SuperPrint weiß deckend','S',21.51,8.48,42.33,96.52,42.33,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1144,'Herma','4229 SuperPrint weiß deckend','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1145,'Herma','4230 SuperPrint weiß deckend','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1146,'Herma','4256 Laser/Inkjet A4 gelb','S',0.0,0.0,37.13,105.0,37.13,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1147,'Herma','4257 Laser/Inkjet A4 rot','S',0.0,0.0,37.13,105.0,37.13,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1148,'Herma','4258 Laser/Inkjet A4 blau','S',0.0,0.0,37.13,105.0,37.13,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1149,'Herma','4259 Laser/Inkjet A4 grün','S',0.0,0.0,37.13,105.0,37.13,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1150,'Herma','4262 Laser/Inkjet A4 weiß','S',13.03,8.1,33.87,64.6,33.87,64.6,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1151,'Herma','4263 Laser/Inkjet A4 weiß','S',13.03,0.0,33.87,70.0,33.87,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1152,'Herma','4264 Laser/Inkjet A4 weiß','S',13.03,0.0,33.87,105.0,33.87,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1153,'Herma','4265 Laser/Inkjet A4 weiß Ecken abgerundet','S',8.82,7.21,46.56,63.5,46.56,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (1154,'Herma','4266 Laser/Inkjet A4 weiß Ecken abgerundet','S',4.5,7.21,72.0,63.5,72.0,66.04,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1155,'Herma','4267 Laser/Inkjet A4 weiß Ecken abgerundet','S',13.03,4.67,33.87,99.06,33.87,101.6,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1156,'Herma','4268 Laser/Inkjet A4 weiß Ecken abgerundet','S',6.0,4.67,57.0,99.06,57.0,101.6,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1157,'Herma','4269 Laser/Inkjet A4 weiß Ecken abgerundet','S',13.03,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1158,'Herma','4270 Laser/Inkjet A4 weiß','S',10.7,9.75,21.2,38.1,21.2,38.1,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (1159,'Herma','4271 Laser/Inkjet A4 weiß','S',13.06,8.48,16.93,48.26,16.93,48.26,4,16, NULL, NULL ) +INSERT INTO label_def VALUES (1160,'Herma','4272 Laser/Inkjet A4 weiß','S',8.8,8.48,25.4,48.26,25.4,48.26,4,11, NULL, NULL ) +INSERT INTO label_def VALUES (1161,'Herma','4273 Laser/Inkjet A4 weiß','S',0.0,0.0,21.2,52.5,21.2,52.5,4,14, NULL, NULL ) +INSERT INTO label_def VALUES (1162,'Herma','4275 Laser/Inkjet A4 weiß','S',8.8,6.0,25.4,66.0,25.4,66.0,3,11, NULL, NULL ) +INSERT INTO label_def VALUES (1163,'Herma','4278 Laser/Inkjet A4 3 5\"-Disketten weiß','S',21.5,0.0,50.8,70.0,50.8,70.0,3,5, NULL, NULL ) +INSERT INTO label_def VALUES (1164,'Herma','4279 Laser/Inkjet A4 3 5\"-Disketten weiß','S',13.03,0.0,67.73,70.0,67.73,70.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1165,'Herma','4280 Laser/Inkjet A4 weiß','S',13.03,8.48,67.73,96.52,67.73,96.52,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1166,'Herma','4281 Laser/Inkjet A4 weiß','S',21.5,0.0,50.8,105.0,50.8,105.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1167,'Herma','4282 Laser/Inkjet A4 weiß A5','S',0.0,0.0,148.5,210.0,148.5,210.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1168,'Herma','4283 Laser/Inkjet A4 für schmale Ordner weiß','S',15.5,9.0,38.0,192.0,38.0,192.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1169,'Herma','4284 Laser/Inkjet A4 für breite Ordner weiß','S',26.5,9.0,61.0,192.0,61.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1170,'Herma','4290 Laser/Inkjet A4 für schmale Ordner weiß','S',12.5,9.0,34.0,192.0,34.0,192.0,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (1171,'Herma','4291 Laser/Inkjet A4 für breite Ordner weiß','S',30.5,9.0,59.0,192.0,59.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1172,'Herma','4292 Laser/Inkjet A4 für schmale Ordner gelb','S',15.5,9.0,38.0,192.0,38.0,192.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1173,'Herma','4293 Laser/Inkjet A4 für schmale Ordner rot','S',15.5,9.0,38.0,192.0,38.0,192.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1174,'Herma','4294 Laser/Inkjet A4 für schmale Ordner blau','S',15.5,9.0,38.0,192.0,38.0,192.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1175,'Herma','4295 Laser/Inkjet A4 für schmale Ordner grün','S',15.5,9.0,38.0,192.0,38.0,192.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1176,'Herma','4296 Laser/Inkjet A4 für breite Ordner gelb','S',26.5,9.0,61.0,192.0,61.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1177,'Herma','4297 Laser/Inkjet A4 für breite Ordner rot','S',26.5,9.0,61.0,192.0,61.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1178,'Herma','4298 Laser/Inkjet A4 für breite Ordner blau','S',26.5,9.0,61.0,192.0,61.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1179,'Herma','4299 Laser/Inkjet A4 für breite Ordner grün','S',26.5,9.0,61.0,192.0,61.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1180,'Herma','4343 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',13.5,4.26,10.0,17.8,10.0,20.41,10,27, NULL, NULL ) +INSERT INTO label_def VALUES (1181,'Herma','4344 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',13.5,8.48,10.0,25.4,10.0,27.94,7,27, NULL, NULL ) +INSERT INTO label_def VALUES (1182,'Herma','4345 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',13.06,11.02,16.93,35.56,16.93,38.1,5,16, NULL, NULL ) +INSERT INTO label_def VALUES (1183,'Herma','4346 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',21.5,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (1184,'Herma','4347 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',15.15,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (1185,'Herma','4348 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',21.5,7.73,42.33,96.0,42.33,98.54,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1186,'Herma','4349 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',21.5,7.73,50.8,96.0,50.8,98.54,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1187,'Herma','4350 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',21.5,7.73,63.5,96.0,63.5,98.54,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1188,'Herma','4351 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',0.0,0.0,148.5,210.0,148.5,210.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1189,'Herma','4352 Laser/Inkjet A4 weiß ablösbar','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1190,'Herma','4353 Laser/Inkjet A4 3 5\"-Disketten weiß','S',21.5,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1191,'Herma','4354 Laser/Inkjet A4 3 5\"-Disketten farbig sortiert','S',21.5,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1192,'Herma','4355 Laser/Inkjet A4 3 5\"-Disketten weiß','S',13.04,25.0,67.73,70.0,67.73,90.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1193,'Herma','4356 Laser/Inkjet A4 3 5\"-Disketten farbig sortiert','S',13.04,25.0,67.73,70.0,67.73,90.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1194,'Herma','4357 Laser/Inkjet A4 weiß','S',21.5,8.0,25.4,48.5,25.4,48.5,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (1195,'Herma','4358 Laser/Inkjet A4 Oval weiß ablösbar','S',10.93,7.21,42.33,63.5,46.57,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (1196,'Herma','4359 Laser/Inkjet A4 weiß','S',13.03,8.48,67.73,96.52,67.73,96.52,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1197,'Herma','4360 Laser/Inkjet A4 weiß','S',4.5,0.0,36.0,70.0,36.0,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1198,'Herma','4361 Laser/Inkjet A4 weiß','S',4.13,0.0,41.25,70.0,41.25,70.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1199,'Herma','4362 Laser/Inkjet A4 weiß','S',4.13,0.0,41.25,105.0,41.25,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1200,'Herma','4363 Laser/Inkjet A4 weiß','S',4.5,0.0,48.0,105.0,48.0,105.0,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1201,'Herma','4364 Laser/Inkjet A4 weiß','S',4.5,0.0,144.0,105.0,144.0,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1202,'Herma','4366 Laser/Inkjet A4 gelb Ecken abgerundet','S',21.5,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (1203,'Herma','4367 Laser/Inkjet A4 rot Ecken abgerundet','S',21.5,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (1204,'Herma','4368 Laser/Inkjet A4 blau Ecken abgerundet','S',21.5,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (1205,'Herma','4369 Laser/Inkjet A4 grün Ecken abgerundet','S',21.5,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (1206,'Herma','4373 SuperPrint CD-Cover-Etikett/Einleger weiß','S',17.0,44.25,117.5,121.5,145.5,121.5,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1207,'Herma','4374 SuperPrint CD-Etikett transparente Folie','S',16.5,47.0,116.0,116.0,148.0,116.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1208,'Herma','4375 Laser/Inkjet A4 transparente Folie','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1209,'Herma','4376 Laser/Inkjet A4 transparente Folie','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1210,'Herma','4377 Laser A4 witterungsbeständig weiß','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1211,'Herma','4378 Laser A4 witterungsbeständig weiß','S',0.0,0.0,148.5,210.0,148.5,210.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1212,'Herma','4379 Laser A4 witterungsbeständig weiß','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1213,'Herma','4380 Laser/Inkjet A4 Oval weiß','S',17.27,16.1,25.4,40.64,29.63,45.72,4,9, NULL, NULL ) +INSERT INTO label_def VALUES (1214,'Herma','4385 Laser/Inkjet A4 Kreise 10 mm weiß ablösbar','S',16.5,11.1,10.0,10.0,12.7,12.7,15,21, NULL, NULL ) +INSERT INTO label_def VALUES (1215,'Herma','4386 Laser/Inkjet A4 Kreise 20 mm weiß ablösbar','S',14.53,16.11,20.0,20.0,22.54,22.54,8,12, NULL, NULL ) +INSERT INTO label_def VALUES (1216,'Herma','4387 Laser/Inkjet A4 Kreise 30 mm weiß','S',19.61,8.65,30.0,30.0,32.54,32.54,6,8, NULL, NULL ) +INSERT INTO label_def VALUES (1217,'Herma','4388 Laser/Inkjet A4 Tiefkühletiketten weiß','S',10.7,9.75,21.2,38.1,21.2,38.1,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (1218,'Herma','4389 Laser/Inkjet A4 Tiefkühletiketten weiß','S',13.03,6.0,33.87,66.0,33.87,66.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1219,'Herma','4392 Laser/Inkjet A4 weiß ablösbar','S',0.0,0.0,29.7,52.5,29.7,52.5,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (1220,'Herma','4393 Laser/Inkjet A4 weiß ablösbar','S',4.13,0.0,41.25,105.0,41.25,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1221,'Herma','4394 Laser/Inkjet A4 weiß ablösbar','S',4.5,0.0,144.0,105.0,144.0,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1222,'Herma','4396 Laser/Inkjet A4 gelb A6','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1223,'Herma','4397 Laser/Inkjet A4 rot A6','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1224,'Herma','4398 Laser/Inkjet A4 blau A6','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1225,'Herma','4399 Laser/Inkjet A4 grün A6','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1226,'Herma','4401 Laser/Inkjet A4 gelb A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1227,'Herma','4402 Laser/Inkjet A4 rot A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1228,'Herma','4403 Laser/Inkjet A4 blau A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1229,'Herma','4404 Laser/Inkjet A4 grün A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1230,'Herma','4406 Laser/Inkjet A4 gelb','S',0.0,0.0,37.13,70.0,37.13,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1231,'Herma','4407 Laser/Inkjet A4 rot','S',0.0,0.0,37.13,70.0,37.13,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1232,'Herma','4408 Laser/Inkjet A4 blau','S',0.0,0.0,37.13,70.0,37.13,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1233,'Herma','4409 Laser/Inkjet A4 grün','S',0.0,0.0,37.13,70.0,37.13,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1234,'Herma','4414 Laser/Inkjet A4 weiß','S',4.5,0.0,36.0,70.0,36.0,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1235,'Herma','4415 Laser/Inkjet A4 weiß','S',4.13,0.0,41.25,70.0,41.25,70.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1236,'Herma','4416 Laser/Inkjet A4 weiß','S',4.13,0.0,41.25,105.0,41.25,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1237,'Herma','4417 Laser/Inkjet A4 weiß','S',4.5,0.0,48.0,105.0,48.0,105.0,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1238,'Herma','4418 Laser A4 Namensetiketten Acetatseide rot','S',15.15,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (1239,'Herma','4419 Laser A4 Namensetiketten Acetatseide blau','S',15.15,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (1240,'Herma','4421 Laser/Inkjet A4 gelb','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1241,'Herma','4422 Laser/Inkjet A4 rot','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1242,'Herma','4423 Laser/Inkjet A4 blau','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1243,'Herma','4424 Laser/Inkjet A4 grün','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1244,'Herma','4425 Laser/Inkjet A4 weiß','S',6.0,0.0,57.0,105.0,57.0,105.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1245,'Herma','4426 Laser/Inkjet A4 weiß','S',8.5,0.0,70.0,105.0,70.0,105.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1246,'Herma','4427 Laser/Inkjet A4 weiß','S',8.5,0.0,35.0,105.0,35.0,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1247,'Herma','4428 Laser/Inkjet A4 weiß A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1248,'Herma','4429 Laser/Inkjet A4 weiß','S',8.5,0.0,35.0,70.0,35.0,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1249,'Herma','4450 Laser/Inkjet A4 weiß','S',4.5,0.0,32.0,70.0,32.0,70.0,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (1250,'Herma','4451 Laser/Inkjet A4 weiß','S',4.13,0.0,41.25,70.0,41.25,70.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1251,'Herma','4452 Laser/Inkjet A4 weiß','S',4.13,0.0,41.25,105.0,41.25,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1252,'Herma','4453 Laser/Inkjet A4 weiß','S',4.5,0.0,36.0,70.0,36.0,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1253,'Herma','4454 Laser/Inkjet A4 weiß','S',4.5,0.0,144.0,105.0,144.0,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1254,'Herma','4455 Laser/Inkjet A4 weiß','S',8.8,0.0,25.4,70.0,25.4,70.0,3,11, NULL, NULL ) +INSERT INTO label_def VALUES (1255,'Herma','4456 Laser/Inkjet A4 weiß','S',0.0,0.0,29.7,70.0,29.7,70.0,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (1256,'Herma','4457 Laser/Inkjet A4 weiß','S',4.5,0.0,48.0,105.0,48.0,105.0,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1257,'Herma','4458 Laser/Inkjet A4 weiß','S',0.0,0.0,297.0,200.0,297.0,200.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1258,'Herma','4459 Laser/Inkjet A4 weiß','S',4.6,0.0,16.93,70.0,16.93,70.0,3,17, NULL, NULL ) +INSERT INTO label_def VALUES (1259,'Herma','4461 Laser/Inkjet A4 weiß','S',0.0,0.0,29.7,52.5,29.7,52.5,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (1260,'Herma','4462 Laser/Inkjet A4 weiß','S',0.0,0.0,37.13,105.0,37.13,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1261,'Herma','4464 Laser/Inkjet A4 weiß','S',0.0,0.0,37.13,70.0,37.13,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1262,'Herma','4465 Laser A4 transparente Folie','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1263,'Herma','4466 Laser/Inkjet A4 gelb','S',0.0,0.0,37.13,70.0,37.13,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1264,'Herma','4467 Laser/Inkjet A4 rot','S',0.0,0.0,37.13,70.0,37.13,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1265,'Herma','4468 Laser/Inkjet A4 blau','S',0.0,0.0,37.13,70.0,37.13,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1266,'Herma','4469 Laser/Inkjet A4 grün','S',0.0,0.0,37.13,70.0,37.13,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1267,'Herma','4470 Laser/Inkjet A4 weiß','S',0.0,0.0,74.25,105.0,74.25,105.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1268,'Herma','4471 SuperPrint CD-Etikett weiß','S',16.5,47.0,116.0,116.0,148.0,116.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1269,'Herma','4472 Laser/Inkjet A4 weiß Ecken abgerundet','S',8.8,24.99,139.7,78.74,139.7,81.28,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1270,'Herma','4473 Laser/Inkjet A4 weiß','S',5.0,0.0,41.0,70.0,41.0,70.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1271,'Herma','4474 Laser/Inkjet A4 weiß','S',21.5,8.0,25.4,48.5,25.4,48.5,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (1272,'Herma','4475 Laser/Inkjet A4 weiß','S',5.0,0.0,41.0,105.0,41.0,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1273,'Herma','4476 Laser/Inkjet A4 Kreise 40 mm weiß','S',13.5,16.0,40.0,40.0,46.0,46.0,4,6, NULL, NULL ) +INSERT INTO label_def VALUES (1274,'Herma','4477 Laser/Inkjet A4 Kreise 60 mm weiß','S',18.0,8.0,60.0,60.0,67.0,67.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1275,'Herma','4478 Laser/Inkjet A4 Kreise 85 mm weiß','S',11.0,15.0,85.0,85.0,95.0,95.0,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (1276,'Herma','4479 Laser/Inkjet A4 weiß Ecken abgerundet','S',13.03,12.29,33.87,88.9,33.87,96.52,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1277,'Herma','4606 Laser/Inkjet A4 weiß','S',10.7,9.75,21.2,38.1,21.2,38.1,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (1278,'Herma','4607 Laser/Inkjet A4 weiß','S',13.06,8.48,16.93,48.26,16.93,48.26,4,16, NULL, NULL ) +INSERT INTO label_def VALUES (1279,'Herma','4608 Laser/Inkjet A4 weiß','S',8.8,8.48,25.4,48.26,25.4,48.26,4,11, NULL, NULL ) +INSERT INTO label_def VALUES (1280,'Herma','4609 Laser/Inkjet A4 weiß','S',0.0,0.0,21.2,52.5,21.2,52.5,4,14, NULL, NULL ) +INSERT INTO label_def VALUES (1281,'Herma','4610 Laser/Inkjet A4 weiß','S',0.0,0.0,29.7,52.5,29.7,52.5,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (1282,'Herma','4611 Laser/Inkjet A4 weiß','S',4.6,0.0,16.93,70.0,16.93,70.0,3,17, NULL, NULL ) +INSERT INTO label_def VALUES (1283,'Herma','4612 Laser/Inkjet A4 weiß','S',0.0,0.0,29.7,70.0,29.7,70.0,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (1284,'Herma','4613 Laser/Inkjet A4 weiß','S',8.8,6.0,25.4,66.0,25.4,66.0,3,11, NULL, NULL ) +INSERT INTO label_def VALUES (1285,'Herma','4614 Laser/Inkjet A4 weiß','S',13.03,6.0,33.87,66.0,33.87,66.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1286,'Herma','4615 Laser/Inkjet A4 weiß','S',0.0,0.0,37.13,70.0,37.13,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1287,'Herma','4616 Laser/Inkjet A4 weiß','S',0.0,0.0,42.43,70.0,42.43,70.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1288,'Herma','4617 Laser/Inkjet A4 3 5\"-Disketten weiß','S',13.03,0.0,67.73,70.0,67.73,70.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1289,'Herma','4618 Laser/Inkjet A4 3 5\"-Disketten weiß','S',21.5,0.0,50.8,70.0,50.8,70.0,3,5, NULL, NULL ) +INSERT INTO label_def VALUES (1290,'Herma','4619 Laser/Inkjet A4 weiß','S',13.03,8.48,33.87,96.52,33.87,96.52,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1291,'Herma','4620 Laser/Inkjet A4 weiß','S',0.0,0.0,37.13,105.0,37.13,105.0,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1292,'Herma','4623 Laser/Inkjet A4 weiß','S',21.51,8.48,42.33,96.52,42.33,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1293,'Herma','4624 Laser/Inkjet A4 weiß','S',13.03,8.48,67.73,96.52,67.73,96.52,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1294,'Herma','4625 Laser/Inkjet A4 weiß','S',0.0,0.0,42.43,105.0,42.43,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1295,'Herma','4626 Laser/Inkjet A4 weiß','S',0.0,0.0,74.25,105.0,74.25,105.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1296,'Herma','4627 Laser/Inkjet A4 weiß A6','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1297,'Herma','4628 Laser/Inkjet A4 weiß A5','S',0.0,0.0,148.5,210.0,148.5,210.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1298,'Herma','4629 Laser/Inkjet A4 weiß','S',21.5,0.0,50.8,105.0,50.8,105.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1299,'Herma','4631 Laser/Inkjet A4 weiß','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1300,'Herma','4649a SuperPrint MiniDisk weiß','S',12.5,15.0,52.0,36.0,55.0,36.0,5,5, NULL, NULL ) +INSERT INTO label_def VALUES (1301,'Herma','4649b SuperPrint MiniDisk-Hülle weiß','S',21.5,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1302,'Herma','4654 Laser/Inkjet A4 weiß','S',12.0,0.0,39.0,105.0,39.0,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1303,'Herma','4666 Laser/Inkjet A4 weiß Ecken abgerundet','S',8.8,12.29,46.56,88.9,46.56,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1304,'Herma','4667 Laser/Inkjet A4 weiß Ecken abgerundet','S',21.5,7.73,50.8,96.0,50.8,98.54,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1305,'Herma','4668 Laser/Inkjet A4 weiß','S',0.0,0.0,42.43,70.0,42.43,70.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1306,'Herma','4669 Laser/Inkjet A4 weiß','S',21.5,8.48,42.33,96.52,42.33,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1307,'Herma','4670 Laser/Inkjet A4 weiß','S',13.03,6.0,33.87,66.0,33.87,66.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1308,'Herma','4672 Laser/Inkjet A4 weiß','S',13.03,8.48,33.87,96.52,33.87,96.52,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1309,'Herma','4674 Laser/Inkjet A4 weiß','S',0.0,0.0,42.43,105.0,42.43,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1310,'Herma','4676 Laser/Inkjet A4 weiß A6','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1311,'Herma','4677 Laser/Inkjet A4 weiß Ecken abgerundet','S',15.15,7.21,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1312,'Herma','4678 Laser/Inkjet A4 weiß Ecken abgerundet','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1313,'Herma','4680 Laser A4 transparente Folie','S',8.8,8.48,25.4,48.26,25.4,48.26,4,11, NULL, NULL ) +INSERT INTO label_def VALUES (1314,'Herma','4681 Laser A4 transparente Folie','S',13.03,6.0,33.87,66.0,33.87,66.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1315,'Herma','4682 Laser A4 transparente Folie','S',21.5,8.48,42.33,96.52,42.33,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1316,'Herma','4683 Laser A4 transparente Folie A5','S',0.0,0.0,148.5,210.0,148.5,210.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1317,'Herma','4684 Laser A4 transparente Folie','S',0.0,0.0,29.7,52.5,29.7,52.5,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (1318,'Herma','4685 Laser A4 transparente Folie','S',0.0,0.0,37.13,70.0,37.13,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1319,'Herma','4686 Laser A4 Kreise 40 mm transparent','S',13.5,16.0,40.0,40.0,46.0,46.0,4,6, NULL, NULL ) +INSERT INTO label_def VALUES (1320,'Herma','4690 Laser A4 weiße Folie','S',8.8,8.48,25.4,48.26,25.4,48.26,4,11, NULL, NULL ) +INSERT INTO label_def VALUES (1321,'Herma','4691 Laser A4 weiße Folie','S',13.03,6.0,33.87,66.0,33.87,66.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1322,'Herma','4692 Laser A4 weiße Folie','S',21.5,8.48,42.33,96.52,42.33,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1323,'Herma','4693 Laser A4 weiße Folie A5','S',0.0,0.0,148.5,210.0,148.5,210.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1324,'Herma','4694 Laser A4 weiße Folie','S',0.0,0.0,29.7,52.5,29.7,52.5,4,10, NULL, NULL ) +INSERT INTO label_def VALUES (1325,'Herma','4695 Laser A4 weiße Folie','S',0.0,0.0,37.13,70.0,37.13,70.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1326,'Herma','4696 Laser A4 weiße Folie','S',0.0,0.0,42.43,105.0,42.43,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1327,'Herma','4697 Laser A4 weiße Folie','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1328,'Herma','4698 Laser A4 weiße Folie','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1329,'Herma','4810 InkPrint Special weiß','S',10.7,9.75,21.2,38.1,21.2,38.1,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (1330,'Herma','4811 InkPrint Special weiß','S',13.03,8.48,16.93,48.26,16.93,48.26,4,16, NULL, NULL ) +INSERT INTO label_def VALUES (1331,'Herma','4812 InkPrint Special weiß','S',8.8,8.48,25.4,48.26,25.4,48.26,4,11, NULL, NULL ) +INSERT INTO label_def VALUES (1332,'Herma','4814 InkPrint Special weiß','S',13.03,6.0,33.87,66.0,33.87,66.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1333,'Herma','4815 InkPrint Special weiß','S',13.03,8.48,33.87,96.52,33.87,96.52,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1334,'Herma','4816 InkPrint Special weiß','S',21.5,8.48,42.3,96.52,42.3,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1335,'Herma','4817 InkPrint Special weiß','S',13.03,8.48,67.73,96.52,67.73,96.52,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1336,'Herma','4819 InkPrint Special weiß','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1337,'Herma','4820 InkPrint Special weiß','S',13.03,6.0,33.87,66.0,33.87,66.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1338,'Herma','4821 InkPrint Special 3 5\"-Disketten weiß','S',13.03,6.0,67.73,66.0,67.73,66.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1339,'Herma','4822 InkPrint Special weiß','S',13.03,8.48,33.87,96.52,33.87,96.52,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1340,'Herma','4823 InkPrint Special weiß','S',21.5,8.48,42.3,96.52,42.3,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1341,'Herma','4824 InkPrint Special weiß','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1342,'Herma','4825 InkPrint Special für schmale Ordner weiß','S',15.5,9.0,38.0,192.0,38.0,192.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1343,'Herma','4826 InkPrint Special für breite Ordner weiß','S',26.5,9.0,61.0,192.0,61.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1344,'Herma','4827 InkPrint Special Videocassette Rücken weiß','S',18.5,31.34,20.0,147.32,20.0,147.32,1,13, NULL, NULL ) +INSERT INTO label_def VALUES (1345,'Herma','4828 InkPrint Special Videocassette Front weiß','S',8.82,24.99,46.56,78.74,46.56,81.28,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1346,'Herma','4829 InkPrint Special Diabeschriftung weiß','S',12.98,14.83,8.47,43.18,8.47,45.72,4,32, NULL, NULL ) +INSERT INTO label_def VALUES (1347,'Herma','4830 InkPrint Special für schmale Ordner lang weiß','S',0.0,10.0,297.0,38.0,297.0,38.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (1348,'Herma','4831 InkPrint Special für breite Ordner lang weiß','S',0.0,13.5,297.0,61.0,297.0,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1349,'Herma','4841 InkPrint Special transparente Folie','S',8.8,8.48,25.4,48.26,25.4,48.26,4,11, NULL, NULL ) +INSERT INTO label_def VALUES (1350,'Herma','4842 InkPrint Special transparente Folie','S',13.03,6.0,33.87,66.0,33.87,66.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1351,'Herma','4843 InkPrint Special transparente Folie','S',21.5,8.48,42.33,96.52,42.33,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1352,'Herma','4844 InkPrint Special transparente Folie A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1353,'Herma','4845 InkPrint Special transparente Folie','S',21.5,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (1354,'Herma','4846 InkPrint Special transparente Folie','S',15.15,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (1355,'Herma','4847 InkPrint Special transparente Folie','S',21.5,7.73,50.8,96.0,50.8,98.54,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1356,'Herma','4848 InkPrint Special CD-Etikett transparente Folie','S',16.5,47.0,116.0,116.0,148.0,116.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1357,'Herma','4851 InkPrint Special weiße Folie','S',8.8,8.48,25.4,48.26,25.4,48.26,4,11, NULL, NULL ) +INSERT INTO label_def VALUES (1358,'Herma','4852 InkPrint Special weiße Folie','S',13.03,6.0,33.87,66.0,33.87,66.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1359,'Herma','4853 InkPrint Special weiße Folie','S',21.5,8.48,42.33,96.52,42.33,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1360,'Herma','4854 InkPrint Special weiße Folie A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1361,'Herma','5051 Laser/Inkjet A4 weiß','S',8.8,8.48,25.4,48.26,25.4,48.26,4,11, NULL, NULL ) +INSERT INTO label_def VALUES (1362,'Herma','5052 Laser/Inkjet A4 weiß','S',0.0,0.0,21.2,52.5,21.2,52.5,4,14, NULL, NULL ) +INSERT INTO label_def VALUES (1363,'Herma','5053 Laser/Inkjet A4 weiß','S',13.03,6.0,33.87,66.0,33.87,66.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1364,'Herma','5054 Laser/Inkjet A4 weiß','S',0.0,0.0,42.43,70.0,42.43,70.0,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1365,'Herma','5055 Laser/Inkjet A4 3 5\"-Disketten weiß','S',21.5,0.0,50.8,70.0,50.8,70.0,3,5, NULL, NULL ) +INSERT INTO label_def VALUES (1366,'Herma','5056 Laser/Inkjet A4 weiß','S',21.51,8.5,42.33,96.52,42.33,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1367,'Herma','5057 Laser/Inkjet A4 weiß','S',0.0,0.0,42.43,105.0,42.43,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1368,'Herma','5058 Laser/Inkjet A4 gelb','S',0.0,0.0,42.43,105.0,42.43,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1369,'Herma','5059 Laser/Inkjet A4 rot','S',0.0,0.0,42.43,105.0,42.43,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1370,'Herma','5060 Laser/Inkjet A4 blau','S',0.0,0.0,42.43,105.0,42.43,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1371,'Herma','5061 Laser/Inkjet A4 grün','S',0.0,0.0,42.43,105.0,42.43,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1372,'Herma','5062 Laser/Inkjet A4 weiß','S',0.0,0.0,74.25,105.0,74.25,105.0,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1373,'Herma','5063 Laser/Inkjet A4 weiß A6','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1374,'Herma','5064 Laser/Inkjet A4 weiß A5','S',0.0,0.0,148.5,210.0,148.5,210.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1375,'Herma','5065 Laser/Inkjet A4 weiß A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1376,'Herma','5066 Laser/Inkjet A4 Kreise 40 mm weiß','S',13.5,16.0,40.0,40.0,46.0,46.0,4,6, NULL, NULL ) +INSERT INTO label_def VALUES (1377,'Herma','5067 Laser/Inkjet A4 Kreise 60 mm weiß','S',18.0,8.0,60.0,60.0,67.0,67.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1378,'Herma','5068 Laser/Inkjet A4 Kreise 85 mm weiß','S',11.0,15.0,85.0,85.0,95.0,95.0,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (1379,'Herma','5069 Laser/Inkjet A4 Videocassette Rücken weiß','S',18.5,31.34,20.0,147.32,20.0,147.32,1,13, NULL, NULL ) +INSERT INTO label_def VALUES (1380,'Herma','5070 Laser/Inkjet A4 Videocassette Front weiß','S',8.82,24.99,46.56,78.74,46.56,81.28,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1381,'Herma','5071 Laser/Inkjet A4 Diabeschriftung weiß','S',12.98,14.83,8.47,43.18,8.47,45.72,4,32, NULL, NULL ) +INSERT INTO label_def VALUES (1382,'Herma','5072 Laser/Inkjet A4 Pfeile gelb','S',19.38,11.02,25.4,91.44,46.56,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1383,'Herma','5073 Laser/Inkjet A4 Pfeile rot','S',19.38,11.02,25.4,91.44,46.56,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1384,'Herma','5074 Laser/Inkjet A4 weiß Ecken abgerundet ablösbar','S',15.15,7.21,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1385,'Herma','5075 Laser/Inkjet A4 weiß Ecken abgerundet','S',13.03,4.67,33.87,99.06,33.87,101.6,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1386,'Herma','5076 Laser/Inkjet A4 weiß Ecken abgerundet','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1387,'Herma','5077 Laser/Inkjet A4 weiß Ecken abgerundet','S',13.03,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1388,'Herma','5078 Laser/Inkjet A4 CD-Box-Etiketten weiß','S',16.5,47.85,5.5,114.3,5.5,114.3,1,48, NULL, NULL ) +INSERT INTO label_def VALUES (1389,'Herma','5079 Laser/Inkjet A4 CD-Etikett weiß','S',16.5,47.0,116.0,116.0,148.0,116.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1390,'Herma','5080 Laser/Inkjet A4 weiß ablösbar','S',0.0,0.0,21.2,52.5,21.2,52.5,4,14, NULL, NULL ) +INSERT INTO label_def VALUES (1391,'Herma','5081 Laser/Inkjet A4 weiß ablösbar','S',0.0,0.0,42.43,105.0,42.43,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1392,'Herma','5082 Laser/Inkjet A4 weiß ablösbar','S',0.0,0.0,148.5,105.0,148.5,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1393,'Herma','5083 Laser/Inkjet A4 CD-Etikett gelb','S',16.5,47.0,116.0,116.0,148.0,116.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1394,'Herma','5084 Laser/Inkjet A4 CD-Etikett rot','S',16.5,47.0,116.0,116.0,148.0,116.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1395,'Herma','5085 Laser/Inkjet A4 CD-Etikett blau','S',16.5,47.0,116.0,116.0,148.0,116.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1396,'Herma','5086 Laser/Inkjet A4 CD-Etikett grün','S',16.5,47.0,116.0,116.0,148.0,116.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1397,'Herma','5087 Laser/Inkjet A4 ZIP-Disketten weiß','S',23.5,13.75,50.0,59.0,50.0,61.75,3,5, NULL, NULL ) +INSERT INTO label_def VALUES (1398,'Herma','5088 Laser/Inkjet A4 für schmale Ordner farbig sort.','S',15.5,9.0,38.0,192.0,38.0,192.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1399,'Herma','5089 Laser/Inkjet A4 für breite Ordner farbig sort.','S',26.5,9.0,61.0,192.0,61.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1400,'Herma','5090 Laser/Inkjet A4 für schmale Ordner weiß','S',15.5,9.0,38.0,192.0,38.0,192.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1401,'Herma','5091 Laser/Inkjet A4 für schmale Ordner gelb','S',15.5,9.0,38.0,192.0,38.0,192.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1402,'Herma','5092 Laser/Inkjet A4 für schmale Ordner rot','S',15.5,9.0,38.0,192.0,38.0,192.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1403,'Herma','5093 Laser/Inkjet A4 für schmale Ordner blau','S',15.5,9.0,38.0,192.0,38.0,192.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1404,'Herma','5094 Laser/Inkjet A4 für schmale Ordner grün','S',15.5,9.0,38.0,192.0,38.0,192.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1405,'Herma','5095 Laser/Inkjet A4 für breite Ordner weiß','S',26.5,9.0,61.0,192.0,61.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1406,'Herma','5096 Laser/Inkjet A4 für breite Ordner gelb','S',26.5,9.0,61.0,192.0,61.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1407,'Herma','5097 Laser/Inkjet A4 für breite Ordner rot','S',26.5,9.0,61.0,192.0,61.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1408,'Herma','5098 Laser/Inkjet A4 für breite Ordner blau','S',26.5,9.0,61.0,192.0,61.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1409,'Herma','5099 Laser/Inkjet A4 für breite Ordner grün','S',26.5,9.0,61.0,192.0,61.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1410,'Herma','5123 Laser/Inkjet A4 für breite Ordner weiß','S',30.5,9.0,59.0,192.0,59.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1411,'Herma','5124 Laser/Inkjet A4 für breite Ordner gelb','S',30.5,9.0,59.0,192.0,59.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1412,'Herma','5125 Laser/Inkjet A4 für breite Ordner rot','S',30.5,9.0,59.0,192.0,59.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1413,'Herma','5126 Laser/Inkjet A4 für breite Ordner blau','S',30.5,9.0,59.0,192.0,59.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1414,'Herma','5127 Laser/Inkjet A4 für breite Ordner grün','S',30.5,9.0,59.0,192.0,59.0,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1415,'Herma','5128 Laser/Inkjet A4 für schmale Ordner lang farbig sort.','S',0.0,10.0,297.0,38.0,297.0,38.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (1416,'Herma','5129 Laser/Inkjet A4 für breite Ordner lang farbig sort.','S',0.0,13.5,297.0,61.0,297.0,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1417,'Herma','5130 Laser/Inkjet A4 für schmale Ordner lang weiß','S',0.0,10.0,297.0,38.0,297.0,38.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (1418,'Herma','5131 Laser/Inkjet A4 für schmale Ordner lang gelb','S',0.0,10.0,297.0,38.0,297.0,38.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (1419,'Herma','5132 Laser/Inkjet A4 für schmale Ordner lang rot','S',0.0,10.0,297.0,38.0,297.0,38.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (1420,'Herma','5133 Laser/Inkjet A4 für schmale Ordner lang blau','S',0.0,10.0,297.0,38.0,297.0,38.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (1421,'Herma','5134 Laser/Inkjet A4 für schmale Ordner lang grün','S',0.0,10.0,297.0,38.0,297.0,38.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (1422,'Herma','5135 Laser/Inkjet A4 für breite Ordner lang weiß','S',0.0,13.5,297.0,61.0,297.0,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1423,'Herma','5136 Laser/Inkjet A4 für breite Ordner lang gelb','S',0.0,13.5,297.0,61.0,297.0,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1424,'Herma','5137 Laser/Inkjet A4 für breite Ordner lang rot','S',0.0,13.5,297.0,61.0,297.0,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1425,'Herma','5138 Laser/Inkjet A4 für breite Ordner lang blau','S',0.0,13.5,297.0,61.0,297.0,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1426,'Herma','5139 Laser/Inkjet A4 für breite Ordner lang grün','S',0.0,13.5,297.0,61.0,297.0,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1427,'Herma','5140 Laser A4 neon-gelb','S',15.15,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (1428,'Herma','5141 Laser A4 neon-orange','S',15.15,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (1429,'Herma','5142 Laser A4 neon-pink','S',15.15,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (1430,'Herma','5143 Laser A4 neon-grün','S',15.15,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (1431,'Herma','5144 Laser A4 neon-gelb','S',13.03,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1432,'Herma','5145 Laser A4 neon-orange','S',13.03,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1433,'Herma','5146 Laser A4 neon-pink','S',13.03,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1434,'Herma','5147 Laser A4 neon-grün','S',13.03,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1435,'Herma','5148 Laser A4 neon-gelb A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1436,'Herma','5149 Laser A4 neon-orange A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1437,'Herma','5150 Laser A4 neon-pink A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1438,'Herma','5151 Laser A4 neon-grün A4','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1439,'Herma','5152 Laser A4 neon-gelb Kreise 60 mm','S',18.0,8.0,60.0,60.0,67.0,67.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1440,'Herma','5153 Laser A4 neon-orange Kreise 60 mm','S',18.0,8.0,60.0,60.0,67.0,67.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1441,'Herma','5154 Laser A4 neon-pink Kreise 60 mm','S',18.0,8.0,60.0,60.0,67.0,67.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1442,'Herma','5155 Laser A4 neon-grün Kreise 60 mm','S',18.0,8.0,60.0,60.0,67.0,67.0,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1443,'Herma','5158 Laser/Inkjet A4 für schmale Ordner lang weiß','S',0.0,20.0,297.0,34.0,297.0,34.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (1444,'Herma','5159 Laser/Inkjet A4 für breite Ordner lang weiß','S',0.0,16.5,297.0,59.0,297.0,59.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1445,'Herma','5160 Laser/Inkjet A4 für schmale Ordner weiß','S',12.5,9.0,34.0,192.0,34.0,192.0,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (1446,'Herma','5161 Laser/Inkjet A4 für schmale Ordner gelb','S',12.5,9.0,34.0,192.0,34.0,192.0,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (1447,'Herma','5162 Laser/Inkjet A4 für schmale Ordner rot','S',12.5,9.0,34.0,192.0,34.0,192.0,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (1448,'Herma','5163 Laser/Inkjet A4 für schmale Ordner blau','S',12.5,9.0,34.0,192.0,34.0,192.0,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (1449,'Herma','5164 Laser/Inkjet A4 für schmale Ordner grün','S',12.5,9.0,34.0,192.0,34.0,192.0,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (1450,'Herma','5165 Laser/Inkjet A4 für schmale Hängeordner weiß','S',0.0,20.0,297.0,34.0,297.0,34.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (1451,'Herma','5166 Laser/Inkjet A4 für breite Hängeordner weiß','S',0.0,18.0,297.0,58.0,297.0,58.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1452,'Herma','5167 Laser/Inkjet A4 für breite Hängeordner weiß','S',0.0,10.5,297.0,63.0,297.0,63.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1453,'Herma','8600 Laser/Inkjet A5 Kreise 10 mm weiß ablösbar','S',12.1,11.1,10.0,10.0,12.7,12.7,15,10, NULL, NULL ) +INSERT INTO label_def VALUES (1454,'Herma','8601 Laser/Inkjet A5 Kreise 20 mm weiß ablösbar','S',6.75,14.5,20.0,20.0,23.0,23.0,8,6, NULL, NULL ) +INSERT INTO label_def VALUES (1455,'Herma','8602 Laser/Inkjet A5 Kreise 60 mm gelb ablösbar','S',10.75,8.0,60.0,60.0,67.0,67.0,3,2, NULL, NULL ) +INSERT INTO label_def VALUES (1456,'Herma','8603 Laser/Inkjet A5 weiß Ecken abgerundet ablösbar','S',10.5,7.21,8.5,12.7,8.5,15.24,13,15, NULL, NULL ) +INSERT INTO label_def VALUES (1457,'Herma','8604 Laser/Inkjet A5 weiß Ecken abgerundet ablösbar','S',14.25,4.57,10.0,17.8,10.0,20.34,10,12, NULL, NULL ) +INSERT INTO label_def VALUES (1458,'Herma','8605 Laser/Inkjet A5 weiß Ecken abgerundet ablösbar','S',15.0,8.48,16.93,25.4,16.93,27.94,7,7, NULL, NULL ) +INSERT INTO label_def VALUES (1459,'Herma','8606 Laser/Inkjet A5 Diabeschriftung weiß','S',14.25,9.75,10.0,45.72,10.0,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (1460,'Herma','8607 Laser/Inkjet A5 Sichtreiteretiketten weiß','S',15.0,9.75,16.93,45.72,16.93,48.26,4,7, NULL, NULL ) +INSERT INTO label_def VALUES (1461,'Herma','8608 Laser/Inkjet A5 weiß Ecken abgerundet','S',15.0,7.21,29.63,63.5,29.63,66.04,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1462,'Herma','8609 Laser/Inkjet A5 weiß Ecken abgerundet','S',10.76,7.73,42.33,96.0,42.33,98.54,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (1463,'Herma','8610 Laser/Inkjet A5 weiß Ecken abgerundet','S',10.75,7.73,63.5,96.0,63.5,98.54,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1464,'Herma','8611 Laser/Inkjet A5 3 5\"-Disketten farbig sortiert','S',6.52,25.0,67.73,70.0,67.73,90.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1465,'Herma','8612 Laser/Inkjet A5 Videoetiketten Front weiß','S',27.69,24.99,46.46,78.74,46.46,81.28,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1466,'Herma','8613 Laser/Inkjet A5 Videoetiketten Rücken weiß','S',15.0,31.34,16.93,147.32,16.93,147.32,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1467,'Herma','8614 Laser/Inkjet A5 Musik-Cassetten weiß','S',10.76,14.73,42.33,89.0,42.33,91.54,2,3, NULL, NULL ) +INSERT INTO label_def VALUES (1468,'Herma','8615 Laser/Inkjet A5 für schmale Ordner farbig sortiert','S',17.25,9.0,38.0,192.0,38.0,192.0,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (1469,'Herma','8616 Laser/Inkjet A5 für breite Ordner farbig sortiert','S',13.25,9.0,61.0,192.0,61.0,192.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1470,'Herma','8650 ColorPrint weiß Ecken abgerundet','S',15.15,7.21,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1471,'Herma','8651 ColorPrint weiß Ecken abgerundet','S',13.03,12.29,33.87,88.9,33.87,96.52,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1472,'Herma','8652 ColorPrint weiß Ecken abgerundet','S',8.82,12.29,46.56,88.9,46.56,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1473,'Herma','8653 ColorPrint weiß Ecken abgerundet','S',21.5,7.73,50.8,96.0,50.8,98.54,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1474,'Herma','8654 ColorPrint weiß Ecken abgerundet','S',8.8,7.73,139.7,96.0,139.7,98.54,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1475,'Herma','8655 ColorPrint weiß Ecken abgerundet','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1476,'Herma','8680 ColorPrint weiß Ecken abgerundet','S',15.15,7.21,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1477,'Herma','8681 ColorPrint weiß Ecken abgerundet','S',8.82,12.29,46.56,88.9,46.56,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1478,'Herma','8682 ColorPrint weiß Ecken abgerundet','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1479,'Herma','8800 InkPrint Special weiß Ecken abgerundet','S',13.03,17.37,33.87,53.34,33.87,60.96,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1480,'Herma','8801 InkPrint Special weiß Ecken abgerundet','S',15.15,7.21,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1481,'Herma','8802 InkPrint Special weiß Ecken abgerundet','S',8.82,7.21,46.56,63.5,46.56,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (1482,'Herma','8803 InkPrint Special 3 5\"-Disketten weiß','S',21.5,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1483,'Herma','8804 InkPrint Special weiß Ecken abgerundet','S',13.03,12.29,33.87,88.9,33.87,96.52,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1484,'Herma','8805 InkPrint Special weiß Ecken abgerundet','S',8.8,12.29,46.57,88.9,46.57,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1485,'Herma','8806 InkPrint Special weiß Ecken abgerundet','S',21.5,7.73,50.8,96.0,50.8,98.54,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1486,'Herma','8807 InkPrint Special weiß z.B. Paketadresse ca. A6','S',8.8,7.73,139.7,96.0,139.7,98.54,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1487,'Herma','8808 InkPrint Special weiß Ecken abgerundet','S',13.03,4.67,33.87,99.06,33.87,101.6,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1488,'Herma','8809 InkPrint Special weiß Ecken abgerundet','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1489,'Herma','8810 InkPrint Special weiß Ecken abgerundet','S',13.03,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1490,'Herma','8811 InkPrint Special weiß ca. DIN A5','S',8.8,9.0,139.7,192.0,139.7,192.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1491,'Herma','8830 InkPrint Special weiß z.B. für Preisauszeichnung','S',13.03,8.48,8.47,25.4,8.47,27.94,7,32, NULL, NULL ) +INSERT INTO label_def VALUES (1492,'Herma','8831 InkPrint Special weiß quadratisch','S',8.8,16.1,25.4,25.4,25.4,30.48,6,11, NULL, NULL ) +INSERT INTO label_def VALUES (1493,'Herma','8832 InkPrint Special weiß z.B. für Preisauszeichnung','S',13.03,7.21,16.93,30.48,16.93,33.02,6,16, NULL, NULL ) +INSERT INTO label_def VALUES (1494,'Herma','8833 InkPrint Special weiß','S',10.7,9.75,21.2,38.1,21.2,38.1,5,13, NULL, NULL ) +INSERT INTO label_def VALUES (1495,'Herma','8834 InkPrint Special weiß','S',13.3,8.4,16.93,48.3,16.93,48.3,4,16, NULL, NULL ) +INSERT INTO label_def VALUES (1496,'Herma','8835 InkPrint Special weiß','S',8.8,8.4,25.4,48.3,25.4,48.3,4,11, NULL, NULL ) +INSERT INTO label_def VALUES (1497,'Herma','8836 InkPrint Special weiß Ecken abgerundet','S',13.03,17.37,33.87,53.34,33.87,60.96,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1498,'Herma','8837 InkPrint Special weiß Ecken abgerundet','S',8.8,7.21,25.4,63.5,25.4,66.04,3,11, NULL, NULL ) +INSERT INTO label_def VALUES (1499,'Herma','8838 InkPrint Special weiß Ecken abgerundet','S',15.15,7.21,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1500,'Herma','8839 InkPrint Special 3 5\"-Disketten weiß','S',21.5,25.0,50.8,70.0,50.8,90.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1501,'Herma','8840 InkPrint Special weiß Visitenkartenformat','S',21.5,18.64,50.8,83.82,50.8,88.9,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1502,'Herma','8841 InkPrint Special weiß Ecken abgerundet','S',13.03,12.29,33.87,88.9,33.87,96.52,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1503,'Herma','8842 InkPrint Special weiß Ecken abgerundet','S',8.82,12.29,46.56,88.9,46.56,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1504,'Herma','8843 InkPrint Special weiß z.B. für Regalbeschriftung','S',13.03,7.73,8.47,96.0,8.47,98.54,2,32, NULL, NULL ) +INSERT INTO label_def VALUES (1505,'Herma','8844 InkPrint Special weiß z.B. für Regalbeschriftung','S',13.03,7.73,16.93,96.0,16.93,98.54,2,16, NULL, NULL ) +INSERT INTO label_def VALUES (1506,'Herma','8845 InkPrint Special weiß Ecken abgerundet','S',21.5,7.73,50.8,96.0,50.8,98.54,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1507,'Herma','8846 InkPrint Special weiß','S',13.03,8.48,67.73,96.52,67.73,96.52,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1508,'Herma','8847 InkPrint Special weiß Paketadresse ca. A6','S',8.8,7.73,139.7,96.0,139.7,98.54,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1509,'Herma','8848 InkPrint Special weiß z.B. für Regalbeschriftung','S',13.03,9.0,8.47,192.0,8.47,192.0,1,32, NULL, NULL ) +INSERT INTO label_def VALUES (1510,'Herma','8849 InkPrint Special weiß z.B. für Regalbeschriftung','S',13.03,9.0,16.93,192.0,16.93,192.0,1,16, NULL, NULL ) +INSERT INTO label_def VALUES (1511,'Herma','8850 InkPrint Special weiß ca. DIN A5','S',8.8,9.0,139.7,192.0,139.7,192.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1512,'Herma','8851 InkPrint Special Kreise 32 mm weiß','S',18.2,12.8,32.0,32.0,38.1,38.1,5,7, NULL, NULL ) +INSERT INTO label_def VALUES (1513,'Herma','8852 InkPrint Special Kreise 63 5 mm weiß','S',15.16,7.21,63.5,63.5,67.73,66.04,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1514,'Herma','8853 InkPrint Special Oval weiß','S',10.92,12.29,42.33,58.42,46.56,63.5,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (1515,'Herma','8854 InkPrint Special Oval weiß','S',15.15,13.56,63.5,88.9,67.73,93.98,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1516,'Herma','8855 InkPrint Special abgeschrägte Ecken weiß','S',13.03,12.29,67.73,88.9,67.73,96.52,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1517,'Herma','8856 InkPrint Special Registeretiketten weiß','S',10.92,16.1,42.3,25.4,46.56,30.48,6,6, NULL, NULL ) +INSERT INTO label_def VALUES (1518,'Herma','8857 InkPrint Special Sterne 63 5 mm weiß','S',15.16,7.21,63.5,63.5,67.73,66.04,3,4, NULL, NULL ) +INSERT INTO label_def VALUES (1519,'Herma','8858 InkPrint Special weiß Ecken abgerundet','S',8.82,7.21,46.56,63.5,46.56,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (1520,'Herma','8859 InkPrint Special weiß Ecken abgerundet','S',13.03,4.67,33.87,99.06,33.87,101.6,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1521,'Herma','8860 InkPrint Special weiß Ecken abgerundet','S',15.15,4.67,38.1,99.06,38.1,101.6,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1522,'Herma','8861 InkPrint Special weiß Ecken abgerundet','S',6.0,4.67,57.0,99.06,57.0,101.6,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1523,'Herma','8862 InkPrint Special weiß Ecken abgerundet','S',13.03,4.67,67.73,99.06,67.73,101.6,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1524,'Herma','8863 InkPrint Special Kreise 40 mm weiß','S',13.5,16.0,40.0,40.0,46.0,46.0,4,6, NULL, NULL ) +INSERT INTO label_def VALUES (1525,'Herma','8864 InkPrint Special weiß Ecken abgerundet','S',21.5,9.75,21.17,45.72,21.17,48.26,4,12, NULL, NULL ) +INSERT INTO label_def VALUES (1526,'Herma','8865 InkPrint Special weiß Ecken abgerundet','S',15.15,7.21,29.63,63.5,29.63,66.04,3,9, NULL, NULL ) +INSERT INTO label_def VALUES (1527,'Herma','8866 InkPrint Special weiß Ecken abgerundet','S',21.5,7.73,42.33,96.0,42.33,98.54,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1528,'Herma','8867 InkPrint Special weiß Ecken abgerundet','S',21.5,7.73,63.5,96.0,63.5,98.54,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1529,'Herma','8868 InkPrint Special Sonderform weiß','S',10.93,7.21,42.33,63.5,46.57,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (1530,'Herma','8869 InkPrint Special Oval weiß','S',10.93,7.21,42.33,63.5,46.57,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (1531,'Herma','8870 InkPrint Special Oval weiß','S',15.15,7.73,63.5,96.0,67.73,98.54,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1532,'Herma','8887 InkPrint Special Glossy Paßfoto-Format Two-in-one','S',24.0,26.0,45.0,35.0,51.0,41.0,4,5, NULL, NULL ) +INSERT INTO label_def VALUES (1533,'Herma','8888 InkPrint Special Glossy CD-Cover-Etikett/Einleger Two-in-one','S',17.0,44.25,117.5,121.5,145.5,121.5,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1534,'Herma','8889 InkPrint Special Glossy Visitenkartenetikett Two-in-one','S',12.5,15.5,52.0,83.0,55.0,96.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1535,'Herma','8890 InkPrint Special Glossy-Qualität Ecken abgerundet','S',15.15,7.21,38.1,63.5,38.1,66.04,3,7, NULL, NULL ) +INSERT INTO label_def VALUES (1536,'Herma','8891 InkPrint Special Glossy-Qualität Ecken abgerundet','S',13.03,12.29,33.87,88.9,33.87,96.52,2,8, NULL, NULL ) +INSERT INTO label_def VALUES (1537,'Herma','8892 InkPrint Special Glossy-Qualität Ecken abgerundet','S',8.82,12.29,46.56,88.9,46.56,96.52,2,6, NULL, NULL ) +INSERT INTO label_def VALUES (1538,'Herma','8893 InkPrint Special Glossy-Qualität Ecken abgerundet','S',21.5,7.73,50.8,96.0,50.8,98.54,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1539,'Herma','8894 InkPrint Special Glossy-Qualität Ecken abgerundet','S',8.8,7.73,139.7,96.0,139.7,98.54,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1540,'Herma','8895 InkPrint Special Glossy-Qualität weiß','S',0.0,0.0,297.0,210.0,297.0,210.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1541,'Herma','8896 InkPrint Special Glossy Ecken abgerundet','S',23.64,7.21,46.56,63.5,50.79,66.04,3,5, NULL, NULL ) +INSERT INTO label_def VALUES (1542,'Herma','8897 InkPrint Special Glossy Ecken abgerundet','S',15.15,13.56,63.5,88.9,67.73,93.98,2,4, NULL, NULL ) +INSERT INTO label_def VALUES (1543,'Herma','8898 InkPrint Special Glossy Fotos 9x13 Two-in-one','S',19.32,13.56,127.0,88.9,131.23,93.98,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1544,'Herma','8899 InkPrint Special Glossy Fotos 13x18 Two-in-one','S',18.43,16.0,127.0,178.0,133.0,178.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1545,'Herma','8900 InkPrint Special Glossy CD-Etikett weiß','S',16.5,47.0,116.0,116.0,148.0,116.0,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1546,'Herma','8901 InkPrint Special Glossy oval','S',10.93,7.21,42.33,63.5,46.56,66.04,3,6, NULL, NULL ) +INSERT INTO label_def VALUES (1547,'Herma','8001 Endlosetiketten 1-bahnig','C',0.0,11.05,23.0,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1548,'Herma','8002 Endlosetiketten 3-bahnig Kennzeichnung','C',0.0,14.86,14.53,25.4,16.93,27.94,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1549,'Herma','8003 Endlosetiketten 2-bahnig Kennzeichnung','C',0.0,18.67,19.0,35.56,21.17,38.1,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1550,'Herma','8004 Endlosetiketten 2-bahnig Diabeschriftung','C',0.0,11.05,10.3,43.18,12.7,45.72,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1551,'Herma','8005 Endlosetiketten 2-bahnig Kennzeichnung','C',0.0,16.13,23.0,38.1,25.4,40.64,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1552,'Herma','8006 Endlosetiketten 2-bahnig Kennzeichnung','C',0.0,13.59,14.53,40.64,16.93,43.18,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1553,'Herma','8007 Endlosetiketten 2-bahnig Kennzeichnung','C',0.0,11.05,35.7,43.18,38.1,45.72,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1554,'Herma','8008 Endlosetiketten 1-bahnig 3 5\"-Diskette weiß','C',0.0,19.94,69.6,71.12,76.2,71.12,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1555,'Herma','8009 Endlosetiketten 1-bahnig Namensetiketten Acetatseide','C',0.0,17.0,23.0,70.0,25.4,70.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1556,'Herma','8010 Endlosetiketten 1-bahnig 3 5\"-Diskette weiß Front','C',0.0,14.44,48.4,71.12,50.8,71.12,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1557,'Herma','8011 Endlosetiketten 1-bahnig 3 5\"-Diskette gelb','C',0.0,17.0,69.6,71.12,76.2,71.12,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1558,'Herma','8012 Endlosetiketten 1-bahnig 3 5\"-Diskette rot','C',0.0,17.0,69.6,71.12,76.2,71.12,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1559,'Herma','8013 Endlosetiketten 1-bahnig 3 5\"-Diskette blau','C',0.0,17.0,69.6,71.12,76.2,71.12,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1560,'Herma','8014 Endlosetiketten 1-bahnig','C',0.0,15.71,35.7,68.58,38.1,68.58,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1561,'Herma','8015 Endlosetiketten 1-bahnig 3 5\"-Diskette grün','C',0.0,17.0,69.6,71.12,76.2,71.12,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1562,'Herma','8021 Endlosetiketten 2-bahnig gelb','C',0.0,16.13,23.0,38.1,25.4,40.64,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1563,'Herma','8022 Endlosetiketten 2-bahnig rot','C',0.0,16.13,23.0,38.1,25.4,40.64,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1564,'Herma','8036 Endlosetiketten 2-bahnig ablösbar','C',0.0,16.13,23.0,38.1,25.4,40.64,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1565,'Herma','8038 Endlosetiketten 1-bahnig Recyclingpapier','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1566,'Herma','8039 Endlosetiketten 1-bahnig Recyclingpapier','C',0.0,11.05,48.4,88.9,50.8,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1567,'Herma','8040 Endlosetiketten 1-bahnig','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1568,'Herma','8041 Endlosetiketten 1-bahnig gelb','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1569,'Herma','8042 Endlosetiketten 1-bahnig rot','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1570,'Herma','8043 Endlosetiketten 1-bahnig blau','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1571,'Herma','8045 Endlosetiketten 1-bahnig grün','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1572,'Herma','8050 Endlosetiketten 1-bahnig','C',0.0,11.05,48.4,88.9,50.8,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1573,'Herma','8051 Endlosetiketten 2-bahnig PE-Folie weiß','C',0.0,16.13,23.0,38.1,25.4,40.64,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1574,'Herma','8053 Endlosetiketten 2-bahnig PP-Folie weiß','C',0.0,16.13,23.0,38.1,25.4,40.64,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1575,'Herma','8055 Endlosetiketten 2-bahnig transparente Folie','C',0.0,16.13,23.0,38.1,25.4,40.64,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1576,'Herma','8060 Endlosetiketten 1-bahnig','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1577,'Herma','8061 Endlosetiketten 1-bahnig','C',0.0,11.05,48.4,88.9,50.8,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1578,'Herma','8066 Endlosetiketten 1-bahnig','C',0.0,11.7,35.7,101.6,38.1,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1579,'Herma','8067 Endlosetiketten 1-bahnig','C',0.0,9.16,35.7,106.68,38.1,106.68,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1580,'Herma','8068 Endlosetiketten 1-bahnig','C',0.0,11.7,48.4,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1581,'Herma','8069 Endlosetiketten 1-bahnig','C',0.0,9.16,48.4,106.68,50.8,106.68,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1582,'Herma','8070 Endlosetiketten 1-bahnig','C',0.0,11.62,48.4,111.76,50.8,111.76,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1583,'Herma','8071 Endlosetiketten 1-bahnig Videocassetten','C',0.0,11.34,19.0,147.32,25.4,147.32,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1584,'Herma','8072 Endlosetiketten 1-bahnig Querperforation weiß','C',0.0,11.0,99.2,147.32,101.6,147.32,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1585,'Herma','8073 Endlosetiketten 1-bahnig Querperforation gelb','C',0.0,11.0,99.2,147.32,101.6,147.32,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1586,'Herma','8074 Endlosetiketten 1-bahnig Querperforation rot','C',0.0,11.0,99.2,147.32,101.6,147.32,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1587,'Herma','8104 Endlosetiketten 1-bahnig mit Querperforation','C',0.0,11.05,48.4,88.9,50.8,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1588,'Herma','8111 Endlosetiketten 1-bahnig mit Querperforation','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1589,'Herma','8112 Endlosetiketten 1-bahnig mit Querperforation','C',0.0,11.7,35.7,101.6,38.1,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1590,'Herma','8113 Endlosetiketten 1-bahnig mit Querperforation','C',0.0,11.7,48.4,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1591,'Herma','8116 Endlosetiketten 1-bahnig mit Querperforation','C',0.0,11.62,48.4,111.76,50.8,111.76,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1592,'Herma','8121 Endlosetiketten 1-bahnig gelb','C',0.0,11.7,48.4,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1593,'Herma','8122 Endlosetiketten 1-bahnig rot','C',0.0,11.7,48.4,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1594,'Herma','8123 Endlosetiketten 1-bahnig blau','C',0.0,11.7,48.4,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1595,'Herma','8125 Endlosetiketten 1-bahnig grün','C',0.0,11.7,48.4,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1596,'Herma','8130 Endlosetiketten 1-bahnig transparente Folie','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1597,'Herma','8135 Endlosetiketten 1-bahnig transparente Folie','C',0.0,11.0,73.8,147.32,76.2,147.32,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1598,'Herma','8140 Endlosetiketten 1-bahnig PP-Folie weiß','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1599,'Herma','8145 Endlosetiketten 1-bahnig PP-Folie weiß','C',0.0,11.0,73.8,147.32,76.2,147.32,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1600,'Herma','8150 Endlosetiketten 1-bahnig PE-Folie weiß','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1601,'Herma','8155 Endlosetiketten 1-bahnig PE-Folie weiß','C',0.0,11.0,73.8,147.32,76.2,147.32,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1602,'Herma','8158 Endlosetiketten 1-bahnig Kennzeichnung','C',0.0,13.17,10.3,73.66,12.7,73.66,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1603,'Herma','8160 Endlosetiketten 1-bahnig','C',0.0,11.05,23.0,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1604,'Herma','8161 Endlosetiketten 1-bahnig','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1605,'Herma','8162 Endlosetiketten 1-bahnig','C',0.0,11.7,35.7,101.6,38.1,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1606,'Herma','8163 Endlosetiketten 1-bahnig','C',0.0,11.7,48.4,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1607,'Herma','8164 Endlosetiketten 1-bahnig','C',0.0,11.7,23.0,101.6,25.4,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1608,'Herma','8166 Endlosetiketten 1-bahnig','C',0.0,11.62,48.4,111.76,50.8,111.76,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1609,'Herma','8167 Endlosetiketten 2-bahnig','C',0.0,17.13,35.7,101.6,38.1,104.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1610,'Herma','8168 Endlosetiketten 2-bahnig','C',0.0,22.13,48.4,101.6,50.8,104.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1611,'Herma','8169 Endlosetiketten 2-bahnig','C',0.0,12.13,23.0,101.6,25.4,104.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1612,'Herma','8170 Endlosetiketten 1-bahnig ablösbar','C',0.0,11.05,23.0,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1613,'Herma','8171 Endlosetiketten 1-bahnig ablösbar','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1614,'Herma','8172 Endlosetiketten 1-bahnig ablösbar','C',0.0,15.71,35.7,68.58,38.1,68.58,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1615,'Herma','8173 Endlosetiketten 1-bahn. Querperforation ablösbar','C',0.0,11.0,48.4,147.32,50.8,147.32,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1616,'Herma','8178 Endlosetiketten 1-bahnig schnittgestanzt','C',0.0,10.0,38.1,95.0,38.1,95.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1617,'Herma','8179 Endlosetiketten 1-bahnig schnittgestanzt','C',0.0,9.0,50.8,152.0,50.8,152.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1618,'Herma','8181 Endlosetiketten 1-bahnig gelb','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1619,'Herma','8182 Endlosetiketten 1-bahnig rot','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1620,'Herma','8183 Endlosetiketten 1-bahnig blau','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1621,'Herma','8185 Endlosetiketten 1-bahnig grün','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1622,'Herma','8187 Endlosetiketten 1-bahnig Recyclingpapier','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1623,'Herma','8189 Endlosetiketten 1-bahnig Recyclingpapier','C',0.0,11.7,48.4,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1624,'Herma','8200 Endlosetiketten 1-bahnig','C',0.0,10.63,23.0,78.74,25.4,78.74,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1625,'Herma','8201 Endlosetiketten 1-bahnig 3 5\"-Diskette Front','C',0.0,14.44,48.4,71.12,50.8,71.12,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1626,'Herma','8202 Endlosetiketten 1-bahnig Kennzeichnung','C',0.0,13.17,10.3,73.66,12.7,73.66,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1627,'Herma','8203 Endlosetiketten 1-bahnig','C',0.0,11.7,73.8,101.6,76.2,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1628,'Herma','8204 Endlosetiketten 1-bahnig','C',0.0,11.05,48.4,88.9,50.8,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1629,'Herma','8207 Endlosetiketten 1-bahnig','C',0.0,8.81,35.7,68.58,38.1,68.58,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1630,'Herma','8209 Endlosetiketten 1-bahnig','C',0.0,9.16,35.7,106.68,38.1,106.68,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1631,'Herma','8210 Endlosetiketten 1-bahnig','C',0.0,11.05,23.0,88.9,25.4,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1632,'Herma','8211 Endlosetiketten 1-bahnig','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1633,'Herma','8212 Endlosetiketten 1-bahnig','C',0.0,11.7,35.7,101.6,38.1,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1634,'Herma','8213 Endlosetiketten 1-bahnig','C',0.0,11.7,48.4,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1635,'Herma','8214 Endlosetiketten 1-bahnig','C',0.0,11.7,23.0,101.6,25.4,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1636,'Herma','8215 Endlosetiketten 1-bahnig','C',0.0,11.62,35.7,111.76,38.1,111.76,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1637,'Herma','8216 Endlosetiketten 1-bahnig','C',0.0,11.62,48.4,111.76,50.8,111.76,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1638,'Herma','8217 Endlosetiketten 1-bahnig','C',0.0,11.5,23.0,127.0,25.4,127.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1639,'Herma','8218 Endlosetiketten 1-bahnig','C',0.0,11.5,35.7,127.0,38.1,127.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1640,'Herma','8219 Endlosetiketten 1-bahnig','C',0.0,12.0,19.0,134.6,21.17,134.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1641,'Herma','8220 Endlosetiketten 2-bahnig','C',0.0,11.08,35.7,88.9,38.1,91.44,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1642,'Herma','8221 Endlosetiketten 2-bahnig','C',0.0,11.08,23.0,88.9,25.4,91.44,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1643,'Herma','8222 Endlosetiketten 2-bahnig','C',0.0,10.43,35.7,50.8,38.1,53.34,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1644,'Herma','8225 Endlosetiketten 2-bahnig','C',0.0,12.13,35.7,101.6,38.1,104.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1645,'Herma','8226 Endlosetiketten 2-bahnig','C',0.0,11.08,48.4,88.9,50.8,91.44,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1646,'Herma','8227 Endlosetiketten 2-bahnig','C',0.0,12.13,48.4,101.6,50.8,104.14,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1647,'Herma','8228 Endlosetiketten 2-bahnig','C',0.0,16.13,10.3,38.1,12.7,40.64,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1648,'Herma','8229 Endlosetiketten 2-bahnig','C',0.0,10.43,23.0,50.8,25.4,53.34,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1649,'Herma','8230 Endlosetiketten 3-bahnig','C',0.0,12.11,23.0,88.9,25.4,91.44,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1650,'Herma','8231 Endlosetiketten 3-bahnig','C',0.0,12.11,35.7,88.9,38.1,91.44,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1651,'Herma','8232 Endlosetiketten 3-bahnig','C',0.0,11.56,35.7,101.6,38.1,104.14,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1652,'Herma','8233 Endlosetiketten 3-bahnig','C',0.0,12.44,48.4,106.68,50.8,109.22,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1653,'Herma','8234 Endlosetiketten 3-bahnig','C',0.0,12.11,48.4,88.9,50.8,91.44,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1654,'Herma','8235 Endlosetiketten 3-bahnig','C',0.0,12.32,48.4,111.76,50.8,114.3,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1655,'Herma','8236 Endlosetiketten 3-bahnig mit Querperforation','C',0.0,12.09,35.7,68.58,38.1,71.12,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1656,'Herma','8237 Endlosetiketten 3-bahnig','C',0.0,12.44,35.7,106.68,38.1,109.22,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1657,'Herma','8238 Endlosetiketten 3-bahnig','C',0.0,11.56,48.4,101.6,50.8,104.14,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1658,'Herma','8240 Endlosetiketten 4-bahnig','C',0.0,10.87,35.7,73.66,38.1,76.2,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (1659,'Herma','8241 Endlosetiketten 4-bahnig','C',0.0,12.13,23.0,81.28,25.4,83.82,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (1660,'Herma','8242 Endlosetiketten 4-bahnig','C',0.0,12.13,35.7,81.28,38.1,83.82,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (1661,'Herma','8243 Endlosetiketten 4-bahnig','C',0.0,12.13,48.4,81.28,50.8,83.82,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (1662,'Herma','8245 Endlosetiketten 4-bahnig','C',0.0,12.09,23.0,50.8,25.4,53.34,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (1663,'Herma','8246 Endlosetiketten 4-bahnig','C',0.0,12.09,35.7,50.8,38.1,53.34,4,1, NULL, NULL ) +INSERT INTO label_def VALUES (1664,'Herma','8261 Endlosetiketten 1-bahnig Recyclingpapier','C',0.0,11.05,35.7,88.9,38.1,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1665,'Herma','8262 Endlosetiketten 1-bahnig Recyclingpapier','C',0.0,11.7,35.7,101.6,38.1,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1666,'Herma','8263 Endlosetiketten 1-bahnig Recyclingpapier','C',0.0,11.7,48.4,101.6,50.8,101.6,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1667,'Herma','8264 Endlosetiketten 1-bahnig Recyclingpapier','C',0.0,11.05,48.4,88.9,50.8,88.9,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1668,'Herma','8265 Endlosetiketten 1-bahnig','C',0.0,11.5,48.4,127.0,50.8,127.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1669,'Herma','8266 Endlosetiketten 2-bahnig','C',0.0,11.73,48.4,127.0,50.8,129.54,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1670,'Herma','8267 Endlosetiketten 1-bahnig','C',0.0,10.63,35.7,78.74,38.1,78.74,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1671,'Herma','8269 Endlosetiketten 1-bahnig mit Querperforation','C',0.0,12.09,150.0,210.82,152.4,210.82,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1672,'Herma','8290 Endlosetiketten 2-bahnig mit Querperforation','C',0.0,11.41,99.2,147.32,101.6,149.86,2,1, NULL, NULL ) +INSERT INTO label_def VALUES (1673,'Herma','8291 Endlosetiketten 1-bahnig 3 5\"-Diskette','C',0.0,19.94,69.6,71.12,76.2,71.12,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1674,'Herma','8292 Endlosetiketten 1-bahnig mit Querperforation','C',0.0,11.0,99.2,147.32,101.6,147.32,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1675,'Herma','8293 Endlosetiketten 1-bahnig mit Querperforation','C',0.0,11.0,48.4,147.32,50.8,147.32,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1676,'Herma','8294 Endlosetiketten 1-bahnig mit Querperforation','C',0.0,11.0,73.8,147.32,76.2,147.32,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1677,'Herma','8295 Endlosetiketten 8-bahnig','C',0.0,13.71,10.3,38.1,12.7,40.64,8,1, NULL, NULL ) +INSERT INTO label_def VALUES (1678,'Herma','8296 Endlosetiketten 1-bahnig','C',0.0,9.16,48.4,106.68,50.8,106.68,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1679,'Herma','8299 Endlosetiketten 1-bahnig 5 25\"-Diskette ablösbar','C',0.0,14.44,31.46,71.12,33.86,71.12,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1680,'Leitz','1680 Kartonrückenschilder breit','S',21.5,10.0,56.0,190.0,66.0,190.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1681,'Leitz','1681 Kartonrückenschilder schmal','S',16.0,10.0,31.0,190.0,39.0,190.0,1,7, NULL, NULL ) +INSERT INTO label_def VALUES (1682,'Leitz','1685 Papierrückenschilder selbstkl. breit','S',13.5,9.0,61.5,192.0,69.5,192.0,1,4, NULL, NULL ) +INSERT INTO label_def VALUES (1683,'Leitz','1686 Papierrückenschilder selbstkl. schmal','S',11.5,9.0,39.0,192.0,47.0,192.0,1,6, NULL, NULL ) +INSERT INTO label_def VALUES (1684,'Leitz','1687 Papierrückenschilder selbstkl. breit','S',6.0,12.5,285.0,61.5,285.0,61.5,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1685,'Leitz','1688 Papierrückenschilder selbstkl. schmal','S',6.0,6.0,285.0,39.0,285.0,39.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (1686,'Leitz','6098 Papierrückenschilder selbstkl. breit','S',9.0,13.5,279.0,61.0,279.0,61.0,3,1, NULL, NULL ) +INSERT INTO label_def VALUES (1687,'Leitz','6099 Papierrückenschilder selbstkl. schmal','S',9.0,20.0,279.0,34.0,279.0,34.0,5,1, NULL, NULL ) +INSERT INTO label_def VALUES (1688,'Leitz','1900 Blanko-Schildchen','S',12.0,15.0,20.8,60.0,20.8,60.0,3,13, NULL, NULL ) +INSERT INTO label_def VALUES (1689,'Leitz','2466 Blanko-Schildchen','S',12.0,30.0,15.0,50.0,15.0,50.0,3,18, NULL, NULL ) +INSERT INTO label_def VALUES (1690,'Leitz','6010 Blanko-Schildchen','S',12.0,30.0,21.0,50.0,21.0,50.0,3,13, NULL, NULL ) +INSERT INTO label_def VALUES (1691,'Leitz','6643 Beschriftungsschilder selbstklebend ','S',12.0,32.0,39.0,73.0,39.0,73.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1692,'Sigel','DP001 Tischkarten blanko weiß','S',53.5,15.0,85.0,95.0,85.0,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1693,'Sigel','DP002 Tischkarten konturgestanzt','S',53.5,15.0,85.0,95.0,85.0,105.0,2,2, NULL, NULL ) +INSERT INTO label_def VALUES (1694,'Sigel','DE115 Design-Etiketten','S',23.6,19.8,21.2,54.0,25.4,58.2,3,10, NULL, NULL ) +INSERT INTO label_def VALUES (1695,'Sigel','DE141 Design-Etiketten','S',18.0,12.0,30.0,60.0,33.0,63.0,3,8, NULL, NULL ) +INSERT INTO label_def VALUES (1696,'Sigel','LP750 CD-Einleger','S',24.0,29.75,121.0,120.5,131.0,120.5,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1697,'Sigel','DD300 CD-Einleger','S',24.0,29.75,121.0,120.5,131.0,120.5,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1698,'Sigel','DD405 CD-Einleger','S',24.0,29.75,121.0,120.5,131.0,120.5,1,2, NULL, NULL ) +INSERT INTO label_def VALUES (1699,'Sigel','LP755 CD-Booklet','S',28.5,45.0,240.0,120.0,240.0,120.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1700,'Sigel','DD450 CD-Booklet','S',28.5,45.0,240.0,120.0,240.0,120.0,1,1, NULL, NULL ) +INSERT INTO label_def VALUES (1701,'Sigel','DP839/DP939 Design-Visitenkarten','S',10.0,15.0,55.0,85.0,55.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1702,'Sigel','DP835/DP935 Design-Visitenkarten gestanzt','S',11.0,15.0,55.0,85.0,55.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1703,'Sigel','DP836/DP936 Design-Visitenkarten','S',10.0,15.0,55.0,85.0,55.0,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1704,'Sigel','DP837/DP937 Design-Visitenkarten gestanzt m. abger. Ecken','S',6.0,15.0,55.0,85.0,56.5,95.0,2,5, NULL, NULL ) +INSERT INTO label_def VALUES (1705,'Sigel','DP838/DP938 Design-Klapp-Visitenkarten','S',10.0,20.0,55.0,170.0,55.0,170.0,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (1706,'Sigel','LP781 Regalschild','S',15.5,0.0,38.0,105.0,38.0,105.0,2,7, NULL, NULL ) +INSERT INTO label_def VALUES (1707,'Sigel','LP731 Ordner-Einsteckschild','S',28.5,10.0,30.0,190.0,30.0,190.0,1,8, NULL, NULL ) +INSERT INTO label_def VALUES (1708,'Sigel','LP734 Ordner-Einsteckschild','S',16.0,10.0,53.0,190.0,53.0,190.0,1,5, NULL, NULL ) +INSERT INTO label_def VALUES (1709,'Sigel','LP710 Postkarte bedruckt','S',0.0,30.75,99.0,148.5,99.0,148.5,1,3, NULL, NULL ) +INSERT INTO label_def VALUES (1710,'Sigel','LP711 Postkarte','S',0.0,0.0,148.5,99.0,148.5,99.0,2,2, NULL, NULL ) diff --git a/kbarcode/labeleditor.cpp b/kbarcode/labeleditor.cpp new file mode 100644 index 0000000..144d9a1 --- /dev/null +++ b/kbarcode/labeleditor.cpp @@ -0,0 +1,1192 @@ +/*************************************************************************** + labeleditor.cpp - description + ------------------- + begin : Die Apr 23 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "labeleditor.h" + +#include "barcodecombo.h" +#include "barcodedialog.h" +#include "barcodeitem.h" +#include "barcodeprinterdlg.h" +#include "batchprinter.h" +#include "batchwizard.h" +#include "commands.h" +#include "configdialog.h" +#include "databasebrowser.h" +#include "documentitemdlg.h" +#include "kbarcode.h" +#include "kbarcodesettings.h" +#include "label.h" +#include "measurements.h" +#include "mimesources.h" +#include "multilineeditdlg.h" +#include "mycanvasitem.h" +#include "mycanvasview.h" +#include "newlabel.h" +#include "previewdialog.h" +#include "printersettings.h" +#include "printlabeldlg.h" +#include "rectitem.h" +#include "rectsettingsdlg.h" +#include "sqltables.h" +#include "tcanvasitem.h" +#include "tokendialog.h" +#include "tokenprovider.h" +#include "zplutils.h" +//NY34 +#include "textlineitem.h" +//NY34 + +// QT includes +#include <qbuffer.h> +#include <qcanvas.h> +#include <qcheckbox.h> +#include <qclipboard.h> +#include <qdockarea.h> +#include <qdom.h> +#include <qdragobject.h> +#include <qgroupbox.h> +#include <qimage.h> +#include <qinputdialog.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qmap.h> +#include <qmime.h> +#include <qpainter.h> +#include <qpaintdevicemetrics.h> +#include <qpicture.h> +#include <qpoint.h> +#include <qprogressdialog.h> +#include <qsqlquery.h> +#include <qtextbrowser.h> +#include <qtooltip.h> +#include <qvalidator.h> +#include <qxml.h> +#if QT_VERSION <= 0x030100 + #include <qregexp.h> +#endif + +// KDE includes +#include <kabc/stdaddressbook.h> +#include <kaction.h> +#include <kapplication.h> +#include <kcolordialog.h> +#include <kcommand.h> +#include <kcombobox.h> +#include <kfiledialog.h> +#include <kiconloader.h> +#include <kimageio.h> +#include <klineedit.h> +#include <klistbox.h> +#include <klocale.h> +#include <kmenubar.h> +#include <kmessagebox.h> +#include <knuminput.h> +#include <kpopupmenu.h> +#include <kpushbutton.h> +#include <kprinter.h> +#include <krun.h> +#include <kspell.h> +#include <kstatusbar.h> +#include <kstandarddirs.h> +#include <ktempfile.h> +#include <dcopclient.h> + +#include "tcanvasitem.h" +#include "rectitem.h" +#include "textitem.h" +#include "imageitem.h" +#include "barcodeitem.h" +#include "lineitem.h" + +#define STATUS_ID_SIZE 100 +#define STATUS_ID_TEMPLATE 101 +#define STATUS_ID_MOUSE 102 + +#define ID_LOCK_ITEM 8000 + +#define CANVAS_UPDATE_PERIOD 50 + +#define KBARCODE_UNDO_LIMIT 25 + +using namespace KABC; + +LabelEditor::LabelEditor( QWidget *parent, QString _filename, const char *name, WFlags f ) + : DCOPObject( "LabelEditor" ), + DSMainWindow( parent, name, f ) +{ + undoAct = + redoAct = NULL; + history = NULL; + + description = QString::null; + d = new Definition(); + m_token = new TokenProvider( KApplication::desktop() ); + + statusBar()->insertItem( "", STATUS_ID_TEMPLATE, 0, true ); + statusBar()->insertItem( "", STATUS_ID_SIZE, 0, true ); + statusBar()->insertItem( "", STATUS_ID_MOUSE, 2, true ); + statusBar()->setSizeGripEnabled( true ); + statusBar()->show(); + + c = new MyCanvas( this ); + c->setDoubleBuffering( true ); + c->setUpdatePeriod( CANVAS_UPDATE_PERIOD ); + + cv = new MyCanvasView( d, c, this ); + cv->setPosLabel( statusBar(), STATUS_ID_MOUSE ); + setCentralWidget( cv ); + + setupActions(); + setupContextMenu(); + setAutoSaveSettings( QString("Window") + name, true ); + + clearLabel(); + + loadConfig(); + show(); + +// if( isFirstStart() ) +// moveDockWindow( tools, Qt::DockLeft ); + + connect( cv, SIGNAL( doubleClickedItem(TCanvasItem*) ), this, SLOT( doubleClickedItem(TCanvasItem*) ) ); + connect( cv, SIGNAL( showContextMenu(QPoint) ), this, SLOT( showContextMenu(QPoint) ) ); + connect( cv, SIGNAL( movedSomething() ), this, SLOT( setEdited() ) ); + connect( KBarcodeSettings::getInstance(), SIGNAL( updateGrid( int ) ), cv, SLOT( updateGUI() ) ); + connect( kapp, SIGNAL( aboutToQuit() ), this, SLOT( saveConfig() ) ); + + connect( history, SIGNAL( commandExecuted() ), cv, SLOT( updateGUI() ) ); + connect( history, SIGNAL( commandExecuted() ), this, SLOT( setEdited() ) ); + + if( !_filename.isEmpty() ) + openUrl( _filename ); +} + +LabelEditor::~LabelEditor() +{ + delete m_token; + delete d; + delete history; +} + +void LabelEditor::loadConfig() +{ + KConfig* config = kapp->config(); + recentAct->loadEntries( config, "RecentFiles" ); + + gridAct->setChecked( config->readBoolEntry("gridenabled", false ) ); + toggleGrid(); +} + +void LabelEditor::saveConfig() +{ + KConfig* config = kapp->config(); + + recentAct->saveEntries( config, "RecentFiles" ); + + config->setGroup("LabelEditor"); + config->writeEntry("gridenabled", gridAct->isChecked() ); + + config->sync(); + + DSMainWindow::saveConfig(); +} + +void LabelEditor::createCommandHistory() +{ + KConfig* config = kapp->config(); + + if( undoAct && redoAct ) + { + undoAct->unplug( editMenu ); + undoAct->unplug( toolBar() ); + redoAct->unplug( editMenu ); + redoAct->unplug( toolBar() ); + actionCollection()->remove( undoAct ); + actionCollection()->remove( redoAct ); + } + + history = new KCommandHistory( actionCollection(), false ); + cv->setHistory( history ); + + config->setGroup("LabelEditor"); + history->setUndoLimit( KBARCODE_UNDO_LIMIT ); + history->setRedoLimit( KBARCODE_UNDO_LIMIT ); +} + +void LabelEditor::createCommandHistoryActions() +{ + undoAct = (KAction*)actionCollection()->action("edit_undo"); + redoAct = (KAction*)actionCollection()->action("edit_redo"); + + undoAct->plug( editMenu, 0 ); + redoAct->plug( editMenu, 1 ); + + undoAct->plug( toolBar(), 5 ); + redoAct->plug( toolBar(), 6 ); +} + +void LabelEditor::clearLabel() +{ + TCanvasItem* citem; + QCanvasItemList::Iterator it; + + description = QString::null; + + delete history; + createCommandHistory(); + createCommandHistoryActions(); + + connect( history, SIGNAL( commandExecuted() ), cv, SLOT( updateGUI() ) ); + connect( history, SIGNAL( commandExecuted() ), this, SLOT( setEdited() ) ); + + m_edited = false; + + QCanvasItemList list = c->allItems(); + it = list.begin(); + for (; it != list.end(); ++it) + { + citem = static_cast<TCanvasItem*>(*it); + citem->remRef(); + } + + updateInfo(); + c->update(); + cv->repaintContents(); +} + +bool LabelEditor::save() +{ + bool ret; + if( filename.isEmpty() ) + ret = saveas(); + else + ret = save( filename ); + + KURL url; + url.setPath( filename ); + recentAct->addURL( url ); + + updateInfo(); + + return ret; +} + +bool LabelEditor::saveas() +{ + QString name = KFileDialog::getSaveFileName ( NULL, "*.kbarcode", this ); + if(name.isEmpty()) + return false; + + if( name.right(9).lower() != ".kbarcode" ) + name += ".kbarcode"; + + return save( name ); +} + +bool LabelEditor::save( QString name ) +{ + if( QFile::exists( name ) ) + QFile::remove( name ); + + QFile f( name ); + if ( !f.open( IO_WriteOnly ) ) + return false; + + save( &f ); + + m_token->setLabelName( filename.right( filename.length() - filename.findRev( "/" ) - 1 ) ); + // maybe we should redraw all items on the canvas now. + // if there is a label with [filename], the filename might not + // get updated if the label gets saved with another filename. + + filename = name; + history->documentSaved(); + m_edited = false; + + enableActions(); + setCaption( filename, false ); + + return true; +} + +void LabelEditor::save( QIODevice* device ) +{ + + QDomDocument doc( "KBarcodeLabel" ); + QDomElement root = doc.createElement( "kbarcode" ); + doc.appendChild( root ); + + writeXMLHeader( &root, description, d ); + + QCanvasItemList list = c->allItems(); + for( unsigned int i = 0; i < list.count(); i++ ) + { + TCanvasItem* item = static_cast<TCanvasItem*>(list[i]); + DocumentItem* ditem = item->item(); + + writeXMLDocumentItem( &root, &ditem ); + } + + QCString xml = doc.toCString(); + device->writeBlock( xml, xml.length() ); + device->close(); +} + +bool LabelEditor::open() +{ + QString name = KFileDialog::getOpenFileName ( NULL, "*.kbarcode", this, i18n("Select Label") ); + if(name.isEmpty()) return false; + + return openUrl( name ); +} + +bool LabelEditor::openUrl( const QString & url ) +{ + if( url.isEmpty() ) { + return open(); + } + + filename = url; + setCaption( filename, false ); + m_token->setLabelName( filename.right( filename.length() - filename.findRev( "/" ) - 1 ) ); + + QFile f( filename ); + if ( !f.open( IO_ReadOnly ) ) + return false; + + clearLabel(); + + QDomDocument doc( "KBarcodeLabel" ); + if ( !doc.setContent( &f ) ) { + f.close(); + return false; + } + f.close(); + + bool kbarcode18 = false; + delete d; + d = NULL; + + readXMLHeader( &doc, description, kbarcode18, &d ); + + if( !d || d->getId() == -1 ) + { + KMessageBox::error( this, QString( i18n("<qt>The file <b>%1</b> cannot be loaded as the label definition is missing.</qt>") ).arg( filename ) ); + return false; + } + + cv->setDefinition( d ); + + DocumentItemList list; + readDocumentItems( &list, &doc, m_token, kbarcode18 ); + for( unsigned int i=0;i<list.count();i++ ) + { + TCanvasItem* citem = new TCanvasItem( cv ); + citem->setItem( list.at( i ) ); + citem->addRef(); + } + list.clear(); + + KURL murl; + murl.setPath( filename ); + recentAct->addURL( murl ); + + enableActions(); + cv->repaintContents( true ); + + return true; +} + +bool LabelEditor::newLabel() +{ + NewLabel* nl = new NewLabel( this ); + if( nl->exec() != QDialog::Accepted ) { + delete nl; + return false; + } + + closeLabel(); + + if( !nl->empty() ) + { + d->setId( nl->labelId() ); + clearLabel(); + cv->setDefinition( d ); + } + + delete nl; + + filename = QString::null; + m_token->setLabelName( filename.right( filename.length() - filename.findRev( "/" ) - 1 ) ); + setCaption( filename, false ); + enableActions(); + + return true; +} + +void LabelEditor::setupActions() +{ + KAction* newAct = KStdAction::openNew( this, SLOT(startEditor()), actionCollection() ); + KAction* loadAct = KStdAction::open( this, SLOT(startLoadEditor()), actionCollection() ); + KAction* quitAct = KStdAction::quit(kapp, SLOT(quit()), actionCollection()); + KAction* closeAct = KStdAction::close( this, SLOT( close() ), actionCollection(), "close" ); + closeLabelAct = new KAction( i18n("Close &Label" ), 0, 0, this, SLOT( closeLabel() ), actionCollection() ); + + recentAct = new KRecentFilesAction( i18n("&Recent Files"), 0, this, SLOT( loadRecentEditor( const KURL& ) ) ); + + KAction* importPrintFileAct = new KAction( i18n("&Import and Print Batch File..."), BarIconSet( "fileprint" ), 0, this, SLOT( batchPrint() ), actionCollection() ); + + saveAct = KStdAction::save( this, SLOT( save() ), actionCollection(), "save" ); + saveAsAct = KStdAction::saveAs( this, SLOT( saveas() ), actionCollection(), "saveas" ); + descriptionAct = new KAction( i18n("&Change description..."), 0, 0, this, SLOT(changeDes()), actionCollection() ); + deleteAct = new KAction( i18n("&Delete Object"), QIconSet( BarIcon("editdelete") ), Key_Delete, cv, SLOT( deleteCurrent() ), actionCollection() ); + editPropAct = new KAction( i18n("&Properties..."), 0, 0, this, SLOT( doubleClickedCurrent() ), actionCollection() ); + printAct = KStdAction::print( this, SLOT( print() ), actionCollection(), "print" ); + bcpAct = new KAction( i18n("Print to &Barcode Printer..."), 0, 0, this, SLOT( printBCP() ), actionCollection() ); + imgAct = new KAction( i18n("Print to &Image..."), 0, 0, this, SLOT(printImage() ), actionCollection() ); + changeSizeAct = new KAction( i18n("&Change Label..."), 0, 0, this, SLOT( changeSize() ), actionCollection() ); + barcodeAct = new KAction( i18n("Insert &Barcode"), QIconSet( BarIcon("barcode") ), 0, this, SLOT( insertBarcode() ), actionCollection() ); + barcodeAct->setEnabled( Barkode::haveBarcode() ); + + pictureAct = new KAction( i18n("Insert &Picture"), QIconSet( BarIcon("inline_image") ), 0, this, SLOT( insertPicture() ), actionCollection() ); + textAct = new KAction( i18n("Insert &Text"), QIconSet( BarIcon("text") ), 0, this, SLOT( insertText() ), actionCollection() ); + textDataAct = new KAction( i18n("Insert &Data Field"), QIconSet( BarIcon("contents") ), 0, this, SLOT( insertDataText() ), actionCollection() ); + textLineAct = new KAction( i18n("Insert &Text Line"), QIconSet( BarIcon("text") ), 0, this, SLOT( insertTextLine() ), actionCollection() ); + lineAct = new KAction( i18n("Insert &Line"), QIconSet( BarIcon("kbarcodelinetool") ), 0, this, SLOT( insertLine() ), actionCollection() ); + rectAct = new KAction( i18n("Insert &Rectangle"), QIconSet( BarIcon("kbarcoderect") ), 0, this, SLOT( insertRect() ), actionCollection() ); + circleAct = new KAction( i18n("Insert &Ellipse"), QIconSet( BarIcon("kbarcodeellipse") ), 0, this, SLOT( insertCircle() ), actionCollection() ); + spellAct = KStdAction::spelling( this, SLOT(spellCheck()), actionCollection(), "spell" ); + gridAct = new KToggleAction( i18n("&Grid"), QIconSet( BarIcon("kbarcodegrid") ), 0, this, SLOT( toggleGrid() ), actionCollection() ); + previewAct = new KAction( i18n("&Preview..."), 0, 0, this, SLOT( preview() ), actionCollection() ); + sep = new KActionSeparator( this ); + cutAct = KStdAction::cut( this, SLOT( cut() ), actionCollection(), "cut" ); + copyAct = KStdAction::copy( this, SLOT( copy() ), actionCollection(), "copy" ); + pasteAct = KStdAction::paste( this, SLOT( paste() ), actionCollection(), "paste" ); + selectAllAct = KStdAction::selectAll( cv, SLOT( selectAll() ), actionCollection(), "select_all" ); + deSelectAllAct = KStdAction::deselect( cv, SLOT( deSelectAll() ), actionCollection(), "de_select_all" ); + addressBookAct = new KAction( i18n("Address&book"), QIconSet( BarIcon("kaddressbook") ), 0, this, SLOT( launchAddressBook() ), actionCollection() ); + KAction* singleBarcodeAct = new KAction(i18n("&Create Single Barcode..."), "", + 0, this, SLOT(startBarcodeGen()), + actionCollection(), "create" ); + singleBarcodeAct->setEnabled( Barkode::haveBarcode() ); + + newAct->plug( toolBar() ); + loadAct->plug( toolBar() ); + saveAct->plug( toolBar() ); + printAct->plug( toolBar() ); + sep->plug( toolBar() ); + cutAct->plug( toolBar() ); + copyAct->plug( toolBar() ); + pasteAct->plug( toolBar() ); + + tools = new KToolBar( this, this->leftDock(), true, "tools" ); + + barcodeAct->plug( tools ); + pictureAct->plug( tools ); + textAct->plug( tools ); + textDataAct->plug( tools ); + textLineAct->plug( tools ); + lineAct->plug( tools ); + rectAct->plug( tools ); + circleAct->plug( tools ); + (new KActionSeparator( this ))->plug( tools ); +// spellAct->plug( tools ); // KDE 3.2 + gridAct->plug( tools ); + + DSMainWindow::setupActions(); + connect( recentAct, SIGNAL( urlSelected( const KURL& ) ), this, SLOT( startLoadRecentEditor( const KURL& ) ) ); + + KPopupMenu* fileMenu = new KPopupMenu( this ); + editMenu = new KPopupMenu( this ); + KPopupMenu* viewMenu = new KPopupMenu( this ); + KPopupMenu* insMenu = new KPopupMenu( this ); + KPopupMenu* toolMenu = new KPopupMenu( this ); + KPopupMenu* barMenu = new KPopupMenu( this ); + + menuBar()->removeItemAt( 0 ); + menuBar()->insertItem( i18n("&File"), fileMenu, -1, 0 ); + menuBar()->insertItem( i18n("&Edit"), editMenu, -1, 1 ); + menuBar()->insertItem( i18n("&Insert"), insMenu, -1, 2 ); + menuBar()->insertItem( i18n("&View"), viewMenu, -1, 3 ); + menuBar()->insertItem( i18n("T&ools"), toolMenu, -1, 4 ); + menuBar()->insertItem( i18n("&Barcode"), barMenu, -1, 5 ); + + // Menubar + newAct->plug( fileMenu ); + loadAct->plug( fileMenu ); + recentAct->plug( fileMenu ); + saveAct->plug( fileMenu ); + saveAsAct->plug( fileMenu ); + sep->plug( fileMenu ); + printAct->plug( fileMenu ); + bcpAct->plug( fileMenu ); + imgAct->plug( fileMenu ); + sep->plug( fileMenu ); + closeLabelAct->plug( fileMenu ); + closeAct->plug( fileMenu ); + quitAct->plug( fileMenu ); + + sep->plug( editMenu ); + cutAct->plug( editMenu ); + copyAct->plug( editMenu ); + pasteAct->plug( editMenu ); + sep->plug( editMenu ); + selectAllAct->plug( editMenu ); + deSelectAllAct->plug( editMenu ); + sep->plug( editMenu ); + descriptionAct->plug( editMenu ); + changeSizeAct->plug( editMenu ); + sep->plug( editMenu ); + deleteAct->plug( editMenu ); + editPropAct->plug( editMenu ); + + barcodeAct->plug( insMenu ); + pictureAct->plug( insMenu ); + textAct->plug( insMenu ); + textDataAct->plug( insMenu ); + textLineAct->plug( insMenu ); + lineAct->plug( insMenu ); + rectAct->plug( insMenu ); + circleAct->plug( insMenu ); + +// spellAct->plug( toolMenu ); // KDE 3.2 + toolMenu->insertSeparator(); + addressBookAct->plug( toolMenu ); + + gridAct->plug( viewMenu ); + previewAct->plug( viewMenu ); + + singleBarcodeAct->plug( barMenu ); + importPrintFileAct->plug( barMenu ); + + enableActions(); +} + +void LabelEditor::setupContextMenu() +{ + m_mnuContext = new KPopupMenu( this ); + m_mnuContext->setCheckable( true ); + + KPopupMenu* orderMenu = new KPopupMenu( m_mnuContext ); + orderMenu->insertItem( i18n("&On Top"), this, SLOT( onTopCurrent() ) ); + orderMenu->insertItem( i18n("&Raise"), this, SLOT( raiseCurrent() ) ); + orderMenu->insertItem( i18n("&Lower"), this, SLOT( lowerCurrent() ) ); + orderMenu->insertItem( i18n("&To Background"), this, SLOT( backCurrent() ) ); + + KPopupMenu* centerMenu = new KPopupMenu( m_mnuContext ); + centerMenu->insertItem( i18n("Center &Horizontally"), this, SLOT( centerHorizontal() ) ); + centerMenu->insertItem( i18n("Center &Vertically"), this, SLOT( centerVertical() ) ); + + m_mnuContext->insertItem( i18n("&Order"), orderMenu ); + m_mnuContext->insertItem( i18n("&Center"), centerMenu ); + m_mnuContext->insertSeparator(); + m_mnuContext->insertItem( SmallIcon("editdelete"), i18n("&Delete"), cv, SLOT( deleteCurrent() ) ); + m_mnuContext->insertItem( i18n("&Protect Position and Size"), this, SLOT( lockItem() ), 0, ID_LOCK_ITEM ); + m_mnuContext->insertSeparator(); + m_mnuContext->insertItem( i18n("&Properties"), this, SLOT( doubleClickedCurrent() ) ); +} + +void LabelEditor::insertBarcode() +{ + NewBarcodeCommand* bc = new NewBarcodeCommand( cv, m_token ); + bc->execute(); + + BarcodeItem* bcode = static_cast<BarcodeItem*>((static_cast<TCanvasItem*>(bc->createdItem()))->item()); + if( !bcode ) + return; + + history->addCommand( bc, false ); +} + +void LabelEditor::insertPicture() +{ + NewPictureCommand* pc = new NewPictureCommand( cv ); + history->addCommand( pc, true ); + + TCanvasItem* item = pc->createdItem(); + doubleClickedItem( item ); +} + +void LabelEditor::insertText() +{ + insertText( "<nobr>Some Text</nobr>" ); +} + +void LabelEditor::insertDataText() +{ +// DocumentItemList list = cv->getAllItems(); +// QStringList vars = m_token->listUserVars( &list ); + + TokenDialog dlg( m_token, this, "dlg" ); + if( dlg.exec() == QDialog::Accepted ) + insertText( dlg.token() ); +} + +void LabelEditor::insertText( QString caption ) +{ + NewTextCommand* tc = new NewTextCommand( caption, cv, m_token ); + history->addCommand( tc, true ); +} + +//NY30 +void LabelEditor::insertTextLine() +{ + insertTextLine( "Some Plain Text" ); +} + +void LabelEditor::insertTextLine( QString caption ) +{ + NewTextLineCommand* tc = new NewTextLineCommand( caption, cv, m_token ); + history->addCommand( tc, true ); +} +//NY30 + +void LabelEditor::insertRect() +{ + NewRectCommand* rc = new NewRectCommand( cv ); + history->addCommand( rc, true ); +} + +void LabelEditor::insertCircle() +{ + NewRectCommand* rc = new NewRectCommand( cv, true ); + history->addCommand( rc, true ); +} + +void LabelEditor::insertLine() +{ + NewLineCommand* lc = new NewLineCommand( cv ); + history->addCommand( lc, true ); +} + +void LabelEditor::changeDes() +{ + QString tmp = QInputDialog::getText( i18n("Label Description"), + i18n("Please enter a description:"), QLineEdit::Normal, description ); + if( !tmp.isEmpty() ) + description = tmp; +} + +void LabelEditor::changeSize() +{ + NewLabel* nl = new NewLabel( this, "nl", true, true ); + nl->setLabelId( d->getId() ); + if( nl->exec() == QDialog::Rejected ) + { + delete nl; + return; + } + + d->setId( nl->labelId() ); + cv->setDefinition( d ); + + updateInfo(); + enableActions(); + // TODO: make sure that all items are redrawn. + // Otherwise barcodes might become invisible when changing the label + c->update(); + cv->repaint(); + delete nl; +} + +void LabelEditor::updateInfo() +{ + statusBar()->changeItem( i18n("Size: ") + QString("%1%2 x %3%4").arg( + d->getMeasurements().width() ).arg( Measurements::system() + ).arg( d->getMeasurements().height() ).arg( Measurements::system() ), STATUS_ID_SIZE ); + statusBar()->changeItem( i18n("Label Template: ") + d->getProducer() + " - " + d->getType(), STATUS_ID_TEMPLATE ); +} + +void LabelEditor::doubleClickedItem( TCanvasItem* item ) +{ + m_token->setCurrentDocumentItems( cv->getAllItems() ); + DocumentItemDlg dlg( m_token, item->item(), history, this ); + if( dlg.exec() == QDialog::Accepted ) + { + c->update(); + cv->repaintContents(); + } +} + +void LabelEditor::doubleClickedCurrent() +{ + if( cv->getActive() ) + doubleClickedItem( cv->getActive() ); +} + +void LabelEditor::showContextMenu( QPoint pos ) +{ + TCanvasItemList list = cv->getSelected(); + + m_mnuContext->setItemChecked( ID_LOCK_ITEM, (list[0])->item()->locked() ); + m_mnuContext->popup( pos ); +} + +void LabelEditor::lockItem() +{ + TCanvasItemList list = cv->getSelected(); + KMacroCommand* mc = new KMacroCommand( i18n("Protected Item") ); + + DocumentItem* item = NULL; + LockCommand* lc = NULL; + for( unsigned int i=0;i<list.count();i++) + { + item = list[i]->item(); + lc = new LockCommand( !item->locked(), list[i] ); + lc->execute(); + mc->addCommand( lc ); + } + + history->addCommand( mc ); +} + +void LabelEditor::print() +{ + PrintLabelDlg pld( this, "pld" ); + if( pld.exec() != QDialog::Accepted ) + return; + + PrinterSettings::getInstance()->getData()->border = pld.border(); + + KPrinter* printer = PrinterSettings::getInstance()->setupPrinter( KURL( filename ), this ); + if( !printer ) + return; + + BatchPrinter batch( printer, this ); + batch.setMove( pld.position() ); + + batchPrint( &batch, pld.labels(), BatchPrinter::POSTSCRIPT ); + + delete printer; +} + +void LabelEditor::printBCP() +{ + BarcodePrinterDlg dlg(this); + if( dlg.exec() == QDialog::Accepted ) + { + QString name( dlg.printToFile() ? dlg.fileName() : dlg.deviceName() ); + + BatchPrinter batch( name, dlg.outputFormat(), this ); + batchPrint( &batch, 1, BatchPrinter::BCP ); + } +} + +void LabelEditor::printImage() +{ + KFileDialog fd( ":save_image", KImageIO::pattern( KImageIO::Writing ), this, "fd", true ); + fd.setMode( KFile::File ); + fd.setOperationMode( KFileDialog::Saving ); + if( fd.exec() == QDialog::Accepted ) { + QString path = fd.selectedURL().path(); + BatchPrinter batch( path, this ); + batchPrint( &batch, 1, BatchPrinter::IMAGE ); + } +} + +void LabelEditor::batchPrint( BatchPrinter* batch, int copies, int mode ) +{ + QBuffer buffer; + if( !buffer.open( IO_WriteOnly ) ) + return; + + save( &buffer ); + + batch->setBuffer( &buffer ); + batch->setSerial( QString::null, 1 ); + batch->setName( filename ); + batch->setDefinition( d ); + batch->setCustomer( QString::null ); + batch->setEvents( false ); + + QValueList<BatchPrinter::data>* list = new QValueList<BatchPrinter::data>; + BatchPrinter::data m_data; + m_data.number = copies; + m_data.article_no = QString::null; + m_data.group = QString::null; + list->append( m_data ); + + batch->setData( list ); + switch( mode ) + { + default: + case BatchPrinter::POSTSCRIPT: + batch->start(); + break; + case BatchPrinter::IMAGE: + batch->startImages(); + break; + case BatchPrinter::BCP: + batch->startBCP(); + break; + } +} + +void LabelEditor::spellCheck() +{ + KMacroCommand* sc = new KMacroCommand( i18n("Spellchecking") ); + QCanvasItemList list = c->allItems(); + for( unsigned int i = 0; i < list.count(); i++ ) + if( list[i]->rtti() == eRtti_Text ) { + TCanvasItem* item = (TCanvasItem*)list[i]; + TextItem* mytext = (TextItem*)item->item(); + QString text = mytext->text(); + bool nocheck = false; +// for( int z = 0; z < comboText->count(); z++ ) +// if( text == "[" + comboText->text(z) + "]" ) { +// nocheck = true; +// break; +// } + + if( !nocheck ) { + QString textbefore = text; + KSpell::modalCheck( text ); + if( text != textbefore ) { + TextChangeCommand* tc = new TextChangeCommand( mytext, text ); + tc->execute(); + sc->addCommand( tc ); + } + } + } + + history->addCommand( sc, false ); +} + +void LabelEditor::centerHorizontal() +{ + if( !cv->getActive() ) + return; + + TCanvasItem* item = cv->getActive(); + + MoveCommand* mv = new MoveCommand( int( ((d->getMeasurements().widthMM() * 1000.0 - item->item()->rectMM().width())/2 )) - item->item()->rectMM().x(), 0, item ); + history->addCommand( mv, true ); +} + +void LabelEditor::centerVertical() +{ + if( !cv->getActive() ) + return; + + TCanvasItem* item = cv->getActive(); + + MoveCommand* mv = new MoveCommand( 0, int( ((d->getMeasurements().heightMM() * 1000.0 - item->item()->rectMM().height())/2 ) - item->item()->rectMM().y() ), item ); + history->addCommand( mv, true ); +} + +void LabelEditor::raiseCurrent() +{ + if( !cv->getActive() ) + return; + + ChangeZCommand* czc = new ChangeZCommand( (int)cv->getActive()->z() + 1, cv->getActive() ); + history->addCommand( czc, true ); +} + +void LabelEditor::lowerCurrent() +{ + if( !cv->getActive() ) + return; + + ChangeZCommand* czc = new ChangeZCommand( (int)cv->getActive()->z() - 1, cv->getActive() ); + history->addCommand( czc, true ); +} + +void LabelEditor::onTopCurrent() +{ + if( !cv->getActive() ) + return; + + int z = 0; + + QCanvasItemList list = c->allItems(); + for( unsigned int i = 0; i < list.count(); i++ ) + if( list[i]->z() > z ) + z = (int)list[i]->z(); + + + ChangeZCommand* czc = new ChangeZCommand( z + 1, cv->getActive() ); + history->addCommand( czc, true ); +} + +void LabelEditor::backCurrent() +{ + if( !cv->getActive() ) + return; + + int z = 0; + + QCanvasItemList list = c->allItems(); + for( unsigned int i = 0; i < list.count(); i++ ) + if( list[i]->z() < z ) + z = (int)list[i]->z(); + + ChangeZCommand* czc = new ChangeZCommand( z - 1, cv->getActive() ); + history->addCommand( czc, true ); +} + +const QString LabelEditor::fileName() const +{ + return filename.right( filename.length() - filename.findRev( "/" ) - 1 ); +} + +void LabelEditor::preview() +{ + QBuffer buffer; + if( !buffer.open( IO_WriteOnly ) ) + return; + + save( &buffer ); + + // No need to delete pd as it has WDestructiveClose set! + PreviewDialog* pd = new PreviewDialog( &buffer, d, fileName(), this ); + pd->exec(); +} + +void LabelEditor::toggleGrid() +{ + c->setGrid( gridAct->isChecked() ); + cv->repaintContents(); +} + +void LabelEditor::cut() +{ + copy(); + cv->deleteCurrent(); +} + +void LabelEditor::copy() +{ + TCanvasItemList list = cv->getSelected(); + if( list.isEmpty() ) + return; + + DocumentItemList items; + for( unsigned int i=0;i<list.count();i++) + items.append( (list[i])->item() ); + + DocumentItemDrag* drag = new DocumentItemDrag(); + drag->setDocumentItem( &items ); +#if QT_VERSION >= 0x030100 + kapp->clipboard()->setData( drag, QClipboard::Clipboard ); +#else + kapp->clipboard()->setData( drag ); +#endif +} + +void LabelEditor::paste() +{ + QMimeSource* data = QApplication::clipboard()->data(); + if ( DocumentItemDrag::canDecode( data ) ) + DocumentItemDrag::decode( data, cv, m_token, history ); +} + +void LabelEditor::startEditor() +{ + if( isChanged() ) { + LabelEditor* lb = new LabelEditor( NULL, QString::null, "LabelEditorWindow" ); + lb->startupDlg( eCreateNewLabel, QString::null ); + } else + newLabel(); +} + +void LabelEditor::startBarcodeGen() +{ + new BarCodeDialog(); +} + +void LabelEditor::startLoadRecentEditor( const KURL& url ) +{ + if( !QFile::exists( url.path() ) ) { + KMessageBox::information( this, i18n("The file %1 does not exist.").arg( url.path() ) ); + recentAct->removeURL( url ); + return; + } + + if( isChanged() ) + new LabelEditor( 0, url.path(), "LabelEditorWindow" ); + else + openUrl( url.path() ); +} + +void LabelEditor::startLoadEditor() +{ + if( isChanged() ) { + LabelEditor* lb = new LabelEditor( 0, QString::null, "LabelEditorWindow" ); + lb->startupDlg( eLoadLabel, QString::null ); + } else + open(); +} + +void LabelEditor::batchPrint() +{ + new BatchWizard( NULL ); +} + +void LabelEditor::closeEvent( QCloseEvent* e ) +{ + if( !isChanged() ) { + saveConfig(); + e->accept(); + delete this; + return; + } + + int m = KMessageBox::warningYesNoCancel( this, + i18n("<qt>The document has been modified.<br><br>Do you want to save it ?</qt>") ); + + if( m == KMessageBox::Cancel ) + e->ignore(); + else if( m == KMessageBox::No ) { + saveConfig(); + e->accept(); + delete this; + } else if( m == KMessageBox::Yes ) { + if( save() ) { + saveConfig(); + e->accept(); + delete this; + } + } +} + +bool LabelEditor::isChanged() +{ + if( !c->width() && !c->height() ) + return false; + + if( m_edited ) + return true; + + return false; +} + +bool LabelEditor::startupDlg( ELabelEditorMode mode, QString f ) +{ + if( mode == eCreateNewLabel && KBarcodeSettings::getInstance()->newDialog() ) + { + if(!newLabel()) { + close(); + return false; + } + } + else if( mode == eLoadLabel ) + { + if(!openUrl(f)) { + close(); + return false; + } + } + + return true; +} + +void LabelEditor::closeLabel() +{ + delete d; + d = new Definition(); + + m_edited = false; + + clearLabel(); + enableActions(); + + cv->setDefinition( d ); + + filename = QString::null; + setCaption( filename, false ); +} + +void LabelEditor::setEdited() +{ + setCaption( filename, true ); + m_edited = true; +} + +void LabelEditor::enableActions() +{ + editPropAct->setEnabled( cv->getActive() ); + deleteAct->setEnabled( cv->getActive() ); + + if( d->getId() == -1 ){ + // label closed + deleteAct->setEnabled( false ); + barcodeAct->setEnabled( false ); + pictureAct->setEnabled( false ); + textAct->setEnabled( false ); + textDataAct->setEnabled( false ); + textLineAct->setEnabled( false ); + rectAct->setEnabled( false ); + circleAct->setEnabled( false ); + lineAct->setEnabled( false ); + spellAct->setEnabled( false ); + gridAct->setEnabled( false ); + + saveAct->setEnabled( false ); + saveAsAct->setEnabled( false ); + printAct->setEnabled( false ); + bcpAct->setEnabled( false ); + imgAct->setEnabled( false ); + + previewAct->setEnabled( false ); + closeLabelAct->setEnabled( false ); + descriptionAct->setEnabled( false ); + + cutAct->setEnabled( false ); + copyAct->setEnabled( false ); + pasteAct->setEnabled( false ); + + selectAllAct->setEnabled( false ); + deSelectAllAct->setEnabled( false ); + } else { + deleteAct->setEnabled( true ); + barcodeAct->setEnabled( Barkode::haveBarcode() ); + pictureAct->setEnabled( true ); + textAct->setEnabled( true ); + textDataAct->setEnabled( true ); + textLineAct->setEnabled( true ); + rectAct->setEnabled( true ); + circleAct->setEnabled( true ); + lineAct->setEnabled( true ); + spellAct->setEnabled( true ); + gridAct->setEnabled( true ); + + saveAct->setEnabled( true ); + saveAsAct->setEnabled( true ); + printAct->setEnabled( true ); + bcpAct->setEnabled( true ); + imgAct->setEnabled( true ); + descriptionAct->setEnabled( true ); + + previewAct->setEnabled( true ); + closeLabelAct->setEnabled( true ); + + cutAct->setEnabled( true ); + copyAct->setEnabled( true ); + pasteAct->setEnabled( true ); + + selectAllAct->setEnabled( true ); + deSelectAllAct->setEnabled( true ); + } +} + +void LabelEditor::launchAddressBook() +{ + KRun::runCommand( "kaddressbook" ); +} + +#include "labeleditor.moc" diff --git a/kbarcode/labeleditor.h b/kbarcode/labeleditor.h new file mode 100644 index 0000000..9bd9b30 --- /dev/null +++ b/kbarcode/labeleditor.h @@ -0,0 +1,251 @@ +/*************************************************************************** + labeleditor.h - description + ------------------- + begin : Die Apr 23 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef LABELEDITOR_H +#define LABELEDITOR_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "sqltables.h" +#include "labelutils.h" +#include "definition.h" +#include "dsmainwindow.h" +#include "xmlutils.h" +#include "editoriface.h" + +#include <kdialogbase.h> +#include <qdialog.h> +#include <qmap.h> + +class BatchPrinter; +class KURL; +class KAction; +class KActionMenu; +class KActionSeparator; +class KToggleAction; +class KRecentFilesAction; +class KToolBarPopupAction; +class KListBox; +class KMenuBar; +class KPopupMenu; +class KRuler; +class KToolBar; +class KCommandHistory; +class MyCanvasText; +class MyCanvasRectangle; +class MyCanvasView; +class BarcodeItem; +class MyCanvas; +class QCanvasItemList; +class QCheckBox; +class KComboBox; +class QDockArea; +class QDockWindow; +class QGroupBox; +class QLabel; +class QImage; +class QHBoxLayout; +class QVBoxLayout; +class QPoint; +class QRect; +class QPaintDevice; +class QString; +class KPushButton; +class KPrinter; +class QCanvasItem; +class TCanvasItem; +class RectItem; +class LineItem; + +class TokenProvider; +/** The LabelEditor is a graphical, easy to use label designer. + * It provides all the function necessary to create colorful labels + * and save them. Labels can also be printed directly, but without database + * support. Use Batchprinting (LabelPrinter) for this. + */ +class LabelEditor : public DSMainWindow, public EditorIface, private LabelUtils, private XMLUtils { + Q_OBJECT + public: + enum ELabelEditorMode { + eCreateNewLabel, + eLoadLabel + }; + + LabelEditor( QWidget *parent=0, QString _filename = QString::null, + const char *name="labeleditor", WFlags f = WType_TopLevel | WDestructiveClose ); + ~LabelEditor(); + bool startupDlg( ELabelEditorMode mode, QString f = QString::null ); + + /** + * returns the filename of the currently loaded label. + */ + const QString fileName() const; + + public slots: + void print(); + void printBCP(); + void printImage(); + + private: + + /** Creates a KCommandHistory object which will be + * pointed to by history. + * Make sure to delete history by yourself when needed. + */ + void createCommandHistory(); + /** Create undo and redo actions and plug them into + * menus and toolbars. They have to be regenerated + * when ever createCommandHistory was called. + */ + void createCommandHistoryActions(); + + QString getCustomerName( int mode = 0, QString text = "" ); + void clearLabel(); + //void setupBarcode( BarcodeItem* bcode ); + void insertText( QString caption ); + //NY35 + void insertTextLine( QString caption ); + //NY35 + void setupActions(); + void enableActions(); + bool isChanged(); // if the current document has been changed + void batchPrint( BatchPrinter* batch, int copies, int mode ); + void setupContextMenu(); + + private slots: + void startEditor(); + bool open(); + bool openUrl( const QString & url ); + bool save(); + bool saveas(); + bool save( QString url ); + void save( QIODevice* device ); + bool newLabel(); + void insertBarcode(); + void insertPicture(); + void insertText(); + void insertDataText(); + //NY36 + void insertTextLine(); + //NY36 + void insertRect(); + void insertCircle(); + void insertLine(); + + void changeDes(); + void changeSize(); + void updateInfo(); + void doubleClickedItem( TCanvasItem* item ); + void showContextMenu( QPoint pos ); + void doubleClickedCurrent(); + void spellCheck(); + void centerVertical(); + void centerHorizontal(); + void raiseCurrent(); + void lowerCurrent(); + void onTopCurrent(); + void backCurrent(); + void preview(); + void toggleGrid(); + void cut(); + void copy(); + void paste(); + void startBarcodeGen(); + void saveConfig(); + void loadConfig(); + void startLoadRecentEditor( const KURL& url ); + void startLoadEditor(); + void batchPrint(); + void closeLabel(); + void setEdited(); + void launchAddressBook(); + void lockItem(); + + protected: + void closeEvent( QCloseEvent* e ); + + KCommandHistory* history; + + KAction* saveAct; + KAction* saveAsAct; + KAction* exportAct; + KAction* descriptionAct; + KAction* printAct; + KAction* bcpAct; + KAction* imgAct; + KAction* changeSizeAct; + KAction* deleteAct; + KAction* editPropAct; + KAction* barcodeAct; + KAction* rectAct; + KAction* circleAct; + KAction* lineAct; + KAction* pictureAct; + KAction* previewAct; + KAction* textAct; + KAction* textDataAct; + KAction* textLineAct; + KAction* spellAct; + KAction* cutAct; + KAction* copyAct; + KAction* pasteAct; + KAction* undoAct; + KAction* redoAct; + KAction* closeLabelAct; + KAction* addressBookAct; + KAction* selectAllAct; + KAction* deSelectAllAct; + + /** + * Undo/Redo actins get pluged into this menu + */ + KPopupMenu* editMenu; + KPopupMenu* exportMenu; + KPopupMenu* m_mnuContext; + + KToolBar* tools; + + KToggleAction* gridAct; + + KComboBox* comboScale; + + KRecentFilesAction* recentAct; + KActionSeparator* sep; + KToolBarPopupAction* listAct; + MyCanvas* c; + MyCanvasView* cv; + + Definition* d; + TokenProvider* m_token; + + // Label info's: + QString description; // description + QString filename; // current file + + KListBox* listFields; + KPushButton* buttonText; + + QVBoxLayout* pageLayout; + + QMap<QString,QString> fields; + + bool m_edited; +}; + +#endif diff --git a/kbarcode/labelutils.cpp b/kbarcode/labelutils.cpp new file mode 100644 index 0000000..7325f3e --- /dev/null +++ b/kbarcode/labelutils.cpp @@ -0,0 +1,188 @@ +/*************************************************************************** + labelutils.cpp - description + ------------------- + begin : Sam Okt 26 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "labelutils.h" +#include "dsrichtext.h" + +// Qt includes +#include <qbitmap.h> +#include <qimage.h> +#include <qpaintdevicemetrics.h> +#include <qpainter.h> +#include <qsimplerichtext.h> + +// KDE includes +#include <kapplication.h> +#include <kglobal.h> +#include <klocale.h> + +// own includes +#include "printersettings.h" + +#define CONVERSION_FACTOR 25.4000508001016 + +LabelUtils::LabelUtils() +{ +} + +LabelUtils::~LabelUtils() +{ } + +double LabelUtils::pixelToMm( double pixel, const QPaintDevice* device, int mode ) +{ + QPaintDeviceMetrics pdm( device ? device : KApplication::desktop() ); + if( mode == DpiX ) + return (pixel * CONVERSION_FACTOR) / (double)pdm.logicalDpiX(); + else + return (pixel * CONVERSION_FACTOR) / (double)pdm.logicalDpiY(); +} + +double LabelUtils::mmToPixel( double mm, const QPaintDevice* device, int mode ) +{ + if( !mm ) + return 0; + + // We don't get valid metrics from the printer - and we want a better resolution + // anyway (it's the PS driver that takes care of the printer resolution). + + QPaintDeviceMetrics pdm( device ? device : KApplication::desktop() ); + +// qDebug("DpiX=%i", pdm.logicalDpiX()); +// qDebug("DpiY=%i", pdm.logicalDpiY()); + if( mode == DpiX ) + return (mm / CONVERSION_FACTOR) * (double)pdm.logicalDpiX(); + else + return (mm / CONVERSION_FACTOR) * (double)pdm.logicalDpiY(); +} + +double LabelUtils::pixelToPixelX( double unit, const QPaintDevice* src, const QPaintDevice* dest ) +{ + QPaintDeviceMetrics p1( src ); + QPaintDeviceMetrics p2( dest ); + + return ( unit * (double)p2.logicalDpiX() ) / (double)p1.logicalDpiX(); +} + +double LabelUtils::pixelToPixelY( double unit, const QPaintDevice* src, const QPaintDevice* dest ) +{ + QPaintDeviceMetrics p1( src ); + QPaintDeviceMetrics p2( dest ); + + //return pixelToPixelX( unit, src, dest ); + return ( unit * (double)p2.logicalDpiY() ) / (double)p1.logicalDpiY(); +} + +const QString LabelUtils::getTypeFromCaption( const QString & cap ) +{ + // TODO: remove this function + QString search = cap.right( cap.length() - cap.find(":") - 1 ).lower().stripWhiteSpace(); + return search; +} + +const QString LabelUtils::getModeFromCaption( const QString & cap ) +{ + return cap.left( cap.find(":") ).lower().stripWhiteSpace(); +} + +QSize LabelUtils::stringSize( const QString & t ) +{ + QSimpleRichText srt( t, KApplication::font() ); + QSize s; + s.setWidth( srt.widthUsed() ); + s.setHeight( srt.height() ); + + return s; +} + +void LabelUtils::renderString( QPainter* painter, const QString & t, const QRect & rect, double scalex, double scaley ) +{ + // DSRichText cannot calculate the width on its own + QSimpleRichText srt( t, KApplication::font() ); + int width = (rect.width() > 0) ? rect.width() : srt.widthUsed(); + int height = (rect.height() > 0) ? rect.height() : srt.height(); + + DSRichText r( t ); + r.setX( rect.x() ); + r.setY( rect.y() ); + r.setWidth( width ); + r.setHeight( height ); + r.setScale( scalex, scaley ); + r.draw( painter ); +} + +QPixmap* LabelUtils::drawString( const QString & t, int w, int h, double rot ) +{ + QSimpleRichText srt( t, KApplication::font() ); + + int width = (w > 0) ? w : srt.widthUsed(); + int height = (h > 0) ? h : srt.height(); + srt.setWidth( width ); + + QPixmap* pix; + QPainter painter; + if( rot == 0.0 ) { + QBitmap bm( width, height ); + bm.fill( Qt::color0 ); //transparent + painter.begin( &bm ); + + painter.save(); + painter.setPen( Qt::color1 ); + QColorGroup cg; + cg.setColor( QColorGroup::Foreground, Qt::color1 ); + cg.setColor( QColorGroup::Text, Qt::color1 ); + cg.setColor( QColorGroup::Base, Qt::color0 ); + + srt.draw( &painter, 0, 0, bm.rect(), cg ); + painter.restore(); + painter.end(); + + pix = new QPixmap( width, height ); + pix->fill( Qt::white ); + pix->setMask( bm ); + + if( !pix->isNull() ) { + painter.begin( pix ); + painter.setPen( Qt::black ); + QColorGroup cg; + srt.draw( &painter, 0, 0, pix->rect(), cg ); + painter.end(); + } + } else { + int w2 = (w > 0) ? w : srt.widthUsed(); + int h2 = (h > 0) ? h : srt.height(); + + QWMatrix wm; + wm.rotate( rot ); + + QSize s = LabelUtils::stringSize( t ); + QPixmap* tmp = LabelUtils::drawString( t, s.width(), s.height() ); + + QPixmap* p = new QPixmap( w2, h2 ); + p->fill( Qt::white ); + painter.begin( p ); + painter.drawPixmap( 0, 0, tmp->xForm( wm ) ); + painter.end(); + + p->setMask( p->createHeuristicMask() ); + + pix = p; + delete tmp; + } + + return pix; +} + diff --git a/kbarcode/labelutils.h b/kbarcode/labelutils.h new file mode 100644 index 0000000..724000d --- /dev/null +++ b/kbarcode/labelutils.h @@ -0,0 +1,61 @@ +/*************************************************************************** + labelutils.h - description + ------------------- + begin : Sam Okt 26 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef LABELUTILS_H +#define LABELUTILS_H + +class Definition; +class KPrinter; +class QDomElement; +class QFont; +class QImage; +class QPainter; +class QPixmap; +class QPaintDevice; +class QPoint; +class QRect; +class QSize; +class QString; +class QStringList; +class QSqlQuery; +class LabelUtils { + public: + LabelUtils(); + ~LabelUtils(); + + enum _dpixy { + DpiX, + DpiY + }; + + double pixelToMm( double pixel, const QPaintDevice* device, int mode = DpiX ); + double mmToPixel( double mm, const QPaintDevice* device, int mode = DpiX ); + + double pixelToPixelX( double unit, const QPaintDevice* src, const QPaintDevice* dest ); + double pixelToPixelY( double unit, const QPaintDevice* src, const QPaintDevice* dest ); + static QSize stringSize( const QString & t ); + static QPixmap* drawString( const QString & t, int w, int h, double rot = 0 ); + static QPixmap* drawString( const QString & t ) { + return LabelUtils::drawString( t, 0, 0, 0 ); + } + static void renderString( QPainter* painter, const QString & t, const QRect & r, double scalex, double scaley ); + + const QString getTypeFromCaption( const QString & cap ); + const QString getModeFromCaption( const QString & cap ); +}; + +#endif diff --git a/kbarcode/lineitem.cpp b/kbarcode/lineitem.cpp new file mode 100644 index 0000000..5e7ae65 --- /dev/null +++ b/kbarcode/lineitem.cpp @@ -0,0 +1,67 @@ +/*************************************************************************** + lineitem.cpp - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#include <qstring.h> + +#include "documentitem.h" +#include "lineitem.h" + +#include <qpainter.h> + +LineItem::LineItem() + : DocumentItem() +{ + init(); +} + +void LineItem::init() +{ + setRect( QRect( 0, 0, 20, 20 ) ); +} + +void LineItem::draw(QPainter* painter) +{ + painter->save(); + painter->setPen( pen() ); + painter->drawLine( rect().x(), rect().y(), rect().x() + rect().width(), rect().y() + rect().height() ); + painter->restore(); +} + +void LineItem::drawZpl( QTextStream* ) +{ + qDebug("LineItem not implemented for ZPL"); +} + +void LineItem::drawEPcl( QTextStream* ) +{ + qDebug("LineItem not implemented for EPCL"); +} + +void LineItem::drawIpl( QTextStream*, IPLUtils* ) +{ + qDebug("LineItem not implemented for IPL"); +} + +void LineItem::loadXML(QDomElement* element) +{ + DocumentItem::loadXML(element); +} + +void LineItem::saveXML(QDomElement* element) +{ + DocumentItem::saveXML(element); +} diff --git a/kbarcode/lineitem.h b/kbarcode/lineitem.h new file mode 100644 index 0000000..0843a42 --- /dev/null +++ b/kbarcode/lineitem.h @@ -0,0 +1,44 @@ +/*************************************************************************** + lineitem.h - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#ifndef LINEITEM_H +#define LINEITEM_H +#include <qstring.h> +#include "documentitem.h" +#include "qcolor.h" + +/** + * Class LineItem + * Implements a line on screen or printer + */ +class LineItem : public DocumentItem { +public: + LineItem (); + + virtual int rtti() const { return eRtti_Line; } + virtual void draw(QPainter* painter); + virtual void drawZpl( QTextStream* stream ); + virtual void drawIpl( QTextStream* stream, IPLUtils* utils ); + virtual void drawEPcl( QTextStream* stream ); + virtual void loadXML(QDomElement* element); + virtual void saveXML(QDomElement* element); + +private: + void init(); +}; +#endif //LINEITEM_H + diff --git a/kbarcode/logo.png b/kbarcode/logo.png Binary files differnew file mode 100644 index 0000000..d50eefb --- /dev/null +++ b/kbarcode/logo.png diff --git a/kbarcode/main.cpp b/kbarcode/main.cpp new file mode 100644 index 0000000..081cf08 --- /dev/null +++ b/kbarcode/main.cpp @@ -0,0 +1,121 @@ +/*************************************************************************** + main.cpp - description + ------------------- + begin : Don Apr 18 12:34:56 CEST 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kaboutdata.h> +#include <kimageio.h> +#include <klocale.h> +#include <kstandarddirs.h> + +#include "kbarcode.h" +#include "labeleditor.h" +#include "barcodedialog.h" + +#ifndef VERSION + #define VERSION "Unknown Version" +#endif + +static KCmdLineOptions options[] = +{ + { "+[file]", I18N_NOOP("Load the file in KBarcode (if --batch is specified, the file will be used in batchprinting mode)"), 0}, + { "print", I18N_NOOP("Print any loaded files immediately on the default printer " + "or on the printer specified by the --printer commandline option and exit afterwards"), 0 }, + { "printer <printer>", I18N_NOOP("Printer/destination to print on"), 0}, + { ":", I18N_NOOP("KBarcode Modes:"), 0 }, + { "barcode", I18N_NOOP("Start KBarcode as xbarcode replacement"), 0 }, + { "label", I18N_NOOP("Open the label editor"), 0 }, + { "batch", I18N_NOOP("Start directly in batchprinting mode"), 0 }, + { ":", I18N_NOOP("Additional options for batchprinting (--batch):"), 0 }, + { "output <mode>", I18N_NOOP("Output format where mode is one of POSTSCRIPT|IMAGE|BARCODE"), "POSTSCRIPT" }, + { "serialnumber <value>", I18N_NOOP("Set the serial number to be used"), 0 }, + { "serialinc <value>", I18N_NOOP("Increase a previously specified serial number using this value for each printed label"), 0 }, + { "numlabels <value>", I18N_NOOP("Print <value> labels without any data"), 0 }, + { "importsql <query>", I18N_NOOP("Import variable data from a specified sql query"), 0 }, + { "importcsv <csvfile>", I18N_NOOP("Import variable data from a specified csv file"), 0 }, + KCmdLineLastOption +}; + +void setupDirs() +{ + if( locate("data", "kbarcode/logo.png").isEmpty() ) { + // Maybe KBarcode was not installed into $KDEDIR + KStandardDirs* dirs = KGlobal::dirs(); + QString kdedir = dirs->kfsstnd_prefixes(); + + if( !kdedir.contains( "/usr/local/" ) ) + dirs->addPrefix( "/usr/local/" ); + + if( !kdedir.contains( "/usr/local/kde/" ) ) + dirs->addPrefix( "/usr/local/kde/" ); + + if( !kdedir.contains( "/usr/" ) ) + dirs->addPrefix( "/usr/" ); + + qDebug("WARNING: Prefix changed: %s", dirs->kfsstnd_prefixes().latin1() ); + } +} + +int main(int argc, char *argv[]) +{ + KAboutData aboutData( "kbarcode", I18N_NOOP("KBarcode"), VERSION, I18N_NOOP( + "KBarcode is a barcode and label printing application for KDE 3." + ), KAboutData::License_GPL, "KBarcode Build:\n" __DATE__ " " __TIME__ + , "(c) 2001-2006, Dominik Seichter\n\n", + "http://www.kbarcode.net", "kbarcode-users@lists.sourceforge.net" ); + + aboutData.addAuthor("Dominik Seichter", I18N_NOOP("Programmer"), "domseichter@web.de"); + aboutData.addAuthor("Stefan \"Stonki\" Onken", + I18N_NOOP("Project Manager"), + "support@stonki.de", "http://www.stonki.de" ); + + aboutData.addCredit("Alessandro Rubini", I18N_NOOP("Wrote GNU Barcode on which kbarcode is based."), + "rubini@prosa.it", "http://arcana.linux.it/" ); + aboutData.addCredit("Terry Burton", I18N_NOOP("Author of Barcode Writer in Pure Postscript"), + "tez@terryburton.co.uk", "http://www.terryburton.co.uk/" ); + aboutData.addCredit("Daniele Medri", I18N_NOOP("Italian translation"), "madrid@linuxmeeting.net" ); + aboutData.addCredit("Anton Vaaranmaa", + I18N_NOOP("Finnish and Swedish translation, created the KBarcode icon"), "antonv@postikaista.net" ); + aboutData.addCredit("Miguel Revilla Rodr�uez", I18N_NOOP("Spanish translation"), "yo@miguelrevilla.com" ); + aboutData.addCredit("Sandor Jager", I18N_NOOP("Hungarian translation"), "jager@puskas.hu" ); + aboutData.addCredit("Daniel Etzold", + I18N_NOOP("Tab icon code stolen from his excellent app qtella."), "detzold@qtella.net" ); + aboutData.addCredit("Richard J. Moore", I18N_NOOP("Wrote the RichText KPart"), "rich@kde.org", "http://xmelegance.org/" ); + aboutData.addCredit("Yann Bouan", I18N_NOOP("French Translation"), "yann@bouan.net" ); + aboutData.addCredit("Erich Kitzmüller", I18N_NOOP("Help with ZPL and IPL code"), "kitzmueller@metasyst.at" ); + aboutData.addCredit("Dag Nygren", I18N_NOOP("Wrote many patches to improve KBarcode"), "dag@newtech.fi" ); + aboutData.addCredit("Frank Schoolmeesters", I18N_NOOP("Made the Netherlands translation"), "frank_schoolmeesters@fastmail.fm" ); + aboutData.addCredit("John Volpe", I18N_NOOP("Added lot's of useful data fields to kbarcode"), "jtvolpe@cape.com" ); + aboutData.addCredit("Nyssa s.r.l.", I18N_NOOP("Added TEC barcode printer support"), "imorrison@nyssa.com.ar", "http://www.nyssa.com.ar" ); + aboutData.addCredit("Brian Glass", I18N_NOOP("Added EPCL barcode printer support"), "brian@glassbrian.com", "http://www.glassbrian.com" ); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); + + KApplication a; + // setup standard dirs + setupDirs(); + + KImageIO::registerFormats(); + a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); + + KBarcode* kbc = new KBarcode( 0, "KBarcodeMainWindow" ); + + if( kbc->parseCmdLine() ) + return 0; + else + return a.exec(); +} diff --git a/kbarcode/measurements.cpp b/kbarcode/measurements.cpp new file mode 100644 index 0000000..07044ec --- /dev/null +++ b/kbarcode/measurements.cpp @@ -0,0 +1,164 @@ +/*************************************************************************** + measurements.cpp - description + ------------------- + begin : Mit Dec 24 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "measurements.h" + +// Qt includes +#include <qpaintdevicemetrics.h> + +// KDE includes +#include <kglobal.h> + +Measurements::Measurements() +{ + Measurements::init(); + + defaultMeasurements(); +} + +Measurements::Measurements( const Measurements & rhs ) +{ + Measurements::init(); + + this->operator=( rhs ); +} + + +Measurements::~Measurements() {} + +int Measurements::m_system = None; +QString Measurements::m_string = QString::null; + +void Measurements::init() +{ + if( m_system == None ) { + m_system = KGlobal::locale()->measureSystem(); + m_string = (m_system == Metric) ? + KGlobal::staticQString( i18n("mm" ) ) : + KGlobal::staticQString( i18n("in" ) ); + } +} + +void Measurements::defaultMeasurements() { + // init everything in case of + // database connection fails. + gap_h = 40.0; + gap_left = 0.0; + gap_top = 0.0; + gap_v = 40.0; + m_height = 40.0; + num_h = 1; + num_v = 1; + m_width = 40.0; +} + +void Measurements::operator=( const Measurements & m ) { + num_h = m.num_h; + num_v = m.num_v; + gap_left = m.gap_left; + gap_top = m.gap_top; + gap_v = m.gap_v; + gap_h = m.gap_h; + m_width = m.m_width; + m_height = m.m_height; +} + +double Measurements::mmToPixel( double mm, const QPaintDevice* device, int mode ) const { + QPaintDeviceMetrics pdm( device ); + if( mode == DpiX ) + return (mm / 25.4) * pdm.logicalDpiX(); + else + return (mm / 25.4 ) * pdm.logicalDpiY(); +} + +double Measurements::gapLeft( const QPaintDevice* device ) const { + return mmToPixel( gap_left, device, DpiX ); +} + +double Measurements::gapTop( const QPaintDevice* device ) const { + return mmToPixel( gap_top, device, DpiY ); +} + +double Measurements::gapV( const QPaintDevice* device ) const { + return mmToPixel( gap_v, device, DpiX ); +} + +double Measurements::gapH( const QPaintDevice* device ) const { + return mmToPixel( gap_h, device, DpiY ); +} + +double Measurements::width( const QPaintDevice* device ) const { + return mmToPixel( m_width, device, DpiX ); +} + +double Measurements::height( const QPaintDevice* device ) const { + return mmToPixel( m_height, device, DpiY ); +} + +double Measurements::gapLeft() const { + return (gapLeftMM() / (m_system == Imperial ? 25.4 : 1 )); +} + +double Measurements::gapTop() const { + return (gapTopMM() / (m_system == Imperial ? 25.4 : 1 )); +} + +double Measurements::gapV() const { + return (gapVMM() / (m_system == Imperial ? 25.4 : 1 )); +} + +double Measurements::gapH() const { + return (gapHMM() / (m_system == Imperial ? 25.4 : 1 )); +} + +double Measurements::width() const { + return (widthMM() / (m_system == Imperial ? 25.4 : 1 )); +} + +double Measurements::height() const { + return (heightMM() / (m_system == Imperial ? 25.4 : 1 )); +} + +void Measurements::setGapLeft( double d ) +{ + gap_left = (d * (m_system == Imperial ? 25.4 : 1 )); +} + +void Measurements::setGapTop( double d ) +{ + gap_top = (d * (m_system == Imperial ? 25.4 : 1 )); +} + +void Measurements::setGapV( double d ) +{ + gap_v = (d * (m_system == Imperial ? 25.4 : 1 )); +} + +void Measurements::setGapH( double d ) +{ + gap_h = (d * (m_system == Imperial ? 25.4 : 1 )); +} + +void Measurements::setWidth( double d ) +{ + m_width = (d * (m_system == Imperial ? 25.4 : 1 )); +} + +void Measurements::setHeight( double d ) +{ + m_height = (d * (m_system == Imperial ? 25.4 : 1 )); +} diff --git a/kbarcode/measurements.h b/kbarcode/measurements.h new file mode 100644 index 0000000..a95e666 --- /dev/null +++ b/kbarcode/measurements.h @@ -0,0 +1,134 @@ +/*************************************************************************** + measurements.h - description + ------------------- + begin : Mit Dec 24 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef MEASUREMENTS_H +#define MEASUREMENTS_H + +#include <klocale.h> + +class QPaintDevice; + +/** + * This class keeps all measurements required to correctly draw a label. + * The measurements are available in pixels, milimeter and inch. + * This class allows also for transformations from inch to mm or pixels + * (and the other way round). Internally, everything is handled in mm. + * + * @author Dominik Seichter + */ +class Measurements { + public: + enum { + DpiX, + DpiY + }; + + enum { + Metric = KLocale::Metric, + Imperial = KLocale::Imperial, + None + }; + + Measurements(); + Measurements( const Measurements & rhs ); + ~Measurements(); + + int numH() const { return num_h; } + int numV() const { return num_v; } + + double gapLeftMM() const { return gap_left; } + double gapTopMM() const { return gap_top; } + double gapVMM() const { return gap_v; } + double gapHMM() const { return gap_h; } + double widthMM() const { return m_width; } + double heightMM() const { return m_height; } + + // return inch or milimeters according to the + // users preferrences + double gapLeft() const; + double gapTop() const; + double gapV() const; + double gapH() const; + double width() const; + double height() const; + + double gapLeft( const QPaintDevice* device ) const; + double gapTop( const QPaintDevice* device ) const; + double gapV( const QPaintDevice* device ) const; + double gapH( const QPaintDevice* device ) const; + double width( const QPaintDevice* device ) const; + double height( const QPaintDevice* device ) const; + + void setNumH( int n ) { num_h = n; } + void setNumV( int n ) { num_v = n; } + + // use milimeters for all of the setter methods + void setGapLeftMM( double d ) { gap_left = d; } + void setGapTopMM( double d ) { gap_top = d; } + void setGapVMM( double d ) { gap_v = d; } + void setGapHMM( double d ) { gap_h = d; } + void setWidthMM( double d ) { m_width = d; } + void setHeightMM( double d ) { m_height = d; } + + // inch or milimeters are taken as input + // according to the users preferrences + void setGapLeft( double d ); + void setGapTop( double d ); + void setGapV( double d ); + void setGapH( double d ); + void setWidth( double d ); + void setHeight( double d ); + + void operator=(const Measurements & rhs ); + + /** return the localized string that should be appended + * to a measurement number visible to the user. I.e. + * "mm" or "in". + */ + static const QString & system() { Measurements::init(); return m_string; } + + /** return the measurements system to be used. + */ + static int measurementSystem() { Measurements::init(); return m_system; } + + private: + /** initialize measurements with the correctly + * measurements system to be used from KDE. + */ + static void init(); + + void defaultMeasurements(); + + double mmToPixel( double mm, const QPaintDevice* device, int mode = DpiX ) const; + + /** Measurement system to use: + * milimeters or inch + */ + static int m_system; + static QString m_string; + + int num_h; + int num_v; + double gap_left; + double gap_top; + double gap_v; + double gap_h; + double m_width; + double m_height; +}; + +#endif diff --git a/kbarcode/mimesources.cpp b/kbarcode/mimesources.cpp new file mode 100644 index 0000000..c02ded7 --- /dev/null +++ b/kbarcode/mimesources.cpp @@ -0,0 +1,129 @@ +/*************************************************************************** + mimesources.cpp - description + ------------------- + begin : Son Sep 14 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "mimesources.h" +#include "mycanvasview.h" +#include "documentitem.h" +#include "commands.h" +#include "xmlutils.h" + +#include <kcommand.h> + +#include <qbuffer.h> +#include <qcstring.h> +#include <qdom.h> + +class DragCommand : public NewItemCommand { + public: + DragCommand( MyCanvasView* view, DocumentItem* doc_item ) + : NewItemCommand( view, i18n("Pasted Object") ) + { + m_doc_item = doc_item; + } + + void create() + { + m_object = m_doc_item; + } + + private: + DocumentItem* m_doc_item; +}; + + + +DocumentItemDrag::DocumentItemDrag( QWidget* dragSource, const char* name ) + : QStoredDrag( DocumentItemDrag::mimeType(), dragSource, name ) +{ +} + +QString DocumentItemDrag::mimeType() +{ + return "application/x-kbarcode-document-item"; +} + +void DocumentItemDrag::setDocumentItem( DocumentItemList* list ) +{ + QByteArray data; + QBuffer buffer( data ); + if( buffer.open( IO_WriteOnly ) ) + { + QDomDocument doc("KBarcodeClipboard"); + QDomElement root = doc.createElement( "root" ); + doc.appendChild( root ); + + XMLUtils xml; + for( unsigned int i=0;i<list->count();i++) + { + DocumentItem* item = list->at( i ); + xml.writeXMLDocumentItem( &root, &item ); + } + + QTextStream t( &buffer ); + doc.save( t, 0 ); + + buffer.close(); + setEncodedData( data ); + } +} + +bool DocumentItemDrag::canDecode( QMimeSource* e ) +{ + return e->provides( DocumentItemDrag::mimeType() ); +} + +bool DocumentItemDrag::decode( QMimeSource* mime, MyCanvasView* cv, TokenProvider* token, KCommandHistory* history ) +{ + QByteArray data = mime->encodedData( DocumentItemDrag::mimeType() ); + QDomDocument doc( "KBarcodeClipboard" ); + if( !doc.setContent( data ) ) + return false; + + QDomNode n = doc.documentElement(); + QDomNodeList list = n.childNodes(); + KMacroCommand* commands = new KMacroCommand( i18n("Paste") ); + + for( unsigned int i=0;i<list.length();i++) + { + QDomNode n = list.item(i); + + QDomElement e = n.toElement(); + if( !e.isNull() ) + { + XMLUtils xml; + DocumentItem* item = NULL; + if( xml.readXMLDocumentItem( &e, &item, token ) ) + { + DragCommand* dc = new DragCommand( cv, item ); + dc->execute(); + commands->addCommand( dc ); + } + else + { + delete commands; + return false; + } + } + } + + history->addCommand( commands, false ); + + return true; +} + + +#include "mimesources.moc" diff --git a/kbarcode/mimesources.h b/kbarcode/mimesources.h new file mode 100644 index 0000000..abaf5d7 --- /dev/null +++ b/kbarcode/mimesources.h @@ -0,0 +1,41 @@ +/*************************************************************************** + mimesources.h - description + ------------------- + begin : Son Sep 14 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef MIMESOURCES_H +#define MIMESOURCES_H + +#include <qdragobject.h> +#include "documentitem.h" + +class KCommandHistory; +class TokenProvider; +class MyCanvasView; + +class DocumentItemDrag : public QStoredDrag { + Q_OBJECT + public: + DocumentItemDrag( QWidget* dragSource = NULL, const char* name = 0 ); + + static QString mimeType(); + + void setDocumentItem( DocumentItemList* list ); + + static bool canDecode( QMimeSource * ); + static bool decode( QMimeSource *, MyCanvasView* cv, TokenProvider* token, KCommandHistory* history ); +}; + +#endif diff --git a/kbarcode/multilineeditdlg.cpp b/kbarcode/multilineeditdlg.cpp new file mode 100644 index 0000000..650f58e --- /dev/null +++ b/kbarcode/multilineeditdlg.cpp @@ -0,0 +1,312 @@ +/*************************************************************************** + multilineeditdlg.cpp - description + ------------------- + begin : Sam Jan 11 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "multilineeditdlg.h" +#include "tokendialog.h" + +// KDE includes +#include <kaction.h> +#include <kdeversion.h> +#include <kcolordialog.h> +#include <kfiledialog.h> +#include <klocale.h> +#include <kspell.h> +#include <dstextedit.h> +#include <ktoolbar.h> +#include <kcombobox.h> + +// Qt includes +#include <qdockarea.h> +#include <qregexp.h> + +MultiLineEditor::MultiLineEditor( TokenProvider* token, QWidget *parent, const char *name ) + : QWidget( parent, name ), m_token( token ) +{ + QVBoxLayout* layout = new QVBoxLayout( this, 6, 6 ); + +// ksc = new KSpellConfig( this ); + + editor = new DSTextEdit( this ); + editor->setTextFormat( Qt::RichText ); + //editor->setText( text, "" ); + editor->setFocus(); + + QDockArea* area = new QDockArea( Qt::Horizontal, QDockArea::Normal, this ); + toolBar = new KToolBar( area ); + tool2Bar = new KToolBar( area ); + tool3Bar = new KToolBar( area ); + + setupActions(); + + layout->addWidget( area ); + layout->addWidget( editor ); + +} + +MultiLineEditor::~MultiLineEditor() +{ +} + + +void MultiLineEditor::setupActions() +{ + ac = new KActionCollection( this ); + + KAction* action_export = new KAction( i18n("Export"), "fileexport", 0, this, SLOT( save() ), ac ); + + // + // Edit Actions + // + KAction *action_undo = KStdAction::undo( editor, SLOT( undo() ), ac ); + action_undo->setEnabled( false ); + connect( editor, SIGNAL( undoAvailable(bool) ), action_undo, SLOT( setEnabled(bool) ) ); + + + KAction *action_redo = KStdAction::redo( editor, SLOT( redo() ), ac ); + action_redo->setEnabled( false ); + connect( editor, SIGNAL( redoAvailable(bool) ), action_redo, SLOT( setEnabled(bool) ) ); + + KAction *action_cut = KStdAction::cut( editor, SLOT( cut() ), ac ); + action_cut->setEnabled( false ); + connect( editor, SIGNAL( copyAvailable(bool) ), action_cut, SLOT( setEnabled(bool) ) ); + + KAction *action_copy = KStdAction::copy( editor, SLOT( copy() ), ac ); + action_copy->setEnabled( false ); + connect( editor, SIGNAL( copyAvailable(bool) ), action_copy, SLOT( setEnabled(bool) ) ); + + KAction* action_paste = KStdAction::paste( editor, SLOT( paste() ), ac ); + + // + // Character Formatting + // + action_bold = new KToggleAction( i18n("&Bold"), "text_bold", CTRL+Key_B, ac, "format_bold" ); + connect( action_bold, SIGNAL( toggled(bool) ), editor, SLOT( setBold(bool) ) ); + + action_italic = new KToggleAction( i18n("&Italic"), "text_italic", CTRL+Key_I, ac, "format_italic" ); + connect( action_italic, SIGNAL( toggled(bool) ), editor, SLOT( setItalic(bool) ) ); + + action_underline = new KToggleAction( i18n("&Underline"), "text_under", CTRL+Key_U, ac, "format_underline" ); + connect( action_underline, SIGNAL( toggled(bool) ), editor, SLOT( setUnderline(bool) ) ); + + KAction* action_color = new KAction( i18n("Text &Color..."), "colorpicker", 0, this, SLOT( formatColor() ), ac, "format_color" ); + + // + // Font + // + action_font = new KFontAction( i18n("&Font"), 0, ac, "format_font" ); + connect( action_font, SIGNAL( activated( const QString & ) ), editor, SLOT( setFamily( const QString & ) ) ); + + action_font_size = new KFontSizeAction( i18n("Font &Size"), 0, ac, "format_font_size" ); + connect( action_font_size, SIGNAL( fontSizeChanged(int) ), editor, SLOT( setPointSize(int) ) ); + + // + // Alignment + // + action_align_left = new KToggleAction( i18n("Align &Left"), "text_left", 0, ac, "format_align_left" ); + connect( action_align_left, SIGNAL( toggled(bool) ), this, SLOT( setAlignLeft(bool) ) ); + + action_align_center = new KToggleAction( i18n("Align &Center"), "text_center", 0, ac, "format_align_center" ); + connect( action_align_center, SIGNAL( toggled(bool) ), this, SLOT( setAlignCenter(bool) ) ); + + action_align_right = new KToggleAction( i18n("Align &Right"), "text_right", 0, ac, "format_align_right" ); + connect( action_align_right, SIGNAL( toggled(bool) ), this, SLOT( setAlignRight(bool) ) ); + + action_align_justify = new KToggleAction( i18n("&Justify"), "text_block", 0, ac, "format_align_justify" ); + connect( action_align_justify, SIGNAL( toggled(bool) ), this, SLOT( setAlignJustify(bool) ) ); + + action_align_left->setExclusiveGroup( "alignment" ); + action_align_center->setExclusiveGroup( "alignment" ); + action_align_right->setExclusiveGroup( "alignment" ); + action_align_justify->setExclusiveGroup( "alignment" ); + + //KAction* action_spell = KStdAction::spelling( this, SLOT( checkSpelling() ), ac ); + + KAction* textDataAct = new KAction( i18n("Insert &Data Field"), "contents", 0, this, SLOT( insertNewField() ), ac, "text_data_act"); action_export->plug( toolBar ); + + toolBar->insertSeparator(); + action_undo->plug( toolBar ); + action_redo->plug( toolBar ); + toolBar->insertSeparator(); + action_cut->plug( toolBar ); + action_copy->plug( toolBar ); + action_paste->plug( toolBar ); + toolBar->insertSeparator(); + action_bold->plug( toolBar ); + action_italic->plug( toolBar ); + action_underline->plug( toolBar ); + toolBar->insertSeparator(); +//#if KDE_IS_VERSION( 3, 1, 90 ) +// action_spell->plug( toolBar ); +//#endif + + action_font->plug( tool2Bar ); + action_font_size->plug( tool2Bar ); + action_color->plug( tool2Bar ); + tool2Bar->insertSeparator(); + action_align_left->plug( tool2Bar ); + action_align_center->plug( tool2Bar ); + action_align_right->plug( tool2Bar ); + action_align_justify->plug( tool2Bar ); + + textDataAct->plug( tool3Bar ); + + // + // Setup enable/disable + // + updateActions(); + + connect( editor, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( updateFont() ) ); + connect( editor, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( updateCharFmt() ) ); + connect( editor, SIGNAL( cursorPositionChanged( int,int ) ), this, SLOT( updateAligment() ) ); +} + +QString MultiLineEditor::text() +{ + return editor->text(); +} + +void MultiLineEditor::setText( const QString & t ) +{ + editor->setText( t ); +} + +void MultiLineEditor::updateCharFmt() +{ + action_bold->setChecked( editor->bold() ); + action_italic->setChecked( editor->italic() ); + action_underline->setChecked( editor->underline() ); +} + +void MultiLineEditor::updateAligment() +{ + int align = editor->alignment(); + + switch ( align ) { + case AlignRight: + action_align_right->setChecked( true ); + break; + case AlignCenter: + action_align_center->setChecked( true ); + break; + case AlignLeft: + action_align_left->setChecked( true ); + break; + case AlignJustify: + action_align_justify->setChecked( true ); + break; + default: + break; + } +} + +void MultiLineEditor::updateFont() +{ + if ( editor->pointSize() > 0 ) + action_font_size->setFontSize( editor->pointSize() ); + action_font->setFont( editor->family() ); +} + +void MultiLineEditor::updateActions() +{ + updateCharFmt(); + updateAligment(); + updateFont(); +} + +void MultiLineEditor::formatColor() +{ + QColor col; + + int s = KColorDialog::getColor( col, editor->color(), editor ); + if ( s != QDialog::Accepted ) + return; + + editor->setColor( col ); +} + +void MultiLineEditor::setAlignLeft( bool yes ) +{ + if ( yes ) + editor->setAlignment( AlignLeft ); +} + +void MultiLineEditor::setAlignRight( bool yes ) +{ + if ( yes ) + editor->setAlignment( AlignRight ); +} + +void MultiLineEditor::setAlignCenter( bool yes ) +{ + if ( yes ) + editor->setAlignment( AlignCenter ); +} + +void MultiLineEditor::setAlignJustify( bool yes ) +{ + if ( yes ) + editor->setAlignment( AlignJustify ); +} + +void MultiLineEditor::insertNewField() +{ + TokenDialog dlg( m_token, this, "dlg" ); + if( dlg.exec() == QDialog::Accepted ) + editor->insert( dlg.token() ); +} + +void MultiLineEditor::checkSpelling() +{ +/* +#if KDE_IS_VERSION( 3, 1, 90 ) + QString s; + if ( editor->hasSelectedText() ) + s = editor->selectedText(); + else + s = editor->text(); + + spell = new KSpell( this, i18n("Spell Checking"), 0, 0, 0, true, true, KSpell::HTML ); + spell->setAutoDelete( true ); + spell->check( s, true ); + connect( spell, SIGNAL( done(const QString &) ), this, SLOT( spellCheckDone(const QString &) ) ); + + spell->cleanUp(); +#endif +*/ +} + +void MultiLineEditor::spellCheckDone(const QString & buffer) +{ + editor->setText( buffer ); + spell->cleanUp(); +} + +void MultiLineEditor::save() +{ + QString name = KFileDialog::getSaveFileName ( NULL, "*", this ); + if( name.isEmpty() ) + return; + + QFile file( name ); + if ( file.open( IO_WriteOnly ) ) { + QTextStream ts( &file ); + ts << editor->text(); + } +} + + +#include "multilineeditdlg.moc" diff --git a/kbarcode/multilineeditdlg.h b/kbarcode/multilineeditdlg.h new file mode 100644 index 0000000..8941950 --- /dev/null +++ b/kbarcode/multilineeditdlg.h @@ -0,0 +1,85 @@ +/*************************************************************************** + multilineeditdlg.h - description + ------------------- + begin : Sam Jan 11 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef MULTILINEEDITDLG_H +#define MULTILINEEDITDLG_H + +#include <qwidget.h> +#include "documentitem.h" + +class KActionCollection; +class KToggleAction; +class KFontAction; +class KFontSizeAction; +class KToolBar; +class KSpell; +class KSpellConfig; +class DSTextEdit; +class TokenProvider; + +class MultiLineEditor : public QWidget { + Q_OBJECT + public: + MultiLineEditor( TokenProvider* token, QWidget *parent=0, const char *name=0); + ~MultiLineEditor(); + QString text(); + void setText( const QString & t ); + + private slots: + void setupActions(); + void updateActions(); + void spellCheckDone(const QString & buffer); + + void save(); + void updateFont(); + void updateCharFmt(); + void updateAligment(); + void formatColor(); + void checkSpelling(); + void setAlignLeft( bool yes ); + void setAlignRight( bool yes ); + void setAlignCenter( bool yes ); + void setAlignJustify( bool yes ); + void insertNewField(); + + protected: + TokenProvider* m_token; + + DSTextEdit* editor; + + KActionCollection* ac; + + KToggleAction *action_bold; + KToggleAction *action_italic; + KToggleAction *action_underline; + + KFontAction *action_font; + KFontSizeAction *action_font_size; + + KToggleAction *action_align_left; + KToggleAction *action_align_right; + KToggleAction *action_align_center; + KToggleAction *action_align_justify; + + KToolBar* toolBar; + KToolBar* tool2Bar; + KToolBar* tool3Bar; + + KSpell* spell; +}; + +#endif diff --git a/kbarcode/mybarcode.cpp b/kbarcode/mybarcode.cpp new file mode 100644 index 0000000..64160df --- /dev/null +++ b/kbarcode/mybarcode.cpp @@ -0,0 +1,620 @@ +f/*************************************************************************** + barcode.cpp - description + ------------------- + begin : Die Apr 23 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "sqltables.h" +#include "barcodecache.h" + +#include "mybarcode.h" +#include <stdio.h> + +// Qt includes +#include <qdir.h> +#include <qpainter.h> +#include <qpaintdevicemetrics.h> +#include <qsqlquery.h> + +// KDE includes +#include <kapplication.h> +#include <kconfig.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kprocess.h> +#include <kstandarddirs.h> +#include <ktempfile.h> + +#define BARCODE_MARGIN 10 /* Margin added by GNU Barcode to the barcodes */ + +QValueList<barcodeFormat> codes; + +void init() { + BarCode::setHaveBarcode(); +} + +bool barcodeData::operator==( const struct barcodeData d ) const { + bool b = ( value == d.value && type == d.type && + scale == d.scale && text == d.text ); + + if( BarCode::hasFeature( type, TBARCODEADV ) ) + b = ( b && tbarcode == d.tbarcode ); + + if( BarCode::hasFeature( type, DATAMATRIX ) ) + b = ( b && datamatrix == d.datamatrix ); + + if( BarCode::hasFeature( type, PDF417BARCODE ) ) + b = ( b && pdf417 == d.pdf417 ); + + return b; +}; + +BarCode::BarCode( const barcodeData* data ) +{ + barcode = *data; + m_index = 0; +} + +BarCode::BarCode() +{ + fillDefault( &barcode ); + m_index = 0; +} + +BarCode::~BarCode() +{ +} + +const QPixmap BarCode::pixmap() +{ + if( p.isNull() ) + createBarcode( &p, KApplication::desktop() ); + + if( p.isNull() ) { + KMessageBox::error( 0, "<qt>" + i18n("Barcode not valid!") + "<br>" + barcode.value + "</qt>" ); + barcode.valid = false; + } + + return p; +} + +bool BarCode::createPixmap( QPixmap* target, int resx, int resy ) +{ + KTempFile* output = new KTempFile( QString::null, ".ps" );; + output->file()->close(); + + KTempFile* input = new KTempFile( QString::null, ".pbm" ); + input->file()->close(); + + m_value = createSequence( barcode.value ); + + if( BarCode::hasFeature( barcode.type, PDF417 ) ) { + if(!createPdf417( output )) { + cleanUp( output, input, target ); + return false; + } + } else if( BarCode::hasFeature( barcode.type, TBARCODE ) ) { + if(!createTBarcode( output )) { + cleanUp( output, input, target ); + return false; + } + } else { // if( BarCode::hasFeature( barcode.type, GNU_BARCODE ) ) { + QString flag = barcode.text ? "" : "-n"; + + KShellProcess proc; + proc << "barcode" << "-E" + << "-b" << KShellProcess::quote( m_value ) << flag + << "-e" << barcode.type << "-o" << output->name(); + + proc.start( KProcess::Block, KProcess::NoCommunication ); + proc.resume(); + + if( proc.exitStatus() ) { + cleanUp( output, input, target ); + return false; + } + } + + QFileInfo fi( output->name() ); + // if file size = 0, error in generation + if( !fi.size() ) { + cleanUp( output, input, target ); + return false; + } + + QSize s = getBoundingBox( output->name() ); + double sw = (double)s.width()/72 * resx; + double sh = (double)s.height()/72 * resy; + + KShellProcess proc2; + proc2 << "gs" << QString("-g%1x%2").arg(int(sw*(double)barcode.scale)).arg(int(sh*(double)barcode.scale)) + << "-r" + QString::number( resx*(double)barcode.scale ) + "x" + QString::number( resy*(double)barcode.scale ) + << "-sDEVICE=pbmraw" << "-sOutputFile=" + input->name() << "-sNOPAUSE" + << "-q " + output->name() << "-c showpage" << "-c quit"; + + proc2.start( KProcess::Block, KProcess::NoCommunication ); + proc2.resume(); + + if( proc2.exitStatus() ) { + cleanUp( output, input, target ); + return false; + } + + target->load( input->name(), "PBM" ); +// BarcodeCache::instance()->write( barcode, resx, resy, target, m_value ); + + input->unlink(); + output->unlink(); + + delete output; + delete input; + + return true; +} + +void BarCode::createBarcode( QPixmap* target, QPaintDevice* device ) +{ + QPaintDeviceMetrics pdm( device ); + int resx = pdm.logicalDpiX(); + int resy = pdm.logicalDpiY(); + + QString value = createSequence( barcode.value ); + QPixmap* cached = 0;//BarcodeCache::instance()->read( barcode, resx, resy, value ); + + // no matching barcode found in cache + if( !cached ) { + if( !createPixmap( target, resx, resy ) ) + return; + } else { + *target = *cached; + delete cached; + } + + if( BarCode::hasFeature( barcode.type, PDF417 ) ) { + // we have to scale to the correct resolution. + // we scale already here and not at the end, + // so that the addMargin function does not get a scaled margin. + QPaintDeviceMetrics pdm( KApplication::desktop() ); + int screenresx = pdm.logicalDpiX(); + int screenresy = pdm.logicalDpiY(); + + QWMatrix m; + double scalex = (resx/screenresx)*barcode.scale; + double scaley = (resy/screenresy)*barcode.scale; + m.scale( scalex, scaley ); + *target = target->xForm( m ); + } + *target = cut( target, barcode.cut ); + *target = addMargin( target, barcode.margin ); + + // Rotate + QWMatrix m; + m.rotate( (double)barcode.rotation ); + *target = target->xForm( m ); + + barcode.valid = true; +} + +bool BarCode::createPdf417( KTempFile* output ) +{ + KTempFile text( QString::null, ".txt" ); + QTextStream t( text.file() ); + t << m_value; + text.file()->close(); + + // ps does not work use pbm! + KShellProcess proc; + proc << "pdf417_enc" << "-tps" << text.name() << output->name() + << barcode.pdf417.row + << barcode.pdf417.col + << barcode.pdf417.err; + + proc.start( KProcess::Block, KProcess::NoCommunication ); + proc.resume(); + + if( proc.exitStatus() ) { + text.unlink(); + return false; + } + + text.unlink(); + return true; +} + +bool BarCode::createTBarcode( KTempFile* output ) +{ + // print text + QString flag = barcode.text ? "" : "n"; + // escape text + flag.append( barcode.tbarcode.escape ? " son" : " soff" ); + // autocorrection + flag.append( barcode.tbarcode.autocorrect ? " Aon" : " Aoff" ); + // text above + flag.append( barcode.tbarcode.above ? " a" : "" ); + + KShellProcess proc; + proc << "tbarcodeclient" << "-f" + output->name(); + if( !BarCode::hasFeature( barcode.type, BARCODE2D ) ) + proc << QString( "m%1" ).arg( barcode.tbarcode.modulewidth * 1000 ); + + if( BarCode::hasFeature( barcode.type, DATAMATRIX ) ) + proc << QString( "Ds%1" ).arg( barcode.datamatrix.size ); + + if( BarCode::hasFeature( barcode.type, PDF417BARCODE ) ) + proc << QString( "Pr%1 Pc%2 Pe%3" ).arg( barcode.pdf417.row ) + .arg( barcode.pdf417.col ) + .arg( barcode.pdf417.err ); + + proc << barcode.type << "tPS" << QString("c%1").arg( barcode.tbarcode.checksum ) << flag << "d" + KShellProcess::quote( m_value ); + proc.start( KProcess::Block, KProcess::NoCommunication ); + proc.resume(); + + if( proc.exitStatus() ) + return false; + + return true; +} + +const QPixmap BarCode::printerPixmap( QPaintDevice* device ) +{ + if( pp.isNull() ) + createBarcode( &pp, device ); + + return pp; +} + +void BarCode::fillDefault( barcodeData* data ) +{ + data->margin = 10; + data->text = true; + data->value = "1234567890"; + data->type = "code39"; + data->scale = 1.0; + data->cut = 1.0; + data->rotation = 0; + data->valid = false; + + data->pdf417.row = 24; + data->pdf417.col = 8; + data->pdf417.err = 5; + + data->datamatrix.size = 0; + + data->tbarcode.modulewidth = 0.353; + data->tbarcode.escape = false; + data->tbarcode.above = false; + data->tbarcode.autocorrect = false; + data->tbarcode.checksum = 0; + + data->xml.caption = "Static"; + data->xml.x = 0; + data->xml.y = 0; + + data->sequence.enabled = false; + data->sequence.mode = NUM; + data->sequence.step = 1; + data->sequence.start = 1; +} + +void BarCode::redrawBarcode() +{ + p.resize( 0, 0 ); + pp.resize( 0, 0 ); +} + +QPixmap BarCode::cut( QPixmap* pic, double cut) +{ + if( cut == 1.0 ) + return (*pic); + + QPixmap pcut( pic->width(), int((double)pic->height() * cut) ); + pcut.fill( Qt::white ); // barcode.bg + + QWMatrix m; + /* + * if text is above the barcode cut from + * below the barcode. + */ + + // TODO: put this into one if, I am to stupid today..... + if( BarCode::hasFeature( barcode.type, TBARCODEADV ) ) { + if( !barcode.tbarcode.above ) + m.rotate( 180 ); + } else + m.rotate( 180 ); + + QPainter painter( &pcut ); + painter.drawPixmap( 0, 0, pic->xForm( m ) ); + + return pcut.xForm( m ); +} + +QPixmap BarCode::addMargin( QPixmap* pic, int margin ) +{ + QPixmap p; + + /* We have to handle UPC special because of the checksum character + * which is printed on the right margin. + * The samve goes for ISBN codes. + * Any other formats?? + */ + + bool gnubarcode = BarCode::hasFeature( barcode.type, GNU_BARCODE ); + double barm = gnubarcode ? BARCODE_MARGIN * barcode.scale : 0; + + // Add margin + double sx = barm; + double sy = barm; + double sw = pic->width() - barm * 2; + double sh = pic->height() - barm * 2; + + if( gnubarcode && (barcode.type == "upc" || barcode.type == "isbn") ) { + sw = pic->width() - barm; + + p.resize( pic->width() + int(margin*2 - barm), pic->height() + int(margin * 2 - barm * 2) ); + } else + p.resize( pic->width() + int(margin*2 - barm * 2), pic->height() + int(margin * 2 - barm * 2) ); + + p.fill( Qt::white ); // barcode.bg + QPainter painter( &p ); + painter.drawPixmap( margin, margin, *pic, (int)sx, (int)sy, (int)sw, (int)sh ); + painter.end(); + + return p; +} + +const QString BarCode::getMaxLength( const QString & name ) +{ + QSqlQuery query("select uid, (length(barcode_no)) as LEN from " TABLE_BASIC + " where encoding_type = '" + name +"' ORDER by LEN DESC LIMIT 1" ); + + while( query.next() ) { + QSqlQuery queryuid("select barcode_no from barcode_basic where uid = '" + + query.value( 0 ).toString() + "'" ); + while( queryuid.next() ) + if(!queryuid.value( 0 ).toString().isEmpty()) + return queryuid.value( 0 ).toString(); + } + + QSqlQuery query1("select uid, (length(barcode_no)) as LEN from " TABLE_CUSTOMER_TEXT + " where encoding_type = '" + name +"' ORDER by LEN DESC LIMIT 1" ); + + while( query1.next() ) { + QSqlQuery queryuid("select barcode_no from customer_text where uid = '" + + query1.value( 0 ).toString() + "'" ); + while( queryuid.next() ) + if(!queryuid.value( 0 ).toString().isEmpty()) + return queryuid.value( 0 ).toString(); + } + + return "1234567"; +} + +void BarCode::cleanUp( KTempFile* file, KTempFile* file2, QPixmap* target ) +{ + target->resize( 0, 0 ); + + file->unlink(); + file2->unlink(); + delete file; + delete file2; +} + +QString BarCode::createSequence( const QString & value ) +{ + if( !barcode.sequence.enabled ) + return value; + + if( value.contains( '#' ) <= 0 ) + return value; + + QString text = value; + int pos = 0, counter = 1; + + pos = text.find("#", pos); + pos++; + while( text[pos] == '#' ) { + text.remove(pos, 1); + counter++; + } + + pos = text.find("#", 0); + QString temp; + + if( barcode.sequence.mode == NUM ) { + int v = barcode.sequence.start + m_index*barcode.sequence.step; + temp.sprintf("%0*i", counter, v ); + } else { + for( int i = 0; i < counter; i++ ) + temp.append( "A" ); + + unsigned int z = 0; + for( int p = temp.length(); p >= 0; p--, z++ ) { + if( barcode.sequence.mode == ALPHA ) { + int v = 'A' + m_index*barcode.sequence.step; + v -= z*('Z'-'A'); + + if( v <= 'Z' ) { + temp[p] = QChar(v); + break; + } else if( v > 'Z' ) + v = 'Z'; + temp[p] = QChar(v); + } else if( barcode.sequence.mode == ALPHANUM ) { + qDebug("NOT IMPLEMENTED"); +/* char array[36]; + for( unsigned int i = 'A'; i <= 'Z'; i++ ) + array[i-'A'] = i; + for( unsigned int i = '0'; i <= '9'; i++ ) + array['Z'-'A'+i-'0'] = i; + + int z = m_index*barcode.sequence.step; + if( z < sizeof(array) ) + temp[] + int v = array[ ]*/ + } + } + } + + text.replace( pos, 1, temp); + + return text; +} + +QString BarCode::sequenceValue() +{ + return createSequence( barcode.value ); +} + +bool BarCode::hasFeature( const QString & type, unsigned int feature ) +{ + for( unsigned int i = 0; i < codes.count(); i++ ) + if( codes[i].name == type ) + return (codes[i].features & feature) == feature; + + return false; +} + +QSize BarCode::getBoundingBox( const QString & filename ) +{ + QSize s(0,0); + QFile f( filename ); + if( !f.open( IO_ReadOnly ) ) + return s; + + QString t; + while( f.readLine( t, 1000 ) != -1 ) + { + if( t.startsWith( "%%BoundingBox:") ) + { + int x = 0; + int y = 0; + int w = 0; + int h = 0; + t = t.right( t.length() - 14 ); + sscanf( (const char*)t, "%d %d %d %d", &x, &y, &w, &h ); + s = QSize( w, h ); + break; + } + } + + f.close(); + return s; +} + +bool BarCode::m_haveGnuBarcode = false; +bool BarCode::m_havePdfEncode = false; +bool BarCode::m_haveTBarcode = false; + +barcodeFormat BarCode::fillStruct( const QString & name, const QString & text, const int feature ) +{ + barcodeFormat t; + t.name = name; + t.text = text; + t.features = feature; + return t; +} + +void BarCode::setHaveBarcode() +{ + m_haveGnuBarcode = !KStandardDirs::findExe( "barcode" ).isNull(); + m_havePdfEncode = !KStandardDirs::findExe( "pdf417_enc" ).isNull(); + m_haveTBarcode = !KStandardDirs::findExe( "tbarcodeclient" ).isNull(); + + if( codes.count() == 0 ) { + if( m_haveGnuBarcode ) { + codes.append( fillStruct( "ean", i18n("EAN (EAN 8 or EAN 13)"), GNU_BARCODE ) ); + codes.append( fillStruct( "upc", i18n("UPC (12-digit EAN; UPCA and UPCB)"), GNU_BARCODE ) ); + codes.append( fillStruct( "isbn", i18n("ISBN (still EAN13)"), GNU_BARCODE | NOCUT ) ); + codes.append( fillStruct( "code39", i18n("Code 39"), GNU_BARCODE ) ); + codes.append( fillStruct( "code39 -c", i18n("Code 39 (no checksum)"), GNU_BARCODE ) ); + codes.append( fillStruct( "code128", i18n("Code 128 (a,b,c: autoselection)"), GNU_BARCODE ) ); + codes.append( fillStruct( "code128c", i18n("Code 128C (compact form digits)"), GNU_BARCODE ) ); + codes.append( fillStruct( "code128b", i18n("Code 128B, full printable ascii"), GNU_BARCODE ) ); + codes.append( fillStruct( "i25", i18n("interleaved 2 of 5 (only digits)"), GNU_BARCODE ) ); + codes.append( fillStruct( "i25 -c", i18n("interleaved 2 of 5 (only digits, no checksum)"), GNU_BARCODE ) ); + codes.append( fillStruct( "128raw", i18n("Raw code 128"), GNU_BARCODE ) ); + codes.append( fillStruct( "cbr", i18n("Codabar"), GNU_BARCODE ) ); + codes.append( fillStruct( "cbr -c", i18n("Codabar (no checksum)"), GNU_BARCODE ) ); + codes.append( fillStruct( "msi", i18n("MSI"), GNU_BARCODE ) ); + codes.append( fillStruct( "pls", i18n("Plessey"), GNU_BARCODE ) ); + codes.append( fillStruct( "code93", i18n("Code 93"), GNU_BARCODE ) ); + } + + if( m_havePdfEncode ) { + codes.append( fillStruct( "pdf417", i18n("pdf 417 2D Barcode"), BARCODE2D | PDF417 | PDF417BARCODE ) ); + } + + if( m_haveTBarcode ) { + codes.append( fillStruct( "b1", "Code 11", TBARCODE | TBARCODEADV | MODULO10CHECK ) ); + codes.append( fillStruct( "b2", "Code 2 of 5 (Standard)", TBARCODE | TBARCODEADV | MODULO10CHECK ) ); + codes.append( fillStruct( "b3", "Interleaved 2 of 5 Standard", TBARCODE | TBARCODEADV ) ); + codes.append( fillStruct( "b4", "Code 2 of 5 IATA", TBARCODE | TBARCODEADV | MODULO10CHECK ) ); + codes.append( fillStruct( "b5", "Code 2 of 5 Matrix", TBARCODE | TBARCODEADV | MODULO10CHECK ) ); + codes.append( fillStruct( "b6", "Code 2 of 5 Data Logic", TBARCODE | TBARCODEADV | MODULO10CHECK ) ); + codes.append( fillStruct( "b7", "Code 2 of 5 Industrial", TBARCODE | TBARCODEADV | MODULO10CHECK ) ); + codes.append( fillStruct( "b8", "Code 3 of 9 (Code 39)", TBARCODE | TBARCODEADV | MODULOALLCHECK ) ); + codes.append( fillStruct( "b9", "Code 3 of 9 (Code 39) ASCII", TBARCODE | TBARCODEADV | MODULOALLCHECK ) ); + codes.append( fillStruct( "b10", "EAN8", TBARCODE | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) ); + codes.append( fillStruct( "b11", "EAN8 - 2 digits add on", TBARCODE | NOCUT | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) ); + codes.append( fillStruct( "b12", "EAN8 - 5 digits add on", TBARCODE | NOCUT | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) ); + codes.append( fillStruct( "b13", "EAN13", TBARCODE | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) ); + codes.append( fillStruct( "b14", "EAN13 - 2 digits add on", TBARCODE | NOCUT | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) ); + codes.append( fillStruct( "b15", "EAN13 - 5 digits add on", TBARCODE | NOCUT | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) ); + codes.append( fillStruct( "b16", "EAN128 (supports AIS)", TBARCODE | TBARCODEADV | MODULOALLCHECK ) ); + codes.append( fillStruct( "b17", "UPC 12 Digits", TBARCODE | TBARCODEADV | MODULOALLCHECK ) ); + codes.append( fillStruct( "b18", "CodaBar (2 width)", TBARCODE | TBARCODEADV | MODULO10CHECK ) ); + codes.append( fillStruct( "b19", "CodaBar (18 widths)", TBARCODE | TBARCODEADV ) ); + codes.append( fillStruct( "b20", "Code128", TBARCODE | TBARCODEADV ) ); + codes.append( fillStruct( "b21", "Deutsche Post Leitcode", TBARCODE | TBARCODEADV ) ); + codes.append( fillStruct( "b22", "Deutsche Post Identcode", TBARCODE | TBARCODEADV ) ); + codes.append( fillStruct( "b25", "Code 93", TBARCODE | TBARCODEADV ) ); + codes.append( fillStruct( "b26", "Identical to eBC_UPCA", TBARCODE | TBARCODEADV ) ); + codes.append( fillStruct( "b33", "UCC128 (= EAN128)", TBARCODE | TBARCODEADV ) ); + codes.append( fillStruct( "b34", "UPC A", TBARCODE | TBARCODEADV | TBARCODEADV | UPCACHECK ) ); + codes.append( fillStruct( "b35", "UPC A - 2 digit add on", TBARCODE | TBARCODEADV | UPCACHECK ) ); + codes.append( fillStruct( "b36", "UPC A - 5 digit add on", TBARCODE | TBARCODEADV | UPCACHECK ) ); + codes.append( fillStruct( "b37", "UPC E", TBARCODE | TBARCODEADV | UPCECHECK ) ); + codes.append( fillStruct( "b38", "UPC E - 2 digit add on", TBARCODE | TBARCODEADV | UPCECHECK ) ); + codes.append( fillStruct( "b39", "UPC E - 5 digit add on", TBARCODE | TBARCODEADV | UPCECHECK ) ); + codes.append( fillStruct( "b40", "PostNet ZIP (5d.)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) ); + codes.append( fillStruct( "b41", "PostNet ZIP (5d.+CD)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) ); + codes.append( fillStruct( "b42", "PostNet ZIP (8d.)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) ); + codes.append( fillStruct( "b43", "PostNet ZIP+4 (5d.+4d.+CD)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) ); + codes.append( fillStruct( "b44", "PostNet DPBC (5d.+4d.+2d.)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) ); + codes.append( fillStruct( "b45", "PostNet DPBC (5d.+4d.+2d.+CD)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) ); + codes.append( fillStruct( "b46", "Plessey Code", TBARCODE | TBARCODEADV ) ); + codes.append( fillStruct( "b47", "MSI Code", TBARCODE | TBARCODEADV | MODULO10CHECK ) ); + codes.append( fillStruct( "b50", "LOGMARS", TBARCODE | TBARCODEADV | MODULOALLCHECK ) ); + codes.append( fillStruct( "b55", "PDF417 - 2D bar code", TBARCODE | BARCODE2D | PDF417BARCODE ) ); + codes.append( fillStruct( "b56", "PDF417 Truncated - 2D bar code", TBARCODE | BARCODE2D | PDF417BARCODE ) ); + codes.append( fillStruct( "b57", "MaxiCode - 2D-bar code (Postscript only)", TBARCODE | BARCODE2D ) ); + codes.append( fillStruct( "b58", "QR-Code", TBARCODE | BARCODE2D ) ); + codes.append( fillStruct( "b59", "Code128 (CharSet A)", TBARCODE | TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) ); + codes.append( fillStruct( "b60", "Code128 (CharSet B)", TBARCODE | TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) ); + codes.append( fillStruct( "b61", "Code128 (CharSet C)", TBARCODE | TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) ); + codes.append( fillStruct( "b62", "Code 93 Ascii", TBARCODE | TBARCODEADV | MODULOALLCHECK ) ); + codes.append( fillStruct( "b63", "Australian Post Standard Customer", TBARCODE | NOCUT | TBARCODEADV ) ); + codes.append( fillStruct( "b64", "Australian Post Customer 2", TBARCODE | NOCUT | TBARCODEADV ) ); + codes.append( fillStruct( "b65", "Australian Post Customer 3", TBARCODE | NOCUT | TBARCODEADV ) ); + codes.append( fillStruct( "b66", "Australian Post Reply Paid", TBARCODE | NOCUT | TBARCODEADV ) ); + codes.append( fillStruct( "b67", "Australian Post Routing", TBARCODE | NOCUT | TBARCODEADV ) ); + codes.append( fillStruct( "b68", "Australian Post Redirection", TBARCODE | NOCUT | TBARCODEADV ) ); + codes.append( fillStruct( "b69", "ISBN Code (=EAN13P5)", TBARCODE | TBARCODEADV ) ); + codes.append( fillStruct( "b70", "Royal Mail 4 State (RM4SCC)", TBARCODE | NOCUT | TBARCODEADV ) ); + codes.append( fillStruct( "b71", "Data Matrix", DATAMATRIX | TBARCODE | BARCODE2D | NOSCALE ) ); + } + } +} + diff --git a/kbarcode/mybarcode.h b/kbarcode/mybarcode.h new file mode 100644 index 0000000..5865b2d --- /dev/null +++ b/kbarcode/mybarcode.h @@ -0,0 +1,304 @@ +/*************************************************************************** + mybarcode.h - description + ------------------- + begin : Die Apr 23 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef MY_BARCODE_H +#define MY_BARCODE_H + +#include <qpixmap.h> +#include <qobject.h> + +#include <qvaluelist.h> +#include "barkode.h" +void init(); + +typedef union u_settings { + struct { + int row; + int col; + int err; + } pdf417; + + struct { + int size; + } datamatrix; + + struct { + double modulewidth; + bool escape; + } tbarcode; +}; + +class QColor; +class QString; +typedef struct barcodeData { + QString value; + QString type; + int margin; + int rotation; + double scale; + double cut; + bool text; + bool valid; + + struct _pdf417 { + int row; + int col; + int err; + + bool operator==( const struct _pdf417 p ) const { + return row == p.row && col == p.col && err == p.err; + }; + + } pdf417; + + struct _datamatrix { + int size; + + bool operator==( const struct _datamatrix d ) const { + return size == d.size; + }; + + } datamatrix; + + struct _tbarcode { + double modulewidth; + bool escape; + bool above; + bool autocorrect; + int checksum; + + bool operator==( const struct _tbarcode t ) const { + return modulewidth == t.modulewidth && escape == t.escape && above == t.above && checksum == t.checksum && autocorrect == t.autocorrect; + }; + + } tbarcode; + + struct { + // only important + // when this struct + // is read from XML + QString caption; + int x; + int y; + } xml; + + /** + * Compare to barcodeData structs, + * but only the fields which are used + * as commandline parameters for + * the genaration backends. + * E.g. margin is not compared, because + * the margin is created by KBarcode internally. + */ + bool operator==( const struct barcodeData d ) const; + + struct { + bool enabled; + int mode; + int step; + int start; + } sequence; +}; + +#if 0 +enum { NOCUT = 0x00001, MULTILINE = 0x00002, NOTEXT = 0x00004, NOSCALE = 0x00008, + /** + * The different Generator Backends + */ + GNU_BARCODE = 0x00010, PDF417 = 0x00020, TBARCODE = 0x00040, + /** + * Different advanced option modes. + */ + DATAMATRIX = 0x00080, PDF417BARCODE = 0x00100, TBARCODEADV = 0x00200, + /** + * Checksum ID's + */ + POSTNETCHECK = 0x01000, CODE128CHECK = 0x02000, EAN8CHECK = 0x04000, EAN13CHECK = 0x08000, + UPCACHECK = 0x10000, UPCECHECK = 0x20000, MODULOALLCHECK = 0x40000, MODULO10CHECK = 0x80000, + /** + * Short cut's + */ + BARCODE2D = NOCUT | MULTILINE | NOTEXT }; +#endif + +typedef struct barcodeFormat { + QString name; + QString text; + unsigned int features; +}; + +class KProcess; +class KTempFile; +class QPaintDevice; +/** + * This class creates a QPixmap from a barcodeData struct. + * Several backends are supported to generate the pixmap. + * GNU Barcode + * pdf417_enc + * TBarcode (http://www.tec-it.com) + * + * This tools generate a postscript file. The ps file is + * transformed to a PBM file scaled to the requested resolution + * or screen resolution using ghostscript. + * + * The generated barcodes are cached using BarcodeCache. + * To fill a barcodeData struct with data from the user, you + * might want to use BarcodeWidget. + * + * A small example, of how to generate a valid Barcode in your application + * without the use of BarcodeWidget: + * <pre> + * barcodeData data; + * BarCode::fillDefault( &data ); // setup a barcode object with valid data + * data.value = "KBARCODE"; + * data.type = "code39"; + * BarCode b( &data ); // create a barcode object + * QPixmap p = b.pixmap(); // get a pixmap of the barcode + * </pre> + * + * @see BarcodeCache @see BarcodeWidget + * @author Dominik Seichter + */ +class BarCode { + public: + /** Create a BarCode object from the data const barcodeData* @p data. + * You may delete @p data afterwards. Be sure to call at least once + * BarCode::fillDefault() on @p data. Otherwise you rsik invalid barcode data. + */ + BarCode( const barcodeData* data ); + /** Create a BarCode object filled with default data. + */ + BarCode(); + ~BarCode(); + + /** Get a QPixmap of the current barcodeData in + * screen resolution- + */ + const QPixmap pixmap(); + /** Get a QPixmap of the barcode in the same resolution as the + * QPaintDevice* @p device. This is necessary if you want to print + * your barcodes, as they won't be scanable in screen resolution. + */ + const QPixmap printerPixmap( QPaintDevice* device ); + + /** Set the index of the barcodes for barcode sequences. + */ + void setIndex( int i ) { m_index = i; } + /** Change the barcodeData to @p d, call redraw() afterwards. + */ + void setData( barcodeData* d ) { barcode = *d; } + bool validBarcode() {return !p.isNull();} + + barcodeData data() const { return barcode; } + + QString sequenceValue(); + + /** Fill @p barcodeData* data with its default parameters. + * Always call this function, after you have created a new + * barcodeData struct. + */ + static void fillDefault( barcodeData* data ); + + /** Test if the encodingType @p type has a certain + * @p feature, as defined in the codes QValueList. + */ + static bool hasFeature( const QString & type, unsigned int feature ); + + /** get the meximum length of value for the encoding type @p name + * from the SQL databases. + */ + static const QString getMaxLength( const QString & name ); + + /** This function has to be called befor barcode support is avaible. + * It searches for the barcode generation backends + * (gnu barcode, tbarcode and pdf417) and fills the QValueList codes + * with data and information about the avaible barcode encoding types. + * You only have to call this function once. + * The results can be retrieved with the following functions: + * @see haveBarcode() + * @see haveTBarcode() + * @see havePDFBarcode() + */ + static void setHaveBarcode(); + static bool haveBarcode() { + return ( m_haveGnuBarcode || m_havePdfEncode || m_haveTBarcode ); + } + static bool haveGNUBarcode() { + return m_haveGnuBarcode; + } + static bool haveTBarcode() { + return m_haveTBarcode; + } + static bool havePDFBarcode() { + return m_havePdfEncode; + } + + /** call this, always after you changed the barcodeData using setData, + * so that the pixmaps are recreated. + */ + void redrawBarcode(); + private: + bool createPixmap( QPixmap* target, int resx, int resy ); + void createBarcode( QPixmap* target, QPaintDevice* device ); + bool createPdf417( KTempFile* output ); + bool createTBarcode( KTempFile* output ); + QString createSequence( const QString & value ); + /** reads the bounding box information from a postscript file + */ + QSize getBoundingBox( const QString & filename ); + + void cleanUp( KTempFile* file, KTempFile* file2, QPixmap* target ); + static barcodeFormat fillStruct( const QString & name, const QString & text, const int feature ); + + /** + * Cut the barcode either on the top or + * on the bottom, depending on the text position. + * + * @param pic the QPixmap that will be cutted + * @param cut a value between 0.0 and 1.0. If cut = 1.0 + * then no cut will happen, if cut = 0.5, half of + * the barcode is going to be cutted away. + */ + QPixmap cut( QPixmap* pic, double cut ); + + /** + * Add a margin to the QPixmap pic. + * @param pic the QPixmap pic which should get a margin + * @param margin the margin size in pixels. + */ + QPixmap addMargin( QPixmap* pic, int margin ); + + + /** + * The barcode is generated from this value. + * This is necessary so that sequences will work. + */ + QString m_value; + + /** index for barcode sequences; + */ + int m_index; + + QPixmap p; + QPixmap pp; + barcodeData barcode; + static bool m_haveGnuBarcode; + static bool m_havePdfEncode; + static bool m_haveTBarcode; +}; + +#endif diff --git a/kbarcode/mycanvasitem.cpp b/kbarcode/mycanvasitem.cpp new file mode 100644 index 0000000..43cc56d --- /dev/null +++ b/kbarcode/mycanvasitem.cpp @@ -0,0 +1,54 @@ +/*************************************************************************** + mycanvasitem.cpp - description + ------------------- + begin : Die Apr 23 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "mycanvasitem.h" +#include "labelutils.h" +#include "labeleditor.h" + +// KDE includes +#include <kapplication.h> + +// QT includes +#include <qbitmap.h> +#include <qpainter.h> + +SpotProvider::SpotProvider() +{ + m_spot = new QPixmap( SPOTSIZE, SPOTSIZE ); + m_spot->fill( Qt::green ); + + QPainter p( m_spot ); + p.drawRect( 0, 0, SPOTSIZE, SPOTSIZE ); + p.end(); +} + +SpotProvider::~SpotProvider() +{ + delete m_spot; +} + +SpotProvider* SpotProvider::instance = 0; +QPixmap* SpotProvider::m_spot = 0; + +SpotProvider* SpotProvider::getInstance() +{ + if( !instance ) + instance = new SpotProvider(); + + return instance; +} + diff --git a/kbarcode/mycanvasitem.h b/kbarcode/mycanvasitem.h new file mode 100644 index 0000000..a01d9c2 --- /dev/null +++ b/kbarcode/mycanvasitem.h @@ -0,0 +1,52 @@ +/*************************************************************************** + mycanvasitem.h - description + ------------------- + begin : Die Apr 23 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef MYCANVASITEM_H +#define MYCANVASITEM_H + +#include <qcanvas.h> +#include <qpoint.h> +#include <qimage.h> +#include <qpicture.h> +#include "tokenprovider.h" + +#define SPOTSIZE 7 + +class QPixmap; +/** A very small singleton, which creates a pixmap + * for the accesor points in the label editor. + * + * @author Dominik Seichter + */ +class SpotProvider { + public: + static SpotProvider* getInstance(); + + const QPixmap* spot() const { + return m_spot; + } + + private: + SpotProvider(); + ~SpotProvider(); + + static SpotProvider* instance; + static QPixmap* m_spot; +}; + + +#endif diff --git a/kbarcode/mycanvasview.cpp b/kbarcode/mycanvasview.cpp new file mode 100644 index 0000000..b9bd295 --- /dev/null +++ b/kbarcode/mycanvasview.cpp @@ -0,0 +1,611 @@ +/*************************************************************************** + mycanvasview.cpp - description + ------------------- + begin : Die Apr 23 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "mycanvasview.h" +#include "commands.h" +#include "definition.h" +#include "measurements.h" +#include "kbarcodesettings.h" + +// Qt includes +#include <qcursor.h> +#include <qpainter.h> +#include <qpaintdevicemetrics.h> + +// KDE includes +#include <kruler.h> +#include <kstatusbar.h> + +MyCanvas::MyCanvas( QObject* parent, const char* name ) + : QCanvas( parent, name ) +{ + m_grid = false; + + setBackgroundColor( Qt::lightGray ); + + resize( 0, 0 ); +} + +MyCanvas::~MyCanvas() +{ +} + +void MyCanvas::drawBackground( QPainter & painter, const QRect & clip ) +{ + QCanvas::drawBackground( painter, clip ); + + QRect shadow1( int(m_rect.x() + m_rect.width()), m_rect.y() + 5, 5, m_rect.height() ); + QRect shadow2( m_rect.x()+ 5, int(m_rect.y() + m_rect.height()), m_rect.width(), 5 ); + + // draw background shadow + if( clip.intersects( shadow1 ) ) + painter.fillRect( shadow1, Qt::black ); + + if( clip.intersects( shadow2 ) ) + painter.fillRect( shadow2, Qt::black ); + + if( clip.intersects( m_rect ) ) { + painter.fillRect( m_rect, Qt::white ); + + if( m_grid ) { + painter.translate( m_rect.x(), m_rect.y() ); + + painter.setPen( QPen( KBarcodeSettings::getInstance()->gridColor(), 0 ) ); + for( int y = 0; y <= m_rect.height(); y += KBarcodeSettings::getInstance()->gridSize() ) + for( int x = 0; x <= m_rect.width(); x += KBarcodeSettings::getInstance()->gridSize() ) + painter.drawPoint( x, y ); + + painter.translate( -m_rect.x(), -m_rect.y() ); + } + } +} + +MyCanvasView::MyCanvasView( Definition* d, MyCanvas* c, QWidget* parent, const char* name, WFlags f) + : QCanvasView(c,parent,name,f) +{ + statusbar = 0; + m_commov = 0; + canv = c; + + rulerv = new KRuler( Qt::Vertical, this ); + rulerh = new KRuler( Qt::Horizontal, this ); + if( Measurements::measurementSystem() == Measurements::Metric ) { + rulerv->setRulerMetricStyle( KRuler::Millimetres ); + rulerh->setRulerMetricStyle( KRuler::Millimetres ); + } else { + rulerv->setRulerMetricStyle( KRuler::Inch ); + rulerh->setRulerMetricStyle( KRuler::Inch ); + } + rulerv->setMaxValue( 0 ); + rulerh->setMaxValue( 0 ); + + viewport()->setMouseTracking( true ); + setDefinition( d ); +} + +MyCanvasView::~MyCanvasView() +{ +} + +void MyCanvasView::snapPoint(QPoint * point, TCanvasItem* item ) +{ + // move item to next grid position + // TODO: align the top left to the grid not the current mouse position! + + /* + */ + + if( item ) + { + int difx = point->x() - (int)item->x(); + int dify = point->y() - (int)item->y(); + + int x = (int)item->x(); + int y = (int)item->y(); + + int grid = KBarcodeSettings::getInstance()->gridSize(); + int modx = x % grid; + int mody = y % grid; + + x -= modx; + y -= mody; + + if(modx >= grid / 2) + x += grid; + + if(mody >= grid / 2) + y += grid; + + point->setX( x + difx ); + point->setY( y + dify ); + } + else + { + point->setX(point->x() - point->x() % KBarcodeSettings::getInstance()->gridSize()); + point->setY(point->y() - point->y() % KBarcodeSettings::getInstance()->gridSize()); + } +} + +void MyCanvasView::contentsMouseMoveEvent(QMouseEvent* e) +{ + rulerh->slotNewValue( e->x() ); + rulerv->slotNewValue( e->y() ); + + if( statusbar ) { + LabelUtils l; + int x = (int)l.pixelToMm( e->x(), this, LabelUtils::DpiX ); + int y = (int)l.pixelToMm( e->y(), this, LabelUtils::DpiY ); + statusbar->changeItem( i18n("Position: ") + + QString( "%1%2 x %3%4" ).arg( x ) + .arg( Measurements::system() ).arg( y ).arg( Measurements::system()), mouseid ); + } + + updateCursor( e->pos() ); + + // if no mouse button is pressed bail out now + if( !(e->state() & Qt::LeftButton ) ) { + (void)updateCursor( e->pos(), true ); + return; + } + + bool shift_pressed = e->state() & Qt::ShiftButton; + + TCanvasItem* moving = getActive(); + if( moving && !moving->item()->locked() ) { + QPoint p = inverseWorldMatrix().map(e->pos()); + + if( m_mode == Barcode || m_mode == Inside ) { + TCanvasItemList list = getSelected(); + for( unsigned int i = 0; i < list.count(); i++ ) { + TCanvasItem* moving = list[i]; + QPoint new_pt = QPoint(p.x() - delta_pt.x(),p.y() - delta_pt.y()); + if( canv->grid() ) { + snapPoint(&new_pt, moving) ; + } + + LabelUtils l; + QPoint pmm; + pmm.setX( (int)l.pixelToMm( new_pt.x() - getTranslation().x(), this, LabelUtils::DpiX ) * 1000 ); + pmm.setY( (int)l.pixelToMm( new_pt.y() - getTranslation().y(), this, LabelUtils::DpiY ) * 1000 ); + + // Move the item + MoveCommand* mv = new MoveCommand( pmm.x() - moving->item()->rectMM().x(), + pmm.y() - moving->item()->rectMM().y(), moving ); + mv->execute(); + getMoveCommand()->addCommand( mv ); + } + } else { + + if( canv->grid() ) { + snapPoint(&p, NULL ) ; + } + + LabelUtils l; + + QPoint pmm; + pmm.setX( (int)l.pixelToMm( p.x() - getTranslation().x(), this, LabelUtils::DpiX ) * 1000 ); + pmm.setY( (int)l.pixelToMm( p.y() - getTranslation().y(), this, LabelUtils::DpiY ) * 1000 ); + + QRect rmm = moving->item()->rectMM(); + ResizeCommand* mv = new ResizeCommand( moving, shift_pressed ); + + switch( m_mode ) { + case RightMiddle: + mv->setRect( rmm.x(), rmm.y(), pmm.x() - rmm.x(), rmm.height() ); + break; + case LeftMiddle: + mv->setRect( pmm.x(), rmm.y(), rmm.width()+ (rmm.x() - pmm.x()), rmm.height() ); + break; + case BottomMiddle: + mv->setRect( rmm.x(), rmm.y(), rmm.width(), pmm.y() - rmm.y()); + break; + case TopMiddle: + mv->setRect( rmm.x(), pmm.y(), rmm.width(), rmm.height()+ (rmm.y() - pmm.y())); + break; + case BottomLeft: + mv->setRect( pmm.x(), rmm.y(), rmm.width()+ (rmm.x() - pmm.x()), pmm.y() - rmm.y() ); + break; + case BottomRight: + mv->setRect( rmm.x(), rmm.y(), pmm.x() - rmm.x(), pmm.y() - rmm.y() ); + break; + case TopLeft: + mv->setRect( pmm.x(), pmm.y(), rmm.width()+ (rmm.x() - pmm.x()), rmm.height()+ (rmm.y() - pmm.y())); + break; + case TopRight: + mv->setRect( rmm.x(), pmm.y(), pmm.x() - rmm.x(),rmm.height()+ (rmm.y() - pmm.y()) ); + break; + default: + break; + } + mv->execute(); + getMoveCommand()->addCommand( mv ); + } + + moving_start = p; + + emit movedSomething(); + } +} + +void MyCanvasView::contentsMousePressEvent(QMouseEvent* e) +{ + setActive( 0, e->state() & Qt::ControlButton ); + + QCanvasItemList list = canvas()->allItems(); + for( int z = MyCanvasView::getLowestZ( list ); z <= MyCanvasView::getHighestZ( list ); z++ ) + for( unsigned int i = 0; i < list.count(); i++ ) + if( list[i]->z() == z && isInside( e->pos(), list[i] ) ) + setActive( list[i], (e->state() & Qt::ControlButton) ); + + if( getActive() ) { + moving_start = inverseWorldMatrix().map(e->pos()); + m_mode = updateCursor( e->pos() ); + old = getActive()->boundingRect(); + delta_pt=QPoint(e->x() - old.x(),e->y() - old.y()); + } + + if( e->button() == Qt::RightButton && getActive() ) + emit showContextMenu( e->globalPos() ); +} + +void MyCanvasView::contentsMouseReleaseEvent(QMouseEvent* e) +{ + if( e->button() != Qt::LeftButton || getSelected().isEmpty() ) + return; + + if( m_commov ) { + history->addCommand( getMoveCommand(), false ); + m_commov = 0; + } + + updateCursor( e->pos() ); +} + +KMacroCommand* MyCanvasView::getMoveCommand() +{ + if( !m_commov ) + m_commov = new KMacroCommand( i18n("Item Moved") ); + + return m_commov; +} + +void MyCanvasView::contentsMouseDoubleClickEvent(QMouseEvent* e) +{ + setActive( 0 ); + QCanvasItemList list = canvas()->allItems(); + for( int z = MyCanvasView::getHighestZ( list ); z >= MyCanvasView::getLowestZ( list ); z-- ) + for( unsigned int i = 0; i < list.count(); i++ ) + if( list[i]->z() == z && isInside( e->pos(), list[i] ) ) { + setActive( list[i] ); + emit doubleClickedItem( getActive() ); + return; + } +} + +bool MyCanvasView::isInside( QPoint p, QCanvasItem* item ) +{ + if( !item->isVisible() ) + return false; + + return item->boundingRect().contains( p ); +} + +int MyCanvasView::isEdge( QPoint p, QCanvasItem* item ) +{ + if( !isInside( p, item ) ) + return Outside; + + QRect r = item->boundingRect(); + + int rh = r.y() + r.height(); + int rw = r.x() + r.width(); + if( p.x() > r.x() && p.x() < r.x() + SPOTSIZE ) { + // Left + if( p.y() > r.y() && p.y() < r.y() + SPOTSIZE ) + return TopLeft; + + if( p.y() > rh - SPOTSIZE && p.y() < rh ) + return BottomLeft; + + if( (r.height() - 2 * SPOTSIZE ) / 2 > SPOTSIZE ) { + // Middle + int start = ( r.y() + (r.height() - SPOTSIZE)/2 ); + if( p.y() > start && p.y() < start + SPOTSIZE ) + return LeftMiddle; + } + + } + + if( p.y() > r.y() && p.y() < r.y() + SPOTSIZE ) { + // Top + if( (r.width() - 2 * SPOTSIZE ) / 2 > SPOTSIZE ) { + // Middle + int start = ( r.x() + (r.width() - SPOTSIZE)/2 ); + if( p.x() > start && p.x() < start + SPOTSIZE ) + return TopMiddle; + } + } + + if( p.y() > rh - SPOTSIZE && p.y() < rh ) { + // Bottom + if( (r.width() - 2 * SPOTSIZE ) / 2 > SPOTSIZE ) { + // Middle + int start = ( r.x() + (r.width() - SPOTSIZE)/2 ); + if( p.x() > start && p.x() < start + SPOTSIZE ) + return BottomMiddle; + } + } + + if( p.x() > rw - SPOTSIZE && p.x() < rw ) { + // Right + if( p.y() > r.y() && p.y() < r.y() + SPOTSIZE ) + return TopRight; + + if( p.y() > rh - SPOTSIZE && p.y() < rh ) + return BottomRight; + + if( (r.height() - 2 * SPOTSIZE ) / 2 > SPOTSIZE ) { + // Middle + int start = ( r.y() + (r.height() - SPOTSIZE)/2 ); + if( p.y() > start && p.y() < start + SPOTSIZE ) + return RightMiddle; + } + } + + return Inside; +} + +void MyCanvasView::deleteCurrent() +{ + TCanvasItemList list = getSelected(); + if( !list.isEmpty() ) { + KMacroCommand* mc = new KMacroCommand( i18n("Delete") ); + + for( unsigned int i = 0; i < list.count(); i++ ) { + DeleteCommand* dc = new DeleteCommand( list[i] ); + dc->execute(); + mc->addCommand( dc ); + } + + history->addCommand( mc, false ); + setActive( 0 ); + canvas()->update(); + } +} + +void MyCanvasView::setCurrent( QCanvasItem* item ) +{ + setSelected( item ); + setActive( item ); +} + +void MyCanvasView::updateRuler() +{ + rulerh->setGeometry( 20, 0, width() - 20, 20 ); + rulerv->setGeometry( 0, 20, 20, height() - 20 ); + + if( def ) { + canv->setRect( QRect( translation.x(), translation.y(), (int)def->getMeasurements().width( this ), (int)def->getMeasurements().height( this )) ); + + rulerv->setMaxValue( height() ); + rulerh->setMaxValue( width() ); + + + QPaintDeviceMetrics pdm( this ); + if( Measurements::measurementSystem() == Measurements::Metric ) { + rulerh->setPixelPerMark( (1/ 25.4)* pdm.logicalDpiX() ); + rulerv->setPixelPerMark( (1/25.4)* pdm.logicalDpiY() ); + } + } + +} + +void MyCanvasView::resizeEvent( QResizeEvent * r ) +{ + setUpdatesEnabled( false ); + QPoint old = translation; + + QCanvasView::resizeEvent( r ); + + reposition(); + updateRuler(); + + repaintContents(); + + old = translation - old; + QCanvasItemList list = canvas()->allItems(); + for( unsigned int i = 0; i < list.count(); i++ ) + list[i]->moveBy( old.x(), old.y() ); + + setUpdatesEnabled( true ); +} + +void MyCanvasView::reposition() +{ + /* + * it is difficult to handle the repositioning + * when a new scaling factor has been set. + * Therefore we divide by the old factor + * and multiply with the new one. + * As a result we have the correct width. + */ + int x = int((width() - (def->getMeasurements().width( this )) ) / 2); + int y = int((height() - (def->getMeasurements().height( this )) ) / 2); + + // move label 30 pixels away from top/left if necessary + x = x > 0 ? x : 30; + y = y > 0 ? y : 30; + + // make sure that there is some space around the label, therefore at 60 pixel + int w = ( this->width() - 2 > def->getMeasurements().width( this ) ? this->width() - 2 : int(def->getMeasurements().width( this ) + 60) ); + int h = ( this->height() - 2 > def->getMeasurements().height( this ) ? this->height() - 2 : int(def->getMeasurements().height( this ) + 60) ); + + canvas()->resize( w, h ); + + + translation = QPoint( x, y ); +} + +void MyCanvasView::setDefinition( Definition* d ) +{ + def = d; + reposition(); + updateRuler(); + repaintContents( true ); +} + +void MyCanvasView::selectAll() +{ + QCanvasItemList list = canvas()->allItems(); + for( unsigned int i = 0; i < list.count(); i++ ) + setSelected( list[i], true ); +} + +void MyCanvasView::deSelectAll() +{ + setSelected( 0 ); +} + +int MyCanvasView::getLowestZ( QCanvasItemList list ) +{ + int v = 0; + for( unsigned int i = 0; i < list.count(); i++ ) + if( list[i]->z() < v ) + v = (int)list[i]->z(); + + return v; +} + +int MyCanvasView::getHighestZ( QCanvasItemList list ) +{ + int v = 0; + for( unsigned int i = 0; i < list.count(); i++ ) + if( list[i]->z() > v ) + v = (int)list[i]->z(); + + return v; +} + +TCanvasItem* MyCanvasView::getActive() +{ + QCanvasItemList list = canvas()->allItems(); + for( unsigned int i = 0; i < list.count(); i++ ) + if( list[i]->isActive() ) + return (TCanvasItem*)list[i]; + + return 0; +} + +void MyCanvasView::setActive( QCanvasItem* item, bool control ) +{ + emit selectionChanged(); + QCanvasItemList list = canvas()->allItems(); + for( unsigned int i = 0; i < list.count(); i++ ) + list[i]->setActive( false ); + + if( item ) + item->setActive( true ); + + setSelected( item, control ); +} + +DocumentItemList MyCanvasView::getAllItems() +{ + DocumentItemList l; + + QCanvasItemList list = canvas()->allItems(); + for( unsigned int i = 0; i < list.count(); i++ ) + l.append( ((TCanvasItem*)list[i])->item() ); + + return l; +} + +TCanvasItemList MyCanvasView::getSelected() +{ + TCanvasItemList l; + QCanvasItemList list = canvas()->allItems(); + for( unsigned int i = 0; i < list.count(); i++ ) + if( list[i]->isSelected() ) + l.append( (TCanvasItem*)list[i] ); + + return l; +} + +void MyCanvasView::setSelected( QCanvasItem* item, bool control ) +{ + if( !control ) { + QCanvasItemList list = canvas()->allItems(); + for( unsigned int i = 0; i < list.count(); i++ ) + list[i]->setSelected( false ); + } + + if( item ) + item->setSelected( true ); +} + +int MyCanvasView::updateCursor( QPoint pos, bool pressed ) +{ + if( !getActive() ) { + this->setCursor( QCursor::ArrowCursor ); + return -1; + } + + int mode = isEdge( pos, getActive() ); + + if( getActive()->item()->locked() ) + { + pressed && mode != Outside ? setCursor( Qt::ForbiddenCursor ) : setCursor( QCursor::ArrowCursor ); + return mode; + } + + if( getActive()->rtti() == eRtti_Barcode ) { + pressed && mode != Outside ? setCursor( QCursor::SizeAllCursor ) : setCursor( QCursor::ArrowCursor ); + mode = Barcode; + return mode; + } + + switch( mode ) { + case TopLeft: + case BottomRight: + this->setCursor( QCursor::SizeFDiagCursor ); + break; + case TopMiddle: + case BottomMiddle: + this->setCursor( QCursor::SizeVerCursor ); + break; + case TopRight: + case BottomLeft: + this->setCursor( QCursor::SizeBDiagCursor ); + break; + case RightMiddle: + case LeftMiddle: + this->setCursor( QCursor::SizeHorCursor ); + break; + case Inside: + pressed ? setCursor( QCursor::SizeAllCursor ) : setCursor( QCursor::ArrowCursor ); + break; + case Outside: + default: + this->setCursor( QCursor::ArrowCursor ); + break; + }; + + return mode; +} + + +#include "mycanvasview.moc" diff --git a/kbarcode/mycanvasview.h b/kbarcode/mycanvasview.h new file mode 100644 index 0000000..0922717 --- /dev/null +++ b/kbarcode/mycanvasview.h @@ -0,0 +1,175 @@ +/*************************************************************************** + mycanvasview.h - description + ------------------- + begin : Die Apr 23 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef MYCANVASVIEW_H +#define MYCANVASVIEW_H + +#include <qcanvas.h> +#include <qvaluelist.h> +#include "documentitem.h" + +class TCanvasItem; + +typedef QValueList<TCanvasItem*> TCanvasItemList; + + +class QRect; +class QPainter; +class MyCanvas : public QCanvas { + Q_OBJECT + + public: + MyCanvas( QObject* parent, const char* name = 0 ); + ~MyCanvas(); + + void setRect( QRect r ) { + m_rect = r; + } + + QRect rect() const { + return m_rect; + } + + void setGrid( bool enabled ) { + m_grid = enabled; + } + + bool grid() const { return m_grid; } + + protected: + void drawBackground( QPainter & painter, const QRect & clip ); + + private: + QRect m_rect; + bool m_grid; +}; + +class Definition; +class QColor; +class QLabel; +class QPoint; +class KCommandHistory; +class KMacroCommand; +class KRuler; +class KStatusBar; +class MyCanvasView : public QCanvasView +{ + Q_OBJECT + + enum edges { + TopLeft, + TopMiddle, + TopRight, + RightMiddle, + LeftMiddle, + BottomLeft, + BottomMiddle, + BottomRight, + Inside, + Outside, + Barcode + }; + + public: + MyCanvasView( Definition* d, MyCanvas *c, QWidget* parent=0, const char* name=0, WFlags f=0); + ~MyCanvasView(); + + /** return a list of all DocumentItems on the canvas + */ + DocumentItemList getAllItems(); + + TCanvasItemList getSelected(); + + TCanvasItem* getActive(); + void setActive( QCanvasItem* item = 0, bool control = false ); + + void setCurrent( QCanvasItem* item ); + + void setHistory( KCommandHistory* hist ) { + history = hist; + } + + QPoint getTranslation() const { + return translation; + } + + void setDefinition( Definition* d ); + void setPosLabel( KStatusBar* s, int id ) { + mouseid = id; + statusbar = s; + } + + static int getLowestZ( QCanvasItemList list ); + static int getHighestZ( QCanvasItemList list ); + + void snapPoint(QPoint* point, TCanvasItem* item) ; + + public slots: + void selectAll(); + void deSelectAll(); + + void deleteCurrent(); + + void updateGUI() { + canvas()->update(); + repaintContents(); + } + + protected: + void contentsMousePressEvent(QMouseEvent*); + void contentsMouseMoveEvent(QMouseEvent*); + void contentsMouseReleaseEvent(QMouseEvent *); + void contentsMouseDoubleClickEvent(QMouseEvent*); + void resizeEvent( QResizeEvent * r ); + + signals: + void selectionChanged(); + void movedSomething(); + void doubleClickedItem( TCanvasItem* ); + void showContextMenu( QPoint ); + + private: + void setSelected( QCanvasItem* item = 0, bool control = false ); + KMacroCommand* getMoveCommand(); + + Definition* def; + + KRuler* rulerv; + KRuler* rulerh; + + KCommandHistory* history; + KMacroCommand* m_commov; + MyCanvas* canv; + + int mouseid; + KStatusBar* statusbar; + + QPoint moving_start; + QPoint translation; + + QRect old; + + bool isInside( QPoint p, QCanvasItem* item ); + int isEdge( QPoint p, QCanvasItem* item ); + void reposition(); + void updateRuler(); + int updateCursor( QPoint pos, bool pressed = false ); + int m_mode; + QPoint delta_pt ; +}; + +#endif diff --git a/kbarcode/mydatatable.cpp b/kbarcode/mydatatable.cpp new file mode 100644 index 0000000..9ec9dd1 --- /dev/null +++ b/kbarcode/mydatatable.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + mydatatable.cpp - description + ------------------- + begin : Son Jun 16 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "mydatatable.h" + +MyDataTable::MyDataTable(QWidget *parent, const char *name ) + : QDataTable(parent,name) +{ } + +MyDataTable::~MyDataTable() +{ +} + +bool MyDataTable::update() +{ + return updateCurrent(); +} + + +bool MyDataTable::deleteItem() +{ + return deleteCurrent(); +} + +bool MyDataTable::newItem() +{ + return insertCurrent(); +} + +#include "mydatatable.moc" diff --git a/kbarcode/mydatatable.h b/kbarcode/mydatatable.h new file mode 100644 index 0000000..fa55fb4 --- /dev/null +++ b/kbarcode/mydatatable.h @@ -0,0 +1,37 @@ +/*************************************************************************** + mydatatable.h - description + ------------------- + begin : Son Jun 16 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef MYDATATABLE_H +#define MYDATATABLE_H + +#include <qwidget.h> +#include <qdatatable.h> + +/** A table to modify SQL tables. + */ +class MyDataTable : public QDataTable { + Q_OBJECT + public: + MyDataTable(QWidget *parent=0, const char *name=0); + ~MyDataTable(); + + bool update(); + bool deleteItem(); + bool newItem(); +}; + +#endif diff --git a/kbarcode/newlabel.cpp b/kbarcode/newlabel.cpp new file mode 100644 index 0000000..4ca7f04 --- /dev/null +++ b/kbarcode/newlabel.cpp @@ -0,0 +1,248 @@ +/*************************************************************************** + newlabel.cpp - description + ------------------- + begin : Son Mai 5 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "newlabel.h" +#include "definitiondialog.h" +#include "sqltables.h" + +// Qt includes +#include <qcheckbox.h> +#include <qgroupbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qsqlquery.h> + +// KDE includes +#include <klocale.h> +#include <kcombobox.h> +#include <kpushbutton.h> + +#ifndef I2S + #define I2S(x) QString("%1").arg(x) +#endif // I2S + +NewLabel::NewLabel( QWidget* parent, const char* name, bool change, WFlags fl ) + : QDialog( parent, name, true, fl ) +{ + setCaption( i18n( "New Label" ) ); + curid = 0; + types = 0; + + NewLabelLayout = new QVBoxLayout( this, 11, 6, "NewLabelLayout"); + + TextLabel1 = new QLabel( this, "TextLabel1" ); + if( !change ) + TextLabel1->setText( i18n( "<h1>Create a new Label</h1><br><br>" ) ); + else + TextLabel1->setText( i18n( "<h1>Change Label Size</h1><br><br>" ) ); + + NewLabelLayout->addWidget( TextLabel1 ); + + QGroupBox* group1 = new QGroupBox( this ); + group1->setTitle( i18n( "Label" ) ); + group1->setColumnLayout(0, Qt::Vertical ); + group1->layout()->setSpacing( 6 ); + group1->layout()->setMargin( 11 ); + QGridLayout* group1Layout = new QGridLayout( group1->layout() ); + group1Layout->setAlignment( Qt::AlignTop ); + + TextLabel2 = new QLabel( group1, "TextLabel2" ); + TextLabel2->setText( i18n( "Producer:" ) ); + + TextLabel3 = new QLabel( group1, "TextLabel3" ); + TextLabel3->setText( i18n( "Type:" ) ); + + comboProducer = new KComboBox( FALSE, group1, "comboProducer" ); + comboType = new KComboBox( FALSE, group1, "comboType" ); + + checkEmpty = new QCheckBox( i18n("&Start with an empty label"), group1 ); + checkEmpty->setEnabled( !change ); + + group1Layout->addMultiCellWidget( checkEmpty, 0, 0, 0, 1 ); + group1Layout->addWidget( TextLabel2, 1, 0 ); + group1Layout->addWidget( TextLabel3, 2, 0 ); + group1Layout->addWidget( comboProducer, 1, 1 ); + group1Layout->addWidget( comboType, 2, 1 ); + + NewLabelLayout->addWidget( group1 ); + + Layout2 = new QHBoxLayout( 0, 0, 6, "Layout2"); + + QSpacerItem* spacer_2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + Layout2->addItem( spacer_2 ); + NewLabelLayout->addLayout( Layout2 ); + + TextLabel4 = new QLabel( this, "TextLabel4" ); + preview = new LabelPreview( this, "preview" ); + + QHBoxLayout* hlayout = new QHBoxLayout( 0, 6, 6 ); + hlayout->addWidget( TextLabel4 ); + hlayout->addWidget( preview ); + NewLabelLayout->addLayout( hlayout ); + QSpacerItem* spacer_3 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); + NewLabelLayout->addItem( spacer_3 ); + + Layout1 = new QHBoxLayout( 0, 0, 6, "Layout1"); + + buttonOwnFormat = new KPushButton( this, "buttonOwnFormat" ); + buttonOwnFormat->setText( i18n( "&Add own Label Definition" ) ); + Layout1->addWidget( buttonOwnFormat ); + + QSpacerItem* spacer_4 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + Layout1->addItem( spacer_4 ); + + buttonOk = new KPushButton( this, "buttonOk" ); + buttonOk->setText( i18n( "&OK" ) ); + buttonOk->setDefault( true ); + Layout1->addWidget( buttonOk ); + + buttonCancel = new KPushButton( this, "buttonCancel" ); + buttonCancel->setText( i18n( "&Cancel" ) ); + Layout1->addWidget( buttonCancel ); + NewLabelLayout->addLayout( Layout1 ); + + connect( comboProducer, SIGNAL( activated(int) ), this, SLOT( updateType() ) ); + connect( comboProducer, SIGNAL( activated(int) ), this, SLOT( updateText() ) ); + connect( comboType, SIGNAL( activated(int) ), this, SLOT( updateText() ) ); + connect( checkEmpty, SIGNAL( clicked() ), this, SLOT( updateText() ) ); + + connect( buttonOk, SIGNAL( clicked() ), this, SLOT(accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT(reject() ) ); + connect( buttonOwnFormat, SIGNAL( clicked() ), this, SLOT(add() ) ); + fillData(); + updateType(); + updateText(); +} + +NewLabel::~NewLabel() +{ + if( types ) + delete [] types; +} + +void NewLabel::fillData() +{ + comboProducer->clear(); + QStringList list = Definition::getProducers(); + comboProducer->insertStringList( list ); + + if( comboProducer->count() ) { + types = new QStringList[comboProducer->count()]; + for( int i = 0; i < comboProducer->count(); i++ ) + types[i] = Definition::getTypes( comboProducer->text( i ) ); + } +} + +void NewLabel::updateType() +{ + comboType->clear(); + if( types ) + comboType->insertStringList( types[ comboProducer->currentItem() ] ); +} + +void NewLabel::updateText() +{ + comboProducer->setEnabled( !checkEmpty->isChecked() ); + comboType->setEnabled( !checkEmpty->isChecked() ); + TextLabel2->setEnabled( !checkEmpty->isChecked() ); + TextLabel3->setEnabled( !checkEmpty->isChecked() ); + + if(!checkEmpty->isChecked()) + { + Definition d( comboProducer->currentText(), comboType->currentText() ); + TextLabel4->setText( QString(i18n( + "<b>Format:</b><br>\nWidth: ") + I2S(d.getMeasurements().width()) + + i18n("%1<br>Height: ") + I2S(d.getMeasurements().height()) + + i18n("%2<br>Horizontal Gap: ") + I2S(d.getMeasurements().gapH()) + + i18n("%3<br>Vertical Gap: ") + I2S(d.getMeasurements().gapV()) + + i18n("%4<br>Top Gap: ") + I2S(d.getMeasurements().gapTop()) + + i18n("%5<br>Left Gap: ") + I2S(d.getMeasurements().gapLeft()) + "%6<br>" + ).arg( Measurements::system() ) + .arg( Measurements::system() ) + .arg( Measurements::system() ) + .arg( Measurements::system() ) + .arg( Measurements::system() ) + .arg( Measurements::system() ) ); + + preview->setRect( QRect( (int)d.getMeasurements().gapLeftMM(), + (int)d.getMeasurements().gapTopMM(), + (int)d.getMeasurements().widthMM(), + (int)d.getMeasurements().heightMM() ) ); + preview->setMeasurements( d.getMeasurements() ); + preview->setPrvEnabled( true ); + preview->repaint(); + curid = d.getId(); + } + else + { + TextLabel4->setText( i18n("No label selected.") ); + preview->setPrvEnabled( false ); + preview->repaint(); + } +} + +bool NewLabel::isInCombo( QComboBox* combo, QString text ) +{ + if( combo->count() == 0 ) + return false; + + for( int i = 0; i < combo->count(); i++ ) + if( combo->text( i ) == text ) + return true; + return false; +} + +void NewLabel::setLabelId( int id ) +{ + QString name; + QSqlQuery query("SELECT type FROM " TABLE_LABEL_DEF " WHERE label_no='" + QString::number( id ) + "'" ); + while( query.next() ) + name = query.value( 0 ).toString(); + + for( int i = 0; i < comboProducer->count(); i++ ) { + comboProducer->setCurrentItem( i ); + updateType(); + for( int z = 0; z < comboType->count(); z++ ) + if( comboType->text( z ) == name ) { + comboProducer->setCurrentItem( i ); + comboType->setCurrentItem( z ); + return; + } + } + + comboProducer->setCurrentItem( 0 ); + updateType(); +} + +void NewLabel::add() +{ + DefinitionDialog* d = new DefinitionDialog( this ); + if( d->exec() == QDialog::Accepted ){ + fillData(); + updateType(); + updateText(); + } + delete d; +} + +bool NewLabel::empty() const +{ + return checkEmpty->isChecked(); +} + + +#include "newlabel.moc" diff --git a/kbarcode/newlabel.h b/kbarcode/newlabel.h new file mode 100644 index 0000000..5c5da06 --- /dev/null +++ b/kbarcode/newlabel.h @@ -0,0 +1,79 @@ +/*************************************************************************** + newlabel.h - description + ------------------- + begin : Son Mai 5 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef NEWLABEL_H +#define NEWLABEL_H + +#include <qdialog.h> +#include <qwidget.h> + +#include "definition.h" + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QCheckBox; +class QComboBox; +class KComboBox; +class KPushButton; +class QLabel; +class QString; +class LabelPreview; +class NewLabel : public QDialog +{ + Q_OBJECT + public: + NewLabel( QWidget* parent = 0, const char* name = 0, bool change = FALSE, WFlags fl = 0 ); + ~NewLabel(); + + int labelId() const { return curid; } + bool empty() const; + + void setLabelId( int id ); + + static bool isInCombo( QComboBox* combo, QString text ); + + private slots: + void updateType(); + void updateText(); + void add(); + + private: + void fillData(); + + QLabel* TextLabel1; + QLabel* TextLabel2; + QLabel* TextLabel3; + QCheckBox* checkEmpty; + KComboBox* comboProducer; + KComboBox* comboType; + KPushButton* buttonOwnFormat; + QLabel* TextLabel4; + KPushButton* buttonOk; + KPushButton* buttonCancel; + LabelPreview* preview; + QStringList* types; + + protected: + int curid; + QVBoxLayout* NewLabelLayout; + QHBoxLayout* Layout5; + QHBoxLayout* Layout2; + QHBoxLayout* Layout1; +}; + +#endif // NEWLABEL_H diff --git a/kbarcode/pixmapbarcode.cpp b/kbarcode/pixmapbarcode.cpp new file mode 100644 index 0000000..56a597e --- /dev/null +++ b/kbarcode/pixmapbarcode.cpp @@ -0,0 +1,492 @@ +/*************************************************************************** + pixmapbarcode.cpp - description + ------------------- + begin : Mon Nov 22 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#include "pixmapbarcode.h" +#include "barkode.h" + +// patch from Ali Akcaagac says that this include is needed +#include <stdlib.h> + +#include <kapplication.h> +#include <kprocess.h> +#include <ktempfile.h> + +#include <qbuffer.h> +#include <qdom.h> +#include <qfile.h> +#include <qfileinfo.h> +#include <qpainter.h> +#include <qpaintdevicemetrics.h> +#include <qpixmap.h> +#include <qtextstream.h> + +/* Margin added by GNU Barcode to the barcodes */ +#define BARCODE_MARGIN 10 + +/* Use a 5KB buffer for pipes */ +#define BUFFER_SIZE 1024 * 5 + +PDF417Options::PDF417Options() +{ + defaults(); +} + +const PDF417Options& PDF417Options::operator=( const BarkodeEngineOptions& rhs ) +{ + const PDF417Options* pdf = (dynamic_cast<const PDF417Options*>(&rhs)); + + this->m_row = pdf->m_row; + this->m_col = pdf->m_col; + this->m_err = pdf->m_err; + + return *this; +} + +void PDF417Options::defaults() +{ + m_row = 24; + m_col = 8; + m_err = 5; +} + +void PDF417Options::load( const QDomElement* tag ) +{ + m_row = tag->attribute( "pdf417.row", "24" ).toInt(); + m_col = tag->attribute( "pdf417.col", "8" ).toInt(); + m_err = tag->attribute( "pdf417.err", "5" ).toInt(); +} + +void PDF417Options::save( QDomElement* tag ) +{ + tag->setAttribute( "pdf417.row", m_row ); + tag->setAttribute( "pdf417.col", m_col ); + tag->setAttribute( "pdf417.err", m_err ); +} + +PixmapBarcode::PixmapBarcode() + : BarkodeEngine() +{ +} + + +PixmapBarcode::~PixmapBarcode() +{ +} + +const PixmapBarcode & PixmapBarcode::operator=( const BarkodeEngine & rhs ) +{ + const PixmapBarcode* pix = dynamic_cast<const PixmapBarcode*>(&rhs); + + if( pix ) + { + m_pdf417_options = pix->m_pdf417_options; + p = pix->p; + } + + return *this; +} + +const QSize PixmapBarcode::size() const +{ + return ( p.size().isNull() ? QSize( 100, 80 ) : p.size() ); +} + +void PixmapBarcode::update( const QPaintDevice* device ) +{ + p.resize( 0, 0 ); + createBarcode( &p, device ); +} + +void PixmapBarcode::drawBarcode( QPainter & painter, int x, int y ) +{ + if( p.isNull() ) + createBarcode( &p, painter.device() ); + + if( p.isNull() ) // still no barcode.... + { + barkode->drawInvalid( painter, x, y ); + return; + } + + painter.drawPixmap( x, y, p ); +} + +bool PixmapBarcode::createPixmap( QPixmap* target, int resx, int resy ) +{ + char* postscript = NULL; + long postscript_size = 0; + QString cmd; + bool bMonocrome; + + bMonocrome = ( barkode->foreground() == Qt::black && + barkode->background() == Qt::white && + barkode->textColor() == Qt::black ); + + KTempFile* input = new KTempFile( QString::null, bMonocrome ? ".pbm" : ".ppm" ); + input->file()->close(); + + if( Barkode::engineForType( barkode->type() ) == PDF417 ) { + if(!createPdf417( input )) { + cleanUp( input, target ); + return false; + } + + target->load( input->name(), "GIF" ); + } else { + if( !createPostscript( &postscript, &postscript_size ) ) + { + cleanUp( input, target ); + return false; + } + + FILE* gs_pipe; + + if( !postscript_size ) + { + // GNU Barcode was not able to encode this barcode + cleanUp( input, target ); + return false; + } + + QRect size = bbox( postscript, postscript_size ); + double sw = (double)(size.x() + size.width())/72 * resx; + double sh = (double)(size.y() + size.height())/72 * resy; + + if( Barkode::engineForType( barkode->type() ) == TBARCODE ) + { + sw = (double)(size.x() + size.width()); + sh = (double)(size.y() + size.height()); + } + + cmd = QString("gs -g%1x%2").arg(int(sw*(double)barkode->scaling())).arg(int(sh*(double)barkode->scaling())); + cmd += " -r" + QString::number( resx*(double)barkode->scaling()) + "x" + QString::number( resy*(double)barkode->scaling() ); + cmd += QString(" -sDEVICE=%1 -sOutputFile=").arg( bMonocrome ? "pbmraw" : "ppm" ); + cmd += input->name(); + cmd += " -sNOPAUSE -q - -c showpage quit"; + + qDebug("cmd: " + cmd ); + gs_pipe = popen( cmd.latin1(), "w" ); + if( !gs_pipe ) + { + qDebug("ERROR: cannot open Ghostscript pipe!"); + cleanUp( input, target ); + return false; + } + + fwrite( postscript, sizeof(char), postscript_size, gs_pipe ); + pclose( gs_pipe ); + + target->load( input->name(), "PBM" ); + } + + + free( postscript ); + + input->unlink(); + delete input; + + return true; +} + +bool PixmapBarcode::createPostscript( char** postscript, long* postscript_size ) +{ + QString cmd; + + /* + if( Barkode::engineForType( barkode->type() ) == TBARCODE ) + { + cmd = createTBarcodeCmd(); + qDebug("tbarcodeclient commandline: %s", cmd.latin1() ); + } + else // GNU_BARCODE + */ + { + cmd = "barcode -E -b "; + cmd += KShellProcess::quote( barkode->parsedValue() ) + (barkode->textVisible() ? "" : " -n"); + cmd += " -e " + barkode->type(); + } + + if( !readFromPipe( cmd.latin1(), postscript, postscript_size ) ) + return false; + + return true; +} + +QRect PixmapBarcode::bbox( const char* data, long size ) +{ + int x = 0, y = 0, w = 0, h = 0; + const char* bbox = "%%BoundingBox:"; + int len = strlen( bbox ); + + QRect s(0,0,0,0); + QByteArray array; + array.setRawData( data, size ); + + QBuffer b( array ); + if( !b.open( IO_ReadOnly ) ) + return s; + + QTextStream t( &b ); + + QString text = t.readLine(); + while( !text.isNull() ) + { + if( text.startsWith( bbox ) ) + { + text = text.right( text.length() - len ); + sscanf( (const char*)text, "%d %d %d %d", &x, &y, &w, &h ); + s = QRect( x, y, w, h ); + break; + } + + text = t.readLine(); + } + + b.close(); + array.resetRawData( data, size ); + + return s; +} + +bool PixmapBarcode::readFromPipe( const char* command, char** buffer, long* buffer_size ) +{ + FILE* pipe = popen( command, "r" ); + if( !pipe ) + { + qDebug("ERROR: cannot open pipe %s!", command ); + return false; + } + + char* buf = (char*)malloc( BUFFER_SIZE ); + char* tmp = NULL; + int s = 0; + + *buffer_size = 0; + do { + s = fread( buf, sizeof(char), BUFFER_SIZE, pipe ); + + // Special case: + // GNU Barcode Error + if( !s ) + break; + + // there won't be more data to read + tmp = (char*)malloc( *buffer_size + s ); + + if( *buffer ) + { + memcpy( tmp, *buffer, *buffer_size ); + free( *buffer ); + } + + memcpy( tmp+ *buffer_size, buf, s ); + *buffer = tmp; + *buffer_size += s; + } while( s == BUFFER_SIZE ); + + pclose( pipe ); + free( buf ); + + return true; +} + +void PixmapBarcode::createBarcode( QPixmap* target, const QPaintDevice* device ) +{ + QPaintDeviceMetrics pdm( device ); + int resx = pdm.logicalDpiX(); + int resy = pdm.logicalDpiY(); + + QPixmap* cached = 0;//BarcodeCache::instance()->read( barcode, resx, resy, value ); + + // no matching barcode found in cache + if( !cached ) { + if( !createPixmap( target, resx, resy ) ) + return; + } else { + *target = *cached; + delete cached; + } + + if( Barkode::hasFeature( barkode->type(), PDF417 ) ) { + // we have to scale to the correct resolution. + // we scale already here and not at the end, + // so that the addMargin function does not get a scaled margin. + QPaintDeviceMetrics pdm( KApplication::desktop() ); + int screenresx = pdm.logicalDpiX(); + int screenresy = pdm.logicalDpiY(); + + QWMatrix m; + double scalex = (resx/screenresx)*barkode->scaling(); + double scaley = (resy/screenresy)*barkode->scaling(); + m.scale( scalex, scaley ); + *target = target->xForm( m ); + } + *target = cut( target, barkode->cut() ); + *target = addMargin( target ); + + // Rotate + QWMatrix m; + m.rotate( (double)barkode->rotation() ); + *target = target->xForm( m ); + + //barcode.valid = true; +} + +bool PixmapBarcode::createPdf417( KTempFile* output ) +{ + const PDF417Options* options = (dynamic_cast<const PDF417Options*>(barkode->engine()->options())); + + if( !options ) + { + qDebug("No PDF417Options available!"); + return false; + } + + KTempFile text( QString::null, ".txt" ); + QTextStream t( text.file() ); + t << barkode->parsedValue(); + text.file()->close(); + + // ps does not work because bounding box information is missing + // pbm cannot be loaded by KImgIO (works fine in GIMP) + // gif is the only other option + KShellProcess proc; + proc << "pdf417_enc" << "-tgif" << text.name() << output->name() + << options->row() + << options->col() + << options->err(); + + proc.start( KProcess::Block, KProcess::NoCommunication ); + proc.resume(); + + if( proc.exitStatus() ) { + text.unlink(); + return false; + } + + text.unlink(); + return true; +} + +#if 0 +QString PixmapBarcode::createTBarcodeCmd() +{ + QString cmd; + + // print text + QString flag = barkode->textVisible() ? " Ton" : " n Toff"; // we pass the old parameter Ton and the new one: n + // escape text + flag.append( barkode->tbarcodeOptions()->escape() ? " son" : " soff" ); + // autocorrection + flag.append( barkode->tbarcodeOptions()->autocorrect() ? " Aon" : " Aoff" ); + // barcode height + flag.append( QString( " h%1" ).arg( barkode->tbarcodeOptions()->height() ) ); + // text above + if( barkode->tbarcodeOptions()->above() ) + flag.append( " a" ); + + cmd = "tbarcodeclient "; + if( !Barkode::hasFeature( barkode->type(), BARCODE2D ) ) + cmd += QString( " m%1" ).arg( barkode->tbarcodeOptions()->moduleWidth() * 1000 ); + + if( Barkode::hasFeature( barkode->type(), DATAMATRIX ) ) + cmd += QString( " Ds%1" ).arg( barkode->datamatrixSize() ); + + if( Barkode::hasFeature( barkode->type(), PDF417BARCODE ) ) + cmd += QString( " Pr%1 Pc%2 Pe%3" ).arg( barkode->pdf417Options()->row() ) + .arg( barkode->pdf417Options()->col() ) + .arg( barkode->pdf417Options()->err() ); + + cmd += " " + barkode->type() + QString(" tPS c%1").arg( barkode->tbarcodeOptions()->checksum() ); + cmd += flag + " d" + KShellProcess::quote( barkode->parsedValue() ); + + return cmd; +} +#endif // 0 + +void PixmapBarcode::cleanUp( KTempFile* file, QPixmap* target ) +{ + target->resize( 0, 0 ); + + file->unlink(); + delete file; +} + +QPixmap PixmapBarcode::cut( QPixmap* pic, double cut) +{ + if( cut == 1.0 ) + return (*pic); + + QPixmap pcut( pic->width(), int((double)pic->height() * cut) ); + pcut.fill( Qt::white ); // barcode.bg + + QWMatrix m; + /* + * if text is above the barcode cut from + * below the barcode. + */ + + // TODO: put this into one if, I am to stupid today..... + if( Barkode::hasFeature( barkode->type(), TBARCODEADV ) ) { + //if( !barcode.tbarcode.above ) + m.rotate( 180 ); + } else + m.rotate( 180 ); + + QPainter painter( &pcut ); + painter.drawPixmap( 0, 0, pic->xForm( m ) ); + + return pcut.xForm( m ); +} + +QPixmap PixmapBarcode::addMargin( QPixmap* pic ) +{ + QPixmap p; + + /* We have to handle UPC special because of the checksum character + * which is printed on the right margin. + * The samve goes for ISBN codes. + * Any other formats?? + */ + + bool gnubarcode = (Barkode::engineForType( barkode->type() ) == GNU_BARCODE) || + (Barkode::engineForType( barkode->type() ) == PURE_POSTSCRIPT); + double barm = gnubarcode ? BARCODE_MARGIN * barkode->scaling() : 0.0; + + // Add margin + double sx = barm; + double sy = barm; + double sw = pic->width() - (barm * 2); + double sh = pic->height() - (barm * 2); + int margin = (int)(barkode->quietZone()*2 - barm*2); + + if( gnubarcode && (barkode->type() == "upc" || barkode->type() == "isbn") ) + { + sw = pic->width() - barm; + + p.resize( pic->width() + int(barkode->quietZone()*2 - barm), pic->height() + margin ); + } + else + p.resize( pic->width() + margin, pic->height() + margin ); + + p.fill( barkode->background() ); + QPainter painter( &p ); + painter.drawPixmap( barkode->quietZone(), barkode->quietZone(), *pic, (int)sx, (int)sy, (int)sw, (int)sh ); + painter.end(); + + return p; +} diff --git a/kbarcode/pixmapbarcode.h b/kbarcode/pixmapbarcode.h new file mode 100644 index 0000000..76591a2 --- /dev/null +++ b/kbarcode/pixmapbarcode.h @@ -0,0 +1,136 @@ +/*************************************************************************** + pixmapbarcode.cpp - description + ------------------- + begin : Mon Nov 22 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#ifndef PIXMAPBARCODE_H +#define PIXMAPBARCODE_H + +#include "barkodeengine.h" +#include <qpixmap.h> + +class KTempFile; +class QPainter; + +class PDF417Options : public BarkodeEngineOptions { + public: + PDF417Options(); + + const PDF417Options& operator=( const BarkodeEngineOptions& rhs ); + void defaults(); + + void load( const QDomElement* tag ); + void save( QDomElement* tag ); + + inline int row() const { return m_row; } + inline int col() const { return m_col; } + inline int err() const { return m_err; } + + inline void setRow( int r ) { m_row = r; } + inline void setCol( int r ) { m_col = r; } + inline void setErr( int r ) { m_err = r; } + + private: + int m_row; + int m_col; + int m_err; +}; + +/** + * A pixmap based barcode engine which + * uses different commandline tools to + * generate barcodes. + * This class is a port of the old BarCode + * class to the new Barkode interface. + * + * @author Dominik Seichter + */ +class PixmapBarcode : public BarkodeEngine +{ + public: + PixmapBarcode(); + ~PixmapBarcode(); + + const PixmapBarcode & operator=( const BarkodeEngine & rhs ); + + inline EEngine engine() const; + const QSize size() const; + void update( const QPaintDevice* device ); + void drawBarcode( QPainter & painter, int x, int y ); + + inline BarkodeEngineOptions* options(); + + private: + bool createPixmap( QPixmap* target, int resx, int resy ); + void createBarcode( QPixmap* target, const QPaintDevice* device ); + bool createPdf417( KTempFile* output ); + //QString createTBarcodeCmd(); + + virtual bool createPostscript( char** postscript, long* postscript_size ); + + /** Mage sure the temporaray file @p file + * gets closed and deleted properly + */ + void cleanUp( KTempFile* file, QPixmap* target ); + /** + * Cut the barcode either on the top or + * on the bottom, depending on the text position. + *g + * @param pic the QPixmap that will be cutted + * @param cut a value between 0.0 and 1.0. If cut = 1.0 + * then no cut will happen, if cut = 0.5, half of + * the barcode is going to be cutted away. + */ + QPixmap cut( QPixmap* pic, double cut ); + + /** + * Add a margin to the QPixmap pic. + * @param pic the QPixmap pic which should get a margin + */ + QPixmap addMargin( QPixmap* pic ); + + protected: + /** Creates a pipe and read the data returned by the command into a buffer. + * \param command the command to execute + * \param buffer pointer to a buffer, will be malloc'ed and has to be free'd + * \param buffer_size pointer to a long where the size of the buffer will be stored + * \returns true if all data could be read sucessfully otherwise false. + */ + bool readFromPipe( const char* command, char** buffer, long* buffer_size ); + + /** + * \param postscript a postscript program + * \param postscript_size length of the postscript program + * \returns the BoundingBox of the postscript or EPS file + * so that it can be cropped correctly + */ + virtual QRect bbox( const char* postscript, long postscript_size ); + + private: + QPixmap p; + PDF417Options m_pdf417_options; +}; + +EEngine PixmapBarcode::engine() const +{ + return PIXMAP; +} + +BarkodeEngineOptions* PixmapBarcode::options() +{ + return &m_pdf417_options; +} + +#endif diff --git a/kbarcode/previewdialog.cpp b/kbarcode/previewdialog.cpp new file mode 100644 index 0000000..2af08f6 --- /dev/null +++ b/kbarcode/previewdialog.cpp @@ -0,0 +1,219 @@ +/*************************************************************************** + previewdialog.cpp - description + ------------------- + begin : Die Dez 10 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "previewdialog.h" +#include "label.h" +#include "sqltables.h" +#include "labeleditor.h" +#include "measurements.h" + +// Qt includes +#include <qiodevice.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qpainter.h> +#include <qscrollview.h> +#include <qsqlcursor.h> + +// KDE includes +#include <kabc/addresseedialog.h> +#include <kapplication.h> +#include <kcombobox.h> +#include <kconfig.h> +#include <kiconloader.h> +#include <klineedit.h> +#include <klocale.h> +#include <knuminput.h> +#include <kpushbutton.h> + +int PreviewDialog::customer_index = 0; +int PreviewDialog::m_index = 1; +QString PreviewDialog::group = ""; +QString PreviewDialog::article = ""; + +PreviewDialog::PreviewDialog( QIODevice* device, Definition* d, QString filename, QWidget *parent, const char *name ) + : QDialog( parent, name, true, WDestructiveClose ) +{ + file = device; + def = d; + m_filename = filename; + + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + + QHBoxLayout* Layout = new QHBoxLayout( this, 6, 6 ); + QVBoxLayout* vbox = new QVBoxLayout( 0, 6, 6 ); + QVBoxLayout* buttons = new QVBoxLayout( 0, 6, 6 ); + QGridLayout* grid = new QGridLayout( 0 ); + + customerName = new KComboBox( false, this ); + customerId = new KComboBox( false, this ); + + groupName = new KLineEdit( group, this ); + articleId = new KLineEdit( article, this ); + if( SqlTables::isConnected() ) { + KCompletion* comp = articleId->completionObject(); + QSqlQuery query( "select article_no from barcode_basic" ); + QStringList slist; + while ( query.next() ) + slist.append( query.value(0).toString() ); + slist.sort(); + comp->setItems( slist ); + } + + spinIndex = new KIntNumInput( this ); + spinIndex->setRange( 1, 100000, 1, false ); + spinIndex->setValue( m_index ); + + serialStart = new KLineEdit( this ); + + serialInc = new KIntNumInput( this ); + serialInc->setRange( 1, 10000, 1, false ); + + lineAddr = new KLineEdit( this ); + lineAddr->setReadOnly( true ); + + buttonAddr = new KPushButton( i18n("Select &Address"), this ); + + buttonUpdate = new KPushButton( i18n("&Update"), this ); + buttonClose = new KPushButton( i18n("&Close"), this ); + buttonClose->setIconSet( SmallIconSet("fileclose") ); + + grid->addWidget( new QLabel( i18n("Customer Name and No.:"), this ), 0, 0 ); + grid->addWidget( customerName, 0, 1 ); + grid->addWidget( customerId, 0, 2 ); + grid->addWidget( new QLabel( i18n("Article Number:"), this ), 1, 0 ); + grid->addMultiCellWidget( articleId, 1, 1, 1, 2 ); + grid->addWidget( new QLabel( i18n("Group:"), this ), 2, 0 ); + grid->addMultiCellWidget( groupName, 2, 2, 1, 2 ); + grid->addWidget( new QLabel( i18n("Index:"), this ), 3, 0 ); + grid->addMultiCellWidget( spinIndex, 3, 3, 1, 2 ); + grid->addWidget( new QLabel( i18n("Serial start:"), this ), 4, 0 ); + grid->addMultiCellWidget( serialStart, 4, 4, 1, 2 ); + grid->addWidget( new QLabel( i18n( "Serial increment:" ), this ), 5, 0 ); + grid->addMultiCellWidget( serialInc, 5, 5, 1, 2 ); + grid->addWidget( new QLabel( i18n( "Addressbook entry:" ), this ), 6, 0 ); + grid->addWidget( lineAddr, 6, 1 ); + grid->addWidget( buttonAddr, 6, 2 ); + QScrollView* sv = new QScrollView( this ); + + preview = new QLabel( sv->viewport() ); + sv->addChild( preview ); + + QPixmap pix( (int)d->getMeasurements().width( this ), (int)d->getMeasurements().height( this ) ); + pix.fill( Qt::white ); + preview->setPixmap( pix ); + + vbox->addLayout( grid ); + vbox->addWidget( sv ); + + buttons->addWidget( buttonUpdate ); + buttons->addWidget( buttonClose ); + buttons->addItem( spacer ); + + Layout->addLayout( vbox ); + Layout->addLayout( buttons ); + + connect( buttonClose, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( buttonAddr, SIGNAL( clicked() ), this, SLOT( selectAddress() ) ); + // TODO: + // remove this ugly hack! The finished label is only shown when I call + // updateChanges() twice. I have no idea why! + connect( buttonUpdate, SIGNAL( clicked() ), this, SLOT( updatechanges() ) ); + connect( buttonUpdate, SIGNAL( clicked() ), this, SLOT( updatechanges() ) ); + // end ugly hack + + connect( customerName, SIGNAL( activated(int) ), this, SLOT( customerNameChanged(int) ) ); + connect( customerId, SIGNAL( activated(int) ), this, SLOT( customerIdChanged(int) ) ); + + KConfig* config = kapp->config(); + config->setGroup( "PreviewDialog" ); + resize( config->readNumEntry( "width", width() ), config->readNumEntry( "height", height() ) ); + + if( SqlTables::isConnected() ) + setupSql(); +} + +PreviewDialog::~PreviewDialog() +{ + KConfig* config = kapp->config(); + config->setGroup( "PreviewDialog" ); + config->writeEntry( "width", width() ); + config->writeEntry( "height", height() ); + config->sync(); +} + +void PreviewDialog::setupSql() +{ + QSqlCursor cur( "customer" ); + cur.select(); + customerId->clear(); + customerName->clear(); + while ( cur.next() ) { + customerId->insertItem( cur.value("customer_no" ).toString() ); + customerName->insertItem( cur.value("customer_name" ).toString() ); + } + + customerId->setCurrentItem( customer_index ); + customerName->setCurrentItem( customer_index ); +} + +void PreviewDialog::selectAddress() +{ + m_address = KABC::AddresseeDialog::getAddressee( this ); + if( !m_address.isEmpty() ) + lineAddr->setText( m_address.realName() ); + else + lineAddr->setText( QString::null ); +} + +void PreviewDialog::updatechanges() +{ + QPixmap pix( (int)def->getMeasurements().width( this ), (int)def->getMeasurements().height( this ) ); + pix.fill( Qt::white ); + + QPainter painter( &pix ); + + Label* l = new Label( def, file, m_filename, KApplication::desktop(), + customerId->currentText(), articleId->text(), groupName->text() ); + l->setIndex( spinIndex->value() - 1 ); + l->setSerial( serialStart->text(), serialInc->value() ); + l->setAddressee( &m_address ); + l->draw( &painter, 0, 0 ); + + preview->setPixmap( pix ); + + delete l; + + // keep settings for next the + // next time the dialog is shown + group = groupName->text(); + article = articleId->text(); + customer_index = customerId->currentItem(); + m_index = spinIndex->value(); +} + +void PreviewDialog::customerIdChanged( int index ) +{ + customerName->setCurrentItem( index ); +} + +void PreviewDialog::customerNameChanged( int index ) +{ + customerId->setCurrentItem( index ); +} + +#include "previewdialog.moc" diff --git a/kbarcode/previewdialog.h b/kbarcode/previewdialog.h new file mode 100644 index 0000000..db3c056 --- /dev/null +++ b/kbarcode/previewdialog.h @@ -0,0 +1,76 @@ +/*************************************************************************** + previewdialog.h - description + ------------------- + begin : Die Dez 10 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef PREVIEWDIALOG_H +#define PREVIEWDIALOG_H + +#include <qdialog.h> +#include <kabc/addressee.h> + +class Definition; +class KComboBox; +class KIntNumInput; +class KLineEdit; +class KPushButton; +class QIODevice; +class QLabel; +class QWidget; +class PreviewDialog : public QDialog { + Q_OBJECT + public: + PreviewDialog( QIODevice* device, Definition* d, QString filename, QWidget *parent=0, const char *name=0); + ~PreviewDialog(); + + private slots: + void updatechanges(); + void customerNameChanged( int index ); + void customerIdChanged( int index ); + void setupSql(); + void selectAddress(); + + private: + QLabel* preview; + + KLineEdit* articleId; + KLineEdit* groupName; + KLineEdit* serialStart; + KLineEdit* lineAddr; + + KIntNumInput* spinIndex; + KIntNumInput* serialInc; + + KComboBox* customerName; + KComboBox* customerId; + + KPushButton* buttonUpdate; + KPushButton* buttonClose; + KPushButton* buttonAddr; + + KABC::Addressee m_address; + + Definition* def; + QIODevice* file; + + QString m_filename; + + static int customer_index; + static int m_index; + static QString group; + static QString article; +}; + +#endif diff --git a/kbarcode/printersettings.cpp b/kbarcode/printersettings.cpp new file mode 100644 index 0000000..1668f44 --- /dev/null +++ b/kbarcode/printersettings.cpp @@ -0,0 +1,199 @@ +/*************************************************************************** + printersettings.cpp - description + ------------------- + begin : Don Jan 16 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "printersettings.h" +#include "kbarcode.h" + +// KDE includes +#include <kapplication.h> +#include <kcombobox.h> +#include <kconfig.h> +#include <kglobal.h> +#include <klocale.h> +#include <kurl.h> + +// Stolen from koffice/lib/kofficecore/koGlobal.cc +// and modified afterwards + +// - the comments "should be..." indicates the exact values if the inch sizes would be multiplied by 25.4 mm/inch + +// paper formats ( mm ) - public for compat reasons, but DO NOT USE in new programs ! +// See KoPageFormat's methods instead. + +const PageFormatInfo pageFormatInfo[]= +{ + { KPrinter::A3, "A3", I18N_NOOP("ISO A3"), 297.0, 420.0 }, + { KPrinter::A4, "A4", I18N_NOOP("ISO A4"), 210.0, 297.0 }, + { KPrinter::A5, "A5", I18N_NOOP("ISO A5"), 148.0, 210.0 }, + { KPrinter::Letter, "Letter", I18N_NOOP("US Letter"), 216.0, 279.0 }, // should be 215.9 mm x 279.4 mm + { KPrinter::Legal, "Legal", I18N_NOOP("US Legal"), 216.0, 356.0 }, // should be 215.9 mm x 335.6 mm + { KPrinter::A4, "Screen", I18N_NOOP("Screen"), 297.0, 210.0 }, // Custom, so fall back to A4 + { KPrinter::A4, "Custom", I18N_NOOP("Custom"), 210.0, 297.0 }, // Custom, so fall back to A4 + { KPrinter::B5, "B5", I18N_NOOP("ISO B5"), 182.0, 257.0 }, + { KPrinter::Executive, "Executive", I18N_NOOP("US Executive"), 191.0, 254.0 }, // should be 190.5 mm x 254.0 mm + { KPrinter::A0, "A0", I18N_NOOP("ISO A0"), 841.0, 1189.0 }, + { KPrinter::A1, "A1", I18N_NOOP("ISO A1"), 594.0, 841.0 }, + { KPrinter::A2, "A2", I18N_NOOP("ISO A2"), 420.0, 594.0 }, + { KPrinter::A6, "A6", I18N_NOOP("ISO A6"), 105.0, 148.0 }, + { KPrinter::A7, "A7", I18N_NOOP("ISO A7"), 74.0, 105.0 }, + { KPrinter::A8, "A8", I18N_NOOP("ISO A8"), 52.0, 74.0 }, + { KPrinter::A9, "A9", I18N_NOOP("ISO A9"), 37.0, 52.0 }, + { KPrinter::B0, "B0", I18N_NOOP("ISO B0"), 1030.0, 1456.0 }, + { KPrinter::B1, "B1", I18N_NOOP("ISO B1"), 728.0, 1030.0 }, + { KPrinter::B10, "B10", I18N_NOOP("ISO B10"), 32.0, 45.0 }, + { KPrinter::B2, "B2", I18N_NOOP("ISO B2"), 515.0, 728.0 }, + { KPrinter::B3, "B3", I18N_NOOP("ISO B3"), 364.0, 515.0 }, + { KPrinter::B4, "B4", I18N_NOOP("ISO B4"), 257.0, 364.0 }, + { KPrinter::B6, "B6", I18N_NOOP("ISO B6"), 128.0, 182.0 }, + { KPrinter::C5E, "C5", I18N_NOOP("ISO C5"), 163.0, 229.0 }, // Some sources tells: 162 mm x 228 mm + { KPrinter::Comm10E, "Comm10", I18N_NOOP("US Common 10"), 105.0, 241.0 }, // should be 104.775 mm x 241.3 mm + { KPrinter::DLE, "DL", I18N_NOOP("ISO DL"), 110.0, 220.0 }, + { KPrinter::Folio, "Folio", I18N_NOOP("US Folio"), 210.0, 330.0 }, // should be 209.54 mm x 330.2 mm + { KPrinter::Ledger, "Ledger", I18N_NOOP("US Ledger"), 432.0, 279.0 }, // should be 431.8 mm x 297.4 mm + { KPrinter::Tabloid, "Tabloid", I18N_NOOP("US Tabloid"), 279.0, 432.0 } // should be 297.4 mm x 431.8 mm +}; +// end stolen + +PrinterSettings* PrinterSettings::printerInstance = 0; + +PrinterSettings::PrinterSettings() + :QObject( 0, "printersettings" ) +{ + lpdata = new labelprinterdata; + loadConfig(); + + connect( kapp, SIGNAL( aboutToQuit() ), this, SLOT( saveConfig() ) ); +} + +PrinterSettings::~PrinterSettings() +{ +} + +PrinterSettings* PrinterSettings::getInstance() +{ + if( !printerInstance ) + printerInstance = new PrinterSettings(); + + return printerInstance; +} + +void PrinterSettings::loadConfig() +{ + KConfig* config = kapp->config(); + + config->setGroup("Printer"); + lpdata->articleEvent1 = (enum linebreak)config->readNumEntry("articleEvent1", NO_BREAK ); + lpdata->articleEvent2 = (enum linebreak)config->readNumEntry("articleEvent2", NO_BREAK ); + lpdata->articleEvent3 = (enum linebreak)config->readNumEntry("articleEvent3", NO_BREAK ); + lpdata->articleEvent4 = (enum linebreak)config->readNumEntry("articleEvent4", NO_BREAK ); + lpdata->groupEvent1 = (enum linebreak)config->readNumEntry("groupEvent1", NO_BREAK ); + lpdata->groupEvent2 = (enum linebreak)config->readNumEntry("groupEvent2", NO_BREAK ); + lpdata->groupEvent3 = (enum linebreak)config->readNumEntry("groupEvent3", NO_BREAK ); + lpdata->groupEvent4 = (enum linebreak)config->readNumEntry("groupEvent4", NO_BREAK ); + lpdata->useCustomNo = config->readBoolEntry("UseArticleCustomerNo", false ); + lpdata->quality = config->readNumEntry( "quality", Middle ); + // screen resolution was removed before 1.5.4, use middle instead + if( lpdata->quality != High && lpdata->quality != Middle && lpdata->quality != VeryHigh ) + lpdata->quality = Middle; + + config->setGroup("BatchPrinting"); + lpdata->comment = config->readEntry("comment", "#" ); + lpdata->separator = config->readEntry("separator", ";" ); + lpdata->quote = config->readEntry("quote", ""); + lpdata->border = config->readBoolEntry("border", false ); + lpdata->format = config->readNumEntry("PageSize", -1 ); + // get default page size from KDE + if( lpdata->format == -1 ) + for( unsigned int i = 0; i < sizeof( pageFormatInfo ) / sizeof( PageFormatInfo ); i++ ) + if( pageFormatInfo[i].kprinter == KGlobal::locale()->pageSize() ) { + lpdata->format = i; + break; + } + +} + +void PrinterSettings::saveConfig() +{ + KConfig* config = kapp->config(); + + config->setGroup("Printer"); + config->writeEntry("articleEvent1", lpdata->articleEvent1 ); + config->writeEntry("articleEvent2", lpdata->articleEvent2 ); + config->writeEntry("articleEvent3", lpdata->articleEvent3 ); + config->writeEntry("articleEvent4", lpdata->articleEvent4 ); + config->writeEntry("groupEvent1", lpdata->groupEvent1 ); + config->writeEntry("groupEvent2", lpdata->groupEvent2 ); + config->writeEntry("groupEvent3", lpdata->groupEvent3 ); + config->writeEntry("groupEvent4", lpdata->groupEvent4 ); + config->writeEntry("quality", lpdata->quality ); + config->writeEntry("UseArticleCustomerNo", lpdata->useCustomNo ); + + config->setGroup("BatchPrinting"); + config->writeEntry("comment", lpdata->comment ); + config->writeEntry("separator", lpdata->separator ); + config->writeEntry("quote", lpdata->quote ); + config->writeEntry("border", lpdata->border ); + config->writeEntry("PageSize", lpdata->format ); + + config->sync(); +} + +int PrinterSettings::getQuality() const +{ + return lpdata->quality == Middle || lpdata->quality == VeryHigh? High : lpdata->quality; +}; + +KPrinter* PrinterSettings::setupPrinter( const KURL & url, QWidget* parent, bool immediately, const QString & prn ) +{ + KPrinter* printer = new KPrinter( true, (enum QPrinter::PrinterMode)getQuality() ); + if( getData()->quality == Middle ) + printer->setResolution( 300 ); + else if( getData()->quality == VeryHigh ) + printer->setResolution( 1200 ); + + printer->setFullPage( true ); // don't use build in margin system + + if( !immediately && !printer->setup( parent ) ) + return 0; + + if( immediately && !prn.isEmpty() ) + printer->autoConfigure( prn ); + + if( !url.isValid() ) + printer->setDocFileName( url.fileName() ); + + return printer; +} + +void PrinterSettings::insertPageFormat( KComboBox* combo ) +{ + for( unsigned int i = 0; i < sizeof( pageFormatInfo ) / sizeof( PageFormatInfo ); i++ ) + combo->insertItem( pageFormatInfo[i].descriptiveName ); +} + +double PrinterSettings::pageWidth() const +{ + return pageFormatInfo[lpdata->format].width; +} + +double PrinterSettings::pageHeight() const +{ + return pageFormatInfo[lpdata->format].height; +} + + +#include "printersettings.moc" diff --git a/kbarcode/printersettings.h b/kbarcode/printersettings.h new file mode 100644 index 0000000..8083fcb --- /dev/null +++ b/kbarcode/printersettings.h @@ -0,0 +1,95 @@ +/*************************************************************************** + printersettings.h - description + ------------------- + begin : Don Jan 16 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef PRINTERSETTINGS_H +#define PRINTERSETTINGS_H + +#include <qobject.h> +#include <qstring.h> +#include <kprinter.h> + +class KURL; + +typedef struct labelprinterdata { + int articleEvent1; + int articleEvent2; + int articleEvent3; + int articleEvent4; + + int groupEvent1; + int groupEvent2; + int groupEvent3; + int groupEvent4; + + bool useCustomNo; + + int quality; // printer quality; enum PrinterMode + bool border; + int format; // index of the page format + + QString comment; + QString separator; + QString quote; +}; + +typedef struct PageFormatInfo +{ + KPrinter::PageSize kprinter; + const char* shortName; // Short name + const char* descriptiveName; // Full name, which will be translated + double width; // in mm + double height; // in mm +}; + +class KPrinter; +class KComboBox; +class PrinterSettings: public QObject { + Q_OBJECT + public: + enum { High = QPrinter::HighResolution, Middle, VeryHigh }; + enum { TEC, ZEBRA, INTERMEC, EPCL }; + + PrinterSettings(); + ~PrinterSettings(); + + labelprinterdata* getData() const { + return lpdata; + } + + int getQuality() const; + + // Get the size of the current selected page format + double pageWidth() const; + double pageHeight() const; + + void insertPageFormat( KComboBox* combo ); + static PrinterSettings* getInstance(); + + // don't forget to delete printer + KPrinter* setupPrinter( const KURL & url, QWidget* parent, bool immediately = false, const QString & prn = QString::null ); + + public slots: + void loadConfig(); + void saveConfig(); + + private: + labelprinterdata* lpdata; + + static PrinterSettings* printerInstance; +}; + +#endif diff --git a/kbarcode/printlabeldlg.cpp b/kbarcode/printlabeldlg.cpp new file mode 100644 index 0000000..849750f --- /dev/null +++ b/kbarcode/printlabeldlg.cpp @@ -0,0 +1,78 @@ +/*************************************************************************** + printlabeldlg.cpp - description + ------------------- + begin : Mon Jun 30 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "printlabeldlg.h" +#include "printersettings.h" + +// Qt includes +#include <qcheckbox.h> +#include <qlayout.h> + +// KDE includes +#include <knuminput.h> +#include <klocale.h> + +PrintLabelDlg::PrintLabelDlg(QWidget *parent, const char *name ) + : KDialogBase( KDialogBase::Plain, i18n("Print"), + KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, parent,name) +{ + QVBoxLayout* box = new QVBoxLayout( plainPage() ); + + numLabels = new KIntNumInput( plainPage() ); + numLabels->setLabel( i18n("Number of labels:" ), KNumInput::AlignLeft | KNumInput::AlignVCenter ); + numLabels->setRange( 1, 100000, 1, false ); + + numPos = new KIntNumInput( numLabels, 1, plainPage() ); + numPos->setLabel( i18n("Start at label position:" ), KNumInput::AlignLeft | KNumInput::AlignVCenter ); + numPos->setRange( 1, 100, 1, false ); + + checkBorder = new QCheckBox( i18n("&Print crop marks (borders)"), plainPage() ); + checkBorder->setChecked( PrinterSettings::getInstance()->getData()->border ); + + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); + + box->addWidget( numLabels ); + box->addWidget( numPos ); + box->addWidget( checkBorder ); + box->addItem( spacer ); +} + +PrintLabelDlg::~PrintLabelDlg() +{ +} + +void PrintLabelDlg::setLabelsEnabled( bool b ) +{ + numLabels->setEnabled( b ); +} + +int PrintLabelDlg::labels() const +{ + return numLabels->value(); +} + +int PrintLabelDlg::position() const +{ + return numPos->value(); +} + +bool PrintLabelDlg::border() const +{ + return checkBorder->isChecked(); +} + +#include "printlabeldlg.moc" diff --git a/kbarcode/printlabeldlg.h b/kbarcode/printlabeldlg.h new file mode 100644 index 0000000..4760359 --- /dev/null +++ b/kbarcode/printlabeldlg.h @@ -0,0 +1,69 @@ +/*************************************************************************** + printlabeldlg.h - description + ------------------- + begin : Mon Jun 30 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef PRINTLABELDLG_H +#define PRINTLABELDLG_H + +#include <qwidget.h> +#include <kdialogbase.h> + +class QCheckBox; +class KIntNumInput; + +/** + *@author Dominik Seichter + * + * This small dialogs allows the user to select how many + * pages shall be printed and at which position the first + * label should be printed. + */ +class PrintLabelDlg : public KDialogBase { + Q_OBJECT + public: + PrintLabelDlg(QWidget *parent=0, const char *name=0); + ~PrintLabelDlg(); + + /** + * Allow/disallow the user to enter the + * numer of labels to print. + * @param b bool + */ + void setLabelsEnabled( bool b ); + + /** + * returns how many labels should be printed + */ + int labels() const; + + /** + * returns at which position the first label shall be printed + * (counting from the first label being number 1 _not_ 0 ) + */ + int position() const; + + /** + * returns wether crop marks shall be printed or not + */ + bool border() const; + + private: + KIntNumInput* numLabels; + KIntNumInput* numPos; + QCheckBox* checkBorder; +}; + +#endif diff --git a/kbarcode/propertywidget.cpp b/kbarcode/propertywidget.cpp new file mode 100644 index 0000000..ee56af5 --- /dev/null +++ b/kbarcode/propertywidget.cpp @@ -0,0 +1,631 @@ +/*************************************************************************** + propertywidget.h - description + ------------------- + begin : Do Sep 10 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#include "propertywidget.h" +#include "documentitem.h" +#include "rectitem.h" +#include "commands.h" +#include "sqltables.h" +#include "barcodecombo.h" +#include "multilineeditdlg.h" +#include "textitem.h" +#include "imageitem.h" +#include "measurements.h" +#include "mycanvasview.h" +//NY20 +#include "textlineitem.h" +#include "textlineedit.h" +//NY20 +#include "tokendialog.h" + +#include <kcolorbutton.h> +#include <kcombobox.h> +#include <kcommand.h> +#include <kiconloader.h> +#include <kimageio.h> +#include <klineedit.h> +#include <klocale.h> +#include <knuminput.h> +#include <ktextedit.h> +#include <kurlrequester.h> + +#include <qcheckbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qpainter.h> +#include <qradiobutton.h> +#include <qsqlquery.h> +#include <qvbox.h> +#include <qvbuttongroup.h> +#include <kmessagebox.h> + +#define IMAGE_INTERNAL i18n("Image Saved in KBarcode") + +void FillLineCombo( KComboBox* box ) +{ + /* A small helper function to fill + * a combobox with all by Qt + * supported pen styles. + */ + + // TODO: Use the enum for Qt line styles here! + + QPainter p; + for( int i = 1; i < 6; i++ ) { + QPixmap pixmap( 60, 20 ); + pixmap.fill( Qt::white ); + p.begin( &pixmap ); + p.setPen( QPen( Qt::black, 3, (Qt::PenStyle)i ) ); + p.drawLine( 5, 10, 55, 10 ); + p.end(); + + box->insertItem( pixmap ); + } +} + +PropertyWidget::PropertyWidget(QWidget* parent ) + : QWidget( parent, 0 ) +{ + grid = new QGridLayout( this, 2, 2 ); +} + +PropertyBorder::PropertyBorder( QWidget* parent ) + : PropertyWidget( parent ) +{ + checkBorder = new QCheckBox( this ); + checkBorder->setText( i18n("&Border Visible") ); + + buttonColor = new KColorButton( this ); + + spinWidth = new KIntNumInput( this ); + spinWidth->setRange( 1, 100, 1, false ); + + comboLine = new KComboBox( false, this ); + FillLineCombo( comboLine ); + + grid->addMultiCellWidget( checkBorder, 0, 0, 0, 1 ); + grid->addWidget( new QLabel( i18n("Color:"), this ), 1, 0 ); + grid->addWidget( buttonColor, 1, 1 ); + grid->addWidget( new QLabel( i18n("Line Width:"), this ), 2, 0 ); + grid->addWidget( spinWidth, 2, 1 ); + grid->addWidget( new QLabel( i18n("Line Style:"), this ), 3, 0 ); + grid->addWidget( comboLine, 3, 1 ); + + + connect( checkBorder, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); +} + +void PropertyBorder::applySettings( DocumentItem* item, KMacroCommand* command ) +{ + BorderCommand* bc = new BorderCommand( checkBorder->isChecked(), QPen( buttonColor->color(), spinWidth->value(), (Qt::PenStyle)(comboLine->currentItem() + 1) ), item ); + bc->execute(); + command->addCommand( bc ); +} + +void PropertyBorder::initSettings( DocumentItem* item ) +{ + checkBorder->setChecked( item->border() ); + buttonColor->setColor( item->pen().color() ); + spinWidth->setValue( item->pen().width() ); + comboLine->setCurrentItem( item->pen().style() - 1 ); + + enableControls(); +} + +void PropertyBorder::enableControls() +{ + buttonColor->setEnabled( checkBorder->isChecked() ); + spinWidth->setEnabled( checkBorder->isChecked() ); + comboLine->setEnabled( checkBorder->isChecked() ); +} + + +PropertyRotation::PropertyRotation( QWidget* parent ) + : PropertyWidget( parent ) +{ + QLabel* label = new QLabel( i18n("&Rotation:"), this ); + comboRotation = new KComboBox( FALSE, this ); + label->setBuddy( comboRotation ); + + comboRotation->insertItem( i18n("0") ); + comboRotation->insertItem( i18n("90") ); + comboRotation->insertItem( i18n("180") ); + comboRotation->insertItem( i18n("270") ); + + grid->addWidget( label, 0, 0 ); + grid->addWidget( comboRotation, 0, 1 ); + +} + +void PropertyRotation::applySettings( DocumentItem* item, KMacroCommand* command ) +{ + TextItem* text = static_cast<TextItem*>(item); + double rot = 0.0; + + if( comboRotation->currentItem() == 1 ) + rot = 90.0; + else if( comboRotation->currentItem() == 2 ) + rot = 180.0; + else if( comboRotation->currentItem() == 3 ) + rot = 270.0; + + TextRotationCommand* rc = new TextRotationCommand( rot, text ); + rc->execute(); + command->addCommand( rc ); +} + +void PropertyRotation::initSettings( DocumentItem* item ) +{ + TextItem* text = static_cast<TextItem*>(item); + + if( text->rotation() == 0.0 ) + comboRotation->setCurrentItem( 0 ); + else if( text->rotation() == 90.0 ) + comboRotation->setCurrentItem( 1 ); + else if( text->rotation() == 180.0 ) + comboRotation->setCurrentItem( 2 ); + else if( text->rotation() == 270.0 ) + comboRotation->setCurrentItem( 3 ); +} + +PropertyFill::PropertyFill( QWidget* parent ) + : PropertyWidget( parent ) +{ + buttonColor = new KColorButton( this ); + + grid->addWidget( new QLabel( i18n("Color:"), this ), 0, 0 ); + grid->addWidget( buttonColor, 0, 1 ); +} + +void PropertyFill::applySettings( DocumentItem* item, KMacroCommand* command ) +{ + RectItem* rect = static_cast<RectItem*>(item); + FillCommand* fc = new FillCommand( buttonColor->color(), rect ); + fc->execute(); + command->addCommand( fc ); +} + +void PropertyFill::initSettings( DocumentItem* item ) +{ + RectItem* rect = static_cast<RectItem*>(item); + buttonColor->setColor( rect->color() ); +} + +PropertyBarcode::PropertyBarcode( TokenProvider* token, QWidget* parent ) + : PropertyWidget( parent ) +{ + QLabel* TextLabel1 = new QLabel( this, "TextLabel1" ); + TextLabel1->setText( i18n( "Barcode Settings:" ) ); + + comboComplex = new KComboBox( FALSE, this ); + if( SqlTables::isConnected() ) + { + QSqlQuery* query = new QSqlQuery("select encoding_type from barcode_basic group by encoding_type"); + while( query->next() ) + comboComplex->insertItem( "Main:" + query->value( 0 ).toString() ); + + delete query; + + query = new QSqlQuery("select customer_no, encoding_type from customer_text group by customer_no, encoding_type"); + while( query->next() ) + comboComplex->insertItem( query->value( 0 ).toString() + ":" + query->value( 1 ).toString() ); + delete query; + } + + comboComplex->insertItem( "Static" ); + + barcode = new BarcodeWidget( this, "barcode" ); + barcode->setTokenProvider( token ); + + //connect( this, SIGNAL( defaultClicked() ), this, SLOT( defaults() ) ); + connect( comboComplex, SIGNAL( activated(int) ), this, SLOT(changedCombo() ) ); + + grid->addWidget( TextLabel1, 0, 0 ); + grid->addWidget( comboComplex, 0, 1 ); + grid->addMultiCellWidget( barcode, 1, 1, 0, 1 ); + + changedCombo(); +} + +// void PropertyBarcode::defaults() +// { +// comboComplex->setCurrentItem( 0 ); +// barcode->defaults(); +// } + +void PropertyBarcode::changedCombo() +{ + bool v = false; + if( comboComplex->currentItem() == comboComplex->count() - 1 ) + v = true; + + barcode->setDataEnabled( v ); + barcode->setStandardEnabled( v ); +} + +void PropertyBarcode::applySettings( DocumentItem* item, KMacroCommand* command ) +{ + BarcodeItem* bcode = static_cast<BarcodeItem*>(item); + + Barkode* d = new Barkode(); + barcode->getData( *d ); + + if( comboComplex->currentItem() != comboComplex->count() - 1 ) { + d->setType( getTypeFromCaption( comboComplex->currentText() ) ); + d->setValue( SqlTables::getInstance()->getBarcodeMaxLength( d->type() ) ); + } + d->setDatabaseMode( comboComplex->currentText() ); + + BarcodeCommand* bc = new BarcodeCommand( bcode, d ); + bc->execute(); + command->addCommand( bc ); +} + +void PropertyBarcode::initSettings( DocumentItem* item ) +{ + BarcodeItem* bcode = static_cast<BarcodeItem*>(item); + + barcode->setData( *bcode ); + for( int i = 0; i < comboComplex->count(); i++ ) + if( comboComplex->text( i ).lower() == bcode->databaseMode().lower() ) + comboComplex->setCurrentItem( i ); + + changedCombo(); +} + +PropertyText::PropertyText( TokenProvider* token, QWidget* parent ) + : PropertyWidget( parent ) +{ + m_editor = new MultiLineEditor( token, this, "m_editor" ); + grid->addWidget( m_editor, 0, 0 ); +} + +void PropertyText::applySettings( DocumentItem* item, KMacroCommand* command ) +{ + TextItem* text = static_cast<TextItem*>(item); + + TextChangeCommand* tc = new TextChangeCommand( text, m_editor->text() ); + tc->execute(); + command->addCommand( tc ); +} + +void PropertyText::initSettings( DocumentItem* item ) +{ + TextItem* text = static_cast<TextItem*>(item); + m_editor->setText( text->text() ); +} + +//NY21 +PropertyTextLine::PropertyTextLine( TokenProvider* token, QWidget* parent ) + : PropertyWidget( parent ) +{ + m_editor = new TextLineEditor( token, this ); + grid->addWidget( m_editor, 0, 0 ); +} + +void PropertyTextLine::applySettings( DocumentItem* item, KMacroCommand* command ) +{ + TextLineItem* text = static_cast<TextLineItem*>(item); + + TextLineChangeCommand* tc = new TextLineChangeCommand( text, m_editor->text(), m_editor->getFontType(),m_editor->getVertMag(),m_editor->getHorMag() ); + tc->execute(); + command->addCommand( tc ); +} + +void PropertyTextLine::initSettings( DocumentItem* item ) +{ + TextLineItem* text = static_cast<TextLineItem*>(item); + m_editor->setText( text->text() ); + m_editor->setFontType(text->getFont()); + m_editor->setHorMag(text->getMagHor()); + m_editor->setVertMag(text->getMagVert()); +} +//NY21 + +PropertySize::PropertySize( QWidget* parent ) + : PropertyWidget( parent ) +{ + const double low = -1000.0; + const double max = 1000.0; + QVBox* box = new QVBox( this ); + + checkLock = new QCheckBox( i18n("&Protect item from being moved or resized"), box ); + numTop = new KDoubleNumInput( low, max, 0.0, 0.2, 3, box ); + numLeft = new KDoubleNumInput( numTop, low, max, 0.0, 0.2, 3, box ); + numHeight = new KDoubleNumInput( numLeft, low, max, 0.0, 0.2, 3, box ); + numWidth = new KDoubleNumInput( numHeight, low, max, 0.0, 0.2, 3, box ); + + numTop->setSuffix( Measurements::system() ); + numLeft->setSuffix( Measurements::system() ); + numHeight->setSuffix( Measurements::system() ); + numWidth->setSuffix( Measurements::system() ); + + numTop->setLabel( i18n("&Top:"), AlignLeft | AlignCenter ); + numLeft->setLabel( i18n("&Left:"), AlignLeft | AlignCenter ); + numHeight->setLabel( i18n("&Height:"), AlignLeft | AlignCenter ); + numWidth->setLabel( i18n("&Width:"), AlignLeft | AlignCenter ); + + grid->addWidget( box, 0, 0 ); + + connect( checkLock, SIGNAL( clicked() ), this, SLOT( enableControls() )); +} + +void PropertySize::enableControls() +{ + numTop->setEnabled( !checkLock->isChecked() ); + numLeft->setEnabled( !checkLock->isChecked() ); + numHeight->setEnabled( !checkLock->isChecked() ); + numWidth->setEnabled( !checkLock->isChecked() ); +} + +void PropertySize::applySettings( DocumentItem* item, KMacroCommand* command ) +{ + QRect r = item->rect(); + QPoint translation( 0, 0 ); + + TCanvasItem* canvasItem = item->canvasItem(); + if( canvasItem ) + { + MyCanvasView* view = canvasItem->canvasView(); + translation = view->getTranslation(); + } + + if( Measurements::measurementSystem() == Measurements::Metric ) + { + r.setX( (int)(numLeft->value() * 1000)); + r.setY( (int)(numTop->value() * 1000)); + r.setWidth( (int)(numWidth->value() * 1000)); + r.setHeight( (int)(numHeight->value() * 1000)); + } + else + { + /* This conversion from int to millimeter should get its own + * function or maybe even an own class. + */ + #warning "test inch to mm!" + r.setX( (int)(numLeft->value() * 1000 * 25.4000508001016 ) ); + r.setY( (int)(numTop->value() * 1000 * 25.4000508001016 ) ); + r.setWidth( (int)(numWidth->value() * 1000 * 25.4000508001016 ) ); + r.setHeight( (int)(numHeight->value() * 1000 * 25.4000508001016 ) ); + } + + if( canvasItem ) + { + if( item->rectMM().x() != r.x() || item->rectMM().y() != r.y() ) + { + MoveCommand* mc = new MoveCommand( r.x(), r.y(), canvasItem ); + mc->execute(); + command->addCommand( mc ); + } + + if( item->rectMM() != r ) + { + ResizeCommand* rc = new ResizeCommand( canvasItem, false ); + rc->setRect( r.x(), r.y(), r.width(), r.height() ); + rc->execute(); + command->addCommand( rc ); + } + + if( checkLock->isChecked() != item->locked() ) + { + LockCommand* lc = new LockCommand( checkLock->isChecked(), canvasItem ); + lc->execute(); + command->addCommand( lc ); + } + } +} + +void PropertySize::initSettings( DocumentItem* item ) +{ + QRect r = item->rectMM(); + QPoint translation( 0, 0 ); + + TCanvasItem* canvasItem = item->canvasItem(); + if( canvasItem ) + { + MyCanvasView* view = canvasItem->canvasView(); + translation = view->getTranslation(); + } + + if( Measurements::measurementSystem() == Measurements::Metric ) + { + numLeft->setValue( r.x() / 1000.0 ); + numTop->setValue( r.y() / 1000.0 ); + numWidth->setValue( r.width() / 1000.0 ); + numHeight->setValue( r.height() / 1000.0 ); + } + else // Imperial + { + numLeft->setValue( (r.x() / 1000.0) / 25.4000508001016 ); + numTop->setValue( (r.y() / 1000.0) / 25.4000508001016 ); + numWidth->setValue( (r.width() / 1000.0) / 25.4000508001016 ); + numHeight->setValue( (r.height() / 1000.0) / 25.4000508001016 ); + } + + checkLock->setChecked( item->locked() ); + enableControls(); +} + +PropertyImage::PropertyImage( TokenProvider* token, QWidget* parent ) + : PropertyWidget( parent ), m_token( token ) +{ + QLabel* label = new QLabel( i18n("&Rotation:"), this ); + comboRotation = new KComboBox( FALSE, this ); + label->setBuddy( comboRotation ); + + QVButtonGroup* groupFile = new QVButtonGroup( i18n("&Image"), this ); + radioImagePath = new QRadioButton( i18n("&Load image from path"), groupFile ); + imgUrl = new KURLRequester( groupFile ); + imgUrl->setFilter( KImageIO::pattern( KImageIO::Reading ) ); + imgUrl->setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly ); + radioImageExpression = new QRadioButton( i18n("&Read image path from expression"), groupFile ); + + imgHBox = new QHBox( groupFile ); + imgHBox->setSpacing( 5 ); + + imgExpression = new KLineEdit( imgHBox ); + buttonToken = new KPushButton( i18n("&Insert Data Field..."), imgHBox ); + buttonToken->setIconSet( QIconSet( SmallIcon("contents") ) ); + + comboRotation->insertItem( i18n("0") ); + comboRotation->insertItem( i18n("90") ); + comboRotation->insertItem( i18n("180") ); + comboRotation->insertItem( i18n("270") ); + + QVButtonGroup* group = new QVButtonGroup( i18n("&Size"), this ); + + radioOriginal = new QRadioButton( i18n("&None"), group ); + radioZoomed = new QRadioButton( i18n("&Zoom"), group ); + radioScaled = new QRadioButton( i18n("S&cale"), group ); + + checkMirrorH = new QCheckBox( i18n("Mirror &Horizontaly"), this ); + checkMirrorV = new QCheckBox( i18n("Mirror &Vertically"), this ); + + grid->addMultiCellWidget( groupFile, 0, 1, 0, 1 ); + grid->addMultiCellWidget( group, 2, 3, 0, 1 ); + grid->addWidget( label, 4, 0 ); + grid->addWidget( comboRotation, 4, 1 ); + grid->addMultiCellWidget( checkMirrorH, 5, 5, 0, 1 ); + grid->addMultiCellWidget( checkMirrorV, 6, 6, 0, 1 ); + + connect( radioImageExpression, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioImagePath, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( buttonToken, SIGNAL( clicked() ), this, SLOT( slotTokens() ) ); +} + +void PropertyImage::applySettings( DocumentItem* item, KMacroCommand* command ) +{ + ImageItem* img = static_cast<ImageItem*>(item); + EImageScaling scaling = eImage_Original; + double rot = 0.0; + QPixmap pix; + + if( radioImagePath->isChecked() ) + { + if( !imgUrl->url().isEmpty() ) + { + if( !pix.load( imgUrl->url() ) ) + KMessageBox::error( NULL, QString( i18n("Image format not supported for file: %1") ).arg( imgUrl->url() ) ); + } + else + { + pix = img->pixmap(); + } + } + + if( radioZoomed->isChecked() ) + scaling = eImage_Zoomed; + else if( radioScaled->isChecked() ) + scaling = eImage_Scaled; + + if( comboRotation->currentItem() == 1 ) + rot = 90.0; + else if( comboRotation->currentItem() == 2 ) + rot = 180.0; + else if( comboRotation->currentItem() == 3 ) + rot = 270.0; + + PictureCommand* pc = new PictureCommand( rot, checkMirrorH->isChecked(), checkMirrorV->isChecked(), scaling, img ); + pc->setExpression( radioImageExpression->isChecked() ? imgExpression->text() : QString::null ); + pc->setPixmap( pix ); + pc->execute(); + command->addCommand( pc ); +} + +void PropertyImage::initSettings( DocumentItem* item ) +{ + ImageItem* img = static_cast<ImageItem*>(item); + QString expr = img->expression(); + + if( !expr.isEmpty() ) + { + radioImageExpression->setChecked( true ); + imgExpression->setText( expr ); + } + else + { + // imgUrl->setURL( IMAGE_INTERNAL ); + radioImagePath->setChecked( true ); + } + + switch( img->scaling() ) + { + default: + case eImage_Original: + radioOriginal->setChecked( true ); + break; + case eImage_Scaled: + radioScaled->setChecked( true ); + break; + case eImage_Zoomed: + radioZoomed->setChecked( true ); + break; + } + + if( img->rotation() == 0.0 ) + comboRotation->setCurrentItem( 0 ); + else if( img->rotation() == 90.0 ) + comboRotation->setCurrentItem( 1 ); + else if( img->rotation() == 180.0 ) + comboRotation->setCurrentItem( 2 ); + else if( img->rotation() == 270.0 ) + comboRotation->setCurrentItem( 3 ); + + checkMirrorH->setChecked( img->mirrorHorizontal() ); + checkMirrorV->setChecked( img->mirrorVertical() ); + + + enableControls(); +} + +void PropertyImage::enableControls() +{ + imgHBox->setEnabled( radioImageExpression->isChecked() ); + imgUrl->setEnabled( radioImagePath->isChecked() ); +} + +void PropertyImage::slotTokens() +{ + TokenDialog tokendlg( m_token, this, "tokendlg" ); + if( tokendlg.exec() == QDialog::Accepted ) + imgExpression->insert( tokendlg.token() ); +} + +PropertyVisible::PropertyVisible( QWidget* parent ) + : PropertyWidget( parent ) +{ + QLabel* label = new QLabel( i18n("Evaluate JavsScript code to define the visibility of this item:"), this ); + m_script = new KTextEdit( this ); + + grid->addWidget( label, 0, 0 ); + grid->addMultiCellWidget( m_script, 1, 8, 0, 2 ); +} + +void PropertyVisible::applySettings( DocumentItem* item, KMacroCommand* command ) +{ + TCanvasItem* canvasItem = item->canvasItem(); + ScriptCommand* sc = new ScriptCommand( m_script->text(), canvasItem ); + sc->execute(); + command->addCommand( sc); +} + +void PropertyVisible::initSettings( DocumentItem* item ) +{ + m_script->setText( item->visibilityScript() ); +} + +#include "propertywidget.moc" diff --git a/kbarcode/propertywidget.h b/kbarcode/propertywidget.h new file mode 100644 index 0000000..bc2ea78 --- /dev/null +++ b/kbarcode/propertywidget.h @@ -0,0 +1,210 @@ +/*************************************************************************** + propertywidget.h - description + ------------------- + begin : Do Sep 10 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#ifndef PROPERTYWIDGET_H +#define PROPERTYWIDGET_H + +#include <qwidget.h> +#include "labelutils.h" + +class BarcodeWidget; +class DocumentItem; +class KColorButton; +class KComboBox; +class KIntNumInput; +class KDoubleNumInput; +class KMacroCommand; +class KTextEdit; +class MultiLineEditor; +class QCheckBox; +class QGridLayout; +class QRadioButton; +//NY23 +class TextLineEditor; +//NY23 +class TokenProvider; + +class QHBox; +class KURLRequester; +class KLineEdit; +class KPushButton; + +/** +@author Dominik Seichter +*/ +class PropertyWidget : public QWidget +{ + Q_OBJECT + public: + PropertyWidget( QWidget* parent ); + + virtual void applySettings( DocumentItem* item, KMacroCommand* command ) = 0; + virtual void initSettings( DocumentItem* item ) = 0; + + protected: + QGridLayout* grid; +}; + +class PropertyBorder : public PropertyWidget { + Q_OBJECT + public: + PropertyBorder( QWidget* parent ); + + virtual void applySettings( DocumentItem* item, KMacroCommand* command ); + virtual void initSettings( DocumentItem* item ); + + private slots: + void enableControls(); + + private: + KColorButton* buttonColor; + KComboBox* comboLine; + KIntNumInput* spinWidth; + QCheckBox* checkBorder; +}; + +class PropertyRotation : public PropertyWidget { + Q_OBJECT + public: + PropertyRotation( QWidget* parent ); + + virtual void applySettings( DocumentItem* item, KMacroCommand* command ); + virtual void initSettings( DocumentItem* item ); + + private: + KComboBox* comboRotation; +}; + +class PropertyFill : public PropertyWidget { + Q_OBJECT + public: + PropertyFill( QWidget* parent ); + + virtual void applySettings( DocumentItem* item, KMacroCommand* command ); + virtual void initSettings( DocumentItem* item ); + + private: + KColorButton* buttonColor; +}; + +class PropertyBarcode : public PropertyWidget, private LabelUtils { + Q_OBJECT + public: + PropertyBarcode( TokenProvider* token, QWidget* parent ); + + virtual void applySettings( DocumentItem* item, KMacroCommand* command ); + virtual void initSettings( DocumentItem* item ); + + private slots: + void changedCombo(); + + private: + KComboBox* comboComplex; + BarcodeWidget* barcode; +}; + +class PropertyText : public PropertyWidget, private LabelUtils { + Q_OBJECT + public: + PropertyText( TokenProvider* token, QWidget* parent ); + + virtual void applySettings( DocumentItem* item, KMacroCommand* command ); + virtual void initSettings( DocumentItem* item ); + + private: + MultiLineEditor* m_editor; +}; + +//NY22 +class PropertyTextLine : public PropertyWidget, private LabelUtils { + Q_OBJECT + public: + PropertyTextLine( TokenProvider* token, QWidget* parent ); + + virtual void applySettings( DocumentItem* item, KMacroCommand* command ); + virtual void initSettings( DocumentItem* item ); + + private: + TextLineEditor* m_editor; +}; +//NY22 + +class PropertySize : public PropertyWidget, private LabelUtils { + Q_OBJECT + public: + PropertySize( QWidget* parent ); + + virtual void applySettings( DocumentItem* item, KMacroCommand* command ); + virtual void initSettings( DocumentItem* item ); + + private slots: + void enableControls(); + + private: + QCheckBox* checkLock; + KDoubleNumInput* numTop; + KDoubleNumInput* numLeft; + KDoubleNumInput* numWidth; + KDoubleNumInput* numHeight; +}; + +class PropertyImage : public PropertyWidget { + Q_OBJECT + public: + PropertyImage( TokenProvider* token, QWidget* parent ); + + virtual void applySettings( DocumentItem* item, KMacroCommand* command ); + virtual void initSettings( DocumentItem* item ); + + private slots: + void enableControls(); + void slotTokens(); + + private: + TokenProvider* m_token; + + QCheckBox* checkMirrorH; + QCheckBox* checkMirrorV; + + QHBox* imgHBox; + + KComboBox* comboRotation; + KURLRequester* imgUrl; + KLineEdit* imgExpression; + KPushButton* buttonToken; + + QRadioButton* radioImagePath; + QRadioButton* radioImageExpression; + + QRadioButton* radioOriginal; + QRadioButton* radioScaled; + QRadioButton* radioZoomed; +}; + +class PropertyVisible : public PropertyWidget { + Q_OBJECT + public: + PropertyVisible( QWidget* parent ); + + virtual void applySettings( DocumentItem* item, KMacroCommand* command ); + virtual void initSettings( DocumentItem* item ); + + private: + KTextEdit* m_script; +}; + +#endif diff --git a/kbarcode/purepostscript.cpp b/kbarcode/purepostscript.cpp new file mode 100644 index 0000000..0b543e6 --- /dev/null +++ b/kbarcode/purepostscript.cpp @@ -0,0 +1,240 @@ +/*************************************************************************** + purepostscript.cpp - description + ------------------- + begin : Mon Jan 2 2006 + copyright : (C) 2006 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "purepostscript.h" +#include "barkode.h" + +#include <stdlib.h> + +#include <qdom.h> +#include <qfile.h> +#include <qtextstream.h> + +#include <kstandarddirs.h> +#include <ktempfile.h> + +#define MAX_LINE_LENGTH 256 +#define BEGIN_TEMPLATE "--BEGIN TEMPLATE--" +#define END_TEMPLATE "--END TEMPLATE--" + +QString PurePostscriptBarcode::s_path = QString::null; + +PurePostscriptOptions::PurePostscriptOptions() + : BarkodeEngineOptions() +{ + defaults(); +} + +const BarkodeEngineOptions& PurePostscriptOptions::operator=( const BarkodeEngineOptions& rhs ) +{ + const PurePostscriptOptions* ps = (dynamic_cast<const PurePostscriptOptions*>(&rhs)); + + m_check = ps->m_check; + + return *this; +} + +void PurePostscriptOptions::defaults() +{ + m_check = false; +} + +void PurePostscriptOptions::load( const QDomElement* tag ) +{ + m_check = (bool)tag->attribute( "pure.check", "0" ).toInt(); +} + +void PurePostscriptOptions::save( QDomElement* tag ) +{ + tag->setAttribute( "pure.check", (int)m_check ); +} + +PurePostscriptBarcode::PurePostscriptBarcode() + : PixmapBarcode() +{ + bool append = false; + QString line; + + if( s_path.isNull() ) + { + qDebug( "Cannot locate barcode writer in pure postscript." ); + return; + } + + QFile pureFile( s_path ); + if( pureFile.open( IO_ReadOnly ) ) + { + while( pureFile.readLine( line, MAX_LINE_LENGTH ) != -1 ) + { + if( append ) + { + if( line.contains( END_TEMPLATE ) ) + break; + + m_program.append( line ); + } + + if( !append && line.contains( BEGIN_TEMPLATE ) ) + append = true; + } + pureFile.close(); + } +} + +PurePostscriptBarcode::~PurePostscriptBarcode() +{ +} + +void PurePostscriptBarcode::init() +{ + if( s_path.isNull() ) + { + // first look at the default location + const char* default_barcode = "/usr/share/libpostscriptbarcode/barcode.ps"; + if( QFile::exists( default_barcode ) ) + s_path = default_barcode; + else + s_path = locate( "data", "kbarcode/barcode.ps" ); + } + + if( !QFile::exists( s_path ) ) + s_path = QString::null; +} + +#define START_TOKEN "% --" +#define BEGIN_ENCODER "BEGIN ENCODER " +#define DESCRIPTION "DESC: " +#define EXAMPLE "EXAM: " + +void PurePostscriptBarcode::initInfo( TBarcodeInfoList* info ) +{ + PurePostscriptBarcode::init(); + + QFile pureFile( s_path ); + if( pureFile.open( IO_ReadOnly ) ) + { + QString encoder; + QString description; + QString example; + QString line; + + while( pureFile.readLine( line, MAX_LINE_LENGTH ) != -1 ) + { + /* + % --BEGIN ENCODER ean13-- + % --DESC: EAN-13 + % --EXAM: 977147396801 + */ + + if( line.startsWith( START_TOKEN ) ) + { + // remove all whitespaces on the line ending (and '-') + line = line.stripWhiteSpace(); + + line = line.right( line.length() - QString( START_TOKEN ).length() ); + if( line.startsWith( BEGIN_ENCODER ) ) + { + encoder = line.right( line.length() - QString( BEGIN_ENCODER ).length() ); + + if( encoder.endsWith( "--" ) ) + encoder = encoder.left( encoder.length() - 2 ); + } + else if( line.startsWith( DESCRIPTION ) ) + description = line.right( line.length() - QString( DESCRIPTION ).length() ); + else if( line.startsWith( EXAMPLE ) ) + { + example = line.right( line.length() - QString( EXAMPLE ).length() ); + + // we should have a complete encoder now. + info->append( Barkode::createInfo( QString("ps_") + encoder, description, PURE_POSTSCRIPT, PUREADV | COLORED ) ); + } + } + } + pureFile.close(); + } +} + +bool PurePostscriptBarcode::hasPurePostscriptBarcode() +{ + return !s_path.isNull(); +} + +void PurePostscriptBarcode::createProgram( QString & prg ) +{ + const PurePostscriptOptions* options = (dynamic_cast<const PurePostscriptOptions*>(barkode->engine()->options())); + QString type = barkode->type().right( barkode->type().length() - 3 ); + QString opt; + + opt.sprintf( "%s %s barcolor=%02X%02X%02X showbackground backgroundcolor=%02X%02X%02X textcolor=%02X%02X%02X", + barkode->textVisible() ? "includetext" : "", + options && options->checksum() ? "includecheck" : "", + barkode->foreground().red(), barkode->foreground().green(), barkode->foreground().blue(), + barkode->background().red(), barkode->background().green(), barkode->background().blue(), + barkode->textColor().red(), barkode->textColor().green(), barkode->textColor().blue() + ); + + prg = "%!PS-Adobe-2.0 EPSF-2.0\n%%EndComments\n%%EndProlog\n"; + prg += m_program; + prg += QString("20 20 moveto\n(%1) (%2) %3 barcode\n") + .arg( barkode->parsedValue() ) + .arg( opt ).arg( type ); +} + +QRect PurePostscriptBarcode::bbox( const char* postscript, long postscript_size ) +{ + const char* gs_bbox = "gs -sDEVICE=bbox -sNOPAUSE -q %1 -c showpage quit 2>&1"; + + char* buffer = NULL; + long len = 0; + QRect size; + + KTempFile psfile( QString::null, ".ps" ); + psfile.file()->writeBlock( postscript, postscript_size ); + psfile.file()->close(); + + if( !readFromPipe( QString( gs_bbox ).arg( psfile.file()->name() ).latin1(), &buffer, &len ) || !len ) + { + psfile.unlink(); + return QRect( 0, 0, 0, 0 ); + } + else + psfile.unlink(); + + size = PixmapBarcode::bbox( buffer, len ); + free( buffer ); + + return size; +} + +bool PurePostscriptBarcode::createPostscript( char** postscript, long* postscript_size ) +{ + QString cmd; + + if( m_program.isEmpty() ) + return false; + + createProgram( cmd ); + + *postscript_size = cmd.length(); + *postscript = (char*)malloc( sizeof(char) * *postscript_size ); + if( !*postscript ) + return false; + + memcpy( *postscript, cmd.latin1(), *postscript_size ); + + return true; +} diff --git a/kbarcode/purepostscript.h b/kbarcode/purepostscript.h new file mode 100644 index 0000000..406fbc9 --- /dev/null +++ b/kbarcode/purepostscript.h @@ -0,0 +1,90 @@ +/*************************************************************************** + purepostscript.h - description + ------------------- + begin : Mon Jan 2 2006 + copyright : (C) 2006 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#ifndef PURE_POSTSCRIPT_H +#define PURE_POSTSCRIPT_H + +#include "pixmapbarcode.h" +#include "barkode.h" + +#include <qcstring.h> + +class PurePostscriptOptions : public BarkodeEngineOptions { + public: + PurePostscriptOptions(); + + const BarkodeEngineOptions& operator=( const BarkodeEngineOptions & ps ); + void defaults(); + + void load( const QDomElement* tag ); + void save( QDomElement* tag ); + + inline bool checksum() const { return m_check; } + inline void setChecksum( bool b ) { m_check = b; } + + private: + bool m_check; +}; + +class PurePostscriptBarcode : public PixmapBarcode { + public: + PurePostscriptBarcode(); + ~PurePostscriptBarcode(); + + /** Initialize PurePostscriptBarcode and set the path to + * the postscript program file or to QString::null if it cannot be found + */ + static void init(); + + static void initInfo( TBarcodeInfoList* info ); + + static bool hasPurePostscriptBarcode(); + + inline EEngine engine() const; + + inline BarkodeEngineOptions* options(); + + private: + virtual bool createPostscript( char** postscript, long* postscript_size ); + virtual QRect bbox( const char* postscript, long postscript_size ); + + /** Create a program which can be executed by ghostscript from + * m_program and the barcodes data. + * \param prg the program will be written to this string + */ + void createProgram( QString & prg ); + + private: + PurePostscriptOptions m_options; + + QString m_program; + + static QString s_path; +}; + +EEngine PurePostscriptBarcode::engine() const +{ + return PURE_POSTSCRIPT; +} + +BarkodeEngineOptions* PurePostscriptBarcode::options() +{ + return &m_options; +} + +#endif /* PURE_POSTSCRIPT_H */ diff --git a/kbarcode/rectitem.cpp b/kbarcode/rectitem.cpp new file mode 100644 index 0000000..4fe2e84 --- /dev/null +++ b/kbarcode/rectitem.cpp @@ -0,0 +1,159 @@ +/*************************************************************************** + rectitem.cpp - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#include "rectitem.h" + +#include <qdom.h> +#include <qpainter.h> + +RectItem::RectItem() + : DocumentItem() +{ + init(); +} + +void RectItem::loadXML (QDomElement* element) +{ + DocumentItem::loadXML( element ); + + m_color = readXMLColor( element, "fill-color", Qt::white ); + m_filled = element->attribute( "filled", "0" ).toInt(); + m_circle = element->attribute( "circle", "0" ).toInt(); +} + +void RectItem::saveXML (QDomElement* element) +{ + DocumentItem::saveXML( element ); + + writeXMLColor( element, "fill-color", m_color ); + element->setAttribute( "filled", m_filled ); + element->setAttribute( "circle", m_circle ); +} + +void RectItem::draw (QPainter* painter) +{ + if( m_circle ) + { + if( m_filled ) + { + painter->save(); + painter->setPen( QPen( Qt::NoPen ) ); + painter->setBrush( m_color ); + painter->drawEllipse( rect() ); + painter->restore(); + } + + if( border() ) + { + painter->save(); + painter->setPen( pen() ); + painter->drawEllipse( rect() ); + painter->restore(); + } + } + else + { + if( m_filled ) + painter->fillRect( rect(), m_color ); + + DocumentItem::drawBorder( painter ); + } +} + +void RectItem::drawZpl( QTextStream* stream ) +{ + // TODO: refactor later and respect millimeters + int thick = pen().width(); + + *stream << ZPLUtils::fieldOrigin( rect().x(), rect().y() ); + if( m_circle ) + *stream << QString("~GE%1,%2,%3,B").arg( rect().width() ).arg( rect().height() ).arg( thick ); + else + *stream << QString("~GB%1,%2,%3,B,0").arg( rect().width() ).arg( rect().height() ).arg( thick ); +} + +void RectItem::drawIpl( QTextStream* stream, IPLUtils* utils ) +{ + // TODO: refactor later and respect millimeters + int thick = pen().width(); + + if( m_circle ) + qDebug("Cirlce not implemented for IPL"); + else + { + int counter = utils->counter(); + + QString s = QString("W%1;").arg( counter ); // field number + + s += utils->fieldOrigin( rect().x(), rect().y() ); + s += QString("l%1;").arg( rect().width() ); // box length + s += QString("h%1;").arg( rect().height() ); // box height + s += QString("w%1;").arg( thick ); + + *stream << utils->field( s ); + } +} + +void RectItem::drawEPcl( QTextStream* stream ) +{ + QString s = QString("C %1").arg( rect().x()+1 ); + s += QString(" %1").arg( rect().y()+1 ); + s += QString(" %1").arg( rect().width() ); + s += QString(" %1").arg( rect().height() ); + s += QString(" %1 2").arg( pen().width() ); + + *stream << EPCLUtils::field( s ); +} + +void RectItem::init() +{ + m_color = Qt::white; + m_filled = true; + m_circle = false; + setRect( QRect( 0, 0, 20, 20 ) ); +} + +void RectItem::setColor (const QColor & c) +{ + m_color = c; +} + +QColor RectItem::color () const +{ + return m_color; +} + +void RectItem::setFilled (bool f) +{ + m_filled = f; +} + +bool RectItem::filled () const +{ + return m_filled; +} + +void RectItem::setCircle (bool b) +{ + m_circle = b; +} + +bool RectItem::circle () const +{ + return m_circle; +} + diff --git a/kbarcode/rectitem.h b/kbarcode/rectitem.h new file mode 100644 index 0000000..c820db2 --- /dev/null +++ b/kbarcode/rectitem.h @@ -0,0 +1,71 @@ +/*************************************************************************** + rectitem.h - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#ifndef RECTITEM_H +#define RECTITEM_H +#include <qstring.h> +#include "documentitem.h" +#include "qcolor.h" + +/** + * Class RectItem + * A rectangle or elipse. + */ +class RectItem : public DocumentItem { +public: + RectItem ( ); + + int rtti() const { return eRtti_Rect; } + /** + * + * @param c + */ + void setColor (const QColor & c=Qt::black); + QColor color () const; + + + /** + * + * @param f + */ + void setFilled (bool f=true); + bool filled () const; + + /** + * + * @param b + */ + void setCircle (bool b=false); + bool circle () const; + + void loadXML (QDomElement* element); + void saveXML (QDomElement* element); + void draw (QPainter* painter); + void drawZpl( QTextStream* stream ); + void drawIpl( QTextStream* stream, IPLUtils* utils ); + void drawEPcl( QTextStream* stream ); + +private: + void init(); + +private: + bool m_circle; + bool m_filled; + QColor m_color; +}; +#endif //RECTITEM_H + diff --git a/kbarcode/rectsettingsdlg.cpp b/kbarcode/rectsettingsdlg.cpp new file mode 100644 index 0000000..7cb112a --- /dev/null +++ b/kbarcode/rectsettingsdlg.cpp @@ -0,0 +1,183 @@ +/*************************************************************************** + rectsettingsdlg.cpp - description + ------------------- + begin : Mit Jun 18 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "rectsettingsdlg.h" + +// Qt includes +#include <qcheckbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qpainter.h> +#include <qpen.h> + +// KDE includes +#include <kcolorbutton.h> +#include <kcombobox.h> +#include <klocale.h> +#include <knuminput.h> + +void fillLineCombo( KComboBox* box ) +{ + /* A small helper function to fill + * a combobox with all by Qt + * supported pen styles. + */ + + QPainter p; + for( int i = 1; i < 6; i++ ) { + QPixmap pixmap( 60, 20 ); + pixmap.fill( Qt::white ); + p.begin( &pixmap ); + p.setPen( QPen( Qt::black, 3, (Qt::PenStyle)i ) ); + p.drawLine( 5, 10, 55, 10 ); + p.end(); + + box->insertItem( pixmap ); + } +} + +RectSettingsDlg::RectSettingsDlg(QWidget *parent, const char *name ) + : KDialogBase( KDialogBase::Plain, i18n("Settings"), + KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, parent,name) +{ + QFrame* frame = plainPage(); + QGridLayout* grid = new QGridLayout( frame, 6, 6 ); + QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + + + buttonBorder = new KColorButton( frame ); + buttonFill = new KColorButton( frame ); + + spinWidth = new KIntNumInput( frame ); + spinWidth->setRange( 1, 100, 1, false ); + + comboLine = new KComboBox( false, frame ); + fillLineCombo( comboLine ); + + checkBorder = new QCheckBox( i18n("&Enable Border"), frame ); + + grid->addWidget( new QLabel( i18n("Fill Color:"), frame ), 0, 0 ); + grid->addWidget( buttonFill, 0, 1 ); + grid->addItem( spacer, 1, 0 ); + grid->addWidget( checkBorder, 2, 0 ); + grid->addWidget( new QLabel( i18n("Border Color:"), frame ), 3, 0 ); + grid->addWidget( buttonBorder, 3, 1 ); + grid->addWidget( new QLabel( i18n("Border Width:"), frame ), 4, 0 ); + grid->addWidget( spinWidth, 4, 1 ); + grid->addWidget( new QLabel( i18n("Line Style:"), frame ), 5, 0 ); + grid->addWidget( comboLine, 5, 1 ); + + connect( checkBorder, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); +} + +RectSettingsDlg::~RectSettingsDlg() +{ +} + +void RectSettingsDlg::enableControls() +{ + buttonBorder->setEnabled( checkBorder->isChecked() ); + spinWidth->setEnabled( checkBorder->isChecked() ); + comboLine->setEnabled( checkBorder->isChecked() ); +} + +void RectSettingsDlg::setBorderColor( const QColor & c ) +{ + buttonBorder->setColor( c ); +} + +void RectSettingsDlg::setFillColor( const QColor & c ) +{ + buttonFill->setColor( c ); +} + +void RectSettingsDlg::setBorderWidth( int w ) +{ + spinWidth->setValue( w ); +} + +void RectSettingsDlg::setPenStyle( int s ) +{ + if( s ) { + comboLine->setCurrentItem( s - 1 ); + checkBorder->setChecked( true ); + } else + checkBorder->setChecked( false ); + + enableControls(); +} + +const QColor RectSettingsDlg::borderColor() const +{ + return buttonBorder->color(); +} + +const QColor RectSettingsDlg::fillColor() const +{ + return buttonFill->color(); +} + +int RectSettingsDlg::borderWidth() const +{ + return spinWidth->value(); +} + +int RectSettingsDlg::penStyle() const +{ + return checkBorder->isChecked() ? comboLine->currentItem() + 1 : 0; +} + +LineSettingsDlg::LineSettingsDlg(QWidget *parent, const char *name ) + : KDialogBase( KDialogBase::Plain, i18n("Settings"), + KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, parent,name) +{ + QFrame* frame = plainPage(); + QGridLayout* grid = new QGridLayout( frame, 6, 6 ); + + buttonColor = new KColorButton( frame ); + + spinWidth = new KIntNumInput( frame ); + spinWidth->setRange( 1, 100, 1, false ); + + comboLine = new KComboBox( false, frame ); + fillLineCombo( comboLine ); + + grid->addWidget( new QLabel( i18n("Color:"), frame ), 0, 0 ); + grid->addWidget( buttonColor, 0, 1 ); + grid->addWidget( new QLabel( i18n("Line Width:"), frame ), 1, 0 ); + grid->addWidget( spinWidth, 1, 1 ); + grid->addWidget( new QLabel( i18n("Line Style:"), frame ), 2, 0 ); + grid->addWidget( comboLine, 2, 1 ); +} + +LineSettingsDlg::~LineSettingsDlg() +{ +} + +QPen LineSettingsDlg::pen() const +{ + return QPen( buttonColor->color(), spinWidth->value(), (Qt::PenStyle)(comboLine->currentItem() + 1) ); +} + +void LineSettingsDlg::setPen( const QPen p ) +{ + buttonColor->setColor( p.color() ); + spinWidth->setValue( p.width() ); + comboLine->setCurrentItem( p.style() - 1 ); +} + +#include "rectsettingsdlg.moc" diff --git a/kbarcode/rectsettingsdlg.h b/kbarcode/rectsettingsdlg.h new file mode 100644 index 0000000..5bcd5f4 --- /dev/null +++ b/kbarcode/rectsettingsdlg.h @@ -0,0 +1,71 @@ +/*************************************************************************** + rectsettingsdlg.h - description + ------------------- + begin : Mit Jun 18 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef RECTSETTINGSDLG_H +#define RECTSETTINGSDLG_H + +#include <kdialogbase.h> + +class KColorButton; +class KComboBox; +class KIntNumInput; +class QCheckBox; +class RectSettingsDlg : public KDialogBase { + Q_OBJECT + public: + RectSettingsDlg(QWidget *parent=0, const char *name=0); + ~RectSettingsDlg(); + + void setBorderColor( const QColor & c ); + void setFillColor( const QColor & c ); + void setBorderWidth( int w ); + void setPenStyle( int s ); + + const QColor borderColor() const; + const QColor fillColor() const; + int borderWidth() const; + int penStyle() const; + + private slots: + void enableControls(); + + private: + KColorButton* buttonBorder; + KColorButton* buttonFill; + + KComboBox* comboLine; + QCheckBox* checkBorder; + + KIntNumInput* spinWidth; +}; + +class QPen; +class LineSettingsDlg : public KDialogBase { + Q_OBJECT + public: + LineSettingsDlg(QWidget *parent=0, const char *name=0); + ~LineSettingsDlg(); + + void setPen( const QPen p ); + QPen pen() const; + + private: + KColorButton* buttonColor; + KComboBox* comboLine; + KIntNumInput* spinWidth; +}; +#endif diff --git a/kbarcode/referencecounted.cpp b/kbarcode/referencecounted.cpp new file mode 100644 index 0000000..8759ffc --- /dev/null +++ b/kbarcode/referencecounted.cpp @@ -0,0 +1,23 @@ + +/*************************************************************************** + referencecounted.cpp - description + ------------------- + begin : Mo Apr 18 2005 + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#include "referencecounted.h" + + + + diff --git a/kbarcode/referencecounted.h b/kbarcode/referencecounted.h new file mode 100644 index 0000000..684cd21 --- /dev/null +++ b/kbarcode/referencecounted.h @@ -0,0 +1,64 @@ +/*************************************************************************** + referencecounted.h - description + ------------------- + begin : Mo Apr 18 2005 + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#ifndef REFERENCE_COUNTED_H +#define REFERENCE_COUNTED_H + +/** + * A class to make objects reference counted. + * Most likely you will want to subclass this class. + * @see TCanvasItem for an example. + * + * Whenever you get a reference to a ReferenceCounted + * object, call addRef(). Whenever you do not need + * the object anymore, call remRef(). + * + * When the reference count reaches 0, the object + * deletes itself. + */ + + +class ReferenceCounted { + public: + ReferenceCounted():m_counter(0) {} + virtual ~ReferenceCounted() {} + + inline void addRef() + { + m_counter++; + } + + + inline void remRef() + { + if(--m_counter == 0) delete this; + } + + + inline unsigned int refCount() + { + return m_counter; + } + + private: + unsigned int m_counter; + +}; + +#endif // REFERENCE_COUNTED_H + + diff --git a/kbarcode/rules.xml b/kbarcode/rules.xml new file mode 100644 index 0000000..0c75828 --- /dev/null +++ b/kbarcode/rules.xml @@ -0,0 +1,159 @@ +<?xml version="1.0"?> + +<encoders> + +<encoder id="ean13"> +<pattern sense="false" exception="Accepts only numeric data"><![CDATA[ +[^0-9] +]]></pattern> +<pattern sense="true" exception="Data must be 12 or 13 digits"><![CDATA[ +^.{12,13}$ +]]></pattern> +</encoder> + +<encoder id="ean8"> +<pattern sense="false" exception="Accepts only numeric data"><![CDATA[ +[^0-9] +]]></pattern> +<pattern sense="true" exception="Data must be precisely 8 digits"><![CDATA[ +^.{8}$ +]]></pattern> +</encoder> + +<encoder id="ean5"> +<pattern sense="false" exception="Accepts only numeric data"><![CDATA[ +[^0-9] +]]></pattern> +<pattern sense="true" exception="Data must be precisely 5 digits"><![CDATA[ +^.{5}$ +]]></pattern> +</encoder> + +<encoder id="ean2"> +<pattern sense="false" exception="Accepts only numeric data"><![CDATA[ +[^0-9] +]]></pattern> +<pattern sense="true" exception="Data must be precisely 2 digits"><![CDATA[ +^.{2}$ +]]></pattern> +</encoder> + +<encoder id="upca"> +<pattern sense="false" exception="Accepts only numeric data"><![CDATA[ +[^0-9] +]]></pattern> +<pattern sense="true" exception="Data must be 11 or 12 digits"><![CDATA[ +^.{11,12}$ +]]></pattern> +</encoder> + +<encoder id="upce"> +<pattern sense="false" exception="Accepts only numeric data"><![CDATA[ +[^0-9] +]]></pattern> +<pattern sense="true" exception="Data must be 7 or 8 digits"><![CDATA[ +^.{7,8}$ +]]></pattern> +</encoder> + +<encoder id="isbn"> +<pattern sense="false" exception="Accepts digits and the dash (-) character"><![CDATA[ +[^0-9\-] +]]></pattern> +</encoder> + +<encoder id="code128"> +<pattern sense="false" exception="Accepts mixed-case letters, digits, symbols !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ and space"><![CDATA[ +[^\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/0123456789\:\;\<\=\>\?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]\^\_\`abcdefghijklmnopqrstuvwxyz\{\|\}\~] +]]></pattern> + +<pattern sense="true" exception="Must begin either ^103, ^104 or ^105"><![CDATA[ +^(\^103|\^104|\^105) +]]></pattern> +<pattern sense="false" exception="After ^105 or ^099 digits must be paired"><![CDATA[ +(\^105|\^099)[0-9]([0-9][0-9])*(\^|$) +]]></pattern> +<pattern sense="false" exception="The carat (^) character must be followed by a three digit ordinal value"><![CDATA[ +\^[0-9]{0,2}([^0-9]|$) +]]></pattern> +</encoder> + +<encoder id="code39"> +<pattern sense="false" exception="Valid characters are the capital letters A-Z, digits 0-9, and symbols -.$/+%* and space"><![CDATA[ +[^A-Z0-9\-\.\$\/+%\*\ ] +]]></pattern> +</encoder> + +<encoder id="code93"> +<pattern sense="false" exception="Valid characters are the capital letters A-Z, digits 0-9, and symbols -.$/+%* space and ordinals"><![CDATA[ +[^A-Z0-9\-\.\$\/+%\*\ \^] +]]></pattern> +<pattern sense="false" exception="The carat (^) character must be followed by a three digit ordinal value"><![CDATA[ +\^[0-9]{0,2}([^0-9]|$) +]]></pattern> +</encoder> + +<encoder id="interleaved2of5"> +<pattern sense="false" exception="Accepts numeric data only"><![CDATA[ +[^0-9] +]]></pattern> +</encoder> + +<encoder id="code2of5"> +<pattern sense="false" exception="Accepts numeric data only"><![CDATA[ +[^0-9] +]]></pattern> +</encoder> + +<encoder id="code11"> +<pattern sense="false" exception="Accepts digits and the dash (-) character"><![CDATA[ +[^0-9\-] +]]></pattern> +</encoder> + +<encoder id="rationalizedCodabar"> +<pattern sense="false" exception="Valid characters are digits 0-9, letters A-D and the symbols -$:/.+"><![CDATA[ +[^0-9A-D\-\$\:\/\.+] +]]></pattern> +</encoder> + +<encoder id="postnet"> +<pattern sense="false" exception="Valid characters are digits from the ZIP code without dashes"><![CDATA[ +[^0-9] +]]></pattern> +</encoder> + +<encoder id="royalmail"> +<pattern sense="false" exception="Valid characters are digits 0-9 and capital letters A-Z"><![CDATA[ +[^0-9A-Z] +]]></pattern> +</encoder> + +<encoder id="auspost"> +<pattern sense="true" exception="Valid characters are digits 0-9, mixed-case letters A-Z, space and the hash (#) character"><![CDATA[ +[^0-9A-Za-z\ \#] +]]></pattern> +</encoder> + +<encoder id="kix"> +<pattern sense="true" exception="Valid characters are digits 0-9, letters A-D and the symbols -$:/.+"><![CDATA[ +[^0-9A-D\-\$\:\/\.+] +]]></pattern> +</encoder> + +<encoder id="msi"> +<pattern sense="true" exception="Valid characters are digits 0-9, letters A-D and the symbols -$:/.+"><![CDATA[ +[^0-9A-D\-\$\:\/\.+] +]]></pattern> +</encoder> + +<encoder id="plessey"> +<pattern sense="true" exception="Valid characters are digits 0-9, letters A-D and the symbols -$:/.+"><![CDATA[ +[^0-9A-D\-\$\:\/\.+] +]]></pattern> +</encoder> + +<encoder id="symbol"> +</encoder> + +</encoders> diff --git a/kbarcode/semantic.cache b/kbarcode/semantic.cache new file mode 100644 index 0000000..4e667be --- /dev/null +++ b/kbarcode/semantic.cache @@ -0,0 +1,39 @@ +;; Object kbarcode/ +;; SEMANTICDB Tags save file +(semanticdb-project-database-file "kbarcode/" + :tables (list + (semanticdb-table "barkode.cpp" + :major-mode 'c++-mode + :tags '(("barkode.h" include nil nil [830 850]) ("barkodeengine.h" include nil nil [851 877]) ("gnubarcode.h" include nil nil [878 901]) ("pixmapbarcode.h" include nil nil [902 928]) ("purepostscript.h" include nil nil [929 956]) ("tbarcode2.h" include nil nil [957 979]) ("tokenprovider.h" include nil nil [980 1006]) ("barcode.h" include (:system-flag t) nil [1042 1064]) ("BARCODE_DEFAULT_FLAGS" variable (:constant-flag t :default-value (nil)) nil [1071 1111]) ("BARCODE_ENCODING_MASK" variable (:constant-flag t :default-value (nil)) nil [1113 1153]) ("BARCODE_NO_ASCII" variable (:constant-flag t :default-value (nil)) nil [1182 1222]) ("BARCODE_NO_CHECKSUM" variable (:constant-flag t :default-value (nil)) nil [1252 1292]) ("BARCODE_OUTPUT_MASK" variable (:constant-flag t :default-value (nil)) nil [1327 1367]) ("BARCODE_OUT_EPS" variable (:constant-flag t :default-value (nil)) nil [1393 1433]) ("BARCODE_OUT_PS" variable (:constant-flag t :default-value (nil)) nil [1434 1474]) ("BARCODE_OUT_PCL" variable (:constant-flag t :default-value (nil)) nil [1475 1515]) ("BARCODE_OUT_PCL_III" variable (:constant-flag t :default-value (nil)) nil [1588 1628]) ("BARCODE_OUT_NOHEADERS" variable (:constant-flag t :default-value (nil)) nil [1629 1669]) ("" type (:members (("BARCODE_ANY" variable (:constant-flag t :default-value (1767 1768) :type "int") (reparse-symbol enumsubparts) [1753 1768]) ("BARCODE_EAN" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [1800 1812]) ("BARCODE_UPC" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [1817 1829]) ("BARCODE_ISBN" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [1867 1880]) ("BARCODE_39" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [1924 1935]) ("BARCODE_128" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [1962 1974]) ("BARCODE_128C" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [2024 2037]) ("BARCODE_128B" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [2089 2102]) ("BARCODE_I25" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [2150 2162]) ("BARCODE_128RAW" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [2213 2228]) ("BARCODE_CBR" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [2280 2292]) ("BARCODE_MSI" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [2342 2354]) ("BARCODE_PLS" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [2400 2412]) ("BARCODE_93" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [2462 2519])) :type "enum") nil [1742 2520]) ("qdom.h" include (:system-flag t) nil [2559 2576]) ("qfile.h" include (:system-flag t) nil [2577 2595]) ("qpainter.h" include (:system-flag t) nil [2596 2617]) ("qpicture.h" include (:system-flag t) nil [2618 2639]) ("qpixmap.h" include (:system-flag t) nil [2640 2660]) ("qsize.h" include (:system-flag t) nil [2661 2679]) ("klocale.h" include (:system-flag t) nil [2681 2701]) ("kstandarddirs.h" include (:system-flag t) nil [2702 2728]) ("Barkode::s_info" variable (:type ("QValueList" type (:type "class") nil nil)) nil [2730 2771]) ("Barkode::s_encoding" variable (:pointer 1 :default-value "NULL;" :type ("QStringList" type (:type "class") nil nil)) nil [2772 2814]) ("Barkode::s_haveGnuBarcode" variable (:default-value "false;" :type ("bool" type (:type "class") nil nil)) nil [2815 2858]) ("Barkode::s_havePdfEncode" variable (:default-value "false;" :type ("bool" type (:type "class") nil nil)) nil [2859 2902]) ("Barkode::s_haveTBarcode" variable (:default-value "false;" :type ("bool" type (:type "class") nil nil)) nil [2903 2946]) ("Barkode::s_haveTBarcode2" variable (:default-value "false;" :type ("bool" type (:type "class") nil nil)) nil [2947 2990]) ("Barkode::s_havePurePostscript" variable (:default-value "false;" :type ("bool" type (:type "class") nil nil)) nil [2991 3034]) ("Barkode" function (:constructor-flag t :parent "Barkode" :type ("Barkode" type "class")) nil [3036 3136]) ("Barkode" function (:constructor-flag t :parent "Barkode" :arguments (("barkode" variable (:constant-flag t :type ("Barkode" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [3156 3181])) :type ("Barkode" type "class")) nil [3138 3268]) ("Barkode" function (:destructor-flag t :parent "Barkode" :type "void") nil [3270 3337]) ("setTokenProvider" function (:parent "Barkode" :arguments (("token" variable (:pointer 1 :type ("TokenProvider" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [3371 3393])) :type "void") nil [3339 3418]) ("defaults" function (:parent "Barkode" :type "void") nil [3420 4097]) ("setData" function (:parent "Barkode" :arguments (("barkode" variable (:constant-flag t :type ("Barkode" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [4122 4147])) :type "void") nil [4099 5122]) ("==" function (:parent "Barkode" :arguments (("barkode" variable (:constant-flag t :type ("Barkode" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [5230 5255])) :type ("bool" type (:type "class") nil nil)) nil [5204 5723]) ("picture" function (:parent "Barkode" :constant-flag t :type ("QPicture" type (:type "class") nil nil)) nil [5725 5973]) ("drawInvalid" function (:parent "Barkode" :arguments (("painter" variable (:type ("QPainter" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [6002 6021]) ("x" variable (:type "int") (reparse-symbol arg-sub-list) [6022 6028]) ("y" variable (:type "int") (reparse-symbol arg-sub-list) [6029 6036])) :type "void") nil [5975 6395]) ("size" function (:parent "Barkode" :constant-flag t :type ("QSize" type (:type "class") nil nil)) nil [6397 6490]) ("pixmap" function (:parent "Barkode" :constant-flag t :arguments (("scalex" variable (:type "double") (reparse-symbol arg-sub-list) [6523 6537]) ("scaley" variable (:type "double") (reparse-symbol arg-sub-list) [6538 6553])) :type ("QPixmap" type (:type "class") nil nil)) nil [6492 6898]) ("parsedValue" function (:parent "Barkode" :constant-flag t :type ("QString" type (:type "class") nil nil)) nil [6900 8603]) ("engineForType" function (:parent "Barkode" :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [8637 8659])) :type ("EEngine" type (:type "class") nil nil)) nil [8605 8877]) ("updateEngine" function (:parent "Barkode" :type "void") nil [8879 9790]) ("drawBarcode" function (:parent "Barkode" :arguments (("painter" variable (:type ("QPainter" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [9820 9839]) ("x" variable (:type "int") (reparse-symbol arg-sub-list) [9840 9846]) ("y" variable (:type "int") (reparse-symbol arg-sub-list) [9847 9854])) :type "void") nil [9792 9927]) ("update" function (:parent "Barkode" :arguments (("device" variable (:pointer 1 :constant-flag t :type ("QPaintDevice" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [9951 9979])) :type "void") nil [9929 10038]) ("isValid" function (:parent "Barkode" :type ("bool" type (:type "class") nil nil)) nil [10224 10277]) ("background" function (:parent "Barkode" :constant-flag t :type ("QColor" type (:type "class") nil nil)) nil [10279 10350]) ("foreground" function (:parent "Barkode" :constant-flag t :type ("QColor" type (:type "class") nil nil)) nil [10352 10423]) ("textColor" function (:parent "Barkode" :constant-flag t :type ("QColor" type (:type "class") nil nil)) nil [10425 10494]) ("fontsize" function (:parent "Barkode" :constant-flag t :type "unsigned int") nil [10496 10567]) ("quietZone" function (:parent "Barkode" :constant-flag t :type "unsigned int") nil [10569 10642]) ("barHeight" function (:parent "Barkode" :constant-flag t :type "unsigned int") nil [10644 10718]) ("type" function (:parent "Barkode" :constant-flag t :type ("QString" type (:type "class") nil nil)) nil [10720 10780]) ("value" function (:parent "Barkode" :constant-flag t :type ("QString" type (:type "class") nil nil)) nil [10782 10844]) ("index" function (:parent "Barkode" :constant-flag t :type "unsigned int") nil [10846 10911]) ("sequenceEnabled" function (:parent "Barkode" :constant-flag t :type ("bool" type (:type "class") nil nil)) nil [10913 10983]) ("sequenceMode" function (:parent "Barkode" :constant-flag t :type ("ESequence" type (:type "class") nil nil)) nil [10985 11058]) ("sequenceStart" function (:parent "Barkode" :constant-flag t :type "int") nil [11060 11133]) ("sequenceStep" function (:parent "Barkode" :constant-flag t :type "int") nil [11135 11206]) ("databaseMode" function (:parent "Barkode" :constant-flag t :type ("QString" type (:type "class") nil nil)) nil [11208 11285]) ("textVisible" function (:parent "Barkode" :constant-flag t :type ("bool" type (:type "class") nil nil)) nil [11287 11357]) ("rotation" function (:parent "Barkode" :constant-flag t :type "int") nil [11359 11421]) ("scaling" function (:parent "Barkode" :constant-flag t :type "double") nil [11423 11486]) ("cut" function (:parent "Barkode" :constant-flag t :type "double") nil [11488 11543]) ("datamatrixSize" function (:parent "Barkode" :constant-flag t :type "int") nil [11545 11620]) ("setBackground" function (:parent "Barkode" :arguments (("c" variable (:constant-flag t :type ("QColor" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [11835 11853])) :type "void") nil [11806 11879]) ("setForeground" function (:parent "Barkode" :arguments (("c" variable (:constant-flag t :type ("QColor" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [11910 11928])) :type "void") nil [11881 11954]) ("setTextColor" function (:parent "Barkode" :arguments (("c" variable (:constant-flag t :type ("QColor" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [11984 12002])) :type "void") nil [11956 12027]) ("setFontsize" function (:parent "Barkode" :arguments (("f" variable (:type "unsigned int") (reparse-symbol arg-sub-list) [12056 12072])) :type "void") nil [12029 12096]) ("setQuietZone" function (:parent "Barkode" :arguments (("q" variable (:constant-flag t :type "unsigned int") (reparse-symbol arg-sub-list) [12126 12148])) :type "void") nil [12098 12173]) ("setBarHeight" function (:parent "Barkode" :arguments (("h" variable (:type "unsigned int") (reparse-symbol arg-sub-list) [12203 12219])) :type "void") nil [12175 12245]) ("setType" function (:parent "Barkode" :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [12270 12292])) :type "void") nil [12247 12343]) ("setValue" function (:parent "Barkode" :arguments (("value" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [12369 12392])) :type "void") nil [12345 12417]) ("setIndex" function (:parent "Barkode" :arguments (("i" variable (:constant-flag t :type "unsigned int") (reparse-symbol arg-sub-list) [12443 12465])) :type "void") nil [12419 12486]) ("setSequenceEnabled" function (:parent "Barkode" :arguments (("b" variable (:type ("bool" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [12522 12530])) :type "void") nil [12488 12554]) ("setSequenceMode" function (:parent "Barkode" :arguments (("e" variable (:type ("ESequence" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [12587 12600])) :type "void") nil [12556 12625]) ("setSequenceStart" function (:parent "Barkode" :arguments (("s" variable (:type "int") (reparse-symbol arg-sub-list) [12659 12666])) :type "void") nil [12627 12696]) ("setSequenceStep" function (:parent "Barkode" :arguments (("s" variable (:type "int") (reparse-symbol arg-sub-list) [12729 12736])) :type "void") nil [12698 12765]) ("setDatabaseMode" function (:parent "Barkode" :arguments (("mode" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [12798 12820])) :type "void") nil [12767 12852]) ("setTextVisible" function (:parent "Barkode" :arguments (("b" variable (:constant-flag t :type ("bool" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [12884 12898])) :type "void") nil [12854 12926]) ("setRotation" function (:parent "Barkode" :arguments (("r" variable (:constant-flag t :type "int") (reparse-symbol arg-sub-list) [12955 12968])) :type "void") nil [12928 12992]) ("setScaling" function (:parent "Barkode" :arguments (("d" variable (:constant-flag t :type "double") (reparse-symbol arg-sub-list) [13020 13036])) :type "void") nil [12994 13059]) ("setCut" function (:parent "Barkode" :arguments (("c" variable (:constant-flag t :type "double") (reparse-symbol arg-sub-list) [13083 13099])) :type "void") nil [13061 13118]) ("setDatamatrixSize" function (:parent "Barkode" :arguments (("s" variable (:type "int") (reparse-symbol arg-sub-list) [13153 13160])) :type "void") nil [13120 13191]) ("hasFeature" function (:parent "Barkode" :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [13371 13392]) ("feature" variable (:type "unsigned int") (reparse-symbol arg-sub-list) [13393 13415])) :type ("bool" type (:type "class") nil nil)) nil [13345 13603]) ("internalType" function (:parent "Barkode" :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [13632 13654])) :type "int") nil [13605 13819]) ("encodingTypes" function (:pointer 1 :parent "Barkode" :constant-flag t :type ("QStringList" type (:type "class") nil nil)) nil [13821 14107]) ("typeFromName" function (:pointer 1 :parent "Barkode" :constant-flag t :arguments (("name" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [14144 14166])) :type "char") nil [14109 14326]) ("nameFromType" function (:pointer 1 :parent "Barkode" :constant-flag t :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [14363 14385])) :type "char") nil [14328 14545]) ("validatorFromType" function (:pointer 1 :parent "Barkode" :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [14584 14606])) :type ("QString" type (:type "class") nil nil)) nil [14547 14762]) ("validatorNotFromType" function (:pointer 1 :parent "Barkode" :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [14804 14826])) :type ("QString" type (:type "class") nil nil)) nil [14764 14985]) ("createInfo" function (:parent "Barkode" :arguments (("xml" variable (:pointer 1 :constant-flag t :type "char") (reparse-symbol arg-sub-list) [15021 15037]) ("name" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [15038 15059]) ("engine" variable (:constant-flag t :type ("EEngine" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [15060 15081]) ("features" variable (:constant-flag t :type "unsigned int") (reparse-symbol arg-sub-list) [15115 15143]) ("internal" variable (:constant-flag t :type "int") (reparse-symbol arg-sub-list) [15144 15164])) :type ("tBarcodeInfo" type (:type "class") nil nil)) nil [14987 16059]) ("initInfo" function (:parent "Barkode" :type "void") nil [16061 35789]) ("initValidators" function (:parent "Barkode" :type "void") nil [35791 37608])) + :file "barkode.cpp" + :pointmax 37610 + ) + (semanticdb-table "purepostscript.cpp" + :major-mode 'c++-mode + :tags '(("purepostscript.h" include nil nil [1029 1056]) ("barkode.h" include nil nil [1057 1077]) ("stdlib.h" include (:system-flag t) nil [1079 1098]) ("qdom.h" include (:system-flag t) nil [1100 1117]) ("qfile.h" include (:system-flag t) nil [1118 1136]) ("qtextstream.h" include (:system-flag t) nil [1137 1161]) ("kstandarddirs.h" include (:system-flag t) nil [1163 1189]) ("ktempfile.h" include (:system-flag t) nil [1190 1212]) ("MAX_LINE_LENGTH" variable (:constant-flag t :default-value (nil)) nil [1214 1241]) ("BEGIN_TEMPLATE" variable (:constant-flag t :default-value (nil)) nil [1242 1285]) ("END_TEMPLATE" variable (:constant-flag t :default-value (nil)) nil [1286 1325]) ("PurePostscriptBarcode::s_path" variable (:default-value "QString::null;" :type ("QString" type (:type "class") nil nil)) nil [1327 1381]) ("PurePostscriptOptions" function (:constructor-flag t :parent "PurePostscriptOptions" :type ("PurePostscriptOptions" type "class")) nil [1383 1478]) ("defaults" function (:parent "PurePostscriptOptions" :type "void") nil [1718 1781]) ("load" function (:parent "PurePostscriptOptions" :arguments (("tag" variable (:pointer 1 :constant-flag t :type ("QDomElement" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [1817 1841])) :type "void") nil [1783 1910]) ("save" function (:parent "PurePostscriptOptions" :arguments (("tag" variable (:pointer 1 :type ("QDomElement" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [1946 1964])) :type "void") nil [1912 2021]) ("PurePostscriptBarcode" function (:constructor-flag t :parent "PurePostscriptBarcode" :type ("PurePostscriptBarcode" type "class")) nil [2023 2746]) ("PurePostscriptBarcode" function (:destructor-flag t :parent "PurePostscriptBarcode" :type "void") nil [2748 2799]) ("init" function (:parent "PurePostscriptBarcode" :type "void") nil [2801 3235]) ("START_TOKEN" variable (:constant-flag t :default-value (nil)) nil [3237 3263]) ("BEGIN_ENCODER" variable (:constant-flag t :default-value (nil)) nil [3264 3302]) ("DESCRIPTION" variable (:constant-flag t :default-value (nil)) nil [3303 3331]) ("EXAMPLE" variable (:constant-flag t :default-value (nil)) nil [3332 3356]) ("initInfo" function (:parent "PurePostscriptBarcode" :arguments (("info" variable (:pointer 1 :type ("TBarcodeInfoList" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [3396 3420])) :type "void") nil [3358 5039]) ("hasPurePostscriptBarcode" function (:parent "PurePostscriptBarcode" :type ("bool" type (:type "class") nil nil)) nil [5041 5128]) ("createProgram" function (:parent "PurePostscriptBarcode" :arguments (("prg" variable (:type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [5173 5188])) :type "void") nil [5130 6215]) ("bbox" function (:parent "PurePostscriptBarcode" :arguments (("postscript" variable (:pointer 1 :constant-flag t :type "char") (reparse-symbol arg-sub-list) [6252 6275]) ("postscript_size" variable (:type "long") (reparse-symbol arg-sub-list) [6276 6298])) :type ("QRect" type (:type "class") nil nil)) nil [6217 6895]) ("createPostscript" function (:parent "PurePostscriptBarcode" :arguments (("postscript" variable (:pointer 2 :type "char") (reparse-symbol arg-sub-list) [6943 6961]) ("postscript_size" variable (:pointer 1 :type "long") (reparse-symbol arg-sub-list) [6962 6985])) :type ("bool" type (:type "class") nil nil)) nil [6897 7316])) + :file "purepostscript.cpp" + :pointmax 7317 + ) + (semanticdb-table "barkode.h" + :major-mode 'c-mode + :tags '(("BARKODE_H" variable (:constant-flag t) nil [889 910]) ("qcolor.h" include (:system-flag t) nil [909 928]) ("qstring.h" include (:system-flag t) nil [929 949]) ("barkodeengine.h" include nil nil [951 977]) ("ESequence" type (:typedef (nil type (:members (("NUM" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [1045 1049]) ("ALPHA" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [1050 1056]) ("ALPHANUM" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [1057 1067])) :type "enum") nil nil) :type "typedef") nil [1030 1078]) ("" type (:members (("NOCUT" variable (:constant-flag t :default-value (1193 1200) :type "int") (reparse-symbol enumsubparts) [1185 1200]) ("MULTILINE" variable (:constant-flag t :default-value (1214 1221) :type "int") (reparse-symbol enumsubparts) [1202 1221]) ("NOTEXT" variable (:constant-flag t :default-value (1232 1239) :type "int") (reparse-symbol enumsubparts) [1223 1239]) ("NOSCALE" variable (:constant-flag t :default-value (1251 1258) :type "int") (reparse-symbol enumsubparts) [1241 1258]) ("PDF417BARCODE" variable (:constant-flag t :default-value (1350 1357) :type "int") (reparse-symbol enumsubparts) [1334 1357]) ("TBARCODEADV" variable (:constant-flag t :default-value (1373 1380) :type "int") (reparse-symbol enumsubparts) [1359 1380]) ("PUREADV" variable (:constant-flag t :default-value (1392 1399) :type "int") (reparse-symbol enumsubparts) [1382 1399]) ("DATAMATRIX" variable (:constant-flag t :default-value (1414 1421) :type "int") (reparse-symbol enumsubparts) [1401 1421]) ("COLORED" variable (:constant-flag t :default-value (1441 1448) :type "int") (reparse-symbol enumsubparts) [1431 1448]) ("POSTNETCHECK" variable (:constant-flag t :default-value (1521 1528) :type "int") (reparse-symbol enumsubparts) [1506 1528]) ("CODE128CHECK" variable (:constant-flag t :default-value (1545 1552) :type "int") (reparse-symbol enumsubparts) [1530 1552]) ("EAN8CHECK" variable (:constant-flag t :default-value (1566 1573) :type "int") (reparse-symbol enumsubparts) [1554 1573]) ("EAN13CHECK" variable (:constant-flag t :default-value (1588 1595) :type "int") (reparse-symbol enumsubparts) [1575 1595]) ("UPCACHECK" variable (:constant-flag t :default-value (1616 1623) :type "int") (reparse-symbol enumsubparts) [1604 1623]) ("UPCECHECK" variable (:constant-flag t :default-value (1637 1644) :type "int") (reparse-symbol enumsubparts) [1625 1644]) ("MODULOALLCHECK" variable (:constant-flag t :default-value (1663 1670) :type "int") (reparse-symbol enumsubparts) [1646 1670]) ("MODULO10CHECK" variable (:constant-flag t :default-value (1688 1695) :type "int") (reparse-symbol enumsubparts) [1672 1695]) ("BARCODE2D" variable (:constant-flag t :default-value (1764 1771) :type "int") (reparse-symbol enumsubparts) [1751 1771]) ("MULTILINE" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [1772 1783]) ("NOTEXT" variable (:constant-flag t :type "int") (reparse-symbol enumsubparts) [1784 1792])) :type "enum") nil [1178 1793]) ("tBarcodeInfo" type (:members (("xml" variable (:type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [2053 2065]) ("name" variable (:type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [2125 2138]) ("engine" variable (:type ("EEngine" type (:type "class") nil nil)) (reparse-symbol classsubparts) [2186 2201]) ("features" variable (:type "unsigned int") (reparse-symbol classsubparts) [2270 2292]) ("internal" variable (:type "int") (reparse-symbol classsubparts) [2363 2376]) ("validator" variable (:type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [2468 2486]) ("validatorNot" variable (:type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [2491 2512])) :type "struct") nil [1888 2515]) ("TBarcodeInfoList" type (:typedef ("QValueList" type (:type "class") nil nil) :superclasses "QValueList" :type "typedef") nil [2517 2567]) ("BarkodeEngine" type (:type "class") nil [2569 2589]) ("QPainter" type (:type "class") nil [2590 2605]) ("QPicture" type (:type "class") nil [2606 2621]) ("QSize" type (:type "class") nil [2622 2634]) ("QPaintDevice" type (:type "class") nil [2635 2654]) ("TokenProvider" type (:type "class") nil [2655 2675]) ("Barkode" type (:members (("public" label nil (reparse-symbol classsubparts) [2694 2701]) ("Barkode" function (:prototype-flag t :constructor-flag t :type ("Barkode" type "class")) (reparse-symbol classsubparts) [2706 2716]) ("Barkode" function (:prototype-flag t :constructor-flag t :arguments (("barkode" variable (:constant-flag t :type ("Barkode" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [2730 2755])) :type ("Barkode" type "class")) (reparse-symbol classsubparts) [2721 2756]) ("Barkode" function (:prototype-flag t :destructor-flag t :typemodifiers ("virtual") :type "void") (reparse-symbol classsubparts) [2761 2780]) ("setTokenProvider" function (:prototype-flag t :arguments (("token" variable (:pointer 1 :type ("TokenProvider" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [2869 2891])) :type "void") (reparse-symbol classsubparts) [2846 2892]) ("defaults" function (:prototype-flag t :type "void") (reparse-symbol classsubparts) [2939 2955]) ("update" function (:prototype-flag t :arguments (("device" variable (:pointer 1 :constant-flag t :type ("QPaintDevice" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [3079 3107])) :type "void") (reparse-symbol classsubparts) [3066 3108]) ("parsedValue" function (:prototype-flag t :constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3217 3245]) ("pixmap" function (:prototype-flag t :constant-flag t :arguments (("scalex" variable (:default-value "1.0" :type "double") (reparse-symbol arg-sub-list) [3274 3293]) ("scaley" variable (:default-value "1.0" :type "double") (reparse-symbol arg-sub-list) [3295 3314])) :type ("QPixmap" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3252 3317]) ("picture" function (:prototype-flag t :constant-flag t :type ("QPicture" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3322 3347]) ("size" function (:prototype-flag t :constant-flag t :type ("QSize" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3352 3377]) ("isValid" function (:prototype-flag t :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3382 3403]) ("background" function (:prototype-flag t :constant-flag t :type ("QColor" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3409 3443]) ("foreground" function (:prototype-flag t :constant-flag t :type ("QColor" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3448 3482]) ("textColor" function (:prototype-flag t :constant-flag t :type ("QColor" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3487 3520]) ("fontsize" function (:prototype-flag t :constant-flag t :type "unsigned int") (reparse-symbol classsubparts) [3525 3561]) ("quietZone" function (:prototype-flag t :constant-flag t :type "unsigned int") (reparse-symbol classsubparts) [3566 3603]) ("barHeight" function (:prototype-flag t :constant-flag t :type "unsigned int") (reparse-symbol classsubparts) [3608 3645]) ("type" function (:prototype-flag t :constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3650 3679]) ("value" function (:prototype-flag t :constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3684 3714]) ("sequenceEnabled" function (:prototype-flag t :constant-flag t :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3719 3754]) ("sequenceMode" function (:prototype-flag t :constant-flag t :type ("ESequence" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3759 3796]) ("sequenceStart" function (:prototype-flag t :constant-flag t :type "int") (reparse-symbol classsubparts) [3801 3833]) ("sequenceStep" function (:prototype-flag t :constant-flag t :type "int") (reparse-symbol classsubparts) [3838 3869]) ("databaseMode" function (:prototype-flag t :constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3874 3911]) ("textVisible" function (:prototype-flag t :constant-flag t :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [3916 3947]) ("rotation" function (:prototype-flag t :constant-flag t :type "int") (reparse-symbol classsubparts) [3952 3979]) ("scaling" function (:prototype-flag t :constant-flag t :type "double") (reparse-symbol classsubparts) [3984 4013]) ("index" function (:prototype-flag t :constant-flag t :type "unsigned int") (reparse-symbol classsubparts) [4018 4051]) ("cut" function (:prototype-flag t :constant-flag t :type "double") (reparse-symbol classsubparts) [4056 4081]) ("datamatrixSize" function (:prototype-flag t :constant-flag t :type "int") (reparse-symbol classsubparts) [4086 4119]) ("setBackground" function (:prototype-flag t :arguments (("c" variable (:constant-flag t :type ("QColor" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [4149 4167])) :type "void") (reparse-symbol classsubparts) [4129 4168]) ("setForeground" function (:prototype-flag t :arguments (("c" variable (:constant-flag t :type ("QColor" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [4193 4211])) :type "void") (reparse-symbol classsubparts) [4173 4212]) ("setTextColor" function (:prototype-flag t :arguments (("c" variable (:constant-flag t :type ("QColor" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [4236 4254])) :type "void") (reparse-symbol classsubparts) [4217 4255]) ("setFontsize" function (:prototype-flag t :arguments (("f" variable (:type "unsigned int") (reparse-symbol arg-sub-list) [4279 4295])) :type "void") (reparse-symbol classsubparts) [4260 4296]) ("setQuietZone" function (:prototype-flag t :arguments (("q" variable (:type "unsigned int") (reparse-symbol arg-sub-list) [4320 4336])) :type "void") (reparse-symbol classsubparts) [4301 4337]) ("setBarHeight" function (:prototype-flag t :arguments (("h" variable (:type "unsigned int") (reparse-symbol arg-sub-list) [4361 4377])) :type "void") (reparse-symbol classsubparts) [4342 4378]) ("setType" function (:prototype-flag t :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [4397 4419])) :type "void") (reparse-symbol classsubparts) [4383 4420]) ("setValue" function (:prototype-flag t :arguments (("value" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [4440 4463])) :type "void") (reparse-symbol classsubparts) [4425 4464]) ("setTextVisible" function (:prototype-flag t :arguments (("b" variable (:constant-flag t :type ("bool" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [4490 4504])) :type "void") (reparse-symbol classsubparts) [4469 4505]) ("setIndex" function (:prototype-flag t :arguments (("i" variable (:type "unsigned int") (reparse-symbol arg-sub-list) [4595 4611])) :type "void") (reparse-symbol classsubparts) [4580 4612]) ("setSequenceEnabled" function (:prototype-flag t :arguments (("b" variable (:type ("bool" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [4642 4650])) :type "void") (reparse-symbol classsubparts) [4617 4651]) ("setSequenceMode" function (:prototype-flag t :arguments (("e" variable (:type ("ESequence" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [4678 4691])) :type "void") (reparse-symbol classsubparts) [4656 4692]) ("setSequenceStart" function (:prototype-flag t :arguments (("s" variable (:type "int") (reparse-symbol arg-sub-list) [4720 4727])) :type "void") (reparse-symbol classsubparts) [4697 4728]) ("setSequenceStep" function (:prototype-flag t :arguments (("s" variable (:type "int") (reparse-symbol arg-sub-list) [4755 4762])) :type "void") (reparse-symbol classsubparts) [4733 4763]) ("setDatabaseMode" function (:prototype-flag t :arguments (("mode" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [4790 4812])) :type "void") (reparse-symbol classsubparts) [4768 4813]) ("setRotation" function (:prototype-flag t :arguments (("r" variable (:constant-flag t :type "int") (reparse-symbol arg-sub-list) [4836 4849])) :type "void") (reparse-symbol classsubparts) [4818 4850]) ("setScaling" function (:prototype-flag t :arguments (("d" variable (:constant-flag t :type "double") (reparse-symbol arg-sub-list) [4872 4888])) :type "void") (reparse-symbol classsubparts) [4855 4889]) ("setCut" function (:prototype-flag t :arguments (("c" variable (:constant-flag t :type "double") (reparse-symbol arg-sub-list) [4907 4923])) :type "void") (reparse-symbol classsubparts) [4894 4924]) ("setDatamatrixSize" function (:prototype-flag t :arguments (("s" variable (:type "int") (reparse-symbol arg-sub-list) [4953 4960])) :type "void") (reparse-symbol classsubparts) [4929 4961]) ("setData" function (:prototype-flag t :arguments (("barkode" variable (:constant-flag t :type ("Barkode" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [5067 5092])) :type "void") (reparse-symbol classsubparts) [5053 5093]) ("==" function (:prototype-flag t :arguments (("barkode" variable (:constant-flag t :type ("Barkode" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [5162 5187])) :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [5145 5194]) ("engine" function (:prototype-flag t :pointer 1 :typemodifiers ("inline") :type ("BarkodeEngine" type (:type "class") nil nil)) (reparse-symbol classsubparts) [5200 5231]) ("engine" function (:prototype-flag t :pointer 1 :typemodifiers ("inline") :constant-flag t :type ("BarkodeEngine" type (:type "class") nil nil)) (reparse-symbol classsubparts) [5236 5279]) ("hasFeature" function (:prototype-flag t :typemodifiers ("static") :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [5430 5451]) ("feature" variable (:type "unsigned int") (reparse-symbol arg-sub-list) [5452 5474])) :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [5406 5475]) ("internalType" function (:prototype-flag t :typemodifiers ("static") :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [5582 5604])) :type "int") (reparse-symbol classsubparts) [5557 5605]) ("encodingTypes" function (:prototype-flag t :pointer 1 :typemodifiers ("static") :constant-flag t :type ("QStringList" type (:type "class") nil nil)) (reparse-symbol classsubparts) [5710 5752]) ("typeFromName" function (:prototype-flag t :pointer 1 :typemodifiers ("static") :constant-flag t :arguments (("name" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [5888 5910])) :type "char") (reparse-symbol classsubparts) [5855 5911]) ("nameFromType" function (:prototype-flag t :pointer 1 :typemodifiers ("static") :constant-flag t :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [6049 6071])) :type "char") (reparse-symbol classsubparts) [6016 6072]) ("validatorFromType" function (:prototype-flag t :pointer 1 :typemodifiers ("static") :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [6113 6135])) :type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [6078 6136]) ("validatorNotFromType" function (:prototype-flag t :pointer 1 :typemodifiers ("static") :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [6179 6201])) :type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [6141 6202]) ("engineForType" function (:prototype-flag t :typemodifiers ("static") :arguments (("type" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [6313 6335])) :type ("EEngine" type (:type "class") nil nil)) (reparse-symbol classsubparts) [6283 6336]) ("drawInvalid" function (:prototype-flag t :arguments (("painter" variable (:type ("QPainter" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [6432 6451]) ("x" variable (:default-value "0" :type "int") (reparse-symbol arg-sub-list) [6452 6461]) ("y" variable (:default-value "0" :type "int") (reparse-symbol arg-sub-list) [6463 6472])) :type "void") (reparse-symbol classsubparts) [6414 6475]) ("haveBarcode" function (:typemodifiers ("static") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [6561 6721]) ("haveGNUBarcode" function (:typemodifiers ("static") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [6726 6824]) ("haveTBarcode" function (:typemodifiers ("static") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [6829 6923]) ("haveTBarcode2" function (:typemodifiers ("static") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [6928 7024]) ("havePDFBarcode" function (:typemodifiers ("static") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [7029 7126]) ("havePurePostscriptBarcode" function (:typemodifiers ("static") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [7131 7244]) ("createInfo" function (:prototype-flag t :typemodifiers ("static") :arguments (("xml" variable (:pointer 1 :constant-flag t :type "char") (reparse-symbol arg-sub-list) [7282 7298]) ("name" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [7299 7320]) ("engine" variable (:constant-flag t :type ("EEngine" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [7321 7342]) ("features" variable (:constant-flag t :default-value "0" :type "unsigned int") (reparse-symbol arg-sub-list) [7380 7411]) ("internal" variable (:constant-flag t :default-value "0" :type "int") (reparse-symbol arg-sub-list) [7413 7435])) :type ("tBarcodeInfo" type (:type "class") nil nil)) (reparse-symbol classsubparts) [7250 7438]) ("protected" label nil (reparse-symbol classsubparts) [7441 7451]) ("drawBarcode" function (:prototype-flag t :arguments (("painter" variable (:type ("QPainter" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [7475 7494]) ("x" variable (:default-value "0" :type "int") (reparse-symbol arg-sub-list) [7495 7504]) ("y" variable (:default-value "0" :type "int") (reparse-symbol arg-sub-list) [7506 7515])) :type "void") (reparse-symbol classsubparts) [7456 7518]) ("private" label nil (reparse-symbol classsubparts) [7521 7529]) ("initInfo" function (:prototype-flag t :typemodifiers ("static") :type "void") (reparse-symbol classsubparts) [7534 7557]) ("initValidators" function (:prototype-flag t :typemodifiers ("static") :type "void") (reparse-symbol classsubparts) [7562 7591]) ("updateEngine" function (:prototype-flag t :type "void") (reparse-symbol classsubparts) [7597 7617]) ("protected" label nil (reparse-symbol classsubparts) [7620 7630]) ("m_engine" variable (:pointer 1 :type ("BarkodeEngine" type (:type "class") nil nil)) (reparse-symbol classsubparts) [7635 7659]) ("m_token" variable (:pointer 1 :type ("TokenProvider" type (:type "class") nil nil)) (reparse-symbol classsubparts) [7664 7687]) ("m_valid" variable (:type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [7693 7706]) ("m_sequence" variable (:type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [7711 7727]) ("m_esequence" variable (:type ("ESequence" type (:type "class") nil nil)) (reparse-symbol classsubparts) [7732 7754]) ("m_sequence_start" variable (:type "int") (reparse-symbol classsubparts) [7759 7780]) ("m_sequence_step" variable (:type "int") (reparse-symbol classsubparts) [7785 7805]) ("m_text_visible" variable (:type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [7810 7830]) ("m_background" variable (:type ("QColor" type (:type "class") nil nil)) (reparse-symbol classsubparts) [7840 7860]) ("m_foreground" variable (:type ("QColor" type (:type "class") nil nil)) (reparse-symbol classsubparts) [7865 7885]) ("m_textcolor" variable (:type ("QColor" type (:type "class") nil nil)) (reparse-symbol classsubparts) [7890 7909]) ("m_quietzone" variable (:type "unsigned int") (reparse-symbol classsubparts) [7915 7940]) ("m_bar_height" variable (:type "unsigned int") (reparse-symbol classsubparts) [7945 7971]) ("m_fontsize" variable (:type "unsigned int") (reparse-symbol classsubparts) [7976 8000]) ("m_index" variable (:type "unsigned int") (reparse-symbol classsubparts) [8005 8026]) ("m_datamatrix_size" variable (:type "int") (reparse-symbol classsubparts) [8031 8053]) ("m_rotation" variable (:type "int") (reparse-symbol classsubparts) [8058 8073]) ("m_scaling" variable (:type "double") (reparse-symbol classsubparts) [8083 8100]) ("m_cut" variable (:type "double") (reparse-symbol classsubparts) [8105 8118]) ("m_type" variable (:type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [8234 8249]) ("m_value" variable (:type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [8254 8270]) ("m_database_mode" variable (:type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [8275 8299]) ("s_info" variable (:typemodifiers ("static") :type ("TBarcodeInfoList" type (:type "class") nil nil)) (reparse-symbol classsubparts) [8309 8340]) ("s_encoding" variable (:pointer 1 :typemodifiers ("static") :type ("QStringList" type (:type "class") nil nil)) (reparse-symbol classsubparts) [8345 8376]) ("s_haveGnuBarcode" variable (:typemodifiers ("static") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [8382 8411]) ("s_haveTBarcode" variable (:typemodifiers ("static") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [8416 8443]) ("s_haveTBarcode2" variable (:typemodifiers ("static") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [8448 8476]) ("s_havePdfEncode" variable (:typemodifiers ("static") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [8481 8509]) ("s_havePurePostscript" variable (:typemodifiers ("static") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [8514 8547])) :type "class") nil [2677 8550]) ("engine" function (:pointer 1 :parent "Barkode" :type ("BarkodeEngine" type (:type "class") nil nil)) nil [8552 8609]) ("engine" function (:pointer 1 :parent "Barkode" :constant-flag t :type ("BarkodeEngine" type (:type "class") nil nil)) nil [8611 8680])) + :file "barkode.h" + :pointmax 8704 + ) + (semanticdb-table "purepostscript.h" + :major-mode 'c-mode + :tags '(("PURE_POSTSCRIPT_H" variable (:constant-flag t) nil [1054 1082]) ("pixmapbarcode.h" include nil nil [1081 1107]) ("barkode.h" include nil nil [1108 1128]) ("qcstring.h" include (:system-flag t) nil [1130 1151]) ("PurePostscriptOptions" type (:superclasses ("BarkodeEngineOptions") :members (("public" label nil (reparse-symbol classsubparts) [1217 1224]) ("PurePostscriptOptions" function (:prototype-flag t :constructor-flag t :type ("PurePostscriptOptions" type "class")) (reparse-symbol classsubparts) [1233 1257]) ("defaults" function (:prototype-flag t :type "void") (reparse-symbol classsubparts) [1349 1365]) ("load" function (:prototype-flag t :arguments (("tag" variable (:pointer 1 :constant-flag t :type ("QDomElement" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [1386 1410])) :type "void") (reparse-symbol classsubparts) [1375 1411]) ("save" function (:prototype-flag t :arguments (("tag" variable (:pointer 1 :type ("QDomElement" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [1431 1449])) :type "void") (reparse-symbol classsubparts) [1420 1450]) ("checksum" function (:typemodifiers ("inline") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [1462 1510]) ("setChecksum" function (:typemodifiers ("inline") :arguments (("b" variable (:type ("bool" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [1544 1552])) :type "void") (reparse-symbol classsubparts) [1519 1569]) ("private" label nil (reparse-symbol classsubparts) [1575 1583]) ("m_check" variable (:type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [1593 1606])) :type "class") nil [1153 1609]) ("PurePostscriptBarcode" type (:superclasses ("PixmapBarcode") :members (("public" label nil (reparse-symbol classsubparts) [1665 1672]) ("PurePostscriptBarcode" function (:prototype-flag t :constructor-flag t :type ("PurePostscriptBarcode" type "class")) (reparse-symbol classsubparts) [1677 1701]) ("PurePostscriptBarcode" function (:prototype-flag t :destructor-flag t :type "void") (reparse-symbol classsubparts) [1706 1731]) ("init" function (:prototype-flag t :typemodifiers ("static") :type "void") (reparse-symbol classsubparts) [1884 1903]) ("initInfo" function (:prototype-flag t :typemodifiers ("static") :arguments (("info" variable (:pointer 1 :type ("TBarcodeInfoList" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [1932 1956])) :type "void") (reparse-symbol classsubparts) [1910 1957]) ("hasPurePostscriptBarcode" function (:prototype-flag t :typemodifiers ("static") :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [1963 2002]) ("engine" function (:prototype-flag t :typemodifiers ("inline") :type ("EEngine" type (:type "class") nil nil)) (reparse-symbol classsubparts) [2008 2038]) ("options" function (:prototype-flag t :pointer 1 :typemodifiers ("inline") :type ("BarkodeEngineOptions" type (:type "class") nil nil)) (reparse-symbol classsubparts) [2044 2083]) ("private" label nil (reparse-symbol classsubparts) [2086 2094]) ("createPostscript" function (:prototype-flag t :typemodifiers ("virtual") :arguments (("postscript" variable (:pointer 2 :type "char") (reparse-symbol arg-sub-list) [2130 2148]) ("postscript_size" variable (:pointer 1 :type "long") (reparse-symbol arg-sub-list) [2149 2172])) :type ("bool" type (:type "class") nil nil)) (reparse-symbol classsubparts) [2099 2173]) ("bbox" function (:prototype-flag t :typemodifiers ("virtual") :arguments (("postscript" variable (:pointer 1 :constant-flag t :type "char") (reparse-symbol arg-sub-list) [2198 2221]) ("postscript_size" variable (:type "long") (reparse-symbol arg-sub-list) [2222 2244])) :type ("QRect" type (:type "class") nil nil)) (reparse-symbol classsubparts) [2178 2245]) ("createProgram" function (:prototype-flag t :arguments (("prg" variable (:type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [2449 2464])) :type "void") (reparse-symbol classsubparts) [2429 2465]) ("private" label nil (reparse-symbol classsubparts) [2468 2476]) ("m_options" variable (:type ("PurePostscriptOptions" type (:type "class") nil nil)) (reparse-symbol classsubparts) [2481 2513]) ("m_program" variable (:type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [2519 2537]) ("s_path" variable (:typemodifiers ("static") :type ("QString" type (:type "class") nil nil)) (reparse-symbol classsubparts) [2543 2565])) :type "class") nil [1611 2568]) ("engine" function (:parent "PurePostscriptBarcode" :type ("EEngine" type (:type "class") nil nil)) nil [2570 2647]) ("options" function (:pointer 1 :parent "PurePostscriptBarcode" :type ("BarkodeEngineOptions" type (:type "class") nil nil)) nil [2649 2730])) + :file "purepostscript.h" + :pointmax 2763 + ) + (semanticdb-table "tokenprovider.cpp" + :major-mode 'c++-mode + :tags '(("tokenprovider.h" include nil nil [1029 1055]) ("sqltables.h" include nil nil [1056 1078]) ("kbarcodesettings.h" include nil nil [1079 1108]) ("barcodeitem.h" include nil nil [1110 1134]) ("textitem.h" include nil nil [1135 1156]) ("textlineitem.h" include nil nil [1157 1182]) ("qdatetime.h" include (:system-flag t) nil [1199 1221]) ("qpaintdevicemetrics.h" include (:system-flag t) nil [1222 1254]) ("qsqlquery.h" include (:system-flag t) nil [1255 1277]) ("qregexp.h" include (:system-flag t) nil [1278 1298]) ("qvaluelist.h" include (:system-flag t) nil [1299 1322]) ("time.h" include (:system-flag t) nil [1323 1340]) ("klocale.h" include (:system-flag t) nil [1342 1362]) ("kabc/addressee.h" include (:system-flag t) nil [1363 1390]) ("kjs/interpreter.h" include (:system-flag t) nil [1434 1462]) ("kjsembed/kjsembedpart.h" include (:system-flag t) nil [1469 1503]) ("NUM_FIELDS" variable (:constant-flag t :default-value (nil)) nil [1553 1574]) ("TOK_ARTICLE_NO_CUSTOMER" variable (:pointer 1 :constant-flag t :default-value "\"article_no_customer\"" :type "char") nil [1576 1636]) ("TOK_BARCODE_NO_CUSTOMER" variable (:pointer 1 :constant-flag t :default-value "\"barcode_no_customer\"" :type "char") nil [1637 1697]) ("TOK_ARTICLE_DESC" variable (:pointer 1 :constant-flag t :default-value "\"article_desc\"" :type "char") nil [1698 1744]) ("TOK_ARTICLE_NO" variable (:pointer 1 :constant-flag t :default-value "\"article_no\"" :type "char") nil [1745 1787]) ("TOK_CUSTOMER_NO" variable (:pointer 1 :constant-flag t :default-value "\"customer_no\"" :type "char") nil [1788 1832]) ("TOK_CUSTOEMR_NAME" variable (:pointer 1 :constant-flag t :default-value "\"customer_name\"" :type "char") nil [1833 1881]) ("TOK_BARCODE_NO" variable (:pointer 1 :constant-flag t :default-value "\"barcode_no\"" :type "char") nil [1882 1924]) ("TOK_BARCODE_NO_BASIC" variable (:pointer 1 :constant-flag t :default-value "\"barcode_no_basic\"" :type "char") nil [1925 1979]) ("TOK_GROUP" variable (:pointer 1 :constant-flag t :default-value "\"group\"" :type "char") nil [1980 2012]) ("TOK_ENCODING_TYPE" variable (:pointer 1 :constant-flag t :default-value "\"encoding_type\"" :type "char") nil [2013 2061]) ("TOK_ENCODING_TYPE_NAME" variable (:pointer 1 :constant-flag t :default-value "\"encoding_type_name\"" :type "char") nil [2062 2120]) ("TOK_LINE" variable (:pointer 1 :constant-flag t :default-value "\"line%1\"" :type "char") nil [2121 2153]) ("TOK_FIELD" variable (:pointer 1 :constant-flag t :default-value "\"field%1\"" :type "char") nil [2154 2188]) ("TOK_FILENAME" variable (:pointer 1 :constant-flag t :default-value "\"filename\"" :type "char") nil [2190 2228]) ("TOK_INDEX" variable (:pointer 1 :constant-flag t :default-value "\"index\"" :type "char") nil [2229 2261]) ("TOK_COL" variable (:pointer 1 :constant-flag t :default-value "\"col\"" :type "char") nil [2262 2290]) ("TOK_ROW" variable (:pointer 1 :constant-flag t :default-value "\"row\"" :type "char") nil [2291 2319]) ("TOK_PAGE" variable (:pointer 1 :constant-flag t :default-value "\"page\"" :type "char") nil [2320 2350]) ("TOK_RESOLUTION" variable (:pointer 1 :constant-flag t :default-value "\"resolution\"" :type "char") nil [2351 2393]) ("TOK_SERIAL" variable (:pointer 1 :constant-flag t :default-value "\"serial\"" :type "char") nil [2394 2428]) ("TOK_JS" variable (:pointer 1 :constant-flag t :default-value "\"js:\"" :type "char") nil [2430 2457]) ("TOK_SQL" variable (:pointer 1 :constant-flag t :default-value "\"sqlquery:\"" :type "char") nil [2458 2492]) ("TOK_VAR" variable (:pointer 1 :constant-flag t :default-value "\"$\"" :type "char") nil [2493 2519]) ("TOK_DATE" variable (:pointer 1 :constant-flag t :default-value "\"date\"" :type "char") nil [2521 2551]) ("TOK_DATE_a" variable (:pointer 1 :constant-flag t :default-value "\"date:%a\"" :type "char") nil [2552 2587]) ("TOK_DATE_A" variable (:pointer 1 :constant-flag t :default-value "\"date:%A\"" :type "char") nil [2588 2623]) ("TOK_DATE_b" variable (:pointer 1 :constant-flag t :default-value "\"date:%b\"" :type "char") nil [2624 2659]) ("TOK_DATE_B" variable (:pointer 1 :constant-flag t :default-value "\"date:%B\"" :type "char") nil [2660 2695]) ("TOK_DATE_c" variable (:pointer 1 :constant-flag t :default-value "\"date:%c\"" :type "char") nil [2696 2731]) ("TOK_DATE_C" variable (:pointer 1 :constant-flag t :default-value "\"date:%C\"" :type "char") nil [2732 2767]) ("TOK_DATE_d" variable (:pointer 1 :constant-flag t :default-value "\"date:%d\"" :type "char") nil [2768 2803]) ("TOK_DATE_D" variable (:pointer 1 :constant-flag t :default-value "\"date:%D\"" :type "char") nil [2804 2839]) ("TOK_DATE_e" variable (:pointer 1 :constant-flag t :default-value "\"date:%e\"" :type "char") nil [2840 2875]) ("TOK_DATE_F" variable (:pointer 1 :constant-flag t :default-value "\"date:%F\"" :type "char") nil [2876 2911]) ("TOK_DATE_g" variable (:pointer 1 :constant-flag t :default-value "\"date:%g\"" :type "char") nil [2912 2947]) ("TOK_DATE_G" variable (:pointer 1 :constant-flag t :default-value "\"date:%G\"" :type "char") nil [2948 2983]) ("TOK_DATE_H" variable (:pointer 1 :constant-flag t :default-value "\"date:%H\"" :type "char") nil [2984 3019]) ("TOK_DATE_I" variable (:pointer 1 :constant-flag t :default-value "\"date:%I\"" :type "char") nil [3020 3055]) ("TOK_DATE_J" variable (:pointer 1 :constant-flag t :default-value "\"date:%J\"" :type "char") nil [3056 3091]) ("TOK_DATE_m" variable (:pointer 1 :constant-flag t :default-value "\"date:%m\"" :type "char") nil [3092 3127]) ("TOK_DATE_M" variable (:pointer 1 :constant-flag t :default-value "\"date:%M\"" :type "char") nil [3128 3163]) ("TOK_DATE_p" variable (:pointer 1 :constant-flag t :default-value "\"date:%p\"" :type "char") nil [3164 3199]) ("TOK_DATE_r" variable (:pointer 1 :constant-flag t :default-value "\"date:%r\"" :type "char") nil [3200 3235]) ("TOK_DATE_R" variable (:pointer 1 :constant-flag t :default-value "\"date:%R\"" :type "char") nil [3236 3271]) ("TOK_DATE_S" variable (:pointer 1 :constant-flag t :default-value "\"date:%S\"" :type "char") nil [3272 3307]) ("TOK_DATE_T" variable (:pointer 1 :constant-flag t :default-value "\"date:%T\"" :type "char") nil [3308 3343]) ("TOK_DATE_u" variable (:pointer 1 :constant-flag t :default-value "\"date:%u\"" :type "char") nil [3344 3379]) ("TOK_DATE_U" variable (:pointer 1 :constant-flag t :default-value "\"date:%U\"" :type "char") nil [3380 3415]) ("TOK_DATE_V" variable (:pointer 1 :constant-flag t :default-value "\"date:%V\"" :type "char") nil [3416 3451]) ("TOK_DATE_w" variable (:pointer 1 :constant-flag t :default-value "\"date:%w\"" :type "char") nil [3452 3487]) ("TOK_DATE_W" variable (:pointer 1 :constant-flag t :default-value "\"date:%W\"" :type "char") nil [3488 3523]) ("TOK_DATE_x" variable (:pointer 1 :constant-flag t :default-value "\"date:%x\"" :type "char") nil [3524 3559]) ("TOK_DATE_X" variable (:pointer 1 :constant-flag t :default-value "\"date:%X\"" :type "char") nil [3560 3595]) ("TOK_DATE_y" variable (:pointer 1 :constant-flag t :default-value "\"date:%y\"" :type "char") nil [3596 3631]) ("TOK_DATE_Y" variable (:pointer 1 :constant-flag t :default-value "\"date:%Y\"" :type "char") nil [3632 3667]) ("TOK_DATE_z" variable (:pointer 1 :constant-flag t :default-value "\"date:%z\"" :type "char") nil [3668 3703]) ("TOK_DATE_Z" variable (:pointer 1 :constant-flag t :default-value "\"date:%Z\"" :type "char") nil [3704 3739]) ("TOK_ADDRESS_NAME" variable (:pointer 1 :constant-flag t :default-value "\"address_name\"" :type "char") nil [3741 3787]) ("TOK_ADDRESS_GIVEN_NAME" variable (:pointer 1 :constant-flag t :default-value "\"address_givenname\"" :type "char") nil [3788 3845]) ("TOK_ADDRESS_FAMILY_NAME" variable (:pointer 1 :constant-flag t :default-value "\"address_familyname\"" :type "char") nil [3846 3905]) ("TOK_ADDRESS_EMAIL" variable (:pointer 1 :constant-flag t :default-value "\"address_email\"" :type "char") nil [3906 3954]) ("TOK_ADDRESS_FULL_EMAIL" variable (:pointer 1 :constant-flag t :default-value "\"address_fullemail\"" :type "char") nil [3955 4012]) ("TOK_ADDRESS_PHONE_PREF" variable (:pointer 1 :constant-flag t :default-value "\"address_phone\"" :type "char") nil [4013 4066]) ("TOK_ADDRESS_PHONE_HOME" variable (:pointer 1 :constant-flag t :default-value "\"address_phonehome\"" :type "char") nil [4067 4124]) ("TOK_ADDRESS_PHONE_WORK" variable (:pointer 1 :constant-flag t :default-value "\"address_phonework\"" :type "char") nil [4125 4182]) ("TOK_ADDRESS_PHONE_MSG" variable (:pointer 1 :constant-flag t :default-value "\"address_phonemsg\"" :type "char") nil [4183 4238]) ("TOK_ADDRESS_PHONE_VOICE" variable (:pointer 1 :constant-flag t :default-value "\"address_phonevoice\"" :type "char") nil [4239 4298]) ("TOK_ADDRESS_PHONE_FAX" variable (:pointer 1 :constant-flag t :default-value "\"address_phonefax\"" :type "char") nil [4299 4354]) ("TOK_ADDRESS_PHONE_CELL" variable (:pointer 1 :constant-flag t :default-value "\"address_phonemobile\"" :type "char") nil [4355 4414]) ("TOK_ADDRESS_PHONE_VIDEO" variable (:pointer 1 :constant-flag t :default-value "\"address_phonevideo\"" :type "char") nil [4415 4474]) ("TOK_ADDRESS_PHONE_BBS" variable (:pointer 1 :constant-flag t :default-value "\"address_phonebbs\"" :type "char") nil [4475 4530]) ("TOK_ADDRESS_PHONE_MODEM" variable (:pointer 1 :constant-flag t :default-value "\"address_phonemodem\"" :type "char") nil [4531 4590]) ("TOK_ADDRESS_PHONE_CAR" variable (:pointer 1 :constant-flag t :default-value "\"address_phonecar\"" :type "char") nil [4591 4646]) ("TOK_ADDRESS_PHONE_ISDN" variable (:pointer 1 :constant-flag t :default-value "\"address_phoneisdn\"" :type "char") nil [4647 4704]) ("TOK_ADDRESS_PHONE_PCS" variable (:pointer 1 :constant-flag t :default-value "\"address_phonepcs\"" :type "char") nil [4705 4760]) ("TOK_ADDRESS_PHONE_PAGER" variable (:pointer 1 :constant-flag t :default-value "\"address_phonepager\"" :type "char") nil [4761 4820]) ("TOK_ADDRESS_ADDRESS_POB" variable (:pointer 1 :constant-flag t :default-value "\"address_postofficebox\"" :type "char") nil [4821 4883]) ("TOK_ADDRESS_ADDRESS_EXTENDED" variable (:pointer 1 :constant-flag t :default-value "\"address_extended\"" :type "char") nil [4884 4946]) ("TOK_ADDRESS_ADDRESS_STREET" variable (:pointer 1 :constant-flag t :default-value "\"address_street\"" :type "char") nil [4947 5005]) ("TOK_ADDRESS_ADDRESS_LOCALITY" variable (:pointer 1 :constant-flag t :default-value "\"address_locality\"" :type "char") nil [5006 5068]) ("TOK_ADDRESS_ADDRESS_REGION" variable (:pointer 1 :constant-flag t :default-value "\"address_region\"" :type "char") nil [5069 5127]) ("TOK_ADDRESS_ADDRESS_POSTALCODE" variable (:pointer 1 :constant-flag t :default-value "\"address_postalcode\"" :type "char") nil [5128 5194]) ("TOK_ADDRESS_ADDRESS_COUNTRY" variable (:pointer 1 :constant-flag t :default-value "\"address_country\"" :type "char") nil [5195 5255]) ("TOK_ADDRESS_ADDRESS_LABEL" variable (:pointer 1 :constant-flag t :default-value "\"address_label\"" :type "char") nil [5256 5312]) ("TOK_ADDRESS" variable (:pointer 1 :constant-flag t :default-value "\"address\"" :type "char") nil [5313 5349]) ("TOK_ADDRESS_URL" variable (:pointer 1 :constant-flag t :default-value "\"address_url\"" :type "char") nil [5357 5401]) ("TOK_ADDRESS_NICK" variable (:pointer 1 :constant-flag t :default-value "\"address_nick\"" :type "char") nil [5402 5448]) ("TOK_ADDRESS_ADDITIONAL_NAME" variable (:pointer 1 :constant-flag t :default-value "\"address_addtionalname\"" :type "char") nil [5449 5515]) ("TOK_ADDRESS_PREFIX" variable (:pointer 1 :constant-flag t :default-value "\"address_prefix\"" :type "char") nil [5516 5566]) ("TOK_ADDRESS_SUFFIX" variable (:pointer 1 :constant-flag t :default-value "\"address_suffix\"" :type "char") nil [5567 5617]) ("TOK_ADDRESS_BIRTHDAY" variable (:pointer 1 :constant-flag t :default-value "\"address_birthday\"" :type "char") nil [5618 5672]) ("TOK_ADDRESS_TITLE" variable (:pointer 1 :constant-flag t :default-value "\"address_title\"" :type "char") nil [5673 5721]) ("TOK_ADDRESS_ROLE" variable (:pointer 1 :constant-flag t :default-value "\"address_role\"" :type "char") nil [5722 5768]) ("TOK_ADDRESS_NOTE" variable (:pointer 1 :constant-flag t :default-value "\"address_note\"" :type "char") nil [5769 5815]) ("TOK_ADDRESS_ORGANIZATION" variable (:pointer 1 :constant-flag t :default-value "\"address_organization\"" :type "char") nil [5816 5878]) ("TokenProvider" function (:constructor-flag t :parent "TokenProvider" :arguments (("paintdevice" variable (:pointer 1 :type ("QPaintDevice" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [5910 5937])) :type ("TokenProvider" type "class")) nil [5880 6579]) ("TokenProvider" function (:destructor-flag t :parent "TokenProvider" :type "void") nil [6581 6616]) ("TokenProvider::s_categories" variable (:type ("QValueList" type (:type "class") nil nil)) nil [6618 6670]) ("TokenProvider::s_captions" variable (:type ("QMap" type (:type "class") nil nil)) nil [6671 6738]) ("TokenProvider::s_interpreter" variable (:pointer 1 :default-value "NULL;" :type ("KJS::Interpreter" type (:type "class") nil nil)) nil [6759 6813]) ("TokenProvider::s_interpreter" variable (:pointer 1 :default-value "NULL;" :type ("KJSEmbed::KJSEmbedPart" type (:type "class") nil nil)) nil [6820 6880]) ("hasJavaScript" function (:parent "TokenProvider" :type ("bool" type (:type "class") nil nil)) nil [6905 7032]) ("getTokens" function (:pointer 1 :parent "TokenProvider" :type ("QValueList" type (:type "class") nil nil)) nil [7034 7143]) ("init" function (:parent "TokenProvider" :type "void") nil [7145 17408]) ("findBrackets" function (:parent "TokenProvider" :arguments (("text" variable (:type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [17445 17460]) ("" variable (:type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [17461 17501])) :type "void") nil [17411 18736]) ("parse" function (:parent "TokenProvider" :arguments (("text" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [18768 18790])) :type ("QString" type (:type "class") nil nil)) nil [18738 18889]) ("listUserVars" function (:parent "TokenProvider" :type ("QStringList" type (:type "class") nil nil)) nil [18891 19537]) ("processUserVars" function (:parent "TokenProvider" :arguments (("t" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [19579 19598])) :type ("QString" type (:type "class") nil nil)) nil [19539 20032]) ("process" function (:parent "TokenProvider" :arguments (("t" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [20066 20085])) :type ("QString" type (:type "class") nil nil)) nil [20034 24091]) ("processAddresses" function (:parent "TokenProvider" :arguments (("t" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [24134 24153])) :type ("QString" type (:type "class") nil nil)) nil [24093 29616]) ("query" function (:parent "TokenProvider" :arguments (("query" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [29648 29671])) :type ("QString" type (:type "class") nil nil)) nil [29618 29867]) ("jsParse" function (:parent "TokenProvider" :arguments (("script" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [29901 29925])) :type ("QString" type (:type "class") nil nil)) nil [29869 31283]) ("jsParseToBool" function (:parent "TokenProvider" :arguments (("script" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [31320 31344])) :type ("bool" type (:type "class") nil nil)) nil [31285 31681]) ("createSerial" function (:parent "TokenProvider" :constant-flag t :type ("QString" type (:type "class") nil nil)) nil [31683 32384]) ("unescapeText" function (:parent "TokenProvider" :arguments (("t" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [32423 32442])) :type ("QString" type (:type "class") nil nil)) nil [32386 32692]) ("escapeText" function (:parent "TokenProvider" :arguments (("t" variable (:constant-flag t :type ("QString" type (:type "class") nil nil)) (reparse-symbol arg-sub-list) [32729 32748])) :type ("QString" type (:type "class") nil nil)) nil [32694 33053])) + :file "tokenprovider.cpp" + :pointmax 33054 + ) + ) + :file "semantic.cache" + :semantic-tag-version "2.0pre3" + :semanticdb-version "2.0pre3" + ) diff --git a/kbarcode/smalldialogs.cpp b/kbarcode/smalldialogs.cpp new file mode 100644 index 0000000..232e2f0 --- /dev/null +++ b/kbarcode/smalldialogs.cpp @@ -0,0 +1,151 @@ +/*************************************************************************** + smalldialogs.cpp - description + ------------------- + begin : Son Jul 20 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "smalldialogs.h" +#include "sqltables.h" + +// Qt includes +#include <qlabel.h> +#include <qlayout.h> +#include <qsqlcursor.h> + +// KDE includes +#include <knuminput.h> +#include <klineedit.h> +#include <klocale.h> + + +using namespace DSSmallDialogs; + +AddAllDialog::AddAllDialog(QWidget *parent, const char *name ) + : KDialogBase( KDialogBase::Plain, i18n("Add Barcode_basic"), + KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, parent,name) +{ + QVBoxLayout* layout = new QVBoxLayout( plainPage(), 6, 6 ); + + group = new KLineEdit( plainPage() ); + number = new KIntNumInput( plainPage() ); + number->setLabel( i18n( "Number of labels:" ) ); + number->setRange( 1, 10000, 1, false ); + + layout->addWidget( new QLabel( i18n("Group:"), plainPage() ) ); + layout->addWidget( group ); + layout->addWidget( number ); +} + +QString AddAllDialog::groupName() const +{ + return group->text(); +} + +int AddAllDialog::numberLabels() const +{ + return number->value(); +} + +AddItemsDialog::AddItemsDialog(QWidget *parent, const char *name ) + : KDialogBase( KDialogBase::Plain, i18n("Add Items"), + KDialogBase::User1 | KDialogBase::Close, KDialogBase::User1, parent,name) +{ + init(); +} + +AddItemsDialog::AddItemsDialog( const QString & a, const QString & g, int c, QWidget* parent, const char* name ) + : KDialogBase( KDialogBase::Plain, i18n("Edit Item"), + KDialogBase::Ok| KDialogBase::Close, KDialogBase::Ok, parent,name) +{ + init(); + article->setText( a ); + group->setText( g ); + number->setValue( c ); +} + +void AddItemsDialog::init() +{ + plainPage()->setFrameStyle( QFrame::GroupBoxPanel | QFrame::Sunken ); + plainPage()->setLineWidth( 2 ); + + QHBoxLayout* layout = new QHBoxLayout( plainPage(), 6, 6 ); + + group = new KLineEdit( plainPage() ); + article = new KLineEdit( plainPage() ); + + number = new KIntNumInput( plainPage() ); + number->setLabel( i18n( "Number of labels:" ), KNumInput::AlignLeft | KNumInput::AlignVCenter ); + number->setRange( 1, 10000, 1, false ); + + layout->addWidget( number ); + layout->addWidget( new QLabel( i18n("Article:" ), plainPage() ) ); + layout->addWidget( article ); + layout->addWidget( new QLabel( i18n("Group:"), plainPage() ) ); + layout->addWidget( group ); + + setButtonText( KDialogBase::User1, i18n("&Add") ); + + setupSql(); + + connect( SqlTables::getInstance(), SIGNAL( tablesChanged() ), this, SLOT( setupSql() ) ); + connect( SqlTables::getInstance(), SIGNAL( connectedSQL() ), this, SLOT( setupSql() ) ); +} + +void AddItemsDialog::slotUser1() +{ + emit add( article->text(), group->text(), number->value() ); + + number->setValue( 1 ); + article->setText( "" ); + group->setText( "" ); + article->setFocus(); +} + +void AddItemsDialog::setupSql() +{ + SqlTables* tables = SqlTables::getInstance(); + if( !tables->isConnected() ) + return; + + KCompletion* comp = article->completionObject(); + comp->clear(); + QSqlQuery query( "select article_no from " TABLE_BASIC " order by article_no" ); + QStringList slist; + while ( query.next() ) + slist.append( query.value(0).toString() ); + + comp->setItems( slist ); +} + +void AddItemsDialog::setGroupCompletion( KCompletion* c ) +{ + group->setCompletionObject( c ); +} + +int AddItemsDialog::count() const +{ + return number->value(); +} + +const QString AddItemsDialog::articleNo() const +{ + return article->text(); +} + +const QString AddItemsDialog::groupName() const +{ + return group->text(); +} + +#include "smalldialogs.moc" diff --git a/kbarcode/smalldialogs.h b/kbarcode/smalldialogs.h new file mode 100644 index 0000000..6687b64 --- /dev/null +++ b/kbarcode/smalldialogs.h @@ -0,0 +1,72 @@ +/*************************************************************************** + smalldialogs.h - description + ------------------- + begin : Son Jul 20 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef SMALLDIALOGS_H +#define SMALLDIALOGS_H + +#include <qwidget.h> +#include <kdialogbase.h> + +class KCompletion; +class KIntNumInput; +class KLineEdit; + +namespace DSSmallDialogs { + + class AddAllDialog : public KDialogBase { + Q_OBJECT + public: + AddAllDialog(QWidget *parent=0, const char *name=0); + + QString groupName() const; + int numberLabels() const; + + protected: + KLineEdit* group; + KIntNumInput* number; + }; + + class AddItemsDialog : public KDialogBase { + Q_OBJECT + public: + AddItemsDialog( QWidget* parent = 0, const char* name = 0 ); + AddItemsDialog( const QString & a, const QString & g, int c, QWidget* parent = 0, const char* name = 0 ); + + void setGroupCompletion( KCompletion* c ); + + int count() const; + const QString articleNo() const; + const QString groupName() const; + + signals: + void add( const QString & article, const QString & group, int count); + + private slots: + void setupSql(); + + protected: + KLineEdit* article; + KLineEdit* group; + KIntNumInput* number; + + void slotUser1(); + void init(); + }; + +} + +#endif diff --git a/kbarcode/sqltables.cpp b/kbarcode/sqltables.cpp new file mode 100644 index 0000000..7852683 --- /dev/null +++ b/kbarcode/sqltables.cpp @@ -0,0 +1,654 @@ +/*************************************************************************** + sqltables.cpp - description + ------------------- + begin : Son Dez 29 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "sqltables.h" +#include "definition.h" + +// Qt includes +#include <qcheckbox.h> +#include <qfile.h> +#include <qgroupbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qmap.h> +#include <qprogressdialog.h> +#include <qsqldatabase.h> + +// KDE includes +#include <kapplication.h> +#include <kcombobox.h> +#include <kconfig.h> +#include <klineedit.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kpushbutton.h> +#include <kstandarddirs.h> + +QMap<QString,SqlDescription*> drivers; + +class MySqlDescription : public SqlDescription { + public: + virtual const QString initdb( QString ) const { return "mysql"; } + virtual const QString autoIncrement() const { return "int(11) NOT NULL auto_increment"; } + virtual const QString showColumns( const QString & table ) const { return "SHOW COLUMNS FROM " + table; } +}; + +class PostgreSQLDescription : public SqlDescription { + public: + virtual const QString initdb( QString ) const { return "template1"; } + virtual const QString autoIncrement() const { return "serial NOT NULL"; } + virtual const QString showColumns( const QString & table ) const { + return "select a.attname, pg_catalog.format_type(a.atttypid, a.atttypmod), " + "a.attnotnull, a.atthasdef, a.attnum, substring(d.adsrc for 128) " + "from pg_catalog.pg_attribute a " + "inner join pg_catalog.pg_class c on c.oid = a.attrelid " + "left join pg_catalog.pg_attrdef d on d.adrelid = c.oid and a.attnum = " + "d.adnum " + "where a.attnum > 0 and not a.attisdropped and c.relname ~ '^" + table + "$';"; + } +}; + +/** should work for ODBC, too */ +class SQLiteDescription : public SqlDescription { + public: + virtual const QString initdb( QString db = QString::null ) const { return db; } + virtual const QString autoIncrement() const { return "serial NOT NULL"; } + virtual const QString showColumns( const QString & table ) const { return "SHOW COLUMNS FROM " + table; } +}; + +SqlTables::SqlTables( QObject* parent ) + : QObject( parent, "sqltables" ) +{ + drivers.insert( "QMYSQL3", new MySqlDescription() ); + drivers.insert( "QPSQL7", new PostgreSQLDescription() ); + /* The same driver plugin is used for QDBC and SQLite */ + drivers.insert( "QSQLITE", new SQLiteDescription() ); + drivers.insert( "QODBC3", new SQLiteDescription() ); + + db = NULL; + connected = false; + loadConfig(); + + connect( kapp, SIGNAL( aboutToQuit() ), this, SLOT( saveConfig() ) ); +} + +SqlTables::~SqlTables() +{ +} + +SqlTables* SqlTables::instance = NULL; + +SqlTables* SqlTables::getInstance() +{ + if( !instance ) + instance = new SqlTables(); + + return instance; +} + +const SqlDescription* SqlTables::driver() const +{ + return drivers[sqldata.driver]; +} +bool SqlTables::connectMySQL() +{ + db = QSqlDatabase::addDatabase( sqldata.driver ); + + db->setDatabaseName( sqldata.database ); + db->setUserName( sqldata.username ); + db->setPassword( sqldata.password ); + db->setHostName( sqldata.hostname ); + + if( !db->open() ) + KMessageBox::error( 0, i18n("<qt>Unable to open database: ") + sqldata.database + "<br>" + + db->lastError().databaseText() + "</qt>"); + + connected = db->open(); + if( connected ) { + updateTables(); + emit connectedSQL(); + // be sure that we have a clean list of producers + Definition::updateProducer(); + } + + return connected; +} + +bool SqlTables::newTables() +{ + return newTables( sqldata.username, sqldata.password, sqldata.hostname, sqldata.database, sqldata.driver ); +} + +bool SqlTables::newTables( const QString & username, const QString & password, const QString & hostname, const QString & database, const QString & driver ) +{ + if( KMessageBox::warningContinueCancel( 0, + i18n("We are going to re-create the tables '") + + QString( TABLE_BASIC "', '" TABLE_CUSTOMER "', '" + TABLE_CUSTOMER_TEXT) +i18n("' and '") + QString(TABLE_LABEL_DEF "'")) == KMessageBox::Cancel ) + return false; + + if( !drivers[driver] ) + return false; + + QSqlDatabase*dbase = QSqlDatabase::addDatabase(driver, drivers[driver]->initdb( database ) ); + dbase->setDatabaseName( drivers[driver]->initdb( database ) ); + dbase->setUserName( username ); + dbase->setPassword( password ); + dbase->setHostName( hostname ); + + if(dbase->open()) { + + if (driver != "QSQLITE") + { + bool found = false; + QSqlQuery existing("SHOW DATABASES LIKE '" + database + "';"); + while( existing.next() ) + found = true; + + QSqlQuery firstquery( NULL, dbase ); + if( !found && !firstquery.exec("CREATE DATABASE " + database + ";")) { + if( KMessageBox::warningContinueCancel( 0, i18n("<qt>Can't create database ")+ database + i18n("<br>You can continue if the database exists already.</qt>") + + firstquery.lastError().databaseText() ) == KMessageBox::Cancel ) { + dbase->close(); + QSqlDatabase::removeDatabase(drivers[driver]->initdb( database )); + return false; + } + } + } + dbase->close(); + QSqlDatabase::removeDatabase(drivers[driver]->initdb( database )); + + // The database is created, now connect to the one specified by the user + dbase = QSqlDatabase::addDatabase(driver, database ); + dbase->setDatabaseName( database ); + dbase->setUserName( username ); + dbase->setPassword( password ); + dbase->setHostName( hostname ); + if(!dbase->open() || !dbase->isOpen()) { + KMessageBox::error( 0, i18n("KBarcode could not create the required database. Please create it manually.") + dbase->lastError().databaseText() ); + QSqlDatabase::removeDatabase( database ); + return false; + } + + + QSqlQuery query( NULL, dbase ); + + // barcode_basic + query.exec("DROP TABLE " TABLE_BASIC ); + exec( &query, "CREATE TABLE " TABLE_BASIC " (" + " uid " + drivers[driver]->autoIncrement() + "," + " article_no varchar(50) DEFAULT NULL," + " article_desc varchar(50) DEFAULT NULL," + " barcode_no TEXT DEFAULT NULL," + " encoding_type varchar(50) DEFAULT NULL," + " field0 varchar(50) DEFAULT NULL," + " field1 varchar(50) DEFAULT NULL," + " field2 varchar(50) DEFAULT NULL," + " field3 varchar(50) DEFAULT NULL," + " field4 varchar(50) DEFAULT NULL," + " field5 varchar(50) DEFAULT NULL," + " field6 varchar(50) DEFAULT NULL," + " field7 varchar(50) DEFAULT NULL," + " field8 varchar(50) DEFAULT NULL," + " field9 varchar(50) DEFAULT NULL," + " PRIMARY KEY (uid)" + ");" ); + + // customer + query.exec("DROP TABLE " TABLE_CUSTOMER ); + exec( &query, "CREATE TABLE " TABLE_CUSTOMER " (" + " uid " + drivers[driver]->autoIncrement() + " ," + " customer_no varchar(20) DEFAULT NULL," + " customer_name varchar(20) DEFAULT NULL," + " PRIMARY KEY (uid)" + ");" ); + + // customer_text + query.exec("DROP TABLE " TABLE_CUSTOMER_TEXT ); + exec( &query, "CREATE TABLE " TABLE_CUSTOMER_TEXT " (" + " uid " + drivers[driver]->autoIncrement() + "," + " customer_no varchar(20) DEFAULT NULL," + " encoding_type varchar(50) DEFAULT NULL," + " article_no varchar(50) DEFAULT NULL," + " article_no_customer varchar(50) NULL," + " barcode_no TEXT DEFAULT NULL," + " line0 varchar(50) DEFAULT NULL," + " line1 varchar(50) DEFAULT NULL," + " line2 varchar(50) DEFAULT NULL," + " line3 varchar(50) DEFAULT NULL," + " line4 varchar(50) DEFAULT NULL," + " line5 varchar(50) DEFAULT NULL," + " line6 varchar(50) DEFAULT NULL," + " line7 varchar(50) DEFAULT NULL," + " line8 varchar(50) DEFAULT NULL," + " line9 varchar(50) DEFAULT NULL," + " PRIMARY KEY (uid)" + ");" ); + + // label_def + query.exec("DROP TABLE " TABLE_LABEL_DEF ); + exec( &query, "CREATE TABLE " TABLE_LABEL_DEF " (" + " label_no " + drivers[driver]->autoIncrement() + "," + " manufacture varchar(255) DEFAULT NULL," + " type varchar(255) DEFAULT NULL," + " paper char(1) DEFAULT NULL," + " gap_top NUMERIC(10,4) NULL," + " gap_left NUMERIC(10,4) NULL," + " height NUMERIC(10,4) NULL," + " width NUMERIC(10,4) NULL," + " gap_v NUMERIC(10,4) NULL," + " gap_h NUMERIC(10,4) NULL," + " number_h int DEFAULT NULL," //smalint(6) + " number_v int DEFAULT NULL," //smalint(6) + " paper_type varchar(30) DEFAULT NULL," + " compatibility varchar(10) DEFAULT NULL," // keep compatibility with older versions, was "remark text" + " PRIMARY KEY (label_no)" + ");" ); + + dbase->close(); + QSqlDatabase::removeDatabase( database ); + KMessageBox::information( 0, i18n("Created table ")+database+i18n(" successfully!") ); + } else { + dbase->close(); + QSqlDatabase::removeDatabase(drivers[driver]->initdb( database )); + KMessageBox::sorry( 0, i18n("Can't connect to database.") ); + return false; + } + + return true; +} + +void SqlTables::importLabelDef() +{ + if( KMessageBox::warningContinueCancel( 0, i18n("We are going to delete the complete table: " ) + TABLE_LABEL_DEF ) == + KMessageBox::Cancel ) + return; + + QSqlQuery query( QString::null, db ); + exec( &query, "delete from " TABLE_LABEL_DEF ); + + QString f = locateLocal( "data", "kbarcode/labeldefinitions.sql" ); + if( !QFile::exists( f ) ) { + KConfig* config = kapp->config(); + config->setGroup( "Definitions" ); + f = config->readEntry( "defpath", locate( "data", "kbarcode/labeldefinitions.sql" ) ); + } + + importData( f, db ); + + Definition::updateProducer(); +} + +void SqlTables::importExampleData() +{ + if( KMessageBox::warningContinueCancel( 0, + i18n("We are going to delete the complete tables: " ) + QString( TABLE_BASIC ", " TABLE_CUSTOMER ", " TABLE_CUSTOMER_TEXT ) ) == + KMessageBox::Cancel ) + return; + + importData( locate("appdata", "exampledata.sql"), db ); +} + +void SqlTables::importData( const QString & filename, QSqlDatabase* db ) +{ + if( !db ) { + qDebug("Can't import data, dabase not open!"); + return; + } + + if( filename.isEmpty() || !db->isOpen() ) // quick escape + { + KMessageBox::error( NULL, i18n("Data file for import not found. Continuing without importing data. Please check your KBarcode installation.") ); + return; + } + + QFile data( filename); + QProgressDialog* dlg = new QProgressDialog( i18n("SQL import progress:"), QString::null, data.size(), 0, "dlg", true ); + + if( data.open( IO_ReadOnly ) ) { + QString s; + QSqlQuery query( QString::null, db ); + while( data.readLine( s, 1024 ) != -1 ) + if( !s.isEmpty() ) { + dlg->setProgress( dlg->progress() + s.length() ); + exec( &query, s ); + } + } else + KMessageBox::sorry( 0, i18n("Can't open the data file containing the label definitions.") ); + + dlg->close( true ); + data.close(); +} + +void SqlTables::exec( QSqlQuery* query, const QString & text ) +{ + if( !query->exec( text ) ) + KMessageBox::sorry( 0, i18n("<qt>Can't execute command:<br><b>") + text + "</b><br></qt>" + query->lastError().databaseText(), "sqlexecerror" ); +} + +void SqlTables::loadConfig() +{ + KConfig* config = kapp->config(); + + config->setGroup("SQL"); + sqldata.username = config->readEntry("username", "root"); + sqldata.password = config->readEntry("password", "" ); + sqldata.hostname = config->readEntry("hostname", "localhost" ); + sqldata.database = config->readEntry("database", "kbarcode" ); + sqldata.driver = config->readEntry("driver", "QMYSQL3" ); + sqldata.autoconnect = config->readBoolEntry("autoconnect", false ); +} + +void SqlTables::saveConfig() +{ + KConfig* config = kapp->config(); + + config->setGroup("SQL"); + config->writeEntry("username", sqldata.username ); + config->writeEntry("password", sqldata.password ); + config->writeEntry("hostname", sqldata.hostname ); + config->writeEntry("database", sqldata.database ); + config->writeEntry("driver", sqldata.driver ); + config->writeEntry("autoconnect", sqldata.autoconnect ); + + config->sync(); +} + +void SqlTables::updateTables() +{ + /* Older versions of KBarcode did only + * support MySQL. As a reason, databases + * do not need to be updated for other DBs + * as they have already been created with the most + * recent database structures. + */ + if( sqldata.driver != "QMYSQL3" ) + return; + + bool changed = false; + // check for field0 - field9 (1.4.0) + QStringList fields; + for( unsigned int i = 0; i < 10; i++ ) + fields.append( QString("field%1").arg( i ) ); + + QSqlQuery query("SHOW FIELDS FROM " TABLE_BASIC ); + while ( query.next() ) + if( fields.grep( query.value( 0 ).toString(), false ).count() ) { + fields.remove( query.value( 0 ).toString() ); + } + + if( fields.count() ) { + QSqlQuery q; + for( unsigned int i = 0; i < 10; i++ ) + q.exec("ALTER TABLE " TABLE_BASIC " ADD " + fields[i] + " varchar(50)"); + + qDebug("changing fields"); + changed = true; + } + + // change barcode_no from varchar to TEXT (1.5.0) + QSqlQuery query2("SHOW FIELDS FROM " TABLE_BASIC ); + while( query2.next() ) + if( query2.value( 0 ).toString() == "barcode_no" && query2.value(1) == "varchar(50)" ) { + query2.exec( "ALTER TABLE " TABLE_BASIC " CHANGE barcode_no barcode_no TEXT" ); + changed = true; + } + + // change barcode_no from varchar to TEXT (1.5.0) + QSqlQuery query3("SHOW FIELDS FROM " TABLE_CUSTOMER_TEXT ); + while( query3.next() ) + if( query3.value( 0 ).toString() == "barcode_no" && query3.value(1) == "varchar(50)" ) { + query3.exec( "ALTER TABLE " TABLE_CUSTOMER_TEXT " CHANGE barcode_no barcode_no TEXT" ); + changed = true; + } + + // change NUMERIC DEFAULT TO NUMERIC(10,4) (1.6.1) + QStringList update; + update << "gap_top" << "gap_left" << "height" << "width" << "gap_v" << "gap_h"; + QSqlQuery query4("SHOW FIELDS FROM " TABLE_LABEL_DEF ); + while( query4.next() ) + if( update.contains( query4.value( 0 ).toString() ) && query4.value(1).toString() == "decimal(10,0)" ) { + QSqlQuery q; + q.exec( QString("ALTER TABLE " TABLE_LABEL_DEF " CHANGE ") + + query4.value( 0 ).toString() + " " + query4.value( 0 ).toString() + " NUMERIC(10,4)" ); + changed = true; + } + + if( changed ) + KMessageBox::information( 0, i18n("The SQL tables of KBarcode have changed since the last version. " + "KBarcode updated them without any loss of data." ) ); +} + +bool SqlTables::testSettings( const QString & username, const QString & password, const QString & hostname, const QString & database, const QString & driver ) +{ + QSqlDatabase* db = QSqlDatabase::addDatabase( driver ); + if( !drivers[driver] ) + return false; + + db->setDatabaseName( database ); + db->setUserName( username ); + db->setPassword( password ); + db->setHostName( hostname ); + + if( !db->open() ) + { + QSqlDatabase::removeDatabase( database ); + } + else + { + KMessageBox::information( 0, i18n("Connected successfully to your database") ); + db->close(); + QSqlDatabase::removeDatabase( database ); + return true; + } + + db = QSqlDatabase::addDatabase( driver ); + + db->setDatabaseName( drivers[driver]->initdb( database ) ); + + db->setUserName( username ); + db->setPassword( password ); + db->setHostName( hostname ); + + if( !db->open() ) { + KMessageBox::error( 0, i18n("<qt>Connection failed:<br>") + database + "<br>" + + db->lastError().databaseText() + "</qt>" ); + QSqlDatabase::removeDatabase(drivers[driver]->initdb( database )); + return false; + } else { + KMessageBox::information( 0, i18n("Connected successfully to your database") ); + db->close(); + QSqlDatabase::removeDatabase(drivers[driver]->initdb( database )); + return true; + } + +} + +const QString SqlTables::getBarcodeMaxLength( const QString & name ) +{ + if( SqlTables::isConnected() ) + { + QSqlQuery query("select uid, (length(barcode_no)) as LEN from " TABLE_BASIC + " where encoding_type = '" + name +"' ORDER by LEN DESC LIMIT 1" ); + + while( query.next() ) { + QSqlQuery queryuid("select barcode_no from barcode_basic where uid = '" + + query.value( 0 ).toString() + "'" ); + while( queryuid.next() ) + if(!queryuid.value( 0 ).toString().isEmpty()) + return queryuid.value( 0 ).toString(); + } + + QSqlQuery query1("select uid, (length(barcode_no)) as LEN from " TABLE_CUSTOMER_TEXT + " where encoding_type = '" + name +"' ORDER by LEN DESC LIMIT 1" ); + + while( query1.next() ) { + QSqlQuery queryuid("select barcode_no from customer_text where uid = '" + + query1.value( 0 ).toString() + "'" ); + while( queryuid.next() ) + if(!queryuid.value( 0 ).toString().isEmpty()) + return queryuid.value( 0 ).toString(); + } + } + + return "1234567"; +} + +SqlWidget::SqlWidget( bool showlabel, QWidget* parent, const char* name ) + : QWidget( parent, name ) +{ + QVBoxLayout* layout = new QVBoxLayout( this ); + + QGroupBox* groupDatabase = new QGroupBox( this ); + groupDatabase->setTitle( i18n( "Database Settings" ) ); + groupDatabase->setColumnLayout(0, Qt::Vertical ); + groupDatabase->layout()->setSpacing( 6 ); + groupDatabase->layout()->setMargin( 11 ); + QVBoxLayout* groupDatabaseLayout = new QVBoxLayout( groupDatabase->layout() ); + groupDatabaseLayout->setAlignment( Qt::AlignTop ); + + QGridLayout* grid = new QGridLayout( 2, 2 ); + + QLabel* label = new QLabel( groupDatabase ); + label->setText( i18n("Username :") ); + grid->addWidget( label, 0, 0 ); + + m_username = new KLineEdit( groupDatabase ); + grid->addWidget( m_username, 0, 1 ); + + label = new QLabel( groupDatabase ); + label->setText( i18n("Password :") ); + grid->addWidget( label, 1, 0 ); + + m_password = new KLineEdit( groupDatabase ); + m_password->setEchoMode( KLineEdit::Password ); + grid->addWidget( m_password, 1, 1 ); + + label = new QLabel( groupDatabase ); + label->setText( i18n("Database :") ); + grid->addWidget( label, 2, 0 ); + + m_database = new KLineEdit( "kbarcode", groupDatabase ); + grid->addWidget( m_database, 2, 1 ); + + label = new QLabel( groupDatabase ); + label->setText( i18n("Host :") ); + grid->addWidget( label, 3, 0 ); + + m_hostname = new KLineEdit( "localhost", groupDatabase ); + grid->addWidget( m_hostname, 3, 1 ); + + label = new QLabel( groupDatabase ); + label->setText( i18n("Driver :") ); + grid->addWidget( label, 4, 0 ); + + m_driver = new KComboBox( false, groupDatabase ); + QStringList drList = QSqlDatabase::drivers(); + QStringList::Iterator it = drList.begin(); + while( it != drList.end() ) { + m_driver->insertItem( *it ); + ++it; + } + grid->addWidget( m_driver, 4, 1 ); + groupDatabaseLayout->addLayout( grid ); + + m_autoconnect = new QCheckBox( i18n("&Autoconnect on program start"), groupDatabase ); + groupDatabaseLayout->addWidget( m_autoconnect ); + + buttonTest = new KPushButton( groupDatabase, "buttonTest" ); + buttonTest->setText( i18n( "&Test Settings" ) ); + + groupDatabaseLayout->addWidget( buttonTest ); + if( showlabel ) + groupDatabaseLayout->addWidget( new QLabel( i18n("<b>You have to test your database settings before you can procede.</b>"), groupDatabase ) ); + + layout->add( groupDatabase ); + + connect( buttonTest, SIGNAL( clicked() ), this, SLOT( testSettings() ) ); + + const mysqldata & sqldata = SqlTables::getInstance()->getData(); + m_username->setText( sqldata.username ); + m_password->setText( sqldata.password ); + m_hostname->setText( sqldata.hostname ); + m_database->setText( sqldata.database ); + m_autoconnect->setChecked( sqldata.autoconnect ); + for( int i = 0; i < m_driver->count(); i++ ) + if( m_driver->text(i) == sqldata.driver ) + m_driver->setCurrentItem( i ); +} + +SqlWidget::~SqlWidget() +{ +} + +void SqlWidget::save( bool usedb ) +{ + mysqldata sqldata = SqlTables::getInstance()->getData(); + sqldata.username = m_username->text(); + sqldata.password = m_password->text(); + sqldata.hostname = m_hostname ->text(); + sqldata.database = m_database->text(); + sqldata.driver = m_driver->currentText(); + sqldata.autoconnect = ( usedb ? m_autoconnect->isChecked() : false ); + SqlTables::getInstance()->setData( sqldata ); +} + +void SqlWidget::testSettings() +{ + emit databaseWorking( + SqlTables::getInstance()->testSettings( m_username->text(), m_password->text(), + m_hostname->text(), m_database->text(), + m_driver->currentText() ) ); +} + +const QString SqlWidget::username() const +{ + return m_username->text(); +} + +const QString SqlWidget::driver() const +{ + return m_driver->currentText(); +} + +const QString SqlWidget::database() const +{ + return m_database->text(); +} + +const QString SqlWidget::hostname() const +{ + return m_hostname->text(); +} + +const QString SqlWidget::password() const +{ + return m_password->text(); +} + +bool SqlWidget::autoconnect() const +{ + return m_autoconnect->isChecked(); +} + +int SqlWidget::driverCount() const +{ + return m_driver->count(); +} + + +#include "sqltables.moc" diff --git a/kbarcode/sqltables.h b/kbarcode/sqltables.h new file mode 100644 index 0000000..d78fd21 --- /dev/null +++ b/kbarcode/sqltables.h @@ -0,0 +1,222 @@ +/*************************************************************************** + sqltables.h - description + ------------------- + begin : Son Dez 29 2002 + copyright : (C) 2002 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef SQLTABLES_H +#define SQLTABLES_H + +#include <qobject.h> +#include <qwidget.h> +#include <qstring.h> + + +/* Change these values to match your environment: */ +#define TABLE_CUSTOMER "customer" +#define TABLE_CUSTOMER_TEXT "customer_text" +#define TABLE_LABEL_DEF "label_def" +#define TABLE_BASIC "barcode_basic" +/* -------- */ + +// a macro to support QString::replace( QString, QString ) +// also on QT 3.0.x +#if QT_VERSION <= 0x030100 + #include <qregexp.h> + #define DSREPLACE( x ) QRegExp( x ) +#else + #define DSREPLACE( x ) x +#endif + +// Holds all information +// necessary for connecting +// to a database +typedef struct mysqldata { + QString username; + QString password; + QString hostname; // localhost + QString database; // kbarcode + QString driver; // QMYSQL3 + bool autoconnect; + + void operator=( const mysqldata & rhs ) { + username = rhs.username; + password = rhs.password; + hostname = rhs.hostname; + database = rhs.database; + driver = rhs.driver; + + autoconnect = rhs.autoconnect; + } +}; + + +/** + * This class describes a SQL database (e.g. MySQL or PostgreSQL) + * and its features. + * @author Dominik Seichter + */ +class SqlDescription { + public: + /** return the name of the database we can always + * use to connect to this database. + */ + virtual const QString initdb( QString ) const = 0; + + /** return the auto_increment or serial command used for this db. + */ + virtual const QString autoIncrement() const = 0; + + /** return the command to show all fields of table for this db. + */ + virtual const QString showColumns( const QString & table ) const = 0; +}; + +class QSqlDatabase; +class QSqlQuery; +/** + * This class is used to access a database, create it and save its settings to the + * application configuration file. Also the labeldefinitions and exmplate data + * are imported using this class. + * + * @short This singleton is used to access a database in KBarcode. + * @author Dominik Seichter + */ +class SqlTables : public QObject { + Q_OBJECT + public: + /** get a mysqldata object which contains the current database settings. + * this object is for all sql databases, not only for mysql. The name is just a + * relict from the past ;-) + * @return mysqldata* + */ + const mysqldata & getData() const { + return sqldata; + } + + /** Set the database settings + */ + void setData( const mysqldata & data ) { + sqldata = data; + } + + /** get an instance of this singleton class. Always use this method as there is + * no public constructor. + * @return SqlTables* + */ + static SqlTables* getInstance(); + + /** returns true if KBarcode is connected to a database at the moment. Returns false if not. + * @return bool + */ + static bool isConnected() { + return getInstance()->connected; + } + + const SqlDescription* driver() const; + + public slots: + const QString getBarcodeMaxLength( const QString & name ); + + void loadConfig(); + void saveConfig(); + + /** Connect to a SQL database using breviously configured + * database settings. + * @return bool returns true on success + */ + bool connectMySQL(); + + bool newTables(); + bool newTables( const QString & username, const QString & password, const QString & hostname, const QString & database, const QString & driver ); + void importLabelDef(); + void importExampleData(); + void importData( const QString & filename, QSqlDatabase* db ); + bool testSettings( const QString & username, const QString & password, const QString & hostname, const QString & database, const QString & driver ); + + inline QSqlDatabase* database() const; + + signals: + void tablesChanged(); + void connectedSQL(); + + private: + SqlTables( QObject* parent = 0 ); + ~SqlTables(); + + void exec( QSqlQuery* query, const QString & text ); + void updateTables(); + + bool connected; + + QSqlDatabase* db; + mysqldata sqldata; + + static SqlTables* instance; +}; + +inline QSqlDatabase* SqlTables::database() const +{ + return db; +} + +class KComboBox; +class KLineEdit; +class KPushButton; +class QCheckBox; +/** A widget for configuring a SQL connection. + * It has child widgets for entering data like the + * user name, database name, host name, password + * and the driver. Optionally the user can also + * test if his settings will work. + * + * @author Dominik Seichter + */ +class SqlWidget : public QWidget { + Q_OBJECT + public: + SqlWidget( bool showlabel, QWidget* parent = 0, const char* name = 0 ); + ~SqlWidget(); + + const QString username() const; + const QString driver() const; + const QString database() const; + const QString hostname() const; + const QString password() const; + bool autoconnect() const; + + int driverCount() const; + + void save( bool usedb = true ); + + signals: + void databaseWorking( bool b ); + + private slots: + void testSettings(); + + private: + KComboBox* m_driver; + + KLineEdit* m_username; + KLineEdit* m_database; + KLineEdit* m_hostname; + KLineEdit* m_password; + + QCheckBox* m_autoconnect; + + KPushButton* buttonTest; +}; + +#endif diff --git a/kbarcode/tbarcode2.cpp b/kbarcode/tbarcode2.cpp new file mode 100644 index 0000000..a07ff41 --- /dev/null +++ b/kbarcode/tbarcode2.cpp @@ -0,0 +1,158 @@ +/*************************************************************************** + tbarcode2.cpp - description + ------------------- + begin : Mon Feb 20 2006 + copyright : (C) 2006 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "tbarcode2.h" +#include "barkode.h" + +#include <stdlib.h> + +#include <qdom.h> +#include <qfile.h> + +#include <kprocess.h> +#include <ktempfile.h> + +TBarcodeOptions::TBarcodeOptions() +{ + defaults(); +} + +void TBarcodeOptions::defaults() +{ + m_escape = false; + m_above = false; + m_autocorrect = false; + m_checksum = 0; + m_modulewidth = 0.353; + m_height = 20; +} + +void TBarcodeOptions::load( const QDomElement* tag ) +{ + this->setModuleWidth( tag->attribute( "tbarcode.modulewidth", "0.353" ).toDouble() ); + this->setEscape( tag->attribute( "tbarcode.escape", "0" ).toInt() ); + this->setAbove( tag->attribute( "tbarcode.above", "0" ).toInt() ); + this->setAutocorrect( tag->attribute ( "tbarcode.autocorrect", "0" ).toInt() ); + this->setCheckSum( tag->attribute( "tbarcode.checksum", "0" ).toInt() ); + this->setHeight( tag->attribute( "tbarcode.height", "0" ).toInt() ); +} + +void TBarcodeOptions::save( QDomElement* tag ) +{ + tag->setAttribute( "tbarcode.modulewidth", this->moduleWidth() ); + tag->setAttribute( "tbarcode.escape", this->escape() ); + tag->setAttribute( "tbarcode.above", this->above() ); + tag->setAttribute( "tbarcode.autocorrect", this->autocorrect() ); + tag->setAttribute( "tbarcode.checksum", this->checksum() ); + tag->setAttribute( "tbarcode.height", this->height() ); +} + +const TBarcodeOptions& TBarcodeOptions::operator=( const BarkodeEngineOptions& rhs ) +{ + const TBarcodeOptions* tbarcode = (dynamic_cast<const TBarcodeOptions*>(&rhs)); + + this->m_escape = tbarcode->m_escape; + this->m_above = tbarcode->m_above; + this->m_autocorrect = tbarcode->m_autocorrect; + this->m_checksum = tbarcode->m_checksum; + this->m_modulewidth = tbarcode->m_modulewidth; + this->m_height = tbarcode->m_height; + + return *this; +} + +TBarcode2::TBarcode2() + : PixmapBarcode() +{ + +} + +TBarcode2::~TBarcode2() +{ + +} + +const TBarcode2 & TBarcode2::operator=( const BarkodeEngine & rhs ) +{ + const TBarcode2* barcode = dynamic_cast<const TBarcode2*>(&rhs); + + if( barcode ) + { + m_options = barcode->m_options; + } + + return *this; +} + +bool TBarcode2::createPostscript( char** postscript, long* postscript_size ) +{ + QString cmd; + const char* text; + + const TBarcodeOptions* tbarcode = (dynamic_cast<TBarcodeOptions*>(barkode->engine()->options())); + if( !tbarcode ) + return false; + + if( !barkode->textVisible() ) + text = "hide"; + else if( tbarcode->above() ) + text = "above"; + else + text = "below"; + + cmd = cmd.sprintf( "tbarcode -f PS -b %s -d %s -t %s --translation=%s --autocorrect=%s --modulewidth=%.3f -h %i --checkdigit=%i --72dpiraster\n", + barkode->type().latin1(), KShellProcess::quote( barkode->parsedValue() ).latin1(), + text, tbarcode->escape() ? "on" : "off", + tbarcode->autocorrect() ? "on" : "off", + tbarcode->moduleWidth(), + tbarcode->height(), + tbarcode->checksum() ); + + qDebug( "Cmd = " + cmd ); + if( !readFromPipe( cmd.latin1(), postscript, postscript_size ) ) + return false; + + return true; +} + +QRect TBarcode2::bbox( const char* postscript, long postscript_size ) +{ + const char* gs_bbox = "gs -sDEVICE=bbox -sNOPAUSE -q %1 -c showpage quit 2>&1"; + + char* buffer = NULL; + long len = 0; + QRect size; + + KTempFile psfile( QString::null, ".ps" ); + psfile.file()->writeBlock( postscript, postscript_size ); + psfile.file()->close(); + + if( !readFromPipe( QString( gs_bbox ).arg( psfile.file()->name() ).latin1(), &buffer, &len ) || !len ) + { + psfile.unlink(); + return QRect( 0, 0, 0, 0 ); + } + else + psfile.unlink(); + + size = PixmapBarcode::bbox( buffer, len ); + free( buffer ); + + return size; + +} + diff --git a/kbarcode/tbarcode2.h b/kbarcode/tbarcode2.h new file mode 100644 index 0000000..30b70d9 --- /dev/null +++ b/kbarcode/tbarcode2.h @@ -0,0 +1,89 @@ +/*************************************************************************** + tbarcode2.h - description + ------------------- + begin : Mon Feb 20 2006 + copyright : (C) 2006 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TBARCODE2_H +#define TBARCODE2_H + +#include "pixmapbarcode.h" + +class QDomElement; + +/** A small class which contains all the options + * which can be configured for tbarcode + */ +class TBarcodeOptions : public BarkodeEngineOptions { + public: + TBarcodeOptions(); + + const TBarcodeOptions& operator=( const BarkodeEngineOptions& rhs ); + void defaults(); + + void load( const QDomElement* tag ); + void save( QDomElement* tag ); + + inline bool escape() const { return m_escape; } + inline bool above() const { return m_above; } + inline bool autocorrect() const { return m_autocorrect; } + inline int checksum() const { return m_checksum; } + inline double moduleWidth() const { return m_modulewidth; } + inline int height() const { return m_height; } + + inline void setEscape( bool b ) { m_escape = b; } + inline void setAbove( bool b ) { m_above = b; } + inline void setAutocorrect( bool b ) { m_autocorrect = b; } + inline void setModuleWidth( double d ) { m_modulewidth = d; } + inline void setCheckSum( int i ) { m_checksum = i; } + inline void setHeight( int i ) { m_height = i; } + private: + bool m_escape; + bool m_above; + bool m_autocorrect; + double m_modulewidth; + int m_checksum; + int m_height; +}; + +class TBarcode2 : public PixmapBarcode { + public: + TBarcode2(); + ~TBarcode2(); + + const TBarcode2 & operator=( const BarkodeEngine & rhs ); + + inline EEngine engine() const; + + inline BarkodeEngineOptions* options(); + + private: + virtual bool createPostscript( char** postscript, long* postscript_size ); + virtual QRect bbox( const char* postscript, long postscript_size ); + + private: + TBarcodeOptions m_options; +}; + +EEngine TBarcode2::engine() const +{ + return TBARCODE2; +} + +BarkodeEngineOptions* TBarcode2::options() +{ + return &m_options; +} + +#endif /* TBARCODE2_H */ diff --git a/kbarcode/tcanvasitem.cpp b/kbarcode/tcanvasitem.cpp new file mode 100644 index 0000000..f770a63 --- /dev/null +++ b/kbarcode/tcanvasitem.cpp @@ -0,0 +1,221 @@ +/*************************************************************************** + tcanvasitem.cpp - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#include "tcanvasitem.h" +#include "mycanvasitem.h" +#include "mycanvasview.h" +#include "imageitem.h" + +#include <qpainter.h> +#include <labelutils.h> + +TCanvasItem::TCanvasItem( MyCanvasView* cv ) + : QCanvasRectangle( cv->canvas() ), + ReferenceCounted() +{ + m_view = cv; + m_item = NULL; + show(); +} + +TCanvasItem::~TCanvasItem() +{ + if( m_item ) + delete m_item; +} + +void TCanvasItem::setZ( double z ) +{ + QCanvasRectangle::setZ( z ); + + if( m_item ) + m_item->setZ( (int)z ); +} + +void TCanvasItem::setSize( int width, int height ) +{ + QCanvasRectangle::setSize( width, height ); + + if( m_item ) + { + m_item->setSize( width, height ); + + if( m_item->rtti() == eRtti_Image ) + { + ImageItem* img = static_cast<ImageItem*>(m_item); + img->updateImage(); + } + + update(); + } +} + +void TCanvasItem::setSizeMM( int w, int h ) +{ + if( m_item ) + { + m_item->setSizeMM( w, h ); + QCanvasRectangle::setSize( m_item->boundingRect().width(), m_item->boundingRect().height() ); + } +} + +void TCanvasItem::moveBy( double dx, double dy ) +{ + QCanvasRectangle::moveBy( dx, dy ); + + if( m_item ) + { + m_item->move( (int)x() - m_view->getTranslation().x(), (int)y() - m_view->getTranslation().y() ); + update(); + } +} + +void TCanvasItem::moveByMM( int x, int y ) +{ + moveMM( m_item->rectMM().x() + x, m_item->rectMM().y() + y ); +} + +void TCanvasItem::moveMM( int x, int y ) +{ + if( m_item ) + { + LabelUtils l; + // the QCanvasRectangle::move is done before the real move + // as we get dancing TCanvasItems on the screen otherwise + QCanvasRectangle::move( l.mmToPixel( x / 1000.0, m_view, LabelUtils::DpiX ) + m_view->getTranslation().x(), + l.mmToPixel( y / 1000.0, m_view, LabelUtils::DpiY ) + m_view->getTranslation().y() ); + m_item->moveMM( x, y ); + } +} + +void TCanvasItem::drawShape (QPainter & painter) +{ + painter.save(); + + if( m_item ) + { + if( z() != (int)m_item->z() ) + QCanvasRectangle::setZ( m_item->z() ); + + painter.save(); + painter.setClipRect( boundingRect(), QPainter::CoordPainter ); + painter.translate( m_view->getTranslation().x(), m_view->getTranslation().y() ); + m_item->draw( &painter ); + painter.restore(); + } + + // draw edges + if( isSelected() ) { + const QPixmap* spot = SpotProvider::getInstance()->spot(); + painter.translate( x(), y() ); + + // top left + painter.drawPixmap( 0, 0, *spot ); + // bottom left + painter.drawPixmap( 0, height()-SPOTSIZE, *spot ); + // top right + painter.drawPixmap( width()-SPOTSIZE, 0, *spot ); + // bottom left + painter.drawPixmap( width()-SPOTSIZE, height()-SPOTSIZE, *spot ); + + if( (width() - 2 * SPOTSIZE ) / 2 > SPOTSIZE ) { + // top middle + painter.drawPixmap( (width()-SPOTSIZE)/2, 0, *spot ); + // bottom middle + painter.drawPixmap( (width()-SPOTSIZE)/2, height()-SPOTSIZE, *spot ); + } + + if( (height() - 2 * SPOTSIZE ) / 2 > SPOTSIZE ) { + // left middle + painter.drawPixmap( 0, (height()-SPOTSIZE)/2, *spot ); + // right middle + painter.drawPixmap( width() - SPOTSIZE, (height()-SPOTSIZE)/2, *spot ); + } + } + painter.restore(); +} + +void TCanvasItem::setItem (DocumentItem* item) +{ + if( m_item ) + m_item->setCanvasItem( NULL ); + + m_item = item; + + if( m_item ) + { + m_item->setCanvasItem( this ); + this->setZ( m_item->z() ); + + QCanvasRectangle::move( m_item->boundingRect().x() + m_view->getTranslation().x(), m_item->boundingRect().y() + m_view->getTranslation().y() ); + QCanvasRectangle::setSize( m_item->boundingRect().width(), m_item->boundingRect().height() ); + update(); + } +} + +DocumentItem* TCanvasItem::item () const +{ + return m_item; +} + +void TCanvasItem::update() +{ + QCanvasRectangle::update(); +} + +int TCanvasItem::rtti() const +{ + if( m_item ) + return m_item->rtti(); + else + return 0; +} + +MyCanvasView* TCanvasItem::canvasView() const +{ + return m_view; +} + + + +void TCanvasItem::show() +{ + if (!isVisible()) + { + this->addRef(); + ((QCanvasItem*) this)->show(); + } +} + +void TCanvasItem::hide() +{ + if (refCount()==1) + { + if (isVisible()) + { + this->remRef(); + } + } + else + { + if (isVisible()) + { + ((QCanvasItem*) this)->hide(); + this->remRef(); + } + } +} diff --git a/kbarcode/tcanvasitem.h b/kbarcode/tcanvasitem.h new file mode 100644 index 0000000..7493fa8 --- /dev/null +++ b/kbarcode/tcanvasitem.h @@ -0,0 +1,57 @@ + +#ifndef TCANVASITEM_H +#define TCANVASITEM_H +#include <qstring.h> +#include <qcanvas.h> + +#include "documentitem.h" +#include "referencecounted.h" + +class MyCanvasView; +/** + * Class TCanvasItem + * Represents a DocumentItem on a QCanvas. + * This class is also responsible for drawing + * the drag marks provided by SpotProvider. + * + * The class is also ReferenceCounted!!! + */ +class TCanvasItem : public QCanvasRectangle, public ReferenceCounted { +public: + + TCanvasItem ( MyCanvasView* cv ); + ~TCanvasItem ( ); + + void update(); + + int rtti() const; + + void setZ( double z ); + void moveBy( double x, double y ); + void setSize( int width, int height ); + + void moveMM( int x, int y ); + void moveByMM( int x, int y ); + void setSizeMM( int w, int h ); + + void show(); + void hide(); + + void setItem (DocumentItem* item); + DocumentItem* item () const; + + MyCanvasView* canvasView() const; + +protected: + /** + * + * @param painter + */ + void drawShape ( QPainter & p ); + +private: + DocumentItem* m_item; + MyCanvasView* m_view; +}; +#endif //TCANVASITEM_H + diff --git a/kbarcode/tec.cpp b/kbarcode/tec.cpp new file mode 100644 index 0000000..174806e --- /dev/null +++ b/kbarcode/tec.cpp @@ -0,0 +1,658 @@ +// +// C++ Implementation: tec +// +// Description: +// +// +// Author: Dominik Seichter <domseichter@web.de>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "tec.h" +#include "kbarcodesettings.h" +#include "tokenprovider.h" + +// Other includes +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <termios.h> +#include <math.h> +#include <unistd.h> + +// QT includes +#include <qclipboard.h> +#include <qcursor.h> +#include <qgroupbox.h> +#include <qhbox.h> +#include <qlayout.h> +#include <qpainter.h> +#include <qpaintdevicemetrics.h> +#include <qprogressdialog.h> +#include <qsqlcursor.h> +#include <qvalidator.h> + +// KDE includes +#include <kapplication.h> +#include <kcombobox.h> +#include <kfiledialog.h> +#include <kiconloader.h> +#include <klistview.h> +#include <klineedit.h> +#include <klineeditdlg.h> +#include <klocale.h> +#include <kmenubar.h> +#include <kmessagebox.h> +#include <kpopupmenu.h> +#include <knuminput.h> +#include <kprinter.h> +#include <kurlrequester.h> + +#define MAXDATASIZE 32550 + +QString tec452(const QString &url, int count, const QString &art, const QString &group, const QString &id) +{ + QString filename; + QString result; + int countBar=0; + int countText=0; + +// if( url.isEmpty() ) { +// return open(); +// } + + filename = url; + //setCaption( filename, false ); + + QFile f( filename ); + if ( !f.open( IO_ReadOnly ) ) + return false; + + //clearLabel(); + + QDomDocument doc( "KBarcodeLabel" ); + if ( !doc.setContent( &f ) ) { + f.close(); + return false; + } + f.close(); + + QDomNode n = doc.documentElement().firstChild(); + // this should not be neccessary, + // but <label><id> needs to be processed first + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + // label has to be the first xml element! + if( e.tagName() == "label" ) { + QDomNode n = e.firstChild(); + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + if( e.tagName() == "id" ) { + result += QString("{D%1,").arg( convZeros((e.attribute( "height" ).toInt() + e.attribute( "gap_v" ).toInt())*10,4)); // Altura + Gap vertical + result += QString("%1,").arg( convZeros(e.attribute( "width" ).toInt()*10,4) ); // Anchura + result += QString("%1|}\n").arg( convZeros(e.attribute( "height" ).toInt()*10,4) ); // Altura + result += QString("{C|}\n"); // Clear buffer + result += QString("{U2;0130|}\n"); // BackFeed + result += QString("{D%1,").arg( convZeros((e.attribute( "height" ).toInt() + e.attribute( "gap_v" ).toInt())*10,4)); // Altura + Gap vertical + result += QString("%1,").arg( convZeros(e.attribute( "width" ).toInt()*10,4) ); // Anchura + result += QString("%1|}\n").arg( convZeros(e.attribute( "height" ).toInt()*10,4) ); // Altura + result += QString("{AX;+000,+000,+00|}\n"); // Position Fine adjust + result += QString("{AY;+04,1|}\n"); // Print density fine adjust + + } + + n = n.nextSibling(); + } + } + n = n.nextSibling(); + } + + n = doc.documentElement().firstChild(); + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + if( e.tagName() == "barcode" ) { + + if ( e.attribute( "type" ) == "i25" or e.attribute( "type" ) == "i25 -c" or e.attribute( "type" ) == "code39" or e.attribute( "type" ) == "code39 -c" or e.attribute( "type" ) == "b7" or e.attribute( "type" ) == "b8" or e.attribute( "type" ) == "b9" or e.attribute( "type" ) == "pls" or e.attribute( "type" ) == "msi" or e.attribute( "type" ) == "b33") result += code39(e, countBar); + + if ( e.attribute( "type" ) == "ean" or e.attribute( "type" ) == "upc" or e.attribute( "type" ) == "code93" or e.attribute( "type" ) == "code128" or e.attribute( "type" ) == "b10" or e.attribute( "type" ) == "b11" or e.attribute( "type" ) == "b15" or e.attribute( "type" ) == "b14" or e.attribute( "type" ) == "b34" or e.attribute( "type" ) == "b35" or e.attribute( "type" ) == "b36" or e.attribute( "type" ) == "b37" or e.attribute( "type" ) == "b39" or e.attribute( "type" ) == "b39" or e.attribute( "type" ) == "b13" or e.attribute( "type" ) == "b12" or e.attribute( "type" ) == "b20" or e.attribute( "type" ) == "b25") result += code128(e, countBar); + + if ( e.attribute( "type" ) == "b55" ) result += pdf417(e, countBar); + + QString data; + QDomNode n = e.firstChild(); + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + if( e.tagName() == "value" ) data = e.text(); + n = n.nextSibling(); + } + result += QString("{RB%1;").arg( convZeros(countBar, 2) ); // count de RB + result += QString("%1|}\n").arg( data ); // Data + fin + countBar++; + + } else if( e.tagName() == "textfield" ) { + + result += QString("{PC%1;").arg( convZeros(countText, 3) ); // count + result += QString("%1,").arg( posConv(e.attribute( "x_mm"), 4 ) ); // X position + result += QString("%1,").arg( posConv(e.attribute( "y_mm"), 4 ) ); // Y position + result += QString("%1,").arg( "10" ); + result += QString("%1,").arg( "15" ); + result += QString("%1,").arg( "J" ); + result += QString("%1,").arg( "00" ); + result += QString("%1|}\n").arg( "B" ); + + QString etext; + QDomNode n = e.firstChild(); + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + if( e.tagName() == "text" ) + etext = e.text(); + n = n.nextSibling(); + } + + result += QString("{RC%1;").arg( convZeros(countText, 3) ); // count de RB + etext=getData(etext, art, group, id ); + result += QString("%1|}\n").arg( etext ); // Data + fin + countText++; + } + else if( e.tagName() == "rect" ) { + + if (e.attribute("colorr")=="0" and e.attribute("colorg")=="0" and e.attribute("colorb")=="0") { + + result += QString("{XR;"); // XR + result += QString("%1,").arg( posConv(e.attribute( "x_mm"), 4 ) ); // X position + result += QString("%1,").arg( posConv(e.attribute( "y_mm"), 4 ) ); // Y position + result += QString("%1,").arg( convZeros(posConv(e.attribute( "x_mm"), 4 ).toInt()+posConv(e.attribute( "width_mm"),4 ).toInt(),4)); // X position + result += QString("%1,").arg( convZeros(posConv(e.attribute( "y_mm"), 4 ).toInt()+posConv(e.attribute( "height_mm"),4 ).toInt(),4)); // Y position + result += QString("A"); // Type of Clear + result += QString("|}\n"); // FIN + result += QString("{XR;"); // XR + result += QString("%1,").arg( posConv(e.attribute( "x_mm"), 4 ) ); // X position + result += QString("%1,").arg( posConv(e.attribute( "y_mm"), 4 ) ); // Y position + result += QString("%1,").arg( convZeros(posConv(e.attribute( "x_mm"), 4 ).toInt()+posConv(e.attribute( "width_mm"),4 ).toInt(),4)); // X position + result += QString("%1,").arg( convZeros(posConv(e.attribute( "y_mm"), 4 ).toInt()+posConv(e.attribute( "height_mm"),4 ).toInt(),4)); // Y position + result += QString("B"); // Type of Clear + result += QString("|}\n"); // FIN + } + else { + result += QString("{LC;"); // LC + result += QString("%1,").arg( posConv(e.attribute( "x_mm"), 4 ) ); // X position + result += QString("%1,").arg( posConv(e.attribute( "y_mm"), 4 ) ); // Y position + result += QString("%1,").arg( convZeros(posConv(e.attribute( "x_mm"), 4 ).toInt()+posConv(e.attribute( "width_mm"),4 ).toInt(),4)); // X position + result += QString("%1,").arg( convZeros(posConv(e.attribute( "y_mm"), 4 ).toInt()+posConv(e.attribute( "height_mm"),4 ).toInt(),4)); // Y position + result += QString("1,"); // Type of line 0=line 1=Rectangulo 2=Jagged line 3=Rectangle with jagged lines + result += QString("%1").arg(lineWidth(e)); // No. of line width dots 1-9 + //result += QString("999"); // Radius of rounded corners of a rectangle + result += QString("|}\n"); // FIN + } + } + else if( e.tagName() == "line" ) { + result += QString("{LC;"); // LC + result += QString("%1,").arg( posConv(e.attribute( "x_mm"), 4 ) ); // X position + result += QString("%1,").arg( posConv(e.attribute( "y_mm"), 4 ) ); // Y position + result += QString("%1,").arg( convZeros(posConv(e.attribute( "x_mm"), 4 ).toInt()+posConv(e.attribute( "width_mm"),4 ).toInt(),4)); // X position + result += QString("%1,").arg( convZeros(posConv(e.attribute( "y_mm"), 4 ).toInt()+posConv(e.attribute( "height_mm"),4 ).toInt(),4)); // Y position + result += QString("0,"); // Type of line 0=line 1=Rectangulo 2=Jagged line 3=Rectangle with jagged lines + result += QString("%1").arg(lineWidth(e)); // No. of line width dots 1-9 + //result += QString("999"); // Radius of rounded corners of a rectangle + result += QString("|}\n"); // FIN + } + n = n.nextSibling(); + } + + result += QString("{U1;0130|}\n"); // ForwardFeed + result += QString("{XS;I,%1,0000C2000|}\n").arg(convZeros(count,4)); // Issue Command + + return result; +} + + +QString convZeros( int count, int zeros ) +{ +QString str= QString("%1").arg(count); +int l=strlen(str); //get the string length +for(;l<zeros;l++) str = QString("0") + str; +return str; +} + +QString posConv( QString str, int zeros ) +{ +int point=str.find(".",0); +QString dec= QString("%1").arg(str.mid(point+1,1)); +str = str.mid(0,point); +str = QString("%1%2").arg(str).arg(dec); +return convZeros (str.toInt(), zeros); +} + +int rotation (int valor){ +if (valor==90) return 1; +else if (valor==180) return 2; +else if (valor==270) return 3; +else return 0; +} + + +QString code39 (const QDomElement &e, int countBar) { + +QString result; + result += QString("{XB%1;").arg( convZeros(countBar, 2) ); // count + result += QString("%1").arg( posConv(e.attribute( "x_mm"), 4 ) ); // X position + result += QString(",%1").arg( posConv(e.attribute( "y_mm"), 4 ) ); // Y position + result += QString(",%1").arg( barcodeType( e.attribute( "type") ) ); // Type of bar code + result += QString(",%1").arg( withChecksum(e) ); // Type of check digit + result += QString(",%1").arg( "03" ); // Narrow bar width + result += QString(",%1").arg( "03" ); // Narrow space width + result += QString(",%1").arg( "06" ); // Wide bar width + result += QString(",%1").arg( "06" ); // Wide space width + result += QString(",%1").arg( "03" ); // Character to Character space width + result += QString(",%1").arg( rotation(e.attribute( "rotation", "0" ).toInt())); // Rotation angel of barcode + result += QString(",%1").arg( "0063" ); // height of barcode + result += QString(",+%1").arg( sequence(e) ); // Increment / Decrement + result += QString(",%1").arg( e.attribute( "text", "1" ).toInt() ); // Selection of print or non print of numerals under bars + result += QString(",00"); //Number of Zeros to be suppressed + result += QString("|}\n"); // FIN + +return result; +} + +QString barcodeType(const QString &type){ +if (type == "i25") return "2"; +if (type == "i25 -c") return "2"; +if (type == "msi") return "1"; +if (type == "code39") return "3"; +if (type == "code39 -c") return "3"; +if (type == "b8") return "3"; +if (type == "ean") return "0"; +if (type == "upc") return "K"; +if (type == "code128") return "9"; +if (type == "code93") return "C"; +if (type == "pls") return "1"; +if (type == "b7") return "O"; +if (type == "b9") return "B"; +if (type == "b10") return "0"; +if (type == "b11") return "I"; +if (type == "b12") return "J"; +if (type == "b13") return "5"; +if (type == "b14") return "7"; +if (type == "b15") return "8"; +if (type == "b34") return "K"; +if (type == "b35") return "L"; +if (type == "b36") return "M"; +if (type == "b37") return "6"; +if (type == "b38") return "G"; +if (type == "b39") return "H"; +if (type == "b20") return "9"; +if (type == "b25") return "C"; +if (type == "b47") return "1"; +//never +return "0"; +} + + +QString withChecksum( const QDomElement &e) { +if (e.attribute("type")=="code39 -c") return "1"; +if (e.attribute("type")=="code39") return "3"; +if (e.attribute("type")=="ean") return "3"; +if (e.attribute("type")=="upc") return "3"; +if (e.attribute("type")=="code128") return "2"; +if (e.attribute("type")=="code93") return "2"; +if (e.attribute("type")=="i25 -c") return "1"; +if (e.attribute("type")=="i25") return "3"; +if (e.attribute("type")=="msi") return "1"; +if (e.attribute("type")=="pls") return "3"; +if (e.attribute("type")=="b7" ) + {if (e.attribute("tbarcode.checksum")=="0") return "1"; + else return "3"; + } +if (e.attribute("type")=="b8" ) + {if (e.attribute("tbarcode.checksum")=="0") return "1"; + else return "3"; + } +if (e.attribute("type")=="b9" ) + {if (e.attribute("tbarcode.checksum")=="0") return "1"; + else return "3"; + } + +if (e.attribute("type")=="b10" ) return "3"; +if (e.attribute("type")=="b11" ) return "3"; +if (e.attribute("type")=="b12" ) return "3"; +if (e.attribute("type")=="b13" ) return "3"; +if (e.attribute("type")=="b14" ) return "3"; +if (e.attribute("type")=="b15" ) return "3"; +if (e.attribute("type")=="b34" ) + {if (e.attribute("tbarcode.checksum")=="0") return "1"; + else return "3"; + } +if (e.attribute("type")=="b35" ) + {if (e.attribute("tbarcode.checksum")=="0") return "1"; + else return "3"; + } +if (e.attribute("type")=="b36" ) + {if (e.attribute("tbarcode.checksum")=="0") return "1"; + else return "3"; + } +if (e.attribute("type")=="b37" ) return "3"; +if (e.attribute("type")=="b38" ) return "3"; +if (e.attribute("type")=="b39" ) return "3"; +if (e.attribute("type")=="b20" ) return "1"; +if (e.attribute("type")=="b25" ) return "1"; +if (e.attribute("type")=="b47" ) + {if (e.attribute("tbarcode.checksum")=="10") return "3"; + else if (e.attribute("tbarcode.checksum")=="11") return "4"; + else if (e.attribute("tbarcode.checksum")=="2") return "5"; + else if (e.attribute("tbarcode.checksum")=="1") return "3"; + return "1"; + } +if (e.attribute("type")=="b55" ) + {if (e.attribute("pdf417.err")=="0") return "00"; + else if (e.attribute("pdf417.err")=="1") return "01"; + else if (e.attribute("pdf417.err")=="2") return "02"; + else if (e.attribute("pdf417.err")=="3") return "03"; + else if (e.attribute("pdf417.err")=="4") return "04"; + else if (e.attribute("pdf417.err")=="5") return "05"; + else if (e.attribute("pdf417.err")=="6") return "06"; + else if (e.attribute("pdf417.err")=="7") return "07"; + else if (e.attribute("pdf417.err")=="8") return "08"; + } +//never +return "0"; +} + + +QString sequence(const QDomElement &e){ +return convZeros(e.attribute("sequencestep" ,"0").toInt() ,10); +} + +QString code128 (const QDomElement &e, int countBar) { + +QString result; + result += QString("{XB%1;").arg( convZeros(countBar, 2) ); // count + result += QString("%1").arg( posConv(e.attribute( "x_mm"), 4 ) ); // X position + result += QString(",%1").arg( posConv(e.attribute( "y_mm"), 4 ) ); // Y position + result += QString(",%1").arg( barcodeType( e.attribute( "type") ) ); // Type of bar code + result += QString(",%1").arg( withChecksum(e) ); // Type of check digit + result += QString(",%1").arg( "03" ); // 1 module width + result += QString(",%1").arg( rotation(e.attribute( "rotation", "0" ).toInt())); // Rotation angel of barcode + result += QString(",%1").arg( "0063" ); // height of barcode + result += QString(",+%1").arg( sequence(e) ); // Increment / Decrement + result += QString(",000"); // Length of th WPC guard bar + result += QString(",%1").arg( e.attribute( "text", "1" ).toInt() ); // Selection of print or non print of numerals under bars + result += QString(",00"); //Number of Zeros to be suppressed + result += QString("|}\n"); // FIN + +return result; +} + +#if 0 +QString serialWatch(){ + +int fd, res, exit=1; +struct termios oldtio,newtio; +char buf[MAXDATASIZE]; +QString result,temp; + + +//fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY ); +fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY ); +if (fd <0) return "Port Error."; +tcgetattr(fd,&oldtio); /* save current serial port settings */ +bzero(&newtio, sizeof(newtio)); /* clear struct for new port settings */ +newtio.c_cflag = B9600 | CRTSCTS | CS8 | CLOCAL | CREAD; +newtio.c_iflag = IGNPAR; // | ICRNL; +newtio.c_oflag = 0; +newtio.c_lflag =0;// ICANON; +newtio.c_cc[VINTR] = 0; /* Ctrl-c */ +newtio.c_cc[VQUIT] = 0; /* Ctrl-\ */ +newtio.c_cc[VERASE] = 0; /* del */ +newtio.c_cc[VKILL] = 0; /* @ */ +newtio.c_cc[VEOF] = 4; /* Ctrl-d */ +newtio.c_cc[VTIME] = 0; /* inter-character timer unused */ +newtio.c_cc[VMIN] = 1; /* blocking read until 1 character arrives */ +newtio.c_cc[VSWTC] = 0; /* '\0' */ +newtio.c_cc[VSTART] = 0; /* Ctrl-q */ +newtio.c_cc[VSTOP] = 0; /* Ctrl-s */ +newtio.c_cc[VSUSP] = 0; /* Ctrl-z */ +newtio.c_cc[VEOL] = 0; /* '\0' */ +newtio.c_cc[VREPRINT] = 0; /* Ctrl-r */ +newtio.c_cc[VDISCARD] = 0; /* Ctrl-u */ +newtio.c_cc[VWERASE] = 0; /* Ctrl-w */ +newtio.c_cc[VLNEXT] = 0; /* Ctrl-v */ +newtio.c_cc[VEOL2] = 0; /* '\0' */ + +fcntl(fd, F_SETFL, FNDELAY); +tcflush(fd, TCIFLUSH); +tcsetattr(fd,TCSADRAIN,&newtio); + +while (exit){ +res=read(fd,buf,MAXDATASIZE); +while (res ==-1 ){ + //sleep(10); + res=read(fd,buf,MAXDATASIZE); + } +temp = QString(buf); +//qDebug ("serial: "+temp+"\n"); +// LF = = 10 +// CR = \r = 13 + +if (temp.find(QString("\r"),0,1)==-1) result+= temp; +else { + result+= temp; + exit=0; + } +} +::close(fd); +return result; +} +#endif // 0 + + + + + +QString pdf417 (const QDomElement &e, int countBar) { + +QString result; + result += QString("{XB%1;").arg( convZeros(countBar, 2) ); // count + result += QString("%1").arg( posConv(e.attribute( "x_mm"), 4 ) ); // X position + result += QString(",%1").arg( posConv(e.attribute( "y_mm"), 4 ) ); // Y position + result += QString(",P"); // Type of bar code ALWAYS PDF417 + result += QString(",%1").arg( withChecksum(e) ); // Type of check digit + result += QString(",%1").arg( "03" ); // Module Width + result += QString(",%1").arg( convZeros(e.attribute("pdf417.col").toInt(),2 )); // Number of columns + result += QString(",%1").arg( rotation(e.attribute( "rotation", "0" ).toInt())); // Rotation angel of barcode + result += QString(",%1").arg( "0063" ); // height of barcode + result += QString("|}\n"); // FIN + +return result; +} + +QString getData(const QString &etext, const QString &art, const QString &group, const QString &id){ + TokenProvider token( NULL ); + token.setArticleNo( art ); + token.setGroup( group ); + token.setCustomerNo( id ); + token.setGroup( group ); + // TODO: + // commented out, because the code is not so clean and only + // used for TEC, maybe we can make this generic for all components of KBarcode +// token.setSerialWatch( serialWatch() ); + token.setIndex( 0 ); // should be increased for every label + + return token.parse( etext ); +/* + +QString temp; + + +if (etext.contains("[serial_watch]") ) etext.replace( "[serial_watch]" , serialWatch() ); +if (etext.contains("[customer_no]") ) etext.replace( "[customer_no]" , id ); +if (etext.contains("[customer_name]") ) etext.replace( "[customer_name]" , name ); +if (etext.contains("[group]") ) etext.replace( "[group]" , group ); +if (etext.contains("[article_no]") ) etext.replace( "[article_no]" , art ); +if (etext.contains("[line1]") ) { + QSqlQuery query("SELECT line1 FROM customer_text where customer_no='" + id + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[line1]" , temp ); + } +if (etext.contains("[line0]") ) { + QSqlQuery query("SELECT line0 FROM customer_text where customer_no='" + id + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[line0]" , temp ); + } +if (etext.contains("[line2]") ) { + QSqlQuery query("SELECT line2 FROM customer_text where customer_no='" + id + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[line2]" , temp ); + } +if (etext.contains("[line3]") ) { + QSqlQuery query("SELECT line3 FROM customer_text where customer_no='" + id + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[line3]" , temp ); + } +if (etext.contains("[line4]") ) { + QSqlQuery query("SELECT line4 FROM customer_text where customer_no='" + id + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[line4]" , temp ); + } +if (etext.contains("[line5]") ) { + QSqlQuery query("SELECT line5 FROM customer_text where customer_no='" + id + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[line5]" , temp ); + } +if (etext.contains("[line6]") ) { + QSqlQuery query("SELECT line6 FROM customer_text where customer_no='" + id + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[line6]" , temp ); + } +if (etext.contains("[line7]") ) { + QSqlQuery query("SELECT line7 FROM customer_text where customer_no='" + id + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[line7]" , temp ); + } +if (etext.contains("[line8]") ) { + QSqlQuery query("SELECT line8 FROM customer_text where customer_no='" + id + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[line8]" , temp ); + } +if (etext.contains("[line9]") ) { + QSqlQuery query("SELECT line9 FROM customer_text where customer_no='" + id + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[line9]" , temp ); + } +if (etext.contains("[field0]") ) { + QSqlQuery query("SELECT field0 FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[field0]" , temp ); + } +if (etext.contains("[field1]") ) { + QSqlQuery query("SELECT field1 FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[field1]" , temp ); + } +if (etext.contains("[field2]") ) { + QSqlQuery query("SELECT field2 FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[field2]" , temp ); + } +if (etext.contains("[field3]") ) { + QSqlQuery query("SELECT field3 FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[field3]" , temp ); + } +if (etext.contains("[field4]") ) { + QSqlQuery query("SELECT field4 FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[field4]" , temp ); + } +if (etext.contains("[field5]") ) { + QSqlQuery query("SELECT field5 FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[field5]" , temp ); + } +if (etext.contains("[field6]") ) { + QSqlQuery query("SELECT field6 FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[field6]" , temp ); + } +if (etext.contains("[field7]") ) { + QSqlQuery query("SELECT field7 FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[field7]" , temp ); + } +if (etext.contains("[field8]") ) { + QSqlQuery query("SELECT field8 FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[field8]" , temp ); + } +if (etext.contains("[field9]") ) { + QSqlQuery query("SELECT field9 FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[field9]" , temp ); + } +if (etext.contains("[article_desc]") ) { + QSqlQuery query("SELECT article_desc FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[article_desc]" , temp ); + } +if (etext.contains("[barcode_no]") ) { + QSqlQuery query("SELECT barcode_no FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[barcode_no]" , temp ); + } +if (etext.contains("[field9]") ) { + QSqlQuery query("SELECT field9 FROM barcode_basic where article_no='" + art + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[field9]" , temp ); + } +if (etext.contains("[article_no_customer]") ) { + QSqlQuery query("SELECT article_no_customer FROM customer_text where customer_no='" + id + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace( "[article_no_customer]" , temp ); + } +if (etext.contains("[barcode_no_customer]") ){ + QSqlQuery query("SELECT barcode_no FROM customer_text where customer_no='" + id + "'" ); + while( query.next() ) temp = QString (query.value( 0 ).toString()); + etext.replace("[barcode_no_customer]" , temp ); + } +if (etext.contains("[date]") ) etext.replace( "[date]" ,QDateTime::currentDateTime().toString( KBarcodeSettings::getDateFormat() )); +if (etext.contains("[time]") ) etext.replace( "[time]" ,QTime::currentTime().toString()); + +return etext;*/ +} + + + + +QString lineWidth(const QDomElement &e){ +QString result; +int width = e.attribute("line-width").toInt(); +if (width > 0 and width < 10) return result.setNum(width); +else return "9"; //Max width supported +} + +QString image (const QString &file){ +int fd, res; +char buf[1]; +QString result; + +fd = open(file, O_RDONLY); +if (fd <0) return "Port Error."; +res=read(fd,buf,1); +while (res == 1){ +result += QString(buf); +res=read(fd,buf,1); +} +return result; +} + +QString getImage( const QString &id){ +QString file; +QSqlQuery query("SELECT line9 FROM customer_text where customer_no='" + id + "'" ); +while( query.next() ) file = QString (query.value( 0 ).toString()); +return image(file); +} diff --git a/kbarcode/tec.h b/kbarcode/tec.h new file mode 100644 index 0000000..46dc15a --- /dev/null +++ b/kbarcode/tec.h @@ -0,0 +1,69 @@ +// +// C++ Interface: tec +// +// Description: +// +// +// Author: Dominik Seichter <domseichter@web.de>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef TEC_H +#define TEC_H +#include "dsmainwindow.h" +#include "labelutils.h" +#include "xmlutils.h" +#include "definition.h" +#include "batchiface.h" + +// Other includes +#include <stdlib.h> +#include <stdio.h> + +// QT includes +#include <qclipboard.h> +#include <qcursor.h> +#include <qgroupbox.h> +#include <qhbox.h> +#include <qlayout.h> +#include <qpainter.h> +#include <qpaintdevicemetrics.h> +#include <qprogressdialog.h> +#include <qsqlcursor.h> +#include <qvalidator.h> + +// KDE includes +#include <kapplication.h> +#include <kcombobox.h> +#include <kfiledialog.h> +#include <kiconloader.h> +#include <klistview.h> +#include <klineedit.h> +#include <klineeditdlg.h> +#include <klocale.h> +#include <kmenubar.h> +#include <kmessagebox.h> +#include <kpopupmenu.h> +#include <knuminput.h> +#include <kprinter.h> +#include <kurlrequester.h> + +QString tec452(const QString &file, int count, const QString &art, const QString &group, const QString &id); +QString convZeros( int count, int zeros ); +QString posConv( QString str, int zeros ); +int rotation (int valor); +QString code39 (const QDomElement &e, int countBar); +QString code128 (const QDomElement &e, int countBar); +QString barcodeType(const QString &type); +QString withChecksum(const QDomElement &e); +QString sequence(const QDomElement &e); +QString serialWatch(); +QString pdf417 (const QDomElement &e, int countBar); +QString getData(const QString &etext, const QString &art, const QString &group, const QString &id); +QString lineWidth(const QDomElement &e); +QString image (const QString &file); +QString getImage(const QString &id); + + +#endif diff --git a/kbarcode/textitem.cpp b/kbarcode/textitem.cpp new file mode 100644 index 0000000..ab1e4cc --- /dev/null +++ b/kbarcode/textitem.cpp @@ -0,0 +1,252 @@ +/*************************************************************************** + textitem.cpp - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#include "textitem.h" +#include "labelutils.h" +#include "labeleditor.h" +#include "tokenprovider.h" + +// we need sin and cos +#include <math.h> + +#include <qapplication.h> +#include <qdom.h> +#include <qpaintdevicemetrics.h> +#include <qpainter.h> +#include <qpicture.h> +#include <qsimplerichtext.h> + +#include <kapplication.h> +#include <qwmatrix.h> + +TextItem::TextItem() + : DocumentItem() +{ + init(); +} + +void TextItem::init() +{ + m_text = QString::null; + m_rotation = 0.0; + + setBorder( false ); + setRect( QRect( 0, 0, 100, 100 ) ); +} + +void TextItem::draw(QPainter* painter) +{ + bool autosize = false; + const QString t = tokenProvider() ? tokenProvider()->parse( m_text ) : m_text; + + if( t != m_text ) + autosize = true; + + QPaintDeviceMetrics metrics( DocumentItem::paintDevice() ); + + double scalex = (double)metrics.logicalDpiX() / (double)QPaintDevice::x11AppDpiX(); + double scaley = (double)metrics.logicalDpiY() / (double)QPaintDevice::x11AppDpiY(); + + QColorGroup cg; + QSimpleRichText srt( t, painter->font() ); + + /* + int width = (rect().width() < (int)((double)srt.widthUsed()*scalex) && autosize) ? srt.widthUsed() : rect().width(); + int height = (rect().height() < (int)((double)srt.height()*scaley) && autosize) ? srt.height() : rect().height(); + */ + + int width = (int)((double)rect().width() / scalex); + int height = (int)((double)rect().height() / scaley); + + painter->save(); + + int w = rect().width(); + int h = rect().height(); + + switch( (int)m_rotation ) + { + default: + case 0: + painter->translate( rect().x(), rect().y() ); + break; + case 90: + painter->translate( rect().x() + w, rect().y() ); + qSwap( w, h ); + break; + case 180: + painter->translate( rect().x() + w, rect().y() + h ); + break; + case 270: + painter->translate( rect().x(), rect().y() + h ); + qSwap( w, h ); + break; + }; + + painter->rotate( m_rotation ); + + if( !TextItem::IsQtTextRenderingBroken() ) + { + painter->setPen( Qt::black ); + srt.setWidth( painter, w ); + srt.draw( painter, 0, 0, QRect( 0, 0, w, h ), cg ); + } + else + { + QRect r( 0, 0, width, height ); + QPicture picture; + QPainter p( &picture ); + LabelUtils::renderString( &p, t, r, scalex, scaley ); + p.end(); + painter->drawPicture( 0, 0, picture ); + } + + painter->restore(); + + DocumentItem::drawBorder( painter ); +} + +void TextItem::drawZpl( QTextStream* stream ) +{ + // simply remove all html tags.... + QString data = m_text.replace( QRegExp("<[^>]*>"), "" ); + *stream << ZPLUtils::fieldOrigin( rect().x(), rect().y() ); + *stream << ZPLUtils::font( QFont() ); // todo: select a valid font +} + +void TextItem::drawIpl( QTextStream* stream, IPLUtils* utils ) +{ + int counter = utils->counter(); + + // simply remove all html tags.... + QString data = m_text.replace( QRegExp("<[^>]*>"), "" ); + + QString s = QString("H%1;").arg( counter ); // field number + + s += utils->fieldOrigin( rect().x(), rect().y() ); + + s += QString("c%1;").arg( 2 ); // font + s += QString("h%1;").arg( 2 ); // vertical magnification ("height") + s += QString("w%1;").arg( 2 ); // horicontyl magnification ("width") + s += QString("d0,%1;").arg( data.length() ); // max length of data ! + + *stream << utils->field( s ); + utils->addValue( data ); +} + +void TextItem::drawEPcl( QTextStream* stream ) +{ + // TODO: parse text field HTML + + // Need to wrap string if too long... + // + + // break string into lines + QString t = m_text.replace( QRegExp("<[^>]*>"), "" ); + // @DOM: + // TODO: + // provide an API which simplifies wordwrapping for + // barcode printers + + QStringList lines = QStringList::split( "\n", t ); + + QStringList::Iterator line = lines.begin(); + for( int i=0; line != lines.end(); ++line, ++i ){ + QString s = QString("T %1").arg( rect().x() + 1 ); + s += QString(" %1 0 0 0 50 1").arg( rect().y()+50+1 + i*52 ); + s += QString(" %1").arg( *line ); + *stream << EPCLUtils::field( s ); + } +} + +void TextItem::loadXML (QDomElement* element) +{ + QDomNode n = element->firstChild(); + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + if( e.tagName() == "text" ) + { + setText( e.text() ); + break; + } + n = n.nextSibling(); + } + + m_rotation = element->attribute("rotation", "0.0").toDouble(); + DocumentItem::loadXML( element ); +} + +void TextItem::saveXML (QDomElement* element) +{ + QDomElement texttag = element->ownerDocument().createElement( "text" ); + texttag.appendChild( element->ownerDocument().createTextNode( text() ) ); + element->appendChild( texttag ); + element->setAttribute( "rotation", m_rotation ); + + DocumentItem::saveXML( element ); +} + +QString TextItem::text () const +{ + return m_text; +} + +void TextItem::setText (const QString & text) +{ + m_text = text; +} + +bool TextItem::s_qt_broken_init = false; +bool TextItem::s_qt_broken = false; + +bool TextItem::IsQtTextRenderingBroken() +{ + if( !s_qt_broken_init ) + { + QString version( qVersion() ); +// qDebug( "Detected Qt Version: %s", version.latin1() ); + int major = version.section( ".", 0, 0 ).toInt(); + int minor = version.section( ".", 1, 1 ).toInt(); + int bugfix = version.section( ".", 2, 2 ).toInt(); + + if( major >= 3 ) + { + if( major == 3 && minor < 3 ) + s_qt_broken = true; + else if( major == 3 && minor == 3 ) + { + if( bugfix < 2 ) + s_qt_broken = true; + else + s_qt_broken = false; + } + else + s_qt_broken = false; + } + else + s_qt_broken = true; + + if( s_qt_broken ) + qDebug("Qt's text redering is broken - using KBarcode fix."); + + s_qt_broken_init = true; + return s_qt_broken; + } + else + return s_qt_broken; +} + diff --git a/kbarcode/textitem.h b/kbarcode/textitem.h new file mode 100644 index 0000000..cec5d46 --- /dev/null +++ b/kbarcode/textitem.h @@ -0,0 +1,61 @@ +/*************************************************************************** + textitem.h - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#ifndef TEXTITEM_H +#define TEXTITEM_H +#include <qstring.h> +#include "documentitem.h" + +class LabelEditor; + +/** + * Class TextItem + * Formated rich text (drawn using either DSRichText or QSimpleRichText - once it is bug free) on screen or printer. + */ +class TextItem : public DocumentItem { +public: + TextItem (); + + void draw (QPainter* painter); + void drawZpl( QTextStream* stream ); + void drawIpl( QTextStream* stream, IPLUtils* utils ); + void drawEPcl( QTextStream* stream ); + + int rtti () const { return eRtti_Text; } + + void loadXML (QDomElement* element); + void saveXML (QDomElement* element); + + void setText (const QString & text); + QString text () const; + + inline void setRotation( double rot ) { m_rotation = rot; } + inline double rotation() const { return m_rotation; } + + static bool IsQtTextRenderingBroken(); +private: + void init(); + +private: + static bool s_qt_broken; + static bool s_qt_broken_init; + + double m_rotation; + QString m_text; +}; +#endif //TEXTITEM_H + diff --git a/kbarcode/textlineedit.cpp b/kbarcode/textlineedit.cpp new file mode 100644 index 0000000..9a6965b --- /dev/null +++ b/kbarcode/textlineedit.cpp @@ -0,0 +1,210 @@ +// +// C++ Implementation: textlineedit +// +// Description: +// +// +// Author: Dominik Seichter <domseichter@web.de>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "textlineedit.h" +#include "tokendialog.h" + +// KDE includes +#include <knuminput.h> +#include <kaction.h> +#include <kdeversion.h> +#include <kcolordialog.h> +#include <kfiledialog.h> +#include <klocale.h> +#include <kspell.h> +#if QT_VERSION >= 0x030100 + #include <klineedit.h> +#else + #include <qlineedit.h> +#endif +#include <ktoolbar.h> +#include <kcombobox.h> + +// Qt includes +#include <qdockarea.h> +#include <qregexp.h> +#include <qlabel.h> +#include <qlayout.h> + +TextLineEditor::TextLineEditor( TokenProvider* token, QWidget *parent, const char *name ) + : QWidget( parent, name ), m_token( token ) +{ + QVBoxLayout* layout = new QVBoxLayout( this, 6, 6 ); + + + +#if QT_VERSION >= 0x030100 + editor = new KLineEdit( this ); +#else + editor = new QLineEdit( this ); +#endif + + editor->setFocus(); + + QDockArea* area = new QDockArea( Qt::Horizontal, QDockArea::Normal, this ); + toolBar = new KToolBar( area ); + tool2Bar = new KToolBar( area ); + tool3Bar = new KToolBar( area ); + + setupActions(); + + layout->addWidget( area ); + layout->addWidget( editor ); + + + + + + +} + +TextLineEditor::~TextLineEditor() +{ +} + + +void TextLineEditor::setupActions() +{ + ac = new KActionCollection( this ); + + + KAction *action_undo = KStdAction::undo( editor, SLOT( undo() ), ac ); + action_undo->setEnabled( false ); + connect( editor, SIGNAL( undoAvailable(bool) ), action_undo, SLOT( setEnabled(bool) ) ); + + + KAction *action_redo = KStdAction::redo( editor, SLOT( redo() ), ac ); + action_redo->setEnabled( false ); + connect( editor, SIGNAL( redoAvailable(bool) ), action_redo, SLOT( setEnabled(bool) ) ); + + KAction *action_cut = KStdAction::cut( editor, SLOT( cut() ), ac ); + action_cut->setEnabled( false ); + connect( editor, SIGNAL( copyAvailable(bool) ), action_cut, SLOT( setEnabled(bool) ) ); + + KAction *action_copy = KStdAction::copy( editor, SLOT( copy() ), ac ); + action_copy->setEnabled( false ); + connect( editor, SIGNAL( copyAvailable(bool) ), action_copy, SLOT( setEnabled(bool) ) ); + + KAction* action_paste = KStdAction::paste( editor, SLOT( paste() ), ac ); + + KAction* textDataAct = new KAction( i18n("Insert &Data Field"), "contents", 0, this, SLOT( insertNewField() ), ac, "text_data_act"); + + action_undo->plug( toolBar ); + action_redo->plug( toolBar ); + toolBar->insertSeparator(); + action_cut->plug( toolBar ); + action_copy->plug( toolBar ); + action_paste->plug( toolBar ); + + + QStringList fuentes; + fuentes += "Tiems Roman (Medium) 8 point"; + fuentes += "Tiems Roman (Medium) 10 point"; + fuentes += "Tiems Roman (Bold) 10 point"; + fuentes += "Tiems Roman (Bold) 12 point"; + fuentes += "Tiems Roman (Bold) 14 point"; + fuentes += "Tiems Roman (Italic) 12 point"; + fuentes += "Helvetica (Medium) 6 point"; + fuentes += "Helvetica (Medium) 10 point"; + fuentes += "Helvetica (Medium) 12 point"; + fuentes += "Helvetica (Bold) 12 point"; + fuentes += "Helvetica (Bold) 14 point"; + fuentes += "Helvetica (Italic) 12 point"; + fuentes += "Presentation (Bold) 18 point"; + fuentes += "Letter Gothic (Medium) 9.5 point"; + fuentes += "Prestige Elite (Medium) 7 point"; + fuentes += "Prestige Elite (Bold) 10 point"; + fuentes += "Courier (Medium) 10 point"; + fuentes += "Courier (Bold) 12 point"; + fuentes += "OCR-A 12 point"; + fuentes += "OCR-B 12 point"; + + textDataAct->plug( tool2Bar ); + + action_font_type = new KComboBox(tool2Bar,"font_type") ; + connect( action_font_type, SIGNAL( activated(int) ), this, SLOT( setFontType(int) ) ); + action_font_type->insertStringList(fuentes) ; + + + + QLabel* labelv = new QLabel( i18n("&Mag. Vert.:"), tool3Bar ); + mag_vert = new KIntNumInput( tool3Bar,"magvert" ); + QLabel* labelh = new QLabel( i18n("&Mag. Hor.:"), tool3Bar ); + mag_hor = new KIntNumInput( tool3Bar,"maghor" ); + connect( mag_vert, SIGNAL( activated(int) ), this, SLOT( setVerMag(int) ) ); + connect( mag_hor, SIGNAL( activated(int) ), this, SLOT( setHorMag(int) ) ); + mag_vert->setRange( 1, 9, 1, false ); + mag_hor->setRange( 1, 9, 1, false ); + + + labelv->setBuddy( mag_vert ); + labelh->setBuddy( mag_hor ); + + + + updateActions(); + + +} + +QString TextLineEditor::text() +{ + return editor->text(); +} + +void TextLineEditor::setText( const QString & t ) +{ + editor->setText( t ); +} + + +void TextLineEditor::updateActions() +{ + +} + + +void TextLineEditor::insertNewField() +{ + TokenDialog dlg( m_token, this, "dlg" ); + if( dlg.exec() == QDialog::Accepted ) + editor->insert( dlg.token() ) ; +} + +void TextLineEditor::setFontType( int index ) +{ + action_font_type->setCurrentItem(index); +} + +int TextLineEditor::getFontType() +{ + return action_font_type->currentItem(); +} +void TextLineEditor::setVertMag( int index ) +{ + mag_vert->setValue(index); +} + +int TextLineEditor::getVertMag() +{ + return mag_vert->value(); +} + +void TextLineEditor::setHorMag( int index ) +{ + mag_hor->setValue(index); +} + +int TextLineEditor::getHorMag() +{ + return mag_hor->value(); +} +#include "textlineedit.moc" diff --git a/kbarcode/textlineedit.h b/kbarcode/textlineedit.h new file mode 100644 index 0000000..80b0eee --- /dev/null +++ b/kbarcode/textlineedit.h @@ -0,0 +1,78 @@ +// +// C++ Interface: textlineedit +// +// Description: +// +// +// Author: Dominik Seichter <domseichter@web.de>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef TECLINEEDITDLG_H +#define TECLINEEDITDLG_H + +#include <qwidget.h> +#include <knuminput.h> + +class KActionCollection; +class KToggleAction; +class KFontAction; +class KFontSizeAction; +class KToolBar; +class KSpell; +class KSpellConfig; +class KComboBox; +class TokenProvider; + +#if QT_VERSION >= 0x030100 + class KLineEdit; +#else + class QLineEdit; +#endif + +class TextLineEditor : public QWidget { + Q_OBJECT + public: + TextLineEditor( TokenProvider* token, QWidget *parent=0, const char *name=0); + ~TextLineEditor(); + QString text(); + KIntNumInput* mag_vert; + KIntNumInput* mag_hor; + + void setText( const QString & t ); + void setFontType(int index); + int getFontType(); + int getHorMag(); + void setHorMag( int index ); + int getVertMag(); + void setVertMag( int index ); + private slots: + void setupActions(); + void updateActions(); + + void insertNewField(); + + + protected: + TokenProvider* m_token; + +#if QT_VERSION >= 0x030100 + KLineEdit* editor; +#else + QLineEdit* editor; +#endif + + KActionCollection* ac; + + KComboBox *action_font_type ; + KToolBar* toolBar; + KToolBar* tool2Bar; + KToolBar* tool3Bar; + + + +}; + +#endif diff --git a/kbarcode/textlineitem.cpp b/kbarcode/textlineitem.cpp new file mode 100644 index 0000000..2dbfef9 --- /dev/null +++ b/kbarcode/textlineitem.cpp @@ -0,0 +1,246 @@ +/*************************************************************************** + textlineitem.cpp - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#include "textlineitem.h" +#include "labelutils.h" +#include "tokenprovider.h" + +#include <qapplication.h> +#include <qdom.h> +#include <qpaintdevicemetrics.h> +#include <qpainter.h> +#include <qsimplerichtext.h> + +#include <kapplication.h> + +TextLineItem::TextLineItem () + : DocumentItem() +{ + init(); +} + +void TextLineItem::init() +{ + m_text = QString::null; + m_font = 0; + m_rotate = 0; + m_mag_vert = 1; + m_mag_hor = 1; + + + setBorder( false ); + setRect( QRect( 0, 0, 100, 20 ) ); +} + +/** + * + * @param painter + */ +void TextLineItem::draw(QPainter* painter) +{ + QString text = tokenProvider() ? tokenProvider()->parse( m_text ) : m_text; + QColorGroup cg; + QSimpleRichText srt( text, painter->font() ); + QPaintDeviceMetrics metrics( DocumentItem::paintDevice() ); + + double scalex = (double)metrics.logicalDpiX() / (double)QPaintDevice::x11AppDpiX(); + double scaley = (double)metrics.logicalDpiY() / (double)QPaintDevice::x11AppDpiY(); + int width = (rect().width() > 0) ? (int)((double)rect().width() / scalex) : srt.widthUsed(); + int height = (rect().height() > 0) ? (int)((double)rect().height() / scaley): srt.height(); + + QRect r( (int)((double)rect().x() / scalex ), (int)((double)rect().y() / scaley), width, height ); + + srt.setWidth( painter, width ); + + painter->save(); + + if( !TextLineItem::IsQtTextRenderingBroken() ) + { + painter->scale( scalex, scaley ); + painter->setPen( Qt::black ); + srt.draw( painter, (int)((double)rect().x() / scalex ), (int)((double)rect().y() / scaley), r, cg ); + } + else + { + LabelUtils::renderString( painter, text, r, scalex, scaley ); + } + + painter->restore(); + + DocumentItem::drawBorder( painter ); +} + +void TextLineItem::drawZpl( QTextStream* stream ) +{ + // simply remove all html tags.... + QString data = m_text.replace( QRegExp("<[^>]*>"), "" ); + *stream << ZPLUtils::fieldOrigin( rect().x(), rect().y() ); + *stream << ZPLUtils::font( QFont() ); // todo: select a valid font +} + +void TextLineItem::drawIpl( QTextStream* stream, IPLUtils* utils ) +{ + int counter = utils->counter(); + + // simply remove all html tags.... + QString data = m_text.replace( QRegExp("<[^>]*>"), "" ); + + QString s = QString("H%1;").arg( counter ); // field number + + s += utils->fieldOrigin( rect().x(), rect().y() ); + + s += QString("c%1;").arg( 2 ); // font + s += QString("h%1;").arg( 2 ); // vertical magnification ("height") + s += QString("w%1;").arg( 2 ); // horicontyl magnification ("width") + s += QString("d0,%1;").arg( data.length() ); // max length of data ! + + *stream << utils->field( s ); + utils->addValue( data ); +} + +void TextLineItem::drawEPcl( QTextStream* stream ) +{ + // TODO: parse text field HTML + + // Need to wrap string if too long... + // + + // break string into lines + QString t = m_text.replace( QRegExp("<[^>]*>"), "" ); + // @DOM: + // TODO: + // provide an API which simplifies wordwrapping for + // barcode printers + QStringList lines = QStringList::split( "\n", t ); + + QStringList::Iterator line = lines.begin(); + for( int i=0; line != lines.end(); ++line, ++i ){ + QString s = QString("T %1").arg( rect().x() + 1 ); + s += QString(" %1 0 0 0 50 1").arg( rect().y()+50+1 + i*52 ); + s += QString(" %1").arg( *line ); + *stream << EPCLUtils::field( s ); + } +} + +void TextLineItem::loadXML (QDomElement* element) +{ + QDomNode n = element->firstChild(); + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + if( e.tagName() == "text" ) + { + setFont(e.attribute( "font", "0").toInt() ); + setMagVert(e.attribute( "vert_mag", "1").toInt() ); + setMagHor(e.attribute( "hor_mag", "1").toInt() ); + setText( e.text() ); + break; + } + n = n.nextSibling(); + } + + DocumentItem::loadXML( element); +} + +void TextLineItem::saveXML (QDomElement* element) +{ + + QDomElement texttag = element->ownerDocument().createElement( "text" ); + texttag.appendChild( element->ownerDocument().createTextNode( text() ) ); + element->appendChild( texttag ); + element->setAttribute( "font", m_font ); + element->setAttribute( "hor_mag", m_mag_hor ); + element->setAttribute( "vert_mag", m_mag_vert ); + DocumentItem::saveXML( element); +} + +QString TextLineItem::text () const +{ + return m_text; +} + +void TextLineItem::setText (const QString & text) +{ + m_text = text; +} + +void TextLineItem::setFont (int count) +{ + m_font = count; +} + +int TextLineItem::getFont () const +{ + return m_font; +} + +void TextLineItem::setMagVert (int count) +{ + m_mag_vert = count; +} + +int TextLineItem::getMagVert () const +{ + return m_mag_vert; +} + +void TextLineItem::setMagHor (int count) +{ + m_mag_hor = count; +} + +int TextLineItem::getMagHor () const +{ + return m_mag_hor; +} + +bool TextLineItem::s_qt_broken_init = false; +bool TextLineItem::s_qt_broken = false; + +bool TextLineItem::IsQtTextRenderingBroken() +{ + if( !s_qt_broken_init ) + { + QString version( qVersion() ); + int major = version.section( ".", 0, 0 ).toInt(); + int minor = version.section( ".", 1, 1 ).toInt(); + int bugfix = version.section( ".", 2, 2 ).toInt(); + + if( major >= 3 ) + { + if( major == 3 && minor < 3 ) + s_qt_broken = true; + else if( major == 3 && minor == 3 ) + { + if( bugfix < 2 ) + s_qt_broken = true; + else + s_qt_broken = false; + } + else + s_qt_broken = false; + } + else + s_qt_broken = true; + + s_qt_broken_init = true; + return s_qt_broken; + } + else + return s_qt_broken; +} + diff --git a/kbarcode/textlineitem.h b/kbarcode/textlineitem.h new file mode 100644 index 0000000..9c74e3d --- /dev/null +++ b/kbarcode/textlineitem.h @@ -0,0 +1,64 @@ +/*************************************************************************** + textilinetem.h - description + ------------------- + begin : Do Sep 2 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ***************************************************************************/ + +#ifndef TEXTLINEITEM_H +#define TEXTLINEITEM_H +#include <qstring.h> +#include "documentitem.h" + +/** + * Class TextLineItem + * plain text (drawn using either DSRichText or QSimpleRichText - once it is bug free) on screen or printer. + */ +class TextLineItem : public DocumentItem { +public: + TextLineItem (); + + void draw (QPainter* painter); + void drawZpl( QTextStream* stream ); + void drawIpl( QTextStream* stream, IPLUtils* utils ); + void drawEPcl( QTextStream* stream ); + int rtti () const { return eRtti_TextLine; } + + void loadXML (QDomElement* element); + void saveXML (QDomElement* element); + + void setText (const QString & text); + void setFont (int index); + int getFont () const; + void setMagHor (int count); + int getMagHor () const; + int getMagVert () const; + void setMagVert (int count); + QString text () const; + + static bool IsQtTextRenderingBroken(); +private: + void init(); + +private: + static bool s_qt_broken; + static bool s_qt_broken_init; + + QString m_text; + int m_font; + int m_rotate; + int m_mag_vert; + int m_mag_hor; +}; +#endif //TEXTITEM_H + diff --git a/kbarcode/tokendialog.cpp b/kbarcode/tokendialog.cpp new file mode 100644 index 0000000..7b4238a --- /dev/null +++ b/kbarcode/tokendialog.cpp @@ -0,0 +1,477 @@ +/*************************************************************************** + tokendialog.h - description + ------------------- + begin : Sat Oct 23 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "tokendialog.h" +#include "tokenprovider.h" +#include "sqltables.h" +#include "dstextedit.h" + +#include <klineedit.h> +#include <klistbox.h> +#include <klistview.h> +#include <klocale.h> + +#include <qhbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qsplitter.h> +#include <qtooltip.h> +#include <qvaluelist.h> +#include <qvbox.h> +#include <qvbuttongroup.h> +#include <qwidgetstack.h> +#include <qradiobutton.h> +#include <kcombobox.h> +#include <qtextbrowser.h> +#include <kpushbutton.h> + +TokenDialog::TokenDialog(TokenProvider* token ,QWidget *parent, const char *name) + : KWizard( parent, name ), m_token( token ) +{ + m_custom_tokens = m_token->listUserVars(); + + setupPage1(); + setupPage2(); + setupPage3(); + + setupStackPage1(); + setupStackPage2(); + + setupStack2Page1(); + setupStack2Page2(); + setupStack2Page3(); + setupStack2Page4(); + setupStack2Page5(); + + enableControls(); +} + +void TokenDialog::setupPage1() +{ + QVButtonGroup* page = new QVButtonGroup( i18n("What do you want to insert?") ); + + radioFixed = new QRadioButton( i18n("Insert a &fixed data field"), page ); + radioCustom = new QRadioButton( i18n("Insert a &custom SQL query, variable or JavaScript function"), page ); + + radioFixed->setChecked( true ); + + addPage( page, i18n("Step 1 of 3") ); +} + +void TokenDialog::setupPage2() +{ + page2 = new QWidgetStack(); + + addPage( page2, i18n("Step 2 of 3") ); +} + +void TokenDialog::setupPage3() +{ + page3 = new QWidgetStack(); + + addPage( page3, i18n("Step 3 of 3") ); +} + +void TokenDialog::setupStackPage1() +{ + stackPage1 = new QVBox(); + + QVButtonGroup* group = new QVButtonGroup( i18n("What do you want to insert?"), stackPage1 ); + radioAll = new QRadioButton( i18n("&Select from a list of all tokens"), group ); + radioLabel = new QRadioButton( i18n("Insert printing &informations"), group ); + radioSQL = new QRadioButton( i18n("&Insert a database field"), group ); + radioDate = new QRadioButton( i18n("Insert a &date/time function"), group ); + radioAddress = new QRadioButton( i18n("Insert an &addressbook field"), group ); + + radioAll->setChecked( true ); + + page2->addWidget( stackPage1 ); +} + +void TokenDialog::setupStackPage2() +{ + stackPage2 = new QVBox(); + + QVButtonGroup* group = new QVButtonGroup( i18n("What do you want to insert?"), stackPage2 ); + + radioVariable = new QRadioButton( i18n("Insert a custom &variable"), group ); + radioSQLQuery = new QRadioButton( i18n("Insert a &SQL query"), group ); + radioJavaScript = new QRadioButton( i18n("Insert a &JavaScript function"), group ); + + radioVariable->setChecked( true ); + + connect( radioVariable, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioSQLQuery, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioJavaScript, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + + page2->addWidget( stackPage2 ); +} + +void TokenDialog::setupStack2Page1() +{ + stack2Page1 = new QWidget(); + + QVBoxLayout* layout = new QVBoxLayout( stack2Page1 ); + QSplitter* splitter = new QSplitter( stack2Page1 ); + layout->addWidget( splitter ); + + QVBox* left = new QVBox( splitter ); + QVBox* right = new QVBox( splitter ); + + QLabel* label = new QLabel( i18n("&Category:"), left ); + category = new KListBox( left ); + label->setBuddy( category ); + + label = new QLabel( i18n("&Token:"), right ); + allList = new KListView( right ); + allList->addColumn( i18n("Token"), 0 ); + allList->addColumn( i18n("Description"), 1 ); + allList->setColumnWidthMode( 0, QListView::Maximum ); + allList->setColumnWidthMode( 1, QListView::Maximum ); + label->setBuddy( allList ); + label = new QLabel( i18n("&Custom Expression to be inserted in the token."), right ); + lineEdit = new KLineEdit( right ); + lineEdit->setEnabled( false ); + label->setBuddy( lineEdit ); + + QToolTip::add( lineEdit, i18n("<qt>Certain tokens, like for exaple the sqlquery token need arguments. " + "In the case of the sqlquery token, the sure has to enter a sql query in " + "this text field.</qt>" ) ); + + QValueList<int> sizes; + int w = (width() / 4); + sizes << w << w * 3; + + left->setStretchFactor( category, 2 ); + right->setStretchFactor( allList, 2 ); + splitter->setSizes( sizes ); + + connect( category, SIGNAL( executed( QListBoxItem* ) ), this, SLOT( categoryChanged( QListBoxItem* ) ) ); + connect( allList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( itemChanged( QListViewItem* ) ) ); + + initAll(); + + page3->addWidget( stack2Page1 ); +} + +void TokenDialog::setupStack2Page2() +{ + stack2Page2 = new QVBox(); + + labelList = new KListView( stack2Page2 ); + labelList->addColumn( i18n("Token"), 0 ); + labelList->addColumn( i18n("Description"), 1 ); + labelList->setColumnWidthMode( 0, QListView::Maximum ); + labelList->setColumnWidthMode( 1, QListView::Maximum ); + + connect( labelList, SIGNAL( selectionChanged() ), this, SLOT( enableControls() ) ); + connect( labelList, SIGNAL( doubleClicked( QListViewItem *, const QPoint &, int ) ), this, SLOT( accept() ) ); + + page3->addWidget( stack2Page2 ); +} + +void TokenDialog::setupStack2Page3() +{ + stack2Page3 = new QVButtonGroup(); + + radioVariableNew = new QRadioButton( i18n("&Create a new custom variable"), stack2Page3 ); + editVariable = new KLineEdit( stack2Page3 ); + + radioVariableExisting = new QRadioButton( i18n("&Insert an existing custom variable"), stack2Page3 ); + listVariable = new KListBox( stack2Page3 ); + + radioVariableNew->setChecked( true ); + + if( m_token ) + listVariable->insertStringList( m_token->listUserVars() ); + + if( !listVariable->count() ) + radioVariableExisting->setEnabled( false ); + + connect( radioVariableNew, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( radioVariableExisting, SIGNAL( clicked() ), this, SLOT( enableControls() ) ); + connect( editVariable, SIGNAL( textChanged( const QString & ) ), this, SLOT( enableControls() ) ); + connect( listVariable, SIGNAL( highlighted( int ) ), this, SLOT( enableControls() ) ); + connect( listVariable, SIGNAL( doubleClicked( QListBoxItem*, const QPoint & ) ), this, SLOT( accept() ) ); + + page3->addWidget( stack2Page3 ); +} + +void TokenDialog::setupStack2Page4() +{ + stack2Page4 = new QVBox(); + + if( !SqlTables::isConnected() ) + new QLabel( i18n("<qt><b>No SQL connection found!</b><br>You can build a query, " + "but you will not be able to execute or test it right now.<br></qt>"), stack2Page4 ); + + QHBox* hbox = new QHBox( stack2Page4 ); + + QLabel* label = new QLabel( i18n("&SQL Query:"), hbox ); + editQuery = new KLineEdit( hbox ); + buttonQuery = new KPushButton( i18n("&Test"), hbox ); + label->setBuddy( editQuery ); + + hbox->setStretchFactor( editQuery, 2 ); + + new QLabel( i18n("Query test results:"), stack2Page4 ); + textQueryResults = new QTextBrowser( stack2Page4 ); + textQueryResults->setReadOnly( true ); + + connect( buttonQuery, SIGNAL( clicked() ), this, SLOT( testQuery() ) ); + connect( editQuery, SIGNAL( textChanged( const QString & ) ), this, SLOT( enableControls() ) ); + + page3->addWidget( stack2Page4 ); +} + +void TokenDialog::setupStack2Page5() +{ + stack2Page5 = new QVBox(); + + editJavaScript = new DSTextEdit( stack2Page5 ); + editJavaScript->setText( i18n("/* Place your JavaScript code into this text field. */\n") ); + + connect( editJavaScript, SIGNAL( textChanged() ), SLOT( enableControls() ) ); + + page3->addWidget( stack2Page5 ); +} + +void TokenDialog::accept() +{ + if( radioCustom->isChecked() ) + { + if( radioVariable->isChecked() ) + { + if( radioVariableNew->isChecked() ) + { + m_result = editVariable->text(); + if( !m_result.startsWith( "$" ) ) + m_result.prepend( '$' ); + } + else if( radioVariableExisting->isChecked() ) + m_result = listVariable->currentText(); + } + else if( radioSQLQuery->isChecked() ) + m_result = QString( "sqlquery:%2").arg( editQuery->text() ); + else if( radioJavaScript->isChecked() ) + m_result = QString( "js:%2").arg( editJavaScript->text() ); + + m_result = "[" + m_result + "]"; + } + else + { + QListViewItem* item = ( radioAll->isChecked() ? allList->selectedItem() : labelList->selectedItem() ); + + if( item ) + { + for( unsigned int i = 0; i < m_tokens.count(); i++ ) + if( QString( "[%1]").arg( m_tokens[i].token ) == item->text( 0 ) ) + { + if( m_tokens[i].appendix ) + m_result = QString( "[%1%2]").arg( m_tokens[i].token ).arg( lineEdit->text() ); + else + m_result = item->text( 0 ); + break; + } + } + } + + KWizard::accept(); +} + +void TokenDialog::showPage( QWidget* w ) +{ + if( w == page3 ) + { + if( radioCustom->isChecked() ) + { + if( radioVariable->isChecked() ) + page3->raiseWidget( stack2Page3 ); + else if( radioSQLQuery->isChecked() ) + page3->raiseWidget( stack2Page4 ); + else if( radioJavaScript->isChecked() ) + { + page3->raiseWidget( stack2Page5 ); + editJavaScript->setFocus(); + } + } + else + { + if( radioAll->isChecked() ) + page3->raiseWidget( stack2Page1 ); + else + { + initStackPage2(); + page3->raiseWidget( stack2Page2 ); + } + } + } + else if( w == page2 ) + { + if( radioFixed->isChecked() ) + page2->raiseWidget( stackPage1 ); + else if( radioCustom->isChecked() ) + page2->raiseWidget( stackPage2 ); + } + + KWizard::showPage( w ); +} + +void TokenDialog::initAll() +{ + unsigned int i, z; + QValueList<tCategories>* categories = TokenProvider::getTokens(); + + category->insertItem( i18n("All") ); + + for( i = 0; i < categories->count(); i++ ) + category->insertItem( TokenProvider::captionForCategory( (TokenProvider::ECategories)(*categories)[i].category ) ); + + for( i = 0; i < categories->count(); i++ ) + for( z = 0; z < (*categories)[i].tokens.count(); z++ ) + m_tokens.append( (*categories)[i].tokens[z] ); + + if( m_token ) + { + QStringList custom_tokens = m_token->listUserVars(); + for( i = 0; i < custom_tokens.count(); i++ ) + m_tokens.append( tToken( custom_tokens[i], i18n("Variable defined by the user for this label.") ) ); + } + + category->setCurrentItem( 0 ); + categoryChanged( category->item( 0 ) ); +} + +void TokenDialog::initStackPage2() +{ + TokenProvider::ECategories cat; + labelList->clear(); + + if( radioLabel->isChecked() ) + cat = TokenProvider::CAT_LABEL; + else if( radioSQL->isChecked() ) + cat = TokenProvider::CAT_DATABASE; + else if( radioDate->isChecked() ) + cat = TokenProvider::CAT_DATE; + else if( radioAddress->isChecked() ) + cat = TokenProvider::CAT_ADDRESS; + else + return; + + QValueList<tCategories>* categories = TokenProvider::getTokens(); + for( int i = 0; i < (int)categories->count(); i++ ) + { + if( (*categories)[i].category == cat ) + { + for( unsigned int z = 0; z < (*categories)[i].tokens.count(); z++ ) + labelList->insertItem( new KListViewItem( labelList, QString( "[%1]").arg( (*categories)[i].tokens[z].token ), + (*categories)[i].tokens[z].description ) ); + + break; + } + } +} + +void TokenDialog::categoryChanged( QListBoxItem* item ) +{ + unsigned int i; + QValueList<tCategories>* categories = TokenProvider::getTokens(); + allList->clear(); + lineEdit->setEnabled( false ); + + if( item->prev() == 0 ) + { + for( i = 0; i < m_tokens.count(); i++ ) + allList->insertItem( new KListViewItem( allList, QString( "[%1]").arg( m_tokens[i].token ), + m_tokens[i].description ) ); + } + else + { + for( i = 0; i < categories->count(); i++ ) + { + if( TokenProvider::captionForCategory( (TokenProvider::ECategories)(*categories)[i].category ) == item->text() ) + { + for( unsigned int z = 0; z < (*categories)[i].tokens.count(); z++ ) + allList->insertItem( new KListViewItem( allList, QString( "[%1]").arg( (*categories)[i].tokens[z].token ), + (*categories)[i].tokens[z].description ) ); + + break; + } + } + + // TODO: comparing by a user visible string cries for bugs!!! + if( item->text() == i18n("Custom Values") ) + for( i=0;i<m_custom_tokens.count();i++ ) + allList->insertItem( new KListViewItem( allList, QString( "[%1]").arg( m_custom_tokens[i] ), + i18n("Variable defined by the user for this label.") ) ); + } +} + +void TokenDialog::itemChanged( QListViewItem* item ) +{ + for( unsigned int i = 0; i < m_tokens.count(); i++ ) + { + if( QString( "[%1]").arg( m_tokens[i].token ) == item->text( 0 ) ) + { + lineEdit->setEnabled( m_tokens[i].appendix ); + if( m_tokens[i].appendix ) + lineEdit->setFocus(); + break; + } + } + + enableControls(); +} + +void TokenDialog::enableControls() +{ + setFinishEnabled( page3, false ); + + listVariable->setEnabled( radioVariableExisting->isChecked() ); + editVariable->setEnabled( radioVariableNew->isChecked() ); + + if( editVariable->isEnabled() && !editVariable->text().isEmpty() || + listVariable->isEnabled() && listVariable->currentItem() != -1 ) + setFinishEnabled( page3, true ); + + buttonQuery->setEnabled( radioSQLQuery->isChecked() && !editQuery->text().isEmpty() && SqlTables::isConnected() ); + if( radioSQLQuery->isChecked() && !editQuery->text().isEmpty() ) + setFinishEnabled( page3, true ); + + if( radioJavaScript->isChecked() && !editJavaScript->text().isEmpty() ) + setFinishEnabled( page3, true ); + + if( !radioCustom->isChecked() ) + { + if( !radioAll->isChecked() && labelList->selectedItem() ) + setFinishEnabled( page3, true ); + + if( radioAll->isChecked() && allList->selectedItem() ) + setFinishEnabled( page3, true ); + } +} + +void TokenDialog::testQuery() +{ + QString ret = "[sqlquery:" + editQuery->text() + "]"; + if( m_token ) + ret = m_token->parse( ret ); + textQueryResults->setText( ret ); +} + +#include "tokendialog.moc" + diff --git a/kbarcode/tokendialog.h b/kbarcode/tokendialog.h new file mode 100644 index 0000000..5907008 --- /dev/null +++ b/kbarcode/tokendialog.h @@ -0,0 +1,129 @@ +/*************************************************************************** + tokendialog.h - description + ------------------- + begin : Sat Oct 23 2004 + copyright : (C) 2004 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TOKENDIALOG_H +#define TOKENDIALOG_H + +#include <kwizard.h> +#include "documentitem.h" +#include "tokenprovider.h" + +class KListBox; +class KListView; +class QListBoxItem; +class QListViewItem; +class KLineEdit; +class TokenProvider; + +class QRadioButton; +class QWidgetStack; +class QHBox; +class KComboBox; +class QTextBrowser; +class KPushButton; +class DSTextEdit; + +class TokenDialog : public KWizard { + + Q_OBJECT + + public: + TokenDialog( TokenProvider* token, QWidget *parent = 0, const char *name = 0 ); + + inline const QString & token() const { return m_result; } + + private slots: + void categoryChanged( QListBoxItem* item ); + void itemChanged( QListViewItem* item ); + + private: + void initAll(); + void initStackPage2(); + + void setupPage1(); + void setupPage2(); + void setupPage3(); + + void setupStackPage1(); + void setupStackPage2(); + + void setupStack2Page1(); + void setupStack2Page2(); + void setupStack2Page3(); + void setupStack2Page4(); + void setupStack2Page5(); + + private slots: + void enableControls(); + void testQuery(); + + protected: + void accept(); + void showPage( QWidget* w ); + + private: + QStringList m_custom_tokens; + + QRadioButton* radioAll; + QRadioButton* radioLabel; + QRadioButton* radioSQL; + QRadioButton* radioDate; + QRadioButton* radioFixed; + QRadioButton* radioCustom; + QRadioButton* radioAddress; + + QRadioButton* radioSQLQuery; + QRadioButton* radioVariable; + QRadioButton* radioJavaScript; + + QRadioButton* radioVariableNew; + QRadioButton* radioVariableExisting; + + KLineEdit* editVariable; + KListBox* listVariable; + + KLineEdit* editQuery; + QTextBrowser* textQueryResults; + KPushButton* buttonQuery; + + DSTextEdit* editJavaScript; + + QString m_result; + + QWidgetStack* page2; + QWidgetStack* page3; + + QWidget* stackPage1; + QWidget* stackPage2; + + QWidget* stack2Page1; + QWidget* stack2Page2; + QWidget* stack2Page3; + QWidget* stack2Page4; + QWidget* stack2Page5; + + QValueList<tToken> m_tokens; + TokenProvider* m_token; + + KListBox* category; + KListView* allList; + KLineEdit* lineEdit; + + KListView* labelList; +}; + +#endif diff --git a/kbarcode/tokenprovider.cpp b/kbarcode/tokenprovider.cpp new file mode 100644 index 0000000..98ebfee --- /dev/null +++ b/kbarcode/tokenprovider.cpp @@ -0,0 +1,936 @@ +/*************************************************************************** + tokenprovider.cpp - description + ------------------- + begin : Fre Sep 19 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "tokenprovider.h" +#include "sqltables.h" +#include "kbarcodesettings.h" + +#include "barcodeitem.h" +#include "textitem.h" +#include "textlineitem.h" + +// Qt includes +#include <qdatetime.h> +#include <qpaintdevicemetrics.h> +#include <qsqlquery.h> +#include <qregexp.h> +#include <qvaluelist.h> +#include <time.h> + +#include <klocale.h> +#include <kabc/addressee.h> + +#ifdef USE_JAVASCRIPT +#ifdef NO_KJS_EMBED +#include <kjs/interpreter.h> +#else +#include <kjsembed/kjsembedpart.h> +#endif // NO_KJS_EMBED +#endif // USE_JAVASCRIPT + +#define NUM_FIELDS 10 + +const char* TOK_ARTICLE_NO_CUSTOMER = "article_no_customer"; +const char* TOK_BARCODE_NO_CUSTOMER = "barcode_no_customer"; +const char* TOK_ARTICLE_DESC = "article_desc"; +const char* TOK_ARTICLE_NO = "article_no"; +const char* TOK_CUSTOMER_NO = "customer_no"; +const char* TOK_CUSTOEMR_NAME = "customer_name"; +const char* TOK_BARCODE_NO = "barcode_no"; +const char* TOK_BARCODE_NO_BASIC = "barcode_no_basic"; +const char* TOK_GROUP = "group"; +const char* TOK_ENCODING_TYPE = "encoding_type"; +const char* TOK_ENCODING_TYPE_NAME = "encoding_type_name"; +const char* TOK_LINE = "line%1"; +const char* TOK_FIELD = "field%1"; + +const char* TOK_FILENAME = "filename"; +const char* TOK_INDEX = "index"; +const char* TOK_COL = "col"; +const char* TOK_ROW = "row"; +const char* TOK_PAGE = "page"; +const char* TOK_RESOLUTION = "resolution"; +const char* TOK_SERIAL = "serial"; + +const char* TOK_JS = "js:"; +const char* TOK_SQL = "sqlquery:"; +const char* TOK_VAR = "$"; + +const char* TOK_DATE = "date"; +const char* TOK_DATE_a = "date:%a"; +const char* TOK_DATE_A = "date:%A"; +const char* TOK_DATE_b = "date:%b"; +const char* TOK_DATE_B = "date:%B"; +const char* TOK_DATE_c = "date:%c"; +const char* TOK_DATE_C = "date:%C"; +const char* TOK_DATE_d = "date:%d"; +const char* TOK_DATE_D = "date:%D"; +const char* TOK_DATE_e = "date:%e"; +const char* TOK_DATE_F = "date:%F"; +const char* TOK_DATE_g = "date:%g"; +const char* TOK_DATE_G = "date:%G"; +const char* TOK_DATE_H = "date:%H"; +const char* TOK_DATE_I = "date:%I"; +const char* TOK_DATE_J = "date:%J"; +const char* TOK_DATE_m = "date:%m"; +const char* TOK_DATE_M = "date:%M"; +const char* TOK_DATE_p = "date:%p"; +const char* TOK_DATE_r = "date:%r"; +const char* TOK_DATE_R = "date:%R"; +const char* TOK_DATE_S = "date:%S"; +const char* TOK_DATE_T = "date:%T"; +const char* TOK_DATE_u = "date:%u"; +const char* TOK_DATE_U = "date:%U"; +const char* TOK_DATE_V = "date:%V"; +const char* TOK_DATE_w = "date:%w"; +const char* TOK_DATE_W = "date:%W"; +const char* TOK_DATE_x = "date:%x"; +const char* TOK_DATE_X = "date:%X"; +const char* TOK_DATE_y = "date:%y"; +const char* TOK_DATE_Y = "date:%Y"; +const char* TOK_DATE_z = "date:%z"; +const char* TOK_DATE_Z = "date:%Z"; + +const char* TOK_ADDRESS_NAME = "address_name"; +const char* TOK_ADDRESS_GIVEN_NAME = "address_givenname"; +const char* TOK_ADDRESS_FAMILY_NAME = "address_familyname"; +const char* TOK_ADDRESS_EMAIL = "address_email"; +const char* TOK_ADDRESS_FULL_EMAIL = "address_fullemail"; +const char* TOK_ADDRESS_PHONE_PREF = "address_phone"; +const char* TOK_ADDRESS_PHONE_HOME = "address_phonehome"; +const char* TOK_ADDRESS_PHONE_WORK = "address_phonework"; +const char* TOK_ADDRESS_PHONE_MSG = "address_phonemsg"; +const char* TOK_ADDRESS_PHONE_VOICE = "address_phonevoice"; +const char* TOK_ADDRESS_PHONE_FAX = "address_phonefax"; +const char* TOK_ADDRESS_PHONE_CELL = "address_phonemobile"; +const char* TOK_ADDRESS_PHONE_VIDEO = "address_phonevideo"; +const char* TOK_ADDRESS_PHONE_BBS = "address_phonebbs"; +const char* TOK_ADDRESS_PHONE_MODEM = "address_phonemodem"; +const char* TOK_ADDRESS_PHONE_CAR = "address_phonecar"; +const char* TOK_ADDRESS_PHONE_ISDN = "address_phoneisdn"; +const char* TOK_ADDRESS_PHONE_PCS = "address_phonepcs"; +const char* TOK_ADDRESS_PHONE_PAGER = "address_phonepager"; +const char* TOK_ADDRESS_ADDRESS_POB = "address_postofficebox"; +const char* TOK_ADDRESS_ADDRESS_EXTENDED = "address_extended"; +const char* TOK_ADDRESS_ADDRESS_STREET = "address_street"; +const char* TOK_ADDRESS_ADDRESS_LOCALITY = "address_locality"; +const char* TOK_ADDRESS_ADDRESS_REGION = "address_region"; +const char* TOK_ADDRESS_ADDRESS_POSTALCODE = "address_postalcode"; +const char* TOK_ADDRESS_ADDRESS_COUNTRY = "address_country"; +const char* TOK_ADDRESS_ADDRESS_LABEL = "address_label"; +const char* TOK_ADDRESS = "address"; +// --- +const char* TOK_ADDRESS_URL = "address_url"; +const char* TOK_ADDRESS_NICK = "address_nick"; +const char* TOK_ADDRESS_ADDITIONAL_NAME = "address_addtionalname"; +const char* TOK_ADDRESS_PREFIX = "address_prefix"; +const char* TOK_ADDRESS_SUFFIX = "address_suffix"; +const char* TOK_ADDRESS_BIRTHDAY = "address_birthday"; +const char* TOK_ADDRESS_TITLE = "address_title"; +const char* TOK_ADDRESS_ROLE = "address_role"; +const char* TOK_ADDRESS_NOTE = "address_note"; +const char* TOK_ADDRESS_ORGANIZATION = "address_organization"; + +TokenProvider::TokenProvider( QPaintDevice* paintdevice ) + : m_printer( paintdevice ) +{ + m_index = 0; + m_page = 0; + m_update = false; + m_contains_update = false; + m_findUserVarsList = NULL; + m_address = NULL; + + // default value for serial that should work with all barcodes + m_serial = "0000000"; + + row = col = 0; + + article_no = barcode_no = customer_no = encoding_type_name = group = label_name = QString::null; + + date_reg_exp.setPattern("date:(%[a-zA-Z])"); + +#ifdef USE_JAVASCRIPT +#ifdef NO_KJS_EMBED + s_interpreter = new KJS::Interpreter(); +#else + s_interpreter = new KJSEmbed::KJSEmbedPart(); +#endif // NO_KJS_EMBED +#endif // USE_JAVASCRIPT +} + +TokenProvider::~TokenProvider() +{ +} + +QValueList<tCategories> TokenProvider::s_categories; +QMap<TokenProvider::ECategories,QString> TokenProvider::s_captions; +#ifdef NO_KJS_EMBED +KJS::Interpreter* TokenProvider::s_interpreter = NULL; +#else +KJSEmbed::KJSEmbedPart* TokenProvider::s_interpreter = NULL; +#endif // NO_KJS_EMBED + +bool TokenProvider::hasJavaScript() +{ +#ifdef USE_JAVASCRIPT + return true; +#else + return false; +#endif // USE_JAVASCRIPT +} + +QValueList<tCategories>* TokenProvider::getTokens() +{ + TokenProvider::init(); + return &s_categories; +} + +void TokenProvider::init() +{ + if( s_categories.isEmpty() ) + { + s_captions[CAT_DATABASE] = i18n("Database"); + s_captions[CAT_LABEL] = i18n("Label"); + s_captions[CAT_CUSTOM] = i18n("Custom Values"); + s_captions[CAT_DATE] = i18n("Date & Time"); + s_captions[CAT_ADDRESS] = i18n("Addressbook"); + tCategories category; + + category.tokens.append( tToken( TOK_ARTICLE_NO_CUSTOMER, QString::null ) ); + category.tokens.append( tToken( TOK_BARCODE_NO_CUSTOMER, QString::null ) ); + category.tokens.append( tToken( TOK_ARTICLE_DESC, i18n("Article description from barcode_basic") ) ); + category.tokens.append( tToken( TOK_ARTICLE_NO, i18n("Article number from barcode_basic") ) ); + for( int i = 0; i < NUM_FIELDS; i++ ) + category.tokens.append( tToken( QString( TOK_LINE ).arg( i ), + QString( TOK_LINE ).arg( i ) + " from customer_text" ) ); + for( int i = 0; i < NUM_FIELDS; i++ ) + category.tokens.append( tToken( QString( TOK_FIELD ).arg( i ), + QString( TOK_FIELD ).arg( i ) + " from barcode_basic" ) ); + category.tokens.append( tToken( TOK_CUSTOMER_NO, i18n("customer number of the current customer") ) ); + category.tokens.append( tToken( TOK_CUSTOEMR_NAME, i18n("name of the current customer") ) ); + category.tokens.append( tToken( TOK_BARCODE_NO, i18n("Barcode number from barcode_basic") ) ); + category.tokens.append( tToken( TOK_BARCODE_NO_BASIC, QString::null ) ); + category.tokens.append( tToken( TOK_GROUP, i18n("group of the current article") ) ); + category.tokens.append( tToken( TOK_ENCODING_TYPE, i18n("Barcode encoding type from barcode_basic") ) ); + category.tokens.append( tToken( TOK_ENCODING_TYPE_NAME, i18n("User readable barcode encoding type from barcode_basic") ) ); + category.category = CAT_DATABASE; + s_categories.append( category ); + + category.tokens.clear(); + category.tokens.append( tToken( TOK_FILENAME, i18n("Path and filename of this file") ) ); + category.tokens.append( tToken( TOK_INDEX, i18n("number of labels currently printed during this printout") ) ); + category.tokens.append( tToken( TOK_COL, i18n("current column on the page") ) ); + category.tokens.append( tToken( TOK_ROW, i18n("current row on the page") ) ); + category.tokens.append( tToken( TOK_PAGE, i18n("Current page") ) ); + category.tokens.append( tToken( TOK_RESOLUTION, i18n("Current resolution") ) ); + category.tokens.append( tToken( TOK_SERIAL, i18n("Include a serial number on your labels.") ) ); + category.category = CAT_LABEL; + s_categories.append( category ); + + category.tokens.clear(); + if( hasJavaScript() ) + category.tokens.append( tToken( TOK_JS, i18n("Execute java script code"), true ) ); + category.tokens.append( tToken( TOK_SQL, i18n("Insert the result of a custom sql query"), true ) ); + category.tokens.append( tToken( TOK_VAR, i18n("Insert a custom variable"), true ) ); + category.category = CAT_CUSTOM; + s_categories.append( category ); + + category.tokens.clear(); + category.tokens.append( tToken( TOK_DATE, i18n("Date formated as configured in the preferences") ) ); + category.tokens.append( tToken( TOK_DATE_a, i18n("Short Weekday Name") ) ); + category.tokens.append( tToken( TOK_DATE_A, i18n("Full Weekday Name") ) ); + category.tokens.append( tToken( TOK_DATE_b, i18n("Short Month Name") ) ); + category.tokens.append( tToken( TOK_DATE_B, i18n("Full Month Name") ) ); + category.tokens.append( tToken( TOK_DATE_c, i18n("Date-Time") ) ); + category.tokens.append( tToken( TOK_DATE_C, i18n("Century") ) ); + category.tokens.append( tToken( TOK_DATE_d, i18n("Day Number (01-31)") ) ); + category.tokens.append( tToken( TOK_DATE_D, i18n("Month-Day-year") ) ); + category.tokens.append( tToken( TOK_DATE_e, i18n("Day Number ( 1-31)") ) ); + category.tokens.append( tToken( TOK_DATE_F, i18n("Year-Month-day") ) ); + category.tokens.append( tToken( TOK_DATE_g, i18n("Week Year (yy)") ) ); + category.tokens.append( tToken( TOK_DATE_G, i18n("Week Year (yyyy)") ) ); + category.tokens.append( tToken( TOK_DATE_H, i18n("Hour (01-24)") ) ); + category.tokens.append( tToken( TOK_DATE_I, i18n("Hour (1-12)") ) ); + category.tokens.append( tToken( TOK_DATE_J, i18n("Day of Year") ) ); + category.tokens.append( tToken( TOK_DATE_m, i18n("Month Number (01-12)") ) ); + category.tokens.append( tToken( TOK_DATE_M, i18n("Minute (00-59)") ) ); + category.tokens.append( tToken( TOK_DATE_p, i18n("a.m./p.m.") ) ); + category.tokens.append( tToken( TOK_DATE_r, i18n("Time (h:m:s am/pm)") ) ); + category.tokens.append( tToken( TOK_DATE_R, i18n("Time (HH:MM)") ) ); + category.tokens.append( tToken( TOK_DATE_S, i18n("Seconds (00-59)") ) ); + category.tokens.append( tToken( TOK_DATE_T, i18n("Time (HH:MM:SS)") ) ); + category.tokens.append( tToken( TOK_DATE_u, i18n("Weekday (1=Monday...)") ) ); + category.tokens.append( tToken( TOK_DATE_U, i18n("Week Number (00-53)") ) ); + category.tokens.append( tToken( TOK_DATE_V, i18n("Week Number (01-53)") ) ); + category.tokens.append( tToken( TOK_DATE_w, i18n("Weekday (0=Sunday...)") ) ); + category.tokens.append( tToken( TOK_DATE_W, i18n("Week Number (00-53)") ) ); + category.tokens.append( tToken( TOK_DATE_x, i18n("Local Date") ) ); + category.tokens.append( tToken( TOK_DATE_X, i18n("Local Time") ) ); + category.tokens.append( tToken( TOK_DATE_y, i18n("Year (00-99)") ) ); + category.tokens.append( tToken( TOK_DATE_Y, i18n("Year (YYYY)") ) ); + category.tokens.append( tToken( TOK_DATE_z, i18n("Offset from UTC") ) ); + category.tokens.append( tToken( TOK_DATE_Z, i18n("Timezone Name") ) ); + category.category = CAT_DATE; + s_categories.append( category ); + + category.tokens.clear(); + category.tokens.append( tToken( TOK_ADDRESS_NAME, i18n("Name") ) ); + category.tokens.append( tToken( TOK_ADDRESS_GIVEN_NAME, KABC::Addressee::givenNameLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_FAMILY_NAME, KABC::Addressee::familyNameLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_EMAIL, KABC::Addressee::emailLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_FULL_EMAIL, i18n("Full E-Mail") ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_PREF, KABC::PhoneNumber::label( KABC::PhoneNumber::Pref ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_HOME, KABC::PhoneNumber::label( KABC::PhoneNumber::Home ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_WORK, KABC::PhoneNumber::label( KABC::PhoneNumber::Work ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_MSG, KABC::PhoneNumber::label( KABC::PhoneNumber::Msg ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_VOICE, KABC::PhoneNumber::label( KABC::PhoneNumber::Voice ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_FAX, KABC::PhoneNumber::label( KABC::PhoneNumber::Fax ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_CELL, KABC::PhoneNumber::label( KABC::PhoneNumber::Cell ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_VIDEO, KABC::PhoneNumber::label( KABC::PhoneNumber::Video ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_BBS, KABC::PhoneNumber::label( KABC::PhoneNumber::Bbs ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_MODEM, KABC::PhoneNumber::label( KABC::PhoneNumber::Modem ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_CAR, KABC::PhoneNumber::label( KABC::PhoneNumber::Car ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_ISDN, KABC::PhoneNumber::label( KABC::PhoneNumber::Isdn ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_PCS, KABC::PhoneNumber::label( KABC::PhoneNumber::Pcs ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_PHONE_PAGER, KABC::PhoneNumber::label( KABC::PhoneNumber::Pager ) ) ); + category.tokens.append( tToken( TOK_ADDRESS_ADDRESS_POB, KABC::Address::postOfficeBoxLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_ADDRESS_EXTENDED, KABC::Address::extendedLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_ADDRESS_STREET, KABC::Address::streetLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_ADDRESS_LOCALITY, KABC::Address::localityLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_ADDRESS_REGION, KABC::Address::regionLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_ADDRESS_POSTALCODE, KABC::Address::postalCodeLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_ADDRESS_COUNTRY, KABC::Address::countryLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_ADDRESS_LABEL, KABC::Address::labelLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS, i18n("Formatted Address") ) ); + category.tokens.append( tToken( TOK_ADDRESS_URL, KABC::Addressee::urlLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_NICK, KABC::Addressee::nickNameLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_ADDITIONAL_NAME, KABC::Addressee::additionalNameLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_PREFIX, KABC::Addressee::prefixLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_SUFFIX, KABC::Addressee::suffixLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_BIRTHDAY, KABC::Addressee::birthdayLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_TITLE, KABC::Addressee::titleLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_ROLE, KABC::Addressee::roleLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_NOTE, KABC::Addressee::noteLabel() ) ); + category.tokens.append( tToken( TOK_ADDRESS_ORGANIZATION, KABC::Addressee::organizationLabel() ) ); + category.category = CAT_ADDRESS; + s_categories.append( category ); + } +} + + +void TokenProvider::findBrackets( QString & text, QString (TokenProvider::*parserfunction)( const QString & ) ) +{ + /* + * looks for a statement in brackets [ ] + * and calls findToken() with this statement. + */ + + int num, pos = -1, a; + QString token; + + if( text.contains("]", FALSE) <= 0 || text.isEmpty() ) + return; + + num = text.contains("[", FALSE); + if(num <= 0 ) + return; + + pos = text.findRev("[", pos); + a = text.find("]", pos ); + if( a < 0 && pos >= 0 ) + return; + + if( pos < 0 && a >= 0 ) + return; + + if( pos >= 0 && a >= 0 ) { + token = text.mid( pos+1, (a-pos)-1 ); + + // support [4-[length]] + findBrackets( token, parserfunction ); + + token = unescapeText( token ); + token = escapeText( (*this.*parserfunction)( token ) ); + if( !token.isNull() ) + { + text.remove( pos, (a-pos)+1 ); + text.insert( pos, token ); + } + else + // TODO: if we have a textfield with two variables: + // [index] [non_existant], index will not be parsed + // because of the non_existant field (which might be + // caused by a typo... + + // otherwise we would end up in and endless recursion + // no one wants that... + return; + } + + findBrackets( text, parserfunction ); +} + +QString TokenProvider::parse( const QString & text ) +{ + QString t = QString( text ); + findBrackets( t, &TokenProvider::process ); + return t; +} + +QStringList TokenProvider::listUserVars() +{ + unsigned int i; + DocumentItem* item; + QStringList lst; + QString t; + + m_findUserVarsList = &lst; + + for( i=0;i<m_document_items.count();i++ ) + { + item = m_document_items.at(i); + t = QString::null; + if( item->rtti() == eRtti_Barcode ) + t = ((BarcodeItem*)item)->value(); + else if( item->rtti() == eRtti_Text ) + t = ((TextItem*)item)->text(); + else if( item->rtti() == eRtti_TextLine ) + t = ((TextLineItem*)item)->text(); + + if( !t.isNull() ) + findBrackets( t, &TokenProvider::processUserVars ); + } + + m_findUserVarsList = NULL; + + lst.sort(); + return lst; +} + +QString TokenProvider::processUserVars( const QString & t ) +{ + QStringList::Iterator it; + bool found = false; + + if( m_findUserVarsList ) + { + if( t.startsWith( TOK_VAR ) ) + { + // every token starting with $ is a user defined variable + for(it = m_findUserVarsList->begin(); it != m_findUserVarsList->end(); ++it ) + if( (*it).lower() == t.lower() ) + { + found = true; + break; + } + + if( !found ) + m_findUserVarsList->append( t ); + } + } + + return t; +} + +QString TokenProvider::process( const QString & t ) +{ + QString ret = QString::null; + QString addr; + int i; + + // process all token that require an sql connection + if( SqlTables::isConnected() ) + { + if( !article_no.isEmpty() ) + { + for( i = 0; i < NUM_FIELDS; i++ ) + { + const QString c = QString( TOK_LINE ).arg( i ); + if( t == c ) + ret = query( "SELECT " + c + " FROM " + TABLE_CUSTOMER_TEXT + " WHERE article_no='" + article_no + + "' AND customer_no='" + customer_no + "'"); + } + + for( i = 0; i < NUM_FIELDS; i++ ) + { + const QString c = QString( TOK_FIELD ).arg( i ); + if( t == c ) + ret = query("SELECT " + c + " FROM " + TABLE_BASIC + " WHERE article_no='" + article_no + "'"); + } + + + if( t == TOK_ARTICLE_NO_CUSTOMER ) + ret = query( QString("SELECT article_no_customer FROM ") + TABLE_CUSTOMER_TEXT + " WHERE article_no='" + + article_no + "' AND customer_no='" + customer_no + "'"); + + if( t == TOK_BARCODE_NO_CUSTOMER ) + ret = query( QString("SELECT barcode_no FROM ") + TABLE_CUSTOMER_TEXT + " WHERE article_no='" + + article_no + "' AND customer_no='" + customer_no + "'"); + + if( t == TOK_ARTICLE_DESC ) + ret = query( QString("SELECT article_desc FROM ") + TABLE_BASIC + " WHERE article_no='" + article_no + "'"); + + if( t == TOK_BARCODE_NO ) + ret = query( QString("SELECT barcode_no FROM ") + TABLE_BASIC + " WHERE article_no='" + article_no + "'"); + + if( t == TOK_ARTICLE_NO ) + ret = article_no; + } + + if( !customer_no.isEmpty() && t == TOK_CUSTOEMR_NAME ) + ret = query( QString("SELECT customer_name FROM ") + TABLE_CUSTOMER + " WHERE customer_no='" + customer_no + "'"); + + const QString sqlq = TOK_SQL; + if( t.startsWith( sqlq ) ) + ret = query( t.right( t.length() - sqlq.length() ) ); + } + + if( !customer_no.isEmpty() && t == TOK_CUSTOMER_NO ) + ret = customer_no; + + if( !barcode_no.isEmpty() && t == TOK_BARCODE_NO ) + ret = barcode_no; + + if( !group.isEmpty() && t == TOK_GROUP ) + ret = group; + + if( !encoding_type_name.isEmpty() && t == TOK_ENCODING_TYPE_NAME ) + ret = encoding_type_name; + + if( !label_name.isEmpty() && t == TOK_FILENAME ) + ret = label_name; + + if( t == TOK_DATE ) + ret = QDateTime::currentDateTime().toString( KBarcodeSettings::getDateFormat() ); + + if( date_reg_exp.search(t,0) != -1 ) + { + time_t label_time; + struct tm label_time_struct; + char temp_time_str[50] ; + + label_time = time(&label_time) ; + localtime_r(&label_time,&label_time_struct) ; + + strftime(temp_time_str,sizeof temp_time_str - 1, date_reg_exp.cap(1).ascii(),&label_time_struct); + ret = temp_time_str; + } + + if( t == TOK_INDEX ) + { + m_contains_update = true; + ret = QString::number( m_index + 1 ); + } + + if( t == TOK_ROW ) + { + m_contains_update = true; + ret = QString::number( row + 1 ); + } + + if( t == TOK_COL ) + { + m_contains_update = true; + ret = QString::number( col + 1 ); + } + + if( t == TOK_PAGE ) + { + m_contains_update = true; + ret = QString::number( m_page + 1 ); + } + + if( m_printer && t == TOK_RESOLUTION ) + { + QPaintDeviceMetrics metrics( m_printer ); + ret = QString( "%1dpi" ).arg( metrics.logicalDpiY() ); + } + + if( !m_serial.isEmpty() && t == TOK_SERIAL ) + { + m_contains_update = true; + ret = createSerial(); + } + + + addr = processAddresses( t ); + if( !addr.isNull() ) + ret = addr; + + // let's parse java script code + const QString js = TOK_JS; + if( t.startsWith( js ) ) + ret = jsParse( t.right( t.length() - js.length() ) ); + + // everything starting with a $ is a user defined variable + if( !m_uservardata.isEmpty() ) + { + QString tok = t.right( t.length() - 1 ); + if( m_uservardata.contains( tok ) ) + { + ret = m_uservardata[tok]; + if( ret.isNull() ) + ret = ""; // we want an empty string and not a null string + } + } + + return ret; +} + +QString TokenProvider::processAddresses( const QString & t ) +{ + QString ret = QString::null; + bool found = false; + + if( !m_address || !t.startsWith( "address" ) ) + return ret; + + KABC::Address addr = m_address->address( KABC::Address::Pref ); + if( addr.isEmpty() ) + { + KABC::Address::List list = m_address->addresses(); + for( int i=0;i<list.count();i++ ) + if( !list[i].isEmpty() ) + { + addr = list[i]; + break; + } + } + + if( t == TOK_ADDRESS_NAME ) + { + ret = m_address->realName(); + found = true; + } + else if( t == TOK_ADDRESS_GIVEN_NAME ) + { + ret = m_address->givenName(); + found = true; + } + else if( t == TOK_ADDRESS_FAMILY_NAME ) + { + ret = m_address->familyName(); + found = true; + } + else if( t == TOK_ADDRESS_EMAIL ) + { + ret = m_address->preferredEmail(); + found = true; + } + else if( t == TOK_ADDRESS_FULL_EMAIL ) + { + ret = m_address->fullEmail(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_PREF ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Pref ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_HOME ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Home ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_WORK ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Work ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_MSG ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Msg ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_VOICE ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Voice ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_FAX ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Fax ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_CELL ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Cell ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_VIDEO ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Video ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_BBS ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Bbs ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_MODEM ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Modem ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_CAR ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Car ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_ISDN ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Isdn ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_PCS ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Pcs ).number(); + found = true; + } + else if( t == TOK_ADDRESS_PHONE_PAGER ) + { + ret = m_address->phoneNumber( KABC::PhoneNumber::Pager ).number(); + found = true; + } + else if( t == TOK_ADDRESS_ADDRESS_POB ) + { + ret = addr.postOfficeBox(); + found = true; + } + else if( t == TOK_ADDRESS_ADDRESS_EXTENDED ) + { + ret = addr.extended(); + found = true; + } + else if( t == TOK_ADDRESS_ADDRESS_STREET ) + { + ret = addr.street(); + found = true; + } + else if( t == TOK_ADDRESS_ADDRESS_LOCALITY ) + { + ret = addr.locality(); + found = true; + } + else if( t == TOK_ADDRESS_ADDRESS_REGION ) + { + ret = addr.region(); + found = true; + } + else if( t == TOK_ADDRESS_ADDRESS_POSTALCODE ) + { + ret = addr.postalCode(); + found = true; + } + else if( t == TOK_ADDRESS_ADDRESS_COUNTRY ) + { + ret = addr.country(); + found = true; + } + else if( t == TOK_ADDRESS_ADDRESS_LABEL ) + { + ret = addr.label(); + found = true; + } + else if( t == TOK_ADDRESS ) + { + ret = addr.formattedAddress( m_address->realName(), m_address->organization() ); + found = true; + } + else if( t == TOK_ADDRESS_URL ) + { + ret = m_address->url().prettyURL(); + found = true; + } + else if( t == TOK_ADDRESS_NICK ) + { + ret = m_address->nickName(); + found = true; + } + else if( t == TOK_ADDRESS_ADDITIONAL_NAME ) + { + ret = m_address->additionalName(); + found = true; + } + else if( t == TOK_ADDRESS_PREFIX ) + { + ret = m_address->prefix(); + found = true; + } + else if( t == TOK_ADDRESS_SUFFIX ) + { + ret = m_address->suffix(); + found = true; + } + else if( t == TOK_ADDRESS_BIRTHDAY ) + { + ret = m_address->birthday().date().toString(); + found = true; + } + else if( t == TOK_ADDRESS_TITLE ) + { + ret = m_address->title(); + found = true; + } + else if( t == TOK_ADDRESS_ROLE ) + { + ret = m_address->role(); + found = true; + } + else if( t == TOK_ADDRESS_NOTE ) + { + ret = m_address->note(); + found = true; + } + else if( t == TOK_ADDRESS_ORGANIZATION ) + { + ret = m_address->organization(); + found = true; + } + else + ret = t; + + if( found && ret.isNull() ) + ret = ""; // empty string, not null string + + return ret; +} + +QString TokenProvider::query( const QString & query ) +{ + if( !query.isEmpty() ) + { + QSqlQuery q( query ); + while( q.next() ) + return q.value( 0 ).toString(); + + return QString::null; + } + else + return i18n("ERROR: Empty SQL Query"); +} + +QString TokenProvider::jsParse( const QString & script ) +{ + QString ret = QString::null; + + ret = "ERROR: No JavaScript interpreter present!"; + +#ifdef USE_JAVASCRIPT +#if 0 + KJS::Interpreter *js = KParts::ComponentFactory::createInstanceFromQuery<KJS::Interpreter>( "KJSEmbed/KJSEmbed" ); + qDebug("JavaScript: %p", js ); + // KJS::Interpreter *js = KJSEmbed::JSFactory::defaultJS() + // KJS::Interpreter *js = new KJS::Interpreter(); //KJSEmbed::JSFactory::defaultJS(); + KJS::Completion comp; + KJS::Value self; + + bool ok = 0;//js->execute( comp, script, self ); + if( ok && comp.isValueCompletion() ) + { + KJS::UString s = comp.value().toString( js->globalExec() ); + ret = s.qstring(); + } + + //delete js; +//#else + KJS::Interpreter *js = new KJS::Interpreter(); //KJSEmbed::JSFactory::defaultJS(); + KJS::Completion comp; + + comp = js->evaluate( KJS::UString( script.latin1() ) ); + if( comp.complType() == KJS::ReturnValue || comp.complType() == KJS::Normal ) + { + ret = comp.value().toString( js->globalExec() ).cstring().c_str(); + } + +#else + // Maybe we need no Completion object for KJSEmbed + KJS::Completion comp = s_interpreter->evaluate( KJS::UString( script.latin1() ) ); + KJS::Value val = comp.value(); + if( val.isValid() ) + ret = val.toString( s_interpreter->globalExec() ).cstring().c_str(); +#endif + +#endif // USE_JAVASCRIPT + + return ret; +} + +bool TokenProvider::jsParseToBool( const QString & script ) +{ +#ifdef USE_JAVASCRIPT + // Maybe we need no Completion object for KJSEmbed + KJS::Completion comp = s_interpreter->evaluate( KJS::UString( script.latin1() ) ); + KJS::Value val = comp.value(); + if( val.isValid() ) + { + return val.toBoolean( s_interpreter->globalExec() ); + } +#endif // USE_JAVASCRIPT + + return false; +} + +const QString TokenProvider::createSerial() +{ + unsigned long tmp; + QString s = QString::null; + // Split string into prenum, number and postnum parts + QRegExp splitit("(\\D*)(\\d+)(.*)"); + int pos = splitit.search(m_serial); + + // Is there anything to increment ? + if (pos > -1) { + QString prenum = splitit.cap(1); + + tmp = splitit.cap(2).toULong(); + QString postnum = splitit.cap(3); + tmp += (m_increment*m_index); + QString tmpstr; + tmpstr.setNum(splitit.cap(2).length()); + QString formatstring = "%0" + tmpstr + "lu"; + + s = prenum + tmpstr.sprintf(formatstring, tmp) + postnum; + m_update = true; + } + + return s; +} + +QString TokenProvider::unescapeText( const QString & t ) +{ + QString tmp = t; + tmp = tmp.replace( DSREPLACE( "<" ), "<" ); + tmp = tmp.replace( DSREPLACE( ">" ), ">" ); + tmp = tmp.replace( DSREPLACE( "&" ), "&" ); + tmp = tmp.replace( DSREPLACE( """ ), "\"" ); + + return tmp; +} + +QString TokenProvider::escapeText( const QString & t ) +{ + QString tmp = t; + tmp = tmp.replace( DSREPLACE( "<" ), "<" ); + tmp = tmp.replace( DSREPLACE( ">" ), ">" ); + tmp = tmp.replace( DSREPLACE( "&" ), "&" ); + tmp = tmp.replace( DSREPLACE( "\"" ), """ ); + tmp = tmp.replace( DSREPLACE( "\n" ), "<br />" ); + + return tmp; +} diff --git a/kbarcode/tokenprovider.h b/kbarcode/tokenprovider.h new file mode 100644 index 0000000..ac7e57f --- /dev/null +++ b/kbarcode/tokenprovider.h @@ -0,0 +1,250 @@ +/*************************************************************************** + tokenprovider.h - description + ------------------- + begin : Fre Sep 19 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TOKENPROVIDER_H +#define TOKENPROVIDER_H + +// enable JAVASCRIPT interpreter +#define USE_JAVASCRIPT +// use KJS instead of +#define NO_KJS_EMBED + +#include <qstring.h> +#include <qregexp.h> +#include <time.h> + +#include "documentitem.h" + +namespace KABC { + class Addressee; +}; + +class tToken { + public: + tToken() {}; + + tToken( const QString & t, const QString & d, bool a = false ) + { + token = t; + description = d; + appendix = a; + } + + void operator=( const tToken & rhs ) + { + token = rhs.token; + description = rhs.description; + appendix = rhs.appendix; + } + + QString token; + QString description; + bool appendix; +}; + +struct tCategories { + int category; + QValueList<tToken> tokens; +}; + + +#ifndef NO_KJS_EMBED +namespace KJSEmbed { + class KJSEmbedPart; +} +#else +namespace KJS { + class Interpreter; +} +#endif // NO_KJS_EMBED + +class QPaintDevice; + +/** This class handles the replacement of tokens like [date] or [article_no]. + * + *@author Dominik Seichter + */ +class TokenProvider { + public: + enum ECategories { CAT_DATABASE, CAT_LABEL, CAT_CUSTOM, CAT_DATE, CAT_ADDRESS }; + + TokenProvider( QPaintDevice* paintdevice ); + virtual ~TokenProvider(); + + static bool hasJavaScript(); + + static QValueList<tCategories>* getTokens(); + + /** + * Get a caption which can be displayed to the user from + * a ECategory enum. + * + * @param e the category which should be used + * + * @returns a translated caption which can be displayed to the user + */ + static const QString captionForCategory( ECategories e ) { + return s_captions[e]; + } + + inline void updateDone() { m_update = false; } + inline virtual bool update() { + return m_update && m_contains_update; + } + + inline void setIndex( unsigned int index ) { m_index = index; m_update = true; } + inline void setPage( unsigned int page ) { m_page = page; m_update = true; } + inline void setArticleNo( const QString & t ) { article_no = t; m_update = true; } + inline void setBarcodeNo( const QString & t ) { barcode_no = t; m_update = true; } + inline void setCustomerNo( const QString & t ) { customer_no = t; m_update = true; } + inline void setEncodingTypeName( const QString & t ) { encoding_type_name = t; m_update = true; } + inline void setGroup( const QString & t ) { group = t; m_update = true; } + inline void setLabelName( const QString & t ) { label_name = t; m_update = true; } + inline void setCol( unsigned int c ) { col = c; m_update = true; } + inline void setRow( unsigned int r ) { row = r; m_update = true; } + inline void setSerial( const QString &t, unsigned int inc ) { m_serial = t; m_increment = inc; m_update = true; m_contains_update = true;} + inline void setAddressee( KABC::Addressee* pAddressee ) { m_address = pAddressee; } + + inline int index() const { return m_index; } + inline unsigned int page() const { return m_page; } + inline const QString & articleNo() const { return article_no; } + inline const QString & barcodeNo() const { return barcode_no; } + inline const QString & serial() const { return m_serial; } + + inline void setPaintDevice( QPaintDevice* paint ) { m_printer = paint; } + inline QPaintDevice* paintDevice() const { return m_printer; } + + /** + * parse the given java script code and return its result + * @returns either the result of the javascript code + * or an error message + * @p script javascript code to execute + */ + QString jsParse( const QString & script ); + + /** + * parse the given java script code and return its result + * @returns true or false + * @p script javascript code to execute + */ + bool jsParseToBool( const QString & script ); + + /** + * parse the given text for tokens and return a + * string with all tokens replaced correctly. + * @param text QString look in this text for tokens to replace + */ + QString parse( const QString & text ); + + + /** + * set @p list as DocumentItemList which is used for @see listUserVars + */ + inline void setCurrentDocumentItems( const DocumentItemList & list ); + + /** + * parses all DocumentItems in @p list and returns a stringlist + * containing all user defined variables in these DocumentItems. + * A user defined variable is something like [$MyVar1]. Variable + * names are case insensitive. + */ + QStringList listUserVars(); + + + inline void setUserVars( const QMap<QString,QString> & data ); + + private: + static void init(); + + const QString createSerial(); + + QString escapeText( const QString & t ); + QString unescapeText( const QString & t ); + + /** A helper function called from parse + * which returns the value for every known + * token @p text. + */ + QString process( const QString & text ); + + /** A helper function called from parse + * which returns the value for every known + * token @p t. + */ + QString processAddresses( const QString & t ); + + /** a helper function needed by listUserVars. + * which adds all user defined variables to + * m_findUserVars. + */ + QString processUserVars( const QString & t ); + + void findBrackets( QString & text, QString (TokenProvider::*parserfunction)( const QString & ) ); + + /** + * run a SQL Query and return it result + * @param query QString the SQL command to execute + */ + QString query( const QString & query ); + + unsigned int m_index; + unsigned int m_page; + unsigned int m_increment; + + DocumentItemList m_document_items; + + QMap<QString,QString> m_uservardata; + + QString article_no; + QString barcode_no; + QString customer_no; + QString encoding_type_name; + QString group; + QString label_name; + QString m_serial; + unsigned int row; + unsigned int col; + + bool m_update; + bool m_contains_update; + QPaintDevice* m_printer; + QRegExp date_reg_exp ; + + KABC::Addressee* m_address; + + QStringList* m_findUserVarsList; + static QValueList<tCategories> s_categories; + static QMap<ECategories, QString> s_captions; + +#ifdef NO_KJS_EMBED + static KJS::Interpreter* s_interpreter; +#else + static KJSEmbed::KJSEmbedPart* s_interpreter; +#endif // NO_KJS_EMBED +}; + +inline void TokenProvider::setCurrentDocumentItems( const DocumentItemList & list ) +{ + m_document_items = list; +} + +inline void TokenProvider::setUserVars( const QMap<QString,QString> & data ) +{ + m_uservardata = data; +} + +#endif diff --git a/kbarcode/xmlutils.cpp b/kbarcode/xmlutils.cpp new file mode 100644 index 0000000..64b5c36 --- /dev/null +++ b/kbarcode/xmlutils.cpp @@ -0,0 +1,489 @@ +/*************************************************************************** + xmlutils.cpp - description + ------------------- + begin : Mit Mai 7 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "xmlutils.h" +#include "definition.h" +#include "mycanvasview.h" +#include "mycanvasitem.h" +#include "labelutils.h" +#include "measurements.h" +#include "barcodeitem.h" +#include "rectitem.h" +#include "imageitem.h" +#include "lineitem.h" +#include "textitem.h" +#include "textlineitem.h" + +// Qt includes +#include <qdom.h> + +// KDE includes +#include <kapplication.h> +#include <klocale.h> +#include <kmessagebox.h> + +XMLUtils::XMLUtils() +{ + // read barcodes saved by kbarcode < 1.3.0 + if( !legacy.count() ) + { + legacy.insert( "0", "any" ); + legacy.insert( "1", "ean" ); + legacy.insert( "2", "upc" ); + legacy.insert( "3", "isbn" ); + legacy.insert( "4", "code39" ); + legacy.insert( "5", "code128" ); + legacy.insert( "6", "code128c" ); + legacy.insert( "7", "code128b" ); + legacy.insert( "8", "i25" ); + legacy.insert( "9", "i28raw" ); + legacy.insert( "10", "cbr" ); + legacy.insert( "11", "msi" ); + legacy.insert( "12", "pls" ); + legacy.insert( "13", "code93" ); + legacy.insert( "14", "msi" ); + legacy.insert( "15", "code39 -c" ); + legacy.insert( "16", "i25 -c" ); + } +} + +XMLUtils::~XMLUtils() +{ +} + +QMap<QString,QString> XMLUtils::legacy; + +void XMLUtils::readXMLHeader( QDomDocument* doc, QString & description, bool & kbarcode18, Definition** def ) +{ + QDomNode n = doc->documentElement().firstChild(); + // this should not be neccessary, + // but <label><id> needs to be processed first + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + // label has to be the first xml element! + if( e.tagName() == "label" ) { + kbarcode18 = (e.attribute( "fileformat-version", "1" ).toInt() == 1); + QDomNode n = e.firstChild(); + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + if( e.tagName() == "description" ) + description = e.text(); + else if( e.tagName() == "id" ) { + if( *def ) + delete *def; + *def = readDefinition( &e ); + } + + n = n.nextSibling(); + } + } + n = n.nextSibling(); + } +} + +void XMLUtils::writeXMLHeader( QDomNode* root, const QString & description, Definition* def ) +{ + QDomElement data = root->ownerDocument().createElement( "label" ); + /** kbarcode <= 1.8.x = fileformat-version = 1 */ + /** kbarcode >= 1.9.0 = fileformat-version = 2 */ + data.setAttribute( "fileformat-version", "2" ); + + if( !description.isEmpty() ) { + QDomElement labeldescription = root->ownerDocument().createElement( "description" ); + labeldescription.appendChild( root->ownerDocument().createTextNode( description ) ); + data.appendChild( labeldescription ); + } + + QDomElement labelid = root->ownerDocument().createElement( "id" ); + writeDefinition( &labelid, def ); + labelid.appendChild( root->ownerDocument().createTextNode( QString( "%1" ).arg(def->getId()) ) ); + + data.appendChild( labelid ); + root->appendChild( data ); +} + +void XMLUtils::readDocumentItems( DocumentItemList* list, QDomDocument* doc, TokenProvider* token, bool kbarcode18 ) +{ + QDomNode n = doc->documentElement().firstChild(); + list->setAutoDelete( false ); + + if( kbarcode18 ) + { + // legacy loading + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + if( e.tagName() == "barcode" ) { + BarcodeItem* bcode = new BarcodeItem(); + ((DocumentItem*)bcode)->setTokenProvider( token ); + readBarcode( &e, bcode ); + bcode->updateBarcode(); + bcode->setZ( e.attribute( "z", "0" ).toInt() ); + + list->append( bcode ); + } else if( e.tagName() == "textfield" ) { + TextItem* t = new TextItem(); + t->setTokenProvider( token ); + + QRect r = readXMLRect( &e ); + t->setBoundingRect( r ); + t->setZ( e.attribute( "z", "0" ).toInt() ); + + QDomNode n = e.firstChild(); + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + if( e.tagName() == "text" ) + { + t->setText( e.text() ); + break; + } + n = n.nextSibling(); + } + + list->append( t ); + } else if( e.tagName() == "picture" ) { + ImageItem* r = new ImageItem(); + + QRect rect = readXMLRect( &e ); + r->setBoundingRect( rect ); + + QPixmap pix; + pix.loadFromData( e.text().utf8(), "XPM" ); + r->setPixmap( pix ); + r->setRotation( e.attribute("rotation", "0.0" ).toDouble() ); + r->setZ( e.attribute( "z", "0" ).toInt() ); + list->append( r ); + } else if( e.tagName() == "rect" ) { + RectItem* r = new RectItem(); + + QRect rect = readXMLRect( &e ); + r->setBoundingRect( rect ); + r->setZ( e.attribute( "z", "0" ).toInt() ); + + r->setCircle( e.attribute( "circle", "0" ).toInt() ); + + r->setPen( QPen(readXMLColor( &e, "bordercolor", Qt::black ),e.attribute( "borderwidth", "1" ).toInt(),(Qt::PenStyle)e.attribute( "borderstyle", "1" ).toInt() )); + r->setColor( readXMLColor( &e, "color", Qt::black ) ); + list->append( r ); + } else if( e.tagName() == "line" ) { +#warning "TODO: test legacy loading of lines" + LineItem* cl = new LineItem(); + int x = e.attribute( "x1", "0" ).toInt(); + int y = e.attribute( "y1", "0" ).toInt(); + cl->setBoundingRect( QRect( x, y, e.attribute( "x2", "0" ).toInt(), e.attribute( "y2", "0" ).toInt() ) ); + + cl->setZ( e.attribute( "z", "0" ).toInt() ); + cl->setPen( QPen( readXMLColor( &e, "color", Qt::black ), + e.attribute( "width", "0" ).toInt(), (QPen::PenStyle)e.attribute( "style", "0" ).toInt() ) ); + list->append( cl ); + } + n = n.nextSibling(); + } + } + else + { + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + { + DocumentItem* item = NULL; + if( readXMLDocumentItem( &e, &item, token ) ) + list->append( item ); + } + n = n.nextSibling(); + } + } + +} + +void XMLUtils::writeXMLDocumentItem( QDomElement* root, DocumentItem** item ) +{ + if( !item ) + return; + + QDomElement tag; + if( (*item)->rtti() == eRtti_Barcode ) + tag = root->ownerDocument().createElement( "barcode" ); + else if( (*item)->rtti() == eRtti_Image ) + tag = root->ownerDocument().createElement( "picture" ); + else if( (*item)->rtti() == eRtti_Text ) + tag = root->ownerDocument().createElement( "textfield" ); + else if( (*item)->rtti() == eRtti_Rect ) + tag = root->ownerDocument().createElement( "rect" ); + else if( (*item)->rtti() == eRtti_Line ) + tag = root->ownerDocument().createElement( "line" ); +//NY32 + else if( (*item)->rtti() == eRtti_TextLine ) + tag = root->ownerDocument().createElement( "textlinefield" ); +//NY32 + + if( !tag.isNull() ) + { + (*item)->saveXML( &tag ); + root->appendChild( tag ); + } +} + +bool XMLUtils::readXMLDocumentItem( QDomElement* tag, DocumentItem** item, TokenProvider* token ) +{ + if( !item ) + return false; + + if( tag->tagName() == "barcode" ) + *item = new BarcodeItem(); + else if( tag->tagName() == "textfield" ) + *item = new TextItem(); + else if( tag->tagName() == "picture" ) + *item = new ImageItem(); + else if( tag->tagName() == "rect" ) + *item = new RectItem(); + else if( tag->tagName() == "line" ) + *item = new LineItem(); + else if( tag->tagName() == "textlinefield" ) + *item = new TextLineItem(); + else + return false; + + (*item)->setTokenProvider( token ); + (*item)->loadXML( tag ); + return true; +} + +void XMLUtils::writeXMLColor( QDomElement* tag, const QString & prefix, QColor c ) const +{ + tag->setAttribute( prefix + "r", c.red() ); + tag->setAttribute( prefix + "g", c.green() ); + tag->setAttribute( prefix + "b", c.blue() ); +} + +QColor XMLUtils::readXMLColor( QDomElement* tag, const QString & prefix, QColor c ) +{ + int r = c.red(); + int g = c.green(); + int b = c.blue(); + + r = tag->attribute( prefix + "r", QString("%1").arg( r ) ).toInt(); + g = tag->attribute( prefix + "g", QString("%1").arg( g ) ).toInt(); + b = tag->attribute( prefix + "b", QString("%1").arg( b ) ).toInt(); + + return QColor( r, g, b); +} + +/* +void XMLUtils::writeXMLRect( QDomElement* tag, QRect r, QPoint ptOrigin ) const +{ + r.moveBy( -ptOrigin.x(), -ptOrigin.y() ); + + tag->setAttribute( "x", r.x() ); + tag->setAttribute( "y", r.y() ); + tag->setAttribute( "width", r.width() ); + tag->setAttribute( "height", r.height() ); + + LabelUtils l; + tag->setAttribute( "x_mm", l.pixelToMm( r.x(), KApplication::desktop(), LabelUtils::DpiX ) ); + tag->setAttribute( "y_mm", l.pixelToMm( r.y(), KApplication::desktop(), LabelUtils::DpiY ) ); + tag->setAttribute( "width_mm", l.pixelToMm( r.width(), KApplication::desktop(), LabelUtils::DpiX ) ); + tag->setAttribute( "height_mm", l.pixelToMm( r.height(), KApplication::desktop(), LabelUtils::DpiY ) ); +}*/ + +QRect XMLUtils::readXMLRect( QDomElement* tag ) +{ + QRect r; + int x = tag->attribute( "x", "0" ).toInt(); + int y = tag->attribute( "y", "0" ).toInt(); + + r.setX( x ); + r.setY( y ); + r.setWidth( tag->attribute( "width", "-1" ).toInt() ); + r.setHeight( tag->attribute( "height", "-1" ).toInt() ); + return r; +} + +void XMLUtils::writeDefinition( QDomElement* tag, Definition* d ) const +{ + tag->setAttribute("producer", d->getProducer()); + tag->setAttribute("type", d->getType()); + + tag->setAttribute("width", d->getMeasurements().widthMM()); + tag->setAttribute("height", d->getMeasurements().heightMM()); + tag->setAttribute("gap_left", d->getMeasurements().gapLeftMM()); + tag->setAttribute("gap_top", d->getMeasurements().gapTopMM()); + tag->setAttribute("gap_v", d->getMeasurements().gapVMM()); + tag->setAttribute("gap_h", d->getMeasurements().gapHMM()); + tag->setAttribute("num_v", d->getMeasurements().numV()); + tag->setAttribute("num_h", d->getMeasurements().numH()); +} + +Definition* XMLUtils::readDefinition( QDomElement* tag ) +{ + int label_def_id = tag->text().toInt(); + QString producer = tag->attribute("producer", "" ); + QString type = tag->attribute("type", "" ); + + // The label was written by KBarcode <= 1.2.0 + Definition* d = new Definition( label_def_id ); + if( type.isEmpty() && producer.isEmpty() ) { + KMessageBox::information( NULL, + i18n("<qt>This appears file appears to be created by an older version of KBarcode.<br>" + "Please check if the used label definition is correct:<br>" + "<b>") + d->getProducer() + " " + d->getType() + "</b><br>" + "You can change the label definition at <i>Edit->Change Label...</i></qt>"); + + return d; + } + + if( d->getType() == type && d->getProducer() == producer && !type.isEmpty() && !producer.isEmpty() ) + return d; + + // The id does not match the correct type and producer, + // try to find the correct one + if( (d->getType() != type || d->getProducer() != producer) && + !(type.isEmpty() && producer.isEmpty() ) ) { + + int id = label_def_id; + QStringList p = Definition::getProducers(); + if( !p.contains( producer ) ) { + for( unsigned int i = 0; i < p.count(); i++ ) { + id = Definition::getClosest( p[i], type ); + if( id >= 0 ) + break; + } + } else + id = Definition::getClosest( producer, type ); + + if( id != label_def_id && id >= 0 ) { + d->setId( id ); + return d; + } + } + + // Everything failed + // Read the measurements from the file + Measurements m; + m.setWidthMM( tag->attribute("width", I2S( m.widthMM() ) ).toDouble() ); + m.setHeightMM( tag->attribute("height", I2S( m.heightMM() )).toDouble() ); + m.setGapLeftMM( tag->attribute("gap_left", I2S( m.gapLeftMM() )).toDouble() ); + m.setGapTopMM( tag->attribute("gap_top", I2S( m.gapTopMM() )).toDouble() ); + m.setGapVMM( tag->attribute("gap_v", I2S( m.gapVMM() )).toDouble() ); + m.setGapHMM( tag->attribute("gap_h", I2S( m.gapHMM() )).toDouble() ); + m.setNumV( tag->attribute("num_v", I2S( m.numH() )).toInt() ); + m.setNumH( tag->attribute("num_h", I2S( m.numV() )).toInt() ); + + qDebug("Definition not found: writing to file!"); + d->setId( Definition::write( m, type, producer ) ); + + return d; +} + +void XMLUtils::writeBarcode( QDomElement* tag, const Barkode* data, bool cache ) const +{ + if( !cache ) { + /* + * This values are not needed for the barcode cache. + */ + tag->setAttribute( "margin", data->quietZone() ); + tag->setAttribute( "rotation", data->rotation() ); + tag->setAttribute( "cut", data->cut() ); + tag->setAttribute( "caption", data->databaseMode() ); + + /* + * This values are only needed for !cache and for sequences + */ + tag->setAttribute( "sequenceenabled", data->sequenceEnabled() ); + /* + if( data->sequenceEnabled() ) { + tag->setAttribute( "sequencemode", data->sequence.mode ); + tag->setAttribute( "sequencestep", data->sequence.step ); + tag->setAttribute( "sequencestart", data->sequence.start ); + } + */ + } + + tag->setAttribute( "type", data->type() ); + tag->setAttribute( "text", data->textVisible() ); + tag->setAttribute( "scale", data->scaling()*1000 ); + + /* + if( BarCode::hasFeature( data->type, PDF417BARCODE ) ) { + tag->setAttribute( "pdf417.row", data->pdf417.row ); + tag->setAttribute( "pdf417.col", data->pdf417.col ); + tag->setAttribute( "pdf417.err", data->pdf417.err ); + } + + if( BarCode::hasFeature( data->type, DATAMATRIX ) ) + tag->setAttribute( "datamatrix.size", data->datamatrix.size ); + + if( BarCode::hasFeature( data->type, TBARCODE ) ) { + tag->setAttribute( "tbarcode.modulewidth", data->tbarcode.modulewidth ); + tag->setAttribute( "tbarcode.escape", data->tbarcode.escape ); + tag->setAttribute( "tbarcode.above", data->tbarcode.above ); + tag->setAttribute( "tbarcode.autocorrect", data->tbarcode.autocorrect ); + tag->setAttribute( "tbarcode.checksum", data->tbarcode.checksum ); + } + */ + + QDomElement texttag = tag->ownerDocument().createElement( "value" ); + texttag.appendChild( tag->ownerDocument().createTextNode( data->value() ) ); + + tag->appendChild( texttag ); +} + +void XMLUtils::readBarcode( QDomElement* tag, Barkode* bcode ) +{ + if( tag->tagName() == "barcode" ) { + bcode->setQuietZone( tag->attribute("margin", "10" ).toInt() ); + bcode->setRotation( tag->attribute("rotation", "0" ).toInt() ); + bcode->setScaling( tag->attribute("scale", "1000" ).toDouble() / 1000 ); + bcode->setCut( tag->attribute("cut", "1.0" ).toDouble() ); + bcode->setType( tag->attribute("type", "code39" ) ); + + /* + * check for encoding types saved by kbarcode <= 1.2.0 + */ + if( legacy.contains( bcode->type() ) ) + bcode->setType( legacy[bcode->type()] ); + + bcode->setTextVisible( tag->attribute("text", "0" ).toInt() ); + bcode->setDatabaseMode( tag->attribute("caption", "static" ) ); + + if( bcode->engine()->options() ) + bcode->engine()->options()->load( tag ); + + bcode->setDatamatrixSize( tag->attribute( "datamatrix.size", "0" ).toInt() ); + + bcode->setSequenceEnabled( tag->attribute( "sequenceenabled", "0" ).toInt() ); + if( bcode->sequenceEnabled() ) + { + bcode->setSequenceMode( (ESequence)tag->attribute( "sequencemode", "0" ).toInt() ); + bcode->setSequenceStep( tag->attribute( "sequencestep", "1" ).toInt() ); + bcode->setSequenceStart( tag->attribute( "sequencestart", "0" ).toInt() ); + } + + QDomNode n = tag->firstChild(); + while( !n.isNull() ) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if( !e.isNull() ) + if( e.tagName() == "value" ) + bcode->setValue( e.text() ); + + n = n.nextSibling(); + } + } +} diff --git a/kbarcode/xmlutils.h b/kbarcode/xmlutils.h new file mode 100644 index 0000000..3cd6b5c --- /dev/null +++ b/kbarcode/xmlutils.h @@ -0,0 +1,72 @@ +/*************************************************************************** + xmlutils.h - description + ------------------- + begin : Mit Mai 7 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef XMLUTILS_H +#define XMLUTILS_H + +#include <qmap.h> +#include <qsortedlist.h> + +class DocumentItem; +class BarcodeItem; +class Barkode; +class Definition; +class TokenProvider; +class MyCanvasView; +class QColor; +class QDomDocument; +class QDomElement; +class QDomNode; +class QRect; +class QString; +class QWidget; +typedef QSortedList<DocumentItem> DocumentItemList; + +/** This class provides helper function for saving and reading to XML files. + * + * @author Dominik Seichter + */ +class XMLUtils { + public: + XMLUtils(); + ~XMLUtils(); + + void readXMLHeader( QDomDocument* doc, QString & description, bool & kbarcode18, Definition** def ); + void writeXMLHeader( QDomNode* root, const QString & description, Definition* def ); + + void readDocumentItems( DocumentItemList* list, QDomDocument* doc, TokenProvider* token, bool kbarcode18 ); + + void writeXMLDocumentItem( QDomElement* root, DocumentItem** item ); + bool readXMLDocumentItem( QDomElement* tag, DocumentItem** item, TokenProvider* token ); + + void writeXMLColor( QDomElement* tag, const QString & prefix, QColor c ) const; + QColor readXMLColor( QDomElement* tag, const QString & prefix, QColor c ); + + //void writeXMLRect( QDomElement* tag, QRect r, QPoint ptOrigin ) const; + QRect readXMLRect( QDomElement* tag ); + + void writeDefinition( QDomElement* tag, Definition* d ) const; + Definition* readDefinition( QDomElement* tag ); + + void writeBarcode( QDomElement* tag, const Barkode* data, bool cache = false ) const; + void readBarcode( QDomElement* tag, Barkode* bcode ); + + private: + static QMap<QString,QString> legacy; +}; + +#endif diff --git a/kbarcode/zplutils.cpp b/kbarcode/zplutils.cpp new file mode 100644 index 0000000..d2a8e5d --- /dev/null +++ b/kbarcode/zplutils.cpp @@ -0,0 +1,445 @@ +/*************************************************************************** + zplutils.cpp - description + ------------------- + begin : Son Okt 12 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "zplutils.h" + +// Qt includes +#include <qbuffer.h> +#include <qcstring.h> +#include <qimage.h> +#include <qpaintdevicemetrics.h> +#include <qregexp.h> +#include <qstring.h> +#include <qtextstream.h> + +// font table for IPL, thanks to Erich Kitzmueller +struct { int size; int c; int h; int w; } iplfonttable[] = { + { 4, 7, 1, 1 }, + { 5, 0, 1, 1 }, + { 6, 1, 1, 1 }, + { 7, 2, 1, 1 }, + { 8, 20, 1, 1 }, + { 10, 24, 1, 1 }, + { 11, 23, 1, 1 }, + { 12, 21, 1, 1 }, + { 14, 2, 2, 2 }, + { 16, 20, 2, 2 }, + { 19, 22, 1, 1 } +}; + +BarcodePrinterDevice::BarcodePrinterDevice( double dpix, double dpiy ) + : QPaintDevice( 0 ) +{ + m_resolution_x = dpix; + m_resolution_y = dpiy; +} + +int BarcodePrinterDevice::metric( int e ) const +{ + int val = 0; + switch ( e ) { + case QPaintDeviceMetrics::PdmPhysicalDpiX: + val = (int)m_resolution_y; + break; + case QPaintDeviceMetrics::PdmPhysicalDpiY: + val = (int)m_resolution_x; + break; + case QPaintDeviceMetrics::PdmDpiX: + val = (int)m_resolution_x; + break; + case QPaintDeviceMetrics::PdmDpiY: + val = (int)m_resolution_y; + break; + + case QPaintDeviceMetrics::PdmNumColors: + val = 2; // black and white + break; + case QPaintDeviceMetrics::PdmDepth: + val = 1; // black and white + break; + + case QPaintDeviceMetrics::PdmWidth: + case QPaintDeviceMetrics::PdmHeight: + case QPaintDeviceMetrics::PdmWidthMM: + case QPaintDeviceMetrics::PdmHeightMM: + default: + break; + } + + return val; +} + +QMap<QString,QString> ZPLUtils::encodings; + +QString ZPLUtils::footer() +{ + return "^XZ\n"; +} + +QString ZPLUtils::header() +{ + QString zpl = QString::null; + + zpl += "^FXLabel created by KBarcode www.kbarcode.net\n"; + zpl += "^XA\n"; // Label start + zpl += "^JMA\n"; // set printer to 304dpi + zpl += "^LH0,0\n"; // set label origin to 0, 0 + + return zpl; +} + +QString ZPLUtils::encoding( const QString & encoding ) +{ + if( !encodings.count() ) + fillEncodings(); + + return encodings[encoding]; +} + +QString ZPLUtils::fieldData( const QString & data ) +{ + QString zpl = QString::null; + + zpl += "^FD" + data + "^FS\n"; // field data + + return zpl; +} + +QString ZPLUtils::fieldOrigin( int x, int y ) +{ + QString zpl = QString::null; + + zpl = QString("^FO%1,%2\n").arg( x ).arg( y ); // field origin + + return zpl; +} + +QString ZPLUtils::font( const QFont & ) +{ + QString zpl = QString::null; + QString fontname = "D"; + // valid fonts: + // A - H, GS + /* + if( font.isNull() ) + font = "D"; + else + // Do some parsing + ; // empty else!!!! + */ + + zpl += "^A" + fontname + "\n"; // select font + + return zpl; +} + +void ZPLUtils::fillEncodings() +{ + encodings.insert( "b1", "1" ); // Code11 + encodings.insert( "b2", "2" ); // Interlieved 2 of 5 + encodings.insert( "i25", "2" ); // Interlieved 2 of 5 + encodings.insert( "i25 -c", "2" ); // Interlieved 2 of 5 no checksum + encodings.insert( "code39", "3" ); // code39 + encodings.insert( "code39 -c", "3" ); // code39 no checksum + encodings.insert( "b8", "3" ); // code39 + encodings.insert( "b9", "3" ); // code39 + encodings.insert( "pdf417", "7" ); // PDF417 + encodings.insert( "b55", "7" ); // PDF417 + encodings.insert( "b10", "8" ); // EAN8 + encodings.insert( "b11", "8" ); // EAN8 + encodings.insert( "b12", "8" ); // EAN8 + encodings.insert( "ean", "8" ); // EAN8 + encodings.insert( "b37", "9" ); // UPC-E + encodings.insert( "b38", "9" ); // UPC-E + encodings.insert( "b39", "9" ); // UPC-E + encodings.insert( "upc", "9" ); // UPC-E + encodings.insert( "code93", "A" ); // Code 93 + encodings.insert( "b25", "A" ); // Code 93 + encodings.insert( "code128", "C" ); // Code 128 + encodings.insert( "code128b", "C" ); // Code 128 + encodings.insert( "code128c", "C" ); // Code 128 + encodings.insert( "b20", "C" ); // Code 128 + encodings.insert( "b59", "C" ); // Code 128 + encodings.insert( "b60", "C" ); // Code 128 + encodings.insert( "b61", "C" ); // Code 128 + encodings.insert( "b57", "D" ); // Maxicode + encodings.insert( "ean", "E" ); // EAN 13 + encodings.insert( "isbn", "E" ); // EAN 13 + encodings.insert( "b13", "E" ); // EAN 13 + encodings.insert( "b14", "E" ); // EAN 13 + encodings.insert( "b15", "E" ); // EAN 13 + encodings.insert( "b56", "F" ); // micro PDF417 + encodings.insert( "b2", "JF" ); // 2 of 5 Standard + encodings.insert( "cbr", "K" ); // codabar + encodings.insert( "b18", "K" ); // codabar + encodings.insert( "b19", "K" ); // codabar + encodings.insert( "b50", "L" ); // LOGMARS + encodings.insert( "msi", "M" ); // MSI + encodings.insert( "b47", "M" ); // MSI + encodings.insert( "pls", "P" ); // Plessey + encodings.insert( "b46", "P" ); // Plessey + encodings.insert( "b58", "Q" ); // QR Code + encodings.insert( "upc", "U" ); // UPC A + encodings.insert( "b34", "U" ); // UPC A + encodings.insert( "b35", "U" ); // UPC A + encodings.insert( "b36", "U" ); // UPC A + encodings.insert( "b71", "X" ); // Datamatrix + encodings.insert( "b40", "Z" ); // Postnet + encodings.insert( "b41", "Z" ); // Postnet + encodings.insert( "b42", "Z" ); // Postnet + encodings.insert( "b43", "Z" ); // Postnet + encodings.insert( "b44", "Z" ); // Postnet + encodings.insert( "b45", "Z" ); // Postnet +} + +/***************************************************************************/ + +IPLUtils::IPLUtils() +{ + m_counter = 0; +} + +QMap<QString,QString> IPLUtils::encodings; + +void IPLUtils::addValue( const QString & v ) +{ + m_values.append( v ); +} + +int IPLUtils::counter() +{ + return m_counter++; +} + +QString IPLUtils::encoding( const QString & type ) +{ + if( !encodings.count() ) + fillEncodings(); + + return encodings[type]; +} + +QString IPLUtils::field( const QString & data ) +{ + QString ipl = "<STX>"; + ipl += data; + ipl += "<ETX>\n"; + return ipl; +} + +QString IPLUtils::fieldOrigin( int x, int y ) +{ + return QString("o%1,%2;f0;").arg( x ).arg( y ); // field origin +} + +QString IPLUtils::footer() +{ + QString ipl = QString::null; + + // set the printer to print mode + ipl += field( "R" ); + // start with actual data + ipl += field( "<ESC>E3<CAN>" ); // choose format number 3 + + for( unsigned int i = 0; i < m_values.count(); i++ ) + ipl += field( m_values[i] + ( i != m_values.count() - 1 ? "<CR>" : QString::null ) ); + + // end actual data + ipl += field( "<ETB>" ); + + return ipl; +} + +QString IPLUtils::header() +{ + QString ipl = QString::null; + + // start form definition: + // --- + // set the printer into propram mode + ipl += field( "<ESC>P" ); + // set darkness to 0 (range -10 to 10) + ipl += field( "<SI>d0" ); + // set print speed + ipl += field( "<SI>S20" ); + // erase format 3, create format 3 + // a Intermec printer can store several "formats" (form definitions), we choose abitrarely number 3 + ipl += field( "E3;F3;" ); + + return ipl; +} + +void IPLUtils::fillEncodings() +{ + encodings.insert( "code39", "0" ); // code39 + encodings.insert( "code39 -c", "0" ); // code39 no checksum + encodings.insert( "b8", "0" ); // code39 + encodings.insert( "b9", "0" ); // code39 + encodings.insert( "code93", "1" ); // Code 93 + encodings.insert( "b25", "1" ); // Code 93 + encodings.insert( "b2", "2" ); // Interlieved 2 of 5 + encodings.insert( "i25", "2" ); // Interlieved 2 of 5 + encodings.insert( "i25 -c", "2" ); // Interlieved 2 of 5 no checksum + encodings.insert( "b2", "3" ); // 2 of 5 Standard + encodings.insert( "cbr", "4" ); // codabar + encodings.insert( "b18", "4" ); // codabar + encodings.insert( "b19", "4" ); // codabar + encodings.insert( "b1", "5" ); // Code11 + encodings.insert( "code128", "6" ); // Code 128 + encodings.insert( "code128b", "6" ); // Code 128 + encodings.insert( "code128c", "6" ); // Code 128 + encodings.insert( "b20", "6" ); // Code 128 + encodings.insert( "b59", "6" ); // Code 128 + encodings.insert( "b60", "6" ); // Code 128 + encodings.insert( "b61", "6" ); // Code 128 + encodings.insert( "b10", "7" ); // EAN8 + encodings.insert( "b11", "7" ); // EAN8 + encodings.insert( "b12", "7" ); // EAN8 + encodings.insert( "ean", "7" ); // EAN8 + encodings.insert( "b37", "7" ); // UPC-E + encodings.insert( "b38", "7" ); // UPC-E + encodings.insert( "b39", "7" ); // UPC-E + encodings.insert( "upc", "7" ); // UPC-E + encodings.insert( "ean", "7" ); // EAN 13 + encodings.insert( "isbn", "7" ); // EAN 13 + encodings.insert( "b13", "7" ); // EAN 13 + encodings.insert( "b14", "7" ); // EAN 13 + encodings.insert( "b15", "7" ); // EAN 13 + encodings.insert( "upc", "7" ); // UPC A + encodings.insert( "b34", "7" ); // UPC A + encodings.insert( "b35", "7" ); // UPC A + encodings.insert( "b36", "7" ); // UPC A + encodings.insert( "b40", "10" ); // Postnet + encodings.insert( "b41", "10" ); // Postnet + encodings.insert( "b42", "10" ); // Postnet + encodings.insert( "b43", "10" ); // Postnet + encodings.insert( "b44", "10" ); // Postnet + encodings.insert( "b45", "10" ); // Postnet + encodings.insert( "pdf417", "12" ); // PDF417 + encodings.insert( "b55", "12" ); // PDF417 + encodings.insert( "b57", "14" ); // Maxicode + encodings.insert( "b71", "17" ); // Datamatrix + encodings.insert( "b58", "18" ); // QR Code + encodings.insert( "b56", "19" ); // micro PDF417 +} + +/***************************************************************************/ + +QMap<QString,QString> EPCLUtils::encodings; + +QString EPCLUtils::footer() +{ + QString pcl = QString::null; + + // print color buffers + pcl += EPCLUtils::field( "IS 0" ); // Yellow + pcl += EPCLUtils::field( "IS 1" ); // Magenta + pcl += EPCLUtils::field( "IS 2" ); // Cyan + // print black resin buffer + pcl += EPCLUtils::field( "I 10" ); + // print varnish and eject card + pcl += EPCLUtils::field( "IV" ); + + return pcl; +} + +QString EPCLUtils::header() +{ + QString pcl = QString::null; + + // start form definition: + // --- + // Clear monochrome buffer + pcl += EPCLUtils::field( "F" ); + // Clear varnish buffer + pcl += EPCLUtils::field( "vF" ); + // Clear color buffers + pcl += EPCLUtils::field( "$F" ); + // Make sure everything is positioned + pcl += EPCLUtils::field( "+EC 0" ); + + return pcl; +} + +QString EPCLUtils::field( const QString & data ) +{ + QString pcl = "\033" + data + "\r\n"; + return pcl; +} + +QString EPCLUtils::encoding( const QString & type ) +{ + if( !encodings.count() ) + fillEncodings(); + + return encodings[type]; +} + +void EPCLUtils::fillEncodings() +{ + encodings.insert( "code39", "0" ); // code39 +// encodings.insert( "code39 -c", "0" ); // code39 no checksum + encodings.insert( "b8", "0" ); // code39 + encodings.insert( "b9", "0" ); // code39 +// encodings.insert( "code93", "1" ); // Code 93 +// encodings.insert( "b25", "1" ); // Code 93 + encodings.insert( "b2", "1" ); // Interlieved 2 of 5 + encodings.insert( "i25", "1" ); // Interlieved 2 of 5 +// encodings.insert( "i25 -c", "2" ); // Interlieved 2 of 5 no checksum + encodings.insert( "b2", "2" ); // 2 of 5 Standard +// encodings.insert( "cbr", "4" ); // codabar +// encodings.insert( "b18", "4" ); // codabar +// encodings.insert( "b19", "4" ); // codabar +// encodings.insert( "b1", "5" ); // Code11 + encodings.insert( "code128", "108" ); // Code 128 + encodings.insert( "code128b", "108" ); // Code 128 + encodings.insert( "code128c", "107" ); // Code 128 +// encodings.insert( "b20", "6" ); // Code 128 +// encodings.insert( "b59", "6" ); // Code 128 +// encodings.insert( "b60", "6" ); // Code 128 +// encodings.insert( "b61", "6" ); // Code 128 + encodings.insert( "b10", "3" ); // EAN8 + encodings.insert( "b11", "3" ); // EAN8 + encodings.insert( "b12", "3" ); // EAN8 + encodings.insert( "ean", "3" ); // EAN8 +// encodings.insert( "b37", "7" ); // UPC-E +// encodings.insert( "b38", "7" ); // UPC-E +// encodings.insert( "b39", "7" ); // UPC-E +// encodings.insert( "upc", "7" ); // UPC-E + encodings.insert( "ean", "4" ); // EAN 13 + encodings.insert( "isbn", "4" ); // EAN 13 + encodings.insert( "b13", "4" ); // EAN 13 + encodings.insert( "b14", "4" ); // EAN 13 + encodings.insert( "b15", "4" ); // EAN 13 + encodings.insert( "upc", "5" ); // UPC A + encodings.insert( "b34", "5" ); // UPC A + encodings.insert( "b35", "5" ); // UPC A + encodings.insert( "b36", "5" ); // UPC A +// encodings.insert( "b40", "10" ); // Postnet +// encodings.insert( "b41", "10" ); // Postnet +// encodings.insert( "b42", "10" ); // Postnet +// encodings.insert( "b43", "10" ); // Postnet +// encodings.insert( "b44", "10" ); // Postnet +// encodings.insert( "b45", "10" ); // Postnet +// encodings.insert( "pdf417", "12" ); // PDF417 +// encodings.insert( "b55", "12" ); // PDF417 +// encodings.insert( "b57", "14" ); // Maxicode +// encodings.insert( "b71", "17" ); // Datamatrix +// encodings.insert( "b58", "18" ); // QR Code +// encodings.insert( "b56", "19" ); // micro PDF417 +} + diff --git a/kbarcode/zplutils.h b/kbarcode/zplutils.h new file mode 100644 index 0000000..14365bb --- /dev/null +++ b/kbarcode/zplutils.h @@ -0,0 +1,137 @@ +/*************************************************************************** + zplutils.h - description + ------------------- + begin : Son Okt 12 2003 + copyright : (C) 2003 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef ZPLUTILS_H +#define ZPLUTILS_H + +#include <qpaintdevice.h> +#include <qstring.h> +#include <qstringlist.h> +#include <qmap.h> + +class QColor; +class QFont; +class QImage; +class QSize; +class QTextStream; + +class BarcodePrinterDevice : public QPaintDevice { + public: + BarcodePrinterDevice( double dpix, double dpiy ); + + bool isExtDev() const { return true; } + bool paintingActive() const { return false; } + + virtual int metric( int e ) const; + + private: + double m_resolution_x; + double m_resolution_y; +}; + +/** + * This class provides functions + * to convert KBarcode label data + * into Zebra Printer Language. + * + *@author Dominik Seichter + */ +class ZPLUtils { + public: + static QString footer(); + static QString header(); + + static QString encoding( const QString & encoding ); + static QString fieldData( const QString & data ); + static QString fieldOrigin( int x, int y ); + static QString font( const QFont & font ); + + private: + static void fillEncodings(); + + protected: + static QMap<QString,QString> encodings; +}; + +/** + * This class provides functions + * to convert KBarcode label data + * into Intermec printer language. + * + * Thanks to Erich Kitzmller for providing + * me with information and an examplefor this stuff. + *@author Dominik Seichter + */ +class IPLUtils { + public: + IPLUtils(); + + void addValue( const QString & v ); + int counter(); + + QString encoding( const QString & type ); + QString footer(); + QString header(); + + QString field( const QString & data ); + QString fieldOrigin( int x, int y ); + + private: + int m_counter; + QStringList m_values; + static QMap<QString,QString> encodings; + + /** fill the map to match kbarcode encoding types with IPL types */ + void fillEncodings(); +}; + +/** + * This class provides functions + * to convert KBarcode label data + * into Eltron printer control language (EPCL). + * + *@author Brian Glass + */ +#define EPCLWidth 646 +#define EPCLHeight 1030 + +class EPCLUtils { + public: + static QString encoding( const QString & type ); + static QString footer(); + static QString header(); + + static QString field( const QString & data ); + + + EPCLUtils( QTextStream* stream, QPaintDevice* source ); + + void setTextField( int x, int y, int width, int height, const QString & text ); + void setBarcode( int x, int y, int h, const QString & value, const QString & type ); + void setRect( int x, int y, const QSize size, bool circle, int width ); + void setImage( int x, int y, const QImage* image ); + void close(); + + private: + static void fillEncodings(); + static QMap<QString,QString> encodings; + + inline void setField( const QString & data ); + void fillImageBuffer( void ); +}; + +#endif |