summaryrefslogtreecommitdiffstats
path: root/share/extensions/render_barcode_datamatrix.py
diff options
context:
space:
mode:
authorNicolas Dufour <nicoduf@yahoo.fr>2011-03-24 19:16:18 +0000
committerJazzyNico <nicoduf@yahoo.fr>2011-03-24 19:16:18 +0000
commitf20053aaedf6a46b516a4b516000000aab4a2cfc (patch)
tree84946d4c9010d70cc3602e09d37d92bc068febae /share/extensions/render_barcode_datamatrix.py
parentDutch translation update (diff)
downloadinkscape-f20053aaedf6a46b516a4b516000000aab4a2cfc.tar.gz
inkscape-f20053aaedf6a46b516a4b516000000aab4a2cfc.zip
Extensions. Datamatrix barcode improvement (see Bug #738108, Inkscape UI can pass invalid values to Datamatrix extension).
Fixed bugs: - https://launchpad.net/bugs/738108 (bzr r10127)
Diffstat (limited to 'share/extensions/render_barcode_datamatrix.py')
-rw-r--r--share/extensions/render_barcode_datamatrix.py47
1 files changed, 45 insertions, 2 deletions
diff --git a/share/extensions/render_barcode_datamatrix.py b/share/extensions/render_barcode_datamatrix.py
index 785d7de56..20bcf94dc 100644
--- a/share/extensions/render_barcode_datamatrix.py
+++ b/share/extensions/render_barcode_datamatrix.py
@@ -57,6 +57,39 @@ import inkex, simplestyle
import gettext
_ = gettext.gettext
+symbols = {
+ 'sq10': (10, 10),
+ 'sq12': (12, 12),
+ 'sq14': (14, 14),
+ 'sq16': (16, 16),
+ 'sq18': (18, 18),
+ 'sq20': (20, 20),
+ 'sq22': (22, 22),
+ 'sq24': (24, 24),
+ 'sq26': (26, 26),
+ 'sq32': (32, 32),
+ 'sq36': (36, 36),
+ 'sq40': (40, 40),
+ 'sq44': (44, 44),
+ 'sq48': (48, 48),
+ 'sq52': (52, 52),
+ 'sq64': (64, 64),
+ 'sq72': (72, 72),
+ 'sq80': (80, 80),
+ 'sq88': (88, 88),
+ 'sq96': (96, 96),
+ 'sq104': (104, 104),
+ 'sq120': (120, 120),
+ 'sq132': (132, 132),
+ 'sq144': (144, 144),
+ 'rect8x18': (8, 18),
+ 'rect8x32': (8, 32),
+ 'rect12x26': (12, 26),
+ 'rect12x36': (12, 36),
+ 'rect16x36': (16, 36),
+ 'rect16x48': (16, 48),
+}
+
#ENCODING ROUTINES ===================================================
# Take an input string and convert it to a sequence (or sequences)
# of codewords as specified in ISO/IEC 16022:2006 (section 5.2.3)
@@ -167,6 +200,7 @@ def get_parameters(nrow, ncol):
#RETURN ERROR
else:
inkex.errormsg(_('Unrecognised DataMatrix size'))
+ exit(0)
return None
@@ -616,6 +650,9 @@ class DataMatrix(inkex.Effect):
self.OptionParser.add_option("--text",
action="store", type="string",
dest="TEXT", default='Inkscape')
+ self.OptionParser.add_option("--symbol",
+ action="store", type="string",
+ dest="SYMBOL", default='')
self.OptionParser.add_option("--rows",
action="store", type="int",
dest="ROWS", default=10)
@@ -630,6 +667,12 @@ class DataMatrix(inkex.Effect):
so = self.options
+ rows = so.ROWS
+ cols = so.COLS
+ if (so.SYMBOL != '' and (so.SYMBOL in symbols)):
+ rows = symbols[so.SYMBOL][0]
+ cols = symbols[so.SYMBOL][1]
+
if so.TEXT == '': #abort if converting blank text
inkex.errormsg(_('Please enter an input string'))
else:
@@ -644,8 +687,8 @@ class DataMatrix(inkex.Effect):
grp = inkex.etree.SubElement(self.current_layer, 'g', grp_attribs)#the group to put everything in
#GENERATE THE DATAMATRIX
- encoded = encode( so.TEXT, (so.ROWS, so.COLS) ) #get the pattern of squares
- render_data_matrix( encoded, so.SIZE, so.COLS*so.SIZE*1.5, grp ) # generate the SVG elements
+ encoded = encode( so.TEXT, (rows, cols) ) #get the pattern of squares
+ render_data_matrix( encoded, so.SIZE, cols*so.SIZE*1.5, grp ) # generate the SVG elements
if __name__ == '__main__':
e = DataMatrix()