filters

footnote.cc

00001 /*
00002 ** A program to convert the XML rendered by KWord into LATEX.
00003 **
00004 ** Copyright (C) 2000,2002 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 <stdlib.h>     /* for atoi function */
00023 #include <kdebug.h>     /* for kdDebug() stream */
00024 #include "footnote.h"
00025 #include "textFrame.h"      /* for generate function (catch text footnote) */
00026 #include "document.h"
00027 
00028 Footnote::Footnote(Para* para): Format(para)
00029 {
00030 }
00031 
00032 Footnote::~Footnote()
00033 {
00034     kdDebug(30522) << "Destruction of a footnote." << endl;
00035 }
00036 
00037 /* Modifiers */
00038 void Footnote::setSpace (QString new_space)
00039 {
00040     _space = new_space;
00041 }
00042 
00043 void Footnote::setBefore(QString new_before)
00044 {
00045     _before = new_before;
00046 
00047 }
00048 
00049 void Footnote::setAfter(QString new_after)
00050 {
00051     _after = new_after;
00052 }
00053 
00054 void Footnote::setRef(QString new_ref)
00055 {
00056     _ref = new_ref;
00057 }
00058 
00059 void Footnote::analyse(const QDomNode balise)
00060 {
00061     /* MARKUPS FORMAT id="1" pos="0" len="17">...</FORMAT> */
00062     
00063     /* Parameters Analyse */
00064     kdDebug(30522) << "ANALYSE A FOOTNOTE" << endl;
00065     
00066     /* Children Markups Analyse */
00067     for(int index= 0; index < getNbChild(balise); index++)
00068     {
00069         if(getChildName(balise, index).compare("INTERNAL")== 0)
00070         {
00071             kdDebug(30522) << "INTERNAL : " << endl;
00072             analyseInternal(balise);
00073         }
00074         else if(getChildName(balise, index).compare("RANGE")== 0)
00075         {
00076             kdDebug(30522) << "RANGE : " << endl;
00077             analyseRange(balise);
00078         }
00079         else if(getChildName(balise, index).compare("TEXT")== 0)
00080         {
00081             kdDebug(30522) << "TEXT : " << endl;
00082             analyseText(balise);
00083         }
00084         else if(getChildName(balise, index).compare("DESCRIPT")== 0)
00085         {
00086             kdDebug(30522) << "DESCRIPT : " << endl;
00087             analyseDescript(balise);
00088         }
00089         else if(getChildName(balise, index).compare("FORMAT")== 0)
00090         {
00091             kdDebug(30522) << "SUBFORMAT : " << endl;
00092             Format::analyse(balise);
00093         }
00094     }
00095     kdDebug(30522) << "END OF FOOTNOTE" << endl;
00096 }
00097 
00098 void Footnote::analyseInternal(const QDomNode balise)
00099 {
00100     QDomNode fils;
00101     /* MARKUPS <INTERNAL> <PART from="1" to="-1" space="-"/> */
00102 
00103     /* Children Markups Analyse */
00104     fils = getChild(balise, "PART");
00105     for(int index= 0; index < getNbChild(balise); index++)
00106     {
00107         if(getChildName(balise, index).compare("PART")== 0)
00108         {
00109             kdDebug(30522) << "PART : " << endl;
00110             setFrom(getAttr(balise, "FROM").toInt());
00111             setTo(getAttr(balise, "TO").toInt());
00112             setSpace(getAttr(balise, "SPACE"));
00113 
00114         }
00115     }
00116 }
00117 
00118 void Footnote::analyseRange(const QDomNode balise)
00119 {
00120     kdDebug(30522) << "PARAM" << endl;
00121     setStart(getAttr(balise, "START").toInt());
00122     setEnd(getAttr(balise, "END").toInt());
00123 }
00124 
00125 void Footnote::analyseText(const QDomNode balise)
00126 {
00127     kdDebug(30522) << "PARAM" << endl;
00128     setBefore(getAttr(balise, "BEFORE"));
00129     setAfter(getAttr(balise, "AFTER"));
00130 }
00131 
00132 void Footnote::analyseDescript(const QDomNode balise)
00133 {
00134     kdDebug(30522) << "PARAM" << endl;
00135     setRef(getAttr(balise, "REF"));
00136 }
00137 
00138 void Footnote::generate(QTextStream &out)
00139 {
00140     Element *footnote = 0;
00141 
00142     kdDebug(30522) << "  GENERATION FOOTNOTE" << endl;
00143     // Go to keep the footnote parag.
00144     // then write it with this format.
00145     // like this : \,\footnote{the parag. }
00146     out << "\\,\\footnote{";
00147     kdDebug(30522) << "footnote : " << _ref << endl;
00148     if((footnote = getRoot()->searchFootnote(_ref)) != 0)
00149         footnote->generate(out);
00150     out << "}";
00151     kdDebug(30522) << "FOOTNOTE GENERATED" << endl;
00152 }
00153 
00154 
KDE Home | KDE Accessibility Home | Description of Access Keys