23#include <tqbitarray.h>
45void Table::setMaxColumn(
int col)
47 if(_maxCol < col) _maxCol = col;
52 if(_maxRow < row) _maxRow = row;
57 kdDebug(30522) <<
"New table" << endl;
58 if(getAttr(balise,
"columnnumber") ==
"1")
60 if(getAttr(balise,
"borders") ==
"1")
62 if(getAttr(balise,
"hide") ==
"1")
64 if(getAttr(balise,
"hidezero") ==
"1")
66 if(getAttr(balise,
"firstletterupper") ==
"1")
67 setFirstletterupper();
68 if(getAttr(balise,
"grid") ==
"1")
70 if(getAttr(balise,
"printgrid") ==
"1")
72 if(getAttr(balise,
"printCommentIndicator") ==
"1")
73 setPrintCommentIndicator();
74 if(getAttr(balise,
"printFormulaIndicator") ==
"1")
75 setPrintFormulaIndicator();
76 if(getAttr(balise,
"showFormula") ==
"1")
78 if(getAttr(balise,
"showFormulaIndicator") ==
"1")
79 setShowFormulaIndicator();
80 if(getAttr(balise,
"lcmode") ==
"1")
82 setName(getAttr(balise,
"name"));
84 analysePaper(getChild(balise,
"paper"));
86 int max = getNbChild(balise);
87 for(
int index = 0; index < max; index++)
89 TQString name = getChildName(balise, index);
92 kdDebug(30522) <<
"----- cell -----" << endl;
93 Cell* cell =
new Cell();
94 cell->analyse(getChild(balise, index));
96 setMaxColumn(cell->getCol());
99 else if(name ==
"column")
101 kdDebug(30522) <<
"----- column -----" << endl;
103 column->
analyse(getChild(balise, index));
104 _columns.append(column);
106 else if(name ==
"row")
108 kdDebug(30522) <<
"----- row -----" << endl;
110 row->
analyse(getChild(balise, index));
114 kdDebug(30522) <<
"name : " << name << endl;
118void Table::analysePaper(
const TQDomNode balise)
120 setFormat(getAttr(balise,
"format"));
121 setOrientation(getAttr(balise,
"orientation"));
124 TQDomNode border = getChild(balise,
"borders");
125 setBorderRight(getAttr(balise,
"right").toLong());
126 setBorderLeft(getAttr(balise,
"left").toLong());
127 setBorderBottom(getAttr(balise,
"bottom").toLong());
128 setBorderTop(getAttr(balise,
"top").toLong());
133 TQPtrListIterator<Cell> it(_cells);
135 kdDebug(30522) <<
"search in list of " << _cells.count() <<
" cells" << endl;
137 while ( (cell = it.current()) != 0 )
140 kdDebug(30522) <<
"cell: " << cell->getRow() <<
"-" << cell->getCol() << endl;
141 if(cell->getCol() == col && cell->getRow() == row)
149 TQPtrListIterator<Column> it(_columns);
152 while ( (column = it.current()) != 0 )
155 if(column->
getCol() == col)
163 TQPtrListIterator<Row> it(_rows);
166 while ( (row = it.current()) != 0 )
169 if(row->
getRow() == rowNumber)
178void Table::generate(TQTextStream& out)
180 kdDebug(30522) <<
"GENERATION OF A TABLE " <<
getMaxRow() <<
" - " << getMaxColumn()
182 out << endl <<
"%% " << getName() << endl;
183 if(getOrientation() ==
"Portrait")
185 out <<
"\\begin{sidewaystable}" << endl << endl;
190 out <<
"\\begin{tabular}";
191 generateTableHeader(out);
197 generateTopLineBorder(out, rowNumber);
202 for(
int col = 1; col <= getMaxColumn(); col++)
205 generateCell(out, rowNumber, col);
207 if(col < getMaxColumn())
210 out <<
"\\\\" << endl;
213 generateBottomLineBorder(out, rowNumber - 1);
216 out <<
"\\end{tabular}" << endl << endl;
219 if(getOrientation() ==
"Portrait")
221 out <<
"\\end{sidewaystable}" << endl;
263 kdDebug(30522) <<
"END OF GENERATINO OF A TABLE" << endl;
269void Table::generateTopLineBorder(TQTextStream& out,
int row)
273 TQBitArray border( getMaxColumn() );
274 bool fullLine =
true;
275 for(
int index = 1; index <= getMaxColumn(); index++)
278 kdDebug(30522) <<
"search " << row <<
", " << index << endl;
282 cell =
new Cell(row, index);
285 border[ index ] = cell->hasTopBorder();
286 if( ! cell->hasTopBorder() )
294 out <<
"\\hline" << endl;
299 while(index < getMaxColumn())
306 while(border[index] && index < getMaxColumn())
311 out <<
"\\cline{" << begin <<
"-" << end <<
"} " << endl;
326void Table::generateBottomLineBorder(TQTextStream& out,
int row)
329 TQBitArray border( getMaxColumn() );
330 bool fullLine =
true;
332 for(
int index = 1; index <= getMaxColumn(); index++)
338 cell =
new Cell(row, index);
341 border[ index ] = cell->hasBottomBorder();
342 if( ! cell->hasBottomBorder() )
350 out <<
"\\hline" << endl;
355 while(index < getMaxColumn())
362 while(border[index] && index < getMaxColumn())
367 out <<
"\\cline{" << begin <<
"-" << end <<
"} " << endl;
377void Table::generateCell(TQTextStream& out,
int row,
int col)
379 kdDebug(30522) <<
"GENERATE CELL : " << row <<
"," << col << endl;
385 kdDebug(30522) <<
"generate cell with text: " << cell->getText() << endl;
386 cell->generate(out,
this);
389 kdDebug(30522) <<
"END OF A CELL" << endl;
395void Table::generateTableHeader(TQTextStream& out)
401 for(
int col = 1; col <= getMaxColumn(); col++)
405 column->generate(out);
This class hold a column.
void analyse(const TQDomNode)
Helpfull functions.
long getCol() const
getters
void analyse(const TQDomNode)
Helpfull functions.
long getRow() const
getters
Cell * searchCell(int col, int row)
Helpfull functions.
Column * searchColumn(int col)
Return one specific column which describe the format of the column.
int getMaxRow() const
getters
Row * searchRow(int row)
Return one specific row which describe the format of the row.
void analyse(const TQDomNode)
Helpfull functions.
void setMaxRow(int r)
setters