xml-base.cpp
author insilmaril
Mon, 07 Jan 2008 14:52:49 +0000
changeset 637 0ff5fc89dc5c
parent 574 56fa27b2be3e
child 646 371945eb6d31
permissions -rw-r--r--
Included french in vym.pro
     1 #include "xml-base.h"
     2 
     3 #include <QMessageBox>
     4 #include <QColor>
     5 #include <QTextStream>
     6 #include <iostream>
     7 
     8 #include "misc.h"
     9 #include "settings.h"
    10 #include "linkablemapobj.h"
    11 #include "version.h"
    12 
    13 /*
    14 static BranchObj *lastBranch;
    15 static FloatObj *lastFloat;
    16 static OrnamentedObj *lastOO;
    17 
    18 extern Settings settings;
    19 extern QString vymVersion;
    20 */
    21 
    22 parseBaseHandler::parseBaseHandler() {}
    23 
    24 parseBaseHandler::~parseBaseHandler() {}
    25 
    26 QString parseBaseHandler::errorProtocol() { return errorProt; }
    27 
    28 
    29 /*
    30 bool parseBaseHandler::startDocument()
    31 {
    32     errorProt = "";
    33     state = StateInit;
    34     laststate = StateInit;
    35 	stateStack.clear();
    36 	stateStack.append(StateInit);
    37     branchDepth=0;
    38 	htmldata="";
    39 	isVymPart=false;
    40     return true;
    41 }
    42 */
    43 
    44 QString parseBaseHandler::parseHREF(QString href)
    45 {
    46 	QString type=href.section(":",0,0);
    47 	QString path=href.section(":",1,1);
    48 	if (!tmpDir.endsWith("/"))
    49 		return tmpDir + "/" + path;
    50 	else	
    51 		return tmpDir + path;
    52 }
    53 
    54 
    55 /*
    56 QString parseBaseHandler::errorString() 
    57 {
    58     return "the document is not in the VYM file format";
    59 }
    60 */
    61 
    62 bool parseBaseHandler::fatalError( const QXmlParseException& exception ) 
    63 {
    64     errorProt += QString( "Fatal parsing error: %1 in line %2, column %3\n")
    65     .arg( exception.message() )
    66     .arg( exception.lineNumber() )
    67     .arg( exception.columnNumber() );
    68 	// Try to read the bogus line
    69 	errorProt+=QString("File is: %1\n").arg(inputFile);
    70 	QString s;
    71 	if (loadStringFromDisk (inputFile,s))
    72 	{
    73 		QStringList sl=QStringList::split ("\n",s);
    74 		int i=1;
    75 		QStringList::Iterator it = sl.begin();
    76 		while (i<exception.lineNumber()-1)
    77 		{
    78 			it++;
    79 			i++;
    80 		}
    81 		s=*it;
    82 		s.insert (exception.columnNumber()-1,"<ERROR>");
    83 		errorProt+=s;
    84     }
    85     return QXmlDefaultHandler::fatalError( exception );
    86 }
    87 
    88 void parseBaseHandler::setMapEditor (MapEditor* e)
    89 {
    90     me=e;
    91 	mc=me->getMapCenter();
    92 }
    93 
    94 void parseBaseHandler::setTmpDir (QString tp)
    95 {
    96 	tmpDir=tp;
    97 }
    98 
    99 void parseBaseHandler::setInputFile (QString f)
   100 {
   101 	inputFile=f;
   102 }
   103 
   104 void parseBaseHandler::setLoadMode (const LoadMode &lm)
   105 {
   106 	loadMode=lm;
   107 }
   108