summaryrefslogtreecommitdiffstats
path: root/share
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
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')
-rw-r--r--share/extensions/render_barcode_datamatrix.inx34
-rw-r--r--share/extensions/render_barcode_datamatrix.py47
2 files changed, 77 insertions, 4 deletions
diff --git a/share/extensions/render_barcode_datamatrix.inx b/share/extensions/render_barcode_datamatrix.inx
index 58699e4a9..ede179e24 100644
--- a/share/extensions/render_barcode_datamatrix.inx
+++ b/share/extensions/render_barcode_datamatrix.inx
@@ -5,8 +5,38 @@
<dependency type="executable" location="extensions">render_barcode_datamatrix.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="text" type="string" _gui-text="Text:">Inkscape</param>
- <param name="rows" type="int" min="8" max="144" _gui-text="Rows:">10</param>
- <param name="cols" type="int" min="10" max="144" _gui-text="Cols:">10</param>
+ <param name="symbol" _gui-text="Size, in unit squares:" type="enum">
+ <item value="sq10">10x10</item>
+ <item value="sq12">12x12</item>
+ <item value="sq14">14x14</item>
+ <item value="sq16">16x16</item>
+ <item value="sq18">18x18</item>
+ <item value="sq20">20x20</item>
+ <item value="sq22">22x22</item>
+ <item value="sq24">24x24</item>
+ <item value="sq26">26x26</item>
+ <item value="sq32">32x32</item>
+ <item value="sq36">36x36</item>
+ <item value="sq40">40x40</item>
+ <item value="sq44">44x44</item>
+ <item value="sq48">48x48</item>
+ <item value="sq52">52x52</item>
+ <item value="sq64">64x64</item>
+ <item value="sq72">72x72</item>
+ <item value="sq80">80x80</item>
+ <item value="sq88">88x88</item>
+ <item value="sq96">96x96</item>
+ <item value="sq104">104x104</item>
+ <item value="sq120">120x120</item>
+ <item value="sq132">132x132</item>
+ <item value="sq144">144x144</item>
+ <item value="rect8x18">8x18</item>
+ <item value="rect8x32">8x32</item>
+ <item value="rect12x26">12x26</item>
+ <item value="rect12x36">12x36</item>
+ <item value="rect16x36">16x36</item>
+ <item value="rect16x48">16x48</item>
+ </param>
<param name="size" type="int" min="1" max="1000" _gui-text="Square Size (px):">4</param>
<effect>
<object-type>all</object-type>
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()