filters

latex/export/cell.cpp
1/*
2** A program to convert the XML rendered by KSpread into LATEX.
3**
4** Copyright (C) 2002, 2003 Robert JACOLIN
5**
6** This library is free software; you can redistribute it and/or
7** modify it under the terms of the GNU Library General Public
8** License as published by the Free Software Foundation; either
9** version 2 of the License, or (at your option) any later version.
10**
11** This library is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14** Library General Public License for more details.
15**
16** To receive a copy of the GNU Library General Public License, write to the
17** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19**
20*/
21
22#include <kdebug.h> /* for kdDebug stream */
23
24#include "cell.h"
25#include "table.h"
26#include "column.h"
27
28/*******************************************/
29/* Constructor */
30/*******************************************/
31Cell::Cell(): Format()
32{
33 setCol(0);
34 setRow(0);
35 setText("");
36 setTextDataType("none");
37 setResultDataType("none");
38}
39
40/*******************************************/
41/* Destructor */
42/*******************************************/
43Cell::~Cell()
44{
45}
46
47void Cell::analyse(const TQDomNode balise)
48{
49 _row = getAttr(balise, "row").toLong();
50 _col = getAttr(balise, "column").toLong();
51 kdDebug(30522) << getRow() << "-" << getCol() << endl;
52 Format::analyse(getChild(balise, "format"));
53 analyseText(balise);
54}
55
56void Cell::analyseText(const TQDomNode balise)
57{
58 setTextDataType( getAttr(getChild(balise, "text"), "dataType"));
59 setText(getData(balise, "text"));
60 kdDebug(30522) << "text(" << getTextDataType() << "): " << getText() << endl;
61}
62
63/*******************************************/
64/* generate */
65/*******************************************/
66void Cell::generate(TQTextStream& out, Table* table)
67{
68 /*if(getMulticol() > 0)
69 out << "\\multicol{" << getMulticol() << "}{";
70 else*/ if (getMultirow() > 0)
71 out << "\\multirow{" << getMultirow() << "}{";
72 kdDebug(30522) << "Generate cell..." << endl;
73
74 out << "\\multicolumn{1}{";
75 Format::generate(out, table->searchColumn(_col));
76 out << "}{" << endl;
77
78 if(getTextDataType() == "Str")
79 {
80 generateTextFormat(out, getText());
81 //out << getText();
82 }
83
84 out << "}" << endl;
85
86 /*if(getColSpan() > 0)
87 out << "}" << endl;
88 else*/ if (getMultirow() > 0)
89 out << "}" << endl;
90
91 /*Element* elt = 0;
92 kdDebug(30522) << "GENERATION OF A TABLE " << count() << endl;
93 out << endl << "\\begin{tabular}";
94 generateCellHeader(out);
95 out << endl;
96 indent();
97
98 int row= 0;
99 while(row <= getMaxRow())
100 {
101 generateTopLineBorder(out, row);
102 for(int col= 0; col <= getMaxCol(); col++)
103 {
104 writeIndent(out);
105 */
106 /* Search the cell in the list */
107 /* elt = searchCell(row, col);
108
109 out << "\\multicolumn{1}{";
110 if(elt->hasLeftBorder())
111 out << "|";
112 out << "m{" << getCellSize(col) << "pt}";
113
114 if(elt->hasRightBorder())
115 out << "|";
116 out << "}{" << endl;
117
118 generateCell(out, row, col);
119 out << "}" << endl;
120 if(col < getMaxCol())
121 out << "&" << endl;
122 }
123 out << "\\\\" << endl;
124 writeIndent(out);
125 row = row + 1;
126 }
127 generateBottomLineBorder(out, row - 1);
128 out << "\\end{tabular}" << endl << endl;
129 desindent();*/
130 kdDebug(30522) << "END OF GENERATINO OF A CELL" << endl;
131}
132
This class describe a cell, row or column format.
long getMultirow() const
getters
void generate(TQTextStream &out, Column *col=NULL, Row *row=NULL)
Generate the cell format inherited from the row or the colum format or use its own format.
virtual void analyse(const TQDomNode)
Helpfull functions.
void generateTextFormat(TQTextStream &out, TQString text)
Generate the text cell format (color and font).
This class hold a table.
Column * searchColumn(int col)
Return one specific column which describe the format of the column.