"""
Copyright (C) 2013 Nicolas Dufour (jazzynico)
Direction code from the Restack extension, by Rob Antonishen
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
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.
"""
# standard library
import chardataeffect
import copy
import csv
import math
import os
import string
try:
except:
# local library
import inkex
help="direction to merge text")
help="horizontal point to compare")
help="vertical point to compare")
help="use a flow text structure instead of a normal text element")
help="keep format")
objlist = []
# get all bounding boxes in file by calling inkscape again with the --query-all command line option
# it returns a comma separated list structured id,x,y,w,h
if bsubprocess:
f = p.communicate()[0]
try:
reader=csv.CSVParser().parse_string(f) #there was a module cvs.py in earlier inkscape that behaved differently
except:
else:
#build a dictionary with id as the key
if not bsubprocess: #close file if opened using os.popen3
f.close
#find the center of all selected objects **Not the average!
minx = x
miny = y
maxx = x + w
maxy = y + h
# get the bounding box
if x < minx:
minx = x
if (x + w) > maxx:
maxx = x + w
if y < miny:
miny = y
if (y + h) > maxy:
maxy = y + h
#calculate distances for each selected object
# get the bounding box
# calc the comparison coords
cx = x
cx = x + w
else: # middle
cx = x + w / 2
cy = y
cy = y + h
else: # middle
cy = y + h / 2
#direction chosen
#move them to the top of the object stack in this order.
else:
self.textRoot=inkex.etree.SubElement(parentnode,inkex.addNS(self.text_element,'svg'),{inkex.addNS('space','xml'):'preserve'})
self.textRoot.set(inkex.addNS('style', ''), 'font-size:20px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;')
self.region=inkex.etree.SubElement(self.textRoot,inkex.addNS('flowRegion','svg'),{inkex.addNS('space','xml'):'preserve'})
self.rect=inkex.etree.SubElement(self.region,inkex.addNS('rect','svg'),{inkex.addNS('space','xml'):'preserve'})
#istext = (node.tag == '{http://www.w3.org/2000/svg}flowPara' or node.tag == '{http://www.w3.org/2000/svg}flowDiv' or node.tag == '{http://www.w3.org/2000/svg}tspan')
newspan=inkex.etree.SubElement(span,inkex.addNS(self.text_span,'svg'),{inkex.addNS('space','xml'):'preserve'})
newspan.set(inkex.addNS('role', 'sodipodi'), node.get('{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}role'))
if (node.tag == '{http://www.w3.org/2000/svg}text' or node.tag == '{http://www.w3.org/2000/svg}flowPara'):
if __name__ == '__main__':
e = Merge()
e.affect()
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99