1 |
bearsoft |
1.1 |
#ifndef __HtmlMatrisList_H__
|
2 |
|
|
#define __HtmlMatrisList_H__
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
#include "../String/String.h"
|
6 |
|
|
#include "../LinkedList/StringLinkedList.h"
|
7 |
|
|
#include "../LinkedList/ObjectLinkedList.h"
|
8 |
|
|
#include "../Element/ObjectElement.h"
|
9 |
|
|
#include "../Element/ObjectMatrisElement.h"
|
10 |
|
|
#include "../System/System.h"
|
11 |
|
|
#include "../Array/ObjectArray.h"
|
12 |
|
|
#include "../System/SystemDefine.h"
|
13 |
|
|
#include "Link.h"
|
14 |
|
|
#include "Picture.h"
|
15 |
|
|
|
16 |
|
|
template <class ClassName>
|
17 |
|
|
|
18 |
|
|
class HtmlMatrisList
|
19 |
|
|
{
|
20 |
|
|
|
21 |
|
|
public:
|
22 |
|
|
|
23 |
|
|
HtmlMatrisList(int iColumnSize)
|
24 |
|
|
{
|
25 |
|
|
howfar=0;
|
26 |
|
|
columnLength=iColumnSize;
|
27 |
|
|
objectArray = new ObjectArray<ClassName>(columnLength);
|
28 |
|
|
|
29 |
|
|
for ( int i=0; i<columnLength ; i++ )
|
30 |
|
|
{
|
31 |
|
|
addColumn(1,"test");
|
32 |
|
|
}
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
~HtmlMatrisList()
|
36 |
|
|
{
|
37 |
|
|
removeAllElement();
|
38 |
|
|
|
39 |
|
|
if (objectArray != null)
|
40 |
|
|
{
|
41 |
|
|
objectArray->resetArray();
|
42 |
|
|
|
43 |
|
|
delete objectArray;
|
44 |
|
|
}
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
void removeAllElement()
|
48 |
|
|
{
|
49 |
|
|
if ( howfar != 0 )
|
50 |
|
|
{
|
51 |
|
|
ObjectMatrisElement<ClassName> *element=first;
|
52 |
|
|
|
53 |
|
|
for ( int s=0; s<howfar ; s++ )
|
54 |
|
|
{
|
55 |
|
|
ObjectMatrisElement<ClassName> *tempElement=element->next;
|
56 |
|
|
delete element;
|
57 |
|
|
element=tempElement;
|
58 |
|
|
}
|
59 |
|
|
}
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
int columnSize()
|
63 |
|
|
{
|
64 |
|
|
return howfar;
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
int rowSize()
|
68 |
|
|
{
|
69 |
|
|
if (howfar!=0)
|
70 |
|
|
{
|
71 |
|
|
ObjectLinkedList<ClassName> *objectList = getColumn(0);
|
72 |
|
|
return objectList->size();
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
return 0;
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
void addColumnInRow(const Link &object, String &iName ,int index)
|
80 |
|
|
{
|
81 |
|
|
if ( index >= 0 && index < columnLength )
|
82 |
|
|
{
|
83 |
|
|
String htmlData="<td>";
|
84 |
|
|
htmlData+=object.data;
|
85 |
|
|
htmlData+="</td>";
|
86 |
|
|
objectArray->setObject(new String(htmlData), iName.buffer, index);
|
87 |
|
|
}
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
void addColumnInRow(const Link &object, String *iName ,int index)
|
91 |
|
|
{
|
92 |
|
|
if ( index >= 0 && index < columnLength )
|
93 |
|
|
{
|
94 |
|
|
String htmlData="<td>";
|
95 |
|
|
htmlData+=object.data;
|
96 |
|
|
htmlData+="</td>";
|
97 |
|
|
objectArray->setObject(new String(htmlData), iName->buffer, index);
|
98 |
|
|
}
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
void addColumnInRow(const Link &object, char *iName ,int index)
|
102 |
|
|
{
|
103 |
|
|
if ( index >= 0 && index < columnLength )
|
104 |
|
|
{
|
105 |
|
|
String htmlData="<td>";
|
106 |
|
|
htmlData+=object.data;
|
107 |
|
|
htmlData+="</td>";
|
108 |
|
|
objectArray->setObject(new String(htmlData), iName, index);
|
109 |
|
|
}
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
void addColumnInRow(Link *object, String &iName ,int index)
|
113 |
|
|
{
|
114 |
|
|
if ( index >= 0 && index < columnLength )
|
115 |
|
|
{
|
116 |
|
|
String htmlData="<td>";
|
117 |
|
|
htmlData+=object->data;
|
118 |
|
|
htmlData+="</td>";
|
119 |
|
|
objectArray->setObject(new String(htmlData), iName.buffer, index);
|
120 |
|
|
}
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
void addColumnInRow(Link *object, String *iName ,int index)
|
124 |
|
|
{
|
125 |
|
|
if ( index >= 0 && index < columnLength )
|
126 |
|
|
{
|
127 |
|
|
String htmlData="<td>";
|
128 |
|
|
htmlData+=object->data;
|
129 |
|
|
htmlData+="</td>";
|
130 |
|
|
objectArray->setObject(new String(htmlData), iName->buffer, index);
|
131 |
|
|
}
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
void addColumnInRow(Link *object, char *iName ,int index)
|
135 |
|
|
{
|
136 |
|
|
if ( index >= 0 && index < columnLength )
|
137 |
|
|
{
|
138 |
|
|
String htmlData="<td>";
|
139 |
|
|
htmlData+=object->data;
|
140 |
|
|
htmlData+="</td>";
|
141 |
|
|
objectArray->setObject(new String(htmlData), iName, index);
|
142 |
|
|
}
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
void addColumnInRow(const String &iName ,int index)
|
146 |
|
|
{
|
147 |
|
|
if ( index >= 0 && index < columnLength )
|
148 |
|
|
{
|
149 |
|
|
String htmlData="<td>";
|
150 |
|
|
htmlData+=iName;
|
151 |
|
|
htmlData+="</td>";
|
152 |
|
|
objectArray->setObject(new String(htmlData), iName.buffer, index);
|
153 |
|
|
}
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
void addColumnInRow(String *iName ,int index)
|
157 |
|
|
{
|
158 |
|
|
if ( index >= 0 && index < columnLength )
|
159 |
|
|
{
|
160 |
|
|
String htmlData="<td>";
|
161 |
|
|
htmlData+=iName;
|
162 |
|
|
htmlData+="</td>";
|
163 |
|
|
objectArray->setObject(new String(htmlData), iName->buffer, index);
|
164 |
|
|
}
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
void addColumnInRow(char *iName ,int index)
|
168 |
|
|
{
|
169 |
|
|
if ( index >= 0 && index < columnLength )
|
170 |
|
|
{
|
171 |
|
|
String htmlData="<td>";
|
172 |
|
|
htmlData+=iName;
|
173 |
|
|
htmlData+="</td>";
|
174 |
|
|
objectArray->setObject(new String(htmlData), iName, index);
|
175 |
|
|
}
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
void addColumnInRow(char *iName, int height, int index)
|
179 |
|
|
{
|
180 |
|
|
if ( index >= 0 && index < columnLength )
|
181 |
|
|
{
|
182 |
|
|
String htmlData="<td height=";
|
183 |
|
|
htmlData+=height;
|
184 |
|
|
htmlData+=">";
|
185 |
|
|
htmlData+=iName;
|
186 |
|
|
htmlData+="</td>";
|
187 |
|
|
|
188 |
|
|
objectArray->setObject(new String(htmlData), iName, index);
|
189 |
|
|
}
|
190 |
|
|
}
|
191 |
|
|
|
192 |
|
|
void addColumnInRow(Picture &picture, int height, int index)
|
193 |
|
|
{
|
194 |
|
|
if ( index >= 0 && index < columnLength )
|
195 |
|
|
{
|
196 |
|
|
String htmlData="<td height=";
|
197 |
|
|
htmlData+=height;
|
198 |
|
|
htmlData+=">";
|
199 |
|
|
htmlData+=picture.data;
|
200 |
|
|
htmlData+="</td>";
|
201 |
|
|
|
202 |
|
|
objectArray->setObject(new String(htmlData), picture.info->buffer, index);
|
203 |
|
|
}
|
204 |
|
|
}
|
205 |
|
|
|
206 |
|
|
void addColumnInRow(Link &link, int height, int index)
|
207 |
|
|
{
|
208 |
|
|
if ( index >= 0 && index < columnLength )
|
209 |
|
|
{
|
210 |
|
|
String htmlData="<td height=";
|
211 |
|
|
htmlData+=height;
|
212 |
|
|
htmlData+=">";
|
213 |
|
|
htmlData+=link.data;
|
214 |
|
|
htmlData+="</td>";
|
215 |
|
|
|
216 |
|
|
objectArray->setObject(new String(htmlData), link.info->buffer, index);
|
217 |
|
|
}
|
218 |
|
|
}
|
219 |
|
|
|
220 |
|
|
void addColumn(int type, char *iName)
|
221 |
|
|
{
|
222 |
|
|
addColumnMain(type, iName);
|
223 |
|
|
}
|
224 |
|
|
|
225 |
|
|
void addColumnMain(int type, char *iName)
|
226 |
|
|
{
|
227 |
|
|
if (howfar == 0)
|
228 |
|
|
{
|
229 |
|
|
first = new ObjectMatrisElement<ClassName>(iName);
|
230 |
|
|
last=first;
|
231 |
|
|
}
|
232 |
|
|
else
|
233 |
|
|
{
|
234 |
|
|
last->next = new ObjectMatrisElement<ClassName>(iName);
|
235 |
|
|
last->next->previos=last;
|
236 |
|
|
last=last->next;
|
237 |
|
|
}
|
238 |
|
|
|
239 |
|
|
howfar++;
|
240 |
|
|
}
|
241 |
|
|
|
242 |
|
|
void addRow()
|
243 |
|
|
{
|
244 |
|
|
ObjectLinkedList<ClassName> *objectList=null;
|
245 |
|
|
|
246 |
|
|
for ( int i=0; i<howfar ; i++ )
|
247 |
|
|
{
|
248 |
|
|
objectList = getColumn(i);
|
249 |
|
|
ObjectElement<ClassName> *object=objectArray->getObjectElement(i);
|
250 |
|
|
objectList->addLast(object->classNameElement,object->name);
|
251 |
|
|
}
|
252 |
|
|
|
253 |
|
|
int size=objectList->size()-1;
|
254 |
|
|
|
255 |
|
|
for ( int r=0; r<howfar ; r++ )
|
256 |
|
|
{
|
257 |
|
|
ObjectLinkedList<ClassName> *objectList = getColumn(r);
|
258 |
|
|
ObjectLinkedList<ClassName> *objectListPrevios = getColumn(r-1);
|
259 |
|
|
ObjectLinkedList<ClassName> *objectListNext = getColumn(r+1);
|
260 |
|
|
|
261 |
|
|
ObjectElement<ClassName> *object=objectList->getObjectElement(size);
|
262 |
|
|
|
263 |
|
|
ObjectElement<ClassName> *objectPrevios=null;
|
264 |
|
|
|
265 |
|
|
if (objectListPrevios!=null)
|
266 |
|
|
{
|
267 |
|
|
objectPrevios=objectListPrevios->getObjectElement(size);
|
268 |
|
|
}
|
269 |
|
|
|
270 |
|
|
ObjectElement<ClassName> *objectNext=null;
|
271 |
|
|
|
272 |
|
|
if (objectListNext!=null)
|
273 |
|
|
{
|
274 |
|
|
objectNext=objectListNext->getObjectElement(size);
|
275 |
|
|
}
|
276 |
|
|
|
277 |
|
|
object->sideNext=objectNext;
|
278 |
|
|
object->sidePrevios=objectPrevios;
|
279 |
|
|
}
|
280 |
|
|
|
281 |
|
|
objectArray->resetArray();
|
282 |
|
|
}
|
283 |
|
|
|
284 |
|
|
ObjectArray<ClassName> *getRow(int columnIndex, int rowIndex)
|
285 |
|
|
{
|
286 |
|
|
objectArray->resetArray();
|
287 |
|
|
|
288 |
|
|
ObjectLinkedList<ClassName> *objectList = getColumn(columnIndex);
|
289 |
|
|
ObjectElement<ClassName> *objectElementIndex = objectList->getObjectElement(rowIndex);
|
290 |
|
|
|
291 |
|
|
ObjectElement<ClassName> *objectElement=objectElementIndex;
|
292 |
|
|
|
293 |
|
|
int indexBack=columnIndex;
|
294 |
|
|
|
295 |
|
|
for (int i=0; i<columnIndex ; i++)
|
296 |
|
|
{
|
297 |
|
|
--indexBack;
|
298 |
|
|
objectElement=objectElement->sidePrevios;
|
299 |
|
|
// objectArray->setObject(objectElement->classNameElement, indexBack);
|
300 |
|
|
/*if (objectElement->classNameElement==null)
|
301 |
|
|
{
|
302 |
|
|
objectArray->setObject(objectElement->name, indexBack);
|
303 |
|
|
}
|
304 |
|
|
else
|
305 |
|
|
{*/
|
306 |
|
|
objectArray->setObject(objectElement->classNameElement, indexBack);
|
307 |
|
|
//}
|
308 |
|
|
}
|
309 |
|
|
|
310 |
|
|
objectElement=objectElementIndex;
|
311 |
|
|
|
312 |
|
|
// System::println(columnLength-columnIndex);
|
313 |
|
|
|
314 |
|
|
for (int r=0; r<(columnLength-columnIndex) ; r++)
|
315 |
|
|
{
|
316 |
|
|
// objectArray->setObject(objectElement->classNameElement, r+columnIndex);
|
317 |
|
|
/* if (objectElement->classNameElement==null)
|
318 |
|
|
{
|
319 |
|
|
objectArray->setObject(objectElement->name, r+columnIndex);
|
320 |
|
|
}
|
321 |
|
|
else
|
322 |
|
|
{*/
|
323 |
|
|
objectArray->setObject(objectElement->classNameElement, r+columnIndex);
|
324 |
|
|
//}
|
325 |
|
|
|
326 |
|
|
objectElement=objectElement->sideNext;
|
327 |
|
|
}
|
328 |
|
|
|
329 |
|
|
return objectArray;
|
330 |
|
|
}
|
331 |
|
|
|
332 |
|
|
void sortColumnInSmallestOrder(int index)
|
333 |
|
|
{
|
334 |
|
|
ObjectLinkedList<ClassName> *objectList = getColumn(index);
|
335 |
|
|
|
336 |
|
|
if (objectList!=null)
|
337 |
|
|
{
|
338 |
|
|
objectList->sortSmallestOrder();
|
339 |
|
|
}
|
340 |
|
|
}
|
341 |
|
|
|
342 |
|
|
void sortColumnInLargestOrder(int index)
|
343 |
|
|
{
|
344 |
|
|
ObjectLinkedList<ClassName> *objectList = getColumn(index);
|
345 |
|
|
|
346 |
|
|
if (objectList!=null)
|
347 |
|
|
{
|
348 |
|
|
objectList->sortLargestOrder();
|
349 |
|
|
}
|
350 |
|
|
}
|
351 |
|
|
|
352 |
|
|
void sortColumnInSmallestValueOrder(int index)
|
353 |
|
|
{
|
354 |
|
|
ObjectLinkedList<ClassName> *objectList = getColumn(index);
|
355 |
|
|
|
356 |
|
|
if (objectList!=null)
|
357 |
|
|
{
|
358 |
|
|
objectList->sortSmallestValueOrder();
|
359 |
|
|
}
|
360 |
|
|
}
|
361 |
|
|
|
362 |
|
|
void sortColumnInLargestValueOrder(int index)
|
363 |
|
|
{
|
364 |
|
|
ObjectLinkedList<ClassName> *objectList = getColumn(index);
|
365 |
|
|
|
366 |
|
|
if (objectList!=null)
|
367 |
|
|
{
|
368 |
|
|
objectList->sortLargestValueOrder();
|
369 |
|
|
}
|
370 |
|
|
}
|
371 |
|
|
|
372 |
|
|
ObjectLinkedList<ClassName> *getColumn(int index)
|
373 |
|
|
{
|
374 |
|
|
if ( index >= 0 && index < howfar)
|
375 |
|
|
{
|
376 |
|
|
ObjectMatrisElement<ClassName> *element=first;
|
377 |
|
|
|
378 |
|
|
for ( int s=0; s<index ; s++ )
|
379 |
|
|
{
|
380 |
|
|
element=element->next;
|
381 |
|
|
}
|
382 |
|
|
|
383 |
|
|
// stringLength=element->length;
|
384 |
|
|
|
385 |
|
|
return element->classNameElement;
|
386 |
|
|
}
|
387 |
|
|
|
388 |
|
|
return null;
|
389 |
|
|
}
|
390 |
|
|
|
391 |
|
|
|
392 |
|
|
ObjectMatrisElement<ClassName> *first;
|
393 |
|
|
ObjectMatrisElement<ClassName> *last;
|
394 |
|
|
|
395 |
|
|
int howfar;
|
396 |
|
|
int columnLength;
|
397 |
|
|
ObjectArray<ClassName> *objectArray;
|
398 |
|
|
|
399 |
|
|
};
|
400 |
|
|
|
401 |
|
|
#endif |