filters

listeformat.cpp
1
2/* BUGS : latex don't support alpha list with one command !!! the
3 * command generated doesn't exist :))))
4 */
5
6/*
7** A program to convert the XML rendered by KWord into LATEX.
8**
9** Copyright (C) 2000 Robert JACOLIN
10**
11** This library is free software; you can redistribute it and/or
12** modify it under the terms of the GNU Library General Public
13** License as published by the Free Software Foundation; either
14** version 2 of the License, or (at your option) any later version.
15**
16** This library is distributed in the hope that it will be useful,
17** but WITHOUT ANY WARRANTY; without even the implied warranty of
18** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19** Library General Public License for more details.
20**
21** To receive a copy of the GNU Library General Public License, write to the
22** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
24**
25*/
26
27#include <kdebug.h> /* for kdDebug() stream */
28#include "listeformat.h"
29
30/* PRIVATE METHODS */
31
32/* PROTECTED METHODS */
33
34/* PUBLIC METHODS */
35
36/* Constructors */
37
38/* Destructors */
39FormatElt::~FormatElt()
40{
41 kdDebug(30522) << "Destruction d'un elementT" << endl;
42 remFormat();
43}
44
45/* Accessors */
46
47/* Modifiors */
48void FormatElt::setFormat(Format* format)
49{
50 _format = format;
51}
52
53void FormatElt::remFormat()
54{
55 delete _format;
56 _format = 0;
57}
58
59void FormatElt::setNext(FormatElt* next)
60{
61 _next = next;
62}
63
64void FormatElt::remNext()
65{
66 delete _next;
67 _next = 0;
68}
69
70/* Operators */
71FormatElt& FormatElt::operator = (const FormatElt & elt)
72{
73 _format = elt.getFormat();
74 _next = elt.getNext();
75 return *this;
76}
77
79ListeFormat::ListeFormat()
80{
81 kdDebug(30522) << "Create format list" << endl;
82 _first = 0;
83 _end = 0;
84 _size = 0;
85}
86
87ListeFormat::~ListeFormat()
88{
89 kdDebug(30522) << "Destruction of a list of format" << endl;
90 vider();
91 kdDebug(30522) << "ok" << endl;
92}
93
94void ListeFormat::addLast(Format *elt)
95{
96
97 FormatElt *new_last = new FormatElt;
98
99 new_last->setFormat(elt);
100
101 if(_first != 0)
102 {
103 _end->setNext(new_last);
104 _end = new_last;
105 }
106 else
107 {
108 /* La liste est vide => _last = _first; */
109 _end = new_last;
110 _first = _end;
111 }
112 _size = _size + 1;
113}
114
115void ListeFormat::addFirst(Format* elt)
116{
117 FormatElt *new_first = new FormatElt;
118
119 new_first->setFormat(elt);
120 new_first->setNext(_first);
121
122 _first = new_first;
123 if(_size == 0)
124 {
125 /* La liste est vide => _last = _first; */
126 _end = _first;
127 }
128 _size = _size + 1;
129}
130
131void ListeFormat::remLast()
132{
133 FormatElt *new_last = new FormatElt(_first);
134
135 for(int index = 1; index< _size - 1; new_last = new_last->getNext())
136 { }
137
138 delete _end;
139 _end = new_last;
140 _size = _size - 1;
141}
142
143void ListeFormat::remFirst()
144{
145 FormatElt *first_saved;
146
147 first_saved = _first->getNext();
148
149 delete _first;
150 _first = first_saved;
151 _size = _size - 1;
152}
153
154void ListeFormat::vider()
155{
156 while(_first != 0)
157 {
158 remFirst();
159 }
160}
161
This class describe a cell, row or column format.