summaryrefslogtreecommitdiffstats
path: root/filters/kspread/latex/export/cell.cpp
blob: 74eb95bb6338991a9bd12fbec9f3949f66b79715 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
** A program to convert the XML rendered by KSpread into LATEX.
**
** Copyright (C) 2002, 2003 Robert JACOLIN
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** Library General Public License for more details.
**
** To receive a copy of the GNU Library General Public License, write to the
** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
**
*/

#include <kdebug.h>		/* for kdDebug stream */

#include "cell.h"
#include "table.h"
#include "column.h"

/*******************************************/
/* Constructor                             */
/*******************************************/
Cell::Cell(): Format()
{
	setCol(0);
	setRow(0);
	setText("");
	setTextDataType("none");
	setResultDataType("none");
}

/*******************************************/
/* Destructor                              */
/*******************************************/
Cell::~Cell()
{
}

void Cell::analyse(const TQDomNode balise)
{
	_row = getAttr(balise, "row").toLong();
	_col = getAttr(balise, "column").toLong();
	kdDebug(30522) << getRow() << "-" << getCol() << endl;
	Format::analyse(getChild(balise, "format"));
	analyseText(balise);
}

void Cell::analyseText(const TQDomNode balise)
{
	setTextDataType( getAttr(getChild(balise, "text"), "dataType"));	
	setText(getData(balise, "text"));
	kdDebug(30522) << "text(" << getTextDataType() << "): " << getText() << endl;
}

/*******************************************/
/* generate                                */
/*******************************************/
void Cell::generate(TQTextStream& out, Table* table)
{
	/*if(getMulticol() > 0)
		out << "\\multicol{" << getMulticol() << "}{";
	else*/ if (getMultirow() > 0)
		out << "\\multirow{" << getMultirow() << "}{";
	kdDebug(30522) << "Generate cell..." << endl;

	out << "\\multicolumn{1}{";
	Format::generate(out, table->searchColumn(_col));
	out << "}{" << endl;
	
	if(getTextDataType() == "Str")
	{
		generateTextFormat(out, getText());
		//out << getText();
	}
	
	out << "}" << endl;
	
	/*if(getColSpan() > 0)
		out << "}" << endl;
	else*/ if (getMultirow() > 0)
		out << "}" << endl;
	
		/*Element* elt = 0;
	kdDebug(30522) << "GENERATION OF A TABLE " << count() << endl;
	out << endl << "\\begin{tabular}";
	generateCellHeader(out);
	out << endl;
	indent();

	int row= 0;
	while(row <= getMaxRow())
	{
		generateTopLineBorder(out, row);
		for(int col= 0; col <= getMaxCol(); col++)
		{
			writeIndent(out);
	*/
			/* Search the cell in the list */
		/*	elt = searchCell(row, col);

			out << "\\multicolumn{1}{";
			if(elt->hasLeftBorder())
				out << "|";
			out << "m{" << getCellSize(col) << "pt}";
			
			if(elt->hasRightBorder())
				out << "|";
			out << "}{" << endl;

			generateCell(out, row, col);
			out << "}" << endl;
			if(col < getMaxCol())
				out << "&" << endl;
		}
		out << "\\\\" << endl;
		writeIndent(out);
		row = row + 1;
	}
	generateBottomLineBorder(out, row - 1);
	out << "\\end{tabular}" << endl << endl;
	desindent();*/
	kdDebug(30522) << "END OF GENERATINO OF A CELL" << endl;
}