wok view inkscape/stuff/patches/0001-Fix_Datamatrix_UI_issue.patch @ rev 17707

Up marlin: edit last patch (again)
author Yuri Pourre <yuripourre@gmail.com>
date Mon Mar 02 11:31:13 2015 -0300 (2015-03-02)
parents
children
line source
1 From: JazzyNico <nicoduf@yahoo.fr>
2 Date: Tue, 2 Jul 2013 10:47:34 +0200
3 Subject: Fix_Datamatrix_UI_issue
5 Prevent invalid input in Datamatrix extension dialog.
7 As reference:
8 - Origin: upstream, https://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/10127
9 - Bug: https://launchpad.net/bugs/738108
10 - Bug-Debian: http://bugs.debian.org/618835
11 - Bug-Ubuntu: https://launchpad.net/bugs/738108
12 - Last-Update: 2011-06-02
14 Signed-off-by: Matteo F. Vescovi <mfv.debian@gmail.com>
15 ---
16 share/extensions/render_barcode_datamatrix.inx | 38 +++++++++++++++++---
17 share/extensions/render_barcode_datamatrix.py | 49 ++++++++++++++++++++++++--
18 2 files changed, 80 insertions(+), 7 deletions(-)
20 diff --git a/share/extensions/render_barcode_datamatrix.inx b/share/extensions/render_barcode_datamatrix.inx
21 index ea2aa47..ede179e 100644
22 --- a/share/extensions/render_barcode_datamatrix.inx
23 +++ b/share/extensions/render_barcode_datamatrix.inx
24 @@ -4,10 +4,40 @@
25 <id>il.datamatrix</id>
26 <dependency type="executable" location="extensions">render_barcode_datamatrix.py</dependency>
27 <dependency type="executable" location="extensions">inkex.py</dependency>
28 - <param name="text" type="string" _gui-text="Text">Inkscape</param>
29 - <param name="rows" type="int" min="8" max="144" _gui-text="Rows">10</param>
30 - <param name="cols" type="int" min="10" max="144" _gui-text="Cols">10</param>
31 - <param name="size" type="int" min="1" max="1000" _gui-text="Square Size / px">4</param>
32 + <param name="text" type="string" _gui-text="Text:">Inkscape</param>
33 + <param name="symbol" _gui-text="Size, in unit squares:" type="enum">
34 + <item value="sq10">10x10</item>
35 + <item value="sq12">12x12</item>
36 + <item value="sq14">14x14</item>
37 + <item value="sq16">16x16</item>
38 + <item value="sq18">18x18</item>
39 + <item value="sq20">20x20</item>
40 + <item value="sq22">22x22</item>
41 + <item value="sq24">24x24</item>
42 + <item value="sq26">26x26</item>
43 + <item value="sq32">32x32</item>
44 + <item value="sq36">36x36</item>
45 + <item value="sq40">40x40</item>
46 + <item value="sq44">44x44</item>
47 + <item value="sq48">48x48</item>
48 + <item value="sq52">52x52</item>
49 + <item value="sq64">64x64</item>
50 + <item value="sq72">72x72</item>
51 + <item value="sq80">80x80</item>
52 + <item value="sq88">88x88</item>
53 + <item value="sq96">96x96</item>
54 + <item value="sq104">104x104</item>
55 + <item value="sq120">120x120</item>
56 + <item value="sq132">132x132</item>
57 + <item value="sq144">144x144</item>
58 + <item value="rect8x18">8x18</item>
59 + <item value="rect8x32">8x32</item>
60 + <item value="rect12x26">12x26</item>
61 + <item value="rect12x36">12x36</item>
62 + <item value="rect16x36">16x36</item>
63 + <item value="rect16x48">16x48</item>
64 + </param>
65 + <param name="size" type="int" min="1" max="1000" _gui-text="Square Size (px):">4</param>
66 <effect>
67 <object-type>all</object-type>
68 <effects-menu>
69 diff --git a/share/extensions/render_barcode_datamatrix.py b/share/extensions/render_barcode_datamatrix.py
70 index e536554..20bcf94 100755
71 --- a/share/extensions/render_barcode_datamatrix.py
72 +++ b/share/extensions/render_barcode_datamatrix.py
73 @@ -57,6 +57,39 @@ import inkex, simplestyle
74 import gettext
75 _ = gettext.gettext
77 +symbols = {
78 + 'sq10': (10, 10),
79 + 'sq12': (12, 12),
80 + 'sq14': (14, 14),
81 + 'sq16': (16, 16),
82 + 'sq18': (18, 18),
83 + 'sq20': (20, 20),
84 + 'sq22': (22, 22),
85 + 'sq24': (24, 24),
86 + 'sq26': (26, 26),
87 + 'sq32': (32, 32),
88 + 'sq36': (36, 36),
89 + 'sq40': (40, 40),
90 + 'sq44': (44, 44),
91 + 'sq48': (48, 48),
92 + 'sq52': (52, 52),
93 + 'sq64': (64, 64),
94 + 'sq72': (72, 72),
95 + 'sq80': (80, 80),
96 + 'sq88': (88, 88),
97 + 'sq96': (96, 96),
98 + 'sq104': (104, 104),
99 + 'sq120': (120, 120),
100 + 'sq132': (132, 132),
101 + 'sq144': (144, 144),
102 + 'rect8x18': (8, 18),
103 + 'rect8x32': (8, 32),
104 + 'rect12x26': (12, 26),
105 + 'rect12x36': (12, 36),
106 + 'rect16x36': (16, 36),
107 + 'rect16x48': (16, 48),
108 +}
109 +
110 #ENCODING ROUTINES ===================================================
111 # Take an input string and convert it to a sequence (or sequences)
112 # of codewords as specified in ISO/IEC 16022:2006 (section 5.2.3)
113 @@ -167,6 +200,7 @@ def get_parameters(nrow, ncol):
114 #RETURN ERROR
115 else:
116 inkex.errormsg(_('Unrecognised DataMatrix size'))
117 + exit(0)
119 return None
121 @@ -616,6 +650,9 @@ class DataMatrix(inkex.Effect):
122 self.OptionParser.add_option("--text",
123 action="store", type="string",
124 dest="TEXT", default='Inkscape')
125 + self.OptionParser.add_option("--symbol",
126 + action="store", type="string",
127 + dest="SYMBOL", default='')
128 self.OptionParser.add_option("--rows",
129 action="store", type="int",
130 dest="ROWS", default=10)
131 @@ -630,6 +667,12 @@ class DataMatrix(inkex.Effect):
133 so = self.options
135 + rows = so.ROWS
136 + cols = so.COLS
137 + if (so.SYMBOL != '' and (so.SYMBOL in symbols)):
138 + rows = symbols[so.SYMBOL][0]
139 + cols = symbols[so.SYMBOL][1]
140 +
141 if so.TEXT == '': #abort if converting blank text
142 inkex.errormsg(_('Please enter an input string'))
143 else:
144 @@ -644,11 +687,11 @@ class DataMatrix(inkex.Effect):
145 grp = inkex.etree.SubElement(self.current_layer, 'g', grp_attribs)#the group to put everything in
147 #GENERATE THE DATAMATRIX
148 - encoded = encode( so.TEXT, (so.ROWS, so.COLS) ) #get the pattern of squares
149 - render_data_matrix( encoded, so.SIZE, so.COLS*so.SIZE*1.5, grp ) # generate the SVG elements
150 + encoded = encode( so.TEXT, (rows, cols) ) #get the pattern of squares
151 + render_data_matrix( encoded, so.SIZE, cols*so.SIZE*1.5, grp ) # generate the SVG elements
153 if __name__ == '__main__':
154 e = DataMatrix()
155 e.affect()
157 -# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
158 +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99