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