Index table:name attribute of table:table of ods files. These store the sheet names.
[beagle.git] / Renderers / ContactHitRenderer.cs
blobcc2a6706eee5d22ec9e1de1f130c165061cda66d
1 //
2 // ContactHitRenderer.cs
3 //
4 // Copyright (C) 2004 Novell, Inc.
5 //
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
28 using System;
29 using System.Collections;
30 using System.Text;
32 namespace Beagle {
34 public class ContactHitRenderer : HitRendererHtml {
36 public ContactHitRenderer ()
38 type = "Contact";
41 protected override String HitsToHtml (ArrayList hits)
43 StringBuilder builder = new StringBuilder ();
45 builder.Append ("<table width=\"100%\" bgcolor=\"#fffa6e\"><tr><td>");
46 builder.Append ("<font size=\"+2\">Contacts</font>");
47 builder.Append ("</td></tr></table>");
49 bool color_band = true;
50 foreach (Hit hit in hits) {
51 SingleHitToHtml (hit, color_band, builder);
52 color_band = ! color_band;
54 return builder.ToString ();
57 private void AddField (Hit hit, String key, String name, StringBuilder builder)
59 if (hit [key] != null) {
60 builder.Append ("<tr><td>" + name + ":</td>");
61 builder.Append ("<td>" + hit [key] + "</td></tr>");
65 private void SingleHitToHtml (Hit hit, bool color_band,
66 StringBuilder builder)
68 builder.Append ("<table");
69 if (color_band)
70 builder.Append (" bgcolor=\"#eeeeee\"");
71 builder.Append (" width=\"100%\">");
72 builder.Append ("<tr><td colspan=2>" + hit ["Name"] + "</td></tr>");
73 AddField (hit, "Email1", "Email", builder);
74 AddField (hit, "Email2", "Email", builder);
75 AddField (hit, "Email3", "Email", builder);
76 AddField (hit, "HomePhone", "Phone", builder);
77 AddField (hit, "HomePhone2", "Phone2", builder);
78 AddField (hit, "MobilePhone", "Mobile", builder);
79 builder.Append ("</table>");