Fixed issue 470: Support loading files with unit-based width/height
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1371 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
b1463213e2
commit
9590cf67f5
|
@ -5527,33 +5527,34 @@ function BatchCommand(text) {
|
||||||
if(!support.goodDecimals) {
|
if(!support.goodDecimals) {
|
||||||
canvas.fixOperaXML(svgcontent, newDoc.documentElement);
|
canvas.fixOperaXML(svgcontent, newDoc.documentElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
svgcontent.id= 'svgcontent';
|
|
||||||
|
|
||||||
|
var content = $(svgcontent);
|
||||||
|
|
||||||
// determine proper size
|
// determine proper size
|
||||||
var w, h;
|
var w, h;
|
||||||
if (svgcontent.getAttribute("viewBox")) {
|
if (content.attr("viewBox")) {
|
||||||
var vb = svgcontent.getAttribute("viewBox").split(' ');
|
var vb = content.attr("viewBox").split(' ');
|
||||||
w = vb[2];
|
w = vb[2];
|
||||||
h = vb[3];
|
h = vb[3];
|
||||||
}
|
}
|
||||||
// handle old content that doesn't have a viewBox
|
// handle content that doesn't have a viewBox
|
||||||
else {
|
else {
|
||||||
w = svgcontent.getAttribute("width");
|
var dims = content.attr(["width", "height"]);
|
||||||
h = svgcontent.getAttribute("height");
|
w = convertToNum('width', dims.width);
|
||||||
|
h = convertToNum('height', dims.height);
|
||||||
// svgcontent.setAttribute("viewBox", ["0", "0", w, h].join(" "));
|
// svgcontent.setAttribute("viewBox", ["0", "0", w, h].join(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
svgcontent.setAttribute('width', w);
|
content.attr({
|
||||||
svgcontent.setAttribute('height', h);
|
id: 'svgcontent',
|
||||||
svgcontent.setAttribute('overflow', 'visible');
|
width: w,
|
||||||
|
height: h,
|
||||||
|
overflow: 'visible'
|
||||||
|
});
|
||||||
|
|
||||||
batchCmd.addSubCommand(new InsertElementCommand(svgcontent));
|
batchCmd.addSubCommand(new InsertElementCommand(svgcontent));
|
||||||
// update root to the correct size
|
// update root to the correct size
|
||||||
var changes = {};
|
var changes = content.attr(["width", "height"]);
|
||||||
changes['width'] = svgcontent.getAttribute('width');
|
|
||||||
changes['height'] = svgcontent.getAttribute('height');
|
|
||||||
// svgroot.setAttribute('width', w);
|
|
||||||
// svgroot.setAttribute('height', h);
|
|
||||||
batchCmd.addSubCommand(new ChangeElementCommand(svgroot, changes));
|
batchCmd.addSubCommand(new ChangeElementCommand(svgroot, changes));
|
||||||
|
|
||||||
// reset zoom
|
// reset zoom
|
||||||
|
|
Loading…
Reference in New Issue