filters
listelement.cc
00001 /* 00002 ** A program to convert the XML rendered by KWord into LATEX. 00003 ** 00004 ** Copyright (C) 2000 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 <kdebug.h> /* for kdDebug stream */ 00023 #include "listelement.h" 00024 00025 /*******************************************/ 00026 /* Constructor */ 00027 /*******************************************/ 00028 ListElement::ListElement() 00029 { 00030 _start = 0; 00031 _end = 0; 00032 _size = 0; 00033 } 00034 00035 /*******************************************/ 00036 /* Destructor */ 00037 /*******************************************/ 00038 ListElement::~ListElement() 00039 { 00040 Element *elt = 0; 00041 kdDebug(30522) << "Destruction of a list of elements" << endl; 00042 while(_start != 0) 00043 { 00044 elt = _start; 00045 _start = _start->getNext(); 00046 delete elt; 00047 _size = _size - 1; 00048 } 00049 } 00050 00051 /*******************************************/ 00052 /* Initialiser */ 00053 /*******************************************/ 00054 void ListElement::initialiser(Element *elt) 00055 { 00056 _end = _start = elt; 00057 } 00058 00059 00060 /*******************************************/ 00061 /* add */ 00062 /*******************************************/ 00063 void ListElement::add(Element *elt) 00064 { 00065 if(_start == 0) 00066 { 00067 initialiser(elt); 00068 _size = 1; 00069 } 00070 else 00071 { 00072 _end->setNext(elt); 00073 _end = elt; 00074 _size = _size + 1; 00075 } 00076 } 00077