*/
private SVGDocument toSVG(final IDrawing drawing, final double incr) {
// Creation of the SVG document.
final List<IShape> shapes;
final SVGDocument doc = new SVGDocument();
final SVGSVGElement root = doc.getFirstChild();
final SVGGElement g = new SVGGElement(doc);
SVGElement elt;
if(onlySelection)
shapes = drawing.getSelection().getShapes();
else shapes = drawing.getShapes();
root.appendChild(g);
root.setAttribute("xmlns:"+LNamespace.LATEXDRAW_NAMESPACE, LNamespace.LATEXDRAW_NAMESPACE_URI);//$NON-NLS-1$
root.appendChild(new SVGDefsElement(doc));
try {
for(final IShape sh : shapes) {
// For each shape an SVG element is created.
elt = SVGShapesFactory.INSTANCE.createSVGElement(sh, doc);
if(elt!=null)
g.appendChild(elt);
setProgress((int)Math.min(100., getProgress()+incr));
}
}catch(final Exception ex) { BadaboomCollector.INSTANCE.add(ex); }
// Setting SVG attributes to the created document.
root.setAttribute(SVGAttributes.SVG_VERSION, "1.1");//$NON-NLS-1$
root.setAttribute(SVGAttributes.SVG_BASE_PROFILE, "full");//$NON-NLS-1$
return doc;
}