diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-10-26 12:27:05 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2013-10-26 12:27:05 +0000 |
| commit | 9b2d4924cf0f30df461236c7850c8e38480d8ad3 (patch) | |
| tree | 560ebd4e32dc9c9645287e8f5a8470bde91d7817 | |
| parent | Update to trunk (diff) | |
| parent | Fix memleak in reference counting introduced in r12532. (diff) | |
| download | inkscape-9b2d4924cf0f30df461236c7850c8e38480d8ad3.tar.gz inkscape-9b2d4924cf0f30df461236c7850c8e38480d8ad3.zip | |
Update to trunk
(bzr r11950.1.189)
49 files changed, 234 insertions, 161 deletions
@@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: Inkscape\n" "Report-Msgid-Bugs-To: inkscape-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-10-09 21:08+0200\n" -"PO-Revision-Date: 2013-10-21 16:24+0300\n" +"PO-Revision-Date: 2013-10-22 22:49+0300\n" "Last-Translator: Jānis Eisaks <jancs@dv.lv>\n" "Language-Team: Latvian\n" "Language: lv\n" @@ -29,7 +29,7 @@ msgstr "Vektoru grafikas redaktors" #: ../inkscape.desktop.in.h:3 msgid "Inkscape Vector Graphics Editor" -msgstr "Inkscape vektoru grafikas redaktors" +msgstr "Vektoru grafikas redaktors Inkscape" #: ../inkscape.desktop.in.h:4 msgid "Create and edit Scalable Vector Graphics images" @@ -52,7 +52,7 @@ msgstr "Slīpumi" #: ../share/filters/filters.svg.h:1 msgid "Same as Matte jelly but with more controls" -msgstr "Līdzīgs matētai želejai, tikai vairāk parametriem" +msgstr "Līdzīgs matētai želejai, tikai ar vairāk parametriem" #: ../share/filters/filters.svg.h:1 msgid "Metal Casting" @@ -19244,6 +19244,8 @@ msgstr "Reti pikseļi (_reizinātājs)" msgid "Favors connections that are part of foreground color" msgstr "Dod priekšroku savienojumiem, kas ir priekšplāna krāsas daļa" +# clarification: +# 'heuristic' vote: voters base their decisions on their feelings towards those promoting a Yes or a No vote, rather than on the issue itself. #: ../src/ui/dialog/pixelartdialog.cpp:218 msgid "The heuristic computed vote will be multiplied by this value" msgstr "" diff --git a/share/extensions/dots.py b/share/extensions/dots.py index 7b88dd1b1..33ead21e7 100755 --- a/share/extensions/dots.py +++ b/share/extensions/dots.py @@ -69,8 +69,8 @@ class Dots(inkex.Effect): y = dy/dist if x1 > x2: x *= -1 if y1 > y2: y *= -1 - p[lastDot][1][-2] += x * inkex.unittouu(self.options.dotsize) - p[lastDot][1][-1] += y * inkex.unittouu(self.options.dotsize) + p[lastDot][1][-2] += x * self.unittouu(self.options.dotsize) + p[lastDot][1][-1] += y * self.unittouu(self.options.dotsize) def addDot(self, node): self.group = inkex.etree.SubElement( node.getparent(), inkex.addNS('g','svg') ) @@ -94,7 +94,7 @@ class Dots(inkex.Effect): if cmd != 'Z' and cmd != 'z': dot_att = { 'style': style, - 'r': str( inkex.unittouu(self.options.dotsize) / 2 ), + 'r': str( self.unittouu(self.options.dotsize) / 2 ), 'cx': str( params[-2] ), 'cy': str( params[-1] ) } @@ -104,8 +104,8 @@ class Dots(inkex.Effect): dot_att ) self.addText( self.numGroup, - params[-2] + ( inkex.unittouu(self.options.dotsize) / 2 ), - params[-1] - ( inkex.unittouu(self.options.dotsize) / 2 ), + params[-2] + ( self.unittouu(self.options.dotsize) / 2 ), + params[-1] - ( self.unittouu(self.options.dotsize) / 2 ), num ) num += self.options.step node.getparent().remove( node ) diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py index c5217f886..f5cf37aff 100755 --- a/share/extensions/dxf_outlines.py +++ b/share/extensions/dxf_outlines.py @@ -325,7 +325,7 @@ class MyEffect(inkex.Effect): scale = eval(self.options.units) if not scale: scale = 25.4/90 # if no scale is specified, assume inch as baseunit - h = inkex.unittouu(self.document.getroot().xpath('@height', namespaces=inkex.NSS)[0]) + h = self.unittouu(self.document.getroot().xpath('@height', namespaces=inkex.NSS)[0]) self.groupmat = [[[scale, 0.0, 0.0], [0.0, -scale, h*scale]]] doc = self.document.getroot() self.process_group(doc) diff --git a/share/extensions/eqtexsvg.py b/share/extensions/eqtexsvg.py index a6000dc6d..99d3c0660 100755 --- a/share/extensions/eqtexsvg.py +++ b/share/extensions/eqtexsvg.py @@ -55,8 +55,8 @@ def create_equation_tex(filename, equation, add_header=""): tex.close() def svg_open(self,filename): - doc_width = inkex.unittouu(self.document.getroot().get('width')) - doc_height = inkex.unittouu(self.document.getroot().get('height')) + doc_width = self.unittouu(self.document.getroot().get('width')) + doc_height = self.unittouu(self.document.getroot().get('height')) doc_sizeH = min(doc_width,doc_height) doc_sizeW = max(doc_width,doc_height) diff --git a/share/extensions/foldablebox.py b/share/extensions/foldablebox.py index 21de10565..5d5945dd9 100755 --- a/share/extensions/foldablebox.py +++ b/share/extensions/foldablebox.py @@ -58,12 +58,12 @@ class FoldableBox(inkex.Effect): def effect(self): - docW = inkex.unittouu(self.document.getroot().get('width')) - docH = inkex.unittouu(self.document.getroot().get('height')) + docW = self.unittouu(self.document.getroot().get('width')) + docH = self.unittouu(self.document.getroot().get('height')) - boxW = inkex.unittouu( str(self.options.width) + self.options.unit ) - boxH = inkex.unittouu( str(self.options.height) + self.options.unit ) - boxD = inkex.unittouu( str(self.options.depth) + self.options.unit ) + boxW = self.unittouu( str(self.options.width) + self.options.unit ) + boxH = self.unittouu( str(self.options.height) + self.options.unit ) + boxD = self.unittouu( str(self.options.depth) + self.options.unit ) tabProp = self.options.tabProportion tabH = boxD * tabProp diff --git a/share/extensions/gcodetools.py b/share/extensions/gcodetools.py index ff0454db0..b9e6348f2 100755 --- a/share/extensions/gcodetools.py +++ b/share/extensions/gcodetools.py @@ -5852,7 +5852,7 @@ class Gcodetools(inkex.Effect): attr["transform"] = transform orientation_group = inkex.etree.SubElement(layer, inkex.addNS('g','svg'), attr) - doc_height = inkex.unittouu(self.document.getroot().get('height')) + doc_height = self.unittouu(self.document.getroot().get('height')) if self.document.getroot().get('height') == "100%" : doc_height = 1052.3622047 print_("Overruding height from 100 percents to %s" % doc_height) diff --git a/share/extensions/gimp_xcf.py b/share/extensions/gimp_xcf.py index ff1589cd8..35d0bbd4c 100755 --- a/share/extensions/gimp_xcf.py +++ b/share/extensions/gimp_xcf.py @@ -74,8 +74,8 @@ class MyEffect(inkex.Effect): docname = ttmp_orig.get(inkex.addNS('docname',u'sodipodi')) if docname is None: docname = self.args[-1] - pageHeight = int(inkex.unittouu(self.xpathSingle('/svg:svg/@height').split('.')[0])) - pageWidth = int(inkex.unittouu(self.xpathSingle('/svg:svg/@width').split('.')[0])) + pageHeight = int(self.unittouu(self.xpathSingle('/svg:svg/@height').split('.')[0])) + pageWidth = int(self.unittouu(self.xpathSingle('/svg:svg/@width').split('.')[0])) # Create os temp dir (to store exported pngs and Gimp log file) self.tmp_dir = tempfile.mkdtemp() @@ -232,7 +232,7 @@ class MyEffect(inkex.Effect): f = p.stdin out = p.stdout err = p.stderr - f.write(script_fu) + f.write(script_fu.encode('utf-8')) return_code = p.wait() if p.returncode != 0: diff --git a/share/extensions/guides_creator.py b/share/extensions/guides_creator.py index 178dc3c95..abd41c6fc 100755 --- a/share/extensions/guides_creator.py +++ b/share/extensions/guides_creator.py @@ -297,8 +297,8 @@ class Guides_Creator(inkex.Effect): svg = self.document.getroot() # getting the width and height attributes of the canvas - width = inkex.unittouu(svg.get('width')) - height = inkex.unittouu(svg.attrib['height']) + width = self.unittouu(svg.get('width')) + height = self.unittouu(svg.attrib['height']) # getting edges coordinates h_orientation = '0,' + str(round(width,4)) diff --git a/share/extensions/guillotine.py b/share/extensions/guillotine.py index 82b1a5441..bd077d60a 100755 --- a/share/extensions/guillotine.py +++ b/share/extensions/guillotine.py @@ -128,7 +128,7 @@ class Guillotine(inkex.Effect): ''' root = self.document.getroot() horizontals = ['0'] - height = inkex.unittouu(root.attrib['height']) + height = self.unittouu(root.attrib['height']) for h in self.get_all_horizontal_guides(): if h >= 0 and float(h) <= float(height): horizontals.append(h) @@ -144,7 +144,7 @@ class Guillotine(inkex.Effect): ''' root = self.document.getroot() verticals = ['0'] - width = inkex.unittouu(root.attrib['width']) + width = self.unittouu(root.attrib['width']) for v in self.get_all_vertical_guides(): if v >= 0 and float(v) <= float(width): verticals.append(v) diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py index 83d6da5af..eb3d6ffe3 100755 --- a/share/extensions/hpgl_output.py +++ b/share/extensions/hpgl_output.py @@ -115,8 +115,8 @@ class MyEffect(inkex.Effect): if viewBox: viewBox = string.split(viewBox, ' ') if viewBox[2] and viewBox[3]: - viewBoxTransformX = float(inkex.unittouu(doc.get('width'))) / float(viewBox[2]) - viewBoxTransformY = float(inkex.unittouu(doc.get('height'))) / float(viewBox[3]) + viewBoxTransformX = float(self.unittouu(doc.get('width'))) / float(viewBox[2]) + viewBoxTransformY = float(self.unittouu(doc.get('height'))) / float(viewBox[3]) # dryRun to find edges self.dryRun = True self.groupmat = [[[scale*viewBoxTransformX, 0.0, 0.0], [0.0, mirror*scale*viewBoxTransformY, 0.0]]] diff --git a/share/extensions/ink2canvas.py b/share/extensions/ink2canvas.py index 7d2ee6a7f..51b75d846 100755 --- a/share/extensions/ink2canvas.py +++ b/share/extensions/ink2canvas.py @@ -78,8 +78,8 @@ class Ink2Canvas(inkex.Effect): def effect(self): """Applies the effect""" svg_root = self.document.getroot() - width = inkex.unittouu(svg_root.get("width")) - height = inkex.unittouu(svg_root.get("height")) + width = self.unittouu(svg_root.get("width")) + height = self.unittouu(svg_root.get("height")) self.canvas = Canvas(width, height) self.walk_tree(svg_root) diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index 861cc2300..4542bc418 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -78,30 +78,6 @@ def localize(): #sys.stderr.write(str(localdir) + "\n") trans.install() -#a dictionary of unit to user unit conversion factors -uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'm':3543.3070866, - 'km':3543307.0866, 'pc':15.0, 'yd':3240 , 'ft':1080} -def unittouu(string): - '''Returns userunits given a string representation of units in another system''' - unit = re.compile('(%s)$' % '|'.join(uuconv.keys())) - param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)') - - p = param.match(string) - u = unit.search(string) - if p: - retval = float(p.string[p.start():p.end()]) - else: - retval = 0.0 - if u: - try: - return retval * uuconv[u.string[u.start():u.end()]] - except KeyError: - pass - return retval - -def uutounit(val, unit): - return val/uuconv[unit] - def debug(what): sys.stderr.write(str(what) + "\n") return what @@ -189,6 +165,7 @@ class Effect: self.original_document = copy.deepcopy(self.document) stream.close() + # defines view_center in terms of document units def getposinlayer(self): #defaults self.current_layer = self.document.getroot() @@ -203,10 +180,10 @@ class Effect: xattr = self.document.xpath('//sodipodi:namedview/@inkscape:cx', namespaces=NSS) yattr = self.document.xpath('//sodipodi:namedview/@inkscape:cy', namespaces=NSS) - doc_height = unittouu(self.document.getroot().get('height')) if xattr and yattr: - x = xattr[0] - y = yattr[0] + x = self.unittouu( xattr[0] + 'px' ) + y = self.unittouu( yattr[0] + 'px') + doc_height = self.unittouu(self.document.getroot().get('height')) if x and y: self.view_center = (float(x), doc_height - float(y)) # FIXME: y-coordinate flip, eliminate it when it's gone in Inkscape @@ -283,6 +260,40 @@ class Effect: errormsg(_("No matching node for expression: %s") % path) retval = None return retval - + + def getDocumentUnit(self): + docunit = self.document.xpath('//sodipodi:namedview/@inkscape:document-units', namespaces=NSS) + if docunit: + return docunit[0] + else: + return 'px' + + #a dictionary of unit to user unit conversion factors + uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'm':3543.3070866, + 'km':3543307.0866, 'pc':15.0, 'yd':3240 , 'ft':1080} + def unittouu(self, string): + '''Returns userunits given a string representation of units in another system''' + unit = re.compile('(%s)$' % '|'.join(self.uuconv.keys())) + param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)') + + p = param.match(string) + u = unit.search(string) + if p: + retval = float(p.string[p.start():p.end()]) + else: + retval = 0.0 + if u: + try: + return retval * (self.uuconv[u.string[u.start():u.end()]] / self.uuconv[self.getDocumentUnit()]) + except KeyError: + pass + else: # default assume 'px' unit + return retval / self.uuconv[self.getDocumentUnit()] + + return retval + + def uutounit(self, val, unit): + return val / (self.uuconv[unit] / self.uuconv[self.getDocumentUnit()]) + # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/interp.py b/share/extensions/interp.py index 9e10f30d8..c69dd4a73 100755 --- a/share/extensions/interp.py +++ b/share/extensions/interp.py @@ -61,8 +61,8 @@ def tweenstylefloat(property, start, end, time): ep = float(end[property]) return str(sp + (time * (ep - sp))) def tweenstyleunit(property, start, end, time): - sp = inkex.unittouu(start[property]) - ep = inkex.unittouu(end[property]) + sp = self.unittouu(start[property]) + ep = self.unittouu(end[property]) return str(sp + (time * (ep - sp))) def tweenstylecolor(property, start, end, time): sr,sg,sb = parsecolor(start[property]) diff --git a/share/extensions/interp_att_g.py b/share/extensions/interp_att_g.py index 8ceaf8e34..0798f7f58 100755 --- a/share/extensions/interp_att_g.py +++ b/share/extensions/interp_att_g.py @@ -103,8 +103,8 @@ class InterpAttG(inkex.Effect): sv = self.options.start_val ev = self.options.end_val if self.inte_att_type and self.inte_att_type != 'none': - sv = inkex.unittouu( sv + self.inte_att_type ) - ev = inkex.unittouu( ev + self.inte_att_type ) + sv = self.unittouu( sv + self.inte_att_type ) + ev = self.unittouu( ev + self.inte_att_type ) self.val_cur = self.val_ini = sv self.val_end = ev self.val_inc = ( ev - sv ) / float( self.tot_el - 1 ) diff --git a/share/extensions/jessyInk_export.inx b/share/extensions/jessyInk_export.inx index 42ab811b9..fc8536a71 100644 --- a/share/extensions/jessyInk_export.inx +++ b/share/extensions/jessyInk_export.inx @@ -11,7 +11,7 @@ <_option value="PDF">PDF</_option> <_option value="PNG">PNG</_option> </param> - <param name="resolution" type="int" min="50" max="1000" _gui-text="Resolution:">92</param> + <param name="resolution" type="int" min="1" max="1000" _gui-text="Resolution:">92</param> </page> <page name="help" _gui-text="Help"> <_param name="help_text" type="description">This extension allows you to export a JessyInk presentation once you created an export layer in your browser. Please see code.google.com/p/jessyink for more details.</_param> diff --git a/share/extensions/layout_nup_pageframe.py b/share/extensions/layout_nup_pageframe.py index 16b781470..59da1f4bb 100755 --- a/share/extensions/layout_nup_pageframe.py +++ b/share/extensions/layout_nup_pageframe.py @@ -32,7 +32,7 @@ def expandTuple(unit, x, length = 4): if len(x) != length: raise Exception("expandTuple: requires 2 or 4 item tuple") try: - return tuple(map(lambda ev: (inkex.unittouu(str(eval(str(ev)))+unit)), x)) + return tuple(map(lambda ev: (self.unittouu(str(eval(str(ev)))+unit)), x)) except: return None #@-node:tbrown.20070622103716.1:expandTuple diff --git a/share/extensions/measure.py b/share/extensions/measure.py index 8aa940ed2..68cce0334 100755 --- a/share/extensions/measure.py +++ b/share/extensions/measure.py @@ -154,7 +154,7 @@ class Length(inkex.Effect): mat = simpletransform.composeParents(node, [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]) p = cubicsuperpath.parsePath(node.get('d')) simpletransform.applyTransformToPath(mat, p) - factor = factor/inkex.unittouu('1'+self.options.unit) + factor = factor/self.unittouu('1'+self.options.unit) if self.options.type == "length": slengths, stotal = csplength(p) else: diff --git a/share/extensions/pixelsnap.py b/share/extensions/pixelsnap.py index 95ae7f0dc..162822920 100755 --- a/share/extensions/pixelsnap.py +++ b/share/extensions/pixelsnap.py @@ -77,7 +77,6 @@ import simplestyle, simpletransform, simplepath try: import inkex - from inkex import unittouu except ImportError: raise ImportError("No module named inkex.\nPlease edit the file %s and see the section titled 'INKEX MODULE'" % __file__) @@ -170,7 +169,7 @@ class PixelSnapEffect(inkex.Effect): stroke_width = 0 if stroke and setval is None: - stroke_width = unittouu(style.get('stroke-width', '').strip()) + stroke_width = self.unittouu(style.get('stroke-width', '').strip()) if setval: style['stroke-width'] = str(setval) @@ -436,10 +435,10 @@ class PixelSnapEffect(inkex.Effect): offset = self.elem_offset(elem, parent_transform) % 1 - width = unittouu(elem.attrib['width']) - height = unittouu(elem.attrib['height']) - x = unittouu(elem.attrib['x']) - y = unittouu(elem.attrib['y']) + width = self.unittouu(elem.attrib['width']) + height = self.unittouu(elem.attrib['height']) + x = self.unittouu(elem.attrib['x']) + y = self.unittouu(elem.attrib['y']) width, height = transform_dimensions(transform, width, height) x, y = transform_point(transform, [x, y]) @@ -494,7 +493,7 @@ class PixelSnapEffect(inkex.Effect): def effect(self): svg = self.document.getroot() - self.document_offset = unittouu(svg.attrib['height']) % 1 # although SVG units are absolute, the elements are positioned relative to the top of the page, rather than zero + self.document_offset = self.unittouu(svg.attrib['height']) % 1 # although SVG units are absolute, the elements are positioned relative to the top of the page, rather than zero for id, elem in self.selected.iteritems(): try: diff --git a/share/extensions/print_win32_vector.py b/share/extensions/print_win32_vector.py index e77b49826..ca166d25a 100644 --- a/share/extensions/print_win32_vector.py +++ b/share/extensions/print_win32_vector.py @@ -63,7 +63,7 @@ class MyEffect(inkex.Effect): if style['stroke'] and style['stroke'] != 'none' and style['stroke'][0:3] != 'url': rgb = simplestyle.parseColor(style['stroke']) if style.has_key('stroke-width'): - stroke = inkex.unittouu(style['stroke-width']) + stroke = self.unittouu(style['stroke-width']) stroke = int(stroke*self.scale) if style.has_key('fill'): if style['fill'] and style['fill'] != 'none' and style['fill'][0:3] != 'url': diff --git a/share/extensions/printing_marks.py b/share/extensions/printing_marks.py index 7d3ab02d1..5c6ac3a61 100755 --- a/share/extensions/printing_marks.py +++ b/share/extensions/printing_marks.py @@ -34,8 +34,6 @@ class Printing_Marks (inkex.Effect): # Default parameters stroke_width = 0.25 - mark_size = inkex.unittouu('1cm') - min_mark_margin = inkex.unittouu('3mm') def __init__(self): inkex.Effect.__init__(self) @@ -228,6 +226,8 @@ class Printing_Marks (inkex.Effect): self.area_h = max_y - min_y def effect(self): + self.mark_size = self.unittouu('1cm') + self.min_mark_margin = self.unittouu('3mm') if self.options.where_to_crop == 'selection' : self.get_selection_area() @@ -235,8 +235,8 @@ class Printing_Marks (inkex.Effect): #exit(1) else : svg = self.document.getroot() - self.area_w = inkex.unittouu(svg.get('width')) - self.area_h = inkex.unittouu(svg.attrib['height']) + self.area_w = self.unittouu(svg.get('width')) + self.area_h = self.unittouu(svg.attrib['height']) self.area_x1 = 0 self.area_y1 = 0 self.area_x2 = self.area_w @@ -245,16 +245,16 @@ class Printing_Marks (inkex.Effect): # Get SVG document dimensions # self.width must be replaced by self.area_x2. same to others. svg = self.document.getroot() - #self.width = width = inkex.unittouu(svg.get('width')) - #self.height = height = inkex.unittouu(svg.attrib['height']) + #self.width = width = self.unittouu(svg.get('width')) + #self.height = height = self.unittouu(svg.attrib['height']) # Convert parameters to user unit - offset = inkex.unittouu(str(self.options.crop_offset) + \ + offset = self.unittouu(str(self.options.crop_offset) + \ self.options.unit) - bt = inkex.unittouu(str(self.options.bleed_top) + self.options.unit) - bb = inkex.unittouu(str(self.options.bleed_bottom) + self.options.unit) - bl = inkex.unittouu(str(self.options.bleed_left) + self.options.unit) - br = inkex.unittouu(str(self.options.bleed_right) + self.options.unit) + bt = self.unittouu(str(self.options.bleed_top) + self.options.unit) + bb = self.unittouu(str(self.options.bleed_bottom) + self.options.unit) + bl = self.unittouu(str(self.options.bleed_left) + self.options.unit) + br = self.unittouu(str(self.options.bleed_right) + self.options.unit) # Bleed margin if bt < offset : bmt = 0 else : bmt = bt - offset @@ -476,9 +476,9 @@ class Printing_Marks (inkex.Effect): } txt = inkex.etree.SubElement(g_pag_info, 'text', txt_attribs) txt.text = 'Page size: ' +\ - str(round(inkex.uutounit(self.area_w,self.options.unit),2)) +\ + str(round(self.uutounit(self.area_w,self.options.unit),2)) +\ 'x' +\ - str(round(inkex.uutounit(self.area_h,self.options.unit),2)) +\ + str(round(self.uutounit(self.area_h,self.options.unit),2)) +\ ' ' + self.options.unit diff --git a/share/extensions/render_gears.py b/share/extensions/render_gears.py index a1b3ee666..5201e553b 100644 --- a/share/extensions/render_gears.py +++ b/share/extensions/render_gears.py @@ -67,9 +67,9 @@ class Gears(inkex.Effect): def effect(self): teeth = self.options.teeth - pitch = inkex.unittouu( str(self.options.pitch) + self.options.unit) + pitch = self.unittouu( str(self.options.pitch) + self.options.unit) angle = self.options.angle # Angle of tangent to tooth at circular pitch wrt radial line. - centerdiameter = inkex.unittouu( str(self.options.centerdiameter) + self.options.unit) + centerdiameter = self.unittouu( str(self.options.centerdiameter) + self.options.unit) # print >>sys.stderr, "Teeth: %s\n" % teeth @@ -182,4 +182,5 @@ if __name__ == '__main__': e.affect() + # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/split.py b/share/extensions/split.py index 0cbc7b05b..18d4327fe 100755 --- a/share/extensions/split.py +++ b/share/extensions/split.py @@ -58,7 +58,7 @@ class Split(inkex.Effect): fontsize = parseStyle(node.get("style"))["font-size"] except: fontsize = "12px" - fs = inkex.unittouu(fontsize) + fs = self.unittouu(fontsize) #selects the flowRegion's child (svg:rect) to get @X and @Y id = node.get("id") @@ -124,7 +124,7 @@ class Split(inkex.Effect): fontsize = parseStyle(line.get("style"))["font-size"] except: fontsize = "12px" - fs = inkex.unittouu(fontsize) + fs = self.unittouu(fontsize) #extract and returns a list of words words_list = "".join(plain_str(line)).split() @@ -170,7 +170,7 @@ class Split(inkex.Effect): fontsize = simplestyle.parseStyle(word.get("style"))["font-size"] except: fontsize = "12px" - fs = inkex.unittouu(fontsize) + fs = self.unittouu(fontsize) #for each letter in element string for letter in word[0].text: diff --git a/share/extensions/svgcalendar.py b/share/extensions/svgcalendar.py index 23290bfe5..a4269f5d7 100755 --- a/share/extensions/svgcalendar.py +++ b/share/extensions/svgcalendar.py @@ -166,8 +166,8 @@ class SVGCalendar (inkex.Effect): else: calendar.setfirstweekday(0) # Convert string numbers with unit to user space float numbers - self.options.month_width = inkex.unittouu( self.options.month_width ) - self.options.month_margin = inkex.unittouu( self.options.month_margin ) + self.options.month_width = self.unittouu( self.options.month_width ) + self.options.month_margin = self.unittouu( self.options.month_margin ) # initial values month_x_pos = 0 @@ -176,8 +176,8 @@ class SVGCalendar (inkex.Effect): def calculate_size_and_positions(self): #month_margin month_width months_per_line auto_organize - self.doc_w = inkex.unittouu(self.document.getroot().get('width')) - self.doc_h = inkex.unittouu(self.document.getroot().get('height')) + self.doc_w = self.unittouu(self.document.getroot().get('width')) + self.doc_h = self.unittouu(self.document.getroot().get('height')) if self.options.show_weeknr: self.cols_before = 1 else: diff --git a/share/extensions/voronoi2svg.py b/share/extensions/voronoi2svg.py index dd693f8bb..c5b8a511f 100755 --- a/share/extensions/voronoi2svg.py +++ b/share/extensions/voronoi2svg.py @@ -290,8 +290,8 @@ class Voronoi2svg(inkex.Effect): clipBox = () if self.options.clipBox == 'Page': svg = self.document.getroot() - w = inkex.unittouu(svg.get('width')) - h = inkex.unittouu(svg.get('height')) + w = self.unittouu(svg.get('width')) + h = self.unittouu(svg.get('height')) clipBox = (0,w,0,h) else: clipBox = (2*gBbox[0]-gBbox[1], diff --git a/share/extensions/webslicer_export.py b/share/extensions/webslicer_export.py index 118dfbeee..c9ea761a7 100755 --- a/share/extensions/webslicer_export.py +++ b/share/extensions/webslicer_export.py @@ -303,8 +303,8 @@ class WebSlicer_Export(WebSlicer_Effect): if len(el) == 5: self.el_geo[el[0]] = { 'x':float(el[1]), 'y':float(el[2]), 'w':float(el[3]), 'h':float(el[4]) } - doc_w = inkex.unittouu( self.document.getroot().get('width') ) - doc_h = inkex.unittouu( self.document.getroot().get('height') ) + doc_w = self.unittouu( self.document.getroot().get('width') ) + doc_h = self.unittouu( self.document.getroot().get('height') ) self.el_geo['webslicer-layer'] = { 'x':0, 'y':0, 'w':doc_w, 'h':doc_h } diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index c0d05e3c4..cb72f65dc 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -303,23 +303,29 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) Geom::Line parallel_hull_edge; parallel_hull_edge.setOrigin(hull_edge.origin()+hull_edge.versor().ccw()*spacing); parallel_hull_edge.setVersor(hull_edge.versor()); - + // determine the intersection point - - Geom::OptCrossing int_pt = Geom::intersection(parallel_hull_edge, prev_parallel_hull_edge); - if (int_pt) - { - Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], - (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]); - poly.ps.push_back(avoid_pt); + try { + Geom::OptCrossing int_pt = Geom::intersection(parallel_hull_edge, prev_parallel_hull_edge); + if (int_pt) + { + Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], + (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]); + poly.ps.push_back(avoid_pt); + } + else + { + // something went wrong... + std::cout<<"conn-avoid-ref.cpp: avoid_item_poly: Geom:intersection failed."<<std::endl; + } } - else - { - // something went wrong... - std::cout<<"conn-avoid-ref.cpp: avoid_item_poly: Geom:intersection failed."<<std::endl; + catch (Geom::InfiniteSolutions const &e) { + // the parallel_hull_edge and prev_parallel_hull_edge lie on top of each other, hence infinite crossings + g_message("conn-avoid-ref.cpp: trying to get crossings of identical lines"); } prev_parallel_hull_edge = parallel_hull_edge; } + return poly; } diff --git a/src/document.cpp b/src/document.cpp index 4f57cf080..3433e42ec 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -84,6 +84,7 @@ static gint sp_document_rerouting_handler(gpointer data); gboolean sp_document_resource_list_free(gpointer key, gpointer value, gpointer data); static gint doc_count = 0; +static gint doc_mem_count = 0; static unsigned long next_serial = 0; @@ -500,15 +501,18 @@ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, b base = NULL; name = g_strdup(uri); } + if (make_new) { + base = NULL; + uri = NULL; + name = g_strdup_printf(_("New document %d"), ++doc_count); + } g_free(s); } else { - rdoc = sp_repr_document_new("svg:svg"); - } + if (make_new) { + name = g_strdup_printf(_("Memory document %d"), ++doc_mem_count); + } - if (make_new) { - base = NULL; - uri = NULL; - name = g_strdup_printf(_("New document %d"), ++doc_count); + rdoc = sp_repr_document_new("svg:svg"); } //# These should be set by now @@ -534,7 +538,7 @@ SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, un // If xml file is not svg, return NULL without warning // TODO fixme: destroy document } else { - Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_count ); + Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_mem_count ); doc = createDoc(rdoc, NULL, NULL, name.c_str(), keepalive); } } @@ -554,6 +558,13 @@ SPDocument *SPDocument::doUnref() return NULL; } +/// guaranteed not to return nullptr +Inkscape::Util::Unit const* SPDocument::getDefaultUnit() const +{ + SPNamedView const* nv = sp_document_namedview(this, NULL); + return nv ? nv->getDefaultUnit() : unit_table.getUnit("pt"); +} + Inkscape::Util::Quantity SPDocument::getWidth() const { g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); @@ -668,7 +679,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) double margin_right = 0.0; double margin_bottom = 0.0; - SPNamedView *nv = sp_document_namedview(this, 0); + SPNamedView *nv = sp_document_namedview(this, NULL); if (with_margins && nv) { if (nv != NULL) { @@ -1471,9 +1482,10 @@ void SPDocument::setModifiedSinceSave(bool modified) { this->modified_since_save = modified; if (SP_ACTIVE_DESKTOP) { Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel(); - g_assert(parent != NULL); - SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget")); - dtw->updateTitle( this->getName() ); + if (parent) { // during load, SP_ACTIVE_DESKTOP may be !nullptr, but parent might still be nullptr + SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget")); + dtw->updateTitle( this->getName() ); + } } } diff --git a/src/document.h b/src/document.h index 948b5b867..0977fc7a8 100644 --- a/src/document.h +++ b/src/document.h @@ -47,6 +47,7 @@ namespace Inkscape { class Node; } namespace Util { + class Unit; class Quantity; } } @@ -123,6 +124,7 @@ public: /** Returns our SPRoot */ SPRoot *getRoot() { return root; } + SPRoot const *getRoot() const { return root; } Inkscape::XML::Node *getReprRoot() { return rroot; } @@ -227,6 +229,7 @@ public: SPDocument *doRef(); SPDocument *doUnref(); + Inkscape::Util::Unit const* getDefaultUnit() const; Inkscape::Util::Quantity getWidth() const; Inkscape::Util::Quantity getHeight() const; Geom::Point getDimensions() const; diff --git a/src/extension/dbus/Makefile_insert b/src/extension/dbus/Makefile_insert index a5eb3fdf4..7d851715e 100644 --- a/src/extension/dbus/Makefile_insert +++ b/src/extension/dbus/Makefile_insert @@ -12,7 +12,8 @@ ink_common_sources += \ extension/dbus/application-interface.cpp \ extension/dbus/application-interface.h \ extension/dbus/document-interface.cpp \ - extension/dbus/document-interface.h + extension/dbus/document-interface.h \ + extension/dbus/org.inkscape.service.in ########################### # Build DBus wrapper files diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp index 517d6fb9c..04087e268 100644 --- a/src/extension/internal/cdr-input.cpp +++ b/src/extension/internal/cdr-input.cpp @@ -258,7 +258,7 @@ SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE); // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } return doc; } diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index f1876c687..36d7ca145 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -789,8 +789,12 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) // Assume src color is "white" if(d->dwRop3){ switch(d->dwRop3){ - case U_PATINVERT: // treat all of these as black - case U_SRCINVERT: + case U_PATINVERT: // invert pattern + fill_rgb[0] = 1.0 - fill_rgb[0]; + fill_rgb[1] = 1.0 - fill_rgb[1]; + fill_rgb[2] = 1.0 - fill_rgb[2]; + break; + case U_SRCINVERT: // treat all of these as black case U_DSTINVERT: case U_BLACKNESS: case U_SRCERASE: @@ -799,7 +803,6 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) break; case U_SRCCOPY: // treat all of these as white case U_NOTSRCERASE: - case U_PATCOPY: case U_WHITENESS: fill_rgb[0]=fill_rgb[1]=fill_rgb[2]=1.0; break; @@ -808,6 +811,7 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) case U_MERGECOPY: case U_MERGEPAINT: case U_PATPAINT: + case U_PATCOPY: default: break; } @@ -2747,7 +2751,10 @@ std::cout << "BEFORE DRAW" { dbg_str << "<!-- U_EMR_BEGINPATH -->\n"; // The next line should never be needed, should have been handled before main switch - *(d->path) = ""; + // qualifier added because EMF's encountered where moveto preceded beginpath followed by lineto + if(d->mask & U_DRAW_VISIBLE){ + *(d->path) = ""; + } d->mask |= emr_mask; break; } @@ -2859,6 +2866,7 @@ std::cout << "BEFORE DRAW" if (!pEmr->cbBmiSrc) { // should be an application of a DIBPATTERNBRUSHPT, use a solid color instead + if(pEmr->dwRop == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */ int32_t dx = pEmr->Dest.x; int32_t dy = pEmr->Dest.y; int32_t dw = pEmr->cDest.x; @@ -3497,12 +3505,13 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // Set document unit Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr(); Inkscape::SVGOStringStream os; - os << doc->getWidth().unit->abbr; + Inkscape::Util::Unit const* doc_unit = doc->getWidth().unit; + os << doc_unit->abbr; repr->setAttribute("inkscape:document-units", os.str().c_str()); - + // Set viewBox - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); - + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc_unit), doc->getHeight().value(doc_unit))); + // Scale and translate objects double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit); ShapeEditor::blockSetItem(true); diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index 13267ee2b..6d159d265 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -105,7 +105,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } // restore undo, as now this document may be shown to the user if a bitmap was opened diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp index b38b0ddc7..865e86698 100644 --- a/src/extension/internal/image-resolution.cpp +++ b/src/extension/internal/image-resolution.cpp @@ -342,9 +342,16 @@ void ImageResolution::readmagick(char const *fn) { image.read(fn); } catch (...) {} Magick::Geometry geo = image.density(); + std::string type = image.magick(); + + if (type == "PNG") { // PNG only supports pixelspercentimeter + x_ = Inkscape::Util::Quantity::convert((double)geo.width(), "in", "cm"); + y_ = Inkscape::Util::Quantity::convert((double)geo.height(), "in", "cm"); + } else { + x_ = (double)geo.width(); + y_ = (double)geo.height(); + } - x_ = Inkscape::Util::Quantity::convert((double)geo.width(), "pt", "px"); - y_ = Inkscape::Util::Quantity::convert((double)geo.height(), "pt", "px"); ok_ = true; } diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp index adac0d6c9..f47fbaf87 100644 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@ -626,7 +626,7 @@ PdfInputCairo::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) { // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } delete output; diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 213550688..3155ac098 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -750,7 +750,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } // Restore undo diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp index 42a9e3d41..6fc79237b 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -258,7 +258,7 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } return doc; diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index d69d46f20..2e55dcb1e 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -1970,7 +1970,9 @@ std::cout << "BEFORE DRAW" } if (!d->dc[d->level].sizeView.x || !d->dc[d->level].sizeView.y) { - d->dc[d->level].sizeView = d->dc[d->level].sizeWnd; + /* Previously it used sizeWnd, but that always resulted in scale = 1 if no viewport ever appeared, and in most files, it did not */ + d->dc[d->level].sizeView.x = d->PixelsInX - 1; + d->dc[d->level].sizeView.y = d->PixelsInY - 1; } /* scales logical to WMF pixels, transfer a negative sign on Y, if any */ @@ -2284,6 +2286,7 @@ std::cout << "BEFORE DRAW" dbg_str << "<!-- U_WMR_BITBLT -->\n"; nSize = U_WMRBITBLT_get(contents,&Dst,&cwh,&Src,&dwRop3,&Bm16,&px); if(!px){ + if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */ int32_t dx = Dst.x; int32_t dy = Dst.y; int32_t dw = cwh.x; @@ -2321,6 +2324,7 @@ std::cout << "BEFORE DRAW" dbg_str << "<!-- U_WMR_STRETCHBLT -->\n"; nSize = U_WMRSTRETCHBLT_get(contents,&Dst,&cDst,&Src,&cSrc,&dwRop3,&Bm16,&px); if(!px){ + if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */ int32_t dx = Dst.x; int32_t dy = Dst.y; int32_t dw = cDst.x; @@ -2715,6 +2719,7 @@ std::cout << "BEFORE DRAW" if (!dib) { // should be an application of a DIBPATTERNBRUSHPT, use a solid color instead + if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */ int32_t dx = Dst.x; int32_t dy = Dst.y; int32_t dw = cwh.x; @@ -3185,11 +3190,12 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // Set document unit Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr(); Inkscape::SVGOStringStream os; - os << doc->getWidth().unit->abbr; + Inkscape::Util::Unit const* doc_unit = doc->getWidth().unit; + os << doc_unit->abbr; repr->setAttribute("inkscape:document-units", os.str().c_str()); // Set viewBox - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc_unit), doc->getHeight().value(doc_unit))); // Scale and translate objects double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit); diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp index cf0302b38..3bb17146c 100644 --- a/src/extension/internal/wmf-print.cpp +++ b/src/extension/internal/wmf-print.cpp @@ -1120,6 +1120,9 @@ unsigned int PrintWmf::image( Geom::Point pLL(x1, y1); Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates + Geom::Point pWH(dw, dh); + Geom::Point pWH2 = pWH * tf.withoutTranslation(); //adjust scale + char *px; uint32_t cbPx; uint32_t colortype; @@ -1133,7 +1136,7 @@ unsigned int PrintWmf::image( Bmi = bitmapinfo_set(Bmih, ct); U_POINT16 Dest = point16_set(round(pLL2[Geom::X] * PX2WORLD), round(pLL2[Geom::Y] * PX2WORLD)); - U_POINT16 cDest = point16_set(round(dw * PX2WORLD), round(dh * PX2WORLD)); + U_POINT16 cDest = point16_set(round(pWH2[Geom::X] * PX2WORLD), round(pWH2[Geom::Y] * PX2WORLD)); U_POINT16 Src = point16_set(0, 0); U_POINT16 cSrc = point16_set(w, h); rec = U_WMRSTRETCHDIB_set( diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index ac86a6171..b5eb3ce8f 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -114,7 +114,7 @@ SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } delete input; diff --git a/src/file.cpp b/src/file.cpp index 8a7b177c0..f978ec66e 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -144,7 +144,7 @@ SPDesktop *sp_file_new(const std::string &templ) // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { DocumentUndo::setUndoSensitive(doc, false); - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); DocumentUndo::setUndoSensitive(doc, true); } diff --git a/src/interface.cpp b/src/interface.cpp index e57092e2b..f411989ce 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -324,7 +324,7 @@ sp_ui_close_view(GtkWidget */*widget*/) SPDocument *doc = SPDocument::createNewDoc( templateUri.c_str() , TRUE, true ); // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } dt->change_document(doc); sp_namedview_window_from_document(dt); diff --git a/src/libdepixelize/priv/point.h b/src/libdepixelize/priv/point.h index dc28a2b84..53babd9dc 100644 --- a/src/libdepixelize/priv/point.h +++ b/src/libdepixelize/priv/point.h @@ -30,8 +30,8 @@ namespace Tracer { template<class T> struct Point { - Point() : visible(true) {} - Point(T x, T y) : visible(true), x(x), y(y) {} + Point() : smooth(false), visible(true) {} + Point(T x, T y) : smooth(false), visible(true), x(x), y(y) {} Point(T x, T y, bool smooth) : smooth(smooth), visible(true), x(x), y(y) {} Point operator+(const Point &rhs) const diff --git a/src/libuemf/uemf.h b/src/libuemf/uemf.h index f1211d63d..1ff6ead60 100644 --- a/src/libuemf/uemf.h +++ b/src/libuemf/uemf.h @@ -856,6 +856,7 @@ extern "C" { #define U_DSTINVERT 0x550009 #define U_BLACKNESS 0x000042 #define U_WHITENESS 0xff0062 +#define U_NOOP 0xaa0029 /* Many GDI programs end with a bitblt with this ROP == "D". Seems to work like flush() */ /** @} */ /** \defgroup U_EMRSETROP2_iMode_Qualifiers Binary Raster Operation Enumeration diff --git a/src/libvpsc/solve_VPSC.cpp b/src/libvpsc/solve_VPSC.cpp index f9bed649c..83cb517b6 100644 --- a/src/libvpsc/solve_VPSC.cpp +++ b/src/libvpsc/solve_VPSC.cpp @@ -301,16 +301,16 @@ bool Solver::constraintGraphIsCyclic(const unsigned n, Variable* const vs[]) { varmap[vs[i]]->out.insert(varmap[r]); } } - while(graph.size()>0) { + while(!graph.empty()) { node *u=NULL; vector<node*>::iterator i=graph.begin(); for(;i!=graph.end();++i) { u=*i; - if(u->in.size()==0) { + if(u->in.empty()) { break; } } - if(i==graph.end() && graph.size()>0) { + if(i==graph.end() && !graph.empty()) { //cycle found! return true; } else { @@ -358,16 +358,16 @@ bool Solver::blockGraphIsCyclic() { c=b->findMinOutConstraint(); } } - while(graph.size()>0) { + while(!graph.empty()) { node *u=NULL; vector<node*>::iterator i=graph.begin(); for(;i!=graph.end();++i) { u=*i; - if(u->in.size()==0) { + if(u->in.empty()) { break; } } - if(i==graph.end() && graph.size()>0) { + if(i==graph.end() && !graph.empty()) { //cycle found! return true; } else { diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index ad497ff2f..a01ba891e 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -1073,6 +1073,11 @@ SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id) return (SPNamedView *) nv; } +SPNamedView const *sp_document_namedview(SPDocument const *document, const gchar *id) +{ + return sp_document_namedview(const_cast<SPDocument *>(document), id); // use a const_cast here to avoid duplicating code +} + void SPNamedView::setGuides(bool v) { g_assert(this->getRepr() != NULL); diff --git a/src/sp-namedview.h b/src/sp-namedview.h index 00302e9a1..05cbcc398 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -110,6 +110,7 @@ protected: SPNamedView *sp_document_namedview(SPDocument *document, gchar const *name); +SPNamedView const *sp_document_namedview(SPDocument const *document, gchar const *name); void sp_namedview_window_from_document(SPDesktop *desktop); void sp_namedview_document_from_window(SPDesktop *desktop); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 2408370cf..e5f119ee0 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -228,7 +228,7 @@ SPObject *sp_object_unref(SPObject *object, SPObject *owner) //g_object_unref(G_OBJECT(object)); object->refCount--; - if (object->refCount < 0) { + if (object->refCount <= 0) { delete object; } diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index ff5e81f95..b327f0b83 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -113,7 +113,7 @@ void SPRect::set(unsigned key, gchar const *value) { void SPRect::update(SPCtx* ctx, unsigned int flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - SPItemCtx const *ictx = (SPItemCtx const *) ctx; + SPItemCtx const *ictx = reinterpret_cast<SPItemCtx const *>(ctx); double const w = ictx->viewport.width(); double const h = ictx->viewport.height(); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index a6019c55c..79fb953ac 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -173,7 +173,7 @@ DocumentProperties::DocumentProperties() signalDocumentReplaced().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDocumentReplaced)); signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleActivateDesktop)); signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop)); - + _rum_deflt._changed_connection.block(); _rum_deflt.getUnitMenu()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::onDocUnitChange)); } @@ -1437,8 +1437,9 @@ void DocumentProperties::update() _rcp_bord.setRgba32 (nv->bordercolor); _rcb_shad.setActive (nv->showpageshadow); - if (nv->doc_units) + if (nv->doc_units) { _rum_deflt.setUnit (nv->doc_units->abbr); + } double doc_w = sp_desktop_document(dt)->getRoot()->width.value; Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit)->abbr; @@ -1643,18 +1644,23 @@ void DocumentProperties::onRemoveGrid() void DocumentProperties::onDocUnitChange() { SPDocument *doc = SP_ACTIVE_DOCUMENT; + // Don't execute when change is being undone + if (!DocumentUndo::getUndoSensitive(doc)) { + return; + } + // Don't execute when initializing widgets + if (_wr.isUpdating()) { + return; + } + + Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); Inkscape::Util::Unit const *old_doc_unit = unit_table.getUnit("px"); if(repr->attribute("inkscape:document-units")) { old_doc_unit = unit_table.getUnit(repr->attribute("inkscape:document-units")); } Inkscape::Util::Unit const *doc_unit = _rum_deflt.getUnit(); - - // Don't execute when change is being undone - if (!DocumentUndo::getUndoSensitive(doc)) { - return; - } - + // Set document unit Inkscape::SVGOStringStream os; os << doc_unit->abbr; |
