Fixed Issue 738: Extra instances of same <symbol> redefine path again

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1879 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2010-12-01 21:20:52 +00:00
parent aafe843485
commit 8b19adc777
1 changed files with 75 additions and 54 deletions

View File

@ -530,7 +530,10 @@ var all_layers = [],
current_mode = "select",
// String with the current direction in which an element is being resized
current_resize_mode = "none";
current_resize_mode = "none",
// Object with IDs for imported files, to see if one was already added
import_ids = {};
// Current text style properties
var cur_text = all_properties.text,
@ -6803,7 +6806,16 @@ this.setSvgString = function(xmlString) {
// was obtained
// * import should happen in top-left of current zoomed viewport
this.importSvgString = function(xmlString) {
try {
// Get unique ID
var uid = svgedit.utilities.encode64(xmlString.length + xmlString).substr(0,32);
if(import_ids[uid]) {
var symbol = import_ids[uid].symbol;
var ts = import_ids[uid].xform;
} else {
// convert string into XML document
var newDoc = svgedit.utilities.text2xml(xmlString);
@ -6857,12 +6869,21 @@ this.importSvgString = function(xmlString) {
var attr = attrs[i];
symbol.setAttribute(attr.nodeName, attr.nodeValue);
}
// var symbol = svg;
// var symbol = svg;
symbol.id = getNextId();
// Store data
import_ids[uid] = {
symbol: symbol,
xform: ts
}
findDefs().appendChild(symbol);
}
var use_el = svgdoc.createElementNS(svgns, "use");
setHref(use_el, "#" + symbol.id);
findDefs().appendChild(symbol);
(current_group || current_layer).appendChild(use_el);
use_el.id = getNextId();