filters
cell.cc
00001 /* 00002 ** A program to convert the XML rendered by KSpread into LATEX. 00003 ** 00004 ** Copyright (C) 2002, 2003 Robert JACOLIN 00005 ** 00006 ** This library is free software; you can redistribute it and/or 00007 ** modify it under the terms of the GNU Library General Public 00008 ** License as published by the Free Software Foundation; either 00009 ** version 2 of the License, or (at your option) any later version. 00010 ** 00011 ** This library is distributed in the hope that it will be useful, 00012 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 ** Library General Public License for more details. 00015 ** 00016 ** To receive a copy of the GNU Library General Public License, write to the 00017 ** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 ** 00020 */ 00021 00022 #include <kdebug.h> /* for kdDebug stream */ 00023 00024 #include "cell.h" 00025 #include "table.h" 00026 #include "column.h" 00027 00028 /*******************************************/ 00029 /* Constructor */ 00030 /*******************************************/ 00031 Cell::Cell(): Format() 00032 { 00033 setCol(0); 00034 setRow(0); 00035 setText(""); 00036 setTextDataType("none"); 00037 setResultDataType("none"); 00038 } 00039 00040 /*******************************************/ 00041 /* Destructor */ 00042 /*******************************************/ 00043 Cell::~Cell() 00044 { 00045 } 00046 00047 void Cell::analyse(const QDomNode balise) 00048 { 00049 _row = getAttr(balise, "row").toLong(); 00050 _col = getAttr(balise, "column").toLong(); 00051 kdDebug(30522) << getRow() << "-" << getCol() << endl; 00052 Format::analyse(getChild(balise, "format")); 00053 analyseText(balise); 00054 } 00055 00056 void Cell::analyseText(const QDomNode balise) 00057 { 00058 setTextDataType( getAttr(getChild(balise, "text"), "dataType")); 00059 setText(getData(balise, "text")); 00060 kdDebug(30522) << "text(" << getTextDataType() << "): " << getText() << endl; 00061 } 00062 00063 /*******************************************/ 00064 /* generate */ 00065 /*******************************************/ 00066 void Cell::generate(QTextStream& out, Table* table) 00067 { 00068 /*if(getMulticol() > 0) 00069 out << "\\multicol{" << getMulticol() << "}{"; 00070 else*/ if (getMultirow() > 0) 00071 out << "\\multirow{" << getMultirow() << "}{"; 00072 kdDebug(30522) << "Generate cell..." << endl; 00073 00074 out << "\\multicolumn{1}{"; 00075 Format::generate(out, table->searchColumn(_col)); 00076 out << "}{" << endl; 00077 00078 if(getTextDataType() == "Str") 00079 { 00080 generateTextFormat(out, getText()); 00081 //out << getText(); 00082 } 00083 00084 out << "}" << endl; 00085 00086 /*if(getColSpan() > 0) 00087 out << "}" << endl; 00088 else*/ if (getMultirow() > 0) 00089 out << "}" << endl; 00090 00091 /*Element* elt = 0; 00092 kdDebug(30522) << "GENERATION OF A TABLE " << count() << endl; 00093 out << endl << "\\begin{tabular}"; 00094 generateCellHeader(out); 00095 out << endl; 00096 indent(); 00097 00098 int row= 0; 00099 while(row <= getMaxRow()) 00100 { 00101 generateTopLineBorder(out, row); 00102 for(int col= 0; col <= getMaxCol(); col++) 00103 { 00104 writeIndent(out); 00105 */ 00106 /* Search the cell in the list */ 00107 /* elt = searchCell(row, col); 00108 00109 out << "\\multicolumn{1}{"; 00110 if(elt->hasLeftBorder()) 00111 out << "|"; 00112 out << "m{" << getCellSize(col) << "pt}"; 00113 00114 if(elt->hasRightBorder()) 00115 out << "|"; 00116 out << "}{" << endl; 00117 00118 generateCell(out, row, col); 00119 out << "}" << endl; 00120 if(col < getMaxCol()) 00121 out << "&" << endl; 00122 } 00123 out << "\\\\" << endl; 00124 writeIndent(out); 00125 row = row + 1; 00126 } 00127 generateBottomLineBorder(out, row - 1); 00128 out << "\\end{tabular}" << endl << endl; 00129 desindent();*/ 00130 kdDebug(30522) << "END OF GENERATINO OF A CELL" << endl; 00131 } 00132