Fixed wrong linenumber in error message of XML parser release-1-12-maintained
authorinsilmaril
Wed, 06 May 2009 09:50:08 +0000
branchrelease-1-12-maintained
changeset 676c6aa8d5e9b6
parent 66 c4893070033f
child 68 3f25bb36200e
Fixed wrong linenumber in error message of XML parser
version.h
xml-base.cpp
     1.1 --- a/version.h	Wed Apr 08 12:02:07 2009 +0000
     1.2 +++ b/version.h	Wed May 06 09:50:08 2009 +0000
     1.3 @@ -7,7 +7,7 @@
     1.4  #define __VYM_VERSION "1.12.2h"
     1.5  #define __VYM_CODENAME "Maintenance Update "
     1.6  //#define __VYM_CODENAME "Codename: development version"
     1.7 -#define __VYM_BUILD_DATE "2009-04-08"
     1.8 +#define __VYM_BUILD_DATE "2009-05-06"
     1.9  
    1.10  
    1.11  bool checkVersion(const QString &);
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/xml-base.cpp	Wed May 06 09:50:08 2009 +0000
     2.3 @@ -0,0 +1,106 @@
     2.4 +#include "xml-base.h"
     2.5 +
     2.6 +#include <QMessageBox>
     2.7 +#include <QColor>
     2.8 +#include <QTextStream>
     2.9 +#include <iostream>
    2.10 +
    2.11 +#include "misc.h"
    2.12 +#include "settings.h"
    2.13 +#include "linkablemapobj.h"
    2.14 +
    2.15 +/*
    2.16 +static BranchObj *lastBranch;
    2.17 +static FloatObj *lastFloat;
    2.18 +static OrnamentedObj *lastOO;
    2.19 +
    2.20 +extern Settings settings;
    2.21 +extern QString vymVersion;
    2.22 +*/
    2.23 +
    2.24 +parseBaseHandler::parseBaseHandler() {}
    2.25 +
    2.26 +parseBaseHandler::~parseBaseHandler() {}
    2.27 +
    2.28 +QString parseBaseHandler::errorProtocol() { return errorProt; }
    2.29 +
    2.30 +
    2.31 +/*
    2.32 +bool parseBaseHandler::startDocument()
    2.33 +{
    2.34 +    errorProt = "";
    2.35 +    state = StateInit;
    2.36 +    laststate = StateInit;
    2.37 +	stateStack.clear();
    2.38 +	stateStack.append(StateInit);
    2.39 +    branchDepth=0;
    2.40 +	htmldata="";
    2.41 +	isVymPart=false;
    2.42 +    return true;
    2.43 +}
    2.44 +*/
    2.45 +
    2.46 +QString parseBaseHandler::parseHREF(QString href)
    2.47 +{
    2.48 +	QString type=href.section(":",0,0);
    2.49 +	QString path=href.section(":",1,1);
    2.50 +	if (!tmpDir.endsWith("/"))
    2.51 +		return tmpDir + "/" + path;
    2.52 +	else	
    2.53 +		return tmpDir + path;
    2.54 +}
    2.55 +
    2.56 +
    2.57 +/*
    2.58 +QString parseBaseHandler::errorString() 
    2.59 +{
    2.60 +    return "the document is not in the VYM file format";
    2.61 +}
    2.62 +*/
    2.63 +
    2.64 +bool parseBaseHandler::fatalError( const QXmlParseException& exception ) 
    2.65 +{
    2.66 +    errorProt += QString( "Fatal parsing error: %1 in line %2, column %3\n")
    2.67 +    .arg( exception.message() )
    2.68 +    .arg( exception.lineNumber() )
    2.69 +    .arg( exception.columnNumber() );
    2.70 +	// Try to read the bogus line
    2.71 +	errorProt+=QString("File is: %1\n").arg(inputFile);
    2.72 +	QString s;
    2.73 +	if (loadStringFromDisk (inputFile,s))
    2.74 +	{
    2.75 +		QStringList sl=QStringList::split ("\n",s);
    2.76 +		int i=1;
    2.77 +		QStringList::Iterator it = sl.begin();
    2.78 +		while (i<exception.lineNumber())
    2.79 +		{
    2.80 +			it++;
    2.81 +			i++;
    2.82 +		}
    2.83 +		s=*it;
    2.84 +		s.insert (exception.columnNumber()-1,"<ERROR>");
    2.85 +		errorProt+=s;
    2.86 +    }
    2.87 +    return QXmlDefaultHandler::fatalError( exception );
    2.88 +}
    2.89 +
    2.90 +void parseBaseHandler::setModel (VymModel *m)
    2.91 +{
    2.92 +	model=m;
    2.93 +}
    2.94 +
    2.95 +void parseBaseHandler::setTmpDir (QString tp)
    2.96 +{
    2.97 +	tmpDir=tp;
    2.98 +}
    2.99 +
   2.100 +void parseBaseHandler::setInputFile (QString f)
   2.101 +{
   2.102 +	inputFile=f;
   2.103 +}
   2.104 +
   2.105 +void parseBaseHandler::setLoadMode (const LoadMode &lm)
   2.106 +{
   2.107 +	loadMode=lm;
   2.108 +}
   2.109 +