Changeset 66 for trunk/Components/CoolWeb/Common/UHtmlClasses.pas
- Timestamp:
- Dec 20, 2011, 9:37:35 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Components/CoolWeb/Common/UHtmlClasses.pas
r65 r66 70 70 end; 71 71 72 { THtmlElement } 73 72 74 THtmlElement = class 73 pr ivate75 protected 74 76 function GetAsXmlElement: TXmlElement; virtual; 75 77 public … … 78 80 ClassId: string; 79 81 Style: string; 82 procedure Assign(Source: THtmlElement); virtual; 80 83 property AsXmlElement: TXmlElement read GetAsXmlElement; 81 84 end; … … 83 86 TBlockType = (btNoTag, btBlockLevel, btInline); 84 87 88 { THtmlString } 89 85 90 THtmlString = class(THtmlElement) 86 91 private … … 88 93 public 89 94 Text: string; 95 procedure Assign(Source: THtmlElement); override; 90 96 end; 91 97 … … 100 106 101 107 THtmlBlock = class(THtmlElement) 102 pr ivate108 protected 103 109 function GetAsXmlElement: TXmlElement; override; 104 110 public … … 149 155 InputType: THtmlInputType; 150 156 Value: Variant; 157 procedure Assign(Source: THtmlElement); override; 151 158 constructor Create; 152 159 destructor Destroy; override; … … 156 163 157 164 THtmlForm = class(THtmlBlock) 158 private 165 protected 166 function GetAsXmlElement: TXmlElement; override; 159 167 public 160 168 Method: string; 161 169 Action: TURL; 162 function GetAsXmlElement: TXmlElement; override;163 170 constructor Create; 164 171 destructor Destroy; override; … … 183 190 184 191 THtmlCell = class(THtmlElement) 192 private 193 function GetAsXmlElement: TXmlElement; override; 194 public 185 195 RowSpan: Integer; 186 196 ColSpan: Integer; 187 197 Value: THtmlElement; 188 198 constructor Create; 199 destructor Destroy; override; 189 200 end; 190 201 … … 192 203 193 204 THtmlRow = class(THtmlElement) 205 private 206 function GetAsXmlElement: TXmlElement; override; 207 public 194 208 Cells: TListObject; // TListObject<THtmlCell> 195 209 constructor Create; … … 199 213 { THtmlTable } 200 214 201 THtmlTable = class 202 pr ivate203 function GetAsXml Document: TXmlDocument;215 THtmlTable = class(THtmlElement) 216 protected 217 function GetAsXmlElement: TXmlElement; override; 204 218 public 205 219 Rows: TListObject; // TListObject<THtmlRow> 206 property AsXmlDocument: TXmlDocument read GetAsXmlDocument;207 220 constructor Create; 208 221 destructor Destroy; override; … … 280 293 { THtmlCell } 281 294 295 function THtmlCell.GetAsXmlElement: TXmlElement; 296 begin 297 Result := inherited GetAsXmlElement; 298 TXmlTag(Result).Name := 'td'; 299 with TXmlTag(Result).Attributes do begin 300 if ColSpan > 1 then Add('colspan', IntToStr(ColSpan)); 301 if RowSpan > 1 then Add('rowspan', IntToStr(RowSpan)); 302 end; 303 TXmlTag(Result).SubElements.Add(Value.AsXmlElement); 304 end; 305 282 306 constructor THtmlCell.Create; 283 307 begin … … 286 310 end; 287 311 312 destructor THtmlCell.Destroy; 313 begin 314 Value.Free; 315 inherited Destroy; 316 end; 317 288 318 { THtmlRow } 319 320 function THtmlRow.GetAsXmlElement: TXmlElement; 321 var 322 Column: Integer; 323 begin 324 Result := inherited GetAsXmlElement; 325 TXmlTag(Result).Name := 'tr'; 326 for Column := 0 to Cells.Count - 1 do 327 TXmlTag(Result).SubElements.AddNew(THtmlCell(Cells[Column]).AsXmlElement); 328 end; 289 329 290 330 constructor THtmlRow.Create; … … 301 341 { THtmlTable } 302 342 303 function THtmlTable.GetAsXml Document: TXmlDocument;343 function THtmlTable.GetAsXmlElement: TXmlElement; 304 344 var 305 345 Row, Column: Integer; 306 346 begin 347 Result := inherited; 307 348 with TXmlTag(Result) do begin 308 349 Name := 'table'; 309 350 for Row := 0 to Rows.Count - 1 do 310 with TXmlTag(SubElements.AddNew(TXmlTag.Create)) do begin 311 Name := 'tr'; 312 for Column := 0 to THtmlRow(Rows[Row]).Cells.Count - 1 do 313 with TXmlTag(SubElements.AddNew(TXmlTag.Create)) do begin 314 Name := 'td'; 315 SubElements.Add(THtmlCell(THtmlRow(Rows[Row]).Cells[Column]).Value); 316 end; 317 end; 351 SubElements.AddNew(THtmlRow(Rows[Row]).AsXmlElement); 318 352 end; 319 353 end; … … 363 397 Attributes.Add('type', InputTypeString); 364 398 Attributes.Add('value', Value); 365 Attributes.Add('name', Name); 366 end; 399 if Self.Name <> '' then 400 Attributes.Add('name', Self.Name); 401 end; 402 end; 403 404 procedure THtmlInput.Assign(Source: THtmlElement); 405 begin 406 inherited Assign(Source); 407 InputType := THtmlInput(Source).InputType; 408 Value := THtmlInput(Source).Value; 367 409 end; 368 410 … … 523 565 end; 524 566 567 procedure THtmlElement.Assign(Source: THtmlElement); 568 begin 569 Id := Source.Id; 570 Name := Source.Name; 571 ClassId := Source.ClassId; 572 Style := Source.Style; 573 end; 574 525 575 { TIpAddress } 526 576 … … 707 757 end; 708 758 759 procedure THtmlString.Assign(Source: THtmlElement); 760 begin 761 inherited Assign(Source); 762 Text := THtmlString(Source).Text; 763 end; 764 709 765 { THostAddress } 710 766
Note:
See TracChangeset
for help on using the changeset viewer.