Akkana set up a service for encoding a document.
This checkin adds the implementations for encoding HTML and plain text: nsTextEncoder::EncodeToString(..) nsHTMLEncoder::EncodeToStream(..) Hooked these services into the nsHTMLEditor implemenation We probably want to update the clipboard code to use the same pattern as in nsHTMLEditor.cpp git-svn-id: svn://10.0.0.236/trunk@34518 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -27,6 +27,7 @@ class nsIDocument;
|
||||
class nsIDOMSelection;
|
||||
class nsIOutputStream;
|
||||
class nsISupportsArray;
|
||||
class nsIPresShell;
|
||||
|
||||
#define NS_IDOCUMENT_ENCODER_IID \
|
||||
{ /* a6cf9103-15b3-11d2-932e-00805f8add32 */ \
|
||||
@@ -44,6 +45,15 @@ class nsISupportsArray;
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} \
|
||||
}
|
||||
|
||||
#define NS_TEXT_ENCODER_CID \
|
||||
{ /* e7ba1480-1dea-11d3-830f-00104bed045e */ \
|
||||
0xe7ba1480, \
|
||||
0x1dea, \
|
||||
0x11d3, \
|
||||
{0x83, 0x0f, 0x00, 0x10, 0x4b, 0xed, 0x04, 0x5e} \
|
||||
}
|
||||
|
||||
|
||||
class nsIDocumentEncoder : public nsISupports
|
||||
{
|
||||
public:
|
||||
@@ -54,7 +64,7 @@ public:
|
||||
* Initialize with a pointer to the document and the mime type.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDocument* aDocument, nsString& aMimeType) = 0;
|
||||
NS_IMETHOD Init(nsIPresShell* aPresShell, nsIDocument* aDocument, nsString& aMimeType) = 0;
|
||||
|
||||
/**
|
||||
* If the selection is set to a non-null value, then the
|
||||
@@ -92,7 +102,7 @@ public:
|
||||
class nsIHTMLEncoder : public nsIDocumentEncoder
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOCUMENT_ENCODER_IID; return iid; }
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_HTML_ENCODER_CID; return iid; }
|
||||
|
||||
// Get embedded objects -- images, links, etc.
|
||||
// NOTE: we may want to use an enumerator
|
||||
@@ -102,5 +112,19 @@ public:
|
||||
NS_IMETHOD PrettyPrint(PRBool aYes) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Example of a output service for a particular encoder
|
||||
class nsITextEncoder : public nsIDocumentEncoder
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_TEXT_ENCODER_CID; return iid; }
|
||||
|
||||
// Get embedded objects -- images, links, etc.
|
||||
// NOTE: we may want to use an enumerator
|
||||
NS_IMETHOD PrettyPrint(PRBool aYes) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIDocumentEncoder_h__ */
|
||||
|
||||
|
||||
@@ -24,12 +24,20 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsXIFDTD.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsHTMLContentSinkStream.h"
|
||||
#include "nsHTMLToTxtSinkStream.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
|
||||
static NS_DEFINE_CID(kCHTMLEncoderCID, NS_HTML_ENCODER_CID);
|
||||
static NS_DEFINE_CID(kCTextEncoderCID, NS_TEXT_ENCODER_CID);
|
||||
|
||||
class nsHTMLEncoder : public nsIHTMLEncoder
|
||||
{
|
||||
@@ -39,7 +47,7 @@ public:
|
||||
nsHTMLEncoder();
|
||||
virtual ~nsHTMLEncoder();
|
||||
|
||||
NS_IMETHOD Init(nsIDocument* aDocument, nsString& aMimeType);
|
||||
NS_IMETHOD Init(nsIPresShell* aPresShell, nsIDocument* aDocument, nsString& aMimeType);
|
||||
|
||||
/* Interfaces for addref and release and queryinterface */
|
||||
NS_DECL_ISUPPORTS
|
||||
@@ -58,31 +66,51 @@ public:
|
||||
NS_IMETHOD PrettyPrint(PRBool aYesNO);
|
||||
|
||||
private:
|
||||
nsIDocument* mDocument;
|
||||
nsString mMimeType;
|
||||
nsIDocument* mDocument;
|
||||
nsIDOMSelection* mSelection;
|
||||
nsIPresShell* mPresShell;
|
||||
nsString mMimeType;
|
||||
nsString mCharset;
|
||||
};
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLEncoder)
|
||||
NS_IMPL_RELEASE(nsHTMLEncoder)
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLEncoder)
|
||||
// NS_IMPL_RELEASE(nsHTMLEncoder)
|
||||
NS_IMETHODIMP_(nsrefcnt) nsHTMLEncoder::Release(void)
|
||||
{
|
||||
NS_PRECONDITION(0 != mRefCnt, "dup release");
|
||||
if (--mRefCnt == 0) {
|
||||
NS_DELETEXPCOM(this);
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
nsHTMLEncoder::nsHTMLEncoder() : mMimeType("text/html")
|
||||
{
|
||||
mDocument = 0;
|
||||
mSelection = 0;
|
||||
mPresShell = 0;
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsHTMLEncoder::~nsHTMLEncoder()
|
||||
{
|
||||
NS_IF_RELEASE(mDocument);
|
||||
NS_IF_RELEASE(mDocument);
|
||||
NS_IF_RELEASE(mSelection);
|
||||
NS_IF_RELEASE(mPresShell);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::Init(nsIDocument* aDocument, nsString& aMimeType)
|
||||
nsHTMLEncoder::Init(nsIPresShell* aPresShell, nsIDocument* aDocument, nsString& aMimeType)
|
||||
{
|
||||
if (!aDocument)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
mDocument = aDocument;
|
||||
NS_ADDREF(mDocument);
|
||||
mPresShell = aPresShell;
|
||||
NS_ADDREF(aPresShell);
|
||||
mMimeType = aMimeType;
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -112,43 +140,131 @@ nsresult nsHTMLEncoder::QueryInterface(REFNSIID aIID,
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::SetSelection(nsIDOMSelection* aSelection)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
mSelection = aSelection;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::SetCharset(const nsString& aCharset)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
mCharset = aCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::EncodeToString(nsString& aOutputString)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mPresShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
// xxx Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
|
||||
if (mPresShell) {
|
||||
if (mDocument) {
|
||||
nsString buffer;
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
mDocument->CreateXIF(buffer,mSelection);
|
||||
nsIParser* parser;
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&parser);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
nsIHTMLContentSink* sink = nsnull;
|
||||
|
||||
rv = NS_New_HTML_ContentSinkStream(&sink,&aOutputString);
|
||||
|
||||
if (sink && NS_SUCCEEDED(rv)) {
|
||||
|
||||
if (NS_OK == rv) {
|
||||
parser->SetContentSink(sink);
|
||||
|
||||
nsIDTD* dtd = nsnull;
|
||||
rv = NS_NewXIFDTD(&dtd);
|
||||
if (NS_OK == rv) {
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->Parse(buffer, 0, "text/xif",PR_FALSE,PR_TRUE);
|
||||
}
|
||||
NS_IF_RELEASE(dtd);
|
||||
NS_IF_RELEASE(sink);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(parser);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::EncodeToStream(nsIOutputStream* aStream)
|
||||
{
|
||||
#if 0
|
||||
nsString str;
|
||||
nsresult rv = Encode(str);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsresult rv;
|
||||
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mPresShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// xxx Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
|
||||
if (mPresShell) {
|
||||
if (mDocument) {
|
||||
nsString buffer;
|
||||
|
||||
mDocument->CreateXIF(buffer,mSelection);
|
||||
|
||||
nsString* charset = nsnull;
|
||||
nsAutoString defaultCharset("ISO-8859-1");
|
||||
if (!mCharset.Equals("null") && !mCharset.Equals(""))
|
||||
charset = &mCharset;
|
||||
|
||||
nsIParser* parser;
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&parser);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
nsIHTMLContentSink* sink = nsnull;
|
||||
|
||||
rv = NS_New_HTML_ContentSinkStream(&sink,aStream,charset);
|
||||
|
||||
if (sink && NS_SUCCEEDED(rv)) {
|
||||
|
||||
if (NS_OK == rv) {
|
||||
parser->SetContentSink(sink);
|
||||
|
||||
nsIDTD* dtd = nsnull;
|
||||
rv = NS_NewXIFDTD(&dtd);
|
||||
if (NS_OK == rv) {
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->Parse(buffer, 0, "text/xif",PR_FALSE,PR_TRUE);
|
||||
}
|
||||
NS_IF_RELEASE(dtd);
|
||||
NS_IF_RELEASE(sink);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(parser);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
||||
|
||||
PRUint32 len = str.Length();
|
||||
// Doesn't work -- how do we get a stream to take input from an nsString?
|
||||
// nsIOutputStream is expecting ascii, I assume,
|
||||
// while nsString's buffer is likely (but not definitely) unicode.
|
||||
return aStream->Write(str, len, &len);
|
||||
#else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -168,16 +284,254 @@ nsHTMLEncoder::PrettyPrint(PRBool aYes)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLEncoder(nsIDocumentEncoder** aResult)
|
||||
{
|
||||
*aResult = new nsHTMLEncoder;
|
||||
if (!*aResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
class nsTextEncoder : public nsITextEncoder
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOCUMENT_ENCODER_IID; return iid; }
|
||||
|
||||
nsTextEncoder();
|
||||
virtual ~nsTextEncoder();
|
||||
|
||||
NS_IMETHOD Init(nsIPresShell* aPresShell, nsIDocument* aDocument, nsString& aMimeType);
|
||||
|
||||
/* Interfaces for addref and release and queryinterface */
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// Inherited methods from nsIDocument
|
||||
NS_IMETHOD SetSelection(nsIDOMSelection* aSelection);
|
||||
NS_IMETHOD SetCharset(const nsString& aCharset);
|
||||
NS_IMETHOD EncodeToStream(nsIOutputStream* aStream);
|
||||
NS_IMETHOD EncodeToString(nsString& aOutputString);
|
||||
|
||||
NS_IMETHOD PrettyPrint(PRBool aYesNO);
|
||||
|
||||
private:
|
||||
nsIDocument* mDocument;
|
||||
nsIDOMSelection* mSelection;
|
||||
nsIPresShell* mPresShell;
|
||||
nsString mMimeType;
|
||||
nsString mCharset;
|
||||
};
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsTextEncoder)
|
||||
NS_IMPL_RELEASE(nsTextEncoder)
|
||||
|
||||
nsTextEncoder::nsTextEncoder() : mMimeType("text/plain")
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mDocument = 0;
|
||||
mSelection = 0;
|
||||
}
|
||||
|
||||
nsTextEncoder::~nsTextEncoder()
|
||||
{
|
||||
NS_IF_RELEASE(mDocument);
|
||||
NS_IF_RELEASE(mSelection);
|
||||
NS_IF_RELEASE(mPresShell);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::Init(nsIPresShell* aPresShell, nsIDocument* aDocument, nsString& aMimeType)
|
||||
{
|
||||
if (!aDocument)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (!aPresShell)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
mDocument = aDocument;
|
||||
NS_ADDREF(mDocument);
|
||||
mPresShell = aPresShell;
|
||||
NS_ADDREF(aPresShell);
|
||||
mMimeType = aMimeType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsTextEncoder::QueryInterface(REFNSIID aIID,
|
||||
void **aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aInstancePtr = 0;
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void *)(nsISupports*)this;
|
||||
} else if (aIID.Equals(nsIDocumentEncoder::GetIID())) {
|
||||
*aInstancePtr = (void *)(nsIDocumentEncoder*)this;
|
||||
}
|
||||
|
||||
if (nsnull == *aInstancePtr)
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::SetSelection(nsIDOMSelection* aSelection)
|
||||
{
|
||||
mSelection = aSelection;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::SetCharset(const nsString& aCharset)
|
||||
{
|
||||
mCharset = aCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::EncodeToString(nsString& aOutputString)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mPresShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// xxx Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
|
||||
if (mPresShell) {
|
||||
if (mDocument) {
|
||||
nsString buffer;
|
||||
|
||||
mDocument->CreateXIF(buffer,mSelection);
|
||||
nsIParser* parser;
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&parser);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
nsIHTMLContentSink* sink = nsnull;
|
||||
|
||||
rv = NS_New_HTMLToTXT_SinkStream(&sink,&aOutputString);
|
||||
|
||||
if (sink && NS_SUCCEEDED(rv)) {
|
||||
|
||||
if (NS_OK == rv) {
|
||||
parser->SetContentSink(sink);
|
||||
|
||||
nsIDTD* dtd = nsnull;
|
||||
rv = NS_NewXIFDTD(&dtd);
|
||||
if (NS_OK == rv) {
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->Parse(buffer, 0, "text/xif",PR_FALSE,PR_TRUE);
|
||||
}
|
||||
NS_IF_RELEASE(dtd);
|
||||
NS_IF_RELEASE(sink);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(parser);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::EncodeToStream(nsIOutputStream* aStream)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mPresShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// xxx Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
|
||||
if (mPresShell) {
|
||||
if (mDocument) {
|
||||
nsString buffer;
|
||||
|
||||
mDocument->CreateXIF(buffer,mSelection);
|
||||
|
||||
nsString* charset = nsnull;
|
||||
nsAutoString defaultCharset("ISO-8859-1");
|
||||
if (!mCharset.Equals("null") && !mCharset.Equals(""))
|
||||
charset = &mCharset;
|
||||
|
||||
nsIParser* parser;
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&parser);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
nsIHTMLContentSink* sink = nsnull;
|
||||
|
||||
rv = NS_New_HTMLToTXT_SinkStream(&sink,aStream,charset);
|
||||
|
||||
if (sink && NS_SUCCEEDED(rv)) {
|
||||
|
||||
if (NS_OK == rv) {
|
||||
parser->SetContentSink(sink);
|
||||
|
||||
nsIDTD* dtd = nsnull;
|
||||
rv = NS_NewXIFDTD(&dtd);
|
||||
if (NS_OK == rv) {
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->Parse(buffer, 0, "text/xif",PR_FALSE,PR_TRUE);
|
||||
}
|
||||
NS_IF_RELEASE(dtd);
|
||||
NS_IF_RELEASE(sink);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(parser);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::PrettyPrint(PRBool aYes)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewTextEncoder(nsIDocumentEncoder** aResult)
|
||||
{
|
||||
*aResult = new nsTextEncoder;
|
||||
if (!*aResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class nsDocumentEncoderFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
@@ -239,6 +593,8 @@ nsDocumentEncoderFactory::CreateInstance(nsISupports *aOuter,
|
||||
|
||||
if (aIID.Equals(kCHTMLEncoderCID))
|
||||
*aResult = new nsHTMLEncoder;
|
||||
else if (aIID.Equals(kCTextEncoderCID))
|
||||
*aResult = new nsTextEncoder;
|
||||
else
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "nsIFileWidget.h" // for GetLocalFileURL stuff
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
|
||||
#include "nsIPresShell.h"
|
||||
|
||||
static NS_DEFINE_IID(kInsertHTMLTxnIID, NS_INSERT_HTML_TXN_IID);
|
||||
|
||||
@@ -56,6 +56,7 @@ static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
|
||||
static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID);
|
||||
static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID);
|
||||
static NS_DEFINE_CID(kHTMLEncoderCID, NS_HTML_ENCODER_CID);
|
||||
static NS_DEFINE_CID(kTextEncoderCID, NS_TEXT_ENCODER_CID);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
static PRBool gNoisy = PR_FALSE;
|
||||
@@ -63,11 +64,13 @@ static PRBool gNoisy = PR_FALSE;
|
||||
static const PRBool gNoisy = PR_FALSE;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
nsHTMLEditor::nsHTMLEditor()
|
||||
{
|
||||
// Done in nsEditor
|
||||
// NS_INIT_REFCNT();
|
||||
}
|
||||
}
|
||||
|
||||
nsHTMLEditor::~nsHTMLEditor()
|
||||
{
|
||||
@@ -513,12 +516,97 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString)
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::OutputTextToString(nsString& aOutputString)
|
||||
{
|
||||
return nsTextEditor::OutputTextToString(aOutputString);
|
||||
nsCOMPtr<nsITextEncoder> encoder;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kTextEncoderCID,
|
||||
nsnull,
|
||||
nsIDocumentEncoder::GetIID(),
|
||||
getter_AddRefs(encoder));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
rv = GetDocument(getter_AddRefs(domdoc));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
|
||||
nsString mimetype ("text/plain");
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
||||
rv = GetPresShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = encoder->Init(shell,doc, mimetype);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
return encoder->EncodeToString(aOutputString);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::OutputHTMLToString(nsString& aOutputString)
|
||||
{
|
||||
#if defined(DEBUG_kostello) || defined(DEBUG_akkana)
|
||||
nsCOMPtr<nsIHTMLEncoder> encoder;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kHTMLEncoderCID,
|
||||
nsnull,
|
||||
nsIDocumentEncoder::GetIID(),
|
||||
getter_AddRefs(encoder));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
rv = GetDocument(getter_AddRefs(domdoc));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
|
||||
nsString mimetype ("text/html");
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
||||
rv = GetPresShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = encoder->Init(shell,doc, mimetype);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
return encoder->EncodeToString(aOutputString);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::OutputTextToStream(nsIOutputStream* aOutputStream, nsString* aCharset)
|
||||
{
|
||||
nsCOMPtr<nsITextEncoder> encoder;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kTextEncoderCID,
|
||||
nsnull,
|
||||
nsIDocumentEncoder::GetIID(),
|
||||
getter_AddRefs(encoder));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
rv = GetDocument(getter_AddRefs(domdoc));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
|
||||
nsString mimetype ("text/plain");
|
||||
|
||||
if (aCharset && aCharset->Length() != 0 && aCharset->Equals("null")==PR_FALSE)
|
||||
encoder->SetCharset(*aCharset);
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
||||
rv = GetPresShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = encoder->Init(shell,doc, mimetype);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
return encoder->EncodeToStream(aOutputStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::OutputHTMLToStream(nsIOutputStream* aOutputStream,nsString* aCharset)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEncoder> encoder;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kHTMLEncoderCID,
|
||||
nsnull,
|
||||
@@ -534,24 +622,19 @@ NS_IMETHODIMP nsHTMLEditor::OutputHTMLToString(nsString& aOutputString)
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
|
||||
nsString mimetype ("text/html");
|
||||
|
||||
rv = encoder->Init(doc, mimetype);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
||||
return encoder->EncodeToString(aOutputString);
|
||||
#else
|
||||
return nsTextEditor::OutputHTMLToString(aOutputString);
|
||||
#endif
|
||||
}
|
||||
if (aCharset && aCharset->Length() != 0 && aCharset->Equals("null")==PR_FALSE)
|
||||
encoder->SetCharset(*aCharset);
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::OutputTextToStream(nsIOutputStream* aOutputStream, nsString* aCharsetOverride)
|
||||
{
|
||||
return nsTextEditor::OutputTextToStream(aOutputStream,aCharsetOverride);
|
||||
}
|
||||
rv = GetPresShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = encoder->Init(shell,doc, mimetype);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::OutputHTMLToStream(nsIOutputStream* aOutputStream,nsString* aCharsetOverride)
|
||||
{
|
||||
return nsTextEditor::OutputHTMLToStream(aOutputStream,aCharsetOverride);
|
||||
return encoder->EncodeToStream(aOutputStream);
|
||||
}
|
||||
|
||||
|
||||
@@ -1809,13 +1892,13 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
|
||||
|
||||
if (aTagName == "" || !aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
|
||||
nsAutoString TagName = aTagName;
|
||||
TagName.ToLowerCase();
|
||||
nsAutoString realTagName;
|
||||
|
||||
PRBool isHREF = (TagName.Equals("href"));
|
||||
PRBool isAnchor = (TagName.Equals("anchor"));
|
||||
PRBool isHREF = (TagName == "href");
|
||||
PRBool isAnchor = (TagName == "anchor");
|
||||
if (isHREF || isAnchor)
|
||||
{
|
||||
realTagName = "a";
|
||||
@@ -1836,20 +1919,16 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
|
||||
// ATTRIBUTES SAVED IN PREFS?
|
||||
if (isAnchor)
|
||||
{
|
||||
|
||||
// TODO: Get the text of the selection and build a suggested Name
|
||||
// Replace spaces with "_"
|
||||
} else if (TagName.Equals("hr"))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ADD OTHER DEFAULT ATTRIBUTES HERE
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
*aReturn = newElement;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1880,12 +1959,15 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection, ns
|
||||
}
|
||||
}
|
||||
|
||||
res = DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode);
|
||||
DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode);
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> newNode = do_QueryInterface(aElement);
|
||||
|
||||
res = InsertNode(aElement, parentSelectedNode, offsetOfNewNode);
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -2165,19 +2247,8 @@ NS_IMETHODIMP nsHTMLEditor::GetLocalFileURL(nsIDOMWindow* aParent, const nsStrin
|
||||
|
||||
|
||||
nsCOMPtr<nsIFileWidget> fileWidget;
|
||||
nsAutoString title("");
|
||||
|
||||
// Get strings from editor resource bundle
|
||||
nsString name;
|
||||
if (htmlFilter)
|
||||
{
|
||||
name = "OpenHTMLFile";
|
||||
} else if (imgFilter)
|
||||
{
|
||||
name = "SelectImageFile";
|
||||
}
|
||||
GetString(name, title);
|
||||
|
||||
// TODO: WHERE TO WE PUT GLOBAL STRINGS TO BE LOCALIZED?
|
||||
nsString title(htmlFilter ? "Open HTML file" : "Select Image File");
|
||||
nsFileSpec fileSpec;
|
||||
// TODO: GET THE DEFAULT DIRECTORY FOR DIFFERENT TYPES FROM PREFERENCES
|
||||
nsFileSpec aDisplayDirectory;
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "nsIFileWidget.h" // for GetLocalFileURL stuff
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
|
||||
#include "nsIPresShell.h"
|
||||
|
||||
static NS_DEFINE_IID(kInsertHTMLTxnIID, NS_INSERT_HTML_TXN_IID);
|
||||
|
||||
@@ -56,6 +56,7 @@ static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
|
||||
static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID);
|
||||
static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID);
|
||||
static NS_DEFINE_CID(kHTMLEncoderCID, NS_HTML_ENCODER_CID);
|
||||
static NS_DEFINE_CID(kTextEncoderCID, NS_TEXT_ENCODER_CID);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
static PRBool gNoisy = PR_FALSE;
|
||||
@@ -63,11 +64,13 @@ static PRBool gNoisy = PR_FALSE;
|
||||
static const PRBool gNoisy = PR_FALSE;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
nsHTMLEditor::nsHTMLEditor()
|
||||
{
|
||||
// Done in nsEditor
|
||||
// NS_INIT_REFCNT();
|
||||
}
|
||||
}
|
||||
|
||||
nsHTMLEditor::~nsHTMLEditor()
|
||||
{
|
||||
@@ -513,12 +516,97 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString)
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::OutputTextToString(nsString& aOutputString)
|
||||
{
|
||||
return nsTextEditor::OutputTextToString(aOutputString);
|
||||
nsCOMPtr<nsITextEncoder> encoder;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kTextEncoderCID,
|
||||
nsnull,
|
||||
nsIDocumentEncoder::GetIID(),
|
||||
getter_AddRefs(encoder));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
rv = GetDocument(getter_AddRefs(domdoc));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
|
||||
nsString mimetype ("text/plain");
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
||||
rv = GetPresShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = encoder->Init(shell,doc, mimetype);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
return encoder->EncodeToString(aOutputString);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::OutputHTMLToString(nsString& aOutputString)
|
||||
{
|
||||
#if defined(DEBUG_kostello) || defined(DEBUG_akkana)
|
||||
nsCOMPtr<nsIHTMLEncoder> encoder;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kHTMLEncoderCID,
|
||||
nsnull,
|
||||
nsIDocumentEncoder::GetIID(),
|
||||
getter_AddRefs(encoder));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
rv = GetDocument(getter_AddRefs(domdoc));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
|
||||
nsString mimetype ("text/html");
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
||||
rv = GetPresShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = encoder->Init(shell,doc, mimetype);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
return encoder->EncodeToString(aOutputString);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::OutputTextToStream(nsIOutputStream* aOutputStream, nsString* aCharset)
|
||||
{
|
||||
nsCOMPtr<nsITextEncoder> encoder;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kTextEncoderCID,
|
||||
nsnull,
|
||||
nsIDocumentEncoder::GetIID(),
|
||||
getter_AddRefs(encoder));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
rv = GetDocument(getter_AddRefs(domdoc));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
|
||||
nsString mimetype ("text/plain");
|
||||
|
||||
if (aCharset && aCharset->Length() != 0 && aCharset->Equals("null")==PR_FALSE)
|
||||
encoder->SetCharset(*aCharset);
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
||||
rv = GetPresShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = encoder->Init(shell,doc, mimetype);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
return encoder->EncodeToStream(aOutputStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::OutputHTMLToStream(nsIOutputStream* aOutputStream,nsString* aCharset)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEncoder> encoder;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kHTMLEncoderCID,
|
||||
nsnull,
|
||||
@@ -534,24 +622,19 @@ NS_IMETHODIMP nsHTMLEditor::OutputHTMLToString(nsString& aOutputString)
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
|
||||
nsString mimetype ("text/html");
|
||||
|
||||
rv = encoder->Init(doc, mimetype);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
||||
return encoder->EncodeToString(aOutputString);
|
||||
#else
|
||||
return nsTextEditor::OutputHTMLToString(aOutputString);
|
||||
#endif
|
||||
}
|
||||
if (aCharset && aCharset->Length() != 0 && aCharset->Equals("null")==PR_FALSE)
|
||||
encoder->SetCharset(*aCharset);
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::OutputTextToStream(nsIOutputStream* aOutputStream, nsString* aCharsetOverride)
|
||||
{
|
||||
return nsTextEditor::OutputTextToStream(aOutputStream,aCharsetOverride);
|
||||
}
|
||||
rv = GetPresShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = encoder->Init(shell,doc, mimetype);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::OutputHTMLToStream(nsIOutputStream* aOutputStream,nsString* aCharsetOverride)
|
||||
{
|
||||
return nsTextEditor::OutputHTMLToStream(aOutputStream,aCharsetOverride);
|
||||
return encoder->EncodeToStream(aOutputStream);
|
||||
}
|
||||
|
||||
|
||||
@@ -1809,13 +1892,13 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
|
||||
|
||||
if (aTagName == "" || !aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
|
||||
nsAutoString TagName = aTagName;
|
||||
TagName.ToLowerCase();
|
||||
nsAutoString realTagName;
|
||||
|
||||
PRBool isHREF = (TagName.Equals("href"));
|
||||
PRBool isAnchor = (TagName.Equals("anchor"));
|
||||
PRBool isHREF = (TagName == "href");
|
||||
PRBool isAnchor = (TagName == "anchor");
|
||||
if (isHREF || isAnchor)
|
||||
{
|
||||
realTagName = "a";
|
||||
@@ -1836,20 +1919,16 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
|
||||
// ATTRIBUTES SAVED IN PREFS?
|
||||
if (isAnchor)
|
||||
{
|
||||
|
||||
// TODO: Get the text of the selection and build a suggested Name
|
||||
// Replace spaces with "_"
|
||||
} else if (TagName.Equals("hr"))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ADD OTHER DEFAULT ATTRIBUTES HERE
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
*aReturn = newElement;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1880,12 +1959,15 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection, ns
|
||||
}
|
||||
}
|
||||
|
||||
res = DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode);
|
||||
DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode);
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> newNode = do_QueryInterface(aElement);
|
||||
|
||||
res = InsertNode(aElement, parentSelectedNode, offsetOfNewNode);
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -2165,19 +2247,8 @@ NS_IMETHODIMP nsHTMLEditor::GetLocalFileURL(nsIDOMWindow* aParent, const nsStrin
|
||||
|
||||
|
||||
nsCOMPtr<nsIFileWidget> fileWidget;
|
||||
nsAutoString title("");
|
||||
|
||||
// Get strings from editor resource bundle
|
||||
nsString name;
|
||||
if (htmlFilter)
|
||||
{
|
||||
name = "OpenHTMLFile";
|
||||
} else if (imgFilter)
|
||||
{
|
||||
name = "SelectImageFile";
|
||||
}
|
||||
GetString(name, title);
|
||||
|
||||
// TODO: WHERE TO WE PUT GLOBAL STRINGS TO BE LOCALIZED?
|
||||
nsString title(htmlFilter ? "Open HTML file" : "Select Image File");
|
||||
nsFileSpec fileSpec;
|
||||
// TODO: GET THE DEFAULT DIRECTORY FOR DIFFERENT TYPES FROM PREFERENCES
|
||||
nsFileSpec aDisplayDirectory;
|
||||
|
||||
@@ -27,6 +27,7 @@ class nsIDocument;
|
||||
class nsIDOMSelection;
|
||||
class nsIOutputStream;
|
||||
class nsISupportsArray;
|
||||
class nsIPresShell;
|
||||
|
||||
#define NS_IDOCUMENT_ENCODER_IID \
|
||||
{ /* a6cf9103-15b3-11d2-932e-00805f8add32 */ \
|
||||
@@ -44,6 +45,15 @@ class nsISupportsArray;
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} \
|
||||
}
|
||||
|
||||
#define NS_TEXT_ENCODER_CID \
|
||||
{ /* e7ba1480-1dea-11d3-830f-00104bed045e */ \
|
||||
0xe7ba1480, \
|
||||
0x1dea, \
|
||||
0x11d3, \
|
||||
{0x83, 0x0f, 0x00, 0x10, 0x4b, 0xed, 0x04, 0x5e} \
|
||||
}
|
||||
|
||||
|
||||
class nsIDocumentEncoder : public nsISupports
|
||||
{
|
||||
public:
|
||||
@@ -54,7 +64,7 @@ public:
|
||||
* Initialize with a pointer to the document and the mime type.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDocument* aDocument, nsString& aMimeType) = 0;
|
||||
NS_IMETHOD Init(nsIPresShell* aPresShell, nsIDocument* aDocument, nsString& aMimeType) = 0;
|
||||
|
||||
/**
|
||||
* If the selection is set to a non-null value, then the
|
||||
@@ -92,7 +102,7 @@ public:
|
||||
class nsIHTMLEncoder : public nsIDocumentEncoder
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOCUMENT_ENCODER_IID; return iid; }
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_HTML_ENCODER_CID; return iid; }
|
||||
|
||||
// Get embedded objects -- images, links, etc.
|
||||
// NOTE: we may want to use an enumerator
|
||||
@@ -102,5 +112,19 @@ public:
|
||||
NS_IMETHOD PrettyPrint(PRBool aYes) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Example of a output service for a particular encoder
|
||||
class nsITextEncoder : public nsIDocumentEncoder
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_TEXT_ENCODER_CID; return iid; }
|
||||
|
||||
// Get embedded objects -- images, links, etc.
|
||||
// NOTE: we may want to use an enumerator
|
||||
NS_IMETHOD PrettyPrint(PRBool aYes) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIDocumentEncoder_h__ */
|
||||
|
||||
|
||||
@@ -24,12 +24,20 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsXIFDTD.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsHTMLContentSinkStream.h"
|
||||
#include "nsHTMLToTxtSinkStream.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
|
||||
static NS_DEFINE_CID(kCHTMLEncoderCID, NS_HTML_ENCODER_CID);
|
||||
static NS_DEFINE_CID(kCTextEncoderCID, NS_TEXT_ENCODER_CID);
|
||||
|
||||
class nsHTMLEncoder : public nsIHTMLEncoder
|
||||
{
|
||||
@@ -39,7 +47,7 @@ public:
|
||||
nsHTMLEncoder();
|
||||
virtual ~nsHTMLEncoder();
|
||||
|
||||
NS_IMETHOD Init(nsIDocument* aDocument, nsString& aMimeType);
|
||||
NS_IMETHOD Init(nsIPresShell* aPresShell, nsIDocument* aDocument, nsString& aMimeType);
|
||||
|
||||
/* Interfaces for addref and release and queryinterface */
|
||||
NS_DECL_ISUPPORTS
|
||||
@@ -58,31 +66,51 @@ public:
|
||||
NS_IMETHOD PrettyPrint(PRBool aYesNO);
|
||||
|
||||
private:
|
||||
nsIDocument* mDocument;
|
||||
nsString mMimeType;
|
||||
nsIDocument* mDocument;
|
||||
nsIDOMSelection* mSelection;
|
||||
nsIPresShell* mPresShell;
|
||||
nsString mMimeType;
|
||||
nsString mCharset;
|
||||
};
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLEncoder)
|
||||
NS_IMPL_RELEASE(nsHTMLEncoder)
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLEncoder)
|
||||
// NS_IMPL_RELEASE(nsHTMLEncoder)
|
||||
NS_IMETHODIMP_(nsrefcnt) nsHTMLEncoder::Release(void)
|
||||
{
|
||||
NS_PRECONDITION(0 != mRefCnt, "dup release");
|
||||
if (--mRefCnt == 0) {
|
||||
NS_DELETEXPCOM(this);
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
nsHTMLEncoder::nsHTMLEncoder() : mMimeType("text/html")
|
||||
{
|
||||
mDocument = 0;
|
||||
mSelection = 0;
|
||||
mPresShell = 0;
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsHTMLEncoder::~nsHTMLEncoder()
|
||||
{
|
||||
NS_IF_RELEASE(mDocument);
|
||||
NS_IF_RELEASE(mDocument);
|
||||
NS_IF_RELEASE(mSelection);
|
||||
NS_IF_RELEASE(mPresShell);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::Init(nsIDocument* aDocument, nsString& aMimeType)
|
||||
nsHTMLEncoder::Init(nsIPresShell* aPresShell, nsIDocument* aDocument, nsString& aMimeType)
|
||||
{
|
||||
if (!aDocument)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
mDocument = aDocument;
|
||||
NS_ADDREF(mDocument);
|
||||
mPresShell = aPresShell;
|
||||
NS_ADDREF(aPresShell);
|
||||
mMimeType = aMimeType;
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -112,43 +140,131 @@ nsresult nsHTMLEncoder::QueryInterface(REFNSIID aIID,
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::SetSelection(nsIDOMSelection* aSelection)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
mSelection = aSelection;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::SetCharset(const nsString& aCharset)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
mCharset = aCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::EncodeToString(nsString& aOutputString)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mPresShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
// xxx Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
|
||||
if (mPresShell) {
|
||||
if (mDocument) {
|
||||
nsString buffer;
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
mDocument->CreateXIF(buffer,mSelection);
|
||||
nsIParser* parser;
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&parser);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
nsIHTMLContentSink* sink = nsnull;
|
||||
|
||||
rv = NS_New_HTML_ContentSinkStream(&sink,&aOutputString);
|
||||
|
||||
if (sink && NS_SUCCEEDED(rv)) {
|
||||
|
||||
if (NS_OK == rv) {
|
||||
parser->SetContentSink(sink);
|
||||
|
||||
nsIDTD* dtd = nsnull;
|
||||
rv = NS_NewXIFDTD(&dtd);
|
||||
if (NS_OK == rv) {
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->Parse(buffer, 0, "text/xif",PR_FALSE,PR_TRUE);
|
||||
}
|
||||
NS_IF_RELEASE(dtd);
|
||||
NS_IF_RELEASE(sink);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(parser);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::EncodeToStream(nsIOutputStream* aStream)
|
||||
{
|
||||
#if 0
|
||||
nsString str;
|
||||
nsresult rv = Encode(str);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsresult rv;
|
||||
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mPresShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// xxx Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
|
||||
if (mPresShell) {
|
||||
if (mDocument) {
|
||||
nsString buffer;
|
||||
|
||||
mDocument->CreateXIF(buffer,mSelection);
|
||||
|
||||
nsString* charset = nsnull;
|
||||
nsAutoString defaultCharset("ISO-8859-1");
|
||||
if (!mCharset.Equals("null") && !mCharset.Equals(""))
|
||||
charset = &mCharset;
|
||||
|
||||
nsIParser* parser;
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&parser);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
nsIHTMLContentSink* sink = nsnull;
|
||||
|
||||
rv = NS_New_HTML_ContentSinkStream(&sink,aStream,charset);
|
||||
|
||||
if (sink && NS_SUCCEEDED(rv)) {
|
||||
|
||||
if (NS_OK == rv) {
|
||||
parser->SetContentSink(sink);
|
||||
|
||||
nsIDTD* dtd = nsnull;
|
||||
rv = NS_NewXIFDTD(&dtd);
|
||||
if (NS_OK == rv) {
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->Parse(buffer, 0, "text/xif",PR_FALSE,PR_TRUE);
|
||||
}
|
||||
NS_IF_RELEASE(dtd);
|
||||
NS_IF_RELEASE(sink);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(parser);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
||||
|
||||
PRUint32 len = str.Length();
|
||||
// Doesn't work -- how do we get a stream to take input from an nsString?
|
||||
// nsIOutputStream is expecting ascii, I assume,
|
||||
// while nsString's buffer is likely (but not definitely) unicode.
|
||||
return aStream->Write(str, len, &len);
|
||||
#else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -168,16 +284,254 @@ nsHTMLEncoder::PrettyPrint(PRBool aYes)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLEncoder(nsIDocumentEncoder** aResult)
|
||||
{
|
||||
*aResult = new nsHTMLEncoder;
|
||||
if (!*aResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
class nsTextEncoder : public nsITextEncoder
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOCUMENT_ENCODER_IID; return iid; }
|
||||
|
||||
nsTextEncoder();
|
||||
virtual ~nsTextEncoder();
|
||||
|
||||
NS_IMETHOD Init(nsIPresShell* aPresShell, nsIDocument* aDocument, nsString& aMimeType);
|
||||
|
||||
/* Interfaces for addref and release and queryinterface */
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// Inherited methods from nsIDocument
|
||||
NS_IMETHOD SetSelection(nsIDOMSelection* aSelection);
|
||||
NS_IMETHOD SetCharset(const nsString& aCharset);
|
||||
NS_IMETHOD EncodeToStream(nsIOutputStream* aStream);
|
||||
NS_IMETHOD EncodeToString(nsString& aOutputString);
|
||||
|
||||
NS_IMETHOD PrettyPrint(PRBool aYesNO);
|
||||
|
||||
private:
|
||||
nsIDocument* mDocument;
|
||||
nsIDOMSelection* mSelection;
|
||||
nsIPresShell* mPresShell;
|
||||
nsString mMimeType;
|
||||
nsString mCharset;
|
||||
};
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsTextEncoder)
|
||||
NS_IMPL_RELEASE(nsTextEncoder)
|
||||
|
||||
nsTextEncoder::nsTextEncoder() : mMimeType("text/plain")
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mDocument = 0;
|
||||
mSelection = 0;
|
||||
}
|
||||
|
||||
nsTextEncoder::~nsTextEncoder()
|
||||
{
|
||||
NS_IF_RELEASE(mDocument);
|
||||
NS_IF_RELEASE(mSelection);
|
||||
NS_IF_RELEASE(mPresShell);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::Init(nsIPresShell* aPresShell, nsIDocument* aDocument, nsString& aMimeType)
|
||||
{
|
||||
if (!aDocument)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (!aPresShell)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
mDocument = aDocument;
|
||||
NS_ADDREF(mDocument);
|
||||
mPresShell = aPresShell;
|
||||
NS_ADDREF(aPresShell);
|
||||
mMimeType = aMimeType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsTextEncoder::QueryInterface(REFNSIID aIID,
|
||||
void **aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aInstancePtr = 0;
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void *)(nsISupports*)this;
|
||||
} else if (aIID.Equals(nsIDocumentEncoder::GetIID())) {
|
||||
*aInstancePtr = (void *)(nsIDocumentEncoder*)this;
|
||||
}
|
||||
|
||||
if (nsnull == *aInstancePtr)
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::SetSelection(nsIDOMSelection* aSelection)
|
||||
{
|
||||
mSelection = aSelection;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::SetCharset(const nsString& aCharset)
|
||||
{
|
||||
mCharset = aCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::EncodeToString(nsString& aOutputString)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mPresShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// xxx Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
|
||||
if (mPresShell) {
|
||||
if (mDocument) {
|
||||
nsString buffer;
|
||||
|
||||
mDocument->CreateXIF(buffer,mSelection);
|
||||
nsIParser* parser;
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&parser);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
nsIHTMLContentSink* sink = nsnull;
|
||||
|
||||
rv = NS_New_HTMLToTXT_SinkStream(&sink,&aOutputString);
|
||||
|
||||
if (sink && NS_SUCCEEDED(rv)) {
|
||||
|
||||
if (NS_OK == rv) {
|
||||
parser->SetContentSink(sink);
|
||||
|
||||
nsIDTD* dtd = nsnull;
|
||||
rv = NS_NewXIFDTD(&dtd);
|
||||
if (NS_OK == rv) {
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->Parse(buffer, 0, "text/xif",PR_FALSE,PR_TRUE);
|
||||
}
|
||||
NS_IF_RELEASE(dtd);
|
||||
NS_IF_RELEASE(sink);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(parser);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::EncodeToStream(nsIOutputStream* aStream)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mPresShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// xxx Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
|
||||
if (mPresShell) {
|
||||
if (mDocument) {
|
||||
nsString buffer;
|
||||
|
||||
mDocument->CreateXIF(buffer,mSelection);
|
||||
|
||||
nsString* charset = nsnull;
|
||||
nsAutoString defaultCharset("ISO-8859-1");
|
||||
if (!mCharset.Equals("null") && !mCharset.Equals(""))
|
||||
charset = &mCharset;
|
||||
|
||||
nsIParser* parser;
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&parser);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
nsIHTMLContentSink* sink = nsnull;
|
||||
|
||||
rv = NS_New_HTMLToTXT_SinkStream(&sink,aStream,charset);
|
||||
|
||||
if (sink && NS_SUCCEEDED(rv)) {
|
||||
|
||||
if (NS_OK == rv) {
|
||||
parser->SetContentSink(sink);
|
||||
|
||||
nsIDTD* dtd = nsnull;
|
||||
rv = NS_NewXIFDTD(&dtd);
|
||||
if (NS_OK == rv) {
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->Parse(buffer, 0, "text/xif",PR_FALSE,PR_TRUE);
|
||||
}
|
||||
NS_IF_RELEASE(dtd);
|
||||
NS_IF_RELEASE(sink);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(parser);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEncoder::PrettyPrint(PRBool aYes)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewTextEncoder(nsIDocumentEncoder** aResult)
|
||||
{
|
||||
*aResult = new nsTextEncoder;
|
||||
if (!*aResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class nsDocumentEncoderFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
@@ -239,6 +593,8 @@ nsDocumentEncoderFactory::CreateInstance(nsISupports *aOuter,
|
||||
|
||||
if (aIID.Equals(kCHTMLEncoderCID))
|
||||
*aResult = new nsHTMLEncoder;
|
||||
else if (aIID.Equals(kCTextEncoderCID))
|
||||
*aResult = new nsTextEncoder;
|
||||
else
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ static NS_DEFINE_CID(kLayoutDocumentLoaderFactoryCID, NS_LAYOUT_DOCUMENT_LOADER_
|
||||
static NS_DEFINE_CID(kLayoutDebuggerCID, NS_LAYOUT_DEBUGGER_CID);
|
||||
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kHTMLEncoderCID, NS_HTML_ENCODER_CID);
|
||||
static NS_DEFINE_CID(kTextEncoderCID, NS_TEXT_ENCODER_CID);
|
||||
|
||||
extern nsresult NS_NewRangeList(nsIDOMSelection** aResult);
|
||||
extern nsresult NS_NewRange(nsIDOMRange** aResult);
|
||||
@@ -90,6 +91,7 @@ extern nsresult NS_NewLayoutDocumentLoaderFactory(nsIDocumentLoaderFactory** aRe
|
||||
extern nsresult NS_NewLayoutDebugger(nsILayoutDebugger** aResult);
|
||||
extern nsresult NS_NewHTMLElementFactory(nsIHTMLElementFactory** aResult);
|
||||
extern nsresult NS_NewHTMLEncoder(nsIDocumentEncoder** aResult);
|
||||
extern nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -386,6 +388,14 @@ nsLayoutFactory::CreateInstance(nsISupports *aOuter,
|
||||
}
|
||||
refCounted = PR_TRUE;
|
||||
}
|
||||
else if (mClassID.Equals(kTextEncoderCID)) {
|
||||
res = NS_NewTextEncoder((nsIDocumentEncoder**) &inst);
|
||||
if (NS_FAILED(res)) {
|
||||
LOG_NEW_FAILURE("NS_NewTextEncoder", res);
|
||||
return res;
|
||||
}
|
||||
refCounted = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
@@ -705,6 +715,13 @@ NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
|
||||
LOG_REGISTER_FAILURE("kHTMLEncoderCID", rv);
|
||||
break;
|
||||
}
|
||||
|
||||
rv = cm->RegisterComponent(kTextEncoderCID, NULL, NULL, aPath,
|
||||
PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
LOG_REGISTER_FAILURE("kTextEncoderCID", rv);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} while (PR_FALSE);
|
||||
|
||||
@@ -751,6 +768,7 @@ NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
|
||||
rv = cm->UnregisterComponent(kFrameUtilCID, aPath);
|
||||
rv = cm->UnregisterComponent(kLayoutDebuggerCID, aPath);
|
||||
rv = cm->UnregisterComponent(kHTMLEncoderCID, aPath);
|
||||
rv = cm->UnregisterComponent(kTextEncoderCID, aPath);
|
||||
|
||||
// XXX why the heck are these exported???? bad bad bad bad
|
||||
#if 1
|
||||
|
||||
Reference in New Issue
Block a user