rem: var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); 
add: var ioService = GetIOService(); 
context: function SaveDocument(aSaveAs, aSaveCopy, aMimeType){  if (!aMimeType || aMimeType == "" || !window.editorShell)    throw NS_ERROR_NOT_INITIALIZED;  var editorDoc = window.editorShell.editorDocument;  if (!editorDoc)    throw NS_ERROR_NOT_INITIALIZED;  // if we don't have the right editor type bail (we handle text and html)  var editorType = window.editorShell.editorType;//  var isMailType = (editorType == "textmail" || editorType == "htmlmail")  if (editorType != "text" && editorType != "html" && editorType != "htmlmail")    throw NS_ERROR_NOT_IMPLEMENTED;  var saveAsTextFile = window.editorShell.isSupportedTextType(aMimeType);  // check if the file is to be saved in a format we don't understand; if so, bail  if (aMimeType != "text/html" && !saveAsTextFile)    throw NS_ERROR_NOT_IMPLEMENTED;  if (saveAsTextFile)    aMimeType = "text/plain";  var urlstring = GetDocumentURI(editorDoc);  var mustShowFileDialog = (aSaveAs || IsUrlAboutBlank(urlstring) || (urlstring == ""));  var replacing = !aSaveAs;  var titleChanged = false;  var doUpdateURL = false;  var tempLocalFile = null;  if (mustShowFileDialog)  {	  try {	    var domhtmldoc = editorDoc.QueryInterface(Components.interfaces.nsIDOMHTMLDocument);	    // Prompt for title if we are saving to HTML	    if (!saveAsTextFile && (editorType == "html"))	    {	      var userContinuing = PromptAndSetTitleIfNone(domhtmldoc); // not cancel	      if (!userContinuing)	        return false;	    }	    var dialogResult = PromptForSaveLocation(saveAsTextFile, editorType, aMimeType, domhtmldoc, urlstring);	    if (dialogResult.filepickerClick == nsIFilePicker.returnCancel)	      return false;	    replacing = (dialogResult.filepickerClick == nsIFilePicker.returnReplace);	    urlstring = dialogResult.resultingURIString;	    tempLocalFile = dialogResult.resultingLocalFile;       // update the new URL for the webshell unless we are saving a copy      if (!aSaveCopy)        doUpdateURL = true;   } catch (e) {  return false; }  } // mustShowFileDialog  try {    var imeEditor = window.editorShell.editor.QueryInterface(Components.interfaces.nsIEditorIMESupport);    if (imeEditor)      imeEditor.ForceCompositionEnd();    } catch (e) {}  var success = true;  try {    var docURI = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);    docURI.spec = urlstring;    if (!tempLocalFile)    {      tempLocalFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);      var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);      ioService.initFileFromURLSpec(tempLocalFile, urlstring);    }    var parentDir;    try {      var lastSlash = urlstring.lastIndexOf("\/");      if (lastSlash != -1)      {        var parentDirString = urlstring.slice(0, lastSlash + 1);  // include last slash        parentDir = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);        parentDir.spec = parentDirString;      }    } catch(e) { parentDir = null; }    var wrapColumn = GetWrapColumn();    var outputFlags = GetOutputFlags(aMimeType, wrapColumn);    // we should supply a parent directory if/when we turn on functionality to save related documents    var persistAPI = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Components.interfaces.nsIWebBrowserPersist);    persistAPI.progressListener = gEditorOutputProgressListener;    persistAPI.saveDocument(editorDoc, tempLocalFile, parentDir, aMimeType, outputFlags, wrapColumn);  }  catch (e)  {    var saveDocStr = GetString("SaveDocument");    var failedStr = GetString("SaveFileFailed");    AlertWithTitle(saveDocStr, failedStr);    success = false;  }  try {    window.editorShell.doAfterSave(doUpdateURL, urlstring);  // we need to update the url before notifying listeners    if (!aSaveCopy && success)      window.editorShell.editor.ResetModificationCount();  // this should cause notification to listeners that document has changed  } catch (e) {}  return success;}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/39c9942b8ce1ac7539a96c0525b1a84fba6a448d/ComposerCommands.js/buggy/editor/ui/composer/content/ComposerCommands.js