Fixed bug #12052 - design changes to the implemenation of the editor charset menu. The charset information is now pushed down to the nsIDocument rather than being stored in the nsEditor component.
git-svn-id: svn://10.0.0.236/trunk@43908 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -149,7 +149,6 @@ nsEditor::nsEditor()
|
||||
, mDocDirtyState(-1)
|
||||
, mDoc(nsnull)
|
||||
, mPrefs(nsnull)
|
||||
, mDocCharset("ISO-8859-1")
|
||||
{
|
||||
//initialize member variables here
|
||||
NS_INIT_REFCNT();
|
||||
@@ -415,7 +414,8 @@ NS_IMETHODIMP nsEditor::SaveDocument(PRBool saveAs, PRBool saveCopy)
|
||||
}
|
||||
}
|
||||
|
||||
rv = diskDoc->SaveFile(&docFileSpec, replacing, saveCopy, nsIDiskDocument::eSaveFileHTML, mDocCharset);
|
||||
nsAutoString useDocCharset("");
|
||||
rv = diskDoc->SaveFile(&docFileSpec, replacing, saveCopy, nsIDiskDocument::eSaveFileHTML,useDocCharset);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
@@ -729,19 +729,48 @@ nsEditor::GetDocumentModified(PRBool *outDocModified)
|
||||
NS_IMETHODIMP
|
||||
nsEditor::GetDocumentCharacterSet(PRUnichar** characterSet)
|
||||
{
|
||||
*characterSet = mDocCharset.ToNewUnicode();
|
||||
return NS_OK;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsString character_set;
|
||||
|
||||
if (characterSet==nsnull) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
rv = GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
presShell->GetDocument(getter_AddRefs(doc));
|
||||
if (doc ) {
|
||||
rv = doc->GetDocumentCharacterSet(character_set);
|
||||
if (NS_SUCCEEDED(rv)) *characterSet=character_set.ToNewUnicode();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
|
||||
{
|
||||
if (characterSet!=NULL) {
|
||||
mDocCharset = characterSet;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsString character_set = characterSet;
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
if (characterSet==nsnull) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
rv = GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
presShell->GetDocument(getter_AddRefs(doc));
|
||||
if (doc ) {
|
||||
return doc->SetDocumentCharacterSet(character_set);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2883,10 +2912,9 @@ nsEditor::GetFirstTextNode(nsIDOMNode *aNode, nsIDOMNode **aRetNode)
|
||||
NS_IMETHODIMP
|
||||
nsEditor::SetInputMethodText(const nsString& aStringToInsert, nsIPrivateTextRangeList *aTextRangeList)
|
||||
{
|
||||
IMETextTxn *txn;
|
||||
nsresult result;
|
||||
|
||||
result = CreateTxnForIMEText(aStringToInsert,aTextRangeList,&txn); // insert at the current selection
|
||||
IMETextTxn *txn;
|
||||
|
||||
nsresult result = CreateTxnForIMEText(aStringToInsert,aTextRangeList,&txn); // insert at the current selection
|
||||
if ((NS_SUCCEEDED(result)) && txn) {
|
||||
BeginUpdateViewBatch();
|
||||
result = Do(txn);
|
||||
|
||||
@@ -609,8 +609,6 @@ protected:
|
||||
// Services are not nsCOMPtr friendly
|
||||
nsIPref* mPrefs;
|
||||
|
||||
//Document 'SaveAs' charset
|
||||
nsString mDocCharset;
|
||||
static PRInt32 gInstanceCount;
|
||||
|
||||
friend PRBool NSCanUnload(nsISupports* serviceMgr);
|
||||
|
||||
@@ -149,7 +149,6 @@ nsEditor::nsEditor()
|
||||
, mDocDirtyState(-1)
|
||||
, mDoc(nsnull)
|
||||
, mPrefs(nsnull)
|
||||
, mDocCharset("ISO-8859-1")
|
||||
{
|
||||
//initialize member variables here
|
||||
NS_INIT_REFCNT();
|
||||
@@ -415,7 +414,8 @@ NS_IMETHODIMP nsEditor::SaveDocument(PRBool saveAs, PRBool saveCopy)
|
||||
}
|
||||
}
|
||||
|
||||
rv = diskDoc->SaveFile(&docFileSpec, replacing, saveCopy, nsIDiskDocument::eSaveFileHTML, mDocCharset);
|
||||
nsAutoString useDocCharset("");
|
||||
rv = diskDoc->SaveFile(&docFileSpec, replacing, saveCopy, nsIDiskDocument::eSaveFileHTML,useDocCharset);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
@@ -729,19 +729,48 @@ nsEditor::GetDocumentModified(PRBool *outDocModified)
|
||||
NS_IMETHODIMP
|
||||
nsEditor::GetDocumentCharacterSet(PRUnichar** characterSet)
|
||||
{
|
||||
*characterSet = mDocCharset.ToNewUnicode();
|
||||
return NS_OK;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsString character_set;
|
||||
|
||||
if (characterSet==nsnull) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
rv = GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
presShell->GetDocument(getter_AddRefs(doc));
|
||||
if (doc ) {
|
||||
rv = doc->GetDocumentCharacterSet(character_set);
|
||||
if (NS_SUCCEEDED(rv)) *characterSet=character_set.ToNewUnicode();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
|
||||
{
|
||||
if (characterSet!=NULL) {
|
||||
mDocCharset = characterSet;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsString character_set = characterSet;
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
if (characterSet==nsnull) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
rv = GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
presShell->GetDocument(getter_AddRefs(doc));
|
||||
if (doc ) {
|
||||
return doc->SetDocumentCharacterSet(character_set);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2883,10 +2912,9 @@ nsEditor::GetFirstTextNode(nsIDOMNode *aNode, nsIDOMNode **aRetNode)
|
||||
NS_IMETHODIMP
|
||||
nsEditor::SetInputMethodText(const nsString& aStringToInsert, nsIPrivateTextRangeList *aTextRangeList)
|
||||
{
|
||||
IMETextTxn *txn;
|
||||
nsresult result;
|
||||
|
||||
result = CreateTxnForIMEText(aStringToInsert,aTextRangeList,&txn); // insert at the current selection
|
||||
IMETextTxn *txn;
|
||||
|
||||
nsresult result = CreateTxnForIMEText(aStringToInsert,aTextRangeList,&txn); // insert at the current selection
|
||||
if ((NS_SUCCEEDED(result)) && txn) {
|
||||
BeginUpdateViewBatch();
|
||||
result = Do(txn);
|
||||
|
||||
@@ -609,8 +609,6 @@ protected:
|
||||
// Services are not nsCOMPtr friendly
|
||||
nsIPref* mPrefs;
|
||||
|
||||
//Document 'SaveAs' charset
|
||||
nsString mDocCharset;
|
||||
static PRInt32 gInstanceCount;
|
||||
|
||||
friend PRBool NSCanUnload(nsISupports* serviceMgr);
|
||||
|
||||
Reference in New Issue
Block a user