Fix for 62039 -- change methods to use const PRUnichar* instead of nsStrings for NS_LITERAL_STRING loving. r=cmanske, akkana, sr=kin

This commit is contained in:
sfraser%netscape.com 2000-12-06 20:48:35 +00:00
Родитель df503cea42
Коммит bea0a7e198
4 изменённых файлов: 80 добавлений и 114 удалений

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

@ -1732,10 +1732,11 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
PRUnichar *titleUnicode; PRUnichar *titleUnicode;
nsAutoString captionStr, msgStr1, msgStr2; nsAutoString captionStr, msgStr1, msgStr2;
GetBundleString(NS_ConvertASCIItoUCS2("DocumentTitle"), captionStr); GetBundleString(NS_LITERAL_STRING("DocumentTitle"), captionStr);
GetBundleString(NS_ConvertASCIItoUCS2("NeedDocTitle"), msgStr1); GetBundleString(NS_LITERAL_STRING("NeedDocTitle"), msgStr1);
GetBundleString(NS_ConvertASCIItoUCS2("DocTitleHelp"), msgStr2); GetBundleString(NS_LITERAL_STRING("DocTitleHelp"), msgStr2);
msgStr1 += NS_ConvertASCIItoUCS2("\n") + msgStr2; msgStr1 += PRUnichar('\n');
msgStr1 += msgStr2;
PRBool retVal = PR_FALSE; PRBool retVal = PR_FALSE;
if(!mContentWindow) if(!mContentWindow)
@ -1768,7 +1769,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
if (NS_SUCCEEDED(res) && fileWidget) if (NS_SUCCEEDED(res) && fileWidget)
{ {
nsAutoString promptString; nsAutoString promptString;
GetBundleString(NS_ConvertASCIItoUCS2("SaveDocumentAs"), promptString); GetBundleString(NS_LITERAL_STRING("SaveDocumentAs"), promptString);
nsString* titles = nsnull; nsString* titles = nsnull;
nsString* filters = nsnull; nsString* filters = nsnull;
@ -1792,12 +1793,12 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
nextTitle = titles; nextTitle = titles;
nextFilter = filters; nextFilter = filters;
// The names of the file types are localizable // The names of the file types are localizable
GetBundleString(NS_ConvertASCIItoUCS2("HTMLFiles"), HTMLFiles); GetBundleString(NS_LITERAL_STRING("HTMLFiles"), HTMLFiles);
GetBundleString(NS_ConvertASCIItoUCS2("TextFiles"), TextFiles); GetBundleString(NS_LITERAL_STRING("TextFiles"), TextFiles);
if (! (HTMLFiles.Length() == 0 || TextFiles.Length() == 0)) if (! (HTMLFiles.Length() == 0 || TextFiles.Length() == 0))
{ {
nsAutoString allFilesStr; nsAutoString allFilesStr;
GetBundleString(NS_ConvertASCIItoUCS2("AllFiles"), allFilesStr); GetBundleString(NS_LITERAL_STRING("AllFiles"), allFilesStr);
*nextTitle++ = HTMLFiles; *nextTitle++ = HTMLFiles;
(*nextFilter++).AssignWithConversion("*.htm; *.html; *.shtml"); (*nextFilter++).AssignWithConversion("*.htm; *.html; *.shtml");
@ -1940,8 +1941,8 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
if (NS_FAILED(res)) if (NS_FAILED(res))
{ {
nsAutoString saveDocStr, failedStr; nsAutoString saveDocStr, failedStr;
GetBundleString(NS_ConvertASCIItoUCS2("SaveDocument"), saveDocStr); GetBundleString(NS_LITERAL_STRING("SaveDocument"), saveDocStr);
GetBundleString(NS_ConvertASCIItoUCS2("SaveFileFailed"), failedStr); GetBundleString(NS_LITERAL_STRING("SaveFileFailed"), failedStr);
Alert(saveDocStr, failedStr); Alert(saveDocStr, failedStr);
} else { } else {
// File was saved successfully // File was saved successfully
@ -2003,7 +2004,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindowInternal *parent, const PRUnichar *fi
nsCOMPtr<nsIFileWidget> fileWidget; nsCOMPtr<nsIFileWidget> fileWidget;
nsAutoString HTMLTitle; nsAutoString HTMLTitle;
GetBundleString(NS_ConvertASCIItoUCS2("OpenHTMLFile"), HTMLTitle); GetBundleString(NS_LITERAL_STRING("OpenHTMLFile"), HTMLTitle);
// An empty string should just result in "Open" for the dialog // An empty string should just result in "Open" for the dialog
nsAutoString title; nsAutoString title;
@ -2012,7 +2013,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindowInternal *parent, const PRUnichar *fi
title = HTMLTitle; title = HTMLTitle;
} else { } else {
nsAutoString ImageTitle; nsAutoString ImageTitle;
GetBundleString(NS_ConvertASCIItoUCS2("SelectImageFile"), ImageTitle); GetBundleString(NS_LITERAL_STRING("SelectImageFile"), ImageTitle);
if (ImageTitle.Length() > 0 && imgFilter) if (ImageTitle.Length() > 0 && imgFilter)
title = ImageTitle; title = ImageTitle;
@ -2045,9 +2046,9 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindowInternal *parent, const PRUnichar *fi
nextTitle = titles; nextTitle = titles;
nextFilter = filters; nextFilter = filters;
GetBundleString(NS_ConvertASCIItoUCS2("HTMLFiles"), tempStr); GetBundleString(NS_LITERAL_STRING("HTMLFiles"), tempStr);
*nextTitle++ = tempStr; *nextTitle++ = tempStr;
GetBundleString(NS_ConvertASCIItoUCS2("TextFiles"), tempStr); GetBundleString(NS_LITERAL_STRING("TextFiles"), tempStr);
*nextTitle++ = tempStr; *nextTitle++ = tempStr;
(*nextFilter++).AssignWithConversion("*.htm; *.html; *.shtml"); (*nextFilter++).AssignWithConversion("*.htm; *.html; *.shtml");
(*nextFilter++).AssignWithConversion("*.txt"); (*nextFilter++).AssignWithConversion("*.txt");
@ -2059,12 +2060,12 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindowInternal *parent, const PRUnichar *fi
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
nextTitle = titles; nextTitle = titles;
nextFilter = filters; nextFilter = filters;
GetBundleString(NS_ConvertASCIItoUCS2("IMGFiles"), tempStr); GetBundleString(NS_LITERAL_STRING("IMGFiles"), tempStr);
*nextTitle++ = tempStr; *nextTitle++ = tempStr;
(*nextFilter++).AssignWithConversion("*.gif; *.jpg; *.jpeg; *.png; *.*"); (*nextFilter++).AssignWithConversion("*.gif; *.jpg; *.jpeg; *.png; *.*");
fileWidget->SetFilterList(2, titles, filters); fileWidget->SetFilterList(2, titles, filters);
} }
GetBundleString(NS_ConvertASCIItoUCS2("AllFiles"), tempStr); GetBundleString(NS_LITERAL_STRING("AllFiles"), tempStr);
*nextTitle++ = tempStr; *nextTitle++ = tempStr;
(*nextFilter++).AssignWithConversion("*.*"); (*nextFilter++).AssignWithConversion("*.*");
// First param should be Parent window, but type is nsIWidget* // First param should be Parent window, but type is nsIWidget*
@ -2108,7 +2109,7 @@ nsEditorShell::UpdateWindowTitle()
res = GetDocumentTitleString(windowCaption); res = GetDocumentTitleString(windowCaption);
// If title is empty, use "untitled" // If title is empty, use "untitled"
if (windowCaption.Length() == 0) if (windowCaption.Length() == 0)
GetBundleString(NS_ConvertASCIItoUCS2("untitled"), windowCaption); GetBundleString(NS_LITERAL_STRING("untitled"), windowCaption);
// Append just the 'leaf' filename to the Doc. Title for the window caption // Append just the 'leaf' filename to the Doc. Title for the window caption
if (NS_SUCCEEDED(res)) if (NS_SUCCEEDED(res))
@ -2951,44 +2952,28 @@ nsEditorShell::FindNext()
/* Get localized strings for UI from the Editor's string bundle */ /* Get localized strings for UI from the Editor's string bundle */
// Use this version from JavaScript: // Use this version from JavaScript:
NS_IMETHODIMP NS_IMETHODIMP
nsEditorShell::GetString(const PRUnichar *name, PRUnichar **_retval) nsEditorShell::GetString(const PRUnichar *stringName, PRUnichar **_retval)
{ {
if (!name || !_retval) if (!stringName || !_retval)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
// Don't fail, just return an empty string *_retval = NULL;
nsAutoString empty;
if (mStringBundle) NS_ASSERTION(mStringBundle, "No string bundle!");
{ if (!mStringBundle) return NS_ERROR_NOT_INITIALIZED;
if (NS_FAILED(mStringBundle->GetStringFromName(name, _retval)))
*_retval = empty.ToNewUnicode();
return NS_OK; return mStringBundle->GetStringFromName(stringName, _retval);
} else {
*_retval = empty.ToNewUnicode();
return NS_ERROR_NOT_INITIALIZED;
}
} }
// Use this version within the shell: // Use this version within the shell:
void nsEditorShell::GetBundleString(const nsString& name, nsString &outString) void nsEditorShell::GetBundleString(const PRUnichar *stringName, nsString &outString)
{ {
if (mStringBundle && name.Length() > 0) outString.Truncate();
{
PRUnichar *ptrv = nsnull;
if (NS_SUCCEEDED(mStringBundle->GetStringFromName(name.GetUnicode(), &ptrv)))
outString = ptrv;
else
outString.SetLength(0);
nsMemory::Free(ptrv); nsXPIDLString tempString;
} if (NS_SUCCEEDED(GetString(stringName, getter_Copies(tempString))) && tempString)
else outString = tempString.get();
{
outString.SetLength(0);
}
} }
// Utilities to bring up a Yes/No/Cancel dialog. // Utilities to bring up a Yes/No/Cancel dialog.
@ -3035,7 +3020,7 @@ nsEditorShell::ConfirmWithCancel(const nsString& aTitle, const nsString& aQuesti
yesStr.Assign(*aYesString); yesStr.Assign(*aYesString);
else else
// We always want a "Yes" string, so supply the default // We always want a "Yes" string, so supply the default
GetBundleString(NS_ConvertASCIItoUCS2("Yes"), yesStr); GetBundleString(NS_LITERAL_STRING("Yes"), yesStr);
if (aNoString && aNoString->Length() > 0) if (aNoString && aNoString->Length() > 0)
{ {
@ -3050,7 +3035,7 @@ nsEditorShell::ConfirmWithCancel(const nsString& aTitle, const nsString& aQuesti
block->SetInt( nsICommonDialogs::eNumberButtons, numberOfButtons ); block->SetInt( nsICommonDialogs::eNumberButtons, numberOfButtons );
nsAutoString cancelStr; nsAutoString cancelStr;
GetBundleString(NS_ConvertASCIItoUCS2("Cancel"), cancelStr); GetBundleString(NS_LITERAL_STRING("Cancel"), cancelStr);
block->SetString( nsICommonDialogs::eDialogTitle, aTitle.GetUnicode() ); block->SetString( nsICommonDialogs::eDialogTitle, aTitle.GetUnicode() );
//Note: "button0" is always Ok or Yes action, "button1" is Cancel //Note: "button0" is always Ok or Yes action, "button1" is Cancel
@ -5161,7 +5146,7 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* aChanne
if (mCloseWindowWhenLoaded && isRootDoc) if (mCloseWindowWhenLoaded && isRootDoc)
{ {
nsAutoString alertLabel, alertMessage; nsAutoString alertLabel, alertMessage;
GetBundleString(NS_ConvertASCIItoUCS2("Alert"), alertLabel); GetBundleString(NS_LITERAL_STRING("Alert"), alertLabel);
nsAutoString stringID; nsAutoString stringID;
switch (mCantEditReason) switch (mCantEditReason)
@ -5180,7 +5165,7 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* aChanne
break; break;
} }
GetBundleString(stringID, alertMessage); GetBundleString(stringID.GetUnicode(), alertMessage);
Alert(alertLabel, alertMessage); Alert(alertLabel, alertMessage);
nsCOMPtr<nsIBaseWindow> baseWindow; nsCOMPtr<nsIBaseWindow> baseWindow;
@ -5203,7 +5188,7 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* aChanne
} }
nsAutoString doneText; nsAutoString doneText;
GetBundleString(NS_ConvertASCIItoUCS2("LoadingDone"), doneText); GetBundleString(NS_LITERAL_STRING("LoadingDone"), doneText);
SetChromeAttribute(mDocShell, "statusText", "value", doneText); SetChromeAttribute(mDocShell, "statusText", "value", doneText);
return res; return res;

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

@ -141,11 +141,9 @@ class nsEditorShell : public nsIEditorShell,
EConfirmResult ConfirmWithCancel(const nsString& aTitle, const nsString& aQuestion, EConfirmResult ConfirmWithCancel(const nsString& aTitle, const nsString& aQuestion,
const nsString *aYesString, const nsString *aNoString); const nsString *aYesString, const nsString *aNoString);
// this returns an AddReffed nsIScriptContext. You must relase it. // Get a string from the string bundle file. If the string is not found
nsIScriptContext* GetScriptContext(nsIDOMWindowInternal * aWin); // this returns an empty string.
void GetBundleString(const PRUnichar *stringName, nsString &outString);
// Get a string from the string bundle file
void GetBundleString(const nsString& name, nsString &outString);
// Get the text of the <title> tag // Get the text of the <title> tag
nsresult GetDocumentTitleString(nsString& title); nsresult GetDocumentTitleString(nsString& title);

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

@ -1732,10 +1732,11 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
PRUnichar *titleUnicode; PRUnichar *titleUnicode;
nsAutoString captionStr, msgStr1, msgStr2; nsAutoString captionStr, msgStr1, msgStr2;
GetBundleString(NS_ConvertASCIItoUCS2("DocumentTitle"), captionStr); GetBundleString(NS_LITERAL_STRING("DocumentTitle"), captionStr);
GetBundleString(NS_ConvertASCIItoUCS2("NeedDocTitle"), msgStr1); GetBundleString(NS_LITERAL_STRING("NeedDocTitle"), msgStr1);
GetBundleString(NS_ConvertASCIItoUCS2("DocTitleHelp"), msgStr2); GetBundleString(NS_LITERAL_STRING("DocTitleHelp"), msgStr2);
msgStr1 += NS_ConvertASCIItoUCS2("\n") + msgStr2; msgStr1 += PRUnichar('\n');
msgStr1 += msgStr2;
PRBool retVal = PR_FALSE; PRBool retVal = PR_FALSE;
if(!mContentWindow) if(!mContentWindow)
@ -1768,7 +1769,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
if (NS_SUCCEEDED(res) && fileWidget) if (NS_SUCCEEDED(res) && fileWidget)
{ {
nsAutoString promptString; nsAutoString promptString;
GetBundleString(NS_ConvertASCIItoUCS2("SaveDocumentAs"), promptString); GetBundleString(NS_LITERAL_STRING("SaveDocumentAs"), promptString);
nsString* titles = nsnull; nsString* titles = nsnull;
nsString* filters = nsnull; nsString* filters = nsnull;
@ -1792,12 +1793,12 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
nextTitle = titles; nextTitle = titles;
nextFilter = filters; nextFilter = filters;
// The names of the file types are localizable // The names of the file types are localizable
GetBundleString(NS_ConvertASCIItoUCS2("HTMLFiles"), HTMLFiles); GetBundleString(NS_LITERAL_STRING("HTMLFiles"), HTMLFiles);
GetBundleString(NS_ConvertASCIItoUCS2("TextFiles"), TextFiles); GetBundleString(NS_LITERAL_STRING("TextFiles"), TextFiles);
if (! (HTMLFiles.Length() == 0 || TextFiles.Length() == 0)) if (! (HTMLFiles.Length() == 0 || TextFiles.Length() == 0))
{ {
nsAutoString allFilesStr; nsAutoString allFilesStr;
GetBundleString(NS_ConvertASCIItoUCS2("AllFiles"), allFilesStr); GetBundleString(NS_LITERAL_STRING("AllFiles"), allFilesStr);
*nextTitle++ = HTMLFiles; *nextTitle++ = HTMLFiles;
(*nextFilter++).AssignWithConversion("*.htm; *.html; *.shtml"); (*nextFilter++).AssignWithConversion("*.htm; *.html; *.shtml");
@ -1940,8 +1941,8 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
if (NS_FAILED(res)) if (NS_FAILED(res))
{ {
nsAutoString saveDocStr, failedStr; nsAutoString saveDocStr, failedStr;
GetBundleString(NS_ConvertASCIItoUCS2("SaveDocument"), saveDocStr); GetBundleString(NS_LITERAL_STRING("SaveDocument"), saveDocStr);
GetBundleString(NS_ConvertASCIItoUCS2("SaveFileFailed"), failedStr); GetBundleString(NS_LITERAL_STRING("SaveFileFailed"), failedStr);
Alert(saveDocStr, failedStr); Alert(saveDocStr, failedStr);
} else { } else {
// File was saved successfully // File was saved successfully
@ -2003,7 +2004,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindowInternal *parent, const PRUnichar *fi
nsCOMPtr<nsIFileWidget> fileWidget; nsCOMPtr<nsIFileWidget> fileWidget;
nsAutoString HTMLTitle; nsAutoString HTMLTitle;
GetBundleString(NS_ConvertASCIItoUCS2("OpenHTMLFile"), HTMLTitle); GetBundleString(NS_LITERAL_STRING("OpenHTMLFile"), HTMLTitle);
// An empty string should just result in "Open" for the dialog // An empty string should just result in "Open" for the dialog
nsAutoString title; nsAutoString title;
@ -2012,7 +2013,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindowInternal *parent, const PRUnichar *fi
title = HTMLTitle; title = HTMLTitle;
} else { } else {
nsAutoString ImageTitle; nsAutoString ImageTitle;
GetBundleString(NS_ConvertASCIItoUCS2("SelectImageFile"), ImageTitle); GetBundleString(NS_LITERAL_STRING("SelectImageFile"), ImageTitle);
if (ImageTitle.Length() > 0 && imgFilter) if (ImageTitle.Length() > 0 && imgFilter)
title = ImageTitle; title = ImageTitle;
@ -2045,9 +2046,9 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindowInternal *parent, const PRUnichar *fi
nextTitle = titles; nextTitle = titles;
nextFilter = filters; nextFilter = filters;
GetBundleString(NS_ConvertASCIItoUCS2("HTMLFiles"), tempStr); GetBundleString(NS_LITERAL_STRING("HTMLFiles"), tempStr);
*nextTitle++ = tempStr; *nextTitle++ = tempStr;
GetBundleString(NS_ConvertASCIItoUCS2("TextFiles"), tempStr); GetBundleString(NS_LITERAL_STRING("TextFiles"), tempStr);
*nextTitle++ = tempStr; *nextTitle++ = tempStr;
(*nextFilter++).AssignWithConversion("*.htm; *.html; *.shtml"); (*nextFilter++).AssignWithConversion("*.htm; *.html; *.shtml");
(*nextFilter++).AssignWithConversion("*.txt"); (*nextFilter++).AssignWithConversion("*.txt");
@ -2059,12 +2060,12 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindowInternal *parent, const PRUnichar *fi
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
nextTitle = titles; nextTitle = titles;
nextFilter = filters; nextFilter = filters;
GetBundleString(NS_ConvertASCIItoUCS2("IMGFiles"), tempStr); GetBundleString(NS_LITERAL_STRING("IMGFiles"), tempStr);
*nextTitle++ = tempStr; *nextTitle++ = tempStr;
(*nextFilter++).AssignWithConversion("*.gif; *.jpg; *.jpeg; *.png; *.*"); (*nextFilter++).AssignWithConversion("*.gif; *.jpg; *.jpeg; *.png; *.*");
fileWidget->SetFilterList(2, titles, filters); fileWidget->SetFilterList(2, titles, filters);
} }
GetBundleString(NS_ConvertASCIItoUCS2("AllFiles"), tempStr); GetBundleString(NS_LITERAL_STRING("AllFiles"), tempStr);
*nextTitle++ = tempStr; *nextTitle++ = tempStr;
(*nextFilter++).AssignWithConversion("*.*"); (*nextFilter++).AssignWithConversion("*.*");
// First param should be Parent window, but type is nsIWidget* // First param should be Parent window, but type is nsIWidget*
@ -2108,7 +2109,7 @@ nsEditorShell::UpdateWindowTitle()
res = GetDocumentTitleString(windowCaption); res = GetDocumentTitleString(windowCaption);
// If title is empty, use "untitled" // If title is empty, use "untitled"
if (windowCaption.Length() == 0) if (windowCaption.Length() == 0)
GetBundleString(NS_ConvertASCIItoUCS2("untitled"), windowCaption); GetBundleString(NS_LITERAL_STRING("untitled"), windowCaption);
// Append just the 'leaf' filename to the Doc. Title for the window caption // Append just the 'leaf' filename to the Doc. Title for the window caption
if (NS_SUCCEEDED(res)) if (NS_SUCCEEDED(res))
@ -2951,44 +2952,28 @@ nsEditorShell::FindNext()
/* Get localized strings for UI from the Editor's string bundle */ /* Get localized strings for UI from the Editor's string bundle */
// Use this version from JavaScript: // Use this version from JavaScript:
NS_IMETHODIMP NS_IMETHODIMP
nsEditorShell::GetString(const PRUnichar *name, PRUnichar **_retval) nsEditorShell::GetString(const PRUnichar *stringName, PRUnichar **_retval)
{ {
if (!name || !_retval) if (!stringName || !_retval)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
// Don't fail, just return an empty string *_retval = NULL;
nsAutoString empty;
if (mStringBundle) NS_ASSERTION(mStringBundle, "No string bundle!");
{ if (!mStringBundle) return NS_ERROR_NOT_INITIALIZED;
if (NS_FAILED(mStringBundle->GetStringFromName(name, _retval)))
*_retval = empty.ToNewUnicode();
return NS_OK; return mStringBundle->GetStringFromName(stringName, _retval);
} else {
*_retval = empty.ToNewUnicode();
return NS_ERROR_NOT_INITIALIZED;
}
} }
// Use this version within the shell: // Use this version within the shell:
void nsEditorShell::GetBundleString(const nsString& name, nsString &outString) void nsEditorShell::GetBundleString(const PRUnichar *stringName, nsString &outString)
{ {
if (mStringBundle && name.Length() > 0) outString.Truncate();
{
PRUnichar *ptrv = nsnull;
if (NS_SUCCEEDED(mStringBundle->GetStringFromName(name.GetUnicode(), &ptrv)))
outString = ptrv;
else
outString.SetLength(0);
nsMemory::Free(ptrv); nsXPIDLString tempString;
} if (NS_SUCCEEDED(GetString(stringName, getter_Copies(tempString))) && tempString)
else outString = tempString.get();
{
outString.SetLength(0);
}
} }
// Utilities to bring up a Yes/No/Cancel dialog. // Utilities to bring up a Yes/No/Cancel dialog.
@ -3035,7 +3020,7 @@ nsEditorShell::ConfirmWithCancel(const nsString& aTitle, const nsString& aQuesti
yesStr.Assign(*aYesString); yesStr.Assign(*aYesString);
else else
// We always want a "Yes" string, so supply the default // We always want a "Yes" string, so supply the default
GetBundleString(NS_ConvertASCIItoUCS2("Yes"), yesStr); GetBundleString(NS_LITERAL_STRING("Yes"), yesStr);
if (aNoString && aNoString->Length() > 0) if (aNoString && aNoString->Length() > 0)
{ {
@ -3050,7 +3035,7 @@ nsEditorShell::ConfirmWithCancel(const nsString& aTitle, const nsString& aQuesti
block->SetInt( nsICommonDialogs::eNumberButtons, numberOfButtons ); block->SetInt( nsICommonDialogs::eNumberButtons, numberOfButtons );
nsAutoString cancelStr; nsAutoString cancelStr;
GetBundleString(NS_ConvertASCIItoUCS2("Cancel"), cancelStr); GetBundleString(NS_LITERAL_STRING("Cancel"), cancelStr);
block->SetString( nsICommonDialogs::eDialogTitle, aTitle.GetUnicode() ); block->SetString( nsICommonDialogs::eDialogTitle, aTitle.GetUnicode() );
//Note: "button0" is always Ok or Yes action, "button1" is Cancel //Note: "button0" is always Ok or Yes action, "button1" is Cancel
@ -5161,7 +5146,7 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* aChanne
if (mCloseWindowWhenLoaded && isRootDoc) if (mCloseWindowWhenLoaded && isRootDoc)
{ {
nsAutoString alertLabel, alertMessage; nsAutoString alertLabel, alertMessage;
GetBundleString(NS_ConvertASCIItoUCS2("Alert"), alertLabel); GetBundleString(NS_LITERAL_STRING("Alert"), alertLabel);
nsAutoString stringID; nsAutoString stringID;
switch (mCantEditReason) switch (mCantEditReason)
@ -5180,7 +5165,7 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* aChanne
break; break;
} }
GetBundleString(stringID, alertMessage); GetBundleString(stringID.GetUnicode(), alertMessage);
Alert(alertLabel, alertMessage); Alert(alertLabel, alertMessage);
nsCOMPtr<nsIBaseWindow> baseWindow; nsCOMPtr<nsIBaseWindow> baseWindow;
@ -5203,7 +5188,7 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* aChanne
} }
nsAutoString doneText; nsAutoString doneText;
GetBundleString(NS_ConvertASCIItoUCS2("LoadingDone"), doneText); GetBundleString(NS_LITERAL_STRING("LoadingDone"), doneText);
SetChromeAttribute(mDocShell, "statusText", "value", doneText); SetChromeAttribute(mDocShell, "statusText", "value", doneText);
return res; return res;

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

@ -141,11 +141,9 @@ class nsEditorShell : public nsIEditorShell,
EConfirmResult ConfirmWithCancel(const nsString& aTitle, const nsString& aQuestion, EConfirmResult ConfirmWithCancel(const nsString& aTitle, const nsString& aQuestion,
const nsString *aYesString, const nsString *aNoString); const nsString *aYesString, const nsString *aNoString);
// this returns an AddReffed nsIScriptContext. You must relase it. // Get a string from the string bundle file. If the string is not found
nsIScriptContext* GetScriptContext(nsIDOMWindowInternal * aWin); // this returns an empty string.
void GetBundleString(const PRUnichar *stringName, nsString &outString);
// Get a string from the string bundle file
void GetBundleString(const nsString& name, nsString &outString);
// Get the text of the <title> tag // Get the text of the <title> tag
nsresult GetDocumentTitleString(nsString& title); nsresult GetDocumentTitleString(nsString& title);