filters
listeformat.cc
00001 00002 /* BUGS : latex don't support alpha list with one command !!! the 00003 * command generated doesn't exist :)))) 00004 */ 00005 00006 /* 00007 ** A program to convert the XML rendered by KWord into LATEX. 00008 ** 00009 ** Copyright (C) 2000 Robert JACOLIN 00010 ** 00011 ** This library is free software; you can redistribute it and/or 00012 ** modify it under the terms of the GNU Library General Public 00013 ** License as published by the Free Software Foundation; either 00014 ** version 2 of the License, or (at your option) any later version. 00015 ** 00016 ** This library is distributed in the hope that it will be useful, 00017 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 ** Library General Public License for more details. 00020 ** 00021 ** To receive a copy of the GNU Library General Public License, write to the 00022 ** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00023 * Boston, MA 02110-1301, USA. 00024 ** 00025 */ 00026 00027 #include <kdebug.h> /* for kdDebug() stream */ 00028 #include "listeformat.h" 00029 00030 /* PRIVATE METHODS */ 00031 00032 /* PROTECTED METHODS */ 00033 00034 /* PUBLIC METHODS */ 00035 00036 /* Constructors */ 00037 00038 /* Destructors */ 00039 FormatElt::~FormatElt() 00040 { 00041 kdDebug(30522) << "Destruction d'un elementT" << endl; 00042 remFormat(); 00043 } 00044 00045 /* Accessors */ 00046 00047 /* Modifiors */ 00048 void FormatElt::setFormat(Format* format) 00049 { 00050 _format = format; 00051 } 00052 00053 void FormatElt::remFormat() 00054 { 00055 delete _format; 00056 _format = 0; 00057 } 00058 00059 void FormatElt::setNext(FormatElt* next) 00060 { 00061 _next = next; 00062 } 00063 00064 void FormatElt::remNext() 00065 { 00066 delete _next; 00067 _next = 0; 00068 } 00069 00070 /* Operators */ 00071 FormatElt& FormatElt::operator = (const FormatElt & elt) 00072 { 00073 _format = elt.getFormat(); 00074 _next = elt.getNext(); 00075 return *this; 00076 } 00077 00079 ListeFormat::ListeFormat() 00080 { 00081 kdDebug(30522) << "Create format list" << endl; 00082 _first = 0; 00083 _end = 0; 00084 _size = 0; 00085 } 00086 00087 ListeFormat::~ListeFormat() 00088 { 00089 kdDebug(30522) << "Destruction of a list of format" << endl; 00090 vider(); 00091 kdDebug(30522) << "ok" << endl; 00092 } 00093 00094 void ListeFormat::addLast(Format *elt) 00095 { 00096 00097 FormatElt *new_last = new FormatElt; 00098 00099 new_last->setFormat(elt); 00100 00101 if(_first != 0) 00102 { 00103 _end->setNext(new_last); 00104 _end = new_last; 00105 } 00106 else 00107 { 00108 /* La liste est vide => _last = _first; */ 00109 _end = new_last; 00110 _first = _end; 00111 } 00112 _size = _size + 1; 00113 } 00114 00115 void ListeFormat::addFirst(Format* elt) 00116 { 00117 FormatElt *new_first = new FormatElt; 00118 00119 new_first->setFormat(elt); 00120 new_first->setNext(_first); 00121 00122 _first = new_first; 00123 if(_size == 0) 00124 { 00125 /* La liste est vide => _last = _first; */ 00126 _end = _first; 00127 } 00128 _size = _size + 1; 00129 } 00130 00131 void ListeFormat::remLast() 00132 { 00133 FormatElt *new_last = new FormatElt(_first); 00134 00135 for(int index = 1; index< _size - 1; new_last = new_last->getNext()) 00136 { } 00137 00138 delete _end; 00139 _end = new_last; 00140 _size = _size - 1; 00141 } 00142 00143 void ListeFormat::remFirst() 00144 { 00145 FormatElt *first_saved; 00146 00147 first_saved = _first->getNext(); 00148 00149 delete _first; 00150 _first = first_saved; 00151 _size = _size - 1; 00152 } 00153 00154 void ListeFormat::vider() 00155 { 00156 while(_first != 0) 00157 { 00158 remFirst(); 00159 } 00160 } 00161