зеркало из https://github.com/mozilla/gecko-dev.git
Add Init method to pass in the document and mime type
This commit is contained in:
Родитель
16d8890834
Коммит
2b9b55f748
|
@ -50,20 +50,11 @@ public:
|
|||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOCUMENT_ENCODER_IID; return iid; }
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Creates a stream representation of aDocument.
|
||||
* Uses the MIMEType to choose an encoding.
|
||||
*
|
||||
* aDocument must point to a valid, non-null nsIDocument object.
|
||||
* Possible result codes: NS_OK, NS_ERROR_ENCODER_NOT_FOUND
|
||||
* Initialize with a pointer to the document and the mime type.
|
||||
*
|
||||
*/
|
||||
nsIDocumentEncoder(nsIDocument* aDocument,
|
||||
const nsString& aMIMEType);
|
||||
|
||||
virtual ~nsIDocumentEncoder();
|
||||
#endif
|
||||
NS_IMETHOD Init(nsIDocument* aDocument, nsString& aMimeType) = 0;
|
||||
|
||||
/**
|
||||
* If the selection is set to a non-null value, then the
|
||||
|
|
|
@ -16,13 +16,14 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsIDocumentEncoder.h"
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
@ -38,6 +39,8 @@ public:
|
|||
nsHTMLEncoder();
|
||||
virtual ~nsHTMLEncoder();
|
||||
|
||||
NS_IMETHOD Init(nsIDocument* aDocument, nsString& aMimeType);
|
||||
|
||||
/* Interfaces for addref and release and queryinterface */
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
@ -53,17 +56,35 @@ public:
|
|||
NS_IMETHOD SubstituteURL(const nsString& aOriginal,
|
||||
const nsString& aReplacement);
|
||||
NS_IMETHOD PrettyPrint(PRBool aYesNO);
|
||||
|
||||
private:
|
||||
nsIDocument* mDocument;
|
||||
nsString mMimeType;
|
||||
};
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLEncoder)
|
||||
NS_IMPL_RELEASE(nsHTMLEncoder)
|
||||
|
||||
nsHTMLEncoder::nsHTMLEncoder()
|
||||
nsHTMLEncoder::nsHTMLEncoder() : mMimeType("text/html")
|
||||
{
|
||||
mDocument = 0;
|
||||
}
|
||||
|
||||
nsHTMLEncoder::~nsHTMLEncoder()
|
||||
{
|
||||
NS_IF_RELEASE(mDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::Init(nsIDocument* aDocument, nsString& aMimeType)
|
||||
{
|
||||
if (!aDocument)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
mDocument = aDocument;
|
||||
NS_ADDREF(mDocument);
|
||||
mMimeType = aMimeType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHTMLEncoder::QueryInterface(REFNSIID aIID,
|
||||
|
@ -103,6 +124,11 @@ nsHTMLEncoder::SetCharset(const nsString& aCharset)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::EncodeToString(nsString& aOutputString)
|
||||
{
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,20 +50,11 @@ public:
|
|||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOCUMENT_ENCODER_IID; return iid; }
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Creates a stream representation of aDocument.
|
||||
* Uses the MIMEType to choose an encoding.
|
||||
*
|
||||
* aDocument must point to a valid, non-null nsIDocument object.
|
||||
* Possible result codes: NS_OK, NS_ERROR_ENCODER_NOT_FOUND
|
||||
* Initialize with a pointer to the document and the mime type.
|
||||
*
|
||||
*/
|
||||
nsIDocumentEncoder(nsIDocument* aDocument,
|
||||
const nsString& aMIMEType);
|
||||
|
||||
virtual ~nsIDocumentEncoder();
|
||||
#endif
|
||||
NS_IMETHOD Init(nsIDocument* aDocument, nsString& aMimeType) = 0;
|
||||
|
||||
/**
|
||||
* If the selection is set to a non-null value, then the
|
||||
|
|
|
@ -16,13 +16,14 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsIDocumentEncoder.h"
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
@ -38,6 +39,8 @@ public:
|
|||
nsHTMLEncoder();
|
||||
virtual ~nsHTMLEncoder();
|
||||
|
||||
NS_IMETHOD Init(nsIDocument* aDocument, nsString& aMimeType);
|
||||
|
||||
/* Interfaces for addref and release and queryinterface */
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
@ -53,17 +56,35 @@ public:
|
|||
NS_IMETHOD SubstituteURL(const nsString& aOriginal,
|
||||
const nsString& aReplacement);
|
||||
NS_IMETHOD PrettyPrint(PRBool aYesNO);
|
||||
|
||||
private:
|
||||
nsIDocument* mDocument;
|
||||
nsString mMimeType;
|
||||
};
|
||||
|
||||
NS_IMPL_ADDREF(nsHTMLEncoder)
|
||||
NS_IMPL_RELEASE(nsHTMLEncoder)
|
||||
|
||||
nsHTMLEncoder::nsHTMLEncoder()
|
||||
nsHTMLEncoder::nsHTMLEncoder() : mMimeType("text/html")
|
||||
{
|
||||
mDocument = 0;
|
||||
}
|
||||
|
||||
nsHTMLEncoder::~nsHTMLEncoder()
|
||||
{
|
||||
NS_IF_RELEASE(mDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::Init(nsIDocument* aDocument, nsString& aMimeType)
|
||||
{
|
||||
if (!aDocument)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
mDocument = aDocument;
|
||||
NS_ADDREF(mDocument);
|
||||
mMimeType = aMimeType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHTMLEncoder::QueryInterface(REFNSIID aIID,
|
||||
|
@ -103,6 +124,11 @@ nsHTMLEncoder::SetCharset(const nsString& aCharset)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLEncoder::EncodeToString(nsString& aOutputString)
|
||||
{
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// Also make sure mString is a mime type "text/html" or "text/plain"
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче