Wed Feb 24 15:47:16 CET 2010 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.UI / Html32TextWriter.cs
1 //
2 // System.Web.UI.Html32TextWriter.cs: Provides a HtmlTextWriter which writes HTML 3.2
3 //
4 // Authors:
5 //      Matthijs ter Woord  [meddochat]  (meddochat@zonnet.nl)
6 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 //
8 // Copyright (C) Matthijs ter Woord, 2004
9 // Copyright (C) 2004-2010 Novell, Inc (http://www.novell.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System.Collections;
32 using System.Globalization;
33 using System.IO;
34 using System.Security.Permissions;
35 using System.Web.Util;
36
37 namespace System.Web.UI
38 {
39         // CAS
40         [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
41         [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
42         public class Html32TextWriter : HtmlTextWriter
43         {
44                 bool div_table_substitution;
45                 bool bold;
46                 bool italic;
47
48                 public Html32TextWriter (TextWriter writer) : base (writer)
49                 {
50                 }
51
52                 public Html32TextWriter (TextWriter writer, string tabString) : base (writer, tabString)
53                 {
54                 }
55
56                 [MonoTODO ("no effect on html generation")]
57                 public bool ShouldPerformDivTableSubstitution {
58                         get { return div_table_substitution; }
59                         set { div_table_substitution = value; }
60                 }
61
62                 [MonoTODO ("no effect on html generation")]
63                 public bool SupportsBold {
64                         get { return bold; }
65                         set { bold = value; }
66                 }
67
68                 [MonoTODO ("no effect on html generation")]
69                 public bool SupportsItalic {
70                         get { return italic; }
71                         set { italic = value; }
72                 }
73
74                 public override void RenderBeginTag (HtmlTextWriterTag tagKey)
75                 {
76                         base.RenderBeginTag (tagKey);
77                 }
78
79                 public override void RenderEndTag ()
80                 {
81                         base.RenderEndTag ();
82                 }
83
84                 protected override string GetTagName (HtmlTextWriterTag tagKey)
85                 {
86                         if (tagKey == HtmlTextWriterTag.Unknown ||
87                             !Enum.IsDefined (typeof (HtmlTextWriterTag), tagKey))
88                                 return String.Empty;
89
90                         return tagKey.ToString ().ToLower (Helpers.InvariantCulture);
91                         /* The code below is here just in case we need to split things up
92                         switch (tagkey) {
93                         case HtmlTextWriterTag.Unknown:
94                                 return String.Empty;
95                         case HtmlTextWriterTag.A:
96                                 return "a";
97                         case HtmlTextWriterTag.Acronym:
98                                 return "acronym";
99                         case HtmlTextWriterTag.Address:
100                                 return "address";
101                         case HtmlTextWriterTag.Area:
102                                 return "area";
103                         case HtmlTextWriterTag.B:
104                                 return "b";
105                         case HtmlTextWriterTag.Base:
106                                 return "base";
107                         case HtmlTextWriterTag.Basefont:
108                                 return "basefont";
109                         case HtmlTextWriterTag.Bdo:
110                                 return "bdo";
111                         case HtmlTextWriterTag.Bgsound:
112                                 return "bgsound";
113                         case HtmlTextWriterTag.Big:
114                                 return "big";
115                         case HtmlTextWriterTag.Blockquote:
116                                 return "blockquote";
117                         case HtmlTextWriterTag.Body:
118                                 return "body";
119                         case HtmlTextWriterTag.Br:
120                                 return "br";
121                         case HtmlTextWriterTag.Button:
122                                 return "button";
123                         case HtmlTextWriterTag.Caption:
124                                 return "caption";
125                         case HtmlTextWriterTag.Center:
126                                 return "center";
127                         case HtmlTextWriterTag.Cite:
128                                 return "cite";
129                         case HtmlTextWriterTag.Code:
130                                 return "code";
131                         case HtmlTextWriterTag.Col:
132                                 return "col";
133                         case HtmlTextWriterTag.Colgroup:
134                                 return "colgroup";
135                         case HtmlTextWriterTag.Dd:
136                                 return "dd";
137                         case HtmlTextWriterTag.Del:
138                                 return "del";
139                         case HtmlTextWriterTag.Dfn:
140                                 return "dfn";
141                         case HtmlTextWriterTag.Dir:
142                                 return "dir";
143                         case HtmlTextWriterTag.Div:
144                                 return "table";
145                         case HtmlTextWriterTag.Dl:
146                                 return "dl";
147                         case HtmlTextWriterTag.Dt:
148                                 return "dt";
149                         case HtmlTextWriterTag.Em:
150                                 return "em";
151                         case HtmlTextWriterTag.Embed:
152                                 return "embed";
153                         case HtmlTextWriterTag.Fieldset:
154                                 return "fieldset";
155                         case HtmlTextWriterTag.Font:
156                                 return "font";
157                         case HtmlTextWriterTag.Form:
158                                 return "form";
159                         case HtmlTextWriterTag.Frame:
160                                 return "frame";
161                         case HtmlTextWriterTag.Frameset:
162                                 return "frameset";
163                         case HtmlTextWriterTag.H1:
164                                 return "h1";
165                         case HtmlTextWriterTag.H2:
166                                 return "h2";
167                         case HtmlTextWriterTag.H3:
168                                 return "h3";
169                         case HtmlTextWriterTag.H4:
170                                 return "h4";
171                         case HtmlTextWriterTag.H5:
172                                 return "h5";
173                         case HtmlTextWriterTag.H6:
174                                 return "h6";
175                         case HtmlTextWriterTag.Head:
176                                 return "head";
177                         case HtmlTextWriterTag.Hr:
178                                 return "hr";
179                         case HtmlTextWriterTag.Html:
180                                 return "html";
181                         case HtmlTextWriterTag.I:
182                                 return "i";
183                         case HtmlTextWriterTag.Iframe:
184                                 return "iframe";
185                         case HtmlTextWriterTag.Img:
186                                 return "img";
187                         case HtmlTextWriterTag.Input:
188                                 return "input";
189                         case HtmlTextWriterTag.Ins:
190                                 return "ins";
191                         case HtmlTextWriterTag.Isindex:
192                                 return "isindex";
193                         case HtmlTextWriterTag.Kbd:
194                                 return "kbd";
195                         case HtmlTextWriterTag.Label:
196                                 return "label";
197                         case HtmlTextWriterTag.Legend:
198                                 return "legend";
199                         case HtmlTextWriterTag.Li:
200                                 return "li";
201                         case HtmlTextWriterTag.Link:
202                                 return "link";
203                         case HtmlTextWriterTag.Map:
204                                 return "map";
205                         case HtmlTextWriterTag.Marquee:
206                                 return "marquee";
207                         case HtmlTextWriterTag.Menu:
208                                 return "menu";
209                         case HtmlTextWriterTag.Meta:
210                                 return "meta";
211                         case HtmlTextWriterTag.Nobr:
212                                 return "nobr";
213                         case HtmlTextWriterTag.Noframes:
214                                 return "noframes";
215                         case HtmlTextWriterTag.Noscript:
216                                 return "noscript";
217                         case HtmlTextWriterTag.Object:
218                                 return "object";
219                         case HtmlTextWriterTag.Ol:
220                                 return "ol";
221                         case HtmlTextWriterTag.Option:
222                                 return "option";
223                         case HtmlTextWriterTag.P:
224                                 return "p";
225                         case HtmlTextWriterTag.Param:
226                                 return "param";
227                         case HtmlTextWriterTag.Pre:
228                                 return "pre";
229                         case HtmlTextWriterTag.Q:
230                                 return "q";
231                         case HtmlTextWriterTag.Rt:
232                                 return "rt";
233                         case HtmlTextWriterTag.Ruby:
234                                 return "ruby";
235                         case HtmlTextWriterTag.S:
236                                 return "s";
237                         case HtmlTextWriterTag.Samp:
238                                 return "samp";
239                         case HtmlTextWriterTag.Script:
240                                 return "script";
241                         case HtmlTextWriterTag.Select:
242                                 return "select";
243                         case HtmlTextWriterTag.Small:
244                                 return "small";
245                         case HtmlTextWriterTag.Span:
246                                 return "span";
247                         case HtmlTextWriterTag.Strike:
248                                 return "strike";
249                         case HtmlTextWriterTag.Strong:
250                                 return "strong";
251                         case HtmlTextWriterTag.Style:
252                                 return "style";
253                         case HtmlTextWriterTag.Sub:
254                                 return "sub";
255                         case HtmlTextWriterTag.Sup:
256                                 return "sup";
257                         case HtmlTextWriterTag.Table:
258                                 return "table";
259                         case HtmlTextWriterTag.Tbody:
260                                 return "tbody";
261                         case HtmlTextWriterTag.Td:
262                                 return "td";
263                         case HtmlTextWriterTag.Textarea:
264                                 return "textarea";
265                         case HtmlTextWriterTag.Tfoot:
266                                 return "tfoot";
267                         case HtmlTextWriterTag.Th:
268                                 return "th";
269                         case HtmlTextWriterTag.Thead:
270                                 return "thead";
271                         case HtmlTextWriterTag.Title:
272                                 return "title";
273                         case HtmlTextWriterTag.Tr:
274                                 return "tr";
275                         case HtmlTextWriterTag.Tt:
276                                 return "tt";
277                         case HtmlTextWriterTag.U:
278                                 return "u";
279                         case HtmlTextWriterTag.Ul:
280                                 return "ul";
281                         case HtmlTextWriterTag.Var:
282                                 return "var";
283                         case HtmlTextWriterTag.Wbr:
284                                 return "wbr";
285                         case HtmlTextWriterTag.Xml:
286                                 return "xml";
287                         default:
288                                 return String.Empty;
289                         }
290                         */
291                 }
292
293                 protected override bool OnStyleAttributeRender (string name, string value, HtmlTextWriterStyle key)
294                 {
295                         return base.OnStyleAttributeRender (name, value, key);
296                 }
297
298                 protected override bool OnTagRender (string name, HtmlTextWriterTag key)
299                 {
300                         return base.OnTagRender (name, key);
301                 }
302
303                 protected override string RenderAfterContent ()
304                 {
305                         return base.RenderAfterContent ();
306                 }
307
308                 protected override string RenderAfterTag ()
309                 {
310                         return base.RenderAfterTag ();
311                 }
312
313                 protected override string RenderBeforeContent ()
314                 {
315                         return base.RenderBeforeContent ();
316                 }
317
318                 protected override string RenderBeforeTag ()
319                 {
320                         return base.RenderBeforeTag ();
321                 }
322
323                 [MonoTODO("Not implemented, always returns null")]
324                 protected Stack FontStack {
325                         get {
326                                 return null;
327                         }
328                 }
329         }
330 }
331