2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-06-04 01:04:08 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-06-04 01:04:08 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-06-04 01:04:08 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 01:32:19 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 21:52:36 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-25 01:32:19 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 01:32:19 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 01:32:19 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-06-04 01:04:08 +00:00
|
|
|
|
|
|
|
#ifndef nsIDocumentEncoder_h__
|
|
|
|
#define nsIDocumentEncoder_h__
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
class nsIDocumentEncoder;
|
|
|
|
class nsIDocument;
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 10:57:30 +00:00
|
|
|
class nsIDOMRange;
|
2000-09-14 11:45:01 +00:00
|
|
|
class nsISelection;
|
1999-06-04 01:04:08 +00:00
|
|
|
class nsIOutputStream;
|
|
|
|
class nsISupportsArray;
|
2000-11-30 01:08:22 +00:00
|
|
|
class nsIDOMNode;
|
1999-08-25 21:42:20 +00:00
|
|
|
|
1999-06-04 01:04:08 +00:00
|
|
|
|
|
|
|
#define NS_IDOCUMENT_ENCODER_IID \
|
|
|
|
{ /* a6cf9103-15b3-11d2-932e-00805f8add32 */ \
|
|
|
|
0xa6cf9103, \
|
|
|
|
0x15b3, \
|
|
|
|
0x11d2, \
|
|
|
|
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} \
|
|
|
|
}
|
|
|
|
|
1999-06-10 00:35:02 +00:00
|
|
|
#define NS_TEXT_ENCODER_CID \
|
|
|
|
{ /* e7ba1480-1dea-11d3-830f-00104bed045e */ \
|
|
|
|
0xe7ba1480, \
|
|
|
|
0x1dea, \
|
|
|
|
0x11d3, \
|
|
|
|
{0x83, 0x0f, 0x00, 0x10, 0x4b, 0xed, 0x04, 0x5e} \
|
|
|
|
}
|
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
#define NS_DOC_ENCODER_CONTRACTID_BASE "@mozilla.org/layout/documentEncoder;1?type="
|
1999-06-10 00:35:02 +00:00
|
|
|
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 10:57:30 +00:00
|
|
|
// {7f915b01-98fc-11d4-8eb0-a803f80ff1bc}
|
|
|
|
#define NS_HTMLCOPY_TEXT_ENCODER_CID \
|
|
|
|
{ 0x7f915b01, 0x98fc, 0x11d4, { 0x8e, 0xb0, 0xa8, 0x03, 0xf8, 0x0f, 0xf1, 0xbc } }
|
|
|
|
|
2000-11-30 01:08:22 +00:00
|
|
|
// {0BC1FAC0-B710-11d4-959F-0020183BF181}
|
|
|
|
#define NS_IDOCUMENTENCODERNODEFIXUP_IID \
|
|
|
|
{ 0xbc1fac0, 0xb710, 0x11d4, { 0x95, 0x9f, 0x0, 0x20, 0x18, 0x3b, 0xf1, 0x81 } }
|
|
|
|
|
2001-01-07 03:06:19 +00:00
|
|
|
#define NS_HTMLCOPY_ENCODER_CONTRACTID "@mozilla.org/layout/htmlCopyEncoder;1"
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 10:57:30 +00:00
|
|
|
|
2000-11-30 01:08:22 +00:00
|
|
|
class nsIDocumentEncoderNodeFixup : public nsISupports
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENTENCODERNODEFIXUP_IID)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a fixed up version of a node. This method is called before
|
|
|
|
* each node in a document is about to be persisted. The implementor
|
|
|
|
* may return a new node with fixed up attributes or nsnull.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD FixupNode(nsIDOMNode *aNode, nsIDOMNode **aOutNode) = 0;
|
|
|
|
};
|
|
|
|
|
1999-06-04 01:04:08 +00:00
|
|
|
class nsIDocumentEncoder : public nsISupports
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 10:57:30 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_ENCODER_IID)
|
|
|
|
|
1999-08-24 18:30:19 +00:00
|
|
|
/**
|
1999-09-29 20:17:51 +00:00
|
|
|
* Output methods flag bits.
|
|
|
|
*
|
|
|
|
* There are a frightening number of these,
|
|
|
|
* because everyone wants something a little bit different!
|
|
|
|
*
|
|
|
|
* These should move to an idl file so that Javascript can
|
|
|
|
* have access to the symbols, not just the constants.
|
1999-08-24 18:30:19 +00:00
|
|
|
*/
|
|
|
|
enum {
|
2000-04-26 01:00:50 +00:00
|
|
|
// Output only the selection (as opposed to the whole document).
|
1999-08-24 18:30:19 +00:00
|
|
|
OutputSelectionOnly = 1,
|
1999-09-29 20:17:51 +00:00
|
|
|
|
2000-04-26 01:00:50 +00:00
|
|
|
// Plaintext output: Convert html to plaintext that looks like the html.
|
1999-09-29 20:17:51 +00:00
|
|
|
// Implies wrap (except inside <pre>), since html wraps.
|
2000-04-26 01:00:50 +00:00
|
|
|
// HTML output: always do prettyprinting, ignoring existing formatting.
|
|
|
|
// (Probably not well tested for HTML output.)
|
1999-08-24 18:30:19 +00:00
|
|
|
OutputFormatted = 2,
|
1999-09-29 20:17:51 +00:00
|
|
|
|
2005-02-07 17:24:05 +00:00
|
|
|
// Don't do prettyprinting of HTML. Don't do any wrapping that's not in
|
|
|
|
// the existing HTML source. This option overrides OutputFormatted if both
|
|
|
|
// are set. Note that this option does not affect entity conversion.
|
2000-10-11 22:50:14 +00:00
|
|
|
OutputRaw = 4,
|
1999-09-29 20:17:51 +00:00
|
|
|
|
|
|
|
// No html head tags
|
|
|
|
OutputBodyOnly = 8,
|
|
|
|
|
|
|
|
// Wrap even if we're not doing formatted output (e.g. for text fields)
|
2005-02-07 17:24:05 +00:00
|
|
|
// XXXbz this doesn't seem to be used by all serializers... document? How
|
|
|
|
// does this interact with
|
|
|
|
// OutputFormatted/OutputRaw/OutputWrap/OutputFormatFlowed?
|
1999-09-29 20:17:51 +00:00
|
|
|
OutputPreformatted = 16,
|
|
|
|
|
|
|
|
// Output as though the content is preformatted
|
|
|
|
// (e.g. maybe it's wrapped in a MOZ_PRE or MOZ_PRE_WRAP style tag)
|
2005-02-07 17:24:05 +00:00
|
|
|
// XXXbz this doesn't seem to be used by all serializers... document? How
|
|
|
|
// does this interact with
|
|
|
|
// OutputFormatted/OutputRaw/OutputPreformatted/OutputFormatFlowed?
|
1999-11-03 03:08:04 +00:00
|
|
|
OutputWrap = 32,
|
|
|
|
|
|
|
|
// Output for format flowed (RFC 2646). This is used when converting
|
|
|
|
// to text for mail sending. This differs just slightly
|
|
|
|
// but in an important way from normal formatted, and that is that
|
|
|
|
// lines are space stuffed. This can't (correctly) be done later.
|
2005-02-07 17:24:05 +00:00
|
|
|
// XXXbz this doesn't seem to be used by all serializers... document? How
|
|
|
|
// does this interact with
|
|
|
|
// OutputFormatted/OutputRaw/OutputPreformatted/OutputWrap?
|
2000-03-22 01:33:59 +00:00
|
|
|
OutputFormatFlowed = 64,
|
|
|
|
|
|
|
|
// Convert links, image src, and script src to absolute URLs when possible
|
2000-03-28 00:10:44 +00:00
|
|
|
OutputAbsoluteLinks = 128,
|
|
|
|
|
2002-12-13 22:12:10 +00:00
|
|
|
// Attempt to encode entities standardized at W3C (HTML, MathML, etc).
|
|
|
|
// This is a catch-all flag for documents with mixed contents. Beware of
|
|
|
|
// interoperability issues. See below for other flags which might likely
|
|
|
|
// do what you want.
|
|
|
|
OutputEncodeW3CEntities = 256,
|
2000-07-10 19:46:59 +00:00
|
|
|
|
|
|
|
// LineBreak processing: we can do either platform line breaks,
|
|
|
|
// CR, LF, or CRLF. If neither of these flags is set, then we
|
|
|
|
// will use platform line breaks.
|
|
|
|
OutputCRLineBreak = 512,
|
2001-10-02 10:02:07 +00:00
|
|
|
OutputLFLineBreak = 1024,
|
|
|
|
|
|
|
|
// Output the content of noscript elements (only for serializing
|
|
|
|
// to plaintext).
|
2001-11-30 09:50:25 +00:00
|
|
|
OutputNoScriptContent = 2048,
|
|
|
|
|
|
|
|
// Output the content of noframes elements (only for serializing
|
|
|
|
// to plaintext).
|
2002-04-10 21:25:15 +00:00
|
|
|
OutputNoFramesContent = 4096,
|
|
|
|
|
|
|
|
// Don't allow any formatting nodes (e.g. <br>, <b>) inside a <pre>.
|
|
|
|
// This is used primarily by mail.
|
2002-12-13 22:12:10 +00:00
|
|
|
OutputNoFormattingInPre = 8192,
|
|
|
|
|
|
|
|
// Encode entities when outputting to a string.
|
|
|
|
// E.g. If set, we'll output if clear, we'll output 0xa0.
|
|
|
|
// The basic set is just & < > " for interoperability
|
|
|
|
// with older products that don't support α and friends.
|
|
|
|
// The Latin1 entity set additionally includes 8bit accented letters
|
|
|
|
// between 128 and 255.
|
|
|
|
// The HTML entity set additionally includes accented letters, greek
|
|
|
|
// letters, and other special markup symbols as defined in HTML4.
|
|
|
|
OutputEncodeBasicEntities = 16384,
|
|
|
|
OutputEncodeLatin1Entities = 32768,
|
|
|
|
OutputEncodeHTMLEntities = 65536
|
1999-08-24 18:30:19 +00:00
|
|
|
};
|
1999-06-04 01:04:08 +00:00
|
|
|
|
|
|
|
/**
|
1999-06-08 00:01:55 +00:00
|
|
|
* Initialize with a pointer to the document and the mime type.
|
1999-06-04 01:04:08 +00:00
|
|
|
*/
|
2002-03-23 23:54:46 +00:00
|
|
|
NS_IMETHOD Init(nsIDocument* aDocument, const nsAString& aMimeType,
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 10:57:30 +00:00
|
|
|
PRUint32 flags) = 0;
|
1999-06-04 01:04:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If the selection is set to a non-null value, then the
|
|
|
|
* selection is used for encoding, otherwise the entire
|
|
|
|
* document is encoded.
|
|
|
|
*/
|
2000-09-14 11:45:01 +00:00
|
|
|
NS_IMETHOD SetSelection(nsISelection* aSelection) = 0;
|
1999-06-04 01:04:08 +00:00
|
|
|
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 10:57:30 +00:00
|
|
|
/**
|
|
|
|
* If the range is set to a non-null value, then the
|
|
|
|
* range is used for encoding, otherwise the entire
|
|
|
|
* document or selection is encoded.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetRange(nsIDOMRange* aRange) = 0;
|
|
|
|
|
2003-04-15 18:13:13 +00:00
|
|
|
/**
|
|
|
|
* If the node is set to a non-null value, then the
|
|
|
|
* node is used for encoding, otherwise the entire
|
|
|
|
* document or range or selection is encoded.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetNode(nsIDOMNode* aNode) = 0;
|
|
|
|
|
1999-06-04 01:04:08 +00:00
|
|
|
/**
|
|
|
|
* Documents typically have an intrinsic character set.
|
|
|
|
* If no intrinsic value is found, the platform character set
|
|
|
|
* is used.
|
|
|
|
* aCharset overrides the both the intrinsic or platform
|
|
|
|
* character set when encoding the document.
|
|
|
|
*
|
|
|
|
* Possible result codes: NS_ERROR_NO_CHARSET_CONVERTER
|
|
|
|
*/
|
2003-06-17 16:40:34 +00:00
|
|
|
NS_IMETHOD SetCharset(const nsACString& aCharset) = 0;
|
1999-06-04 01:04:08 +00:00
|
|
|
|
1999-08-24 18:30:19 +00:00
|
|
|
/**
|
|
|
|
* Set a wrap column. This may have no effect in some types of encoders.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetWrapColumn(PRUint32 aWC) = 0;
|
|
|
|
|
2001-02-15 13:22:26 +00:00
|
|
|
/**
|
|
|
|
* Get the mime type preferred by the encoder. This piece of api was
|
|
|
|
* added because the copy encoder may need to switch mime types on you
|
|
|
|
* if you ask it to copy html that really represents plaintext content.
|
|
|
|
* Call this AFTER Init() and SetSelection() have both been called.
|
|
|
|
*/
|
2002-03-23 23:54:46 +00:00
|
|
|
NS_IMETHOD GetMimeType(nsAString& aMimeType) = 0;
|
2001-02-15 13:22:26 +00:00
|
|
|
|
1999-06-04 01:04:08 +00:00
|
|
|
/**
|
|
|
|
* The document is encoded, the result is sent to the
|
|
|
|
* to nsIOutputStream.
|
|
|
|
*
|
|
|
|
* Possible result codes are passing along whatever stream errors
|
|
|
|
* might have been encountered.
|
|
|
|
*/
|
1999-06-07 19:32:36 +00:00
|
|
|
NS_IMETHOD EncodeToStream(nsIOutputStream* aStream) = 0;
|
2002-03-23 23:54:46 +00:00
|
|
|
NS_IMETHOD EncodeToString(nsAString& aOutputString) = 0;
|
1999-06-04 01:04:08 +00:00
|
|
|
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 10:57:30 +00:00
|
|
|
/**
|
|
|
|
* The document is encoded, the result is sent to the
|
|
|
|
* to aEncodedString. Parent heirarchy information is encoded
|
|
|
|
* to aContextString. Extra context info is encoded in aInfoString.
|
|
|
|
*
|
|
|
|
*/
|
2002-03-23 23:54:46 +00:00
|
|
|
NS_IMETHOD EncodeToStringWithContext(nsAString& aEncodedString,
|
|
|
|
nsAString& aContextString,
|
|
|
|
nsAString& aInfoString) = 0;
|
2000-11-30 01:08:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the fixup object associated with node persistence.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetNodeFixup(nsIDocumentEncoderNodeFixup *aFixup) = 0;
|
1999-06-10 00:35:02 +00:00
|
|
|
};
|
|
|
|
|
1999-06-04 01:04:08 +00:00
|
|
|
#endif /* nsIDocumentEncoder_h__ */
|
|
|
|
|