mSerializer = do_CreateInstance(NS_STATIC_CAST(const char *, progId));
mSerializer = do_CreateInstance(progId.get());
nsDocumentEncoder::EncodeToString(nsAWritableString& aOutputString){  if (!mDocument)    return NS_ERROR_NOT_INITIALIZED;  aOutputString.Truncate();  // xxx Also make sure mString is a mime type "text/html" or "text/plain"  nsCAutoString progId(NS_CONTENTSERIALIZER_CONTRACTID_PREFIX);  progId.AppendWithConversion(mMimeType);  mSerializer = do_CreateInstance(NS_STATIC_CAST(const char *, progId));  NS_ENSURE_TRUE(mSerializer, NS_ERROR_NOT_IMPLEMENTED);  nsresult rv = NS_OK;  nsCOMPtr<nsIAtom> charsetAtom;  if (!mCharset.IsEmpty()) {    if (!mCharsetConverterManager) {      mCharsetConverterManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);      NS_ENSURE_SUCCESS(rv, rv);    }    rv = mCharsetConverterManager->GetCharsetAtom(mCharset.get(), getter_AddRefs(charsetAtom));    NS_ENSURE_SUCCESS(rv, rv);  }  mSerializer->Init(mFlags, mWrapColumn, charsetAtom);  if (mSelection) {    nsCOMPtr<nsIDOMRange> range;    PRInt32 i, count = 0;    rv = mSelection->GetRangeCount(&count);    NS_ENSURE_SUCCESS(rv, rv);    for (i = 0; i < count; i++) {      mSelection->GetRangeAt(i, getter_AddRefs(range));      rv = SerializeRangeToString(range, aOutputString);      NS_ENSURE_SUCCESS(rv, rv);    }    mSelection = nsnull;  } else if (mRange) {      rv = SerializeRangeToString(mRange, aOutputString);      mRange = nsnull;  } else {    nsCOMPtr<nsIDOMNode> doc(do_QueryInterface(mDocument));    rv = SerializeToStringRecursive(doc, aOutputString);  }  NS_ENSURE_SUCCESS(rv, rv);  rv = mSerializer->Flush(aOutputString);  return rv;}