1.9.4 New base class for XML based file parsing (vym & Freemind)
authorinsilmaril
Mon, 30 Jul 2007 09:47:29 +0000
changeset 578610cc6d70683
parent 577 6f090a2b10e3
child 579 1c487b3dd40f
1.9.4 New base class for XML based file parsing (vym & Freemind)
tex/vym.changelog
xml.cpp
xml.h
     1.1 --- a/tex/vym.changelog	Mon Jul 30 09:47:15 2007 +0000
     1.2 +++ b/tex/vym.changelog	Mon Jul 30 09:47:29 2007 +0000
     1.3 @@ -1,3 +1,10 @@
     1.4 +-------------------------------------------------------------------
     1.5 +Fri Jul 27 13:31:41 CEST 2007 - uwe
     1.6 +
     1.7 +- Version: 1.9.4
     1.8 +- Feature: Restructured internal handling of XML based maps
     1.9 +- Feature: Switched from QSimpleTextItem to QTextItem for Freemind support
    1.10 +
    1.11  -------------------------------------------------------------------
    1.12  Mon Jul 23 14:40:38 CEST 2007 - uwedr
    1.13  
     2.1 --- a/xml.cpp	Mon Jul 30 09:47:15 2007 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,682 +0,0 @@
     2.4 -#include "xml.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 -#include "version.h"
    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 -parseVYMHandler::parseVYMHandler() {}
    2.24 -
    2.25 -parseVYMHandler::~parseVYMHandler() {}
    2.26 -
    2.27 -QString parseVYMHandler::errorProtocol() { return errorProt; }
    2.28 -
    2.29 -
    2.30 -bool parseVYMHandler::startDocument()
    2.31 -{
    2.32 -    errorProt = "";
    2.33 -    state = StateInit;
    2.34 -    laststate = StateInit;
    2.35 -	stateStack.clear();
    2.36 -	stateStack.append(StateInit);
    2.37 -    branchDepth=0;
    2.38 -	htmldata="";
    2.39 -	isVymPart=false;
    2.40 -    return true;
    2.41 -}
    2.42 -
    2.43 -
    2.44 -QString parseVYMHandler::parseHREF(QString href)
    2.45 -{
    2.46 -	QString type=href.section(":",0,0);
    2.47 -	QString path=href.section(":",1,1);
    2.48 -	if (!tmpDir.endsWith("/"))
    2.49 -		return tmpDir + "/" + path;
    2.50 -	else	
    2.51 -		return tmpDir + path;
    2.52 -}
    2.53 -
    2.54 -bool parseVYMHandler::startElement  ( const QString&, const QString&,
    2.55 -                    const QString& eName, const QXmlAttributes& atts ) 
    2.56 -{
    2.57 -    QColor col;
    2.58 -	/* Testing
    2.59 -	cout << "startElement <"<< eName.ascii()
    2.60 -		<<">  state="<<state 
    2.61 -		<<"  laststate="<<stateStack.last()
    2.62 -		<<"   loadMode="<<loadMode
    2.63 -		<<"       line="<<QXmlDefaultHandler::lineNumber()
    2.64 -		<<endl;
    2.65 -	*/	
    2.66 -	stateStack.append (state);	
    2.67 -    if ( state == StateInit && (eName == "vymmap")  ) 
    2.68 -	{
    2.69 -        state = StateMap;
    2.70 -		if (!atts.value( "version").isEmpty() ) 
    2.71 -		{
    2.72 -			if (!checkVersion(atts.value("version")))
    2.73 -				QMessageBox::warning( 0, "Warning: Version Problem" ,
    2.74 -				   "<h3>Map is newer than VYM</h3>"
    2.75 -				   "<p>The map you are just trying to load was "
    2.76 -				   "saved using vym " +atts.value("version")+". "
    2.77 -				   "The version of this vym is " + vymVersion + 
    2.78 -				   ". If you run into problems after pressing "
    2.79 -				   "the ok-button below, updating vym should help.");
    2.80 -			else	   
    2.81 -				mc->setVersion(atts.value( "version" ));
    2.82 -
    2.83 -		}
    2.84 -		if (loadMode==NewMap || 
    2.85 -			(loadMode==ImportReplace && me->getSelection()==mc))
    2.86 -		{
    2.87 -			if (!atts.value( "author").isEmpty() )
    2.88 -			{
    2.89 -				mc->setAuthor(atts.value( "author" ) );
    2.90 -			}
    2.91 -			if (!atts.value( "comment").isEmpty() )
    2.92 -			{
    2.93 -				mc->setComment (atts.value( "comment" ) );
    2.94 -			}
    2.95 -			if (!atts.value( "backgroundColor").isEmpty() )
    2.96 -			{
    2.97 -				col.setNamedColor(atts.value("backgroundColor"));
    2.98 -				mc->getScene()->setBackgroundBrush(col);
    2.99 -			}	    
   2.100 -			if (!atts.value( "selectionColor").isEmpty() )
   2.101 -			{
   2.102 -				col.setNamedColor(atts.value("selectionColor"));
   2.103 -				me->setSelectionColor(col);
   2.104 -			}	    
   2.105 -			if (!atts.value( "linkColorHint").isEmpty() ) 
   2.106 -			{
   2.107 -				if (atts.value("linkColorHint")=="HeadingColor")
   2.108 -					me->setMapLinkColorHint(LinkableMapObj::HeadingColor);
   2.109 -				else
   2.110 -					me->setMapLinkColorHint(LinkableMapObj::DefaultColor);
   2.111 -			}
   2.112 -			if (!atts.value( "linkStyle").isEmpty() ) 
   2.113 -			{
   2.114 -				me->setMapLinkStyle(atts.value("linkStyle"));
   2.115 -			}	
   2.116 -			if (!atts.value( "linkColor").isEmpty() ) 
   2.117 -			{
   2.118 -				col.setNamedColor(atts.value("linkColor"));
   2.119 -				me->setMapDefLinkColor(col);
   2.120 -			}	
   2.121 -			if (!atts.value( "defXLinkColor").isEmpty() ) 
   2.122 -			{
   2.123 -				col.setNamedColor(atts.value("defXLinkColor"));
   2.124 -				me->setMapDefXLinkColor(col);
   2.125 -			}	
   2.126 -			if (!atts.value( "defXLinkWidth").isEmpty() ) 
   2.127 -			{
   2.128 -				me->setMapDefXLinkWidth(atts.value("defXLinkWidth").toInt ());
   2.129 -			}	
   2.130 -		}	
   2.131 -	} else if ( eName == "select" && state == StateMap ) 
   2.132 -	{
   2.133 -		state=StateMapSelect;
   2.134 -	} else if ( eName == "setting" && state == StateMap ) 
   2.135 -	{
   2.136 -		state=StateMapSetting;
   2.137 -		if (loadMode==NewMap)
   2.138 -			readSettingAttr (atts);
   2.139 -	} else if ( eName == "mapcenter" && state == StateMap ) 
   2.140 -	{
   2.141 -		state=StateMapCenter;
   2.142 -		if (loadMode==NewMap)
   2.143 -		{	
   2.144 -			// Really use the found mapcenter as MCO in a new map
   2.145 -			lastBranch=mc;	// avoid empty pointer
   2.146 -		} else
   2.147 -		{
   2.148 -			// Treat the found mapcenter as a branch 
   2.149 -			// in an existing map
   2.150 -			LinkableMapObj* lmo=me->getSelection();
   2.151 -			if (lmo && (typeid(*lmo) == typeid(BranchObj) ) 
   2.152 -			        || (typeid(*lmo) == typeid(MapCenterObj) ) )
   2.153 -			{
   2.154 -				lastBranch=(BranchObj*)lmo;
   2.155 -				if (loadMode==ImportAdd)
   2.156 -				{
   2.157 -					lastBranch->addBranch();
   2.158 -					lastBranch=lastBranch->getLastBranch();
   2.159 -				} else
   2.160 -					lastBranch->clear();
   2.161 -			} else
   2.162 -				return false;
   2.163 -		}
   2.164 -		readBranchAttr (atts);
   2.165 -	} else if ( 
   2.166 -		(eName == "standardflag" ||eName == "standardFlag") && 
   2.167 -		(state == StateMapCenter || state==StateBranch)) 
   2.168 -	{
   2.169 -		state=StateStandardFlag;
   2.170 -	} else if ( eName == "heading" && (state == StateMapCenter||state==StateBranch)) 
   2.171 -	{
   2.172 -		laststate=state;
   2.173 -		state=StateHeading;
   2.174 -		if (!atts.value( "textColor").isEmpty() ) 
   2.175 -		{
   2.176 -			col.setNamedColor(atts.value("textColor"));
   2.177 -			lastBranch->setColor(col );
   2.178 -		}	    
   2.179 -	} else if ( eName == "note" && 
   2.180 -				(state == StateMapCenter ||state==StateBranch))
   2.181 -	{	// only for backward compatibility (<1.4.6). Use htmlnote now.
   2.182 -		state=StateNote;
   2.183 -		if (!readNoteAttr (atts) ) return false;
   2.184 -	} else if ( eName == "htmlnote" && state == StateMapCenter) 
   2.185 -	{
   2.186 -		laststate=state;
   2.187 -		state=StateHtmlNote;
   2.188 -    } else if ( eName == "floatimage" && 
   2.189 -				(state == StateMapCenter ||state==StateBranch)) 
   2.190 -	{
   2.191 -		state=StateFloatImage;
   2.192 -        lastBranch->addFloatImage();
   2.193 -		lastFloat=lastBranch->getLastFloatImage();
   2.194 -		if (!readFloatImageAttr(atts)) return false;
   2.195 -	} else if ( (eName == "branch"||eName=="floatimage") && state == StateMap) 
   2.196 -	{
   2.197 -		// This is used in vymparts, which have no mapcenter!
   2.198 -		isVymPart=true;
   2.199 -		LinkableMapObj* lmo=me->getSelection();
   2.200 -		if (!lmo)
   2.201 -		{
   2.202 -			// If a vym part is _loaded_ (not imported), 
   2.203 -			// selection==lmo==NULL
   2.204 -			// Treat it like ImportAdd then...
   2.205 -			loadMode=ImportAdd;
   2.206 -			lmo=mc;
   2.207 -		}	
   2.208 -		if (lmo && (typeid(*lmo) == typeid(BranchObj) ) 
   2.209 -				|| (typeid(*lmo) == typeid(MapCenterObj) ) )
   2.210 -		{
   2.211 -			lastBranch=(BranchObj*)(lmo);
   2.212 -			if (eName=="branch")
   2.213 -			{
   2.214 -				state=StateBranch;
   2.215 -				if (loadMode==ImportAdd)
   2.216 -				{
   2.217 -					lastBranch->addBranch();
   2.218 -					lastBranch=lastBranch->getLastBranch();
   2.219 -					
   2.220 -				} else
   2.221 -					lastBranch->clear();
   2.222 -				branchDepth=1;
   2.223 -				readBranchAttr (atts);
   2.224 -			} else if (eName=="floatimage")
   2.225 -			{
   2.226 -				state=StateFloatImage;
   2.227 -				lastBranch->addFloatImage();
   2.228 -				lastFloat=lastBranch->getLastFloatImage();
   2.229 -				if (!readFloatImageAttr(atts)) return false;
   2.230 -			} else return false;
   2.231 -		} else return false;
   2.232 -	} else if ( eName == "branch" && state == StateMapCenter) 
   2.233 -	{
   2.234 -		state=StateBranch;
   2.235 -		branchDepth=1;
   2.236 -		lastBranch->addBranch();
   2.237 -		lastBranch=lastBranch->getLastBranch();
   2.238 -		readBranchAttr (atts);
   2.239 -	} else if ( eName == "htmlnote" && state == StateBranch) 
   2.240 -	{
   2.241 -		laststate=state;
   2.242 -		state=StateHtmlNote;
   2.243 -		no.clear();
   2.244 -		if (!atts.value( "fonthint").isEmpty() ) 
   2.245 -			no.setFontHint(atts.value ("fonthint") );
   2.246 -	} else if ( eName == "frame" && (state == StateBranch||state==StateMapCenter)) 
   2.247 -	{
   2.248 -		laststate=state;
   2.249 -		state=StateFrame;
   2.250 -		if (!readFrameAttr(atts)) return false;
   2.251 -    } else if ( eName == "xlink" && state == StateBranch ) 
   2.252 -	{
   2.253 -		state=StateBranchXLink;
   2.254 -		if (!readXLinkAttr (atts)) return false;
   2.255 -    } else if ( eName == "branch" && state == StateBranch ) 
   2.256 -	{
   2.257 -        lastBranch->addBranch();
   2.258 -		lastBranch=lastBranch->getLastBranch();		
   2.259 -        branchDepth++;
   2.260 -		readBranchAttr (atts);
   2.261 -    } else if ( eName == "html" && state == StateHtmlNote ) 
   2.262 -	{
   2.263 -		state=StateHtml;
   2.264 -		htmldata="<"+eName;
   2.265 -		readHtmlAttr(atts);
   2.266 -		htmldata+=">";
   2.267 -    } else if ( state == StateHtml ) 
   2.268 -	{
   2.269 -		// accept all while in html mode,
   2.270 -		htmldata+="<"+eName;
   2.271 -		readHtmlAttr(atts);
   2.272 -		htmldata+=">";
   2.273 -    } else
   2.274 -        return false;   // Error
   2.275 -    return true;
   2.276 -}
   2.277 -
   2.278 -bool parseVYMHandler::endElement  ( const QString&, const QString&, const QString &eName)
   2.279 -{
   2.280 -	/* Testing
   2.281 -	cout << "endElement </" <<eName.ascii()
   2.282 -		<<">  state=" <<state 
   2.283 -		<<"  laststate=" <<laststate
   2.284 -		<<"  stateStack="<<stateStack.last() 
   2.285 -		<<endl;
   2.286 -	*/
   2.287 -    switch ( state ) 
   2.288 -	{
   2.289 -        case StateBranch: 
   2.290 -			lastBranch=(BranchObj*)(lastBranch->getParObj());
   2.291 -            break;
   2.292 -        case StateHtml: 
   2.293 -			htmldata+="</"+eName+">";
   2.294 -			if (eName=="html")
   2.295 -			{
   2.296 -				state=StateHtmlNote;  
   2.297 -				htmldata.replace ("<br></br>","<br />");
   2.298 -				no.setNote (htmldata);
   2.299 -				lastBranch->setNote (no);
   2.300 -			}	
   2.301 -			break;
   2.302 -		default: 
   2.303 -			break;
   2.304 -    }  
   2.305 -	state=stateStack.takeLast();	
   2.306 -	return true;
   2.307 -}
   2.308 -
   2.309 -bool parseVYMHandler::characters   ( const QString& ch)
   2.310 -{
   2.311 -	//cout << "characters \""<<ch<<"\"  state="<<state <<"  laststate="<<laststate<<endl;
   2.312 -
   2.313 -	QString ch_org=quotemeta (ch);
   2.314 -    QString ch_simplified=ch.simplifyWhiteSpace();
   2.315 -    if ( ch_simplified.isEmpty() ) return true;
   2.316 -
   2.317 -    switch ( state ) 
   2.318 -    {
   2.319 -        case StateInit: break;
   2.320 -        case StateMap: break; 
   2.321 -		case StateMapSelect:
   2.322 -			me->select(ch_simplified);
   2.323 -			break;
   2.324 -		case StateMapSetting:break;
   2.325 -        case StateMapCenter: break;
   2.326 -        case StateNote:
   2.327 -			lastBranch->setNote(ch_simplified);
   2.328 -			break;
   2.329 -        case StateBranch: break;
   2.330 -        case StateStandardFlag: 
   2.331 -            lastBranch->activateStandardFlag(ch_simplified); 
   2.332 -            break;
   2.333 -        case StateFloatImage: break;
   2.334 -        case StateHtmlNote: break;
   2.335 -        case StateHtml:
   2.336 -			htmldata+=ch_org;
   2.337 -			break;
   2.338 -        case StateHeading: 
   2.339 -            lastBranch->setHeading(ch_simplified);
   2.340 -            break;
   2.341 -        default: 
   2.342 -			return false;
   2.343 -    }
   2.344 -    return true;
   2.345 -}
   2.346 -
   2.347 -QString parseVYMHandler::errorString() 
   2.348 -{
   2.349 -    return "the document is not in the VYM file format";
   2.350 -}
   2.351 -
   2.352 -bool parseVYMHandler::fatalError( const QXmlParseException& exception ) 
   2.353 -{
   2.354 -    errorProt += QString( "Fatal parsing error: %1 in line %2, column %3\n")
   2.355 -    .arg( exception.message() )
   2.356 -    .arg( exception.lineNumber() )
   2.357 -    .arg( exception.columnNumber() );
   2.358 -	// Try to read the bogus line
   2.359 -	errorProt+=QString("File is: %1\n").arg(inputFile);
   2.360 -	QString s;
   2.361 -	if (loadStringFromDisk (inputFile,s))
   2.362 -	{
   2.363 -		QStringList sl=QStringList::split ("\n",s);
   2.364 -		int i=1;
   2.365 -		QStringList::Iterator it = sl.begin();
   2.366 -		while (i<exception.lineNumber()-1)
   2.367 -		{
   2.368 -			it++;
   2.369 -			i++;
   2.370 -		}
   2.371 -		s=*it;
   2.372 -		s.insert (exception.columnNumber()-1,"<ERROR>");
   2.373 -		errorProt+=s;
   2.374 -    }
   2.375 -    return QXmlDefaultHandler::fatalError( exception );
   2.376 -}
   2.377 -
   2.378 -void parseVYMHandler::setMapEditor (MapEditor* e)
   2.379 -{
   2.380 -    me=e;
   2.381 -	mc=me->getMapCenter();
   2.382 -}
   2.383 -
   2.384 -void parseVYMHandler::setTmpDir (QString tp)
   2.385 -{
   2.386 -	tmpDir=tp;
   2.387 -}
   2.388 -
   2.389 -void parseVYMHandler::setInputFile (QString f)
   2.390 -{
   2.391 -	inputFile=f;
   2.392 -}
   2.393 -
   2.394 -void parseVYMHandler::setLoadMode (const LoadMode &lm)
   2.395 -{
   2.396 -	loadMode=lm;
   2.397 -}
   2.398 -
   2.399 -bool parseVYMHandler::readBranchAttr (const QXmlAttributes& a)
   2.400 -{
   2.401 -	lastOO=lastBranch;
   2.402 -	if (!readOOAttr(a)) return false;
   2.403 -
   2.404 -	if (!a.value( "scrolled").isEmpty() )
   2.405 -		lastBranch->toggleScroll();
   2.406 -	if (!a.value( "frameType").isEmpty() ) 
   2.407 -		lastOO->setFrameType (a.value("frameType")); //Compatibility 1.8.1
   2.408 -
   2.409 -	if (!a.value( "incImgV").isEmpty() ) 
   2.410 -	{	
   2.411 -		if (a.value("incImgV")=="true")
   2.412 -			lastBranch->setIncludeImagesVer(true);
   2.413 -		else	
   2.414 -			lastBranch->setIncludeImagesVer(false);
   2.415 -	}	
   2.416 -	if (!a.value( "incImgH").isEmpty() ) 
   2.417 -	{	
   2.418 -		if (a.value("incImgH")=="true")
   2.419 -			lastBranch->setIncludeImagesHor(true);
   2.420 -		else	
   2.421 -			lastBranch->setIncludeImagesHor(false);
   2.422 -	}	
   2.423 -	return true;	
   2.424 -}
   2.425 -
   2.426 -bool parseVYMHandler::readFrameAttr (const QXmlAttributes& a)
   2.427 -{
   2.428 -	bool ok;
   2.429 -	int x;
   2.430 -	if (lastOO)
   2.431 -	{
   2.432 -		if (!a.value( "frameType").isEmpty() ) 
   2.433 -			lastOO->setFrameType (a.value("frameType"));
   2.434 -		if (!a.value( "penColor").isEmpty() ) 
   2.435 -			lastOO->setFramePenColor (a.value("penColor"));
   2.436 -		if (!a.value( "brushColor").isEmpty() ) 
   2.437 -			lastOO->setFrameBrushColor (a.value("brushColor"));
   2.438 -		if (!a.value( "padding").isEmpty() ) 
   2.439 -		{
   2.440 -			x=a.value("padding").toInt(&ok);
   2.441 -			if (ok) lastOO->setFramePadding(x);
   2.442 -		}	
   2.443 -		if (!a.value( "borderWidth").isEmpty() ) 
   2.444 -		{
   2.445 -			x=a.value("borderWidth").toInt(&ok);
   2.446 -			if (ok) lastOO->setFrameBorderWidth(x);
   2.447 -		}	
   2.448 -	}		
   2.449 -	return true;
   2.450 -}
   2.451 -
   2.452 -bool parseVYMHandler::readOOAttr (const QXmlAttributes& a)
   2.453 -{
   2.454 -	if (lastOO)
   2.455 -	{
   2.456 -		bool okx,oky;
   2.457 -		int x,y;
   2.458 -		if (!a.value( "relPosX").isEmpty() ) 
   2.459 -		{
   2.460 -			if (!a.value( "relPosY").isEmpty() ) 
   2.461 -			{
   2.462 -				x=a.value("relPosX").toInt (&okx, 10);
   2.463 -				y=a.value("relPosY").toInt (&oky, 10);
   2.464 -				if (okx && oky  )
   2.465 -				{
   2.466 -					lastOO->setUseRelPos (true);
   2.467 -					lastOO->move2RelPos (x,y);
   2.468 -				}	
   2.469 -				else
   2.470 -					return false;   // Couldn't read relPos
   2.471 -			}           
   2.472 -		}           
   2.473 -		if (!a.value( "absPosX").isEmpty() && loadMode==NewMap && branchDepth<2) 
   2.474 -		{
   2.475 -			if (!a.value( "absPosY").isEmpty() ) 
   2.476 -			{
   2.477 -				x=a.value("absPosX").toInt (&okx, 10);
   2.478 -				y=a.value("absPosY").toInt (&oky, 10);
   2.479 -				if (okx && oky  )
   2.480 -					lastOO->move(x,y);
   2.481 -				else
   2.482 -					return false;   // Couldn't read absPos
   2.483 -			}           
   2.484 -		}           
   2.485 -		if (!a.value( "id").isEmpty() ) 
   2.486 -			lastOO->setID (a.value ("id"));
   2.487 -		if (!a.value( "url").isEmpty() ) 
   2.488 -			lastOO->setURL (a.value ("url"));
   2.489 -		if (!a.value( "vymLink").isEmpty() ) 
   2.490 -			lastOO->setVymLink (a.value ("vymLink"));
   2.491 -		if (!a.value( "hideInExport").isEmpty() ) 
   2.492 -			if (a.value("hideInExport")=="true")
   2.493 -				lastOO->setHideInExport(true);
   2.494 -
   2.495 -		if (!a.value( "hideLink").isEmpty()) 
   2.496 -		{
   2.497 -			if (a.value ("hideLink") =="true")
   2.498 -				lastOO->setHideLinkUnselected(true);
   2.499 -			else	
   2.500 -				lastOO->setHideLinkUnselected(false);
   2.501 -		}	
   2.502 -	}
   2.503 -	return true;	
   2.504 -}
   2.505 -
   2.506 -bool parseVYMHandler::readNoteAttr (const QXmlAttributes& a)
   2.507 -{	// only for backward compatibility (<1.4.6). Use htmlnote now.
   2.508 -	no.clear();
   2.509 -	QString fn;
   2.510 -	if (!a.value( "href").isEmpty() ) 
   2.511 -	{
   2.512 -		// Load note
   2.513 -		fn=parseHREF(a.value ("href") );
   2.514 -		QFile file (fn);
   2.515 -		QString s;						// Reading a note
   2.516 -
   2.517 -		if ( !file.open( QIODevice::ReadOnly) )
   2.518 -		{
   2.519 -			qWarning ("parseVYMHandler::readNoteAttr:  Couldn't load "+fn);
   2.520 -			return false;
   2.521 -		}	
   2.522 -		QTextStream stream( &file );
   2.523 -		QString lines;
   2.524 -		while ( !stream.atEnd() ) {
   2.525 -			lines += stream.readLine()+"\n"; 
   2.526 -		}
   2.527 -		file.close();
   2.528 -
   2.529 -		lines ="<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body>"+lines + "</p></body></html>";
   2.530 -		no.setNote (lines);
   2.531 -	}		
   2.532 -	if (!a.value( "fonthint").isEmpty() ) 
   2.533 -		no.setFontHint(a.value ("fonthint") );
   2.534 -	lastBranch->setNote(no);
   2.535 -	return true;
   2.536 -}
   2.537 -
   2.538 -bool parseVYMHandler::readFloatImageAttr (const QXmlAttributes& a)
   2.539 -{
   2.540 -	lastOO=lastFloat;
   2.541 -	
   2.542 -	//if (!readOOAttr(a)) return false;
   2.543 -
   2.544 -	if (!a.value( "useOrientation").isEmpty() ) 
   2.545 -	{
   2.546 -		if (a.value ("useOrientation") =="true")
   2.547 -			lastFloat->setUseOrientation (true);
   2.548 -		else	
   2.549 -			lastFloat->setUseOrientation (false);
   2.550 -	}	
   2.551 -	if (!a.value( "href").isEmpty() )
   2.552 -	{
   2.553 -		// Load FloatImage
   2.554 -		if (!lastFloat->load (parseHREF(a.value ("href") ) ))
   2.555 -		{
   2.556 -			QMessageBox::warning( 0, "Warning: " ,
   2.557 -				"Couldn't load float image\n"+parseHREF(a.value ("href") ));
   2.558 -			lastBranch->removeFloatImage(((FloatImageObj*)(lastFloat)));
   2.559 -			lastFloat=NULL;
   2.560 -			return true;
   2.561 -		}
   2.562 -		
   2.563 -	}	
   2.564 -	if (!a.value( "floatExport").isEmpty() ) 
   2.565 -	{
   2.566 -		// Only for compatibility. THis is not used since 1.7.11 
   2.567 -		if (a.value ("floatExport") =="true")
   2.568 -			lastFloat->setFloatExport(true);
   2.569 -		else	
   2.570 -			lastFloat->setFloatExport (false);
   2.571 -	}	
   2.572 -	if (!a.value( "zPlane").isEmpty() ) 
   2.573 -		lastFloat->setZValue (a.value("zPlane").toInt ());
   2.574 -    int x,y;
   2.575 -    bool okx,oky;
   2.576 -	if (!a.value( "relPosX").isEmpty() ) 
   2.577 -	{
   2.578 -		if (!a.value( "relPosY").isEmpty() ) 
   2.579 -		{
   2.580 -			// read relPos
   2.581 -			x=a.value("relPosX").toInt (&okx, 10);
   2.582 -			y=a.value("relPosY").toInt (&oky, 10);
   2.583 -			if (okx && oky) 
   2.584 -				
   2.585 -				{
   2.586 -					lastFloat->setRelPos (QPoint (x,y) );
   2.587 -					// make sure floats in mapcenter are repositioned to relative pos
   2.588 -					if (mc==lastBranch) mc->positionContents();
   2.589 -				}
   2.590 -			else
   2.591 -				// Couldn't read relPos
   2.592 -				return false;  
   2.593 -		}           
   2.594 -	}	
   2.595 -	
   2.596 -	if (!readOOAttr(a)) return false;
   2.597 -
   2.598 -	if (!a.value ("orgName").isEmpty() )
   2.599 -	{
   2.600 -		((FloatImageObj*)(lastFloat))->setOriginalFilename (a.value("orgName"));
   2.601 -	}
   2.602 -	return true;
   2.603 -}
   2.604 -
   2.605 -bool parseVYMHandler::readXLinkAttr (const QXmlAttributes& a)
   2.606 -{
   2.607 -	QColor col;
   2.608 -	bool okx;
   2.609 -	bool success=false;
   2.610 -	XLinkObj *xlo=new XLinkObj (mc->getScene());
   2.611 -	if (!a.value( "color").isEmpty() ) 
   2.612 -	{
   2.613 -		col.setNamedColor(a.value("color"));
   2.614 -		xlo->setColor (col);
   2.615 -	}
   2.616 -
   2.617 -	if (!a.value( "width").isEmpty() ) 
   2.618 -	{
   2.619 -		xlo->setWidth(a.value ("width").toInt (&okx, 10));
   2.620 -	}
   2.621 -
   2.622 -	// Connecting by select string for compatibility with version < 1.8.76
   2.623 -	if (!a.value( "beginBranch").isEmpty() ) 
   2.624 -	{ 
   2.625 -		if (!a.value( "endBranch").isEmpty() ) 
   2.626 -		{
   2.627 -			LinkableMapObj *lmo=mc->findObjBySelect (a.value( "beginBranch"));
   2.628 -			if (lmo && typeid (*lmo)==typeid (BranchObj))
   2.629 -			{
   2.630 -				xlo->setBegin ((BranchObj*)lmo);
   2.631 -				lmo=mc->findObjBySelect (a.value( "endBranch"));
   2.632 -				if (lmo && typeid (*lmo)==typeid (BranchObj))
   2.633 -				{
   2.634 -					xlo->setEnd ((BranchObj*)(lmo));
   2.635 -					xlo->activate();
   2.636 -				}
   2.637 -			}
   2.638 -			success=true; // Not all branches there yet, no error
   2.639 -		}           
   2.640 -	}	
   2.641 -
   2.642 -	// object ID is used starting in version 1.8.76
   2.643 -	if (!a.value( "beginID").isEmpty() ) 
   2.644 -	{ 
   2.645 -		if (!a.value( "endID").isEmpty() ) 
   2.646 -		{
   2.647 -			LinkableMapObj *lmo=mc->findID (a.value( "beginBranch"));
   2.648 -			if (lmo && typeid (*lmo)==typeid (BranchObj))
   2.649 -			{
   2.650 -				xlo->setBegin ((BranchObj*)lmo);
   2.651 -				lmo=mc->findID (a.value( "endID"));
   2.652 -				if (lmo && typeid (*lmo)==typeid (BranchObj))
   2.653 -				{
   2.654 -					xlo->setEnd ((BranchObj*)(lmo));
   2.655 -					xlo->activate();
   2.656 -				}
   2.657 -			}
   2.658 -			success=true; // Not all branches there yet, no error
   2.659 -		}           
   2.660 -	}	
   2.661 -	if (!success) delete (xlo);
   2.662 -	return success;
   2.663 -}
   2.664 -
   2.665 -bool parseVYMHandler::readHtmlAttr (const QXmlAttributes& a)
   2.666 -{
   2.667 -	for (int i=1; i<=a.count(); i++)
   2.668 -		htmldata+=" "+a.localName(i-1)+"=\""+a.value(i-1)+"\"";
   2.669 -	return true;
   2.670 -}
   2.671 -
   2.672 -bool parseVYMHandler::readSettingAttr (const QXmlAttributes& a)
   2.673 -{
   2.674 -	if (!a.value( "key").isEmpty() ) 
   2.675 -	{
   2.676 -		if (!a.value( "value").isEmpty() ) 
   2.677 -			settings.setLocalEntry (me->getDestPath(), a.value ("key"), a.value ("value"));
   2.678 -		else
   2.679 -			return false;
   2.680 -		
   2.681 -	} else
   2.682 -		return false;
   2.683 -	
   2.684 -	return true;
   2.685 -}
     3.1 --- a/xml.h	Mon Jul 30 09:47:15 2007 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,74 +0,0 @@
     3.4 -#ifndef XML_H
     3.5 -#define XML_H
     3.6 -
     3.7 -
     3.8 -#include <QString>
     3.9 -#include <QXmlAttributes>
    3.10 -
    3.11 -#include "file.h"
    3.12 -#include "mapcenterobj.h"
    3.13 -#include "mapeditor.h"
    3.14 -
    3.15 -
    3.16 -class parseVYMHandler  : public QXmlDefaultHandler
    3.17 -{
    3.18 -public:
    3.19 -	parseVYMHandler();
    3.20 -	~parseVYMHandler();
    3.21 -	QString errorProtocol();
    3.22 -	bool startDocument();
    3.23 -	QString parseHREF(QString);
    3.24 -	bool startElement ( const QString&, const QString&,
    3.25 -                        const QString& eName, const QXmlAttributes& atts ); 
    3.26 -	bool   endElement ( const QString&, const QString&, const QString& ); 
    3.27 -	bool characters   ( const QString&);
    3.28 -	QString errorString();
    3.29 -	bool fatalError( const QXmlParseException&);
    3.30 -	void setMapEditor (MapEditor*);
    3.31 -	void setTmpDir (QString);
    3.32 -	void setInputFile (QString);
    3.33 -	void setLoadMode (const LoadMode &);
    3.34 -	bool readBranchAttr (const QXmlAttributes&);
    3.35 -	bool readFrameAttr (const QXmlAttributes&);
    3.36 -	bool readOOAttr (const QXmlAttributes&);
    3.37 -	bool readNoteAttr (const QXmlAttributes&);
    3.38 -	bool readFloatImageAttr (const QXmlAttributes&);
    3.39 -	bool readXLinkAttr (const QXmlAttributes&);
    3.40 -	bool readHtmlAttr (const QXmlAttributes&);
    3.41 -	bool readSettingAttr (const QXmlAttributes&);
    3.42 -
    3.43 -private:
    3.44 -	QString     errorProt;
    3.45 -	enum State 
    3.46 -	{ 
    3.47 -		StateInit, 
    3.48 -		StateMap, 
    3.49 -		StateMapSelect, 
    3.50 -		StateMapSetting,
    3.51 -		StateMapCenter, 
    3.52 -		StateBranch, 
    3.53 -		StateBranchXLink,			//
    3.54 -		StateHtmlNote, 
    3.55 -		StateHtml, 
    3.56 -		StateFrame,
    3.57 -		StateStandardFlag,
    3.58 -		StateNote,
    3.59 -		StateFloatImage,
    3.60 -		StateHeading
    3.61 -	 };
    3.62 -				 
    3.63 -
    3.64 -	LoadMode loadMode;
    3.65 -	bool isVymPart;
    3.66 -	State state;			 
    3.67 -	State laststate;
    3.68 -	QList <State> stateStack;
    3.69 -	QString htmldata;
    3.70 -	int branchDepth; 
    3.71 -	NoteObj no;
    3.72 -	MapCenterObj* mc;
    3.73 -	MapEditor* me; 
    3.74 -	QString tmpDir; 
    3.75 -	QString inputFile;
    3.76 -}; 
    3.77 -#endif