footnote.cpp
1/*
2** A program to convert the XML rendered by KWord into LATEX.
3**
4** Copyright (C) 2000,2002 Robert JACOLIN
5**
6** This library is free software; you can redistribute it and/or
7** modify it under the terms of the GNU Library General Public
8** License as published by the Free Software Foundation; either
9** version 2 of the License, or (at your option) any later version.
10**
11** This library is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14** Library General Public License for more details.
15**
16** To receive a copy of the GNU Library General Public License, write to the
17** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19**
20*/
21
22#include <stdlib.h> /* for atoi function */
23#include <kdebug.h> /* for kdDebug() stream */
24#include "footnote.h"
25#include "textFrame.h" /* for generate function (catch text footnote) */
26#include "document.h"
27
29{
30}
31
32Footnote::~Footnote()
33{
34 kdDebug(30522) << "Destruction of a footnote." << endl;
35}
36
37/* Modifiers */
38void Footnote::setSpace (TQString new_space)
39{
40 _space = new_space;
41}
42
43void Footnote::setBefore(TQString new_before)
44{
45 _before = new_before;
46
47}
48
49void Footnote::setAfter(TQString new_after)
50{
51 _after = new_after;
52}
53
54void Footnote::setRef(TQString new_ref)
55{
56 _ref = new_ref;
57}
58
59void Footnote::analyse(const TQDomNode balise)
60{
61 /* MARKUPS FORMAT id="1" pos="0" len="17">...</FORMAT> */
62
63 /* Parameters Analyse */
64 kdDebug(30522) << "ANALYSE A FOOTNOTE" << endl;
65
66 /* Children Markups Analyse */
67 for(int index= 0; index < getNbChild(balise); index++)
68 {
69 if(getChildName(balise, index).compare("INTERNAL")== 0)
70 {
71 kdDebug(30522) << "INTERNAL : " << endl;
72 analyseInternal(balise);
73 }
74 else if(getChildName(balise, index).compare("RANGE")== 0)
75 {
76 kdDebug(30522) << "RANGE : " << endl;
77 analyseRange(balise);
78 }
79 else if(getChildName(balise, index).compare("TEXT")== 0)
80 {
81 kdDebug(30522) << "TEXT : " << endl;
82 analyseText(balise);
83 }
84 else if(getChildName(balise, index).compare("DESCRIPT")== 0)
85 {
86 kdDebug(30522) << "DESCRIPT : " << endl;
87 analyseDescript(balise);
88 }
89 else if(getChildName(balise, index).compare("FORMAT")== 0)
90 {
91 kdDebug(30522) << "SUBFORMAT : " << endl;
92 Format::analyse(balise);
93 }
94 }
95 kdDebug(30522) << "END OF FOOTNOTE" << endl;
96}
97
98void Footnote::analyseInternal(const TQDomNode balise)
99{
100 TQDomNode fils;
101 /* MARKUPS <INTERNAL> <PART from="1" to="-1" space="-"/> */
102
103 /* Children Markups Analyse */
104 fils = getChild(balise, "PART");
105 for(int index= 0; index < getNbChild(balise); index++)
106 {
107 if(getChildName(balise, index).compare("PART")== 0)
108 {
109 kdDebug(30522) << "PART : " << endl;
110 setFrom(getAttr(balise, "FROM").toInt());
111 setTo(getAttr(balise, "TO").toInt());
112 setSpace(getAttr(balise, "SPACE"));
113
114 }
115 }
116}
117
118void Footnote::analyseRange(const TQDomNode balise)
119{
120 kdDebug(30522) << "PARAM" << endl;
121 setStart(getAttr(balise, "START").toInt());
122 setEnd(getAttr(balise, "END").toInt());
123}
124
125void Footnote::analyseText(const TQDomNode balise)
126{
127 kdDebug(30522) << "PARAM" << endl;
128 setBefore(getAttr(balise, "BEFORE"));
129 setAfter(getAttr(balise, "AFTER"));
130}
131
132void Footnote::analyseDescript(const TQDomNode balise)
133{
134 kdDebug(30522) << "PARAM" << endl;
135 setRef(getAttr(balise, "REF"));
136}
137
138void Footnote::generate(TQTextStream &out)
139{
140 Element *footnote = 0;
141
142 kdDebug(30522) << " GENERATION FOOTNOTE" << endl;
143 // Go to keep the footnote parag.
144 // then write it with this format.
145 // like this : \,\footnote{the parag. }
146 out << "\\,\\footnote{";
147 kdDebug(30522) << "footnote : " << _ref << endl;
148 if((footnote = getRoot()->searchFootnote(_ref)) != 0)
149 footnote->generate(out);
150 out << "}";
151 kdDebug(30522) << "FOOTNOTE GENERATED" << endl;
152}
153
154
This class is a element.
Footnote(Para *para=0)
Constructors.
Definition footnote.cpp:28
void analyse(const TQDomNode)
Helpfull functions.
Definition footnote.cpp:59
void setFrom(int f)
Accessors.
Definition footnote.h:71
This class describe a cell, row or column format.
virtual void analyse(const TQDomNode)
Helpfull functions.
This class hold a real paragraph.
Definition para.h:59