final boolean useXMLBase = sop.getUseXMLBase();
final boolean prettyPrint = sop.getPrettyPrint();
sop = null;
final SVGDocument svgDoc = svgCanvas.getSVGDocument();
if (svgDoc == null) return;
statusBar.setMessage(resources.getString("Message.saveAs"));
currentSavePath = f;
OutputStreamWriter w = null;
try {
OutputStream tos = null;
tos = new FileOutputStream(f);
tos = new BufferedOutputStream(tos);
w = new OutputStreamWriter(tos, "utf-8");
} catch (Exception ex) {
userAgent.displayError(ex);
return;
}
final OutputStreamWriter writer = w;
final Runnable doneRun = new Runnable() {
public void run() {
String doneStr = resources.getString("Message.done");
statusBar.setMessage(doneStr);
}
};
Runnable r = new Runnable() {
public void run() {
try {
// Write standard XML header.
writer.write
("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
writer.write (EOL);
Node fc = svgDoc.getFirstChild();
if (fc.getNodeType() != Node.DOCUMENT_TYPE_NODE) {
// Not DT node in Document, so
// provide Document Type dec.
writer.write ("<!DOCTYPE svg PUBLIC '");
writer.write (SVGConstants.SVG_PUBLIC_ID);
writer.write ("' '");
writer.write (SVGConstants.SVG_SYSTEM_ID);
writer.write ("'>");
writer.write (EOL);
writer.write (EOL);
}
Element root = svgDoc.getRootElement();
boolean doXMLBase = useXMLBase;
if (root.hasAttributeNS
(XMLConstants.XML_NAMESPACE_URI, "base"))
doXMLBase = false;
if (doXMLBase) {
root.setAttributeNS
(XMLConstants.XML_NAMESPACE_URI,
"xml:base",
svgDoc.getURL());
}
if (prettyPrint) {
SVGTranscoder trans = new SVGTranscoder();
trans.transcode(new TranscoderInput(svgDoc),