xml.cpp
changeset 578 610cc6d70683
parent 577 6f090a2b10e3
child 579 1c487b3dd40f
     1.1 --- a/xml.cpp	Mon Jul 30 09:47:15 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,682 +0,0 @@
     1.4 -#include "xml.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 -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 -parseVYMHandler::parseVYMHandler() {}
    1.24 -
    1.25 -parseVYMHandler::~parseVYMHandler() {}
    1.26 -
    1.27 -QString parseVYMHandler::errorProtocol() { return errorProt; }
    1.28 -
    1.29 -
    1.30 -bool parseVYMHandler::startDocument()
    1.31 -{
    1.32 -    errorProt = "";
    1.33 -    state = StateInit;
    1.34 -    laststate = StateInit;
    1.35 -	stateStack.clear();
    1.36 -	stateStack.append(StateInit);
    1.37 -    branchDepth=0;
    1.38 -	htmldata="";
    1.39 -	isVymPart=false;
    1.40 -    return true;
    1.41 -}
    1.42 -
    1.43 -
    1.44 -QString parseVYMHandler::parseHREF(QString href)
    1.45 -{
    1.46 -	QString type=href.section(":",0,0);
    1.47 -	QString path=href.section(":",1,1);
    1.48 -	if (!tmpDir.endsWith("/"))
    1.49 -		return tmpDir + "/" + path;
    1.50 -	else	
    1.51 -		return tmpDir + path;
    1.52 -}
    1.53 -
    1.54 -bool parseVYMHandler::startElement  ( const QString&, const QString&,
    1.55 -                    const QString& eName, const QXmlAttributes& atts ) 
    1.56 -{
    1.57 -    QColor col;
    1.58 -	/* Testing
    1.59 -	cout << "startElement <"<< eName.ascii()
    1.60 -		<<">  state="<<state 
    1.61 -		<<"  laststate="<<stateStack.last()
    1.62 -		<<"   loadMode="<<loadMode
    1.63 -		<<"       line="<<QXmlDefaultHandler::lineNumber()
    1.64 -		<<endl;
    1.65 -	*/	
    1.66 -	stateStack.append (state);	
    1.67 -    if ( state == StateInit && (eName == "vymmap")  ) 
    1.68 -	{
    1.69 -        state = StateMap;
    1.70 -		if (!atts.value( "version").isEmpty() ) 
    1.71 -		{
    1.72 -			if (!checkVersion(atts.value("version")))
    1.73 -				QMessageBox::warning( 0, "Warning: Version Problem" ,
    1.74 -				   "<h3>Map is newer than VYM</h3>"
    1.75 -				   "<p>The map you are just trying to load was "
    1.76 -				   "saved using vym " +atts.value("version")+". "
    1.77 -				   "The version of this vym is " + vymVersion + 
    1.78 -				   ". If you run into problems after pressing "
    1.79 -				   "the ok-button below, updating vym should help.");
    1.80 -			else	   
    1.81 -				mc->setVersion(atts.value( "version" ));
    1.82 -
    1.83 -		}
    1.84 -		if (loadMode==NewMap || 
    1.85 -			(loadMode==ImportReplace && me->getSelection()==mc))
    1.86 -		{
    1.87 -			if (!atts.value( "author").isEmpty() )
    1.88 -			{
    1.89 -				mc->setAuthor(atts.value( "author" ) );
    1.90 -			}
    1.91 -			if (!atts.value( "comment").isEmpty() )
    1.92 -			{
    1.93 -				mc->setComment (atts.value( "comment" ) );
    1.94 -			}
    1.95 -			if (!atts.value( "backgroundColor").isEmpty() )
    1.96 -			{
    1.97 -				col.setNamedColor(atts.value("backgroundColor"));
    1.98 -				mc->getScene()->setBackgroundBrush(col);
    1.99 -			}	    
   1.100 -			if (!atts.value( "selectionColor").isEmpty() )
   1.101 -			{
   1.102 -				col.setNamedColor(atts.value("selectionColor"));
   1.103 -				me->setSelectionColor(col);
   1.104 -			}	    
   1.105 -			if (!atts.value( "linkColorHint").isEmpty() ) 
   1.106 -			{
   1.107 -				if (atts.value("linkColorHint")=="HeadingColor")
   1.108 -					me->setMapLinkColorHint(LinkableMapObj::HeadingColor);
   1.109 -				else
   1.110 -					me->setMapLinkColorHint(LinkableMapObj::DefaultColor);
   1.111 -			}
   1.112 -			if (!atts.value( "linkStyle").isEmpty() ) 
   1.113 -			{
   1.114 -				me->setMapLinkStyle(atts.value("linkStyle"));
   1.115 -			}	
   1.116 -			if (!atts.value( "linkColor").isEmpty() ) 
   1.117 -			{
   1.118 -				col.setNamedColor(atts.value("linkColor"));
   1.119 -				me->setMapDefLinkColor(col);
   1.120 -			}	
   1.121 -			if (!atts.value( "defXLinkColor").isEmpty() ) 
   1.122 -			{
   1.123 -				col.setNamedColor(atts.value("defXLinkColor"));
   1.124 -				me->setMapDefXLinkColor(col);
   1.125 -			}	
   1.126 -			if (!atts.value( "defXLinkWidth").isEmpty() ) 
   1.127 -			{
   1.128 -				me->setMapDefXLinkWidth(atts.value("defXLinkWidth").toInt ());
   1.129 -			}	
   1.130 -		}	
   1.131 -	} else if ( eName == "select" && state == StateMap ) 
   1.132 -	{
   1.133 -		state=StateMapSelect;
   1.134 -	} else if ( eName == "setting" && state == StateMap ) 
   1.135 -	{
   1.136 -		state=StateMapSetting;
   1.137 -		if (loadMode==NewMap)
   1.138 -			readSettingAttr (atts);
   1.139 -	} else if ( eName == "mapcenter" && state == StateMap ) 
   1.140 -	{
   1.141 -		state=StateMapCenter;
   1.142 -		if (loadMode==NewMap)
   1.143 -		{	
   1.144 -			// Really use the found mapcenter as MCO in a new map
   1.145 -			lastBranch=mc;	// avoid empty pointer
   1.146 -		} else
   1.147 -		{
   1.148 -			// Treat the found mapcenter as a branch 
   1.149 -			// in an existing map
   1.150 -			LinkableMapObj* lmo=me->getSelection();
   1.151 -			if (lmo && (typeid(*lmo) == typeid(BranchObj) ) 
   1.152 -			        || (typeid(*lmo) == typeid(MapCenterObj) ) )
   1.153 -			{
   1.154 -				lastBranch=(BranchObj*)lmo;
   1.155 -				if (loadMode==ImportAdd)
   1.156 -				{
   1.157 -					lastBranch->addBranch();
   1.158 -					lastBranch=lastBranch->getLastBranch();
   1.159 -				} else
   1.160 -					lastBranch->clear();
   1.161 -			} else
   1.162 -				return false;
   1.163 -		}
   1.164 -		readBranchAttr (atts);
   1.165 -	} else if ( 
   1.166 -		(eName == "standardflag" ||eName == "standardFlag") && 
   1.167 -		(state == StateMapCenter || state==StateBranch)) 
   1.168 -	{
   1.169 -		state=StateStandardFlag;
   1.170 -	} else if ( eName == "heading" && (state == StateMapCenter||state==StateBranch)) 
   1.171 -	{
   1.172 -		laststate=state;
   1.173 -		state=StateHeading;
   1.174 -		if (!atts.value( "textColor").isEmpty() ) 
   1.175 -		{
   1.176 -			col.setNamedColor(atts.value("textColor"));
   1.177 -			lastBranch->setColor(col );
   1.178 -		}	    
   1.179 -	} else if ( eName == "note" && 
   1.180 -				(state == StateMapCenter ||state==StateBranch))
   1.181 -	{	// only for backward compatibility (<1.4.6). Use htmlnote now.
   1.182 -		state=StateNote;
   1.183 -		if (!readNoteAttr (atts) ) return false;
   1.184 -	} else if ( eName == "htmlnote" && state == StateMapCenter) 
   1.185 -	{
   1.186 -		laststate=state;
   1.187 -		state=StateHtmlNote;
   1.188 -    } else if ( eName == "floatimage" && 
   1.189 -				(state == StateMapCenter ||state==StateBranch)) 
   1.190 -	{
   1.191 -		state=StateFloatImage;
   1.192 -        lastBranch->addFloatImage();
   1.193 -		lastFloat=lastBranch->getLastFloatImage();
   1.194 -		if (!readFloatImageAttr(atts)) return false;
   1.195 -	} else if ( (eName == "branch"||eName=="floatimage") && state == StateMap) 
   1.196 -	{
   1.197 -		// This is used in vymparts, which have no mapcenter!
   1.198 -		isVymPart=true;
   1.199 -		LinkableMapObj* lmo=me->getSelection();
   1.200 -		if (!lmo)
   1.201 -		{
   1.202 -			// If a vym part is _loaded_ (not imported), 
   1.203 -			// selection==lmo==NULL
   1.204 -			// Treat it like ImportAdd then...
   1.205 -			loadMode=ImportAdd;
   1.206 -			lmo=mc;
   1.207 -		}	
   1.208 -		if (lmo && (typeid(*lmo) == typeid(BranchObj) ) 
   1.209 -				|| (typeid(*lmo) == typeid(MapCenterObj) ) )
   1.210 -		{
   1.211 -			lastBranch=(BranchObj*)(lmo);
   1.212 -			if (eName=="branch")
   1.213 -			{
   1.214 -				state=StateBranch;
   1.215 -				if (loadMode==ImportAdd)
   1.216 -				{
   1.217 -					lastBranch->addBranch();
   1.218 -					lastBranch=lastBranch->getLastBranch();
   1.219 -					
   1.220 -				} else
   1.221 -					lastBranch->clear();
   1.222 -				branchDepth=1;
   1.223 -				readBranchAttr (atts);
   1.224 -			} else if (eName=="floatimage")
   1.225 -			{
   1.226 -				state=StateFloatImage;
   1.227 -				lastBranch->addFloatImage();
   1.228 -				lastFloat=lastBranch->getLastFloatImage();
   1.229 -				if (!readFloatImageAttr(atts)) return false;
   1.230 -			} else return false;
   1.231 -		} else return false;
   1.232 -	} else if ( eName == "branch" && state == StateMapCenter) 
   1.233 -	{
   1.234 -		state=StateBranch;
   1.235 -		branchDepth=1;
   1.236 -		lastBranch->addBranch();
   1.237 -		lastBranch=lastBranch->getLastBranch();
   1.238 -		readBranchAttr (atts);
   1.239 -	} else if ( eName == "htmlnote" && state == StateBranch) 
   1.240 -	{
   1.241 -		laststate=state;
   1.242 -		state=StateHtmlNote;
   1.243 -		no.clear();
   1.244 -		if (!atts.value( "fonthint").isEmpty() ) 
   1.245 -			no.setFontHint(atts.value ("fonthint") );
   1.246 -	} else if ( eName == "frame" && (state == StateBranch||state==StateMapCenter)) 
   1.247 -	{
   1.248 -		laststate=state;
   1.249 -		state=StateFrame;
   1.250 -		if (!readFrameAttr(atts)) return false;
   1.251 -    } else if ( eName == "xlink" && state == StateBranch ) 
   1.252 -	{
   1.253 -		state=StateBranchXLink;
   1.254 -		if (!readXLinkAttr (atts)) return false;
   1.255 -    } else if ( eName == "branch" && state == StateBranch ) 
   1.256 -	{
   1.257 -        lastBranch->addBranch();
   1.258 -		lastBranch=lastBranch->getLastBranch();		
   1.259 -        branchDepth++;
   1.260 -		readBranchAttr (atts);
   1.261 -    } else if ( eName == "html" && state == StateHtmlNote ) 
   1.262 -	{
   1.263 -		state=StateHtml;
   1.264 -		htmldata="<"+eName;
   1.265 -		readHtmlAttr(atts);
   1.266 -		htmldata+=">";
   1.267 -    } else if ( state == StateHtml ) 
   1.268 -	{
   1.269 -		// accept all while in html mode,
   1.270 -		htmldata+="<"+eName;
   1.271 -		readHtmlAttr(atts);
   1.272 -		htmldata+=">";
   1.273 -    } else
   1.274 -        return false;   // Error
   1.275 -    return true;
   1.276 -}
   1.277 -
   1.278 -bool parseVYMHandler::endElement  ( const QString&, const QString&, const QString &eName)
   1.279 -{
   1.280 -	/* Testing
   1.281 -	cout << "endElement </" <<eName.ascii()
   1.282 -		<<">  state=" <<state 
   1.283 -		<<"  laststate=" <<laststate
   1.284 -		<<"  stateStack="<<stateStack.last() 
   1.285 -		<<endl;
   1.286 -	*/
   1.287 -    switch ( state ) 
   1.288 -	{
   1.289 -        case StateBranch: 
   1.290 -			lastBranch=(BranchObj*)(lastBranch->getParObj());
   1.291 -            break;
   1.292 -        case StateHtml: 
   1.293 -			htmldata+="</"+eName+">";
   1.294 -			if (eName=="html")
   1.295 -			{
   1.296 -				state=StateHtmlNote;  
   1.297 -				htmldata.replace ("<br></br>","<br />");
   1.298 -				no.setNote (htmldata);
   1.299 -				lastBranch->setNote (no);
   1.300 -			}	
   1.301 -			break;
   1.302 -		default: 
   1.303 -			break;
   1.304 -    }  
   1.305 -	state=stateStack.takeLast();	
   1.306 -	return true;
   1.307 -}
   1.308 -
   1.309 -bool parseVYMHandler::characters   ( const QString& ch)
   1.310 -{
   1.311 -	//cout << "characters \""<<ch<<"\"  state="<<state <<"  laststate="<<laststate<<endl;
   1.312 -
   1.313 -	QString ch_org=quotemeta (ch);
   1.314 -    QString ch_simplified=ch.simplifyWhiteSpace();
   1.315 -    if ( ch_simplified.isEmpty() ) return true;
   1.316 -
   1.317 -    switch ( state ) 
   1.318 -    {
   1.319 -        case StateInit: break;
   1.320 -        case StateMap: break; 
   1.321 -		case StateMapSelect:
   1.322 -			me->select(ch_simplified);
   1.323 -			break;
   1.324 -		case StateMapSetting:break;
   1.325 -        case StateMapCenter: break;
   1.326 -        case StateNote:
   1.327 -			lastBranch->setNote(ch_simplified);
   1.328 -			break;
   1.329 -        case StateBranch: break;
   1.330 -        case StateStandardFlag: 
   1.331 -            lastBranch->activateStandardFlag(ch_simplified); 
   1.332 -            break;
   1.333 -        case StateFloatImage: break;
   1.334 -        case StateHtmlNote: break;
   1.335 -        case StateHtml:
   1.336 -			htmldata+=ch_org;
   1.337 -			break;
   1.338 -        case StateHeading: 
   1.339 -            lastBranch->setHeading(ch_simplified);
   1.340 -            break;
   1.341 -        default: 
   1.342 -			return false;
   1.343 -    }
   1.344 -    return true;
   1.345 -}
   1.346 -
   1.347 -QString parseVYMHandler::errorString() 
   1.348 -{
   1.349 -    return "the document is not in the VYM file format";
   1.350 -}
   1.351 -
   1.352 -bool parseVYMHandler::fatalError( const QXmlParseException& exception ) 
   1.353 -{
   1.354 -    errorProt += QString( "Fatal parsing error: %1 in line %2, column %3\n")
   1.355 -    .arg( exception.message() )
   1.356 -    .arg( exception.lineNumber() )
   1.357 -    .arg( exception.columnNumber() );
   1.358 -	// Try to read the bogus line
   1.359 -	errorProt+=QString("File is: %1\n").arg(inputFile);
   1.360 -	QString s;
   1.361 -	if (loadStringFromDisk (inputFile,s))
   1.362 -	{
   1.363 -		QStringList sl=QStringList::split ("\n",s);
   1.364 -		int i=1;
   1.365 -		QStringList::Iterator it = sl.begin();
   1.366 -		while (i<exception.lineNumber()-1)
   1.367 -		{
   1.368 -			it++;
   1.369 -			i++;
   1.370 -		}
   1.371 -		s=*it;
   1.372 -		s.insert (exception.columnNumber()-1,"<ERROR>");
   1.373 -		errorProt+=s;
   1.374 -    }
   1.375 -    return QXmlDefaultHandler::fatalError( exception );
   1.376 -}
   1.377 -
   1.378 -void parseVYMHandler::setMapEditor (MapEditor* e)
   1.379 -{
   1.380 -    me=e;
   1.381 -	mc=me->getMapCenter();
   1.382 -}
   1.383 -
   1.384 -void parseVYMHandler::setTmpDir (QString tp)
   1.385 -{
   1.386 -	tmpDir=tp;
   1.387 -}
   1.388 -
   1.389 -void parseVYMHandler::setInputFile (QString f)
   1.390 -{
   1.391 -	inputFile=f;
   1.392 -}
   1.393 -
   1.394 -void parseVYMHandler::setLoadMode (const LoadMode &lm)
   1.395 -{
   1.396 -	loadMode=lm;
   1.397 -}
   1.398 -
   1.399 -bool parseVYMHandler::readBranchAttr (const QXmlAttributes& a)
   1.400 -{
   1.401 -	lastOO=lastBranch;
   1.402 -	if (!readOOAttr(a)) return false;
   1.403 -
   1.404 -	if (!a.value( "scrolled").isEmpty() )
   1.405 -		lastBranch->toggleScroll();
   1.406 -	if (!a.value( "frameType").isEmpty() ) 
   1.407 -		lastOO->setFrameType (a.value("frameType")); //Compatibility 1.8.1
   1.408 -
   1.409 -	if (!a.value( "incImgV").isEmpty() ) 
   1.410 -	{	
   1.411 -		if (a.value("incImgV")=="true")
   1.412 -			lastBranch->setIncludeImagesVer(true);
   1.413 -		else	
   1.414 -			lastBranch->setIncludeImagesVer(false);
   1.415 -	}	
   1.416 -	if (!a.value( "incImgH").isEmpty() ) 
   1.417 -	{	
   1.418 -		if (a.value("incImgH")=="true")
   1.419 -			lastBranch->setIncludeImagesHor(true);
   1.420 -		else	
   1.421 -			lastBranch->setIncludeImagesHor(false);
   1.422 -	}	
   1.423 -	return true;	
   1.424 -}
   1.425 -
   1.426 -bool parseVYMHandler::readFrameAttr (const QXmlAttributes& a)
   1.427 -{
   1.428 -	bool ok;
   1.429 -	int x;
   1.430 -	if (lastOO)
   1.431 -	{
   1.432 -		if (!a.value( "frameType").isEmpty() ) 
   1.433 -			lastOO->setFrameType (a.value("frameType"));
   1.434 -		if (!a.value( "penColor").isEmpty() ) 
   1.435 -			lastOO->setFramePenColor (a.value("penColor"));
   1.436 -		if (!a.value( "brushColor").isEmpty() ) 
   1.437 -			lastOO->setFrameBrushColor (a.value("brushColor"));
   1.438 -		if (!a.value( "padding").isEmpty() ) 
   1.439 -		{
   1.440 -			x=a.value("padding").toInt(&ok);
   1.441 -			if (ok) lastOO->setFramePadding(x);
   1.442 -		}	
   1.443 -		if (!a.value( "borderWidth").isEmpty() ) 
   1.444 -		{
   1.445 -			x=a.value("borderWidth").toInt(&ok);
   1.446 -			if (ok) lastOO->setFrameBorderWidth(x);
   1.447 -		}	
   1.448 -	}		
   1.449 -	return true;
   1.450 -}
   1.451 -
   1.452 -bool parseVYMHandler::readOOAttr (const QXmlAttributes& a)
   1.453 -{
   1.454 -	if (lastOO)
   1.455 -	{
   1.456 -		bool okx,oky;
   1.457 -		int x,y;
   1.458 -		if (!a.value( "relPosX").isEmpty() ) 
   1.459 -		{
   1.460 -			if (!a.value( "relPosY").isEmpty() ) 
   1.461 -			{
   1.462 -				x=a.value("relPosX").toInt (&okx, 10);
   1.463 -				y=a.value("relPosY").toInt (&oky, 10);
   1.464 -				if (okx && oky  )
   1.465 -				{
   1.466 -					lastOO->setUseRelPos (true);
   1.467 -					lastOO->move2RelPos (x,y);
   1.468 -				}	
   1.469 -				else
   1.470 -					return false;   // Couldn't read relPos
   1.471 -			}           
   1.472 -		}           
   1.473 -		if (!a.value( "absPosX").isEmpty() && loadMode==NewMap && branchDepth<2) 
   1.474 -		{
   1.475 -			if (!a.value( "absPosY").isEmpty() ) 
   1.476 -			{
   1.477 -				x=a.value("absPosX").toInt (&okx, 10);
   1.478 -				y=a.value("absPosY").toInt (&oky, 10);
   1.479 -				if (okx && oky  )
   1.480 -					lastOO->move(x,y);
   1.481 -				else
   1.482 -					return false;   // Couldn't read absPos
   1.483 -			}           
   1.484 -		}           
   1.485 -		if (!a.value( "id").isEmpty() ) 
   1.486 -			lastOO->setID (a.value ("id"));
   1.487 -		if (!a.value( "url").isEmpty() ) 
   1.488 -			lastOO->setURL (a.value ("url"));
   1.489 -		if (!a.value( "vymLink").isEmpty() ) 
   1.490 -			lastOO->setVymLink (a.value ("vymLink"));
   1.491 -		if (!a.value( "hideInExport").isEmpty() ) 
   1.492 -			if (a.value("hideInExport")=="true")
   1.493 -				lastOO->setHideInExport(true);
   1.494 -
   1.495 -		if (!a.value( "hideLink").isEmpty()) 
   1.496 -		{
   1.497 -			if (a.value ("hideLink") =="true")
   1.498 -				lastOO->setHideLinkUnselected(true);
   1.499 -			else	
   1.500 -				lastOO->setHideLinkUnselected(false);
   1.501 -		}	
   1.502 -	}
   1.503 -	return true;	
   1.504 -}
   1.505 -
   1.506 -bool parseVYMHandler::readNoteAttr (const QXmlAttributes& a)
   1.507 -{	// only for backward compatibility (<1.4.6). Use htmlnote now.
   1.508 -	no.clear();
   1.509 -	QString fn;
   1.510 -	if (!a.value( "href").isEmpty() ) 
   1.511 -	{
   1.512 -		// Load note
   1.513 -		fn=parseHREF(a.value ("href") );
   1.514 -		QFile file (fn);
   1.515 -		QString s;						// Reading a note
   1.516 -
   1.517 -		if ( !file.open( QIODevice::ReadOnly) )
   1.518 -		{
   1.519 -			qWarning ("parseVYMHandler::readNoteAttr:  Couldn't load "+fn);
   1.520 -			return false;
   1.521 -		}	
   1.522 -		QTextStream stream( &file );
   1.523 -		QString lines;
   1.524 -		while ( !stream.atEnd() ) {
   1.525 -			lines += stream.readLine()+"\n"; 
   1.526 -		}
   1.527 -		file.close();
   1.528 -
   1.529 -		lines ="<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body>"+lines + "</p></body></html>";
   1.530 -		no.setNote (lines);
   1.531 -	}		
   1.532 -	if (!a.value( "fonthint").isEmpty() ) 
   1.533 -		no.setFontHint(a.value ("fonthint") );
   1.534 -	lastBranch->setNote(no);
   1.535 -	return true;
   1.536 -}
   1.537 -
   1.538 -bool parseVYMHandler::readFloatImageAttr (const QXmlAttributes& a)
   1.539 -{
   1.540 -	lastOO=lastFloat;
   1.541 -	
   1.542 -	//if (!readOOAttr(a)) return false;
   1.543 -
   1.544 -	if (!a.value( "useOrientation").isEmpty() ) 
   1.545 -	{
   1.546 -		if (a.value ("useOrientation") =="true")
   1.547 -			lastFloat->setUseOrientation (true);
   1.548 -		else	
   1.549 -			lastFloat->setUseOrientation (false);
   1.550 -	}	
   1.551 -	if (!a.value( "href").isEmpty() )
   1.552 -	{
   1.553 -		// Load FloatImage
   1.554 -		if (!lastFloat->load (parseHREF(a.value ("href") ) ))
   1.555 -		{
   1.556 -			QMessageBox::warning( 0, "Warning: " ,
   1.557 -				"Couldn't load float image\n"+parseHREF(a.value ("href") ));
   1.558 -			lastBranch->removeFloatImage(((FloatImageObj*)(lastFloat)));
   1.559 -			lastFloat=NULL;
   1.560 -			return true;
   1.561 -		}
   1.562 -		
   1.563 -	}	
   1.564 -	if (!a.value( "floatExport").isEmpty() ) 
   1.565 -	{
   1.566 -		// Only for compatibility. THis is not used since 1.7.11 
   1.567 -		if (a.value ("floatExport") =="true")
   1.568 -			lastFloat->setFloatExport(true);
   1.569 -		else	
   1.570 -			lastFloat->setFloatExport (false);
   1.571 -	}	
   1.572 -	if (!a.value( "zPlane").isEmpty() ) 
   1.573 -		lastFloat->setZValue (a.value("zPlane").toInt ());
   1.574 -    int x,y;
   1.575 -    bool okx,oky;
   1.576 -	if (!a.value( "relPosX").isEmpty() ) 
   1.577 -	{
   1.578 -		if (!a.value( "relPosY").isEmpty() ) 
   1.579 -		{
   1.580 -			// read relPos
   1.581 -			x=a.value("relPosX").toInt (&okx, 10);
   1.582 -			y=a.value("relPosY").toInt (&oky, 10);
   1.583 -			if (okx && oky) 
   1.584 -				
   1.585 -				{
   1.586 -					lastFloat->setRelPos (QPoint (x,y) );
   1.587 -					// make sure floats in mapcenter are repositioned to relative pos
   1.588 -					if (mc==lastBranch) mc->positionContents();
   1.589 -				}
   1.590 -			else
   1.591 -				// Couldn't read relPos
   1.592 -				return false;  
   1.593 -		}           
   1.594 -	}	
   1.595 -	
   1.596 -	if (!readOOAttr(a)) return false;
   1.597 -
   1.598 -	if (!a.value ("orgName").isEmpty() )
   1.599 -	{
   1.600 -		((FloatImageObj*)(lastFloat))->setOriginalFilename (a.value("orgName"));
   1.601 -	}
   1.602 -	return true;
   1.603 -}
   1.604 -
   1.605 -bool parseVYMHandler::readXLinkAttr (const QXmlAttributes& a)
   1.606 -{
   1.607 -	QColor col;
   1.608 -	bool okx;
   1.609 -	bool success=false;
   1.610 -	XLinkObj *xlo=new XLinkObj (mc->getScene());
   1.611 -	if (!a.value( "color").isEmpty() ) 
   1.612 -	{
   1.613 -		col.setNamedColor(a.value("color"));
   1.614 -		xlo->setColor (col);
   1.615 -	}
   1.616 -
   1.617 -	if (!a.value( "width").isEmpty() ) 
   1.618 -	{
   1.619 -		xlo->setWidth(a.value ("width").toInt (&okx, 10));
   1.620 -	}
   1.621 -
   1.622 -	// Connecting by select string for compatibility with version < 1.8.76
   1.623 -	if (!a.value( "beginBranch").isEmpty() ) 
   1.624 -	{ 
   1.625 -		if (!a.value( "endBranch").isEmpty() ) 
   1.626 -		{
   1.627 -			LinkableMapObj *lmo=mc->findObjBySelect (a.value( "beginBranch"));
   1.628 -			if (lmo && typeid (*lmo)==typeid (BranchObj))
   1.629 -			{
   1.630 -				xlo->setBegin ((BranchObj*)lmo);
   1.631 -				lmo=mc->findObjBySelect (a.value( "endBranch"));
   1.632 -				if (lmo && typeid (*lmo)==typeid (BranchObj))
   1.633 -				{
   1.634 -					xlo->setEnd ((BranchObj*)(lmo));
   1.635 -					xlo->activate();
   1.636 -				}
   1.637 -			}
   1.638 -			success=true; // Not all branches there yet, no error
   1.639 -		}           
   1.640 -	}	
   1.641 -
   1.642 -	// object ID is used starting in version 1.8.76
   1.643 -	if (!a.value( "beginID").isEmpty() ) 
   1.644 -	{ 
   1.645 -		if (!a.value( "endID").isEmpty() ) 
   1.646 -		{
   1.647 -			LinkableMapObj *lmo=mc->findID (a.value( "beginBranch"));
   1.648 -			if (lmo && typeid (*lmo)==typeid (BranchObj))
   1.649 -			{
   1.650 -				xlo->setBegin ((BranchObj*)lmo);
   1.651 -				lmo=mc->findID (a.value( "endID"));
   1.652 -				if (lmo && typeid (*lmo)==typeid (BranchObj))
   1.653 -				{
   1.654 -					xlo->setEnd ((BranchObj*)(lmo));
   1.655 -					xlo->activate();
   1.656 -				}
   1.657 -			}
   1.658 -			success=true; // Not all branches there yet, no error
   1.659 -		}           
   1.660 -	}	
   1.661 -	if (!success) delete (xlo);
   1.662 -	return success;
   1.663 -}
   1.664 -
   1.665 -bool parseVYMHandler::readHtmlAttr (const QXmlAttributes& a)
   1.666 -{
   1.667 -	for (int i=1; i<=a.count(); i++)
   1.668 -		htmldata+=" "+a.localName(i-1)+"=\""+a.value(i-1)+"\"";
   1.669 -	return true;
   1.670 -}
   1.671 -
   1.672 -bool parseVYMHandler::readSettingAttr (const QXmlAttributes& a)
   1.673 -{
   1.674 -	if (!a.value( "key").isEmpty() ) 
   1.675 -	{
   1.676 -		if (!a.value( "value").isEmpty() ) 
   1.677 -			settings.setLocalEntry (me->getDestPath(), a.value ("key"), a.value ("value"));
   1.678 -		else
   1.679 -			return false;
   1.680 -		
   1.681 -	} else
   1.682 -		return false;
   1.683 -	
   1.684 -	return true;
   1.685 -}