diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kpresenter/autoformEdit | |
download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip |
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kpresenter/autoformEdit')
-rw-r--r-- | kpresenter/autoformEdit/AFChoose.cpp | 202 | ||||
-rw-r--r-- | kpresenter/autoformEdit/AFChoose.h | 89 | ||||
-rw-r--r-- | kpresenter/autoformEdit/ATFInterpreter.cpp | 453 | ||||
-rw-r--r-- | kpresenter/autoformEdit/ATFInterpreter.h | 175 | ||||
-rw-r--r-- | kpresenter/autoformEdit/Makefile.am | 12 |
5 files changed, 931 insertions, 0 deletions
diff --git a/kpresenter/autoformEdit/AFChoose.cpp b/kpresenter/autoformEdit/AFChoose.cpp new file mode 100644 index 00000000..d5f00758 --- /dev/null +++ b/kpresenter/autoformEdit/AFChoose.cpp @@ -0,0 +1,202 @@ +// -*- Mode: c++-mode; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "AFChoose.h" + +#include <qlabel.h> +#include <qvbox.h> +#include <qtextstream.h> +#include <qdir.h> +#include <qwhatsthis.h> + +#include <klocale.h> +#include <ksimpleconfig.h> +#include <kdebug.h> +#include <kstandarddirs.h> +#include <kicondialog.h> + +#include <KPrFactory.h> + +AFChoose::AFChoose(QWidget *parent, const QString &caption, const char *name) + : QTabDialog(parent,name,true) +{ + setCaption(caption); + setCancelButton(i18n("&Cancel")); + setOkButton(i18n("&OK")); + groupList.setAutoDelete(true); + getGroups(); + setupTabs(); + connect(this,SIGNAL(applyButtonPressed()),this,SLOT(chosen())); + connect(this,SIGNAL(cancelButtonPressed()),this,SLOT(cancelClicked())); +} + +AFChoose::~AFChoose() +{ +} + +void AFChoose::getGroups() +{ + // global autoforms (as we don't have an editor we don't have local ones) + QString afDir = locate( "autoforms", ".autoforms", KPrFactory::global() ); + + QFile f( afDir ); + if ( f.open(IO_ReadOnly) ) { + QTextStream t( &f ); + QString s; + while ( !t.eof() ) { + s = t.readLine(); + if ( !s.isEmpty() ) { + grpPtr = new Group; + QString directory=QFileInfo( afDir ).dirPath() + "/" + s.simplifyWhiteSpace(); + grpPtr->dir.setFile(directory); + QDir d(directory); + if(d.exists(".directory")) { + KSimpleConfig config(d.absPath()+"/.directory", true); + config.setDesktopGroup(); + grpPtr->name=config.readEntry("Name"); + } + groupList.append( grpPtr ); + } + } + f.close(); + } +} + +void AFChoose::setupTabs() +{ + if (!groupList.isEmpty()) + { + for (grpPtr=groupList.first();grpPtr != 0;grpPtr=groupList.next()) + { + grpPtr->tab = new QVBox(this); + QWhatsThis::add(grpPtr->tab, i18n( "Choose a predefined shape by clicking on it then clicking the OK button (or just double-click on the shape). You can then insert the shape onto your slide by drawing the area with the mouse pointer." ) ); + grpPtr->loadWid = new KIconCanvas(grpPtr->tab); + // Changes for the new KIconCanvas (Werner) + QDir d( grpPtr->dir.absFilePath() ); + d.setNameFilter( "*.desktop" ); + if( d.exists() ) { + QStringList files=d.entryList( QDir::Files | QDir::Readable, QDir::Name ); + for(unsigned int i=0; i<files.count(); ++i) { + QString path=grpPtr->dir.absFilePath() + QChar('/'); + files[i]=path + files[i]; + KSimpleConfig config(files[i]); + config.setDesktopGroup(); + if (config.readEntry("Type")=="Link") { + QString text=config.readEntry("Name"); + QString icon=config.readEntry("Icon"); + if(icon[0]!='/') // allow absolute paths for icons + icon=path + icon; + QString filename=config.readPathEntry("URL"); + if(filename[0]!='/') { + if(filename.left(6)=="file:/") // I doubt this will happen + filename=filename.right(filename.length()-6); + filename=path + filename; + } + grpPtr->entries.insert(text, filename); + // now load the icon and create the item + // This code is shamelessly borrowed from KIconCanvas::slotLoadFiles + QImage img; + img.load(icon); + if (img.isNull()) { + kdWarning() << "Couldn't find icon " << icon << endl; + continue; + } + if (img.width() > 60 || img.height() > 60) { + if (img.width() > img.height()) { + int height = (int) ((60.0 / img.width()) * img.height()); + img = img.smoothScale(60, height); + } else { + int width = (int) ((60.0 / img.height()) * img.width()); + img = img.smoothScale(width, 60); + } + } + QPixmap pic; + pic.convertFromImage(img); + QIconViewItem *item = new QIconViewItem(grpPtr->loadWid, text, pic); + item->setKey(text); + item->setDragEnabled(false); + item->setDropEnabled(false); + } else + continue; // Invalid .desktop file + } + } + grpPtr->loadWid->setBackgroundColor(colorGroup().base()); + grpPtr->loadWid->setResizeMode(QIconView::Adjust); + grpPtr->loadWid->sort(); + connect(grpPtr->loadWid,SIGNAL(nameChanged(QString)), + this,SLOT(nameChanged(QString))); + connect(this, SIGNAL(currentChanged(QWidget *)), this, + SLOT(tabChanged(QWidget*))); + connect(grpPtr->loadWid,SIGNAL( doubleClicked ( QIconViewItem *)),this, + SLOT(slotDoubleClick())); + grpPtr->label = new QLabel(grpPtr->tab); + grpPtr->label->setText(" "); + grpPtr->label->setMaximumHeight(grpPtr->label->sizeHint().height()); + addTab(grpPtr->tab,grpPtr->name); + } + } +} + +void AFChoose::slotDoubleClick() +{ + chosen(); + accept(); +} + +void AFChoose::nameChanged(QString name) +{ + for (grpPtr=groupList.first();grpPtr != 0;grpPtr=groupList.next()) + grpPtr->label->setText(name); +} + +void AFChoose::tabChanged(QWidget *w) { + + for(grpPtr=groupList.first();grpPtr != 0;grpPtr=groupList.next()) { + if(grpPtr->tab==w) + grpPtr->label->setText(grpPtr->loadWid->getCurrent()); + } +} + +void AFChoose::chosen() +{ + if (!groupList.isEmpty()) + { + for (grpPtr=groupList.first();grpPtr != 0;grpPtr=groupList.next()) + { + if (grpPtr->tab->isVisible() && !grpPtr->loadWid->getCurrent().isEmpty()) + emit formChosen(grpPtr->entries[grpPtr->loadWid->getCurrent()]); + else + emit afchooseCanceled(); + } + } +} + +void AFChoose::cancelClicked() +{ + emit afchooseCanceled(); +} + +void AFChoose::closeEvent ( QCloseEvent *e ) +{ + emit afchooseCanceled(); + QTabDialog::closeEvent ( e ); +} + +#include "AFChoose.moc" diff --git a/kpresenter/autoformEdit/AFChoose.h b/kpresenter/autoformEdit/AFChoose.h new file mode 100644 index 00000000..e767e4bf --- /dev/null +++ b/kpresenter/autoformEdit/AFChoose.h @@ -0,0 +1,89 @@ +// -*- Mode: c++-mode; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef AFCHOOSE_H +#define AFCHOOSE_H + +#include <qtabdialog.h> +#include <qptrlist.h> +#include <qmap.h> +#include <qfileinfo.h> + +class QLabel; +class KIconCanvas; + +class AFChoose : public QTabDialog +{ + Q_OBJECT + +public: + + // constructor - destructor + AFChoose(QWidget *parent=0, const QString &caption=QString::null, const char *name=0); + ~AFChoose(); + +private: + + // structure of a group + struct Group + { + QFileInfo dir; + QString name; + QWidget *tab; + KIconCanvas *loadWid; + QLabel *label; + QMap<QString, QString> entries; + }; + + // set groups + void getGroups(); + + // setup tabs + void setupTabs(); + + // ********** variables ********** + + // list of groups and a pointer to a group + QPtrList<Group> groupList; + Group *grpPtr; + +private slots: + + // name changed + void nameChanged(QString); + void tabChanged(QWidget *); + + // autoform chosen + void chosen(); + + void cancelClicked(); + + void slotDoubleClick(); +protected: + void closeEvent ( QCloseEvent * ); + +signals: + + //autoform chosen + void formChosen(const QString &); + void afchooseCanceled(); +}; + +#endif //AFCHOOSE_H diff --git a/kpresenter/autoformEdit/ATFInterpreter.cpp b/kpresenter/autoformEdit/ATFInterpreter.cpp new file mode 100644 index 00000000..a32ff7ea --- /dev/null +++ b/kpresenter/autoformEdit/ATFInterpreter.cpp @@ -0,0 +1,453 @@ +// -*- Mode: c++-mode; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "ATFInterpreter.h" + +#include <qvaluestack.h> +#include <qfile.h> + +const char ATFInterpreter::PNT_BG[] = "POINT {"; +const char ATFInterpreter::X_BG[] = "X {"; +const char ATFInterpreter::Y_BG[] = "Y {"; +const char ATFInterpreter::ATTR_BG[] = "ATTRIB {"; +const char ATFInterpreter::END[] = "}"; + +// fields +const int ATFInterpreter::ST_WIDTH = 1; +const int ATFInterpreter::ST_HEIGHT = 2; +const int ATFInterpreter::ST_VARIABLE = 3; +const int ATFInterpreter::ST_NUMBER = 4; +const int ATFInterpreter::ST_OPERATOR = 5; + +// operators +const char ATFInterpreter::OP_EQUAL = '='; +const char ATFInterpreter::OP_PLUS = '+'; +const char ATFInterpreter::OP_MINUS = '-'; +const char ATFInterpreter::OP_MULT = '*'; +const char ATFInterpreter::OP_DIV = '/'; +const char ATFInterpreter::COMMENT = '#'; + +// allowed variables +const char ATFInterpreter::VAR_1 = 'a'; +const char ATFInterpreter::VAR_2 = 'b'; +const char ATFInterpreter::VAR_3 = 'c'; +const char ATFInterpreter::VAR_4 = 'd'; +const char ATFInterpreter::VAR_5 = 'e'; +const char ATFInterpreter::VAR_6 = 'f'; +const char ATFInterpreter::VAR_X = 'x'; +const char ATFInterpreter::VAR_Y = 'y'; +const char ATFInterpreter::VAR_VARIA = 'v'; +const char ATFInterpreter::VAR_PW = 'p'; +const char ATFInterpreter::VAR_W = 'w'; +const char ATFInterpreter::VAR_H = 'h'; + +// level (depth) of the syntax +const int ATFInterpreter::LEVEL_NULL = 0; +const int ATFInterpreter::LEVEL_POINT = 1; +const int ATFInterpreter::LEVEL_X = 2; +const int ATFInterpreter::LEVEL_Y = 3; +const int ATFInterpreter::LEVEL_ATTR = 4; + +// numbers +const char ATFInterpreter::NUM_0 = '0'; +const char ATFInterpreter::NUM_1 = '1'; +const char ATFInterpreter::NUM_2 = '2'; +const char ATFInterpreter::NUM_3 = '3'; +const char ATFInterpreter::NUM_4 = '4'; +const char ATFInterpreter::NUM_5 = '5'; +const char ATFInterpreter::NUM_6 = '6'; +const char ATFInterpreter::NUM_7 = '7'; +const char ATFInterpreter::NUM_8 = '8'; +const char ATFInterpreter::NUM_9 = '9'; + +/******************************************************************/ +/* class ATFInterpreter */ +/******************************************************************/ + +/*====================== constructor =============================*/ +ATFInterpreter::ATFInterpreter() { +} + +/*======================= destrcutor =============================*/ +ATFInterpreter::~ATFInterpreter() +{ + coordList.setAutoDelete(true); + attrLs.setAutoDelete( true ); +} + +void ATFInterpreter::load(const QString & fileName) +{ + QString line; + QFile ptA(fileName); + + coordList.clear(); + lines.clear(); + + if (ptA.open(IO_ReadOnly)) + { + while (!ptA.atEnd()) + { + ptA.readLine(line,255); + lines.append(line.simplifyWhiteSpace()); + } + ptA.close(); + interpret(); + } +} + +QPointArray ATFInterpreter::getPointArray(int wid,int heig) +{ + unsigned int px = 0,py = 0,a = 0,b = 0,c = 0,d = 0,e = 0,f = 0; + unsigned int tmp = 0,num = 0; + bool calc = false,res = false; + char op = OP_EQUAL,var = VAR_1; + QPtrList<Sign> slp; + QPointArray pntArray(coordList.count()); + + if (!coordList.isEmpty()) + { + for (coordPtr=coordList.first();coordPtr != 0;coordPtr=coordList.next()) + { + for (unsigned int i = 1; i<= 14; i++) + { + switch (i) + { + case 1: slp = coordPtr->pntX.var1; break; + case 2: slp = coordPtr->pntX.var2; break; + case 3: slp = coordPtr->pntX.var3; break; + case 4: slp = coordPtr->pntX.var4; break; + case 5: slp = coordPtr->pntX.var5; break; + case 6: slp = coordPtr->pntX.var6; break; + case 7: slp = coordPtr->pntX.result; break; + case 8: slp = coordPtr->pntY.var1; break; + case 9: slp = coordPtr->pntY.var2; break; + case 10: slp = coordPtr->pntY.var3; break; + case 11: slp = coordPtr->pntY.var4; break; + case 12: slp = coordPtr->pntY.var5; break; + case 13: slp = coordPtr->pntY.var6; break; + case 14: slp = coordPtr->pntY.result; break; + } + if (!slp.isEmpty()) + { + tmp = 0; + for (signPtr=slp.first();signPtr != 0;signPtr=slp.next()) + { + switch (signPtr->type) + { + case ST_WIDTH: { num = wid; calc = true; res = false;} break; + case ST_HEIGHT: { num = heig; calc = true; res = false;} break; + case ST_OPERATOR: { op = signPtr->op; calc = false; res = false;} break; + case ST_VARIABLE: { var = signPtr->var; calc = false; res = true;} break; + case ST_NUMBER: { num = signPtr->num; calc = true; res = false;} break; + } + if (calc) + { + switch (op) + { + case OP_EQUAL: tmp = num; break; + case OP_PLUS: tmp += num; break; + case OP_MINUS: tmp -= num; break; + case OP_MULT: tmp *= num; break; + case OP_DIV: tmp /= num; break; + } + } + else if (res) + { + switch (var) + { + case VAR_1: num = a; break; + case VAR_2: num = b; break; + case VAR_3: num = c; break; + case VAR_4: num = d; break; + case VAR_5: num = e; break; + case VAR_6: num = f; break; + } + switch (op) + { + case OP_EQUAL: tmp = num; break; + case OP_PLUS: tmp += num; break; + case OP_MINUS: tmp -= num; break; + case OP_MULT: tmp *= num; break; + case OP_DIV: tmp /= num; break; + } + } + } + if (i == 1 || i == 8) a = tmp; + if (i == 2 || i == 9) b = tmp; + if (i == 3 || i == 10) c = tmp; + if (i == 4 || i == 11) d = tmp; + if (i == 5 || i == 12) e = tmp; + if (i == 6 || i == 13) f = tmp; + if (i == 7) px = tmp; + if (i == 14) py = tmp; + } + } + pntArray.setPoint(coordList.at(),px,py); + } + } + return pntArray; +} + +QPtrList<ATFInterpreter::AttribList> ATFInterpreter::getAttribList() +{ + if(!attrLs.isEmpty()) + return attrLs; + + AttribList *attribPtr; + + if (!coordList.isEmpty()) + { + for (coordPtr=coordList.first();coordPtr != 0;coordPtr=coordList.next()) + { + attribPtr = new AttribList; + attribPtr->isVariable = coordPtr->isVariable; + attribPtr->pwDiv = coordPtr->pwDiv; + attrLs.append(attribPtr); + } + } + attrLs.setAutoDelete(true); + return attrLs; +} + +void ATFInterpreter::interpret() +{ + QValueStack<int> level; + Value value; + bool v = false; + int pw = 1; + CoordStruct coord; + AttribStruct attrib; + + level.push(LEVEL_NULL); + + for (QStringList::Iterator it=lines.begin(); it!=lines.end(); ++it) + { + if (!(*it).isEmpty() && (*it).at(0) != COMMENT) + { + if (level.top() == LEVEL_NULL) + { + if ((*it) == PNT_BG) + { + coordPtr = new Coord; + level.push(LEVEL_POINT); + } + } + else if (level.top() == LEVEL_POINT) + { + if ((*it) == X_BG) + level.push(LEVEL_X); + else if ((*it) == Y_BG) + level.push(LEVEL_Y); + else if ((*it) == ATTR_BG) + level.push(LEVEL_ATTR); + else if ((*it) == QString(END)) + { + level.pop(); + coordList.append(coordPtr); + } + } + else if (level.top() == LEVEL_X || level.top() == LEVEL_Y || level.top() == LEVEL_ATTR) + { + switch (((*it).at(0)).latin1()) + { + case VAR_1: + { + coord.a = (*it); + value.var1 = getVar(*it); + } break; + case VAR_2: + { + coord.b = (*it); + value.var2 = getVar(*it); + } break; + case VAR_3: + { + coord.c = (*it); + value.var3 = getVar(*it); + } break; + case VAR_4: + { + coord.d = (*it); + value.var4 = getVar(*it); + } break; + case VAR_5: + { + coord.e = (*it); + value.var5 = getVar(*it); + } break; + case VAR_6: + { + coord.f = (*it); + value.var6 = getVar(*it); + } break; + case VAR_X: case VAR_Y: + { + coord.result = (*it); + value.result = getVar(*it); + } break; + case VAR_VARIA: + { + if ((*it).find('0') != -1) v = false; + else v = true; + attrib.isVariable = (*it); + } break; + case VAR_PW: + { + pw = 1; pw = ((*it).at(4)).latin1() - 48; + attrib.pwDiv = (*it); + } break; + case '}': + { + switch (level.top()) + { + case LEVEL_X: + { + coordPtr->pntX = value; + coord.a = QString::null; + coord.b = QString::null; + coord.c = QString::null; + coord.d = QString::null; + coord.e = QString::null; + coord.f = QString::null; + coord.result = QString::null; + } break; + case LEVEL_Y: + { + coordPtr->pntY = value; + coord.a = QString::null; + coord.b = QString::null; + coord.c = QString::null; + coord.d = QString::null; + coord.e = QString::null; + coord.f = QString::null; + coord.result = QString::null; + } break; + case LEVEL_ATTR: + { + coordPtr->isVariable = v; + coordPtr->pwDiv = pw; + pw = 1; + v = false; + attrib.isVariable = QString::null; + attrib.pwDiv = 1; + } break; + } + level.pop(); + } break; + } + } + } + } +} + +QPtrList<ATFInterpreter::Sign> ATFInterpreter::getVar(const QString &s) +{ + QPtrList<Sign> list; + + for (unsigned int i=1; i<s.length(); ++i) + { + if(s.at(i)==' ') + continue; + signPtr = new Sign; + switch (s.at(i).latin1()) + { + case VAR_W: signPtr->type = ST_WIDTH; break; + case VAR_H: signPtr->type = ST_HEIGHT; break; + case VAR_1: + { + signPtr->type = ST_VARIABLE; + signPtr->var = VAR_1; + } break; + case VAR_2: + { + signPtr->type = ST_VARIABLE; + signPtr->var = VAR_2; + } break; + case VAR_3: + { + signPtr->type = ST_VARIABLE; + signPtr->var = VAR_3; + } break; + case VAR_4: + { + signPtr->type = ST_VARIABLE; + signPtr->var = VAR_4; + } break; + case VAR_5: + { + signPtr->type = ST_VARIABLE; + signPtr->var = VAR_5; + } break; + case VAR_6: + { + signPtr->type = ST_VARIABLE; + signPtr->var = VAR_6; + } break; + case OP_EQUAL: + { + signPtr->type = ST_OPERATOR; + signPtr->op = OP_EQUAL; + } break; + case OP_PLUS: + { + signPtr->type = ST_OPERATOR; + signPtr->op = OP_PLUS; + } break; + case OP_MINUS: + { + signPtr->type = ST_OPERATOR; + signPtr->op = OP_MINUS; + } break; + case OP_DIV: + { + signPtr->type = ST_OPERATOR; + signPtr->op = OP_DIV; + } break; + case OP_MULT: + { + signPtr->type = ST_OPERATOR; + signPtr->op = OP_MULT; + } break; + case NUM_0: case NUM_1: case NUM_2: case NUM_3: case NUM_4: + case NUM_5: case NUM_6: case NUM_7: case NUM_8: case NUM_9: + { + signPtr->type = ST_NUMBER; + if (s.length() - 1 > i) + { + switch (s.at(i+1).latin1()) + { + case NUM_0: case NUM_1: case NUM_2: case NUM_3: case NUM_4: + case NUM_5: case NUM_6: case NUM_7: case NUM_8: case NUM_9: + { + signPtr->num = (s.at(i).latin1() - 48) * 10 + s.at(i+1).latin1() - 48; + i++; + } break; + default: + signPtr->num = s.at(i).latin1() - 48; break; + } + } + else + signPtr->num = s.at(i).latin1() - 48; + } break; + } + list.append(signPtr); + } + return list; +} diff --git a/kpresenter/autoformEdit/ATFInterpreter.h b/kpresenter/autoformEdit/ATFInterpreter.h new file mode 100644 index 00000000..8e0feebb --- /dev/null +++ b/kpresenter/autoformEdit/ATFInterpreter.h @@ -0,0 +1,175 @@ +// -*- Mode: c++-mode; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef ATFINTERP_H +#define ATFINTERP_H + +#include <qpointarray.h> +#include <qptrlist.h> +#include <qstringlist.h> + +class ATFInterpreter { + +public: + + // structure of an attribute list + struct AttribList + { + bool isVariable; + int pwDiv; + }; + + // coordinate structure + struct CoordStruct + { + QString a; + QString b; + QString c; + QString d; + QString e; + QString f; + QString result; + }; + + // attribute structure + struct AttribStruct + { + QString isVariable; + QString pwDiv; + }; + + // structure of signs + struct Sign + { + char op; + int num; + char var; + int type; + }; + + // structure of values + struct Value + { + QPtrList<Sign> var1; + QPtrList<Sign> var2; + QPtrList<Sign> var3; + QPtrList<Sign> var4; + QPtrList<Sign> var5; + QPtrList<Sign> var6; + QPtrList<Sign> result; + }; + + // constructure - destructure + ATFInterpreter(); + ~ATFInterpreter(); + + // load autoform + void load(const QString &); + + // get pointarray/attribute list/points + QPointArray getPointArray(int,int); + QPtrList<AttribList> getAttribList(); + +protected: + + // fields + static const int ST_WIDTH; + static const int ST_HEIGHT; + static const int ST_VARIABLE; + static const int ST_NUMBER; + static const int ST_OPERATOR; + + // operators + static const char OP_EQUAL; + static const char OP_PLUS; + static const char OP_MINUS; + static const char OP_MULT; + static const char OP_DIV; + static const char COMMENT; + + // block (structure) beginnings - ends + static const char PNT_BG[]; + static const char X_BG[]; + static const char Y_BG[]; + static const char ATTR_BG[]; + static const char END[]; + + // allowed variables + static const char VAR_1; + static const char VAR_2; + static const char VAR_3; + static const char VAR_4; + static const char VAR_5; + static const char VAR_6; + static const char VAR_X; + static const char VAR_Y; + static const char VAR_VARIA; + static const char VAR_PW; + static const char VAR_W; + static const char VAR_H; + + // level (depth) of the syntax + static const int LEVEL_NULL; + static const int LEVEL_POINT; + static const int LEVEL_X; + static const int LEVEL_Y; + static const int LEVEL_ATTR; + + // numbers + static const char NUM_0; + static const char NUM_1; + static const char NUM_2; + static const char NUM_3; + static const char NUM_4; + static const char NUM_5; + static const char NUM_6; + static const char NUM_7; + static const char NUM_8; + static const char NUM_9; + + // structure of coordinates + struct Coord + { + Value pntX; + Value pntY; + bool isVariable; + int pwDiv; + }; + + // interpret the code + void interpret(); + + // get varaible of a line + QPtrList<Sign> getVar(const QString&); + + // ********** variables ********** + + // list of coordinates and pointers to coordinate/sign/value + QPtrList<Coord> coordList; + QPtrList<AttribList> attrLs; + Coord *coordPtr; + Sign *signPtr; + Value *valuePtr; + + // list of lines + QStringList lines; +}; + +#endif //ATFINTERP_H diff --git a/kpresenter/autoformEdit/Makefile.am b/kpresenter/autoformEdit/Makefile.am new file mode 100644 index 00000000..248b3f25 --- /dev/null +++ b/kpresenter/autoformEdit/Makefile.am @@ -0,0 +1,12 @@ +####### General stuff + +INCLUDES = -I$(srcdir)/.. $(KOFFICE_INCLUDES) $(all_includes) + +####### Files + +noinst_LTLIBRARIES = libaf.la + +libaf_la_SOURCES = ATFInterpreter.cpp AFChoose.cpp + +METASOURCES = AUTO + |