filters
variablezone.cc
00001 /* MEMO: to see the unicode table 00002 * xset +fp /usr/X11R6/lib/X11/fonts/ucs/ 00003 * xfd -fn '-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1' 00004 */ 00005 /* 00006 ** A program to convert the XML rendered by KWord into LATEX. 00007 ** 00008 ** Copyright (C) 2002 - 2003 Robert JACOLIN 00009 ** 00010 ** This library is free software; you can redistribute it and/or 00011 ** modify it under the terms of the GNU Library General Public 00012 ** License as published by the Free Software Foundation; either 00013 ** version 2 of the License, or (at your option) any later version. 00014 ** 00015 ** This library is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 ** Library General Public License for more details. 00019 ** 00020 ** To receive a copy of the GNU Library General Public License, write to the 00021 ** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00022 * Boston, MA 02110-1301, USA. 00023 ** 00024 */ 00025 00026 #include <kdebug.h> /* for kdDebug() stream */ 00027 00028 #include "variablezone.h" 00029 #include "para.h" 00030 #include "document.h" 00031 00032 /*******************************************/ 00033 /* VariableZone */ 00034 /*******************************************/ 00035 VariableZone::VariableZone(Para* para): VariableFormat(para) 00036 { 00037 setPara(para); 00038 setSize(para->getSize()); 00039 setWeight(para->getWeight()); 00040 setItalic(para->isItalic()); 00041 setUnderlined(para->getUnderlineType()); 00042 setStrikeout(para->isStrikeout()); 00043 } 00044 00045 /*******************************************/ 00046 /* VariableZone */ 00047 /*******************************************/ 00048 VariableZone::VariableZone(QString text, Para* para): VariableFormat(para) 00049 { 00050 setTexte(text); 00051 /*setPara(para); 00052 setSize(para->getSize()); 00053 setWeight(para->getWeight()); 00054 setItalic(para->isItalic()); 00055 setUnderlined(para->getUnderlineType()); 00056 setStrikeout(para->isStrikeout());*/ 00057 } 00058 00059 /*******************************************/ 00060 /* ~VariableZone */ 00061 /*******************************************/ 00062 VariableZone::~VariableZone() 00063 { 00064 kdDebug(30522) << "Destruction of an area" << endl; 00065 } 00066 00067 /*******************************************/ 00068 /* analyse */ 00069 /*******************************************/ 00070 /* Analyse a text format, get the text used*/ 00071 /* by this format. */ 00072 /*******************************************/ 00073 void VariableZone::analyse(const QDomNode balise) 00074 { 00075 kdDebug(30522) << "FORMAT" << endl; 00076 /* Get header information (size, position) 00077 * Get infos. to format the text 00078 */ 00079 //if(balise != 0) 00080 analyseFormat(balise); 00081 00082 /* Format the text */ 00083 setTexte(getTexte().mid(getPos(), getLength())); 00084 00085 kdDebug(30522) << getTexte().length() << endl; 00086 kdDebug(30522) << getTexte().latin1() << endl; 00087 kdDebug(30522) << "END FORMAT" << endl; 00088 } 00089 00090 /*******************************************/ 00091 /* generate */ 00092 /*******************************************/ 00093 /* Generate the text formated (if needed). */ 00094 /*******************************************/ 00095 void VariableZone::generate(QTextStream &out) 00096 { 00097 00098 if(useFormat()) 00099 generate_format_begin(out); 00100 00101 /* Display the text */ 00102 kdDebug(30522) << "type : " << getType() << endl; 00103 if((getType() == VAR_DATE) && !isFix()) 00104 out << "\\today" << endl; 00105 else if(getType() == VAR_FOOTNOTE) 00106 { 00107 if(getNotetype() == "footnote") 00108 out << "\\,\\footnote{"; 00109 else if(getNotetype() == "endnote") 00110 out << "\\,\\endnote{"; 00111 /* Get the footnote and generate it. */ 00112 Element* footnote = getRoot()->searchFootnote(getFrameset()); 00113 if(footnote != NULL) 00114 { 00115 footnote->generate(out); 00116 } 00117 Config::instance()->writeIndent(out); 00118 out << "}"; 00119 } 00120 else if(getType() == VAR_NOTE) 00121 { 00122 out << "\\marginpar{\\scriptsize "; 00123 if(Config::instance()->mustUseLatin1()) 00124 display(escapeLatin1(getNote()), out); 00125 else if(Config::instance()->mustUseUnicode()) 00126 display(getNote(), out); 00127 out << "}" << endl; 00128 } 00129 else 00130 { 00131 if(Config::instance()->mustUseLatin1()) 00132 display(escapeLatin1(getText()), out); 00133 else if(Config::instance()->mustUseUnicode()) 00134 display(getText(), out); 00135 } 00136 if(useFormat()) 00137 generate_format_end(out); 00138 00139 } 00140