1 |
bearsoft |
1.1 |
#include "Table.h" |
2 |
|
|
#include "../System/System.h" |
3 |
|
|
#include "../System/SystemDefine.h" |
4 |
|
|
#include "../Array/ObjectArray.h"
|
5 |
|
|
|
6 |
|
|
Table::Table() |
7 |
|
|
{
|
8 |
|
|
data = new String();
|
9 |
|
|
tableList = new StringLinkedList();
|
10 |
|
|
center=false; |
11 |
|
|
width=0;
|
12 |
|
|
height=0;
|
13 |
|
|
border=0;
|
14 |
|
|
cellspacing=0;
|
15 |
|
|
cellpadding=0;
|
16 |
|
|
tableHaveBeenAdded=false;
|
17 |
|
|
align = new String("left");
|
18 |
|
|
} |
19 |
|
|
|
20 |
|
|
Table::~Table() |
21 |
|
|
{
|
22 |
|
|
if (data!=null)
|
23 |
|
|
{
|
24 |
|
|
delete data;
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
if (tableList!=null)
|
28 |
|
|
{
|
29 |
|
|
delete tableList;
|
30 |
|
|
} |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
void Table::create()
|
34 |
|
|
{
|
35 |
|
|
String start="<table ";
|
36 |
|
|
String end="</table>";
|
37 |
|
|
String tStart;
|
38 |
|
|
String tEnd;
|
39 |
|
|
|
40 |
|
|
int size=tableList->size();
|
41 |
|
|
|
42 |
|
|
String tableData;
|
43 |
|
|
|
44 |
|
|
for ( int i=0; i<size ; i++ )
|
45 |
|
|
{
|
46 |
|
|
tableData+=tableList->getElement(i);
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
if (tableHaveBeenAdded)
|
50 |
|
|
{
|
51 |
|
|
tStart+="<td><tr>";
|
52 |
|
|
tEnd+="</td></tr>";
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
String widthData;
|
56 |
|
|
|
57 |
|
|
if (width>0)
|
58 |
|
|
{
|
59 |
|
|
widthData+="width=";
|
60 |
|
|
widthData+=width;
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
String heightData;
|
64 |
|
|
|
65 |
|
|
if (height>0)
|
66 |
|
|
{
|
67 |
|
|
heightData+="height=";
|
68 |
|
|
heightData+=height;
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
data->setString(start + widthData + heightData + " border=" + border + " cellspacing=" + cellspacing + " cellpadding=" + cellpadding + " align=" + align + ">" + tStart + tableData + tEnd + end);
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
void Table::createRows(StringLinkedList *list)
|
76 |
|
|
{
|
77 |
|
|
String rows;
|
78 |
|
|
|
79 |
|
|
int size=list->size();
|
80 |
|
|
|
81 |
|
|
for ( int i=0; i<size ; i++ )
|
82 |
|
|
{
|
83 |
|
|
rows+="<tr><td>";
|
84 |
|
|
rows+=list->getElement(i);
|
85 |
|
|
rows+="</td></tr>";
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
tableList->addLast(rows);
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
void Table::createMatris(HtmlMatrisList<String> *htmlMatris)
|
92 |
|
|
{
|
93 |
|
|
createMatris(htmlMatris, 0);
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
void Table::createMatris(HtmlMatrisList<String> *htmlMatris, int column)
|
97 |
|
|
{
|
98 |
|
|
String rows;
|
99 |
|
|
|
100 |
|
|
int rowSize=htmlMatris->rowSize();
|
101 |
|
|
int columnSize=htmlMatris->columnSize();
|
102 |
|
|
|
103 |
|
|
// System::println(rowSize);
|
104 |
|
|
// System::println(columnSize);
|
105 |
|
|
|
106 |
|
|
for ( int r=0; r<rowSize ; r++)
|
107 |
|
|
{
|
108 |
|
|
ObjectArray<String> *objectArray=htmlMatris->getRow(column,r);
|
109 |
|
|
|
110 |
|
|
rows+="<tr>";
|
111 |
|
|
|
112 |
|
|
for ( int i=0; i<columnSize ; i++)
|
113 |
|
|
{
|
114 |
|
|
// rows+="<td>";
|
115 |
|
|
rows+=objectArray->getObject(i);
|
116 |
|
|
// rows+="</td>";
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
rows+="</tr>";
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
htmlMatris->objectArray->resetArray();
|
123 |
|
|
|
124 |
|
|
tableList->addLast(rows);
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
void Table::addTable(Table *table)
|
128 |
|
|
{
|
129 |
|
|
int size=table->tableList->size();
|
130 |
|
|
|
131 |
|
|
if (size!=0)
|
132 |
|
|
{
|
133 |
|
|
for ( int i=0; i<size ; i++ )
|
134 |
|
|
{
|
135 |
|
|
tableList->addLast(table->tableList->getElement(i));
|
136 |
|
|
}
|
137 |
|
|
}
|
138 |
|
|
else
|
139 |
|
|
{
|
140 |
|
|
tableList->addLast("<tr><td></tr></td>");
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
tableHaveBeenAdded=true;
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
void Table::addTable(Table &table)
|
147 |
|
|
{
|
148 |
|
|
int size=table.tableList->size();
|
149 |
|
|
|
150 |
|
|
if (size!=0)
|
151 |
|
|
{
|
152 |
|
|
for ( int i=0; i<size ; i++ )
|
153 |
|
|
{
|
154 |
|
|
tableList->addLast(table.tableList->getElement(i));
|
155 |
|
|
}
|
156 |
|
|
}
|
157 |
|
|
else
|
158 |
|
|
{
|
159 |
|
|
tableList->addLast("<tr><td></tr></td>");
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
tableHaveBeenAdded=true;
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|