outStateString.Assign(NS_LITERAL_STRING("justify"));
outStateString.AssignLiteral("justify");
nsresult GetListState(nsIEditor *aEditor, PRBool *aMixed, PRUnichar **tagStr);nsresult RemoveOneProperty(nsIHTMLEditor *aEditor,const nsString& aProp,                           const nsString &aAttr);nsresult RemoveTextProperty(nsIEditor *aEditor, const PRUnichar *prop,                            const PRUnichar *attr);nsresult SetTextProperty(nsIEditor *aEditor, const PRUnichar *prop,                         const PRUnichar *attr, const PRUnichar *value);//defines#define STATE_ENABLED  "state_enabled"#define STATE_ALL "state_all"#define STATE_ANY "state_any"#define STATE_MIXED "state_mixed"#define STATE_BEGIN "state_begin"#define STATE_END "state_end"#define STATE_ATTRIBUTE "state_attribute"#define STATE_DATA "state_data"nsBaseComposerCommand::nsBaseComposerCommand(){}NS_IMPL_ISUPPORTS1(nsBaseComposerCommand, nsIControllerCommand)#ifdef XP_MAC#pragma mark -#endifnsBaseStateUpdatingCommand::nsBaseStateUpdatingCommand(const char* aTagName): nsBaseComposerCommand(), mTagName(aTagName){}nsBaseStateUpdatingCommand::~nsBaseStateUpdatingCommand(){}NS_IMPL_ISUPPORTS_INHERITED0(nsBaseStateUpdatingCommand, nsBaseComposerCommand)NS_IMETHODIMPnsBaseStateUpdatingCommand::IsCommandEnabled(const char *aCommandName,                                             nsISupports *refCon,                                             PRBool *outCmdEnabled){  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);  *outCmdEnabled = editor ? PR_TRUE : PR_FALSE;  return NS_OK;}NS_IMETHODIMPnsBaseStateUpdatingCommand::DoCommand(const char *aCommandName,                                      nsISupports *refCon){  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);  if (!editor) return NS_ERROR_NOT_INITIALIZED;  return ToggleState(editor, mTagName);}NS_IMETHODIMPnsBaseStateUpdatingCommand::DoCommandParams(const char *aCommandName,                                            nsICommandParams *aParams,                                            nsISupports *refCon){  return DoCommand(aCommandName, refCon);}NS_IMETHODIMPnsBaseStateUpdatingCommand::GetCommandStateParams(const char *aCommandName,                                                   nsICommandParams *aParams,                                                  nsISupports *refCon){  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);  if (editor)    return GetCurrentState(editor, mTagName, aParams);  return NS_OK;}NS_IMETHODIMPnsPasteNoFormattingCommand::IsCommandEnabled(const char * aCommandName,                                              nsISupports *refCon,                                              PRBool *outCmdEnabled){  NS_ENSURE_ARG_POINTER(outCmdEnabled);  *outCmdEnabled = PR_FALSE;  // This command is only implemented by nsIHTMLEditor, since  //  pasting in a plaintext editor automatically only supplies   //  "unformatted" text  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(refCon);  if (!htmlEditor)    return NS_ERROR_NOT_IMPLEMENTED;  nsCOMPtr<nsIEditor> editor = do_QueryInterface(htmlEditor);  if (!editor)    return NS_ERROR_INVALID_ARG;  return editor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled);}NS_IMETHODIMPnsPasteNoFormattingCommand::DoCommand(const char *aCommandName,                                      nsISupports *refCon){  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(refCon);  if (!htmlEditor)    return NS_ERROR_NOT_IMPLEMENTED;  return htmlEditor->PasteNoFormatting(nsIClipboard::kGlobalClipboard);}NS_IMETHODIMPnsPasteNoFormattingCommand::DoCommandParams(const char *aCommandName,                                            nsICommandParams *aParams,                                             nsISupports *refCon){  return DoCommand(aCommandName, refCon);}NS_IMETHODIMPnsPasteNoFormattingCommand::GetCommandStateParams(const char *aCommandName,                                                  nsICommandParams *aParams,                                                  nsISupports *refCon){  NS_ENSURE_ARG_POINTER(aParams);  PRBool enabled = PR_FALSE;  nsresult rv = IsCommandEnabled(aCommandName, refCon, &enabled);  NS_ENSURE_SUCCESS(rv, rv);  return aParams->SetBooleanValue(STATE_ENABLED, enabled);}#ifdef XP_MAC#pragma mark -#endifnsStyleUpdatingCommand::nsStyleUpdatingCommand(const char* aTagName): nsBaseStateUpdatingCommand(aTagName){}nsresultnsStyleUpdatingCommand::GetCurrentState(nsIEditor *aEditor,                                         const char* aTagName,                                        nsICommandParams *aParams){  NS_ASSERTION(aEditor, "Need editor here");  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_NOT_INITIALIZED;    nsresult rv = NS_OK;  PRBool firstOfSelectionHasProp = PR_FALSE;  PRBool anyOfSelectionHasProp = PR_FALSE;  PRBool allOfSelectionHasProp = PR_FALSE;  nsCOMPtr<nsIAtom> styleAtom = do_GetAtom(aTagName);  rv = htmlEditor->GetInlineProperty(styleAtom, EmptyString(),                                      EmptyString(),                                      &firstOfSelectionHasProp,                                      &anyOfSelectionHasProp,                                      &allOfSelectionHasProp);  aParams->SetBooleanValue(STATE_ENABLED, NS_SUCCEEDED(rv));  aParams->SetBooleanValue(STATE_ALL, allOfSelectionHasProp);  aParams->SetBooleanValue(STATE_ANY, anyOfSelectionHasProp);  aParams->SetBooleanValue(STATE_MIXED, anyOfSelectionHasProp           && !allOfSelectionHasProp);  aParams->SetBooleanValue(STATE_BEGIN, firstOfSelectionHasProp);  aParams->SetBooleanValue(STATE_END, allOfSelectionHasProp);//not completely accurate  return NS_OK;}nsresultnsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor, const char* aTagName){  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor)    return NS_ERROR_NO_INTERFACE;  //create some params now...  nsresult rv;  nsCOMPtr<nsICommandParams> params =      do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv);  if (NS_FAILED(rv) || !params)    return rv;  // tags "href" and "name" are special cases in the core editor   // they are used to remove named anchor/link and shouldn't be used for insertion  nsAutoString tagName; tagName.AssignWithConversion(aTagName);  PRBool doTagRemoval;  if (tagName.EqualsLiteral("href") ||      tagName.EqualsLiteral("name"))    doTagRemoval = PR_TRUE;  else  {    // check current selection; set doTagRemoval if formatting should be removed    rv = GetCurrentState(aEditor, aTagName, params);    if (NS_FAILED(rv))       return rv;    rv = params->GetBooleanValue(STATE_ALL, &doTagRemoval);    if (NS_FAILED(rv))       return rv;  }  if (doTagRemoval)    rv = RemoveTextProperty(aEditor, tagName.get(), nsnull);  else  {    // Superscript and Subscript styles are mutually exclusive    nsAutoString removeName;     aEditor->BeginTransaction();    if (tagName.EqualsLiteral("sub"))    {      removeName.AssignWithConversion("sup");      rv = RemoveTextProperty(aEditor,tagName.get(), nsnull);    }     else if (tagName.EqualsLiteral("sup"))    {      removeName.AssignWithConversion("sub");      rv = RemoveTextProperty(aEditor, tagName.get(), nsnull);    }    if (NS_SUCCEEDED(rv))      rv = SetTextProperty(aEditor,tagName.get(), nsnull, nsnull);    aEditor->EndTransaction();  }  return rv;}#ifdef XP_MAC#pragma mark -#endifnsListCommand::nsListCommand(const char* aTagName): nsBaseStateUpdatingCommand(aTagName){}nsresultnsListCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName,                               nsICommandParams *aParams){  NS_ASSERTION(aEditor, "Need editor here");  PRBool bMixed;  PRUnichar *tagStr;  nsresult rv = GetListState(aEditor,&bMixed, &tagStr);  if (NS_FAILED(rv)) return rv;  // Need to use mTagName????  PRBool inList = (0 == nsCRT::strcmp(tagStr,                   NS_ConvertASCIItoUCS2(mTagName).get()));  aParams->SetBooleanValue(STATE_ALL, !bMixed && inList);  aParams->SetBooleanValue(STATE_MIXED, bMixed);  aParams->SetBooleanValue(STATE_ENABLED, PR_TRUE);  if (tagStr) nsCRT::free(tagStr);  return NS_OK;}nsresultnsListCommand::ToggleState(nsIEditor *aEditor, const char* aTagName){  nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(aEditor);  if (!editor)    return NS_NOINTERFACE;  PRBool inList;  // Need to use mTagName????  nsresult rv;  nsCOMPtr<nsICommandParams> params =      do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv);  if (NS_FAILED(rv) || !params)    return rv;  rv = GetCurrentState(aEditor, mTagName, params);  rv = params->GetBooleanValue(STATE_ALL,&inList);  if (NS_FAILED(rv))     return rv;  nsAutoString listType; listType.AssignWithConversion(mTagName);  if (inList)    rv = editor->RemoveList(listType);      else  {    rv = editor->MakeOrChangeList(listType, PR_FALSE, EmptyString());  }    return rv;}#ifdef XP_MAC#pragma mark -#endifnsListItemCommand::nsListItemCommand(const char* aTagName): nsBaseStateUpdatingCommand(aTagName){}nsresultnsListItemCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName,                                   nsICommandParams *aParams){  NS_ASSERTION(aEditor, "Need editor here");  // 39584  nsCOMPtr<nsIHTMLEditor>  htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor)    return NS_NOINTERFACE;  PRBool bMixed, bLI, bDT, bDD;  nsresult rv = htmlEditor->GetListItemState(&bMixed, &bLI, &bDT, &bDD);  if (NS_FAILED(rv)) return rv;  PRBool inList = PR_FALSE;  if (!bMixed)  {    if (bLI) inList = (0 == nsCRT::strcmp(mTagName, "li"));    else if (bDT) inList = (0 == nsCRT::strcmp(mTagName, "dt"));    else if (bDD) inList = (0 == nsCRT::strcmp(mTagName, "dd"));  }  aParams->SetBooleanValue(STATE_ALL, !bMixed && inList);  aParams->SetBooleanValue(STATE_MIXED, bMixed);  return NS_OK;}nsresultnsListItemCommand::ToggleState(nsIEditor *aEditor, const char* aTagName){  NS_ASSERTION(aEditor, "Need editor here");  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_NOT_INITIALIZED;  PRBool inList;  // Need to use mTagName????  nsresult rv;  nsCOMPtr<nsICommandParams> params =      do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv);  if (NS_FAILED(rv) || !params)    return rv;  rv = GetCurrentState(aEditor, mTagName, params);  rv = params->GetBooleanValue(STATE_ALL,&inList);  if (NS_FAILED(rv))     return rv;  if (NS_FAILED(rv)) return rv;    if (inList)  {    // To remove a list, first get what kind of list we're in    PRBool bMixed;    PRUnichar *tagStr;    rv = GetListState(aEditor,&bMixed, &tagStr);    if (NS_FAILED(rv)) return rv;     if (tagStr)    {      if (!bMixed)      {        rv = htmlEditor->RemoveList(nsDependentString(tagStr));          }      nsCRT::free(tagStr);    }  }  else  {    nsAutoString itemType; itemType.AssignWithConversion(mTagName);    // Set to the requested paragraph type    //XXX Note: This actually doesn't work for "LI",    //    but we currently don't use this for non DL lists anyway.    // Problem: won't this replace any current block paragraph style?    rv = htmlEditor->SetParagraphFormat(itemType);  }      return rv;}#ifdef XP_MAC#pragma mark -#endifNS_IMETHODIMPnsRemoveListCommand::IsCommandEnabled(const char * aCommandName,                                      nsISupports *refCon,                                      PRBool *outCmdEnabled){  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);  if (editor)  {    // It is enabled if we are in any list type    PRBool bMixed;    PRUnichar *tagStr;    nsresult rv = GetListState(editor, &bMixed, &tagStr);    if (NS_FAILED(rv)) return rv;    *outCmdEnabled = bMixed ? PR_TRUE : (tagStr && *tagStr);        if (tagStr) nsCRT::free(tagStr);  }  else    *outCmdEnabled = PR_FALSE;  return NS_OK;}NS_IMETHODIMPnsRemoveListCommand::DoCommand(const char *aCommandName, nsISupports *refCon){  nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);  nsresult rv = NS_OK;  if (editor)  {    // This removes any list type    rv = editor->RemoveList(EmptyString());  }  return rv;  }NS_IMETHODIMPnsRemoveListCommand::DoCommandParams(const char *aCommandName,                                      nsICommandParams *aParams,                                     nsISupports *refCon){  return DoCommand(aCommandName, refCon);}NS_IMETHODIMPnsRemoveListCommand::GetCommandStateParams(const char *aCommandName,                                           nsICommandParams *aParams,                                            nsISupports *refCon){  PRBool outCmdEnabled = PR_FALSE;  IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);  return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);}#ifdef XP_MAC#pragma mark -#endifNS_IMETHODIMPnsIndentCommand::IsCommandEnabled(const char * aCommandName,                                  nsISupports *refCon, PRBool *outCmdEnabled){  nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);  *outCmdEnabled = editor ? PR_TRUE : PR_FALSE;  return NS_OK;}NS_IMETHODIMPnsIndentCommand::DoCommand(const char *aCommandName, nsISupports *refCon){  nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);  nsresult rv = NS_OK;  if (editor)  {    rv = editor->Indent(NS_LITERAL_STRING("indent"));  }    return rv;  }NS_IMETHODIMPnsIndentCommand::DoCommandParams(const char *aCommandName,                                 nsICommandParams *aParams,                                 nsISupports *refCon){  return DoCommand(aCommandName, refCon);  }NS_IMETHODIMPnsIndentCommand::GetCommandStateParams(const char *aCommandName,                                       nsICommandParams *aParams,                                       nsISupports *refCon){  PRBool outCmdEnabled = PR_FALSE;  IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);  return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);}//OUTDENTNS_IMETHODIMPnsOutdentCommand::IsCommandEnabled(const char * aCommandName,                                   nsISupports *refCon,                                   PRBool *outCmdEnabled){  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(refCon);  if (htmlEditor)  {    PRBool canIndent, canOutdent;    htmlEditor->GetIndentState(&canIndent, &canOutdent);    *outCmdEnabled = canOutdent;  }  else    *outCmdEnabled = PR_FALSE;  return NS_OK;}NS_IMETHODIMPnsOutdentCommand::DoCommand(const char *aCommandName, nsISupports *refCon){  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(refCon);  if (htmlEditor)    return htmlEditor->Indent(NS_LITERAL_STRING("outdent"));    return NS_OK;  }NS_IMETHODIMPnsOutdentCommand::DoCommandParams(const char *aCommandName,                                  nsICommandParams *aParams,                                   nsISupports *refCon){  return DoCommand(aCommandName, refCon);  }NS_IMETHODIMPnsOutdentCommand::GetCommandStateParams(const char *aCommandName,                                        nsICommandParams *aParams,                                        nsISupports *refCon){  PRBool outCmdEnabled = PR_FALSE;  IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);  return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);}#ifdef XP_MAC#pragma mark -#endifnsMultiStateCommand::nsMultiStateCommand(): nsBaseComposerCommand(){}nsMultiStateCommand::~nsMultiStateCommand(){}NS_IMPL_ISUPPORTS_INHERITED0(nsMultiStateCommand, nsBaseComposerCommand)NS_IMETHODIMPnsMultiStateCommand::IsCommandEnabled(const char * aCommandName,                                      nsISupports *refCon,                                      PRBool *outCmdEnabled){  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);  // should be disabled sometimes, like if the current selection is an image  *outCmdEnabled = editor ? PR_TRUE : PR_FALSE;  return NS_OK; }NS_IMETHODIMPnsMultiStateCommand::DoCommand(const char *aCommandName, nsISupports *refCon){#ifdef DEBUG  printf("who is calling nsMultiStateCommand::DoCommand \          (no implementation)? %s\n", aCommandName);#endif    return NS_OK;  }NS_IMETHODIMPnsMultiStateCommand::DoCommandParams(const char *aCommandName,                                     nsICommandParams *aParams,                                     nsISupports *refCon){  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);  nsresult rv = NS_OK;  if (editor)  {      nsAutoString tString;      if (aParams) {        nsXPIDLCString s;        rv = aParams->GetCStringValue(STATE_ATTRIBUTE, getter_Copies(s));        if (NS_SUCCEEDED(rv))          tString.AssignWithConversion(s);        else          rv = aParams->GetStringValue(STATE_ATTRIBUTE, tString);      }      rv = SetState(editor, tString);  }    return rv;  }NS_IMETHODIMPnsMultiStateCommand::GetCommandStateParams(const char *aCommandName,                                           nsICommandParams *aParams,                                           nsISupports *refCon){  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);  nsresult rv = NS_OK;  if (editor)  {      rv = GetCurrentState(editor, aParams);  }  return rv;}#ifdef XP_MAC#pragma mark -#endifnsParagraphStateCommand::nsParagraphStateCommand(): nsMultiStateCommand(){}nsresultnsParagraphStateCommand::GetCurrentState(nsIEditor *aEditor,                                         nsICommandParams *aParams){  NS_ASSERTION(aEditor, "Need an editor here");    nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;  PRBool outMixed;  nsAutoString outStateString;  nsresult rv = htmlEditor->GetParagraphState(&outMixed, outStateString);  if (NS_SUCCEEDED(rv))  {    nsCAutoString tOutStateString;    tOutStateString.AssignWithConversion(outStateString);    aParams->SetBooleanValue(STATE_MIXED,outMixed);    aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());  }  return rv;}nsresultnsParagraphStateCommand::SetState(nsIEditor *aEditor, nsString& newState){  NS_ASSERTION(aEditor, "Need an editor here");  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;  return htmlEditor->SetParagraphFormat(newState);}#ifdef XP_MAC#pragma mark -#endifnsFontFaceStateCommand::nsFontFaceStateCommand(): nsMultiStateCommand(){}nsresultnsFontFaceStateCommand::GetCurrentState(nsIEditor *aEditor,                                        nsICommandParams *aParams){  NS_ASSERTION(aEditor, "Need an editor here");  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;  nsAutoString outStateString;  PRBool outMixed;  nsresult rv = htmlEditor->GetFontFaceState(&outMixed, outStateString);  if (NS_SUCCEEDED(rv))  {    aParams->SetBooleanValue(STATE_MIXED,outMixed);    aParams->SetCStringValue(STATE_ATTRIBUTE, NS_ConvertUTF16toUTF8(outStateString).get());  }  return rv;}nsresultnsFontFaceStateCommand::SetState(nsIEditor *aEditor, nsString& newState){  NS_ASSERTION(aEditor, "Need an editor here");  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;    nsresult rv;  nsCOMPtr<nsIAtom> ttAtom = do_GetAtom("tt");  nsCOMPtr<nsIAtom> fontAtom = do_GetAtom("font");  if (newState.EqualsLiteral("tt"))  {    // The old "teletype" attribute      rv = htmlEditor->SetInlineProperty(ttAtom, EmptyString(),                                        EmptyString());      // Clear existing font face    rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("face"));  }  else  {    // Remove any existing TT nodes    rv = htmlEditor->RemoveInlineProperty(ttAtom, EmptyString());      if (newState.IsEmpty() || newState.EqualsLiteral("normal")) {      rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("face"));    } else {      rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("face"),                                         newState);    }  }    return rv;}#ifdef XP_MAC#pragma mark -#endifnsFontSizeStateCommand::nsFontSizeStateCommand()  : nsMultiStateCommand(){}//  nsCAutoString tOutStateString;//  tOutStateString.AssignWithConversion(outStateString);nsresultnsFontSizeStateCommand::GetCurrentState(nsIEditor *aEditor,                                        nsICommandParams *aParams){  NS_ASSERTION(aEditor, "Need an editor here");  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_INVALID_ARG;  nsAutoString outStateString;  nsCOMPtr<nsIAtom> fontAtom = do_GetAtom("font");  PRBool firstHas, anyHas, allHas;  nsresult rv = htmlEditor->GetInlinePropertyWithAttrValue(fontAtom,                                         NS_LITERAL_STRING("size"),                                         EmptyString(),                                         &firstHas, &anyHas, &allHas,                                         outStateString);  if (NS_FAILED(rv)) return rv;  nsCAutoString tOutStateString;  tOutStateString.AssignWithConversion(outStateString);  aParams->SetBooleanValue(STATE_MIXED, anyHas && !allHas);  aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());  aParams->SetBooleanValue(STATE_ENABLED, PR_TRUE);  return rv;}// acceptable values for "newState" are://   -2//   -1//    0//   +1//   +2//   +3//   medium//   normalnsresultnsFontSizeStateCommand::SetState(nsIEditor *aEditor, nsString& newState){  NS_ASSERTION(aEditor, "Need an editor here");  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_INVALID_ARG;  nsresult rv;  nsCOMPtr<nsIAtom> fontAtom = do_GetAtom("font");  if (newState.IsEmpty() ||       newState.EqualsLiteral("normal") ||      newState.EqualsLiteral("medium")) {    // remove any existing font size, big or small    rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("size"));      if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIAtom> bigAtom = do_GetAtom("big");    rv = htmlEditor->RemoveInlineProperty(bigAtom, EmptyString());      if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIAtom> smallAtom = do_GetAtom("small");    rv = htmlEditor->RemoveInlineProperty(smallAtom, EmptyString());      if (NS_FAILED(rv)) return rv;  } else {    // set the size    rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("size"),                                       newState);  }  return rv;}#ifdef XP_MAC#pragma mark -#endifnsFontColorStateCommand::nsFontColorStateCommand(): nsMultiStateCommand(){}nsresultnsFontColorStateCommand::GetCurrentState(nsIEditor *aEditor,                                         nsICommandParams *aParams){  NS_ASSERTION(aEditor, "Need an editor here");    nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;  PRBool outMixed;  nsAutoString outStateString;  nsresult rv = htmlEditor->GetFontColorState(&outMixed, outStateString);  if (NS_SUCCEEDED(rv))  {    nsCAutoString tOutStateString;    tOutStateString.AssignWithConversion(outStateString);    aParams->SetBooleanValue(STATE_MIXED,outMixed);    aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());  }  return rv;}nsresultnsFontColorStateCommand::SetState(nsIEditor *aEditor, nsString& newState){  NS_ASSERTION(aEditor, "Need an editor here");  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;    nsresult rv;  nsCOMPtr<nsIAtom> fontAtom = do_GetAtom("font");  if (newState.IsEmpty() || newState.EqualsLiteral("normal")) {    rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("color"));  } else {    rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("color"),                                        newState);  }    return rv;}#ifdef XP_MAC#pragma mark -#endifnsHighlightColorStateCommand::nsHighlightColorStateCommand(): nsMultiStateCommand(){}nsresultnsHighlightColorStateCommand::GetCurrentState(nsIEditor *aEditor,                                              nsICommandParams *aParams){  NS_ASSERTION(aEditor, "Need an editor here");  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;  PRBool outMixed;  nsAutoString outStateString;  nsresult rv = htmlEditor->GetHighlightColorState(&outMixed, outStateString);  if (NS_SUCCEEDED(rv))  {    nsCAutoString tOutStateString;    tOutStateString.AssignWithConversion(outStateString);    aParams->SetBooleanValue(STATE_MIXED,outMixed);    aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());  }  return rv;}nsresultnsHighlightColorStateCommand::SetState(nsIEditor *aEditor, nsString& newState){  NS_ASSERTION(aEditor, "Need an editor here");  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;  nsresult rv;  nsCOMPtr<nsIAtom> fontAtom = do_GetAtom("font");  if (newState.IsEmpty() || newState.EqualsLiteral("normal")) {//    rv = RemoveOneProperty(htmlEditor, NS_LITERAL_STRING("font"), NS_LITERAL_STRING("bgcolor"));    rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("bgcolor"));  } else {    rv = htmlEditor->SetCSSInlineProperty(fontAtom, NS_LITERAL_STRING("bgcolor"),                                          newState);  }  return rv;}NS_IMETHODIMPnsHighlightColorStateCommand::IsCommandEnabled(const char * aCommandName,                                               nsISupports *refCon,                                               PRBool *outCmdEnabled){  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(refCon);  *outCmdEnabled = htmlEditor ? PR_TRUE : PR_FALSE;  return NS_OK;}#ifdef XP_MAC#pragma mark -#endifnsBackgroundColorStateCommand::nsBackgroundColorStateCommand(): nsMultiStateCommand(){}nsresultnsBackgroundColorStateCommand::GetCurrentState(nsIEditor *aEditor,                                               nsICommandParams *aParams){  NS_ASSERTION(aEditor, "Need an editor here");    nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;  PRBool outMixed;  nsAutoString outStateString;  nsresult rv =  htmlEditor->GetBackgroundColorState(&outMixed, outStateString);  if (NS_SUCCEEDED(rv))  {    nsCAutoString tOutStateString;    tOutStateString.AssignWithConversion(outStateString);    aParams->SetBooleanValue(STATE_MIXED,outMixed);    aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());  }  return rv;}nsresultnsBackgroundColorStateCommand::SetState(nsIEditor *aEditor, nsString& newState){  NS_ASSERTION(aEditor, "Need an editor here");    nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;  return htmlEditor->SetBackgroundColor(newState);}#ifdef XP_MAC#pragma mark -#endifnsAlignCommand::nsAlignCommand(): nsMultiStateCommand(){}nsresultnsAlignCommand::GetCurrentState(nsIEditor *aEditor, nsICommandParams *aParams){  NS_ASSERTION(aEditor, "Need an editor here");    nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;   nsIHTMLEditor::EAlignment firstAlign;  PRBool outMixed;  nsresult rv = htmlEditor->GetAlignment(&outMixed, &firstAlign);    if (NS_FAILED(rv))     return rv;    nsAutoString outStateString;  switch (firstAlign)  {    default:    case nsIHTMLEditor::eLeft:      outStateString.Assign(NS_LITERAL_STRING("left"));      break;          case nsIHTMLEditor::eCenter:      outStateString.Assign(NS_LITERAL_STRING("center"));      break;          case nsIHTMLEditor::eRight:      outStateString.Assign(NS_LITERAL_STRING("right"));      break;    case nsIHTMLEditor::eJustify:      outStateString.Assign(NS_LITERAL_STRING("justify"));      break;  }  nsCAutoString tOutStateString;  tOutStateString.AssignWithConversion(outStateString);  aParams->SetBooleanValue(STATE_MIXED,outMixed);  aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());  return NS_OK;}nsresultnsAlignCommand::SetState(nsIEditor *aEditor, nsString& newState){  NS_ASSERTION(aEditor, "Need an editor here");    nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;  return htmlEditor->Align(newState);}#ifdef XP_MAC#pragma mark -#endifnsAbsolutePositioningCommand::nsAbsolutePositioningCommand(): nsBaseStateUpdatingCommand(""){}NS_IMETHODIMPnsAbsolutePositioningCommand::IsCommandEnabled(const char * aCommandName,                                               nsISupports *aCommandRefCon,                                               PRBool *_retval){  NS_ASSERTION(aCommandRefCon, "Need an editor here");    nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(aCommandRefCon);  if (!htmlEditor) return NS_ERROR_FAILURE;  htmlEditor->GetAbsolutePositioningEnabled(_retval);  return NS_OK;}nsresultnsAbsolutePositioningCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams){  NS_ASSERTION(aEditor, "Need an editor here");    nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;  PRBool isEnabled;  htmlEditor->GetAbsolutePositioningEnabled(&isEnabled);  if (!isEnabled) {    aParams->SetBooleanValue(STATE_MIXED,PR_FALSE);    aParams->SetCStringValue(STATE_ATTRIBUTE, "");    return NS_OK;  }  nsCOMPtr<nsIDOMElement>  elt;  nsresult rv = htmlEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));  if (NS_FAILED(rv))     return rv;  nsAutoString outStateString;  if (elt)    outStateString.Assign(NS_LITERAL_STRING("absolute"));  aParams->SetBooleanValue(STATE_MIXED,PR_FALSE);  aParams->SetCStringValue(STATE_ATTRIBUTE, NS_ConvertUCS2toUTF8(outStateString).get());  return NS_OK;}nsresultnsAbsolutePositioningCommand::ToggleState(nsIEditor *aEditor, const char* aTagName){  NS_ASSERTION(aEditor, "Need an editor here");    nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(aEditor);  if (!htmlEditor) return NS_ERROR_FAILURE;  nsCOMPtr<nsIDOMElement>  elt;  nsresult rv = htmlEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));  if (NS_FAILED(rv)) return rv;  if (elt) {    // we have to remove positioning on an element    rv = htmlEditor->AbsolutePositionSelection(PR_FALSE);  }  else {    rv = htmlEditor->AbsolutePositionSelection(PR_TRUE);  }  return rv;}#ifdef XP_MAC#pragma mark -#endifNS_IMETHODIMPnsDecreaseZIndexCommand::IsCommandEnabled(const char * aCommandName,                                          nsISupports *refCon,                                          PRBool *outCmdEnabled){  nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(refCon);  if (!htmlEditor) return NS_ERROR_FAILURE;  htmlEditor->GetAbsolutePositioningEnabled(outCmdEnabled);  if (!(*outCmdEnabled))    return NS_OK;  nsCOMPtr<nsIDOMElement> positionedElement;  htmlEditor->GetPositionedElement(getter_AddRefs(positionedElement));  *outCmdEnabled = PR_FALSE;  if (positionedElement) {    PRInt32 z;    nsresult res = htmlEditor->GetElementZIndex(positionedElement, &z);    if (NS_FAILED(res)) return res;    *outCmdEnabled = (z > 0);  }  return NS_OK;}NS_IMETHODIMPnsDecreaseZIndexCommand::DoCommand(const char *aCommandName,                                   nsISupports *refCon){  nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(refCon);  if (!htmlEditor)    return NS_ERROR_NOT_IMPLEMENTED;  return htmlEditor->RelativeChangeZIndex(-1);}NS_IMETHODIMPnsDecreaseZIndexCommand::DoCommandParams(const char *aCommandName,                                         nsICommandParams *aParams,                                          nsISupports *refCon){  return DoCommand(aCommandName, refCon);}NS_IMETHODIMPnsDecreaseZIndexCommand::GetCommandStateParams(const char *aCommandName,                                               nsICommandParams *aParams,                                               nsISupports *refCon){  NS_ENSURE_ARG_POINTER(aParams);  PRBool enabled = PR_FALSE;  nsresult rv = IsCommandEnabled(aCommandName, refCon, &enabled);  NS_ENSURE_SUCCESS(rv, rv);  return aParams->SetBooleanValue(STATE_ENABLED, enabled);}#ifdef XP_MAC#pragma mark -#endifNS_IMETHODIMPnsIncreaseZIndexCommand::IsCommandEnabled(const char * aCommandName,                                          nsISupports *refCon,                                          PRBool *outCmdEnabled){  nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(refCon);  if (!htmlEditor) return NS_ERROR_FAILURE;  htmlEditor->GetAbsolutePositioningEnabled(outCmdEnabled);  if (!(*outCmdEnabled))    return NS_OK;  nsCOMPtr<nsIDOMElement> positionedElement;  htmlEditor->GetPositionedElement(getter_AddRefs(positionedElement));  *outCmdEnabled = (nsnull != positionedElement);  return NS_OK;}NS_IMETHODIMPnsIncreaseZIndexCommand::DoCommand(const char *aCommandName,                                   nsISupports *refCon){  nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(refCon);  if (!htmlEditor)    return NS_ERROR_NOT_IMPLEMENTED;  return htmlEditor->RelativeChangeZIndex(1);}NS_IMETHODIMPnsIncreaseZIndexCommand::DoCommandParams(const char *aCommandName,                                         nsICommandParams *aParams,                                          nsISupports *refCon){  return DoCommand(aCommandName, refCon);}NS_IMETHODIMPnsIncreaseZIndexCommand::GetCommandStateParams(const char *aCommandName,                                               nsICommandParams *aParams,                                               nsISupports *refCon){  NS_ENSURE_ARG_POINTER(aParams);  PRBool enabled = PR_FALSE;  nsresult rv = IsCommandEnabled(aCommandName, refCon, &enabled);  NS_ENSURE_SUCCESS(rv, rv);  return aParams->SetBooleanValue(STATE_ENABLED, enabled);}#ifdef XP_MAC#pragma mark -#endifNS_IMETHODIMPnsRemoveStylesCommand::IsCommandEnabled(const char * aCommandName,                                        nsISupports *refCon,                                        PRBool *outCmdEnabled){  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);  // test if we have any styles?  *outCmdEnabled = editor ? PR_TRUE : PR_FALSE;  return NS_OK;}NS_IMETHODIMPnsRemoveStylesCommand::DoCommand(const char *aCommandName,                                 nsISupports *refCon){  nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);  nsresult rv = NS_OK;  if (editor)  {    rv = editor->RemoveAllInlineProperties();  }    return rv;  }NS_IMETHODIMPnsRemoveStylesCommand::DoCommandParams(const char *aCommandName,                                       nsICommandParams *aParams,                                       nsISupports *refCon){  return DoCommand(aCommandName, refCon);}NS_IMETHODIMPnsRemoveStylesCommand::GetCommandStateParams(const char *aCommandName,                                             nsICommandParams *aParams,                                             nsISupports *refCon){  PRBool outCmdEnabled = PR_FALSE;  IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);  return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);}#ifdef XP_MAC#pragma mark -#endifNS_IMETHODIMPnsIncreaseFontSizeCommand::IsCommandEnabled(const char * aCommandName,                                            nsISupports *refCon,                                            PRBool *outCmdEnabled){  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);  // test if we have any styles?  *outCmdEnabled = editor ? PR_TRUE : PR_FALSE;  return NS_OK;}NS_IMETHODIMPnsIncreaseFontSizeCommand::DoCommand(const char *aCommandName,                                     nsISupports *refCon){  nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);  nsresult rv = NS_OK;  if (editor)  {    rv = editor->IncreaseFontSize();  }    return rv;  }NS_IMETHODIMPnsIncreaseFontSizeCommand::DoCommandParams(const char *aCommandName,                                           nsICommandParams *aParams,                                           nsISupports *refCon){  return DoCommand(aCommandName, refCon);}NS_IMETHODIMPnsIncreaseFontSizeCommand::GetCommandStateParams(const char *aCommandName,                                                 nsICommandParams *aParams,                                                 nsISupports *refCon){  PRBool outCmdEnabled = PR_FALSE;  IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);  return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);}#ifdef XP_MAC#pragma mark -#endifNS_IMETHODIMPnsDecreaseFontSizeCommand::IsCommandEnabled(const char * aCommandName,                                            nsISupports *refCon,                                            PRBool *outCmdEnabled){  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);  // test if we are at min size?  *outCmdEnabled = editor ? PR_TRUE : PR_FALSE;  return NS_OK;}NS_IMETHODIMPnsDecreaseFontSizeCommand::DoCommand(const char *aCommandName,                                     nsISupports *refCon){  nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);  nsresult rv = NS_OK;  if (editor)  {    rv = editor->DecreaseFontSize();  }    return rv;  }NS_IMETHODIMPnsDecreaseFontSizeCommand::DoCommandParams(const char *aCommandName,                                           nsICommandParams *aParams,                                           nsISupports *refCon){  return DoCommand(aCommandName, refCon);}NS_IMETHODIMPnsDecreaseFontSizeCommand::GetCommandStateParams(const char *aCommandName,                                                 nsICommandParams *aParams,                                                 nsISupports *refCon){  PRBool outCmdEnabled = PR_FALSE;  IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);  return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);}#ifdef XP_MAC#pragma mark -#endifNS_IMETHODIMPnsInsertHTMLCommand::IsCommandEnabled(const char * aCommandName,                                      nsISupports *refCon,                                      PRBool *outCmdEnabled){  NS_ENSURE_ARG_POINTER(outCmdEnabled);  nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);  *outCmdEnabled = editor ? PR_TRUE : PR_FALSE;  return NS_OK;}NS_IMETHODIMPnsInsertHTMLCommand::DoCommand(const char *aCommandName, nsISupports *refCon){  return NS_ERROR_NOT_IMPLEMENTED;}NS_IMETHODIMPnsInsertHTMLCommand::DoCommandParams(const char *aCommandName,                                     nsICommandParams *aParams,                                     nsISupports *refCon){  NS_ENSURE_ARG_POINTER(aParams);  NS_ENSURE_ARG_POINTER(refCon);  nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);  if (!editor)    return NS_ERROR_NOT_IMPLEMENTED;  // Get HTML source string to insert from command params  nsAutoString html;  nsresult rv = aParams->GetStringValue(STATE_DATA, html);  NS_ENSURE_SUCCESS(rv, rv);  if (!html.IsEmpty())    return editor->InsertHTML(html);  return NS_OK;}NS_IMETHODIMPnsInsertHTMLCommand::GetCommandStateParams(const char *aCommandName,                                           nsICommandParams *aParams,                                           nsISupports *refCon){  NS_ENSURE_ARG_POINTER(aParams);  NS_ENSURE_ARG_POINTER(refCon);  PRBool outCmdEnabled = PR_FALSE;  IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);  return aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled);}#ifdef XP_MAC#pragma mark -#endifNS_IMPL_ISUPPORTS_INHERITED0(nsInsertTagCommand, nsBaseComposerCommand)nsInsertTagCommand::nsInsertTagCommand(const char* aTagName): nsBaseComposerCommand(), mTagName(aTagName){}nsInsertTagCommand::~nsInsertTagCommand(){}NS_IMETHODIMPnsInsertTagCommand::IsCommandEnabled(const char * aCommandName,                                     nsISupports *refCon,                                     PRBool *outCmdEnabled){  NS_ENSURE_ARG_POINTER(outCmdEnabled);  nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);  *outCmdEnabled = editor ? PR_TRUE : PR_FALSE;  return NS_OK;}// corresponding STATE_ATTRIBUTE is: src (img) and href (a) NS_IMETHODIMPnsInsertTagCommand::DoCommand(const char *aCmdName, nsISupports *refCon){  if (0 == nsCRT::strcmp(mTagName, "hr"))  {    nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);    if (!editor)      return NS_ERROR_NOT_IMPLEMENTED;    nsCOMPtr<nsIDOMElement> domElem;    nsresult rv;    rv = editor->CreateElementWithDefaults(NS_ConvertASCIItoUCS2(mTagName),                                           getter_AddRefs(domElem));    if (NS_FAILED(rv))      return rv;    return editor->InsertElementAtSelection(domElem, PR_TRUE);  }  return NS_ERROR_NOT_IMPLEMENTED;}NS_IMETHODIMPnsInsertTagCommand::DoCommandParams(const char *aCommandName,                                    nsICommandParams *aParams,                                    nsISupports *refCon){  NS_ENSURE_ARG_POINTER(refCon);  // inserting an hr shouldn't have an parameters, just call DoCommand for that  if (0 == nsCRT::strcmp(mTagName, "hr"))    return DoCommand(aCommandName, refCon);  NS_ENSURE_ARG_POINTER(aParams);  nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);  if (!editor)    return NS_ERROR_NOT_IMPLEMENTED;  // do we have an href to use for creating link?  nsXPIDLCString s;  nsresult rv = aParams->GetCStringValue(STATE_ATTRIBUTE, getter_Copies(s));  NS_ENSURE_SUCCESS(rv, rv);  nsAutoString attrib; attrib.AssignWithConversion(s);  if (attrib.IsEmpty())    return NS_ERROR_INVALID_ARG;  // filter out tags we don't know how to insert  nsAutoString attributeType;  if (0 == nsCRT::strcmp(mTagName, "a")) {    attributeType = NS_LITERAL_STRING("href");  } else if (0 == nsCRT::strcmp(mTagName, "img")) {    attributeType = NS_LITERAL_STRING("src");  } else {    return NS_ERROR_NOT_IMPLEMENTED;  }  nsCOMPtr<nsIDOMElement> domElem;  rv = editor->CreateElementWithDefaults(NS_ConvertASCIItoUCS2(mTagName),                                         getter_AddRefs(domElem));  if (NS_FAILED(rv))    return rv;  rv = domElem->SetAttribute(attributeType, attrib);  if (NS_FAILED(rv))    return rv;  // do actual insertion  if (0 == nsCRT::strcmp(mTagName, "a"))    return editor->InsertLinkAroundSelection(domElem);  return editor->InsertElementAtSelection(domElem, PR_TRUE);}NS_IMETHODIMPnsInsertTagCommand::GetCommandStateParams(const char *aCommandName,                                          nsICommandParams *aParams,                                          nsISupports *refCon){  NS_ENSURE_ARG_POINTER(aParams);  NS_ENSURE_ARG_POINTER(refCon);  PRBool outCmdEnabled = PR_FALSE;  IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);  return aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled);}#ifdef XP_MAC#pragma mark -#endif/****************************///HELPER METHODS/****************************/nsresultGetListState(nsIEditor *aEditor, PRBool *aMixed, PRUnichar **_retval){  if (!aMixed || !_retval || !aEditor)     return NS_ERROR_NULL_POINTER;  *_retval = nsnull;  *aMixed = PR_FALSE;  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);  nsresult err = NS_ERROR_NO_INTERFACE;  if (htmlEditor)  {    PRBool bOL, bUL, bDL;    err = htmlEditor->GetListState(aMixed, &bOL, &bUL, &bDL);    if (NS_SUCCEEDED(err))    {      if (!*aMixed)      {        nsAutoString tagStr;        if (bOL)           tagStr.AssignWithConversion("ol");        else if (bUL)           tagStr.AssignWithConversion("ul");        else if (bDL)           tagStr.AssignWithConversion("dl");        *_retval = ToNewUnicode(tagStr);      }    }    }  return err;}