1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/streamconv/public/mozITXTToHTMLConv.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 1.4 +/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/** 1.10 + Description: Currently only functions to enhance plain text with HTML tags. 1.11 + <p> 1.12 + Wrapper class for various parsing routines, that convert plain text to HTML. 1.13 + They try to recognize cites, URLs, plain text formattting like *bold* etc. 1.14 + See <http://www.bucksch.org/1/projects/mozilla/16507/> for a description. 1.15 + */ 1.16 + 1.17 +#include "nsIStreamConverter.idl" 1.18 + 1.19 +%{C++ 1.20 +// {77c0e42a-1dd2-11b2-8ebf-edc6606f2f4b} 1.21 +#define MOZITXTTOHTMLCONV_CID \ 1.22 + { 0x77c0e42a, 0x1dd2, 0x11b2, \ 1.23 + { 0x8e, 0xbf, 0xed, 0xc6, 0x60, 0x6f, 0x2f, 0x4b } } 1.24 + 1.25 +#define MOZ_TXTTOHTMLCONV_CONTRACTID \ 1.26 + "@mozilla.org/txttohtmlconv;1" 1.27 + 1.28 +%} 1.29 + 1.30 +[scriptable, uuid(77c0e42a-1dd2-11b2-8ebf-edc6606f2f4b)] 1.31 +interface mozITXTToHTMLConv : nsIStreamConverter { 1.32 + const unsigned long kEntities = 0; // just convert < & > to < & and > 1.33 + const unsigned long kURLs = 1 << 1; 1.34 + const unsigned long kGlyphSubstitution = 1 << 2; // Smilies, ® etc. 1.35 + const unsigned long kStructPhrase = 1 << 3; // E.g. *bold* -> <strong> 1.36 + 1.37 +/** 1.38 + @param text: plain text to scan. May be a line, paragraph (recommended) 1.39 + or just a substring.<p> 1.40 + Must be non-escaped, pure unicode.<p> 1.41 + <em>Note:</em> ScanTXT(a, o) + ScanTXT(b, o) may be != 1.42 + Scan(a + b, o) 1.43 + @param whattodo: Bitfield describing the modes of operation 1.44 + @result "<", ">" and "&" are escaped and HTML tags are inserted where 1.45 + appropriate. 1.46 + */ 1.47 + wstring scanTXT(in wstring text, in unsigned long whattodo); 1.48 + 1.49 +/** 1.50 + Adds additional formatting to user edited text, that the user was too lazy 1.51 + or "unknowledged" (DELETEME: is that a word?) to make. 1.52 + <p> 1.53 + <em>Note:</em> Don't use kGlyphSubstitution with this function. This option 1.54 + generates tags, that are unuseable for UAs other than Mozilla. This would 1.55 + be a data loss bug. 1.56 + 1.57 + @param text: HTML source to scan. May be a line, paragraph (recommended) 1.58 + or just a substring.<p> 1.59 + Must be correct HTML. "<", ">" and "&" must be escaped, 1.60 + other chars must be pure unicode.<p> 1.61 + <em>Note:</em> ScanTXT(a, o) + ScanTXT(b, o) may be != 1.62 + Scan(a + b, o) 1.63 + @param whattodo: Bitfield describing the modes of operation 1.64 + @result Additional HTML tags are inserted where appropriate. 1.65 + */ 1.66 + wstring scanHTML(in wstring text, in unsigned long whattodo); 1.67 + 1.68 +/** 1.69 + @param line: line in original msg, possibly starting starting with 1.70 + txt quote tags like ">" 1.71 + @param logLineStart: pos in line, where the real content (logical line) 1.72 + begins, i.e. pos after all txt quote tags. 1.73 + E.g. position of "t" in "> > text". 1.74 + Initial value must be 0, unless line is not real line. 1.75 + @return Cite Level, i.e. number of txt quote tags found, i.e. number of 1.76 + nested quotes. 1.77 + */ 1.78 + unsigned long citeLevelTXT(in wstring line, 1.79 + out unsigned long logLineStart); 1.80 + 1.81 +/** 1.82 + @param a wide string to scan for the presence of a URL. 1.83 + @param aLength --> the length of the buffer to be scanned 1.84 + @param aPos --> the position in the buffer to start scanning for a url 1.85 + 1.86 + aStartPos --> index into the start of a url (-1 if no url found) 1.87 + aEndPos --> index of the last character in the url (-1 if no url found) 1.88 + */ 1.89 + 1.90 + void findURLInPlaintext(in wstring text, in long aLength, in long aPos, out long aStartPos, out long aEndPos); 1.91 +};