|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions are met: |
|
7 * |
|
8 * - Redistributions of source code must retain the above copyright notice, |
|
9 * this list of conditions and the following disclaimer. |
|
10 * - Redistributions in binary form must reproduce the above copyright notice, |
|
11 * this list of conditions and the following disclaimer in the documentation |
|
12 * and/or other materials provided with the distribution. |
|
13 * - Neither the name of Nokia Corporation nor the names of its contributors |
|
14 * may be used to endorse or promote products derived from this software |
|
15 * without specific prior written permission. |
|
16 * |
|
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 * POSSIBILITY OF SUCH DAMAGE. |
|
28 * |
|
29 * Initial Contributors: |
|
30 * Nokia Corporation - initial contribution. |
|
31 * |
|
32 * Contributors: |
|
33 * |
|
34 * Description: |
|
35 * |
|
36 */ |
|
37 |
|
38 using System; |
|
39 using System.IO; |
|
40 using System.Text; |
|
41 using System.Collections; |
|
42 using System.Collections.Generic; |
|
43 using SymbianUtils; |
|
44 using HeapLib.Cells; |
|
45 using HeapLib.Array; |
|
46 using HeapLib.Reconstructor; |
|
47 using HeapLib.Relationships; |
|
48 |
|
49 namespace HeapLib |
|
50 { |
|
51 public class HeapToHTMLPageHeapLinkedCells : AsyncHTMLFileWriter |
|
52 { |
|
53 #region Constructors & destructor |
|
54 public HeapToHTMLPageHeapLinkedCells( HeapReconstructor aReconstructor, string aFileName, HeapCell aCell ) |
|
55 : base( aFileName, TNotUsingThread.ENotUsingThread ) |
|
56 { |
|
57 iReconstructor = aReconstructor; |
|
58 iCell = aCell; |
|
59 } |
|
60 #endregion |
|
61 |
|
62 #region API |
|
63 #endregion |
|
64 |
|
65 #region Internal state related |
|
66 private void OnStateHeader() |
|
67 { |
|
68 #region Header |
|
69 WriteDocumentBegin(); |
|
70 WriteHeadBegin(); |
|
71 WriteTitle( "Heap Cell Contents - 0x" + iCell.Address.ToString("x8") ); |
|
72 WriteStyleBegin(); |
|
73 |
|
74 WriteStyleName( "td, tr, li" ); |
|
75 WriteStyleBodyBegin(); |
|
76 WriteStyleBody( "font-family: Verdana, Arial, Helvetica, sans-serif;" ); |
|
77 WriteStyleBody( "font-size: 9pt;" ); |
|
78 WriteStyleBody( "white-space: nowrap;" ); |
|
79 WriteStyleBodyEnd(); |
|
80 |
|
81 WriteLine( "a:link { text-decoration: none; color: #CC0000 }" ); |
|
82 WriteLine( "a:visited { text-decoration: none; color: #CC0000 }" ); |
|
83 WriteLine( "a:active { text-decoration: none; color: #CC0000 }" ); |
|
84 WriteLine( "a:hover { text-decoration: underline; color: #CC0066 }" ); |
|
85 |
|
86 WriteStyleName( ".tableBorder" ); |
|
87 WriteStyleBodyBegin(); |
|
88 WriteStyleBody( "border-width: 1px;" ); |
|
89 WriteStyleBody( "border-style: solid;" ); |
|
90 WriteStyleBody( "border-color: #000000;" ); |
|
91 WriteStyleBodyEnd(); |
|
92 |
|
93 WriteStyleName( ".tableRowTitle" ); |
|
94 WriteStyleBodyBegin(); |
|
95 WriteStyleBody( "background-color: #DDDDDD;" ); |
|
96 WriteStyleBodyEnd(); |
|
97 |
|
98 WriteStyleName( ".tableRowTotal" ); |
|
99 WriteStyleBodyBegin(); |
|
100 WriteStyleBody( "background-color: #EEEEEE;" ); |
|
101 WriteStyleBody( "border-top: #000000 1px solid;" ); |
|
102 WriteStyleBodyEnd(); |
|
103 |
|
104 WriteStyleName( ".title" ); |
|
105 WriteStyleBodyBegin(); |
|
106 WriteStyleBody( "font-family: Verdana, Arial, Helvetica, sans-serif;" ); |
|
107 WriteStyleBody( "font-size: 10pt;" ); |
|
108 WriteStyleBody( "color: #0000AA; font-weight: bold;" ); |
|
109 WriteStyleBody( "white-space: nowrap;" ); |
|
110 WriteStyleBodyEnd(); |
|
111 |
|
112 WriteStyleName( ".noitems" ); |
|
113 WriteStyleBodyBegin(); |
|
114 WriteStyleBody( "font-family: Verdana, Arial, Helvetica, sans-serif;" ); |
|
115 WriteStyleBody( "font-size: 8pt;" ); |
|
116 WriteStyleBody( "color: #0000AA;" ); |
|
117 WriteStyleBody( "white-space: nowrap;" ); |
|
118 WriteStyleBodyEnd(); |
|
119 |
|
120 WriteStyleName( ".tableHeaders" ); |
|
121 WriteStyleBodyBegin(); |
|
122 WriteStyleBody( "font-family: Verdana, Arial, Helvetica, sans-serif;" ); |
|
123 WriteStyleBody( "font-size: 12pt;" ); |
|
124 WriteStyleBody( "color: #000000; font-weight: bold;" ); |
|
125 WriteStyleBody( "white-space: nowrap;" ); |
|
126 WriteStyleBody( "border-bottom: #000000 1px solid;" ); |
|
127 WriteStyleBodyEnd(); |
|
128 |
|
129 WriteStyleEnd(); |
|
130 |
|
131 WriteLine("<SCRIPT SRC=\"../../" + HeapToHTMLPageJavaScriptManager.JavaScriptHelperFileName + "\"></SCRIPT>"); |
|
132 |
|
133 WriteHeadEnd(); |
|
134 #endregion |
|
135 |
|
136 WriteBodyBegin(); |
|
137 |
|
138 WriteDivisionBegin(); |
|
139 |
|
140 WriteLine( "<P id=\"PageTop\" class=\"title\">Cell Associations</P>" ); |
|
141 |
|
142 if ( iCell.RelationshipManager.EmbeddedReferencesTo.Count > 0 ) |
|
143 { |
|
144 Writer.WriteLine( "<TABLE class=\"tableBorder\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">" ); |
|
145 Writer.WriteLine( "<TR class=\"tableRowTitle\">" ); |
|
146 |
|
147 WriteTableColumn( "Address", TAlignment.EAlignCenter, "tableHeaders" ); |
|
148 WriteTableColumn( "Length", TAlignment.EAlignCenter, "tableHeaders" ); |
|
149 WriteTableColumn( "Symbol", TAlignment.EAlignCenter, "tableHeaders" ); |
|
150 |
|
151 WriteTableRowEnd(); |
|
152 |
|
153 #region Blank row |
|
154 WriteTableRowBegin(); |
|
155 WriteTableColumnEmpty(); |
|
156 WriteTableColumnEmpty(); |
|
157 WriteTableColumnEmpty(); |
|
158 WriteTableRowEnd(); |
|
159 #endregion |
|
160 } |
|
161 else |
|
162 { |
|
163 WriteLine( "<P class=\"noitems\">No linked cells</P>" ); |
|
164 } |
|
165 } |
|
166 |
|
167 private void OnStateBody() |
|
168 { |
|
169 RelationshipCollection linkedCells = iCell.RelationshipManager.EmbeddedReferencesTo; |
|
170 if ( linkedCells.Count > 0 ) |
|
171 { |
|
172 foreach( RelationshipInfo info in linkedCells ) |
|
173 { |
|
174 HeapCell linkedCell = info.ToCell; |
|
175 |
|
176 // Start new row |
|
177 WriteTableRowBegin(); |
|
178 |
|
179 // Address |
|
180 WriteTableColumnHexAddress( linkedCell.Address, TAlignment.EAlignLeft ); |
|
181 |
|
182 // Length |
|
183 WriteTableColumn( linkedCell.PayloadLength, TAlignment.EAlignRight ); |
|
184 |
|
185 // Symbol |
|
186 string linkText = "[Unknown linked cell]"; |
|
187 if ( linkedCell.Symbol != null ) |
|
188 { |
|
189 linkText = linkedCell.Symbol.NameWithoutVTablePrefix; |
|
190 } |
|
191 |
|
192 string url = "javascript:showMainFormCell(\'" + linkedCell.Address.ToString("x8") + "\')"; |
|
193 string windowTarget = "MainWindow"; |
|
194 WriteTableColumnBegin( TAlignment.EAlignLeft, string.Empty ); |
|
195 WriteAnchorWithTarget( windowTarget, url, linkText ); |
|
196 WriteTableColumnEnd(); |
|
197 |
|
198 WriteTableRowEnd(); |
|
199 } |
|
200 |
|
201 #region Blank row |
|
202 WriteTableRowBegin(); |
|
203 WriteTableColumnEmpty(); |
|
204 WriteTableColumnEmpty(); |
|
205 WriteTableColumnEmpty(); |
|
206 WriteTableRowEnd(); |
|
207 #endregion |
|
208 |
|
209 #region Total |
|
210 WriteTableRowBegin(); |
|
211 WriteTableColumn( "Total:", "tableRowTotal" ); |
|
212 WriteTableColumn( ( iCell.PayloadLengthIncludingLinkedCells - iCell.PayloadLength ).ToString( "" ), TAlignment.EAlignRight, "tableRowTotal" ); |
|
213 WriteTableColumn( " ", "tableRowTotal" ); |
|
214 WriteTableRowEnd(); |
|
215 #endregion |
|
216 } |
|
217 } |
|
218 |
|
219 private void OnStateFooter() |
|
220 { |
|
221 if ( iCell.RelationshipManager.EmbeddedReferencesTo.Count > 0 ) |
|
222 { |
|
223 WriteTableEnd(); |
|
224 } |
|
225 |
|
226 WriteDivisionEnd(); |
|
227 WriteBodyEnd(); |
|
228 WriteDocumentEnd(); |
|
229 } |
|
230 #endregion |
|
231 |
|
232 #region From AsyncTextWriterBase |
|
233 public override long Size |
|
234 { |
|
235 get |
|
236 { |
|
237 return 1; |
|
238 } |
|
239 } |
|
240 |
|
241 public override long Position |
|
242 { |
|
243 get |
|
244 { |
|
245 return 0; |
|
246 } |
|
247 } |
|
248 |
|
249 public override void ExportData() |
|
250 { |
|
251 // NB this object is called synchronously, despite its name |
|
252 OnStateHeader(); |
|
253 OnStateBody(); |
|
254 OnStateFooter(); |
|
255 } |
|
256 #endregion |
|
257 |
|
258 #region Data members |
|
259 private readonly HeapReconstructor iReconstructor; |
|
260 private readonly HeapCell iCell; |
|
261 #endregion |
|
262 } |
|
263 } |