1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/xml-base.cpp Mon Jul 27 12:53:19 2009 +0000
1.3 @@ -0,0 +1,106 @@
1.4 +#include "xml-base.h"
1.5 +
1.6 +#include <QMessageBox>
1.7 +#include <QColor>
1.8 +#include <QTextStream>
1.9 +#include <iostream>
1.10 +
1.11 +#include "misc.h"
1.12 +#include "settings.h"
1.13 +#include "linkablemapobj.h"
1.14 +
1.15 +/*
1.16 +static BranchObj *lastBranch;
1.17 +static FloatObj *lastFloat;
1.18 +static OrnamentedObj *lastOO;
1.19 +
1.20 +extern Settings settings;
1.21 +extern QString vymVersion;
1.22 +*/
1.23 +
1.24 +parseBaseHandler::parseBaseHandler() {}
1.25 +
1.26 +parseBaseHandler::~parseBaseHandler() {}
1.27 +
1.28 +QString parseBaseHandler::errorProtocol() { return errorProt; }
1.29 +
1.30 +
1.31 +/*
1.32 +bool parseBaseHandler::startDocument()
1.33 +{
1.34 + errorProt = "";
1.35 + state = StateInit;
1.36 + laststate = StateInit;
1.37 + stateStack.clear();
1.38 + stateStack.append(StateInit);
1.39 + branchDepth=0;
1.40 + htmldata="";
1.41 + isVymPart=false;
1.42 + return true;
1.43 +}
1.44 +*/
1.45 +
1.46 +QString parseBaseHandler::parseHREF(QString href)
1.47 +{
1.48 + QString type=href.section(":",0,0);
1.49 + QString path=href.section(":",1,1);
1.50 + if (!tmpDir.endsWith("/"))
1.51 + return tmpDir + "/" + path;
1.52 + else
1.53 + return tmpDir + path;
1.54 +}
1.55 +
1.56 +
1.57 +/*
1.58 +QString parseBaseHandler::errorString()
1.59 +{
1.60 + return "the document is not in the VYM file format";
1.61 +}
1.62 +*/
1.63 +
1.64 +bool parseBaseHandler::fatalError( const QXmlParseException& exception )
1.65 +{
1.66 + errorProt += QString( "Fatal parsing error: %1 in line %2, column %3\n")
1.67 + .arg( exception.message() )
1.68 + .arg( exception.lineNumber() )
1.69 + .arg( exception.columnNumber() );
1.70 + // Try to read the bogus line
1.71 + errorProt+=QString("File is: %1\n").arg(inputFile);
1.72 + QString s;
1.73 + if (loadStringFromDisk (inputFile,s))
1.74 + {
1.75 + QStringList sl=QStringList::split ("\n",s);
1.76 + int i=1;
1.77 + QStringList::Iterator it = sl.begin();
1.78 + while (i<exception.lineNumber())
1.79 + {
1.80 + it++;
1.81 + i++;
1.82 + }
1.83 + s=*it;
1.84 + s.insert (exception.columnNumber()-1,"<ERROR>");
1.85 + errorProt+=s;
1.86 + }
1.87 + return QXmlDefaultHandler::fatalError( exception );
1.88 +}
1.89 +
1.90 +void parseBaseHandler::setModel (VymModel *m)
1.91 +{
1.92 + model=m;
1.93 +}
1.94 +
1.95 +void parseBaseHandler::setTmpDir (QString tp)
1.96 +{
1.97 + tmpDir=tp;
1.98 +}
1.99 +
1.100 +void parseBaseHandler::setInputFile (QString f)
1.101 +{
1.102 + inputFile=f;
1.103 +}
1.104 +
1.105 +void parseBaseHandler::setLoadMode (const LoadMode &lm)
1.106 +{
1.107 + loadMode=lm;
1.108 +}
1.109 +