File indexing completed on 2025-02-16 13:49:56
0001 /* 0002 ** A program to convert the XML rendered by KSpread into LATEX. 0003 ** 0004 ** Copyright (C) 2002, 2003 Robert JACOLIN 0005 ** 0006 ** This library is free software; you can redistribute it and/or 0007 ** modify it under the terms of the GNU Library General Public 0008 ** License as published by the Free Software Foundation; either 0009 ** version 2 of the License, or (at your option) any later version. 0010 ** 0011 ** This library is distributed in the hope that it will be useful, 0012 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 ** Library General Public License for more details. 0015 ** 0016 ** To receive a copy of the GNU Library General Public License, write to the 0017 ** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 ** 0020 */ 0021 0022 #include "cell.h" 0023 0024 #include "LatexDebug.h" 0025 #include "table.h" 0026 #include "column.h" 0027 0028 #include <QTextStream> 0029 0030 /*******************************************/ 0031 /* Constructor */ 0032 /*******************************************/ 0033 Cell::Cell(): Format() 0034 { 0035 setCol(0); 0036 setRow(0); 0037 setText(""); 0038 setTextDataType("none"); 0039 setResultDataType("none"); 0040 } 0041 0042 /*******************************************/ 0043 /* Destructor */ 0044 /*******************************************/ 0045 Cell::~Cell() 0046 { 0047 } 0048 0049 void Cell::analyze(const QDomNode node) 0050 { 0051 _row = getAttr(node, "row").toLong(); 0052 _col = getAttr(node, "column").toLong(); 0053 debugLatex << getRow() << "-" << getCol(); 0054 Format::analyze(getChild(node, "format")); 0055 analyzeText(node); 0056 } 0057 0058 void Cell::analyzeText(const QDomNode node) 0059 { 0060 setTextDataType(getAttr(getChild(node, "text"), "dataType")); 0061 setText(getAttr(getChild(node, "text"), "outStr")); 0062 debugLatex << "text(" << getTextDataType() << "):" << getText(); 0063 } 0064 0065 /*******************************************/ 0066 /* generate */ 0067 /*******************************************/ 0068 void Cell::generate(QTextStream& out, Table* table) 0069 { 0070 /*if(getMulticol() > 0) 0071 out << "\\multicol{" << getMulticol() << "}{"; 0072 else*/ 0073 if (getMultirow() > 0) 0074 out << "\\multirow{" << getMultirow() << "}{"; 0075 debugLatex << "Generate cell..."; 0076 0077 out << "\\multicolumn{1}{"; 0078 Format::generate(out, table->searchColumn(_col)); 0079 out << "}{" << endl; 0080 0081 if (getTextDataType() == "Str" || getTextDataType() == "Num") { 0082 generateTextFormat(out, getText()); 0083 //out << getText(); 0084 } 0085 0086 out << "}" << endl; 0087 0088 /*if(getColSpan() > 0) 0089 out << "}" << endl; 0090 else*/ if (getMultirow() > 0) 0091 out << "}" << endl; 0092 0093 /*Element* elt = 0; 0094 debugLatex <<"GENERATION OF A TABLE" << count(); 0095 out << endl << "\\begin{tabular}"; 0096 generateCellHeader(out); 0097 out << endl; 0098 indent(); 0099 0100 int row= 0; 0101 while(row <= getMaxRow()) 0102 { 0103 generateTopLineBorder(out, row); 0104 for(int col= 0; col <= getMaxCol(); col++) 0105 { 0106 writeIndent(out); 0107 */ 0108 /* Search the cell in the list */ 0109 /* elt = searchCell(row, col); 0110 0111 out << "\\multicolumn{1}{"; 0112 if(elt->hasLeftBorder()) 0113 out << "|"; 0114 out << "m{" << getCellSize(col) << "pt}"; 0115 0116 if(elt->hasRightBorder()) 0117 out << "|"; 0118 out << "}{" << endl; 0119 0120 generateCell(out, row, col); 0121 out << "}" << endl; 0122 if(col < getMaxCol()) 0123 out << "&" << endl; 0124 } 0125 out << "\\\\" << endl; 0126 writeIndent(out); 0127 row = row + 1; 0128 } 0129 generateBottomLineBorder(out, row - 1); 0130 out << "\\end{tabular}" << endl << endl; 0131 unindent();*/ 0132 debugLatex << "END OF GENERATION OF A CELL"; 0133 } 0134