00001 /* This file is part of the KDE project 00002 Copyright (C) 2001 Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KFORMULACOMPATIBILITY_H 00021 #define KFORMULACOMPATIBILITY_H 00022 00023 #include <QString> 00024 00025 KFORMULA_NAMESPACE_BEGIN 00026 00031 class Compatibility { 00032 public: 00033 00034 Compatibility(); 00035 00039 QDomDocument buildDOM(const QString& text); 00040 00041 private: 00042 00043 QDomElement readSequence(const QDomDocument& doc); 00044 QDomElement readMatrix(const QDomDocument& doc); 00045 00046 void appendToSequence(QDomElement sequence, QDomElement element, int leftIndexSeen); 00047 00048 void appendNextSequence(const QDomDocument& doc, QDomElement element); 00049 QDomElement getLastSequence(const QDomDocument& doc, QDomElement sequence); 00050 00051 QDomElement findIndexNode(const QDomDocument& doc, QDomElement sequence); 00052 00053 ushort nextToken() { return formulaString[pos++].unicode(); } 00054 ushort lookAhead(uint i) const { return formulaString[pos+i].unicode(); } 00055 void pushback() { pos--; } 00056 00057 bool hasNext() const { return pos < formulaString.length(); } 00058 uint tokenLeft() const { return formulaString.length()-pos; } 00059 00063 QString formulaString; 00064 00068 int pos; 00069 }; 00070 00071 KFORMULA_NAMESPACE_END 00072 00073 #endif // KFORMULACOMPATIBILITY_H