Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions
nsHTMLFormatConverter Class Reference

#include <nsHTMLFormatConverter.h>

Inheritance diagram for nsHTMLFormatConverter:
Inheritance graph
[legend]
Collaboration diagram for nsHTMLFormatConverter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsHTMLFormatConverter ()
virtual ~nsHTMLFormatConverter ()
nsISupportsArray getInputDataFlavors ()
 Get the list of the "input" data flavors (mime types as nsISupportsCString), in otherwords, the flavors that this converter can convert "from" (the incoming data to the converter).
nsISupportsArray getOutputDataFlavors ()
 Get the list of the "output" data flavors (mime types as nsISupportsCString), in otherwords, the flavors that this converter can convert "to" (the outgoing data to the converter).
boolean canConvert (in string aFromDataFlavor, in string aToDataFlavor)
 Determines whether a converion from one flavor to another is supported.
void convert (in string aFromDataFlavor, in nsISupports aFromData, in unsigned long aDataLen, in string aToDataFlavor, out nsISupports aToData, out unsigned long aDataToLen)
 Converts from one flavor to another.

Protected Member Functions

nsresult AddFlavorToList (nsISupportsArray *inList, const char *inFlavor)
NS_IMETHOD ConvertFromHTMLToUnicode (const nsAutoString &aFromStr, nsAutoString &aToStr)
NS_IMETHOD ConvertFromHTMLToAOLMail (const nsAutoString &aFromStr, nsAutoString &aToStr)

Detailed Description

Definition at line 44 of file nsHTMLFormatConverter.h.


Constructor & Destructor Documentation

Definition at line 75 of file nsHTMLFormatConverter.cpp.

{
}

Definition at line 84 of file nsHTMLFormatConverter.cpp.

{
}

Member Function Documentation

nsresult nsHTMLFormatConverter::AddFlavorToList ( nsISupportsArray inList,
const char *  inFlavor 
) [protected]

Definition at line 158 of file nsHTMLFormatConverter.cpp.

{
  nsresult rv;
  
  nsCOMPtr<nsISupportsCString> dataFlavor =
      do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
  if ( dataFlavor ) {
    dataFlavor->SetData ( nsDependentCString(inFlavor) );
    // add to list as an nsISupports so the correct interface gets the addref
    // in AppendElement()
    nsCOMPtr<nsISupports> genericFlavor ( do_QueryInterface(dataFlavor) );
    inList->AppendElement ( genericFlavor);
  }
  return rv;

} // AddFlavorToList

Here is the call graph for this function:

boolean nsIFormatConverter::canConvert ( in string  aFromDataFlavor,
in string  aToDataFlavor 
) [inherited]

Determines whether a converion from one flavor to another is supported.

Parameters:
aFromFormatConverterflavor to convert from
aFromFormatConverterflavor to convert to
void nsIFormatConverter::convert ( in string  aFromDataFlavor,
in nsISupports  aFromData,
in unsigned long  aDataLen,
in string  aToDataFlavor,
out nsISupports  aToData,
out unsigned long  aDataToLen 
) [inherited]

Converts from one flavor to another.

Parameters:
aFromFormatConverterflavor to convert from
aFromFormatConverterflavor to convert to (destination own the memory)
Returns:
returns NS_OK if it was converted

Definition at line 327 of file nsHTMLFormatConverter.cpp.

{
  aToStr.AssignLiteral("<HTML>");
  aToStr.Append(aFromStr);
  aToStr.AppendLiteral("</HTML>");

  return NS_OK;
}

Definition at line 293 of file nsHTMLFormatConverter.cpp.

{
  // create the parser to do the conversion.
  aToStr.SetLength(0);
  nsresult rv;
  nsCOMPtr<nsIParser> parser = do_CreateInstance(kCParserCID, &rv);
  if ( !parser )
    return rv;

  // convert it!
  nsCOMPtr<nsIContentSink> sink;

  sink = do_CreateInstance(NS_PLAINTEXTSINK_CONTRACTID);
  NS_ENSURE_TRUE(sink, NS_ERROR_FAILURE);

  nsCOMPtr<nsIHTMLToTextSink> textSink(do_QueryInterface(sink));
  NS_ENSURE_TRUE(textSink, NS_ERROR_FAILURE);

  textSink->Initialize(&aToStr, nsIDocumentEncoder::OutputSelectionOnly
                       | nsIDocumentEncoder::OutputAbsoluteLinks, 0);

  parser->SetContentSink(sink);

  parser->Parse(aFromStr, 0, NS_LITERAL_CSTRING("text/html"), PR_FALSE, PR_TRUE, eDTDMode_fragment);
  
  return NS_OK;
} // ConvertFromHTMLToUnicode

Here is the call graph for this function:

Get the list of the "input" data flavors (mime types as nsISupportsCString), in otherwords, the flavors that this converter can convert "from" (the incoming data to the converter).

Get the list of the "output" data flavors (mime types as nsISupportsCString), in otherwords, the flavors that this converter can convert "to" (the outgoing data to the converter).

Parameters:
aDataFlavorListfills list with supported flavors

The documentation for this class was generated from the following files: