making string conversions explicit

git-svn-id: svn://10.0.0.236/trunk@66273 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
scc%netscape.com 2000-04-18 07:44:58 +00:00
parent 89ee8d4abc
commit 4f0c5e3591
45 changed files with 570 additions and 586 deletions

View File

@ -50,7 +50,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor,
mValue = aValue;
mRemoveAttribute = aRemoveAttribute;
mAttributeWasSet=PR_FALSE;
mUndoValue="";
mUndoValue.SetLength(0);
return NS_OK;
}
@ -62,7 +62,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Do(void)
// need to get the current value of the attribute and save it, and set mAttributeWasSet
nsresult result = mEditor->GetAttributeValue(mElement, mAttribute, mUndoValue, mAttributeWasSet);
// XXX: hack until attribute-was-set code is implemented
if (PR_FALSE==mUndoValue.Equals(""))
if (PR_FALSE==mUndoValue.IsEmpty())
mAttributeWasSet=PR_TRUE;
// XXX: end hack
@ -121,9 +121,9 @@ NS_IMETHODIMP ChangeAttributeTxn::GetUndoString(nsString *aString)
if (nsnull!=aString)
{
if (PR_FALSE==mRemoveAttribute)
*aString="Change Attribute: ";
aString->AssignWithConversion("Change Attribute: ");
else
*aString="Remove Attribute: ";
aString->AssignWithConversion("Remove Attribute: ");
*aString += mAttribute;
}
return NS_OK;
@ -134,9 +134,9 @@ NS_IMETHODIMP ChangeAttributeTxn::GetRedoString(nsString *aString)
if (nsnull!=aString)
{
if (PR_FALSE==mRemoveAttribute)
*aString="Change Attribute: ";
aString->AssignWithConversion("Change Attribute: ");
else
*aString="Add Attribute: ";
aString->AssignWithConversion("Add Attribute: ");
*aString += mAttribute;
}
return NS_OK;

View File

@ -212,7 +212,7 @@ NS_IMETHODIMP CreateElementTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Remove Element: ";
aString->AssignWithConversion("Remove Element: ");
*aString += mTag;
}
return NS_OK;
@ -222,7 +222,7 @@ NS_IMETHODIMP CreateElementTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Create Element: ";
aString->AssignWithConversion("Create Element: ");
*aString += mTag;
}
return NS_OK;

View File

@ -67,12 +67,12 @@ NS_IMETHODIMP DeleteElementTxn::Do(void)
// begin debug output
nsCOMPtr<nsIDOMElement> element;
element = do_QueryInterface(mElement);
nsAutoString elementTag="text node";
nsAutoString elementTag; elementTag.AssignWithConversion("text node");
if (element)
element->GetTagName(elementTag);
nsCOMPtr<nsIDOMElement> parentElement;
parentElement = do_QueryInterface(mParent);
nsAutoString parentElementTag="text node";
nsAutoString parentElementTag; parentElementTag.AssignWithConversion("text node");
if (parentElement)
parentElement->GetTagName(parentElementTag);
char *c, *p;
@ -106,12 +106,12 @@ NS_IMETHODIMP DeleteElementTxn::Undo(void)
// begin debug output
nsCOMPtr<nsIDOMElement> element;
element = do_QueryInterface(mElement);
nsAutoString elementTag="text node";
nsAutoString elementTag; elementTag.AssignWithConversion("text node");
if (element)
element->GetTagName(elementTag);
nsCOMPtr<nsIDOMElement> parentElement;
parentElement = do_QueryInterface(mParent);
nsAutoString parentElementTag="text node";
nsAutoString parentElementTag; parentElementTag.AssignWithConversion("text node");
if (parentElement)
parentElement->GetTagName(parentElementTag);
char *c, *p;
@ -160,7 +160,7 @@ NS_IMETHODIMP DeleteElementTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Insert Element: ";
aString->AssignWithConversion("Insert Element: ");
}
return NS_OK;
}
@ -169,7 +169,7 @@ NS_IMETHODIMP DeleteElementTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Remove Element: ";
aString->AssignWithConversion("Remove Element: ");
}
return NS_OK;
}

View File

@ -203,7 +203,7 @@ NS_IMETHODIMP DeleteRangeTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Insert Range: ";
aString->AssignWithConversion("Insert Range: ");
}
return NS_OK;
}
@ -212,7 +212,7 @@ NS_IMETHODIMP DeleteRangeTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Remove Range: ";
aString->AssignWithConversion("Remove Range: ");
}
return NS_OK;
}

View File

@ -58,7 +58,7 @@ NS_IMETHODIMP DeleteTextTxn::Init(nsIEditor *aEditor,
aElement->GetLength(&count);
NS_ASSERTION(count>=aNumCharsToDelete, "bad arg, numCharsToDelete. Not enough characters in node");
NS_ASSERTION(count>=aOffset+aNumCharsToDelete, "bad arg, numCharsToDelete. Not enough characters in node");
mDeletedText = "";
mDeletedText.SetLength(0);
return NS_OK;
}
@ -121,7 +121,7 @@ NS_IMETHODIMP DeleteTextTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Insert Text: ";
aString->AssignWithConversion("Insert Text: ");
*aString += mDeletedText;
}
return NS_OK;
@ -131,7 +131,7 @@ NS_IMETHODIMP DeleteTextTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Remove Text: ";
aString->AssignWithConversion("Remove Text: ");
*aString += mDeletedText;
}
return NS_OK;

View File

@ -142,14 +142,14 @@ NS_IMETHODIMP EditAggregateTxn::Write(nsIOutputStream *aOutputStream)
NS_IMETHODIMP EditAggregateTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
*aString="";
aString->SetLength(0);
return NS_OK;
}
NS_IMETHODIMP EditAggregateTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
*aString="";
aString->SetLength(0);
return NS_OK;
}

View File

@ -78,14 +78,14 @@ NS_IMETHODIMP EditTxn::Write(nsIOutputStream *aOutputStream)
NS_IMETHODIMP EditTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
*aString="";
aString->SetLength(0);
return NS_OK;
}
NS_IMETHODIMP EditTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
*aString="";
aString->SetLength(0);
return NS_OK;
}

View File

@ -103,7 +103,7 @@ NS_IMETHODIMP IMECommitTxn::GetUndoString(nsString *aString)
if(nsnull == aString) {
return NS_ERROR_NULL_POINTER;
} else {
*aString="Remove IMECommit: ";
aString->AssignWithConversion("Remove IMECommit: ");
return NS_OK;
}
}
@ -114,7 +114,7 @@ NS_IMETHODIMP IMECommitTxn::GetRedoString(nsString *aString)
if(nsnull == aString) {
return NS_ERROR_NULL_POINTER;
} else {
*aString="Insert IMECommit: ";
aString->AssignWithConversion("Insert IMECommit: ");
return NS_OK;
}
}

View File

@ -200,7 +200,7 @@ NS_IMETHODIMP IMETextTxn::GetUndoString(nsString *aString)
if (nsnull!=aString)
{
*aString="Remove Text: ";
aString->AssignWithConversion("Remove Text: ");
*aString += mStringToInsert;
}
return NS_OK;
@ -214,7 +214,7 @@ NS_IMETHODIMP IMETextTxn::GetRedoString(nsString *aString)
if (nsnull!=aString)
{
*aString="Insert Text: ";
aString->AssignWithConversion("Insert Text: ");
*aString += mStringToInsert;
}
return NS_OK;

View File

@ -146,7 +146,7 @@ NS_IMETHODIMP InsertElementTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Remove Element: ";
aString->AssignWithConversion("Remove Element: ");
}
return NS_OK;
}
@ -155,7 +155,7 @@ NS_IMETHODIMP InsertElementTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Insert Element: ";
aString->AssignWithConversion("Insert Element: ");
}
return NS_OK;
}

View File

@ -202,7 +202,7 @@ NS_IMETHODIMP InsertTextTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Remove Text: ";
aString->AssignWithConversion("Remove Text: ");
*aString += mStringToInsert;
}
return NS_OK;
@ -212,7 +212,7 @@ NS_IMETHODIMP InsertTextTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Insert Text: ";
aString->AssignWithConversion("Insert Text: ");
*aString += mStringToInsert;
}
return NS_OK;

View File

@ -168,7 +168,7 @@ NS_IMETHODIMP JoinElementTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Join Element";
aString->AssignWithConversion("Join Element");
}
return NS_OK;
}
@ -177,7 +177,7 @@ NS_IMETHODIMP JoinElementTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Split Element";
aString->AssignWithConversion("Split Element");
}
return NS_OK;
}

View File

@ -64,7 +64,7 @@ nsAOLCiter::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_IMETHODIMP
nsAOLCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
{
aOutString = "\n\n>> ";
aOutString.AssignWithConversion("\n\n>> ");
aOutString += aInString;
// See if the last char is a newline, and replace it if so
@ -72,11 +72,11 @@ nsAOLCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
if (aOutString.Last() == newline)
{
aOutString.SetCharAt(' ',aOutString.Length());
aOutString += "<<\n";
aOutString.AppendWithConversion("<<\n");
}
else
{
aOutString += " <<\n";
aOutString.AppendWithConversion(" <<\n");
}
return NS_OK;

View File

@ -213,7 +213,8 @@ nsEditProperty::nsEditProperty()
// special
nsIEditProperty::allProperties = new nsString("moz_allproperties");
if ( nsIEditProperty::allProperties = new nsString )
nsIEditProperty::allProperties->AssignWithConversion("moz_allproperties");
}
nsEditProperty::~nsEditProperty()

View File

@ -1277,7 +1277,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
if (NS_SUCCEEDED(result) && selection)
{
nsCOMPtr<nsIDOMNodeList> nodeList;
nsAutoString bodyTag = "body";
nsAutoString bodyTag; bodyTag.AssignWithConversion("body");
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
if (!doc) return NS_ERROR_NOT_INITIALIZED;
result = doc->GetElementsByTagName(bodyTag, getter_AddRefs(nodeList));
@ -1336,7 +1336,7 @@ NS_IMETHODIMP nsEditor::EndOfDocument()
if (NS_SUCCEEDED(result) && selection)
{
nsCOMPtr<nsIDOMNodeList> nodeList;
nsAutoString bodyTag = "body";
nsAutoString bodyTag; bodyTag.AssignWithConversion("body");
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
if (!doc) return NS_ERROR_NOT_INITIALIZED;
result = doc->GetElementsByTagName(bodyTag, getter_AddRefs(nodeList));
@ -1461,7 +1461,7 @@ nsEditor::SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveC
if (!diskDoc)
return NS_ERROR_NO_INTERFACE;
nsAutoString useDocCharset("");
nsAutoString useDocCharset;
res = diskDoc->SaveFile(aFileSpec, aReplaceExisting, aSaveCopy,
aSaveFileType, useDocCharset);
@ -1526,7 +1526,7 @@ nsEditor::MarkNodeDirty(nsIDOMNode* aNode)
// mark the node dirty.
nsCOMPtr<nsIDOMElement> element (do_QueryInterface(aNode));
if (element)
element->SetAttribute("_moz_dirty", "");
element->SetAttribute(NS_ConvertASCIItoUCS2("_moz_dirty"), nsAutoString());
return NS_OK;
}
@ -2125,7 +2125,7 @@ nsEditor::DebugDumpContent() const
{
nsCOMPtr<nsIContent>content;
nsCOMPtr<nsIDOMNodeList>nodeList;
nsAutoString bodyTag = "body";
nsAutoString bodyTag; bodyTag.AssignWithConversion("body");
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
if (!doc) return NS_ERROR_NOT_INITIALIZED;
doc->GetElementsByTagName(bodyTag, getter_AddRefs(nodeList));
@ -2332,7 +2332,7 @@ nsEditor::GetBodyElement(nsIDOMElement **aBodyElement)
return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMNodeList>nodeList;
nsAutoString bodyTag = "body";
nsAutoString bodyTag; bodyTag.AssignWithConversion("body");
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
if (!doc) return NS_ERROR_NOT_INITIALIZED;
@ -2478,14 +2478,13 @@ NS_IMETHODIMP nsEditor::ScrollIntoView(PRBool aScrollToBegin)
/** static helper method */
nsresult nsEditor::GetTextNodeTag(nsString& aOutString)
{
aOutString = "";
aOutString.SetLength(0);
static nsString *gTextNodeTag=nsnull;
if (!gTextNodeTag)
{
gTextNodeTag = new nsString("special text node tag");
if (!gTextNodeTag) {
if ( (gTextNodeTag = new nsString) == 0 )
return NS_ERROR_OUT_OF_MEMORY;
}
gTextNodeTag->AssignWithConversion("special text node tag");
}
aOutString = *gTextNodeTag;
return NS_OK;
@ -2512,7 +2511,7 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert,
{
// create a text node
nsCOMPtr<nsIDOMNode> newNode;
res = aDoc->CreateTextNode("", getter_AddRefs(nodeAsText));
res = aDoc->CreateTextNode(nsAutoString(), getter_AddRefs(nodeAsText));
if (NS_FAILED(res)) return res;
if (!nodeAsText) return NS_ERROR_NULL_POINTER;
newNode = do_QueryInterface(nodeAsText);
@ -3642,7 +3641,7 @@ nsEditor::TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild)
if (IsTextNode(aChild))
{
childStringTag = "__moz_text";
childStringTag.AssignWithConversion("__moz_text");
}
else
{
@ -3750,10 +3749,10 @@ nsEditor::IsMozEditorBogusNode(nsIDOMNode *aNode)
element = do_QueryInterface(aNode);
if (element)
{
nsAutoString att(kMOZEditorBogusNodeAttr);
nsAutoString att; att.AssignWithConversion(kMOZEditorBogusNodeAttr);
nsAutoString val;
(void)element->GetAttribute(att, val);
if (val.Equals(kMOZEditorBogusNodeValue)) {
if (val.EqualsWithConversion(kMOZEditorBogusNodeValue)) {
return PR_TRUE;
}
}

View File

@ -163,9 +163,9 @@ nsPasteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon)
nsresult rv = NS_OK;
nsAutoString cmdString(aCommand);
if (cmdString.Equals("cmd_paste"))
if (cmdString.EqualsWithConversion("cmd_paste"))
rv = aEditor->Paste(nsIClipboard::kGlobalClipboard);
else if (cmdString.Equals("cmd_pasteQuote"))
else if (cmdString.EqualsWithConversion("cmd_pasteQuote"))
{
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(aEditor, &rv);
if (mailEditor)
@ -188,19 +188,19 @@ nsDeleteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCo
nsAutoString cmdString(aCommand);
if (cmdString.Equals("cmd_delete"))
if (cmdString.EqualsWithConversion("cmd_delete"))
rv = aEditor->CanCut(*outCmdEnabled);
else if (cmdString.Equals("cmd_deleteCharBackward"))
else if (cmdString.EqualsWithConversion("cmd_deleteCharBackward"))
*outCmdEnabled = PR_TRUE;
else if (cmdString.Equals("cmd_deleteCharForward"))
else if (cmdString.EqualsWithConversion("cmd_deleteCharForward"))
*outCmdEnabled = PR_TRUE;
else if (cmdString.Equals("cmd_deleteWordBackward"))
else if (cmdString.EqualsWithConversion("cmd_deleteWordBackward"))
*outCmdEnabled = PR_TRUE;
else if (cmdString.Equals("cmd_deleteWordForward"))
else if (cmdString.EqualsWithConversion("cmd_deleteWordForward"))
*outCmdEnabled = PR_TRUE;
else if (cmdString.Equals("cmd_deleteToBeginningOfLine"))
else if (cmdString.EqualsWithConversion("cmd_deleteToBeginningOfLine"))
*outCmdEnabled = PR_TRUE;
else if (cmdString.Equals("cmd_deleteToEndOfLine"))
else if (cmdString.EqualsWithConversion("cmd_deleteToEndOfLine"))
*outCmdEnabled = PR_TRUE;
return rv;
@ -218,19 +218,19 @@ nsDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon)
nsIEditor::EDirection deleteDir = nsIEditor::eNone;
if (cmdString.Equals("cmd_delete"))
if (cmdString.EqualsWithConversion("cmd_delete"))
deleteDir = nsIEditor::ePrevious;
else if (cmdString.Equals("cmd_deleteCharBackward"))
else if (cmdString.EqualsWithConversion("cmd_deleteCharBackward"))
deleteDir = nsIEditor::ePrevious;
else if (cmdString.Equals("cmd_deleteCharForward"))
else if (cmdString.EqualsWithConversion("cmd_deleteCharForward"))
deleteDir = nsIEditor::eNext;
else if (cmdString.Equals("cmd_deleteWordBackward"))
else if (cmdString.EqualsWithConversion("cmd_deleteWordBackward"))
deleteDir = nsIEditor::ePreviousWord;
else if (cmdString.Equals("cmd_deleteWordForward"))
else if (cmdString.EqualsWithConversion("cmd_deleteWordForward"))
deleteDir = nsIEditor::eNextWord;
else if (cmdString.Equals("cmd_deleteToBeginningOfLine"))
else if (cmdString.EqualsWithConversion("cmd_deleteToBeginningOfLine"))
deleteDir = nsIEditor::eToBeginningOfLine;
else if (cmdString.Equals("cmd_deleteToEndOfLine"))
else if (cmdString.EqualsWithConversion("cmd_deleteToEndOfLine"))
deleteDir = nsIEditor::eToEndOfLine;
return aEditor->DeleteSelection(deleteDir);
@ -292,81 +292,81 @@ nsSelectionMoveCommands::DoCommand(const PRUnichar *aCommand, nsISupports * refC
nsAutoString cmdString(aCommand);
// complete scroll commands
if (cmdString.Equals("cmd_scrollTop"))
if (cmdString.EqualsWithConversion("cmd_scrollTop"))
return selCont->CompleteScroll(PR_FALSE);
else if (cmdString.Equals("cmd_scrollBottom"))
else if (cmdString.EqualsWithConversion("cmd_scrollBottom"))
return selCont->CompleteScroll(PR_TRUE);
// complete move commands
else if (cmdString.Equals("cmd_moveTop"))
else if (cmdString.EqualsWithConversion("cmd_moveTop"))
return selCont->CompleteMove(PR_FALSE, PR_FALSE);
else if (cmdString.Equals("cmd_moveBottom"))
else if (cmdString.EqualsWithConversion("cmd_moveBottom"))
return selCont->CompleteMove(PR_TRUE, PR_FALSE);
else if (cmdString.Equals("cmd_selectTop"))
else if (cmdString.EqualsWithConversion("cmd_selectTop"))
return selCont->CompleteMove(PR_FALSE, PR_TRUE);
else if (cmdString.Equals("cmd_selectBottom"))
else if (cmdString.EqualsWithConversion("cmd_selectBottom"))
return selCont->CompleteMove(PR_TRUE, PR_TRUE);
// line move commands
else if (cmdString.Equals("cmd_lineNext"))
else if (cmdString.EqualsWithConversion("cmd_lineNext"))
return selCont->LineMove(PR_TRUE, PR_FALSE);
else if (cmdString.Equals("cmd_linePrevious"))
else if (cmdString.EqualsWithConversion("cmd_linePrevious"))
return selCont->LineMove(PR_FALSE, PR_FALSE);
else if (cmdString.Equals("cmd_selectLineNext"))
else if (cmdString.EqualsWithConversion("cmd_selectLineNext"))
return selCont->LineMove(PR_TRUE, PR_TRUE);
else if (cmdString.Equals("cmd_selectLinePrevious"))
else if (cmdString.EqualsWithConversion("cmd_selectLinePrevious"))
return selCont->LineMove(PR_FALSE, PR_TRUE);
// character move commands
else if (cmdString.Equals("cmd_charPrevious"))
else if (cmdString.EqualsWithConversion("cmd_charPrevious"))
return selCont->CharacterMove(PR_FALSE, PR_FALSE);
else if (cmdString.Equals("cmd_charNext"))
else if (cmdString.EqualsWithConversion("cmd_charNext"))
return selCont->CharacterMove(PR_TRUE, PR_FALSE);
else if (cmdString.Equals("cmd_selectCharPrevious"))
else if (cmdString.EqualsWithConversion("cmd_selectCharPrevious"))
return selCont->CharacterMove(PR_FALSE, PR_TRUE);
else if (cmdString.Equals("cmd_selectCharNext"))
else if (cmdString.EqualsWithConversion("cmd_selectCharNext"))
return selCont->CharacterMove(PR_TRUE, PR_TRUE);
// intra line move commands
else if (cmdString.Equals("cmd_beginLine"))
else if (cmdString.EqualsWithConversion("cmd_beginLine"))
return selCont->IntraLineMove(PR_FALSE, PR_FALSE);
else if (cmdString.Equals("cmd_endLine"))
else if (cmdString.EqualsWithConversion("cmd_endLine"))
return selCont->IntraLineMove(PR_TRUE, PR_FALSE);
else if (cmdString.Equals("cmd_selectBeginLine"))
else if (cmdString.EqualsWithConversion("cmd_selectBeginLine"))
return selCont->IntraLineMove(PR_FALSE, PR_TRUE);
else if (cmdString.Equals("cmd_selectEndLine"))
else if (cmdString.EqualsWithConversion("cmd_selectEndLine"))
return selCont->IntraLineMove(PR_TRUE, PR_TRUE);
// word move commands
else if (cmdString.Equals("cmd_wordPrevious"))
else if (cmdString.EqualsWithConversion("cmd_wordPrevious"))
return selCont->WordMove(PR_FALSE, PR_FALSE);
else if (cmdString.Equals("cmd_wordNext"))
else if (cmdString.EqualsWithConversion("cmd_wordNext"))
return selCont->WordMove(PR_TRUE, PR_FALSE);
else if (cmdString.Equals("cmd_selectWordPrevious"))
else if (cmdString.EqualsWithConversion("cmd_selectWordPrevious"))
return selCont->WordMove(PR_FALSE, PR_TRUE);
else if (cmdString.Equals("cmd_selectWordNext"))
else if (cmdString.EqualsWithConversion("cmd_selectWordNext"))
return selCont->WordMove(PR_TRUE, PR_TRUE);
// scroll page commands
else if (cmdString.Equals("cmd_scrollPageUp"))
else if (cmdString.EqualsWithConversion("cmd_scrollPageUp"))
return selCont->ScrollPage(PR_FALSE);
else if (cmdString.Equals("cmd_scrollPageDown"))
else if (cmdString.EqualsWithConversion("cmd_scrollPageDown"))
return selCont->ScrollPage(PR_TRUE);
// scroll line commands
else if (cmdString.Equals("cmd_scrollLineUp"))
else if (cmdString.EqualsWithConversion("cmd_scrollLineUp"))
return selCont->ScrollLine(PR_FALSE);
else if (cmdString.Equals("cmd_scrollLineDown"))
else if (cmdString.EqualsWithConversion("cmd_scrollLineDown"))
return selCont->ScrollLine(PR_TRUE);
// page move commands
else if (cmdString.Equals("cmd_scrollPageUp"))
else if (cmdString.EqualsWithConversion("cmd_scrollPageUp"))
return selCont->PageMove(PR_FALSE, PR_FALSE);
else if (cmdString.Equals("cmd_scrollPageDown"))
else if (cmdString.EqualsWithConversion("cmd_scrollPageDown"))
return selCont->PageMove(PR_TRUE, PR_FALSE);
else if (cmdString.Equals("cmd_selectPageUp"))
else if (cmdString.EqualsWithConversion("cmd_selectPageUp"))
return selCont->PageMove(PR_FALSE, PR_TRUE);
else if (cmdString.Equals("cmd_selectPageDown"))
else if (cmdString.EqualsWithConversion("cmd_selectPageDown"))
return selCont->PageMove(PR_TRUE, PR_TRUE);
return NS_ERROR_FAILURE;

View File

@ -78,23 +78,19 @@ NS_IMETHODIMP nsEditorController::Init()
#define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \
{ \
_cmdClass* theCmd = new _cmdClass; \
nsAutoString cmdString(_cmdName); \
rv = RegisterOneCommand(cmdString.GetUnicode(), inCommandManager, theCmd); \
rv = RegisterOneCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), inCommandManager, theCmd); \
}
#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \
{ \
_cmdClass* theCmd = new _cmdClass; \
nsAutoString cmdString(_cmdName); \
rv = RegisterOneCommand(cmdString.GetUnicode(), inCommandManager, theCmd); \
rv = RegisterOneCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), inCommandManager, theCmd); \
#define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName) \
cmdString = _cmdName; \
rv = RegisterOneCommand(cmdString.GetUnicode(), inCommandManager, theCmd);
rv = RegisterOneCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), inCommandManager, theCmd);
#define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName) \
cmdString = _cmdName; \
rv = RegisterOneCommand(cmdString.GetUnicode(), inCommandManager, theCmd); \
rv = RegisterOneCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), inCommandManager, theCmd); \
}
@ -217,7 +213,7 @@ NS_IMETHODIMP nsEditorController::IsCommandEnabled(const PRUnichar *aCommand, PR
{
#if DEBUG
nsCAutoString msg("EditorController asked about a command that it does not handle -- ");
msg.Append(aCommand);
msg.AppendWithConversion(aCommand);
NS_WARNING(msg);
#endif
return NS_OK; // we don't handle this command
@ -263,7 +259,7 @@ NS_IMETHODIMP nsEditorController::DoCommand(const PRUnichar *aCommand)
{
#if DEBUG
nsCAutoString msg("EditorController asked to do a command that it does not handle -- ");
msg.Append(aCommand);
msg.AppendWithConversion(aCommand);
NS_WARNING(msg);
#endif
return NS_OK; // we don't handle this command

View File

@ -557,7 +557,7 @@ nsTextEditorMouseListener::MouseUp(nsIDOMEvent* aMouseEvent)
if (htmlEditor)
{
nsCOMPtr<nsIDOMElement> selectedElement;
if (NS_SUCCEEDED(htmlEditor->GetSelectedElement("", getter_AddRefs(selectedElement)))
if (NS_SUCCEEDED(htmlEditor->GetSelectedElement(nsAutoString(), getter_AddRefs(selectedElement)))
&& selectedElement)
{
nsAutoString TagName;

View File

@ -100,7 +100,7 @@ void nsEditorParserObserver::Notify()
NS_IMETHODIMP nsEditorParserObserver::Start()
{
nsresult res = NS_OK;
nsAutoString parserService("text/html");
nsAutoString parserService; parserService.AssignWithConversion("text/html");
nsCOMPtr<nsIObserverService> anObserverService = do_GetService(NS_OBSERVERSERVICE_PROGID, &res);
if (NS_FAILED(res)) return res;
@ -111,7 +111,7 @@ NS_IMETHODIMP nsEditorParserObserver::Start()
NS_IMETHODIMP nsEditorParserObserver::End()
{
nsresult res = NS_OK;
nsAutoString parserService("text/html");
nsAutoString parserService; parserService.AssignWithConversion("text/html");
nsCOMPtr<nsIObserverService> anObserverService = do_GetService(NS_OBSERVERSERVICE_PROGID, &res);
if (NS_FAILED(res)) return res;

View File

@ -178,10 +178,10 @@ SetChromeAttribute( nsIDocShell *shell, const char *id,
{
// Find specified element.
nsCOMPtr<nsIDOMElement> elem;
rv = xulDoc->GetElementById( id, getter_AddRefs(elem) );
rv = xulDoc->GetElementById( NS_ConvertASCIItoUCS2(id), getter_AddRefs(elem) );
if ( elem )
// Set the text attribute.
rv = elem->SetAttribute( name, value );
rv = elem->SetAttribute( NS_ConvertASCIItoUCS2(name), value );
}
}
return rv;
@ -273,7 +273,7 @@ nsEditorShell::QueryInterface(REFNSIID aIID,void** aInstancePtr)
NS_IMETHODIMP
nsEditorShell::Init()
{
nsAutoString editorType = "html"; // default to creating HTML editor
nsAutoString editorType; editorType.AssignWithConversion("html"); // default to creating HTML editor
mEditorTypeString = editorType;
mEditorTypeString.ToLowerCase();
@ -462,7 +462,7 @@ nsEditorShell::PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUr
// Load style sheet with settings that should never
// change, even in "Browser" mode
// We won't unload this, so we don't need to be returned the style sheet pointer
styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorOverride.css", nsnull);
styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorOverride.css"), nsnull);
// Load the edit mode override style sheet
// This will be remove for "Browser" mode
@ -472,9 +472,9 @@ nsEditorShell::PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUr
// Activate the debug menu only in debug builds
// by removing the "hidden" attribute set "true" in XUL
nsCOMPtr<nsIDOMElement> elem;
rv = xulDoc->GetElementById("debugMenu", getter_AddRefs(elem));
rv = xulDoc->GetElementById(NS_ConvertASCIItoUCS2("debugMenu"), getter_AddRefs(elem));
if (elem)
elem->RemoveAttribute("hidden");
elem->RemoveAttribute(NS_ConvertASCIItoUCS2("hidden"));
#endif
// Force initial focus to the content window -- HOW?
@ -567,7 +567,7 @@ nsEditorShell::SetEditorType(const PRUnichar *editorType)
nsAutoString theType = editorType;
theType.ToLowerCase();
if (theType.Equals("text") || theType.Equals("html") || theType.IsEmpty() || theType.Equals("htmlmail"))
if (theType.EqualsWithConversion("text") || theType.EqualsWithConversion("html") || theType.IsEmpty() || theType.EqualsWithConversion("htmlmail"))
{
mEditorTypeString = theType;
return NS_OK;
@ -599,17 +599,17 @@ nsEditorShell::InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell)
if (NS_SUCCEEDED(err))
{
if (mEditorTypeString.Equals("text"))
if (mEditorTypeString.EqualsWithConversion("text"))
{
err = editor->Init(aDoc, aPresShell, nsIHTMLEditor::eEditorPlaintextMask);
mEditorType = ePlainTextEditorType;
}
else if (mEditorTypeString.Equals("html") || mEditorTypeString.IsEmpty()) // empty string default to HTML editor
else if (mEditorTypeString.EqualsWithConversion("html") || mEditorTypeString.IsEmpty()) // empty string default to HTML editor
{
err = editor->Init(aDoc, aPresShell, 0);
mEditorType = eHTMLTextEditorType;
}
else if (mEditorTypeString.Equals("htmlmail")) // HTML editor with special mail rules
else if (mEditorTypeString.EqualsWithConversion("htmlmail")) // HTML editor with special mail rules
{
err = editor->Init(aDoc, aPresShell, nsIHTMLEditor::eEditorMailMask);
mEditorType = eHTMLTextEditorType;
@ -618,9 +618,9 @@ nsEditorShell::InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell)
{
err = NS_ERROR_INVALID_ARG; // this is not an editor we know about
#if DEBUG
nsAutoString errorMsg = "Failed to init editor. Unknown editor type \"";
nsAutoString errorMsg; errorMsg.AssignWithConversion("Failed to init editor. Unknown editor type \"");
errorMsg += mEditorTypeString;
errorMsg += "\"\n";
errorMsg.AppendWithConversion("\"\n");
char *errorMsgCString = errorMsg.ToNewCString();
NS_WARNING(errorMsgCString);
nsCRT::free(errorMsgCString);
@ -861,7 +861,7 @@ nsEditorShell::RemoveTextProperty(const PRUnichar *prop, const PRUnichar *attr)
nsAutoString aAttr(attr);
allStr.ToLowerCase();
PRBool doingAll = (allStr.Equals("all"));
PRBool doingAll = (allStr.EqualsWithConversion("all"));
nsresult err = NS_OK;
if (doingAll)
@ -989,7 +989,7 @@ nsEditorShell::SetDisplayMode(PRInt32 aDisplayMode)
//Load the editmode style sheet
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorContent.css",
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorContent.css"),
getter_AddRefs(styleSheet));
// Save the returned style sheet so we can remove it later
@ -1008,7 +1008,7 @@ nsEditorShell::SetDisplayMode(PRInt32 aDisplayMode)
// Note: using "@import url(chrome://editor/content/EditorContent.css);"
// in EditorAllTags.css doesn't seem to work!?
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorContent.css",
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorContent.css"),
getter_AddRefs(styleSheet));
// Save the returned style sheet so we can remove it later
@ -1018,7 +1018,7 @@ nsEditorShell::SetDisplayMode(PRInt32 aDisplayMode)
//Load the editmode style sheet
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorAllTags.css",
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorAllTags.css"),
getter_AddRefs(styleSheet));
// Save the returned style sheet so we can remove it later
@ -1045,7 +1045,7 @@ nsEditorShell::DisplayParagraphMarks(PRBool aShowMarks)
//Load the style sheet
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorParagraphMarks.css",
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorParagraphMarks.css"),
getter_AddRefs(styleSheet));
// Save the returned style sheet so we can remove it later
@ -1255,19 +1255,19 @@ nsEditorShell::CheckAndSaveDocument(const PRUnichar *reasonToSave, PRBool *_retv
// Ask user if they want to save current changes
nsAutoString reasonToSaveStr(reasonToSave);
nsAutoString tmp1, tmp2, title;
GetBundleString("Save", tmp1);
GetBundleString("DontSave", tmp2);
GetBundleString(NS_ConvertASCIItoUCS2("Save"), tmp1);
GetBundleString(NS_ConvertASCIItoUCS2("DontSave"), tmp2);
GetDocumentTitleString(title);
// If title is empty, use "untitled"
if (title.Length() == 0)
GetBundleString("untitled", title);
GetBundleString(NS_ConvertASCIItoUCS2("untitled"), title);
nsAutoString saveMsg;
GetBundleString("SaveFilePrompt", saveMsg);
saveMsg.ReplaceSubstring("%title%", title).ReplaceSubstring("%reason%", reasonToSaveStr);
GetBundleString(NS_ConvertASCIItoUCS2("SaveFilePrompt"), saveMsg);
saveMsg.ReplaceSubstring(NS_ConvertASCIItoUCS2("%title%"), title).ReplaceSubstring(NS_ConvertASCIItoUCS2("%reason%"), reasonToSaveStr);
nsAutoString saveDocString;
GetBundleString("SaveDocument", saveDocString);
GetBundleString(NS_ConvertASCIItoUCS2("SaveDocument"), saveDocString);
EConfirmResult result = ConfirmWithCancel(saveDocString, saveMsg, &tmp1, &tmp2);
if (result == eCancel)
{
@ -1334,8 +1334,8 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
PRUnichar *titleUnicode;
nsAutoString captionStr, msgStr;
GetBundleString("DocumentTitle", captionStr);
GetBundleString("NeedDocTitle", msgStr);
GetBundleString(NS_ConvertASCIItoUCS2("DocumentTitle"), captionStr);
GetBundleString(NS_ConvertASCIItoUCS2("NeedDocTitle"), msgStr);
PRBool retVal = PR_FALSE;
res = dialog->Prompt(mContentWindow, captionStr.GetUnicode(), msgStr.GetUnicode(),
@ -1361,7 +1361,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
if (NS_SUCCEEDED(res) && fileWidget)
{
nsAutoString promptString;
GetBundleString("SaveDocumentAs", promptString);
GetBundleString(NS_ConvertASCIItoUCS2("SaveDocumentAs"), promptString);
nsString* titles = nsnull;
nsString* filters = nsnull;
@ -1385,19 +1385,19 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
nextTitle = titles;
nextFilter = filters;
// The names of the file types are localizable
GetBundleString("HTMLFiles", HTMLFiles);
GetBundleString("TextFiles", TextFiles);
GetBundleString(NS_ConvertASCIItoUCS2("HTMLFiles"), HTMLFiles);
GetBundleString(NS_ConvertASCIItoUCS2("TextFiles"), TextFiles);
if (! (HTMLFiles.Length() == 0 || TextFiles.Length() == 0))
{
nsAutoString allFilesStr;
GetBundleString("AllFiles", allFilesStr);
GetBundleString(NS_ConvertASCIItoUCS2("AllFiles"), allFilesStr);
*nextTitle++ = HTMLFiles;
*nextFilter++ = "*.htm; *.html; *.shtml";
(*nextFilter++).AssignWithConversion("*.htm; *.html; *.shtml");
*nextTitle++ = TextFiles;
*nextFilter++ = "*.txt";
(*nextFilter++).AssignWithConversion("*.txt");
*nextTitle++ = allFilesStr;
*nextFilter++ = "*.*";
(*nextFilter++).AssignWithConversion("*.*");
fileWidget->SetFilterList(3, titles, filters);
}
@ -1412,8 +1412,8 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
// do a QI to get an nsIURL and then call GetFileName()
// if it's not a local file already, grab the current file name
if ( (urlstring.Compare("file", PR_TRUE, 4) != 0 )
&& (urlstring.Compare("about:blank", PR_TRUE, -1) != 0) )
if ( (urlstring.CompareWithConversion("file", PR_TRUE, 4) != 0 )
&& (urlstring.CompareWithConversion("about:blank", PR_TRUE, -1) != 0) )
{
PRInt32 index = urlstring.RFindChar((PRUnichar)'/', PR_FALSE, -1, -1 );
if ( index != -1 )
@ -1422,7 +1422,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
// if the url ends with a '/' then the whole string will be cut
urlstring.Cut(0, index + 1);
if (urlstring.Length() > 0)
fileName = urlstring;
fileName.Assign( urlstring );
}
}
@ -1437,14 +1437,14 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
PRUnichar at = (PRUnichar)'@';
PRUnichar colon = (PRUnichar)':';
PRUnichar underscore = (PRUnichar)'_';
title = title.ReplaceChar(space, underscore);
title = title.ReplaceChar(dot, underscore);
title = title.ReplaceChar(bslash, underscore);
title = title.ReplaceChar(fslash, underscore);
title = title.ReplaceChar(at, underscore);
title = title.ReplaceChar(colon, underscore);
title.ReplaceChar(space, underscore);
title.ReplaceChar(dot, underscore);
title.ReplaceChar(bslash, underscore);
title.ReplaceChar(fslash, underscore);
title.ReplaceChar(at, underscore);
title.ReplaceChar(colon, underscore);
fileName = title;
fileName.Append(".html");
fileName.AppendWithConversion(".html");
}
}
else
@ -1452,7 +1452,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
char *leafName = docFileSpec.GetLeafName();
if (leafName)
{
fileName = leafName;
fileName.AssignWithConversion(leafName);
nsCRT::free(leafName);
}
docFileSpec.GetParent(parentPath);
@ -1488,7 +1488,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
if (webShell)
{
nsFileURL fileURL(docFileSpec);
nsAutoString fileURLString(fileURL.GetURLString());
nsAutoString fileURLString; fileURLString.AssignWithConversion(fileURL.GetURLString());
PRUnichar *fileURLUnicode = fileURLString.ToNewUnicode();
if (fileURLUnicode)
{
@ -1505,8 +1505,8 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
if (NS_FAILED(res))
{
nsAutoString saveDocStr, failedStr;
GetBundleString("SaveDocument", saveDocStr);
GetBundleString("SaveFileFailed", failedStr);
GetBundleString(NS_ConvertASCIItoUCS2("SaveDocument"), saveDocStr);
GetBundleString(NS_ConvertASCIItoUCS2("SaveFileFailed"), failedStr);
Alert(saveDocStr, failedStr);
} else {
// File was saved successfully
@ -1530,7 +1530,7 @@ NS_IMETHODIMP
nsEditorShell::CloseWindow( PRBool *_retval )
{
nsAutoString beforeClosingStr;
GetBundleString("BeforeClosing", beforeClosingStr);
GetBundleString(NS_ConvertASCIItoUCS2("BeforeClosing"), beforeClosingStr);
nsresult rv = CheckAndSaveDocument(beforeClosingStr.GetUnicode(), _retval);
@ -1581,7 +1581,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType
nsCOMPtr<nsIFileWidget> fileWidget;
nsAutoString HTMLTitle;
GetBundleString("OpenHTMLFile", HTMLTitle);
GetBundleString(NS_ConvertASCIItoUCS2("OpenHTMLFile"), HTMLTitle);
// An empty string should just result in "Open" for the dialog
nsAutoString title;
@ -1590,7 +1590,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType
title = HTMLTitle;
} else {
nsAutoString ImageTitle;
GetBundleString("SelectImageFile", ImageTitle);
GetBundleString(NS_ConvertASCIItoUCS2("SelectImageFile"), ImageTitle);
if (ImageTitle.Length() > 0 && imgFilter)
title = ImageTitle;
@ -1623,12 +1623,12 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType
nextTitle = titles;
nextFilter = filters;
GetBundleString("HTMLFiles", tempStr);
GetBundleString(NS_ConvertASCIItoUCS2("HTMLFiles"), tempStr);
*nextTitle++ = tempStr;
GetBundleString("TextFiles", tempStr);
GetBundleString(NS_ConvertASCIItoUCS2("TextFiles"), tempStr);
*nextTitle++ = tempStr;
*nextFilter++ = "*.htm; *.html; *.shtml";
*nextFilter++ = "*.txt";
(*nextFilter++).AssignWithConversion("*.htm; *.html; *.shtml");
(*nextFilter++).AssignWithConversion("*.txt");
fileWidget->SetFilterList(3, titles, filters);
} else {
titles = new nsString[2];
@ -1637,14 +1637,14 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType
return NS_ERROR_OUT_OF_MEMORY;
nextTitle = titles;
nextFilter = filters;
GetBundleString("IMGFiles", tempStr);
GetBundleString(NS_ConvertASCIItoUCS2("IMGFiles"), tempStr);
*nextTitle++ = tempStr;
*nextFilter++ = "*.gif; *.jpg; *.jpeg; *.png", "*.*";
(*nextFilter++).AssignWithConversion("*.gif; *.jpg; *.jpeg; *.png; *.*");
fileWidget->SetFilterList(2, titles, filters);
}
GetBundleString("AllFiles", tempStr);
GetBundleString(NS_ConvertASCIItoUCS2("AllFiles"), tempStr);
*nextTitle++ = tempStr;
*nextFilter++ = "*.*";
(*nextFilter++).AssignWithConversion("*.*");
// First param should be Parent window, but type is nsIWidget*
// Bug is filed to change this to a more suitable window type
dialogResult = fileWidget->GetFile(/*parent*/ nsnull, title, fileSpec);
@ -1660,7 +1660,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType
// Convert it to the string version of the URL format
// NOTE: THIS CRASHES IF fileSpec is empty
nsFileURL url(fileSpec);
nsAutoString returnVal = url.GetURLString();
nsAutoString returnVal; returnVal.AssignWithConversion(url.GetURLString());
*_retval = returnVal.ToNewUnicode();
}
// TODO: SAVE THIS TO THE PREFS?
@ -1686,7 +1686,7 @@ nsEditorShell::UpdateWindowTitle()
res = GetDocumentTitleString(windowCaption);
// If title is empty, use "untitled"
if (windowCaption.Length() == 0)
GetBundleString("untitled", windowCaption);
GetBundleString(NS_ConvertASCIItoUCS2("untitled"), windowCaption);
// Append just the 'leaf' filename to the Doc. Title for the window caption
if (NS_SUCCEEDED(res))
@ -1704,9 +1704,9 @@ nsEditorShell::UpdateWindowTitle()
{
nsAutoString name;
docFileSpec.GetLeafName(name);
windowCaption += " [";
windowCaption.AppendWithConversion(" [");
windowCaption += name;
windowCaption += "]";
windowCaption.AppendWithConversion("]");
}
}
}
@ -1755,7 +1755,7 @@ nsEditorShell::GetDocumentTitle(PRUnichar **title)
*title = titleStr.ToNewUnicode();
} else {
// Don't fail, just return an empty string
nsAutoString empty("");
nsAutoString empty;
*title = empty.ToNewUnicode();
res = NS_OK;
}
@ -1796,7 +1796,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title)
nsCOMPtr<nsIDOMNode>titleNode;
nsCOMPtr<nsIDOMNode>headNode;
nsCOMPtr<nsIDOMNode> resultNode;
res = domDoc->GetElementsByTagName("title", getter_AddRefs(titleList));
res = domDoc->GetElementsByTagName(NS_ConvertASCIItoUCS2("title"), getter_AddRefs(titleList));
if (NS_SUCCEEDED(res))
{
if(titleList)
@ -1832,7 +1832,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title)
}
// Get the <HEAD> node, create a <TITLE> and insert it under the HEAD
nsCOMPtr<nsIDOMNodeList> headList;
res = domDoc->GetElementsByTagName("head",getter_AddRefs(headList));
res = domDoc->GetElementsByTagName(NS_ConvertASCIItoUCS2("head"),getter_AddRefs(headList));
if (NS_FAILED(res)) return res;
if (headList)
{
@ -1844,7 +1844,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title)
{
// Didn't find one above: Create a new one
nsCOMPtr<nsIDOMElement>titleElement;
res = domDoc->CreateElement("title",getter_AddRefs(titleElement));
res = domDoc->CreateElement(NS_ConvertASCIItoUCS2("title"),getter_AddRefs(titleElement));
if (NS_SUCCEEDED(res) && titleElement)
{
titleNode = do_QueryInterface(titleElement);
@ -2367,7 +2367,7 @@ nsEditorShell::GetString(const PRUnichar *name, PRUnichar **_retval)
return NS_ERROR_NULL_POINTER;
// Don't fail, just return an empty string
nsAutoString empty("");
nsAutoString empty;
if (mStringBundle)
{
@ -2391,13 +2391,13 @@ void nsEditorShell::GetBundleString(const nsString& name, nsString &outString)
if (NS_SUCCEEDED(mStringBundle->GetStringFromName(name.GetUnicode(), &ptrv)))
outString = ptrv;
else
outString = "";
outString.SetLength(0);
nsAllocator::Free(ptrv);
}
else
{
outString = "";
outString.SetLength(0);
}
}
@ -2417,22 +2417,22 @@ nsEditorShell::ConfirmWithCancel(const nsString& aTitle, const nsString& aQuesti
// Stuff in Parameters
block->SetInt( nsICommonDialogs::eNumberButtons,3 );
block->SetString( nsICommonDialogs::eMsg, aQuestion.GetUnicode());
nsAutoString url( "chrome://global/skin/question-icon.gif" );
nsAutoString url; url.AssignWithConversion( "chrome://global/skin/question-icon.gif" );
block->SetString( nsICommonDialogs::eIconURL, url.GetUnicode());
nsAutoString yesStr, noStr;
if (aYesString)
yesStr = *aYesString;
yesStr.Assign(*aYesString);
else
GetBundleString("Yes", yesStr);
GetBundleString(NS_ConvertASCIItoUCS2("Yes"), yesStr);
if (aNoString)
noStr = *aNoString;
noStr.Assign(*aNoString);
else
GetBundleString("No", noStr);
GetBundleString(NS_ConvertASCIItoUCS2("No"), noStr);
nsAutoString cancelStr;
GetBundleString("Cancel", cancelStr);
GetBundleString(NS_ConvertASCIItoUCS2("Cancel"), cancelStr);
block->SetString( nsICommonDialogs::eDialogTitle, aTitle.GetUnicode() );
//Note: "button0" is always Ok or Yes action, "button1" is Cancel
@ -2729,12 +2729,12 @@ nsEditorShell::MakeOrChangeList(const PRUnichar *listType)
case eHTMLTextEditorType:
if (aListType.IsEmpty())
{
err = mEditor->RemoveList("ol");
err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("ol"));
if(NS_SUCCEEDED(err))
{
err = mEditor->RemoveList("ul");
err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("ul"));
if(NS_SUCCEEDED(err))
err = mEditor->RemoveList("dl");
err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("dl"));
}
}
else
@ -2761,12 +2761,12 @@ nsEditorShell::RemoveList(const PRUnichar *listType)
case eHTMLTextEditorType:
if (aListType.IsEmpty())
{
err = mEditor->RemoveList("ol");
err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("ol"));
if(NS_SUCCEEDED(err))
{
err = mEditor->RemoveList("ul");
err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("ul"));
if(NS_SUCCEEDED(err))
err = mEditor->RemoveList("dl");
err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("dl"));
}
}
else
@ -3746,7 +3746,7 @@ nsEditorShell::GetSuggestedWord(PRUnichar **aSuggestedWord)
mSuggestedWordIndex++;
} else {
// A blank string signals that there are no more strings
word = "";
word.SetLength(0);
}
result = NS_OK;
}
@ -3820,7 +3820,7 @@ nsEditorShell::GetPersonalDictionaryWord(PRUnichar **aDictionaryWord)
mDictionaryIndex++;
} else {
// A blank string signals that there are no more strings
word = "";
word.SetLength(0);
}
result = NS_OK;
}
@ -4001,7 +4001,7 @@ nsEditorShell::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, cons
{
// Start the throbber
// TODO: We should also start/stop it for saving and publishing?
SetChromeAttribute( mDocShell, "Editor:Throbber", "busy", "true" );
SetChromeAttribute( mDocShell, "Editor:Throbber", "busy", NS_ConvertASCIItoUCS2("true") );
// Disable JavaScript in this document:
nsCOMPtr<nsIScriptGlobalObjectOwner> sgoo (do_QueryInterface(mContentAreaDocShell));
@ -4073,8 +4073,8 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* aChanne
if (mCloseWindowWhenLoaded && isRootDoc)
{
nsAutoString alertLabel, alertMessage;
GetBundleString("Alert", alertLabel);
GetBundleString("CantEditFramesetMsg", alertMessage);
GetBundleString(NS_ConvertASCIItoUCS2("Alert"), alertLabel);
GetBundleString(NS_ConvertASCIItoUCS2("CantEditFramesetMsg"), alertMessage);
Alert(alertLabel, alertMessage);
nsCOMPtr<nsIBaseWindow> baseWindow;
@ -4093,11 +4093,11 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* aChanne
nsCOMPtr<nsIURI> aUrl;
aChannel->GetURI(getter_AddRefs(aUrl));
res = PrepareDocumentForEditing(aLoader, aUrl);
SetChromeAttribute( mDocShell, "Editor:Throbber", "busy", "false" );
SetChromeAttribute( mDocShell, "Editor:Throbber", "busy", NS_ConvertASCIItoUCS2("false") );
}
nsAutoString doneText;
GetBundleString("LoadingDone", doneText);
GetBundleString(NS_ConvertASCIItoUCS2("LoadingDone"), doneText);
SetChromeAttribute(mDocShell, "statusText", "value", doneText);
return res;

View File

@ -359,12 +359,12 @@ nsEditorTxnLog::GetString(nsITransaction *aTransaction, char *aBuffer, PRInt32 a
aBuffer[0] = '\0';
nsString str = "";
nsString str;
aTransaction->GetRedoString(&str);
if (str.Length() == 0)
str = "<NULL>";
str.AssignWithConversion("<NULL>");
str.ToCString(aBuffer, aBufferLength);
aBuffer[aBufferLength - 1] = '\0';

View File

@ -177,9 +177,9 @@ static PRBool IsListNode(nsIDOMNode *aNode)
tagName.ToLowerCase();
// With only 3 tests, it doesn't
// seem worth using nsAtoms
if (tagName.Equals("ol") ||
tagName.Equals("ul") ||
tagName.Equals("dl"))
if (tagName.EqualsWithConversion("ol") ||
tagName.EqualsWithConversion("ul") ||
tagName.EqualsWithConversion("dl"))
{
return PR_TRUE;
}
@ -448,7 +448,7 @@ nsHTMLEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
PRBool newMetaCharset = PR_TRUE;
// get a list of META tags
result = domdoc->GetElementsByTagName("meta", getter_AddRefs(metaList));
result = domdoc->GetElementsByTagName(NS_ConvertASCIItoUCS2("meta"), getter_AddRefs(metaList));
if (NS_SUCCEEDED(result) && metaList) {
PRUint32 listLength = 0;
(void) metaList->GetLength(&listLength);
@ -459,20 +459,20 @@ nsHTMLEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
metaElement = do_QueryInterface(metaNode);
if (!metaElement) continue;
const nsString content("charset=");
const NS_ConvertASCIItoUCS2 content("charset=");
nsString currentValue;
if (NS_FAILED(metaElement->GetAttribute("http-equiv", currentValue))) continue;
if (NS_FAILED(metaElement->GetAttribute(NS_ConvertASCIItoUCS2("http-equiv"), currentValue))) continue;
if (kNotFound != currentValue.Find("content-type", PR_TRUE)) {
if (NS_FAILED(metaElement->GetAttribute("content", currentValue))) continue;
if (NS_FAILED(metaElement->GetAttribute(NS_ConvertASCIItoUCS2("content"), currentValue))) continue;
PRInt32 offset = currentValue.Find(content.GetUnicode(), PR_TRUE);
if (kNotFound != offset) {
currentValue.Left(newMetaString, offset); // copy current value before "charset=" (e.g. text/html)
newMetaString.Append(content);
newMetaString.Append(characterSet);
result = nsEditor::SetAttribute(metaElement, "content", newMetaString);
result = nsEditor::SetAttribute(metaElement, NS_ConvertASCIItoUCS2("content"), newMetaString);
if (NS_SUCCEEDED(result))
newMetaCharset = PR_FALSE;
break;
@ -486,12 +486,12 @@ nsHTMLEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
nsCOMPtr<nsIDOMNode>headNode;
nsCOMPtr<nsIDOMNode>resultNode;
result = domdoc->GetElementsByTagName("head",getter_AddRefs(headList));
result = domdoc->GetElementsByTagName(NS_ConvertASCIItoUCS2("head"),getter_AddRefs(headList));
if (NS_SUCCEEDED(result) && headList) {
headList->Item(0, getter_AddRefs(headNode));
if (headNode) {
// Create a new meta charset tag
result = CreateNode("meta", headNode, 0, getter_AddRefs(resultNode));
result = CreateNode(NS_ConvertASCIItoUCS2("meta"), headNode, 0, getter_AddRefs(resultNode));
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
@ -500,12 +500,12 @@ nsHTMLEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
metaElement = do_QueryInterface(resultNode);
if (metaElement) {
// not undoable, undo should undo CreateNode
result = metaElement->SetAttribute("http-equiv", "Content-Type");
result = metaElement->SetAttribute(NS_ConvertASCIItoUCS2("http-equiv"), NS_ConvertASCIItoUCS2("Content-Type"));
if (NS_SUCCEEDED(result)) {
newMetaString.Assign("text/html;charset=");
newMetaString.AssignWithConversion("text/html;charset=");
newMetaString.Append(characterSet);
// not undoable, undo should undo CreateNode
result = metaElement->SetAttribute("content", newMetaString);
result = metaElement->SetAttribute(NS_ConvertASCIItoUCS2("content"), newMetaString);
}
}
}
@ -771,7 +771,7 @@ NS_IMETHODIMP nsHTMLEditor::TabInTable(PRBool inIsShift, PRBool *outHandled)
// Find enclosing table cell from the selection (cell may be the selected element)
nsCOMPtr<nsIDOMElement> cellElement;
nsresult res = GetElementOrParentByTagName("td", nsnull, getter_AddRefs(cellElement));
nsresult res = GetElementOrParentByTagName(NS_ConvertASCIItoUCS2("td"), nsnull, getter_AddRefs(cellElement));
if (NS_FAILED(res)) return res;
// Do nothing -- we didn't find a table cell
if (!cellElement) return NS_OK;
@ -826,7 +826,7 @@ NS_IMETHODIMP nsHTMLEditor::CreateBRImpl(nsCOMPtr<nsIDOMNode> *aInOutParent, PRI
nsCOMPtr<nsIDOMNode> node = *aInOutParent;
PRInt32 theOffset = *aInOutOffset;
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(node);
nsAutoString brType("br");
nsAutoString brType; brType.AssignWithConversion("br");
nsCOMPtr<nsIDOMNode> brNode;
if (nodeAsText)
{
@ -1414,7 +1414,7 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
if (attrString.EqualsIgnoreCase(*aAttribute)) continue;
// if it's a special _moz... attribute, keep looking
attrString.Left(tmp,4);
if (tmp.Equals("_moz")) continue;
if (tmp.EqualsWithConversion("_moz")) continue;
// otherwise, it's another attribute, so return false
return PR_FALSE;
}
@ -1446,7 +1446,7 @@ nsHTMLEditor::HasMatchingAttributes(nsIDOMNode *aNode1,
attrName->ToString(attrString);
// if it's a special _moz... attribute, keep going
attrString.Left(tmp,4);
if (tmp.Equals("_moz")) continue;
if (tmp.EqualsWithConversion("_moz")) continue;
// otherwise, it's another attribute, so count it
realCount1++;
// and compare it to element2's attributes
@ -1464,7 +1464,7 @@ nsHTMLEditor::HasMatchingAttributes(nsIDOMNode *aNode1,
attrName->ToString(attrString);
// if it's a special _moz... attribute, keep going
attrString.Left(tmp,4);
if (tmp.Equals("_moz")) continue;
if (tmp.EqualsWithConversion("_moz")) continue;
// otherwise, it's another attribute, so count it
realCount2++;
}
@ -2353,7 +2353,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertBreak()
{
// create the new BR node
nsCOMPtr<nsIDOMNode> newNode;
nsAutoString tag("BR");
nsAutoString tag; tag.AssignWithConversion("BR");
res = DeleteSelectionAndCreateNode(tag, getter_AddRefs(newNode));
if (!newNode) res = NS_ERROR_NULL_POINTER; // don't return here, so DidDoAction is called
if (NS_SUCCEEDED(res))
@ -2681,7 +2681,7 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
if (aGetLists)
{
// Get the "ol", "ul", or "dl" parent element
res = GetElementOrParentByTagName("list", node, getter_AddRefs(blockParentElem));
res = GetElementOrParentByTagName(NS_ConvertASCIItoUCS2("list"), node, getter_AddRefs(blockParentElem));
if (NS_FAILED(res)) return res;
}
else
@ -2735,7 +2735,7 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
if (aGetLists)
{
// Get the "ol", "ul", or "dl" parent element
res = GetElementOrParentByTagName("list", startParent, getter_AddRefs(blockParent));
res = GetElementOrParentByTagName(NS_ConvertASCIItoUCS2("list"), startParent, getter_AddRefs(blockParent));
}
else
{
@ -2800,7 +2800,7 @@ nsHTMLEditor::MakeOrChangeList(const nsString& aListType)
if (!selection) return NS_ERROR_NULL_POINTER;
nsTextRulesInfo ruleInfo(nsHTMLEditRules::kMakeList);
if (aListType.Equals("ol")) ruleInfo.bOrdered = PR_TRUE;
if (aListType.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE;
else ruleInfo.bOrdered = PR_FALSE;
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (cancel || (NS_FAILED(res))) return res;
@ -2846,7 +2846,7 @@ nsHTMLEditor::MakeOrChangeList(const nsString& aListType)
res = CreateNode(aListType, parent, offset, getter_AddRefs(newList));
if (NS_FAILED(res)) return res;
// make a list item
nsAutoString tag("li");
nsAutoString tag; tag.AssignWithConversion("li");
nsCOMPtr<nsIDOMNode> newItem;
res = CreateNode(tag, newList, 0, getter_AddRefs(newItem));
if (NS_FAILED(res)) return res;
@ -2878,7 +2878,7 @@ nsHTMLEditor::RemoveList(const nsString& aListType)
if (!selection) return NS_ERROR_NULL_POINTER;
nsTextRulesInfo ruleInfo(nsHTMLEditRules::kRemoveList);
if (aListType.Equals("ol")) ruleInfo.bOrdered = PR_TRUE;
if (aListType.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE;
else ruleInfo.bOrdered = PR_FALSE;
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (cancel || (NS_FAILED(res))) return res;
@ -2971,7 +2971,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
PRBool cancel, handled;
PRInt32 theAction = nsHTMLEditRules::kIndent;
PRInt32 opID = kOpIndent;
if (aIndent.Equals("outdent"))
if (aIndent.EqualsWithConversion("outdent"))
{
theAction = nsHTMLEditRules::kOutdent;
opID = kOpOutdent;
@ -3002,7 +3002,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
if (!node) res = NS_ERROR_FAILURE;
if (NS_FAILED(res)) return res;
nsAutoString inward("indent");
nsAutoString inward; inward.AssignWithConversion("indent");
if (aIndent == inward)
{
if (isCollapsed)
@ -3011,7 +3011,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
nsCOMPtr<nsIDOMNode> parent = node;
nsCOMPtr<nsIDOMNode> topChild = node;
nsCOMPtr<nsIDOMNode> tmp;
nsAutoString bq("blockquote");
nsAutoString bq; bq.AssignWithConversion("blockquote");
while ( !CanContainTag(parent, bq))
{
parent->GetParentNode(getter_AddRefs(tmp));
@ -3034,7 +3034,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
// put a space in it so layout will draw the list item
res = selection->Collapse(newBQ,0);
if (NS_FAILED(res)) return res;
nsAutoString theText(" ");
nsAutoString theText; theText.AssignWithConversion(" ");
res = InsertText(theText);
if (NS_FAILED(res)) return res;
// reposition selection to before the space character
@ -3120,7 +3120,7 @@ nsHTMLEditor::GetElementOrParentByTagName(const nsString &aTagName, nsIDOMNode *
PRBool getNamedAnchor = IsNamedAnchor(TagName);
if ( getLink || getNamedAnchor)
{
TagName = "a";
TagName.AssignWithConversion("a");
}
PRBool findTableCell = aTagName.EqualsIgnoreCase("td");
PRBool findList = aTagName.EqualsIgnoreCase("list");
@ -3261,7 +3261,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
}
#endif
nsCOMPtr<nsIDOMElement> parentLinkOfAnchor;
res = GetElementOrParentByTagName("href", anchorNode, getter_AddRefs(parentLinkOfAnchor));
res = GetElementOrParentByTagName(NS_ConvertASCIItoUCS2("href"), anchorNode, getter_AddRefs(parentLinkOfAnchor));
// XXX: ERROR_HANDLING can parentLinkOfAnchor be null?
if (NS_SUCCEEDED(res) && parentLinkOfAnchor)
{
@ -3272,7 +3272,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
} else if(focusNode)
{ // Link node must be the same for both ends of selection
nsCOMPtr<nsIDOMElement> parentLinkOfFocus;
res = GetElementOrParentByTagName("href", focusNode, getter_AddRefs(parentLinkOfFocus));
res = GetElementOrParentByTagName(NS_ConvertASCIItoUCS2("href"), focusNode, getter_AddRefs(parentLinkOfFocus));
if (NS_SUCCEEDED(res) && parentLinkOfFocus == parentLinkOfAnchor)
bNodeFound = PR_TRUE;
}
@ -3415,7 +3415,7 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
if (IsLink(TagName) || IsNamedAnchor(TagName))
{
realTagName = "a";
realTagName.AssignWithConversion("a");
} else {
realTagName = TagName;
}
@ -3430,26 +3430,26 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
return NS_ERROR_FAILURE;
// Mark the new element dirty, so it will be formatted
newElement->SetAttribute("_moz_dirty", "");
newElement->SetAttribute(NS_ConvertASCIItoUCS2("_moz_dirty"), nsAutoString());
// Set default values for new elements
if (TagName.Equals("hr"))
if (TagName.EqualsWithConversion("hr"))
{
// Note that we read the user's attributes for these from prefs (in InsertHLine JS)
newElement->SetAttribute("align","center");
newElement->SetAttribute("width","100%");
newElement->SetAttribute("size","2");
} else if (TagName.Equals("table"))
newElement->SetAttribute(NS_ConvertASCIItoUCS2("align"),NS_ConvertASCIItoUCS2("center"));
newElement->SetAttribute(NS_ConvertASCIItoUCS2("width"),NS_ConvertASCIItoUCS2("100%"));
newElement->SetAttribute(NS_ConvertASCIItoUCS2("size"),NS_ConvertASCIItoUCS2("2"));
} else if (TagName.EqualsWithConversion("table"))
{
newElement->SetAttribute("cellpadding","2");
newElement->SetAttribute("cellspacing","2");
newElement->SetAttribute("border","1");
} else if (TagName.Equals("tr"))
newElement->SetAttribute(NS_ConvertASCIItoUCS2("cellpadding"),NS_ConvertASCIItoUCS2("2"));
newElement->SetAttribute(NS_ConvertASCIItoUCS2("cellspacing"),NS_ConvertASCIItoUCS2("2"));
newElement->SetAttribute(NS_ConvertASCIItoUCS2("border"),NS_ConvertASCIItoUCS2("1"));
} else if (TagName.EqualsWithConversion("tr"))
{
newElement->SetAttribute("valign","top");
} else if (TagName.Equals("td"))
newElement->SetAttribute(NS_ConvertASCIItoUCS2("valign"),NS_ConvertASCIItoUCS2("top"));
} else if (TagName.EqualsWithConversion("td"))
{
newElement->SetAttribute("valign","top");
newElement->SetAttribute(NS_ConvertASCIItoUCS2("valign"),NS_ConvertASCIItoUCS2("top"));
// I'm def'ing this out to see if auto br insertion is working here
#if 0
@ -3523,7 +3523,7 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
if (href.GetUnicode() && href.Length() > 0)
{
nsAutoEditBatch beginBatching(this);
const nsString attribute("href");
nsString attribute; attribute.AssignWithConversion("href");
SetInlineProperty(nsIEditProperty::a, &attribute, &href);
//TODO: Enumerate through other properties of the anchor tag
// and set those as well.
@ -3556,7 +3556,7 @@ nsHTMLEditor::SetBackgroundColor(const nsString& aColor)
{
while(cell)
{
SetAttribute(cell, "bgcolor", aColor);
SetAttribute(cell, NS_ConvertASCIItoUCS2("bgcolor"), aColor);
GetNextSelectedCell(getter_AddRefs(cell), nsnull);
};
return NS_OK;
@ -3570,7 +3570,7 @@ nsHTMLEditor::SetBackgroundColor(const nsString& aColor)
if (!element) return NS_ERROR_NULL_POINTER;
}
// Use the editor method that goes through the transaction system
return SetAttribute(element, "bgcolor", aColor);
return SetAttribute(element, NS_ConvertASCIItoUCS2("bgcolor"), aColor);
}
NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsString& aAttribute, const nsString& aValue)
@ -3990,7 +3990,7 @@ NS_IMETHODIMP nsHTMLEditor::SetBodyWrapWidth(PRInt32 aWrapColumn)
if (!bodyElement) return NS_ERROR_NULL_POINTER;
// Get the current style for this body element:
nsAutoString styleName ("style");
nsAutoString styleName; styleName.AssignWithConversion("style");
nsAutoString styleValue;
res = bodyElement->GetAttribute(styleName, styleValue);
if (NS_FAILED(res)) return res;
@ -4005,26 +4005,26 @@ NS_IMETHODIMP nsHTMLEditor::SetBodyWrapWidth(PRInt32 aWrapColumn)
if (styleValue.Length() > 0)
{
styleValue.Trim("; \t", PR_FALSE, PR_TRUE);
styleValue.Append("; ");
styleValue.AppendWithConversion("; ");
}
// Make sure we have fixed-width font. This should be done for us,
// but it isn't, see bug 22502, so we have to add "font: monospace;".
// Only do this if we're wrapping.
if (aWrapColumn >= 0)
styleValue.Append("font-family: monospace; ");
styleValue.AppendWithConversion("font-family: monospace; ");
// and now we're ready to set the new whitespace/wrapping style.
if (aWrapColumn > 0) // Wrap to a fixed column
{
styleValue.Append("white-space: -moz-pre-wrap; width: ");
styleValue.Append(aWrapColumn);
styleValue.Append("ch;");
styleValue.AppendWithConversion("white-space: -moz-pre-wrap; width: ");
styleValue.AppendInt(aWrapColumn);
styleValue.AppendWithConversion("ch;");
}
else if (aWrapColumn == 0)
styleValue.Append("white-space: -moz-pre-wrap;");
styleValue.AppendWithConversion("white-space: -moz-pre-wrap;");
else
styleValue.Append("white-space: pre;");
styleValue.AppendWithConversion("white-space: pre;");
res = bodyElement->SetAttribute(styleName, styleValue);
@ -4090,9 +4090,9 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
tagName.ToLowerCase();
// See if it's an image or an embed
if (tagName.Equals("img") || tagName.Equals("embed"))
if (tagName.EqualsWithConversion("img") || tagName.EqualsWithConversion("embed"))
(*aNodeList)->AppendElement(node);
else if (tagName.Equals("a"))
else if (tagName.EqualsWithConversion("a"))
{
// XXX Only include links if they're links to file: URLs
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor (do_QueryInterface(content));
@ -4100,7 +4100,7 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
{
nsAutoString href;
if (NS_SUCCEEDED(anchor->GetHref(href)))
if (href.Compare("file:", PR_TRUE, 5) == 0)
if (href.CompareWithConversion("file:", PR_TRUE, 5) == 0)
(*aNodeList)->AppendElement(node);
}
}
@ -4265,11 +4265,11 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
PRUint32 len = 0;
if ( NS_SUCCEEDED(trans->GetAnyTransferData(&bestFlavor, getter_AddRefs(genericDataObj), &len)) )
{
nsAutoString flavor ( bestFlavor ); // just so we can use flavor.Equals()
nsAutoString flavor; flavor.AssignWithConversion( bestFlavor ); // just so we can use flavor.Equals()
#ifdef DEBUG_akkana
printf("Got flavor [%s]\n", bestFlavor);
#endif
if (flavor.Equals(kHTMLMime))
if (flavor.EqualsWithConversion(kHTMLMime))
{
nsCOMPtr<nsISupportsWString> textDataObj ( do_QueryInterface(genericDataObj) );
if (textDataObj && len > 0)
@ -4281,7 +4281,7 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
rv = InsertHTML(stuffToPaste);
}
}
else if (flavor.Equals(kUnicodeMime))
else if (flavor.EqualsWithConversion(kUnicodeMime))
{
nsCOMPtr<nsISupportsWString> textDataObj ( do_QueryInterface(genericDataObj) );
if (textDataObj && len > 0)
@ -4293,7 +4293,7 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
rv = InsertText(stuffToPaste);
}
}
else if (flavor.Equals(kJPEGImageMime))
else if (flavor.EqualsWithConversion(kJPEGImageMime))
{
// Insert Image code here
printf("Don't know how to insert an image yet!\n");
@ -4385,7 +4385,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsQuotation(PRInt32 aSelectionType)
if (mFlags & eEditorPlaintextMask)
return PasteAsPlaintextQuotation(aSelectionType);
nsAutoString citation("");
nsAutoString citation;
return PasteAsCitedQuotation(citation, aSelectionType);
}
@ -4410,7 +4410,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation,
if (!handled)
{
nsCOMPtr<nsIDOMNode> newNode;
nsAutoString tag("blockquote");
nsAutoString tag; tag.AssignWithConversion("blockquote");
res = DeleteSelectionAndCreateNode(tag, getter_AddRefs(newNode));
if (NS_FAILED(res)) return res;
if (!newNode) return NS_ERROR_NULL_POINTER;
@ -4419,8 +4419,8 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation,
nsCOMPtr<nsIDOMElement> newElement (do_QueryInterface(newNode));
if (newElement)
{
nsAutoString type ("type");
nsAutoString cite ("cite");
nsAutoString type; type.AssignWithConversion("type");
nsAutoString cite; cite.AssignWithConversion("cite");
newElement->SetAttribute(type, cite);
}
@ -4480,9 +4480,9 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation(PRInt32 aSelectionType)
#ifdef DEBUG_akkana
printf("Got flavor [%s]\n", flav);
#endif
nsAutoString flavor(flav);
nsAutoString flavor; flavor.AssignWithConversion(flav);
nsAutoString stuffToPaste;
if (flavor.Equals(kUnicodeMime))
if (flavor.EqualsWithConversion(kUnicodeMime))
{
nsCOMPtr<nsISupportsWString> textDataObj ( do_QueryInterface(genericDataObj) );
if (textDataObj && len > 0)
@ -4506,8 +4506,8 @@ NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText,
if (mFlags & eEditorPlaintextMask)
return InsertAsPlaintextQuotation(aQuotedText, aNodeInserted);
nsAutoString citation ("");
nsAutoString charset ("");
nsAutoString citation;
nsAutoString charset;
return InsertAsCitedQuotation(aQuotedText, citation, PR_FALSE,
charset, aNodeInserted);
}
@ -4562,7 +4562,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
if (!handled)
{
// Wrap the inserted quote in a <pre> so it won't be wrapped:
nsAutoString tag("pre");
nsAutoString tag; tag.AssignWithConversion("pre");
rv = DeleteSelectionAndCreateNode(tag, getter_AddRefs(preNode));
// If this succeeded, then set selection inside the pre
@ -4575,7 +4575,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
// Do this after the insertion, so that
nsCOMPtr<nsIDOMElement> preElement (do_QueryInterface(preNode));
if (preElement)
preElement->SetAttribute("_moz_quote", "true");
preElement->SetAttribute(NS_ConvertASCIItoUCS2("_moz_quote"), NS_ConvertASCIItoUCS2("true"));
// and set the selection inside it:
selection->Collapse(preNode, 0);
@ -4626,7 +4626,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
if (cancel) return NS_OK; // rules canceled the operation
if (!handled)
{
nsAutoString tag("blockquote");
nsAutoString tag; tag.AssignWithConversion("blockquote");
res = DeleteSelectionAndCreateNode(tag, getter_AddRefs(newNode));
if (NS_FAILED(res)) return res;
if (!newNode) return NS_ERROR_NULL_POINTER;
@ -4635,8 +4635,8 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
nsCOMPtr<nsIDOMElement> newElement (do_QueryInterface(newNode));
if (newElement)
{
nsAutoString type ("type");
nsAutoString cite ("cite");
nsAutoString type; type.AssignWithConversion("type");
nsAutoString cite; cite.AssignWithConversion("cite");
newElement->SetAttribute(type, cite);
if (aCitation.Length() > 0)
@ -4694,14 +4694,14 @@ NS_IMETHODIMP nsHTMLEditor::OutputToString(nsString& aOutputString,
// special-case for empty document when requesting plain text,
// to account for the bogus text node
if (aFormatType.Equals("text/plain"))
if (aFormatType.EqualsWithConversion("text/plain"))
{
PRBool docEmpty;
rv = GetDocumentIsEmpty(&docEmpty);
if (NS_FAILED(rv)) return rv;
if (docEmpty) {
aOutputString = "";
aOutputString.SetLength(0);
return NS_OK;
}
else if (mFlags & eEditorPlaintextMask)
@ -4780,7 +4780,7 @@ NS_IMETHODIMP nsHTMLEditor::OutputToStream(nsIOutputStream* aOutputStream,
// special-case for empty document when requesting plain text,
// to account for the bogus text node
if (aFormatType.Equals("text/plain"))
if (aFormatType.EqualsWithConversion("text/plain"))
{
PRBool docEmpty;
rv = GetDocumentIsEmpty(&docEmpty);
@ -4817,7 +4817,7 @@ NS_IMETHODIMP nsHTMLEditor::OutputToStream(nsIOutputStream* aOutputStream,
return rv;
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
if (aCharset && aCharset->Length() != 0 && aCharset->Equals("null")==PR_FALSE)
if (aCharset && aCharset->Length() != 0 && aCharset->EqualsWithConversion("null")==PR_FALSE)
encoder->SetCharset(*aCharset);
rv = encoder->Init(doc, aFormatType, aFlags);
@ -5004,7 +5004,7 @@ nsHTMLEditor::CanContainTag(nsIDOMNode* aParent, const nsString &aTag)
{
// CNavDTD gives some unwanted results. We override them here.
// if parent is a list and tag is text, say "no".
if (IsListNode(aParent) && (aTag.Equals("__moz_text")))
if (IsListNode(aParent) && (aTag.EqualsWithConversion("__moz_text")))
return PR_FALSE;
// else fall thru
return nsEditor::CanContainTag(aParent, aTag);
@ -5345,7 +5345,7 @@ nsHTMLEditor::IsTable(nsIDOMNode *node)
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTable");
nsAutoString tag;
nsEditor::GetTagString(node,tag);
if (tag.Equals("table"))
if (tag.EqualsWithConversion("table"))
{
return PR_TRUE;
}
@ -5362,7 +5362,7 @@ nsHTMLEditor::IsTableCell(nsIDOMNode *node)
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTableCell");
nsAutoString tag;
nsEditor::GetTagString(node,tag);
if (tag.Equals("td") || tag.Equals("th"))
if (tag.EqualsWithConversion("td") || tag.EqualsWithConversion("th"))
{
return PR_TRUE;
}
@ -5379,10 +5379,10 @@ nsHTMLEditor::IsTableElement(nsIDOMNode *node)
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTableElement");
nsAutoString tagName;
nsEditor::GetTagString(node,tagName);
if (tagName.Equals("table") || tagName.Equals("tr") ||
tagName.Equals("td") || tagName.Equals("th") ||
tagName.Equals("thead") || tagName.Equals("tfoot") ||
tagName.Equals("tbody") || tagName.Equals("caption"))
if (tagName.EqualsWithConversion("table") || tagName.EqualsWithConversion("tr") ||
tagName.EqualsWithConversion("td") || tagName.EqualsWithConversion("th") ||
tagName.EqualsWithConversion("thead") || tagName.EqualsWithConversion("tfoot") ||
tagName.EqualsWithConversion("tbody") || tagName.EqualsWithConversion("caption"))
{
return PR_TRUE;
}
@ -5957,10 +5957,7 @@ nsHTMLEditor::RelativeFontChangeOnTextNode( PRInt32 aSizeChange,
}
// reparent the node inside font node with appropriate relative size
nsAutoString tag;
if (aSizeChange == 1) tag = "big";
else tag = "small";
res = InsertContainerAbove(node, &tmp, tag);
res = InsertContainerAbove(node, &tmp, NS_ConvertASCIItoUCS2( aSizeChange==1 ? "big" : "small" ));
return res;
}
@ -5977,8 +5974,8 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange,
nsresult res = NS_OK;
nsCOMPtr<nsIDOMNode> tmp;
nsAutoString tag;
if (aSizeChange == 1) tag = "big";
else tag = "small";
if (aSizeChange == 1) tag.AssignWithConversion("big");
else tag.AssignWithConversion("small");
// is this node a text node?
if (IsTextNode(aNode))

View File

@ -100,7 +100,7 @@ void nsEditorParserObserver::Notify()
NS_IMETHODIMP nsEditorParserObserver::Start()
{
nsresult res = NS_OK;
nsAutoString parserService("text/html");
nsAutoString parserService; parserService.AssignWithConversion("text/html");
nsCOMPtr<nsIObserverService> anObserverService = do_GetService(NS_OBSERVERSERVICE_PROGID, &res);
if (NS_FAILED(res)) return res;
@ -111,7 +111,7 @@ NS_IMETHODIMP nsEditorParserObserver::Start()
NS_IMETHODIMP nsEditorParserObserver::End()
{
nsresult res = NS_OK;
nsAutoString parserService("text/html");
nsAutoString parserService; parserService.AssignWithConversion("text/html");
nsCOMPtr<nsIObserverService> anObserverService = do_GetService(NS_OBSERVERSERVICE_PROGID, &res);
if (NS_FAILED(res)) return res;

View File

@ -178,10 +178,10 @@ SetChromeAttribute( nsIDocShell *shell, const char *id,
{
// Find specified element.
nsCOMPtr<nsIDOMElement> elem;
rv = xulDoc->GetElementById( id, getter_AddRefs(elem) );
rv = xulDoc->GetElementById( NS_ConvertASCIItoUCS2(id), getter_AddRefs(elem) );
if ( elem )
// Set the text attribute.
rv = elem->SetAttribute( name, value );
rv = elem->SetAttribute( NS_ConvertASCIItoUCS2(name), value );
}
}
return rv;
@ -273,7 +273,7 @@ nsEditorShell::QueryInterface(REFNSIID aIID,void** aInstancePtr)
NS_IMETHODIMP
nsEditorShell::Init()
{
nsAutoString editorType = "html"; // default to creating HTML editor
nsAutoString editorType; editorType.AssignWithConversion("html"); // default to creating HTML editor
mEditorTypeString = editorType;
mEditorTypeString.ToLowerCase();
@ -462,7 +462,7 @@ nsEditorShell::PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUr
// Load style sheet with settings that should never
// change, even in "Browser" mode
// We won't unload this, so we don't need to be returned the style sheet pointer
styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorOverride.css", nsnull);
styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorOverride.css"), nsnull);
// Load the edit mode override style sheet
// This will be remove for "Browser" mode
@ -472,9 +472,9 @@ nsEditorShell::PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUr
// Activate the debug menu only in debug builds
// by removing the "hidden" attribute set "true" in XUL
nsCOMPtr<nsIDOMElement> elem;
rv = xulDoc->GetElementById("debugMenu", getter_AddRefs(elem));
rv = xulDoc->GetElementById(NS_ConvertASCIItoUCS2("debugMenu"), getter_AddRefs(elem));
if (elem)
elem->RemoveAttribute("hidden");
elem->RemoveAttribute(NS_ConvertASCIItoUCS2("hidden"));
#endif
// Force initial focus to the content window -- HOW?
@ -567,7 +567,7 @@ nsEditorShell::SetEditorType(const PRUnichar *editorType)
nsAutoString theType = editorType;
theType.ToLowerCase();
if (theType.Equals("text") || theType.Equals("html") || theType.IsEmpty() || theType.Equals("htmlmail"))
if (theType.EqualsWithConversion("text") || theType.EqualsWithConversion("html") || theType.IsEmpty() || theType.EqualsWithConversion("htmlmail"))
{
mEditorTypeString = theType;
return NS_OK;
@ -599,17 +599,17 @@ nsEditorShell::InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell)
if (NS_SUCCEEDED(err))
{
if (mEditorTypeString.Equals("text"))
if (mEditorTypeString.EqualsWithConversion("text"))
{
err = editor->Init(aDoc, aPresShell, nsIHTMLEditor::eEditorPlaintextMask);
mEditorType = ePlainTextEditorType;
}
else if (mEditorTypeString.Equals("html") || mEditorTypeString.IsEmpty()) // empty string default to HTML editor
else if (mEditorTypeString.EqualsWithConversion("html") || mEditorTypeString.IsEmpty()) // empty string default to HTML editor
{
err = editor->Init(aDoc, aPresShell, 0);
mEditorType = eHTMLTextEditorType;
}
else if (mEditorTypeString.Equals("htmlmail")) // HTML editor with special mail rules
else if (mEditorTypeString.EqualsWithConversion("htmlmail")) // HTML editor with special mail rules
{
err = editor->Init(aDoc, aPresShell, nsIHTMLEditor::eEditorMailMask);
mEditorType = eHTMLTextEditorType;
@ -618,9 +618,9 @@ nsEditorShell::InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell)
{
err = NS_ERROR_INVALID_ARG; // this is not an editor we know about
#if DEBUG
nsAutoString errorMsg = "Failed to init editor. Unknown editor type \"";
nsAutoString errorMsg; errorMsg.AssignWithConversion("Failed to init editor. Unknown editor type \"");
errorMsg += mEditorTypeString;
errorMsg += "\"\n";
errorMsg.AppendWithConversion("\"\n");
char *errorMsgCString = errorMsg.ToNewCString();
NS_WARNING(errorMsgCString);
nsCRT::free(errorMsgCString);
@ -861,7 +861,7 @@ nsEditorShell::RemoveTextProperty(const PRUnichar *prop, const PRUnichar *attr)
nsAutoString aAttr(attr);
allStr.ToLowerCase();
PRBool doingAll = (allStr.Equals("all"));
PRBool doingAll = (allStr.EqualsWithConversion("all"));
nsresult err = NS_OK;
if (doingAll)
@ -989,7 +989,7 @@ nsEditorShell::SetDisplayMode(PRInt32 aDisplayMode)
//Load the editmode style sheet
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorContent.css",
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorContent.css"),
getter_AddRefs(styleSheet));
// Save the returned style sheet so we can remove it later
@ -1008,7 +1008,7 @@ nsEditorShell::SetDisplayMode(PRInt32 aDisplayMode)
// Note: using "@import url(chrome://editor/content/EditorContent.css);"
// in EditorAllTags.css doesn't seem to work!?
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorContent.css",
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorContent.css"),
getter_AddRefs(styleSheet));
// Save the returned style sheet so we can remove it later
@ -1018,7 +1018,7 @@ nsEditorShell::SetDisplayMode(PRInt32 aDisplayMode)
//Load the editmode style sheet
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorAllTags.css",
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorAllTags.css"),
getter_AddRefs(styleSheet));
// Save the returned style sheet so we can remove it later
@ -1045,7 +1045,7 @@ nsEditorShell::DisplayParagraphMarks(PRBool aShowMarks)
//Load the style sheet
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorParagraphMarks.css",
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorParagraphMarks.css"),
getter_AddRefs(styleSheet));
// Save the returned style sheet so we can remove it later
@ -1255,19 +1255,19 @@ nsEditorShell::CheckAndSaveDocument(const PRUnichar *reasonToSave, PRBool *_retv
// Ask user if they want to save current changes
nsAutoString reasonToSaveStr(reasonToSave);
nsAutoString tmp1, tmp2, title;
GetBundleString("Save", tmp1);
GetBundleString("DontSave", tmp2);
GetBundleString(NS_ConvertASCIItoUCS2("Save"), tmp1);
GetBundleString(NS_ConvertASCIItoUCS2("DontSave"), tmp2);
GetDocumentTitleString(title);
// If title is empty, use "untitled"
if (title.Length() == 0)
GetBundleString("untitled", title);
GetBundleString(NS_ConvertASCIItoUCS2("untitled"), title);
nsAutoString saveMsg;
GetBundleString("SaveFilePrompt", saveMsg);
saveMsg.ReplaceSubstring("%title%", title).ReplaceSubstring("%reason%", reasonToSaveStr);
GetBundleString(NS_ConvertASCIItoUCS2("SaveFilePrompt"), saveMsg);
saveMsg.ReplaceSubstring(NS_ConvertASCIItoUCS2("%title%"), title).ReplaceSubstring(NS_ConvertASCIItoUCS2("%reason%"), reasonToSaveStr);
nsAutoString saveDocString;
GetBundleString("SaveDocument", saveDocString);
GetBundleString(NS_ConvertASCIItoUCS2("SaveDocument"), saveDocString);
EConfirmResult result = ConfirmWithCancel(saveDocString, saveMsg, &tmp1, &tmp2);
if (result == eCancel)
{
@ -1334,8 +1334,8 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
PRUnichar *titleUnicode;
nsAutoString captionStr, msgStr;
GetBundleString("DocumentTitle", captionStr);
GetBundleString("NeedDocTitle", msgStr);
GetBundleString(NS_ConvertASCIItoUCS2("DocumentTitle"), captionStr);
GetBundleString(NS_ConvertASCIItoUCS2("NeedDocTitle"), msgStr);
PRBool retVal = PR_FALSE;
res = dialog->Prompt(mContentWindow, captionStr.GetUnicode(), msgStr.GetUnicode(),
@ -1361,7 +1361,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
if (NS_SUCCEEDED(res) && fileWidget)
{
nsAutoString promptString;
GetBundleString("SaveDocumentAs", promptString);
GetBundleString(NS_ConvertASCIItoUCS2("SaveDocumentAs"), promptString);
nsString* titles = nsnull;
nsString* filters = nsnull;
@ -1385,19 +1385,19 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
nextTitle = titles;
nextFilter = filters;
// The names of the file types are localizable
GetBundleString("HTMLFiles", HTMLFiles);
GetBundleString("TextFiles", TextFiles);
GetBundleString(NS_ConvertASCIItoUCS2("HTMLFiles"), HTMLFiles);
GetBundleString(NS_ConvertASCIItoUCS2("TextFiles"), TextFiles);
if (! (HTMLFiles.Length() == 0 || TextFiles.Length() == 0))
{
nsAutoString allFilesStr;
GetBundleString("AllFiles", allFilesStr);
GetBundleString(NS_ConvertASCIItoUCS2("AllFiles"), allFilesStr);
*nextTitle++ = HTMLFiles;
*nextFilter++ = "*.htm; *.html; *.shtml";
(*nextFilter++).AssignWithConversion("*.htm; *.html; *.shtml");
*nextTitle++ = TextFiles;
*nextFilter++ = "*.txt";
(*nextFilter++).AssignWithConversion("*.txt");
*nextTitle++ = allFilesStr;
*nextFilter++ = "*.*";
(*nextFilter++).AssignWithConversion("*.*");
fileWidget->SetFilterList(3, titles, filters);
}
@ -1412,8 +1412,8 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
// do a QI to get an nsIURL and then call GetFileName()
// if it's not a local file already, grab the current file name
if ( (urlstring.Compare("file", PR_TRUE, 4) != 0 )
&& (urlstring.Compare("about:blank", PR_TRUE, -1) != 0) )
if ( (urlstring.CompareWithConversion("file", PR_TRUE, 4) != 0 )
&& (urlstring.CompareWithConversion("about:blank", PR_TRUE, -1) != 0) )
{
PRInt32 index = urlstring.RFindChar((PRUnichar)'/', PR_FALSE, -1, -1 );
if ( index != -1 )
@ -1422,7 +1422,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
// if the url ends with a '/' then the whole string will be cut
urlstring.Cut(0, index + 1);
if (urlstring.Length() > 0)
fileName = urlstring;
fileName.Assign( urlstring );
}
}
@ -1437,14 +1437,14 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
PRUnichar at = (PRUnichar)'@';
PRUnichar colon = (PRUnichar)':';
PRUnichar underscore = (PRUnichar)'_';
title = title.ReplaceChar(space, underscore);
title = title.ReplaceChar(dot, underscore);
title = title.ReplaceChar(bslash, underscore);
title = title.ReplaceChar(fslash, underscore);
title = title.ReplaceChar(at, underscore);
title = title.ReplaceChar(colon, underscore);
title.ReplaceChar(space, underscore);
title.ReplaceChar(dot, underscore);
title.ReplaceChar(bslash, underscore);
title.ReplaceChar(fslash, underscore);
title.ReplaceChar(at, underscore);
title.ReplaceChar(colon, underscore);
fileName = title;
fileName.Append(".html");
fileName.AppendWithConversion(".html");
}
}
else
@ -1452,7 +1452,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
char *leafName = docFileSpec.GetLeafName();
if (leafName)
{
fileName = leafName;
fileName.AssignWithConversion(leafName);
nsCRT::free(leafName);
}
docFileSpec.GetParent(parentPath);
@ -1488,7 +1488,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
if (webShell)
{
nsFileURL fileURL(docFileSpec);
nsAutoString fileURLString(fileURL.GetURLString());
nsAutoString fileURLString; fileURLString.AssignWithConversion(fileURL.GetURLString());
PRUnichar *fileURLUnicode = fileURLString.ToNewUnicode();
if (fileURLUnicode)
{
@ -1505,8 +1505,8 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
if (NS_FAILED(res))
{
nsAutoString saveDocStr, failedStr;
GetBundleString("SaveDocument", saveDocStr);
GetBundleString("SaveFileFailed", failedStr);
GetBundleString(NS_ConvertASCIItoUCS2("SaveDocument"), saveDocStr);
GetBundleString(NS_ConvertASCIItoUCS2("SaveFileFailed"), failedStr);
Alert(saveDocStr, failedStr);
} else {
// File was saved successfully
@ -1530,7 +1530,7 @@ NS_IMETHODIMP
nsEditorShell::CloseWindow( PRBool *_retval )
{
nsAutoString beforeClosingStr;
GetBundleString("BeforeClosing", beforeClosingStr);
GetBundleString(NS_ConvertASCIItoUCS2("BeforeClosing"), beforeClosingStr);
nsresult rv = CheckAndSaveDocument(beforeClosingStr.GetUnicode(), _retval);
@ -1581,7 +1581,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType
nsCOMPtr<nsIFileWidget> fileWidget;
nsAutoString HTMLTitle;
GetBundleString("OpenHTMLFile", HTMLTitle);
GetBundleString(NS_ConvertASCIItoUCS2("OpenHTMLFile"), HTMLTitle);
// An empty string should just result in "Open" for the dialog
nsAutoString title;
@ -1590,7 +1590,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType
title = HTMLTitle;
} else {
nsAutoString ImageTitle;
GetBundleString("SelectImageFile", ImageTitle);
GetBundleString(NS_ConvertASCIItoUCS2("SelectImageFile"), ImageTitle);
if (ImageTitle.Length() > 0 && imgFilter)
title = ImageTitle;
@ -1623,12 +1623,12 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType
nextTitle = titles;
nextFilter = filters;
GetBundleString("HTMLFiles", tempStr);
GetBundleString(NS_ConvertASCIItoUCS2("HTMLFiles"), tempStr);
*nextTitle++ = tempStr;
GetBundleString("TextFiles", tempStr);
GetBundleString(NS_ConvertASCIItoUCS2("TextFiles"), tempStr);
*nextTitle++ = tempStr;
*nextFilter++ = "*.htm; *.html; *.shtml";
*nextFilter++ = "*.txt";
(*nextFilter++).AssignWithConversion("*.htm; *.html; *.shtml");
(*nextFilter++).AssignWithConversion("*.txt");
fileWidget->SetFilterList(3, titles, filters);
} else {
titles = new nsString[2];
@ -1637,14 +1637,14 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType
return NS_ERROR_OUT_OF_MEMORY;
nextTitle = titles;
nextFilter = filters;
GetBundleString("IMGFiles", tempStr);
GetBundleString(NS_ConvertASCIItoUCS2("IMGFiles"), tempStr);
*nextTitle++ = tempStr;
*nextFilter++ = "*.gif; *.jpg; *.jpeg; *.png", "*.*";
(*nextFilter++).AssignWithConversion("*.gif; *.jpg; *.jpeg; *.png; *.*");
fileWidget->SetFilterList(2, titles, filters);
}
GetBundleString("AllFiles", tempStr);
GetBundleString(NS_ConvertASCIItoUCS2("AllFiles"), tempStr);
*nextTitle++ = tempStr;
*nextFilter++ = "*.*";
(*nextFilter++).AssignWithConversion("*.*");
// First param should be Parent window, but type is nsIWidget*
// Bug is filed to change this to a more suitable window type
dialogResult = fileWidget->GetFile(/*parent*/ nsnull, title, fileSpec);
@ -1660,7 +1660,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType
// Convert it to the string version of the URL format
// NOTE: THIS CRASHES IF fileSpec is empty
nsFileURL url(fileSpec);
nsAutoString returnVal = url.GetURLString();
nsAutoString returnVal; returnVal.AssignWithConversion(url.GetURLString());
*_retval = returnVal.ToNewUnicode();
}
// TODO: SAVE THIS TO THE PREFS?
@ -1686,7 +1686,7 @@ nsEditorShell::UpdateWindowTitle()
res = GetDocumentTitleString(windowCaption);
// If title is empty, use "untitled"
if (windowCaption.Length() == 0)
GetBundleString("untitled", windowCaption);
GetBundleString(NS_ConvertASCIItoUCS2("untitled"), windowCaption);
// Append just the 'leaf' filename to the Doc. Title for the window caption
if (NS_SUCCEEDED(res))
@ -1704,9 +1704,9 @@ nsEditorShell::UpdateWindowTitle()
{
nsAutoString name;
docFileSpec.GetLeafName(name);
windowCaption += " [";
windowCaption.AppendWithConversion(" [");
windowCaption += name;
windowCaption += "]";
windowCaption.AppendWithConversion("]");
}
}
}
@ -1755,7 +1755,7 @@ nsEditorShell::GetDocumentTitle(PRUnichar **title)
*title = titleStr.ToNewUnicode();
} else {
// Don't fail, just return an empty string
nsAutoString empty("");
nsAutoString empty;
*title = empty.ToNewUnicode();
res = NS_OK;
}
@ -1796,7 +1796,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title)
nsCOMPtr<nsIDOMNode>titleNode;
nsCOMPtr<nsIDOMNode>headNode;
nsCOMPtr<nsIDOMNode> resultNode;
res = domDoc->GetElementsByTagName("title", getter_AddRefs(titleList));
res = domDoc->GetElementsByTagName(NS_ConvertASCIItoUCS2("title"), getter_AddRefs(titleList));
if (NS_SUCCEEDED(res))
{
if(titleList)
@ -1832,7 +1832,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title)
}
// Get the <HEAD> node, create a <TITLE> and insert it under the HEAD
nsCOMPtr<nsIDOMNodeList> headList;
res = domDoc->GetElementsByTagName("head",getter_AddRefs(headList));
res = domDoc->GetElementsByTagName(NS_ConvertASCIItoUCS2("head"),getter_AddRefs(headList));
if (NS_FAILED(res)) return res;
if (headList)
{
@ -1844,7 +1844,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title)
{
// Didn't find one above: Create a new one
nsCOMPtr<nsIDOMElement>titleElement;
res = domDoc->CreateElement("title",getter_AddRefs(titleElement));
res = domDoc->CreateElement(NS_ConvertASCIItoUCS2("title"),getter_AddRefs(titleElement));
if (NS_SUCCEEDED(res) && titleElement)
{
titleNode = do_QueryInterface(titleElement);
@ -2367,7 +2367,7 @@ nsEditorShell::GetString(const PRUnichar *name, PRUnichar **_retval)
return NS_ERROR_NULL_POINTER;
// Don't fail, just return an empty string
nsAutoString empty("");
nsAutoString empty;
if (mStringBundle)
{
@ -2391,13 +2391,13 @@ void nsEditorShell::GetBundleString(const nsString& name, nsString &outString)
if (NS_SUCCEEDED(mStringBundle->GetStringFromName(name.GetUnicode(), &ptrv)))
outString = ptrv;
else
outString = "";
outString.SetLength(0);
nsAllocator::Free(ptrv);
}
else
{
outString = "";
outString.SetLength(0);
}
}
@ -2417,22 +2417,22 @@ nsEditorShell::ConfirmWithCancel(const nsString& aTitle, const nsString& aQuesti
// Stuff in Parameters
block->SetInt( nsICommonDialogs::eNumberButtons,3 );
block->SetString( nsICommonDialogs::eMsg, aQuestion.GetUnicode());
nsAutoString url( "chrome://global/skin/question-icon.gif" );
nsAutoString url; url.AssignWithConversion( "chrome://global/skin/question-icon.gif" );
block->SetString( nsICommonDialogs::eIconURL, url.GetUnicode());
nsAutoString yesStr, noStr;
if (aYesString)
yesStr = *aYesString;
yesStr.Assign(*aYesString);
else
GetBundleString("Yes", yesStr);
GetBundleString(NS_ConvertASCIItoUCS2("Yes"), yesStr);
if (aNoString)
noStr = *aNoString;
noStr.Assign(*aNoString);
else
GetBundleString("No", noStr);
GetBundleString(NS_ConvertASCIItoUCS2("No"), noStr);
nsAutoString cancelStr;
GetBundleString("Cancel", cancelStr);
GetBundleString(NS_ConvertASCIItoUCS2("Cancel"), cancelStr);
block->SetString( nsICommonDialogs::eDialogTitle, aTitle.GetUnicode() );
//Note: "button0" is always Ok or Yes action, "button1" is Cancel
@ -2729,12 +2729,12 @@ nsEditorShell::MakeOrChangeList(const PRUnichar *listType)
case eHTMLTextEditorType:
if (aListType.IsEmpty())
{
err = mEditor->RemoveList("ol");
err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("ol"));
if(NS_SUCCEEDED(err))
{
err = mEditor->RemoveList("ul");
err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("ul"));
if(NS_SUCCEEDED(err))
err = mEditor->RemoveList("dl");
err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("dl"));
}
}
else
@ -2761,12 +2761,12 @@ nsEditorShell::RemoveList(const PRUnichar *listType)
case eHTMLTextEditorType:
if (aListType.IsEmpty())
{
err = mEditor->RemoveList("ol");
err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("ol"));
if(NS_SUCCEEDED(err))
{
err = mEditor->RemoveList("ul");
err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("ul"));
if(NS_SUCCEEDED(err))
err = mEditor->RemoveList("dl");
err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("dl"));
}
}
else
@ -3746,7 +3746,7 @@ nsEditorShell::GetSuggestedWord(PRUnichar **aSuggestedWord)
mSuggestedWordIndex++;
} else {
// A blank string signals that there are no more strings
word = "";
word.SetLength(0);
}
result = NS_OK;
}
@ -3820,7 +3820,7 @@ nsEditorShell::GetPersonalDictionaryWord(PRUnichar **aDictionaryWord)
mDictionaryIndex++;
} else {
// A blank string signals that there are no more strings
word = "";
word.SetLength(0);
}
result = NS_OK;
}
@ -4001,7 +4001,7 @@ nsEditorShell::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, cons
{
// Start the throbber
// TODO: We should also start/stop it for saving and publishing?
SetChromeAttribute( mDocShell, "Editor:Throbber", "busy", "true" );
SetChromeAttribute( mDocShell, "Editor:Throbber", "busy", NS_ConvertASCIItoUCS2("true") );
// Disable JavaScript in this document:
nsCOMPtr<nsIScriptGlobalObjectOwner> sgoo (do_QueryInterface(mContentAreaDocShell));
@ -4073,8 +4073,8 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* aChanne
if (mCloseWindowWhenLoaded && isRootDoc)
{
nsAutoString alertLabel, alertMessage;
GetBundleString("Alert", alertLabel);
GetBundleString("CantEditFramesetMsg", alertMessage);
GetBundleString(NS_ConvertASCIItoUCS2("Alert"), alertLabel);
GetBundleString(NS_ConvertASCIItoUCS2("CantEditFramesetMsg"), alertMessage);
Alert(alertLabel, alertMessage);
nsCOMPtr<nsIBaseWindow> baseWindow;
@ -4093,11 +4093,11 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* aChanne
nsCOMPtr<nsIURI> aUrl;
aChannel->GetURI(getter_AddRefs(aUrl));
res = PrepareDocumentForEditing(aLoader, aUrl);
SetChromeAttribute( mDocShell, "Editor:Throbber", "busy", "false" );
SetChromeAttribute( mDocShell, "Editor:Throbber", "busy", NS_ConvertASCIItoUCS2("false") );
}
nsAutoString doneText;
GetBundleString("LoadingDone", doneText);
GetBundleString(NS_ConvertASCIItoUCS2("LoadingDone"), doneText);
SetChromeAttribute(mDocShell, "statusText", "value", doneText);
return res;

View File

@ -50,7 +50,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor,
mValue = aValue;
mRemoveAttribute = aRemoveAttribute;
mAttributeWasSet=PR_FALSE;
mUndoValue="";
mUndoValue.SetLength(0);
return NS_OK;
}
@ -62,7 +62,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Do(void)
// need to get the current value of the attribute and save it, and set mAttributeWasSet
nsresult result = mEditor->GetAttributeValue(mElement, mAttribute, mUndoValue, mAttributeWasSet);
// XXX: hack until attribute-was-set code is implemented
if (PR_FALSE==mUndoValue.Equals(""))
if (PR_FALSE==mUndoValue.IsEmpty())
mAttributeWasSet=PR_TRUE;
// XXX: end hack
@ -121,9 +121,9 @@ NS_IMETHODIMP ChangeAttributeTxn::GetUndoString(nsString *aString)
if (nsnull!=aString)
{
if (PR_FALSE==mRemoveAttribute)
*aString="Change Attribute: ";
aString->AssignWithConversion("Change Attribute: ");
else
*aString="Remove Attribute: ";
aString->AssignWithConversion("Remove Attribute: ");
*aString += mAttribute;
}
return NS_OK;
@ -134,9 +134,9 @@ NS_IMETHODIMP ChangeAttributeTxn::GetRedoString(nsString *aString)
if (nsnull!=aString)
{
if (PR_FALSE==mRemoveAttribute)
*aString="Change Attribute: ";
aString->AssignWithConversion("Change Attribute: ");
else
*aString="Add Attribute: ";
aString->AssignWithConversion("Add Attribute: ");
*aString += mAttribute;
}
return NS_OK;

View File

@ -212,7 +212,7 @@ NS_IMETHODIMP CreateElementTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Remove Element: ";
aString->AssignWithConversion("Remove Element: ");
*aString += mTag;
}
return NS_OK;
@ -222,7 +222,7 @@ NS_IMETHODIMP CreateElementTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Create Element: ";
aString->AssignWithConversion("Create Element: ");
*aString += mTag;
}
return NS_OK;

View File

@ -67,12 +67,12 @@ NS_IMETHODIMP DeleteElementTxn::Do(void)
// begin debug output
nsCOMPtr<nsIDOMElement> element;
element = do_QueryInterface(mElement);
nsAutoString elementTag="text node";
nsAutoString elementTag; elementTag.AssignWithConversion("text node");
if (element)
element->GetTagName(elementTag);
nsCOMPtr<nsIDOMElement> parentElement;
parentElement = do_QueryInterface(mParent);
nsAutoString parentElementTag="text node";
nsAutoString parentElementTag; parentElementTag.AssignWithConversion("text node");
if (parentElement)
parentElement->GetTagName(parentElementTag);
char *c, *p;
@ -106,12 +106,12 @@ NS_IMETHODIMP DeleteElementTxn::Undo(void)
// begin debug output
nsCOMPtr<nsIDOMElement> element;
element = do_QueryInterface(mElement);
nsAutoString elementTag="text node";
nsAutoString elementTag; elementTag.AssignWithConversion("text node");
if (element)
element->GetTagName(elementTag);
nsCOMPtr<nsIDOMElement> parentElement;
parentElement = do_QueryInterface(mParent);
nsAutoString parentElementTag="text node";
nsAutoString parentElementTag; parentElementTag.AssignWithConversion("text node");
if (parentElement)
parentElement->GetTagName(parentElementTag);
char *c, *p;
@ -160,7 +160,7 @@ NS_IMETHODIMP DeleteElementTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Insert Element: ";
aString->AssignWithConversion("Insert Element: ");
}
return NS_OK;
}
@ -169,7 +169,7 @@ NS_IMETHODIMP DeleteElementTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Remove Element: ";
aString->AssignWithConversion("Remove Element: ");
}
return NS_OK;
}

View File

@ -203,7 +203,7 @@ NS_IMETHODIMP DeleteRangeTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Insert Range: ";
aString->AssignWithConversion("Insert Range: ");
}
return NS_OK;
}
@ -212,7 +212,7 @@ NS_IMETHODIMP DeleteRangeTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Remove Range: ";
aString->AssignWithConversion("Remove Range: ");
}
return NS_OK;
}

View File

@ -58,7 +58,7 @@ NS_IMETHODIMP DeleteTextTxn::Init(nsIEditor *aEditor,
aElement->GetLength(&count);
NS_ASSERTION(count>=aNumCharsToDelete, "bad arg, numCharsToDelete. Not enough characters in node");
NS_ASSERTION(count>=aOffset+aNumCharsToDelete, "bad arg, numCharsToDelete. Not enough characters in node");
mDeletedText = "";
mDeletedText.SetLength(0);
return NS_OK;
}
@ -121,7 +121,7 @@ NS_IMETHODIMP DeleteTextTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Insert Text: ";
aString->AssignWithConversion("Insert Text: ");
*aString += mDeletedText;
}
return NS_OK;
@ -131,7 +131,7 @@ NS_IMETHODIMP DeleteTextTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Remove Text: ";
aString->AssignWithConversion("Remove Text: ");
*aString += mDeletedText;
}
return NS_OK;

View File

@ -142,14 +142,14 @@ NS_IMETHODIMP EditAggregateTxn::Write(nsIOutputStream *aOutputStream)
NS_IMETHODIMP EditAggregateTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
*aString="";
aString->SetLength(0);
return NS_OK;
}
NS_IMETHODIMP EditAggregateTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
*aString="";
aString->SetLength(0);
return NS_OK;
}

View File

@ -78,14 +78,14 @@ NS_IMETHODIMP EditTxn::Write(nsIOutputStream *aOutputStream)
NS_IMETHODIMP EditTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
*aString="";
aString->SetLength(0);
return NS_OK;
}
NS_IMETHODIMP EditTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
*aString="";
aString->SetLength(0);
return NS_OK;
}

View File

@ -200,7 +200,7 @@ NS_IMETHODIMP IMETextTxn::GetUndoString(nsString *aString)
if (nsnull!=aString)
{
*aString="Remove Text: ";
aString->AssignWithConversion("Remove Text: ");
*aString += mStringToInsert;
}
return NS_OK;
@ -214,7 +214,7 @@ NS_IMETHODIMP IMETextTxn::GetRedoString(nsString *aString)
if (nsnull!=aString)
{
*aString="Insert Text: ";
aString->AssignWithConversion("Insert Text: ");
*aString += mStringToInsert;
}
return NS_OK;

View File

@ -146,7 +146,7 @@ NS_IMETHODIMP InsertElementTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Remove Element: ";
aString->AssignWithConversion("Remove Element: ");
}
return NS_OK;
}
@ -155,7 +155,7 @@ NS_IMETHODIMP InsertElementTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Insert Element: ";
aString->AssignWithConversion("Insert Element: ");
}
return NS_OK;
}

View File

@ -202,7 +202,7 @@ NS_IMETHODIMP InsertTextTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Remove Text: ";
aString->AssignWithConversion("Remove Text: ");
*aString += mStringToInsert;
}
return NS_OK;
@ -212,7 +212,7 @@ NS_IMETHODIMP InsertTextTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Insert Text: ";
aString->AssignWithConversion("Insert Text: ");
*aString += mStringToInsert;
}
return NS_OK;

View File

@ -168,7 +168,7 @@ NS_IMETHODIMP JoinElementTxn::GetUndoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Join Element";
aString->AssignWithConversion("Join Element");
}
return NS_OK;
}
@ -177,7 +177,7 @@ NS_IMETHODIMP JoinElementTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
{
*aString="Split Element";
aString->AssignWithConversion("Split Element");
}
return NS_OK;
}

View File

@ -1277,7 +1277,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
if (NS_SUCCEEDED(result) && selection)
{
nsCOMPtr<nsIDOMNodeList> nodeList;
nsAutoString bodyTag = "body";
nsAutoString bodyTag; bodyTag.AssignWithConversion("body");
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
if (!doc) return NS_ERROR_NOT_INITIALIZED;
result = doc->GetElementsByTagName(bodyTag, getter_AddRefs(nodeList));
@ -1336,7 +1336,7 @@ NS_IMETHODIMP nsEditor::EndOfDocument()
if (NS_SUCCEEDED(result) && selection)
{
nsCOMPtr<nsIDOMNodeList> nodeList;
nsAutoString bodyTag = "body";
nsAutoString bodyTag; bodyTag.AssignWithConversion("body");
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
if (!doc) return NS_ERROR_NOT_INITIALIZED;
result = doc->GetElementsByTagName(bodyTag, getter_AddRefs(nodeList));
@ -1461,7 +1461,7 @@ nsEditor::SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveC
if (!diskDoc)
return NS_ERROR_NO_INTERFACE;
nsAutoString useDocCharset("");
nsAutoString useDocCharset;
res = diskDoc->SaveFile(aFileSpec, aReplaceExisting, aSaveCopy,
aSaveFileType, useDocCharset);
@ -1526,7 +1526,7 @@ nsEditor::MarkNodeDirty(nsIDOMNode* aNode)
// mark the node dirty.
nsCOMPtr<nsIDOMElement> element (do_QueryInterface(aNode));
if (element)
element->SetAttribute("_moz_dirty", "");
element->SetAttribute(NS_ConvertASCIItoUCS2("_moz_dirty"), nsAutoString());
return NS_OK;
}
@ -2125,7 +2125,7 @@ nsEditor::DebugDumpContent() const
{
nsCOMPtr<nsIContent>content;
nsCOMPtr<nsIDOMNodeList>nodeList;
nsAutoString bodyTag = "body";
nsAutoString bodyTag; bodyTag.AssignWithConversion("body");
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
if (!doc) return NS_ERROR_NOT_INITIALIZED;
doc->GetElementsByTagName(bodyTag, getter_AddRefs(nodeList));
@ -2332,7 +2332,7 @@ nsEditor::GetBodyElement(nsIDOMElement **aBodyElement)
return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMNodeList>nodeList;
nsAutoString bodyTag = "body";
nsAutoString bodyTag; bodyTag.AssignWithConversion("body");
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
if (!doc) return NS_ERROR_NOT_INITIALIZED;
@ -2478,14 +2478,13 @@ NS_IMETHODIMP nsEditor::ScrollIntoView(PRBool aScrollToBegin)
/** static helper method */
nsresult nsEditor::GetTextNodeTag(nsString& aOutString)
{
aOutString = "";
aOutString.SetLength(0);
static nsString *gTextNodeTag=nsnull;
if (!gTextNodeTag)
{
gTextNodeTag = new nsString("special text node tag");
if (!gTextNodeTag) {
if ( (gTextNodeTag = new nsString) == 0 )
return NS_ERROR_OUT_OF_MEMORY;
}
gTextNodeTag->AssignWithConversion("special text node tag");
}
aOutString = *gTextNodeTag;
return NS_OK;
@ -2512,7 +2511,7 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert,
{
// create a text node
nsCOMPtr<nsIDOMNode> newNode;
res = aDoc->CreateTextNode("", getter_AddRefs(nodeAsText));
res = aDoc->CreateTextNode(nsAutoString(), getter_AddRefs(nodeAsText));
if (NS_FAILED(res)) return res;
if (!nodeAsText) return NS_ERROR_NULL_POINTER;
newNode = do_QueryInterface(nodeAsText);
@ -3642,7 +3641,7 @@ nsEditor::TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild)
if (IsTextNode(aChild))
{
childStringTag = "__moz_text";
childStringTag.AssignWithConversion("__moz_text");
}
else
{
@ -3750,10 +3749,10 @@ nsEditor::IsMozEditorBogusNode(nsIDOMNode *aNode)
element = do_QueryInterface(aNode);
if (element)
{
nsAutoString att(kMOZEditorBogusNodeAttr);
nsAutoString att; att.AssignWithConversion(kMOZEditorBogusNodeAttr);
nsAutoString val;
(void)element->GetAttribute(att, val);
if (val.Equals(kMOZEditorBogusNodeValue)) {
if (val.EqualsWithConversion(kMOZEditorBogusNodeValue)) {
return PR_TRUE;
}
}

View File

@ -163,9 +163,9 @@ nsPasteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon)
nsresult rv = NS_OK;
nsAutoString cmdString(aCommand);
if (cmdString.Equals("cmd_paste"))
if (cmdString.EqualsWithConversion("cmd_paste"))
rv = aEditor->Paste(nsIClipboard::kGlobalClipboard);
else if (cmdString.Equals("cmd_pasteQuote"))
else if (cmdString.EqualsWithConversion("cmd_pasteQuote"))
{
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(aEditor, &rv);
if (mailEditor)
@ -188,19 +188,19 @@ nsDeleteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCo
nsAutoString cmdString(aCommand);
if (cmdString.Equals("cmd_delete"))
if (cmdString.EqualsWithConversion("cmd_delete"))
rv = aEditor->CanCut(*outCmdEnabled);
else if (cmdString.Equals("cmd_deleteCharBackward"))
else if (cmdString.EqualsWithConversion("cmd_deleteCharBackward"))
*outCmdEnabled = PR_TRUE;
else if (cmdString.Equals("cmd_deleteCharForward"))
else if (cmdString.EqualsWithConversion("cmd_deleteCharForward"))
*outCmdEnabled = PR_TRUE;
else if (cmdString.Equals("cmd_deleteWordBackward"))
else if (cmdString.EqualsWithConversion("cmd_deleteWordBackward"))
*outCmdEnabled = PR_TRUE;
else if (cmdString.Equals("cmd_deleteWordForward"))
else if (cmdString.EqualsWithConversion("cmd_deleteWordForward"))
*outCmdEnabled = PR_TRUE;
else if (cmdString.Equals("cmd_deleteToBeginningOfLine"))
else if (cmdString.EqualsWithConversion("cmd_deleteToBeginningOfLine"))
*outCmdEnabled = PR_TRUE;
else if (cmdString.Equals("cmd_deleteToEndOfLine"))
else if (cmdString.EqualsWithConversion("cmd_deleteToEndOfLine"))
*outCmdEnabled = PR_TRUE;
return rv;
@ -218,19 +218,19 @@ nsDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon)
nsIEditor::EDirection deleteDir = nsIEditor::eNone;
if (cmdString.Equals("cmd_delete"))
if (cmdString.EqualsWithConversion("cmd_delete"))
deleteDir = nsIEditor::ePrevious;
else if (cmdString.Equals("cmd_deleteCharBackward"))
else if (cmdString.EqualsWithConversion("cmd_deleteCharBackward"))
deleteDir = nsIEditor::ePrevious;
else if (cmdString.Equals("cmd_deleteCharForward"))
else if (cmdString.EqualsWithConversion("cmd_deleteCharForward"))
deleteDir = nsIEditor::eNext;
else if (cmdString.Equals("cmd_deleteWordBackward"))
else if (cmdString.EqualsWithConversion("cmd_deleteWordBackward"))
deleteDir = nsIEditor::ePreviousWord;
else if (cmdString.Equals("cmd_deleteWordForward"))
else if (cmdString.EqualsWithConversion("cmd_deleteWordForward"))
deleteDir = nsIEditor::eNextWord;
else if (cmdString.Equals("cmd_deleteToBeginningOfLine"))
else if (cmdString.EqualsWithConversion("cmd_deleteToBeginningOfLine"))
deleteDir = nsIEditor::eToBeginningOfLine;
else if (cmdString.Equals("cmd_deleteToEndOfLine"))
else if (cmdString.EqualsWithConversion("cmd_deleteToEndOfLine"))
deleteDir = nsIEditor::eToEndOfLine;
return aEditor->DeleteSelection(deleteDir);
@ -292,81 +292,81 @@ nsSelectionMoveCommands::DoCommand(const PRUnichar *aCommand, nsISupports * refC
nsAutoString cmdString(aCommand);
// complete scroll commands
if (cmdString.Equals("cmd_scrollTop"))
if (cmdString.EqualsWithConversion("cmd_scrollTop"))
return selCont->CompleteScroll(PR_FALSE);
else if (cmdString.Equals("cmd_scrollBottom"))
else if (cmdString.EqualsWithConversion("cmd_scrollBottom"))
return selCont->CompleteScroll(PR_TRUE);
// complete move commands
else if (cmdString.Equals("cmd_moveTop"))
else if (cmdString.EqualsWithConversion("cmd_moveTop"))
return selCont->CompleteMove(PR_FALSE, PR_FALSE);
else if (cmdString.Equals("cmd_moveBottom"))
else if (cmdString.EqualsWithConversion("cmd_moveBottom"))
return selCont->CompleteMove(PR_TRUE, PR_FALSE);
else if (cmdString.Equals("cmd_selectTop"))
else if (cmdString.EqualsWithConversion("cmd_selectTop"))
return selCont->CompleteMove(PR_FALSE, PR_TRUE);
else if (cmdString.Equals("cmd_selectBottom"))
else if (cmdString.EqualsWithConversion("cmd_selectBottom"))
return selCont->CompleteMove(PR_TRUE, PR_TRUE);
// line move commands
else if (cmdString.Equals("cmd_lineNext"))
else if (cmdString.EqualsWithConversion("cmd_lineNext"))
return selCont->LineMove(PR_TRUE, PR_FALSE);
else if (cmdString.Equals("cmd_linePrevious"))
else if (cmdString.EqualsWithConversion("cmd_linePrevious"))
return selCont->LineMove(PR_FALSE, PR_FALSE);
else if (cmdString.Equals("cmd_selectLineNext"))
else if (cmdString.EqualsWithConversion("cmd_selectLineNext"))
return selCont->LineMove(PR_TRUE, PR_TRUE);
else if (cmdString.Equals("cmd_selectLinePrevious"))
else if (cmdString.EqualsWithConversion("cmd_selectLinePrevious"))
return selCont->LineMove(PR_FALSE, PR_TRUE);
// character move commands
else if (cmdString.Equals("cmd_charPrevious"))
else if (cmdString.EqualsWithConversion("cmd_charPrevious"))
return selCont->CharacterMove(PR_FALSE, PR_FALSE);
else if (cmdString.Equals("cmd_charNext"))
else if (cmdString.EqualsWithConversion("cmd_charNext"))
return selCont->CharacterMove(PR_TRUE, PR_FALSE);
else if (cmdString.Equals("cmd_selectCharPrevious"))
else if (cmdString.EqualsWithConversion("cmd_selectCharPrevious"))
return selCont->CharacterMove(PR_FALSE, PR_TRUE);
else if (cmdString.Equals("cmd_selectCharNext"))
else if (cmdString.EqualsWithConversion("cmd_selectCharNext"))
return selCont->CharacterMove(PR_TRUE, PR_TRUE);
// intra line move commands
else if (cmdString.Equals("cmd_beginLine"))
else if (cmdString.EqualsWithConversion("cmd_beginLine"))
return selCont->IntraLineMove(PR_FALSE, PR_FALSE);
else if (cmdString.Equals("cmd_endLine"))
else if (cmdString.EqualsWithConversion("cmd_endLine"))
return selCont->IntraLineMove(PR_TRUE, PR_FALSE);
else if (cmdString.Equals("cmd_selectBeginLine"))
else if (cmdString.EqualsWithConversion("cmd_selectBeginLine"))
return selCont->IntraLineMove(PR_FALSE, PR_TRUE);
else if (cmdString.Equals("cmd_selectEndLine"))
else if (cmdString.EqualsWithConversion("cmd_selectEndLine"))
return selCont->IntraLineMove(PR_TRUE, PR_TRUE);
// word move commands
else if (cmdString.Equals("cmd_wordPrevious"))
else if (cmdString.EqualsWithConversion("cmd_wordPrevious"))
return selCont->WordMove(PR_FALSE, PR_FALSE);
else if (cmdString.Equals("cmd_wordNext"))
else if (cmdString.EqualsWithConversion("cmd_wordNext"))
return selCont->WordMove(PR_TRUE, PR_FALSE);
else if (cmdString.Equals("cmd_selectWordPrevious"))
else if (cmdString.EqualsWithConversion("cmd_selectWordPrevious"))
return selCont->WordMove(PR_FALSE, PR_TRUE);
else if (cmdString.Equals("cmd_selectWordNext"))
else if (cmdString.EqualsWithConversion("cmd_selectWordNext"))
return selCont->WordMove(PR_TRUE, PR_TRUE);
// scroll page commands
else if (cmdString.Equals("cmd_scrollPageUp"))
else if (cmdString.EqualsWithConversion("cmd_scrollPageUp"))
return selCont->ScrollPage(PR_FALSE);
else if (cmdString.Equals("cmd_scrollPageDown"))
else if (cmdString.EqualsWithConversion("cmd_scrollPageDown"))
return selCont->ScrollPage(PR_TRUE);
// scroll line commands
else if (cmdString.Equals("cmd_scrollLineUp"))
else if (cmdString.EqualsWithConversion("cmd_scrollLineUp"))
return selCont->ScrollLine(PR_FALSE);
else if (cmdString.Equals("cmd_scrollLineDown"))
else if (cmdString.EqualsWithConversion("cmd_scrollLineDown"))
return selCont->ScrollLine(PR_TRUE);
// page move commands
else if (cmdString.Equals("cmd_scrollPageUp"))
else if (cmdString.EqualsWithConversion("cmd_scrollPageUp"))
return selCont->PageMove(PR_FALSE, PR_FALSE);
else if (cmdString.Equals("cmd_scrollPageDown"))
else if (cmdString.EqualsWithConversion("cmd_scrollPageDown"))
return selCont->PageMove(PR_TRUE, PR_FALSE);
else if (cmdString.Equals("cmd_selectPageUp"))
else if (cmdString.EqualsWithConversion("cmd_selectPageUp"))
return selCont->PageMove(PR_FALSE, PR_TRUE);
else if (cmdString.Equals("cmd_selectPageDown"))
else if (cmdString.EqualsWithConversion("cmd_selectPageDown"))
return selCont->PageMove(PR_TRUE, PR_TRUE);
return NS_ERROR_FAILURE;

View File

@ -78,23 +78,19 @@ NS_IMETHODIMP nsEditorController::Init()
#define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \
{ \
_cmdClass* theCmd = new _cmdClass; \
nsAutoString cmdString(_cmdName); \
rv = RegisterOneCommand(cmdString.GetUnicode(), inCommandManager, theCmd); \
rv = RegisterOneCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), inCommandManager, theCmd); \
}
#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \
{ \
_cmdClass* theCmd = new _cmdClass; \
nsAutoString cmdString(_cmdName); \
rv = RegisterOneCommand(cmdString.GetUnicode(), inCommandManager, theCmd); \
rv = RegisterOneCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), inCommandManager, theCmd); \
#define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName) \
cmdString = _cmdName; \
rv = RegisterOneCommand(cmdString.GetUnicode(), inCommandManager, theCmd);
rv = RegisterOneCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), inCommandManager, theCmd);
#define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName) \
cmdString = _cmdName; \
rv = RegisterOneCommand(cmdString.GetUnicode(), inCommandManager, theCmd); \
rv = RegisterOneCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), inCommandManager, theCmd); \
}
@ -217,7 +213,7 @@ NS_IMETHODIMP nsEditorController::IsCommandEnabled(const PRUnichar *aCommand, PR
{
#if DEBUG
nsCAutoString msg("EditorController asked about a command that it does not handle -- ");
msg.Append(aCommand);
msg.AppendWithConversion(aCommand);
NS_WARNING(msg);
#endif
return NS_OK; // we don't handle this command
@ -263,7 +259,7 @@ NS_IMETHODIMP nsEditorController::DoCommand(const PRUnichar *aCommand)
{
#if DEBUG
nsCAutoString msg("EditorController asked to do a command that it does not handle -- ");
msg.Append(aCommand);
msg.AppendWithConversion(aCommand);
NS_WARNING(msg);
#endif
return NS_OK; // we don't handle this command

View File

@ -213,7 +213,8 @@ nsEditProperty::nsEditProperty()
// special
nsIEditProperty::allProperties = new nsString("moz_allproperties");
if ( nsIEditProperty::allProperties = new nsString )
nsIEditProperty::allProperties->AssignWithConversion("moz_allproperties");
}
nsEditProperty::~nsEditProperty()

View File

@ -359,12 +359,12 @@ nsEditorTxnLog::GetString(nsITransaction *aTransaction, char *aBuffer, PRInt32 a
aBuffer[0] = '\0';
nsString str = "";
nsString str;
aTransaction->GetRedoString(&str);
if (str.Length() == 0)
str = "<NULL>";
str.AssignWithConversion("<NULL>");
str.ToCString(aBuffer, aBufferLength);
aBuffer[aBufferLength - 1] = '\0';

View File

@ -177,9 +177,9 @@ static PRBool IsListNode(nsIDOMNode *aNode)
tagName.ToLowerCase();
// With only 3 tests, it doesn't
// seem worth using nsAtoms
if (tagName.Equals("ol") ||
tagName.Equals("ul") ||
tagName.Equals("dl"))
if (tagName.EqualsWithConversion("ol") ||
tagName.EqualsWithConversion("ul") ||
tagName.EqualsWithConversion("dl"))
{
return PR_TRUE;
}
@ -448,7 +448,7 @@ nsHTMLEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
PRBool newMetaCharset = PR_TRUE;
// get a list of META tags
result = domdoc->GetElementsByTagName("meta", getter_AddRefs(metaList));
result = domdoc->GetElementsByTagName(NS_ConvertASCIItoUCS2("meta"), getter_AddRefs(metaList));
if (NS_SUCCEEDED(result) && metaList) {
PRUint32 listLength = 0;
(void) metaList->GetLength(&listLength);
@ -459,20 +459,20 @@ nsHTMLEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
metaElement = do_QueryInterface(metaNode);
if (!metaElement) continue;
const nsString content("charset=");
const NS_ConvertASCIItoUCS2 content("charset=");
nsString currentValue;
if (NS_FAILED(metaElement->GetAttribute("http-equiv", currentValue))) continue;
if (NS_FAILED(metaElement->GetAttribute(NS_ConvertASCIItoUCS2("http-equiv"), currentValue))) continue;
if (kNotFound != currentValue.Find("content-type", PR_TRUE)) {
if (NS_FAILED(metaElement->GetAttribute("content", currentValue))) continue;
if (NS_FAILED(metaElement->GetAttribute(NS_ConvertASCIItoUCS2("content"), currentValue))) continue;
PRInt32 offset = currentValue.Find(content.GetUnicode(), PR_TRUE);
if (kNotFound != offset) {
currentValue.Left(newMetaString, offset); // copy current value before "charset=" (e.g. text/html)
newMetaString.Append(content);
newMetaString.Append(characterSet);
result = nsEditor::SetAttribute(metaElement, "content", newMetaString);
result = nsEditor::SetAttribute(metaElement, NS_ConvertASCIItoUCS2("content"), newMetaString);
if (NS_SUCCEEDED(result))
newMetaCharset = PR_FALSE;
break;
@ -486,12 +486,12 @@ nsHTMLEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
nsCOMPtr<nsIDOMNode>headNode;
nsCOMPtr<nsIDOMNode>resultNode;
result = domdoc->GetElementsByTagName("head",getter_AddRefs(headList));
result = domdoc->GetElementsByTagName(NS_ConvertASCIItoUCS2("head"),getter_AddRefs(headList));
if (NS_SUCCEEDED(result) && headList) {
headList->Item(0, getter_AddRefs(headNode));
if (headNode) {
// Create a new meta charset tag
result = CreateNode("meta", headNode, 0, getter_AddRefs(resultNode));
result = CreateNode(NS_ConvertASCIItoUCS2("meta"), headNode, 0, getter_AddRefs(resultNode));
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
@ -500,12 +500,12 @@ nsHTMLEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
metaElement = do_QueryInterface(resultNode);
if (metaElement) {
// not undoable, undo should undo CreateNode
result = metaElement->SetAttribute("http-equiv", "Content-Type");
result = metaElement->SetAttribute(NS_ConvertASCIItoUCS2("http-equiv"), NS_ConvertASCIItoUCS2("Content-Type"));
if (NS_SUCCEEDED(result)) {
newMetaString.Assign("text/html;charset=");
newMetaString.AssignWithConversion("text/html;charset=");
newMetaString.Append(characterSet);
// not undoable, undo should undo CreateNode
result = metaElement->SetAttribute("content", newMetaString);
result = metaElement->SetAttribute(NS_ConvertASCIItoUCS2("content"), newMetaString);
}
}
}
@ -771,7 +771,7 @@ NS_IMETHODIMP nsHTMLEditor::TabInTable(PRBool inIsShift, PRBool *outHandled)
// Find enclosing table cell from the selection (cell may be the selected element)
nsCOMPtr<nsIDOMElement> cellElement;
nsresult res = GetElementOrParentByTagName("td", nsnull, getter_AddRefs(cellElement));
nsresult res = GetElementOrParentByTagName(NS_ConvertASCIItoUCS2("td"), nsnull, getter_AddRefs(cellElement));
if (NS_FAILED(res)) return res;
// Do nothing -- we didn't find a table cell
if (!cellElement) return NS_OK;
@ -826,7 +826,7 @@ NS_IMETHODIMP nsHTMLEditor::CreateBRImpl(nsCOMPtr<nsIDOMNode> *aInOutParent, PRI
nsCOMPtr<nsIDOMNode> node = *aInOutParent;
PRInt32 theOffset = *aInOutOffset;
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(node);
nsAutoString brType("br");
nsAutoString brType; brType.AssignWithConversion("br");
nsCOMPtr<nsIDOMNode> brNode;
if (nodeAsText)
{
@ -1414,7 +1414,7 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
if (attrString.EqualsIgnoreCase(*aAttribute)) continue;
// if it's a special _moz... attribute, keep looking
attrString.Left(tmp,4);
if (tmp.Equals("_moz")) continue;
if (tmp.EqualsWithConversion("_moz")) continue;
// otherwise, it's another attribute, so return false
return PR_FALSE;
}
@ -1446,7 +1446,7 @@ nsHTMLEditor::HasMatchingAttributes(nsIDOMNode *aNode1,
attrName->ToString(attrString);
// if it's a special _moz... attribute, keep going
attrString.Left(tmp,4);
if (tmp.Equals("_moz")) continue;
if (tmp.EqualsWithConversion("_moz")) continue;
// otherwise, it's another attribute, so count it
realCount1++;
// and compare it to element2's attributes
@ -1464,7 +1464,7 @@ nsHTMLEditor::HasMatchingAttributes(nsIDOMNode *aNode1,
attrName->ToString(attrString);
// if it's a special _moz... attribute, keep going
attrString.Left(tmp,4);
if (tmp.Equals("_moz")) continue;
if (tmp.EqualsWithConversion("_moz")) continue;
// otherwise, it's another attribute, so count it
realCount2++;
}
@ -2353,7 +2353,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertBreak()
{
// create the new BR node
nsCOMPtr<nsIDOMNode> newNode;
nsAutoString tag("BR");
nsAutoString tag; tag.AssignWithConversion("BR");
res = DeleteSelectionAndCreateNode(tag, getter_AddRefs(newNode));
if (!newNode) res = NS_ERROR_NULL_POINTER; // don't return here, so DidDoAction is called
if (NS_SUCCEEDED(res))
@ -2681,7 +2681,7 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
if (aGetLists)
{
// Get the "ol", "ul", or "dl" parent element
res = GetElementOrParentByTagName("list", node, getter_AddRefs(blockParentElem));
res = GetElementOrParentByTagName(NS_ConvertASCIItoUCS2("list"), node, getter_AddRefs(blockParentElem));
if (NS_FAILED(res)) return res;
}
else
@ -2735,7 +2735,7 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
if (aGetLists)
{
// Get the "ol", "ul", or "dl" parent element
res = GetElementOrParentByTagName("list", startParent, getter_AddRefs(blockParent));
res = GetElementOrParentByTagName(NS_ConvertASCIItoUCS2("list"), startParent, getter_AddRefs(blockParent));
}
else
{
@ -2800,7 +2800,7 @@ nsHTMLEditor::MakeOrChangeList(const nsString& aListType)
if (!selection) return NS_ERROR_NULL_POINTER;
nsTextRulesInfo ruleInfo(nsHTMLEditRules::kMakeList);
if (aListType.Equals("ol")) ruleInfo.bOrdered = PR_TRUE;
if (aListType.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE;
else ruleInfo.bOrdered = PR_FALSE;
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (cancel || (NS_FAILED(res))) return res;
@ -2846,7 +2846,7 @@ nsHTMLEditor::MakeOrChangeList(const nsString& aListType)
res = CreateNode(aListType, parent, offset, getter_AddRefs(newList));
if (NS_FAILED(res)) return res;
// make a list item
nsAutoString tag("li");
nsAutoString tag; tag.AssignWithConversion("li");
nsCOMPtr<nsIDOMNode> newItem;
res = CreateNode(tag, newList, 0, getter_AddRefs(newItem));
if (NS_FAILED(res)) return res;
@ -2878,7 +2878,7 @@ nsHTMLEditor::RemoveList(const nsString& aListType)
if (!selection) return NS_ERROR_NULL_POINTER;
nsTextRulesInfo ruleInfo(nsHTMLEditRules::kRemoveList);
if (aListType.Equals("ol")) ruleInfo.bOrdered = PR_TRUE;
if (aListType.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE;
else ruleInfo.bOrdered = PR_FALSE;
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (cancel || (NS_FAILED(res))) return res;
@ -2971,7 +2971,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
PRBool cancel, handled;
PRInt32 theAction = nsHTMLEditRules::kIndent;
PRInt32 opID = kOpIndent;
if (aIndent.Equals("outdent"))
if (aIndent.EqualsWithConversion("outdent"))
{
theAction = nsHTMLEditRules::kOutdent;
opID = kOpOutdent;
@ -3002,7 +3002,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
if (!node) res = NS_ERROR_FAILURE;
if (NS_FAILED(res)) return res;
nsAutoString inward("indent");
nsAutoString inward; inward.AssignWithConversion("indent");
if (aIndent == inward)
{
if (isCollapsed)
@ -3011,7 +3011,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
nsCOMPtr<nsIDOMNode> parent = node;
nsCOMPtr<nsIDOMNode> topChild = node;
nsCOMPtr<nsIDOMNode> tmp;
nsAutoString bq("blockquote");
nsAutoString bq; bq.AssignWithConversion("blockquote");
while ( !CanContainTag(parent, bq))
{
parent->GetParentNode(getter_AddRefs(tmp));
@ -3034,7 +3034,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
// put a space in it so layout will draw the list item
res = selection->Collapse(newBQ,0);
if (NS_FAILED(res)) return res;
nsAutoString theText(" ");
nsAutoString theText; theText.AssignWithConversion(" ");
res = InsertText(theText);
if (NS_FAILED(res)) return res;
// reposition selection to before the space character
@ -3120,7 +3120,7 @@ nsHTMLEditor::GetElementOrParentByTagName(const nsString &aTagName, nsIDOMNode *
PRBool getNamedAnchor = IsNamedAnchor(TagName);
if ( getLink || getNamedAnchor)
{
TagName = "a";
TagName.AssignWithConversion("a");
}
PRBool findTableCell = aTagName.EqualsIgnoreCase("td");
PRBool findList = aTagName.EqualsIgnoreCase("list");
@ -3261,7 +3261,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
}
#endif
nsCOMPtr<nsIDOMElement> parentLinkOfAnchor;
res = GetElementOrParentByTagName("href", anchorNode, getter_AddRefs(parentLinkOfAnchor));
res = GetElementOrParentByTagName(NS_ConvertASCIItoUCS2("href"), anchorNode, getter_AddRefs(parentLinkOfAnchor));
// XXX: ERROR_HANDLING can parentLinkOfAnchor be null?
if (NS_SUCCEEDED(res) && parentLinkOfAnchor)
{
@ -3272,7 +3272,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
} else if(focusNode)
{ // Link node must be the same for both ends of selection
nsCOMPtr<nsIDOMElement> parentLinkOfFocus;
res = GetElementOrParentByTagName("href", focusNode, getter_AddRefs(parentLinkOfFocus));
res = GetElementOrParentByTagName(NS_ConvertASCIItoUCS2("href"), focusNode, getter_AddRefs(parentLinkOfFocus));
if (NS_SUCCEEDED(res) && parentLinkOfFocus == parentLinkOfAnchor)
bNodeFound = PR_TRUE;
}
@ -3415,7 +3415,7 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
if (IsLink(TagName) || IsNamedAnchor(TagName))
{
realTagName = "a";
realTagName.AssignWithConversion("a");
} else {
realTagName = TagName;
}
@ -3430,26 +3430,26 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
return NS_ERROR_FAILURE;
// Mark the new element dirty, so it will be formatted
newElement->SetAttribute("_moz_dirty", "");
newElement->SetAttribute(NS_ConvertASCIItoUCS2("_moz_dirty"), nsAutoString());
// Set default values for new elements
if (TagName.Equals("hr"))
if (TagName.EqualsWithConversion("hr"))
{
// Note that we read the user's attributes for these from prefs (in InsertHLine JS)
newElement->SetAttribute("align","center");
newElement->SetAttribute("width","100%");
newElement->SetAttribute("size","2");
} else if (TagName.Equals("table"))
newElement->SetAttribute(NS_ConvertASCIItoUCS2("align"),NS_ConvertASCIItoUCS2("center"));
newElement->SetAttribute(NS_ConvertASCIItoUCS2("width"),NS_ConvertASCIItoUCS2("100%"));
newElement->SetAttribute(NS_ConvertASCIItoUCS2("size"),NS_ConvertASCIItoUCS2("2"));
} else if (TagName.EqualsWithConversion("table"))
{
newElement->SetAttribute("cellpadding","2");
newElement->SetAttribute("cellspacing","2");
newElement->SetAttribute("border","1");
} else if (TagName.Equals("tr"))
newElement->SetAttribute(NS_ConvertASCIItoUCS2("cellpadding"),NS_ConvertASCIItoUCS2("2"));
newElement->SetAttribute(NS_ConvertASCIItoUCS2("cellspacing"),NS_ConvertASCIItoUCS2("2"));
newElement->SetAttribute(NS_ConvertASCIItoUCS2("border"),NS_ConvertASCIItoUCS2("1"));
} else if (TagName.EqualsWithConversion("tr"))
{
newElement->SetAttribute("valign","top");
} else if (TagName.Equals("td"))
newElement->SetAttribute(NS_ConvertASCIItoUCS2("valign"),NS_ConvertASCIItoUCS2("top"));
} else if (TagName.EqualsWithConversion("td"))
{
newElement->SetAttribute("valign","top");
newElement->SetAttribute(NS_ConvertASCIItoUCS2("valign"),NS_ConvertASCIItoUCS2("top"));
// I'm def'ing this out to see if auto br insertion is working here
#if 0
@ -3523,7 +3523,7 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
if (href.GetUnicode() && href.Length() > 0)
{
nsAutoEditBatch beginBatching(this);
const nsString attribute("href");
nsString attribute; attribute.AssignWithConversion("href");
SetInlineProperty(nsIEditProperty::a, &attribute, &href);
//TODO: Enumerate through other properties of the anchor tag
// and set those as well.
@ -3556,7 +3556,7 @@ nsHTMLEditor::SetBackgroundColor(const nsString& aColor)
{
while(cell)
{
SetAttribute(cell, "bgcolor", aColor);
SetAttribute(cell, NS_ConvertASCIItoUCS2("bgcolor"), aColor);
GetNextSelectedCell(getter_AddRefs(cell), nsnull);
};
return NS_OK;
@ -3570,7 +3570,7 @@ nsHTMLEditor::SetBackgroundColor(const nsString& aColor)
if (!element) return NS_ERROR_NULL_POINTER;
}
// Use the editor method that goes through the transaction system
return SetAttribute(element, "bgcolor", aColor);
return SetAttribute(element, NS_ConvertASCIItoUCS2("bgcolor"), aColor);
}
NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsString& aAttribute, const nsString& aValue)
@ -3990,7 +3990,7 @@ NS_IMETHODIMP nsHTMLEditor::SetBodyWrapWidth(PRInt32 aWrapColumn)
if (!bodyElement) return NS_ERROR_NULL_POINTER;
// Get the current style for this body element:
nsAutoString styleName ("style");
nsAutoString styleName; styleName.AssignWithConversion("style");
nsAutoString styleValue;
res = bodyElement->GetAttribute(styleName, styleValue);
if (NS_FAILED(res)) return res;
@ -4005,26 +4005,26 @@ NS_IMETHODIMP nsHTMLEditor::SetBodyWrapWidth(PRInt32 aWrapColumn)
if (styleValue.Length() > 0)
{
styleValue.Trim("; \t", PR_FALSE, PR_TRUE);
styleValue.Append("; ");
styleValue.AppendWithConversion("; ");
}
// Make sure we have fixed-width font. This should be done for us,
// but it isn't, see bug 22502, so we have to add "font: monospace;".
// Only do this if we're wrapping.
if (aWrapColumn >= 0)
styleValue.Append("font-family: monospace; ");
styleValue.AppendWithConversion("font-family: monospace; ");
// and now we're ready to set the new whitespace/wrapping style.
if (aWrapColumn > 0) // Wrap to a fixed column
{
styleValue.Append("white-space: -moz-pre-wrap; width: ");
styleValue.Append(aWrapColumn);
styleValue.Append("ch;");
styleValue.AppendWithConversion("white-space: -moz-pre-wrap; width: ");
styleValue.AppendInt(aWrapColumn);
styleValue.AppendWithConversion("ch;");
}
else if (aWrapColumn == 0)
styleValue.Append("white-space: -moz-pre-wrap;");
styleValue.AppendWithConversion("white-space: -moz-pre-wrap;");
else
styleValue.Append("white-space: pre;");
styleValue.AppendWithConversion("white-space: pre;");
res = bodyElement->SetAttribute(styleName, styleValue);
@ -4090,9 +4090,9 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
tagName.ToLowerCase();
// See if it's an image or an embed
if (tagName.Equals("img") || tagName.Equals("embed"))
if (tagName.EqualsWithConversion("img") || tagName.EqualsWithConversion("embed"))
(*aNodeList)->AppendElement(node);
else if (tagName.Equals("a"))
else if (tagName.EqualsWithConversion("a"))
{
// XXX Only include links if they're links to file: URLs
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor (do_QueryInterface(content));
@ -4100,7 +4100,7 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
{
nsAutoString href;
if (NS_SUCCEEDED(anchor->GetHref(href)))
if (href.Compare("file:", PR_TRUE, 5) == 0)
if (href.CompareWithConversion("file:", PR_TRUE, 5) == 0)
(*aNodeList)->AppendElement(node);
}
}
@ -4265,11 +4265,11 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
PRUint32 len = 0;
if ( NS_SUCCEEDED(trans->GetAnyTransferData(&bestFlavor, getter_AddRefs(genericDataObj), &len)) )
{
nsAutoString flavor ( bestFlavor ); // just so we can use flavor.Equals()
nsAutoString flavor; flavor.AssignWithConversion( bestFlavor ); // just so we can use flavor.Equals()
#ifdef DEBUG_akkana
printf("Got flavor [%s]\n", bestFlavor);
#endif
if (flavor.Equals(kHTMLMime))
if (flavor.EqualsWithConversion(kHTMLMime))
{
nsCOMPtr<nsISupportsWString> textDataObj ( do_QueryInterface(genericDataObj) );
if (textDataObj && len > 0)
@ -4281,7 +4281,7 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
rv = InsertHTML(stuffToPaste);
}
}
else if (flavor.Equals(kUnicodeMime))
else if (flavor.EqualsWithConversion(kUnicodeMime))
{
nsCOMPtr<nsISupportsWString> textDataObj ( do_QueryInterface(genericDataObj) );
if (textDataObj && len > 0)
@ -4293,7 +4293,7 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
rv = InsertText(stuffToPaste);
}
}
else if (flavor.Equals(kJPEGImageMime))
else if (flavor.EqualsWithConversion(kJPEGImageMime))
{
// Insert Image code here
printf("Don't know how to insert an image yet!\n");
@ -4385,7 +4385,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsQuotation(PRInt32 aSelectionType)
if (mFlags & eEditorPlaintextMask)
return PasteAsPlaintextQuotation(aSelectionType);
nsAutoString citation("");
nsAutoString citation;
return PasteAsCitedQuotation(citation, aSelectionType);
}
@ -4410,7 +4410,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation,
if (!handled)
{
nsCOMPtr<nsIDOMNode> newNode;
nsAutoString tag("blockquote");
nsAutoString tag; tag.AssignWithConversion("blockquote");
res = DeleteSelectionAndCreateNode(tag, getter_AddRefs(newNode));
if (NS_FAILED(res)) return res;
if (!newNode) return NS_ERROR_NULL_POINTER;
@ -4419,8 +4419,8 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation,
nsCOMPtr<nsIDOMElement> newElement (do_QueryInterface(newNode));
if (newElement)
{
nsAutoString type ("type");
nsAutoString cite ("cite");
nsAutoString type; type.AssignWithConversion("type");
nsAutoString cite; cite.AssignWithConversion("cite");
newElement->SetAttribute(type, cite);
}
@ -4480,9 +4480,9 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation(PRInt32 aSelectionType)
#ifdef DEBUG_akkana
printf("Got flavor [%s]\n", flav);
#endif
nsAutoString flavor(flav);
nsAutoString flavor; flavor.AssignWithConversion(flav);
nsAutoString stuffToPaste;
if (flavor.Equals(kUnicodeMime))
if (flavor.EqualsWithConversion(kUnicodeMime))
{
nsCOMPtr<nsISupportsWString> textDataObj ( do_QueryInterface(genericDataObj) );
if (textDataObj && len > 0)
@ -4506,8 +4506,8 @@ NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText,
if (mFlags & eEditorPlaintextMask)
return InsertAsPlaintextQuotation(aQuotedText, aNodeInserted);
nsAutoString citation ("");
nsAutoString charset ("");
nsAutoString citation;
nsAutoString charset;
return InsertAsCitedQuotation(aQuotedText, citation, PR_FALSE,
charset, aNodeInserted);
}
@ -4562,7 +4562,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
if (!handled)
{
// Wrap the inserted quote in a <pre> so it won't be wrapped:
nsAutoString tag("pre");
nsAutoString tag; tag.AssignWithConversion("pre");
rv = DeleteSelectionAndCreateNode(tag, getter_AddRefs(preNode));
// If this succeeded, then set selection inside the pre
@ -4575,7 +4575,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
// Do this after the insertion, so that
nsCOMPtr<nsIDOMElement> preElement (do_QueryInterface(preNode));
if (preElement)
preElement->SetAttribute("_moz_quote", "true");
preElement->SetAttribute(NS_ConvertASCIItoUCS2("_moz_quote"), NS_ConvertASCIItoUCS2("true"));
// and set the selection inside it:
selection->Collapse(preNode, 0);
@ -4626,7 +4626,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
if (cancel) return NS_OK; // rules canceled the operation
if (!handled)
{
nsAutoString tag("blockquote");
nsAutoString tag; tag.AssignWithConversion("blockquote");
res = DeleteSelectionAndCreateNode(tag, getter_AddRefs(newNode));
if (NS_FAILED(res)) return res;
if (!newNode) return NS_ERROR_NULL_POINTER;
@ -4635,8 +4635,8 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
nsCOMPtr<nsIDOMElement> newElement (do_QueryInterface(newNode));
if (newElement)
{
nsAutoString type ("type");
nsAutoString cite ("cite");
nsAutoString type; type.AssignWithConversion("type");
nsAutoString cite; cite.AssignWithConversion("cite");
newElement->SetAttribute(type, cite);
if (aCitation.Length() > 0)
@ -4694,14 +4694,14 @@ NS_IMETHODIMP nsHTMLEditor::OutputToString(nsString& aOutputString,
// special-case for empty document when requesting plain text,
// to account for the bogus text node
if (aFormatType.Equals("text/plain"))
if (aFormatType.EqualsWithConversion("text/plain"))
{
PRBool docEmpty;
rv = GetDocumentIsEmpty(&docEmpty);
if (NS_FAILED(rv)) return rv;
if (docEmpty) {
aOutputString = "";
aOutputString.SetLength(0);
return NS_OK;
}
else if (mFlags & eEditorPlaintextMask)
@ -4780,7 +4780,7 @@ NS_IMETHODIMP nsHTMLEditor::OutputToStream(nsIOutputStream* aOutputStream,
// special-case for empty document when requesting plain text,
// to account for the bogus text node
if (aFormatType.Equals("text/plain"))
if (aFormatType.EqualsWithConversion("text/plain"))
{
PRBool docEmpty;
rv = GetDocumentIsEmpty(&docEmpty);
@ -4817,7 +4817,7 @@ NS_IMETHODIMP nsHTMLEditor::OutputToStream(nsIOutputStream* aOutputStream,
return rv;
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
if (aCharset && aCharset->Length() != 0 && aCharset->Equals("null")==PR_FALSE)
if (aCharset && aCharset->Length() != 0 && aCharset->EqualsWithConversion("null")==PR_FALSE)
encoder->SetCharset(*aCharset);
rv = encoder->Init(doc, aFormatType, aFlags);
@ -5004,7 +5004,7 @@ nsHTMLEditor::CanContainTag(nsIDOMNode* aParent, const nsString &aTag)
{
// CNavDTD gives some unwanted results. We override them here.
// if parent is a list and tag is text, say "no".
if (IsListNode(aParent) && (aTag.Equals("__moz_text")))
if (IsListNode(aParent) && (aTag.EqualsWithConversion("__moz_text")))
return PR_FALSE;
// else fall thru
return nsEditor::CanContainTag(aParent, aTag);
@ -5345,7 +5345,7 @@ nsHTMLEditor::IsTable(nsIDOMNode *node)
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTable");
nsAutoString tag;
nsEditor::GetTagString(node,tag);
if (tag.Equals("table"))
if (tag.EqualsWithConversion("table"))
{
return PR_TRUE;
}
@ -5362,7 +5362,7 @@ nsHTMLEditor::IsTableCell(nsIDOMNode *node)
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTableCell");
nsAutoString tag;
nsEditor::GetTagString(node,tag);
if (tag.Equals("td") || tag.Equals("th"))
if (tag.EqualsWithConversion("td") || tag.EqualsWithConversion("th"))
{
return PR_TRUE;
}
@ -5379,10 +5379,10 @@ nsHTMLEditor::IsTableElement(nsIDOMNode *node)
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTableElement");
nsAutoString tagName;
nsEditor::GetTagString(node,tagName);
if (tagName.Equals("table") || tagName.Equals("tr") ||
tagName.Equals("td") || tagName.Equals("th") ||
tagName.Equals("thead") || tagName.Equals("tfoot") ||
tagName.Equals("tbody") || tagName.Equals("caption"))
if (tagName.EqualsWithConversion("table") || tagName.EqualsWithConversion("tr") ||
tagName.EqualsWithConversion("td") || tagName.EqualsWithConversion("th") ||
tagName.EqualsWithConversion("thead") || tagName.EqualsWithConversion("tfoot") ||
tagName.EqualsWithConversion("tbody") || tagName.EqualsWithConversion("caption"))
{
return PR_TRUE;
}
@ -5957,10 +5957,7 @@ nsHTMLEditor::RelativeFontChangeOnTextNode( PRInt32 aSizeChange,
}
// reparent the node inside font node with appropriate relative size
nsAutoString tag;
if (aSizeChange == 1) tag = "big";
else tag = "small";
res = InsertContainerAbove(node, &tmp, tag);
res = InsertContainerAbove(node, &tmp, NS_ConvertASCIItoUCS2( aSizeChange==1 ? "big" : "small" ));
return res;
}
@ -5977,8 +5974,8 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange,
nsresult res = NS_OK;
nsCOMPtr<nsIDOMNode> tmp;
nsAutoString tag;
if (aSizeChange == 1) tag = "big";
else tag = "small";
if (aSizeChange == 1) tag.AssignWithConversion("big");
else tag.AssignWithConversion("small");
// is this node a text node?
if (IsTextNode(aNode))

View File

@ -64,7 +64,7 @@ nsAOLCiter::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_IMETHODIMP
nsAOLCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
{
aOutString = "\n\n>> ";
aOutString.AssignWithConversion("\n\n>> ");
aOutString += aInString;
// See if the last char is a newline, and replace it if so
@ -72,11 +72,11 @@ nsAOLCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
if (aOutString.Last() == newline)
{
aOutString.SetCharAt(' ',aOutString.Length());
aOutString += "<<\n";
aOutString.AppendWithConversion("<<\n");
}
else
{
aOutString += " <<\n";
aOutString.AppendWithConversion(" <<\n");
}
return NS_OK;

View File

@ -557,7 +557,7 @@ nsTextEditorMouseListener::MouseUp(nsIDOMEvent* aMouseEvent)
if (htmlEditor)
{
nsCOMPtr<nsIDOMElement> selectedElement;
if (NS_SUCCEEDED(htmlEditor->GetSelectedElement("", getter_AddRefs(selectedElement)))
if (NS_SUCCEEDED(htmlEditor->GetSelectedElement(nsAutoString(), getter_AddRefs(selectedElement)))
&& selectedElement)
{
nsAutoString TagName;

View File

@ -44,8 +44,7 @@ static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, c
NS_IMETHODIMP macro_class::GetDefaultArgs(PRUnichar **aDefaultArgs) \
{ \
if (!aDefaultArgs) return NS_ERROR_FAILURE; \
nsString args(macro_default_args); \
*aDefaultArgs = args.ToNewUnicode(); \
*aDefaultArgs = NS_ConvertASCIItoUCS2(macro_default_args).ToNewUnicode(); \
return NS_OK; \
}

View File

@ -44,8 +44,7 @@ static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, c
NS_IMETHODIMP macro_class::GetDefaultArgs(PRUnichar **aDefaultArgs) \
{ \
if (!aDefaultArgs) return NS_ERROR_FAILURE; \
nsString args(macro_default_args); \
*aDefaultArgs = args.ToNewUnicode(); \
*aDefaultArgs = NS_ConvertASCIItoUCS2(macro_default_args).ToNewUnicode(); \
return NS_OK; \
}