Fix bug #11687 - [Dogfood] Enable ender to save documents in encodings other than ISO-8859-1. Approved by chofmann@netscape.com, reviewed by buster@netscape.com.

This commit is contained in:
tague%netscape.com 1999-08-13 22:26:50 +00:00
Родитель abc1ed2795
Коммит a15b0b4b19
11 изменённых файлов: 113 добавлений и 5 удалений

Просмотреть файл

@ -155,6 +155,7 @@ nsEditor::nsEditor()
, mDocDirtyState(-1)
, mDoc(nsnull)
, mPrefs(nsnull)
, mDocCharset("ISO-8859-1")
#ifdef ENABLE_JS_EDITOR_LOG
, mJSEditorLog(nsnull)
, mJSTxnLog(nsnull)
@ -430,8 +431,7 @@ NS_IMETHODIMP nsEditor::SaveDocument(PRBool saveAs, PRBool saveCopy)
}
}
nsAutoString charsetStr("");
rv = diskDoc->SaveFile(&docFileSpec, replacing, saveCopy, nsIDiskDocument::eSaveFileHTML, charsetStr);
rv = diskDoc->SaveFile(&docFileSpec, replacing, saveCopy, nsIDiskDocument::eSaveFileHTML, mDocCharset);
if (NS_FAILED(rv))
{
@ -805,6 +805,24 @@ nsEditor::GetDocumentModified(PRBool *outDocModified)
return NS_OK;
}
NS_IMETHODIMP
nsEditor::GetDocumentCharacterSet(PRUnichar** characterSet)
{
*characterSet = mDocCharset.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP
nsEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
{
if (characterSet!=NULL) {
mDocCharset = characterSet;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
/*
NS_IMETHODIMP

Просмотреть файл

@ -134,6 +134,8 @@ public:
NS_IMETHOD Save();
NS_IMETHOD SaveAs(PRBool aSavingCopy);
NS_IMETHOD GetDocumentModified(PRBool *outDocModified);
NS_IMETHOD GetDocumentCharacterSet(PRUnichar** characterSet);
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet);
// these are pure virtual in this base class
NS_IMETHOD Cut() = 0;
@ -619,6 +621,9 @@ protected:
// Services are not nsCOMPtr friendly
nsIPref* mPrefs;
//Document 'SaveAs' charset
nsString mDocCharset;
#ifdef ENABLE_JS_EDITOR_LOG
nsJSEditorLog *mJSEditorLog;
nsJSTxnLog *mJSTxnLog;

Просмотреть файл

@ -1520,6 +1520,29 @@ nsEditorShell::FindNext()
return DoFind(PR_TRUE);
}
NS_IMETHODIMP
nsEditorShell::GetDocumentCharacterSet(PRUnichar** characterSet)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
if (editor)
return editor->GetDocumentCharacterSet(characterSet);
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsEditorShell::SetDocumentCharacterSet(const PRUnichar* characterSet)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
if (editor)
return editor->SetDocumentCharacterSet(characterSet);
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsEditorShell::GetContentsAs(const PRUnichar *format, PRUint32 flags,
PRUnichar **contentsAs)

Просмотреть файл

@ -128,6 +128,10 @@ class nsEditorShell : public nsIEditorShell,
NS_IMETHOD Find();
NS_IMETHOD FindNext();
/* Charset Menu */
NS_IMETHOD GetDocumentCharacterSet(PRUnichar **characterSet);
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar *characterSet);
/* void InsertText (in wstring textToInsert); */
NS_IMETHOD InsertText(const PRUnichar *textToInsert);
NS_IMETHOD InsertSource(const PRUnichar *sourceToInsert);

Просмотреть файл

@ -1520,6 +1520,29 @@ nsEditorShell::FindNext()
return DoFind(PR_TRUE);
}
NS_IMETHODIMP
nsEditorShell::GetDocumentCharacterSet(PRUnichar** characterSet)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
if (editor)
return editor->GetDocumentCharacterSet(characterSet);
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsEditorShell::SetDocumentCharacterSet(const PRUnichar* characterSet)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
if (editor)
return editor->SetDocumentCharacterSet(characterSet);
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsEditorShell::GetContentsAs(const PRUnichar *format, PRUint32 flags,
PRUnichar **contentsAs)

Просмотреть файл

@ -128,6 +128,10 @@ class nsEditorShell : public nsIEditorShell,
NS_IMETHOD Find();
NS_IMETHOD FindNext();
/* Charset Menu */
NS_IMETHOD GetDocumentCharacterSet(PRUnichar **characterSet);
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar *characterSet);
/* void InsertText (in wstring textToInsert); */
NS_IMETHOD InsertText(const PRUnichar *textToInsert);
NS_IMETHOD InsertSource(const PRUnichar *sourceToInsert);

Просмотреть файл

@ -100,6 +100,10 @@ interface nsIEditorShell : nsISupports
void Find();
void FindNext();
/* Charset Menu */
wstring GetDocumentCharacterSet();
void SetDocumentCharacterSet(in wstring characterSet);
/* Structure change */
void InsertText(in wstring textToInsert);

Просмотреть файл

@ -155,6 +155,7 @@ nsEditor::nsEditor()
, mDocDirtyState(-1)
, mDoc(nsnull)
, mPrefs(nsnull)
, mDocCharset("ISO-8859-1")
#ifdef ENABLE_JS_EDITOR_LOG
, mJSEditorLog(nsnull)
, mJSTxnLog(nsnull)
@ -430,8 +431,7 @@ NS_IMETHODIMP nsEditor::SaveDocument(PRBool saveAs, PRBool saveCopy)
}
}
nsAutoString charsetStr("");
rv = diskDoc->SaveFile(&docFileSpec, replacing, saveCopy, nsIDiskDocument::eSaveFileHTML, charsetStr);
rv = diskDoc->SaveFile(&docFileSpec, replacing, saveCopy, nsIDiskDocument::eSaveFileHTML, mDocCharset);
if (NS_FAILED(rv))
{
@ -805,6 +805,24 @@ nsEditor::GetDocumentModified(PRBool *outDocModified)
return NS_OK;
}
NS_IMETHODIMP
nsEditor::GetDocumentCharacterSet(PRUnichar** characterSet)
{
*characterSet = mDocCharset.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP
nsEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
{
if (characterSet!=NULL) {
mDocCharset = characterSet;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
/*
NS_IMETHODIMP

Просмотреть файл

@ -134,6 +134,8 @@ public:
NS_IMETHOD Save();
NS_IMETHOD SaveAs(PRBool aSavingCopy);
NS_IMETHOD GetDocumentModified(PRBool *outDocModified);
NS_IMETHOD GetDocumentCharacterSet(PRUnichar** characterSet);
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet);
// these are pure virtual in this base class
NS_IMETHOD Cut() = 0;
@ -619,6 +621,9 @@ protected:
// Services are not nsCOMPtr friendly
nsIPref* mPrefs;
//Document 'SaveAs' charset
nsString mDocCharset;
#ifdef ENABLE_JS_EDITOR_LOG
nsJSEditorLog *mJSEditorLog;
nsJSTxnLog *mJSTxnLog;

Просмотреть файл

@ -125,7 +125,11 @@ public:
/** Returns true if the document is modifed and needs saving */
NS_IMETHOD GetDocumentModified(PRBool *outDocModified)=0;
/** Returns the current 'Save' document character set */
NS_IMETHOD GetDocumentCharacterSet(PRUnichar** characterSet)=0;
/** Sets the current 'Save' document character set */
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet)=0;
/* ------------ Transaction methods -------------- */

Просмотреть файл

@ -263,7 +263,7 @@ function EditorShowClipboard()
function EditorSetDocumentCharacterSet(aCharset)
{
dump(aCharset);
editorShell.editorDocument.SetDocumentCharacterSet(aCharset);
editorShell.SetDocumentCharacterSet(aCharset);
}