xml.cpp
author insilmaril
Fri, 29 Jun 2007 15:12:04 +0000
changeset 534 32b71ba642aa
parent 529 ce2abdbd0b65
child 558 3665eee7a842
permissions -rw-r--r--
1.8.76 Hackweek version
     1 #include "xml.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 static BranchObj *lastBranch;
    14 static FloatObj *lastFloat;
    15 static OrnamentedObj *lastOO;
    16 
    17 extern Settings settings;
    18 extern QString vymVersion;
    19 
    20 mapBuilderHandler::mapBuilderHandler() {}
    21 
    22 mapBuilderHandler::~mapBuilderHandler() {}
    23 
    24 QString mapBuilderHandler::errorProtocol() { return errorProt; }
    25 
    26 
    27 bool mapBuilderHandler::startDocument()
    28 {
    29     errorProt = "";
    30     state = StateInit;
    31     laststate = StateInit;
    32 	stateStack.clear();
    33 	stateStack.append(StateInit);
    34     branchDepth=0;
    35 	htmldata="";
    36 	isVymPart=false;
    37     return true;
    38 }
    39 
    40 
    41 QString mapBuilderHandler::parseHREF(QString href)
    42 {
    43 	QString type=href.section(":",0,0);
    44 	QString path=href.section(":",1,1);
    45 	if (!tmpDir.endsWith("/"))
    46 		return tmpDir + "/" + path;
    47 	else	
    48 		return tmpDir + path;
    49 }
    50 
    51 bool mapBuilderHandler::startElement  ( const QString&, const QString&,
    52                     const QString& eName, const QXmlAttributes& atts ) 
    53 {
    54     QColor col;
    55 	/* Testing
    56 	cout << "startElement <"<< eName.ascii()
    57 		<<">  state="<<state 
    58 		<<"  laststate="<<stateStack.last()
    59 		<<"   loadMode="<<loadMode
    60 		<<"       line="<<QXmlDefaultHandler::lineNumber()
    61 		<<endl;
    62 	*/	
    63 	stateStack.append (state);	
    64     if ( state == StateInit && (eName == "vymmap")  ) 
    65 	{
    66         state = StateMap;
    67 		if (!atts.value( "version").isEmpty() ) 
    68 		{
    69 			if (!checkVersion(atts.value("version")))
    70 				QMessageBox::warning( 0, "Warning: Version Problem" ,
    71 				   "<h3>Map is newer than VYM</h3>"
    72 				   "<p>The map you are just trying to load was "
    73 				   "saved using vym " +atts.value("version")+". "
    74 				   "The version of this vym is " + vymVersion + 
    75 				   ". If you run into problems after pressing "
    76 				   "the ok-button below, updating vym should help.");
    77 			else	   
    78 				mc->setVersion(atts.value( "version" ));
    79 
    80 		}
    81 		if (loadMode==NewMap || 
    82 			(loadMode==ImportReplace && me->getSelection()==mc))
    83 		{
    84 			if (!atts.value( "author").isEmpty() )
    85 			{
    86 				mc->setAuthor(atts.value( "author" ) );
    87 			}
    88 			if (!atts.value( "comment").isEmpty() )
    89 			{
    90 				mc->setComment (atts.value( "comment" ) );
    91 			}
    92 			if (!atts.value( "backgroundColor").isEmpty() )
    93 			{
    94 				col.setNamedColor(atts.value("backgroundColor"));
    95 				mc->getScene()->setBackgroundBrush(col);
    96 			}	    
    97 			if (!atts.value( "selectionColor").isEmpty() )
    98 			{
    99 				col.setNamedColor(atts.value("selectionColor"));
   100 				me->setSelectionColor(col);
   101 			}	    
   102 			if (!atts.value( "linkColorHint").isEmpty() ) 
   103 			{
   104 				if (atts.value("linkColorHint")=="HeadingColor")
   105 					me->setMapLinkColorHint(LinkableMapObj::HeadingColor);
   106 				else
   107 					me->setMapLinkColorHint(LinkableMapObj::DefaultColor);
   108 			}
   109 			if (!atts.value( "linkStyle").isEmpty() ) 
   110 			{
   111 				me->setMapLinkStyle(atts.value("linkStyle"));
   112 			}	
   113 			if (!atts.value( "linkColor").isEmpty() ) 
   114 			{
   115 				col.setNamedColor(atts.value("linkColor"));
   116 				me->setMapDefLinkColor(col);
   117 			}	
   118 			if (!atts.value( "defXLinkColor").isEmpty() ) 
   119 			{
   120 				col.setNamedColor(atts.value("defXLinkColor"));
   121 				me->setMapDefXLinkColor(col);
   122 			}	
   123 			if (!atts.value( "defXLinkWidth").isEmpty() ) 
   124 			{
   125 				me->setMapDefXLinkWidth(atts.value("defXLinkWidth").toInt ());
   126 			}	
   127 		}	
   128 	} else if ( eName == "select" && state == StateMap ) 
   129 	{
   130 		state=StateMapSelect;
   131 	} else if ( eName == "setting" && state == StateMap ) 
   132 	{
   133 		state=StateMapSetting;
   134 		if (loadMode==NewMap)
   135 			readSettingAttr (atts);
   136 	} else if ( eName == "mapcenter" && state == StateMap ) 
   137 	{
   138 		state=StateMapCenter;
   139 		if (loadMode==NewMap)
   140 		{	
   141 			// Really use the found mapcenter as MCO in a new map
   142 			lastBranch=mc;	// avoid empty pointer
   143 		} else
   144 		{
   145 			// Treat the found mapcenter as a branch 
   146 			// in an existing map
   147 			LinkableMapObj* lmo=me->getSelection();
   148 			if (lmo && (typeid(*lmo) == typeid(BranchObj) ) 
   149 			        || (typeid(*lmo) == typeid(MapCenterObj) ) )
   150 			{
   151 				lastBranch=(BranchObj*)lmo;
   152 				if (loadMode==ImportAdd)
   153 				{
   154 					lastBranch->addBranch();
   155 					lastBranch=lastBranch->getLastBranch();
   156 				} else
   157 					lastBranch->clear();
   158 			} else
   159 				return false;
   160 		}
   161 		readBranchAttr (atts);
   162 	} else if ( 
   163 		(eName == "standardflag" ||eName == "standardFlag") && 
   164 		(state == StateMapCenter || state==StateBranch)) 
   165 	{
   166 		state=StateStandardFlag;
   167 	} else if ( eName == "heading" && (state == StateMapCenter||state==StateBranch)) 
   168 	{
   169 		laststate=state;
   170 		state=StateHeading;
   171 		if (!atts.value( "textColor").isEmpty() ) 
   172 		{
   173 			col.setNamedColor(atts.value("textColor"));
   174 			lastBranch->setColor(col );
   175 		}	    
   176 	} else if ( eName == "note" && 
   177 				(state == StateMapCenter ||state==StateBranch))
   178 	{	// only for backward compatibility (<1.4.6). Use htmlnote now.
   179 		state=StateNote;
   180 		if (!readNoteAttr (atts) ) return false;
   181 	} else if ( eName == "htmlnote" && state == StateMapCenter) 
   182 	{
   183 		laststate=state;
   184 		state=StateHtmlNote;
   185     } else if ( eName == "floatimage" && 
   186 				(state == StateMapCenter ||state==StateBranch)) 
   187 	{
   188 		state=StateFloatImage;
   189         lastBranch->addFloatImage();
   190 		lastFloat=lastBranch->getLastFloatImage();
   191 		if (!readFloatImageAttr(atts)) return false;
   192 	} else if ( (eName == "branch"||eName=="floatimage") && state == StateMap) 
   193 	{
   194 		// This is used in vymparts, which have no mapcenter!
   195 		isVymPart=true;
   196 		LinkableMapObj* lmo=me->getSelection();
   197 		if (!lmo)
   198 		{
   199 			// If a vym part is _loaded_ (not imported), 
   200 			// selection==lmo==NULL
   201 			// Treat it like ImportAdd then...
   202 			loadMode=ImportAdd;
   203 			lmo=mc;
   204 		}	
   205 		if (lmo && (typeid(*lmo) == typeid(BranchObj) ) 
   206 				|| (typeid(*lmo) == typeid(MapCenterObj) ) )
   207 		{
   208 			lastBranch=(BranchObj*)(lmo);
   209 			if (eName=="branch")
   210 			{
   211 				state=StateBranch;
   212 				if (loadMode==ImportAdd)
   213 				{
   214 					lastBranch->addBranch();
   215 					lastBranch=lastBranch->getLastBranch();
   216 					
   217 				} else
   218 					lastBranch->clear();
   219 				branchDepth=1;
   220 				readBranchAttr (atts);
   221 			} else if (eName=="floatimage")
   222 			{
   223 				state=StateFloatImage;
   224 				lastBranch->addFloatImage();
   225 				lastFloat=lastBranch->getLastFloatImage();
   226 				if (!readFloatImageAttr(atts)) return false;
   227 			} else return false;
   228 		} else return false;
   229 	} else if ( eName == "branch" && state == StateMapCenter) 
   230 	{
   231 		state=StateBranch;
   232 		branchDepth=1;
   233 		lastBranch->addBranch();
   234 		lastBranch=lastBranch->getLastBranch();
   235 		readBranchAttr (atts);
   236 	} else if ( eName == "htmlnote" && state == StateBranch) 
   237 	{
   238 		laststate=state;
   239 		state=StateHtmlNote;
   240 		no.clear();
   241 		if (!atts.value( "fonthint").isEmpty() ) 
   242 			no.setFontHint(atts.value ("fonthint") );
   243 	} else if ( eName == "frame" && (state == StateBranch||state==StateMapCenter)) 
   244 	{
   245 		laststate=state;
   246 		state=StateFrame;
   247 		if (!readFrameAttr(atts)) return false;
   248     } else if ( eName == "xlink" && state == StateBranch ) 
   249 	{
   250 		state=StateBranchXLink;
   251 		if (!readXLinkAttr (atts)) return false;
   252     } else if ( eName == "branch" && state == StateBranch ) 
   253 	{
   254         lastBranch->addBranch();
   255 		lastBranch=lastBranch->getLastBranch();		
   256         branchDepth++;
   257 		readBranchAttr (atts);
   258     } else if ( eName == "html" && state == StateHtmlNote ) 
   259 	{
   260 		state=StateHtml;
   261 		htmldata="<"+eName;
   262 		readHtmlAttr(atts);
   263 		htmldata+=">";
   264     } else if ( state == StateHtml ) 
   265 	{
   266 		// accept all while in html mode,
   267 		htmldata+="<"+eName;
   268 		readHtmlAttr(atts);
   269 		htmldata+=">";
   270     } else
   271         return false;   // Error
   272     return true;
   273 }
   274 
   275 bool mapBuilderHandler::endElement  ( const QString&, const QString&, const QString &eName)
   276 {
   277 	/* Testing
   278 	cout << "endElement </" <<eName.ascii()
   279 		<<">  state=" <<state 
   280 		<<"  laststate=" <<laststate
   281 		<<"  stateStack="<<stateStack.last() 
   282 		<<endl;
   283 	*/
   284     switch ( state ) 
   285 	{
   286         case StateBranch: 
   287 			lastBranch=(BranchObj*)(lastBranch->getParObj());
   288             break;
   289         case StateHtml: 
   290 			htmldata+="</"+eName+">";
   291 			if (eName=="html")
   292 			{
   293 				state=StateHtmlNote;  
   294 				htmldata.replace ("<br></br>","<br />");
   295 				no.setNote (htmldata);
   296 				lastBranch->setNote (no);
   297 			}	
   298 			break;
   299 		default: 
   300 			break;
   301     }  
   302 	state=stateStack.takeLast();	
   303 	return true;
   304 }
   305 
   306 bool mapBuilderHandler::characters   ( const QString& ch)
   307 {
   308 	//cout << "characters \""<<ch<<"\"  state="<<state <<"  laststate="<<laststate<<endl;
   309 
   310 	QString ch_org=quotemeta (ch);
   311     QString ch_simplified=ch.simplifyWhiteSpace();
   312     if ( ch_simplified.isEmpty() ) return true;
   313 
   314     switch ( state ) 
   315     {
   316         case StateInit: break;
   317         case StateMap: break; 
   318 		case StateMapSelect:
   319 			me->select(ch_simplified);
   320 			break;
   321 		case StateMapSetting:break;
   322         case StateMapCenter: break;
   323         case StateNote:
   324 			lastBranch->setNote(ch_simplified);
   325 			break;
   326         case StateBranch: break;
   327         case StateStandardFlag: 
   328             lastBranch->activateStandardFlag(ch_simplified); 
   329             break;
   330         case StateFloatImage: break;
   331         case StateHtmlNote: break;
   332         case StateHtml:
   333 			htmldata+=ch_org;
   334 			break;
   335         case StateHeading: 
   336             lastBranch->setHeading(ch_simplified);
   337             break;
   338         default: 
   339 			return false;
   340     }
   341     return true;
   342 }
   343 
   344 QString mapBuilderHandler::errorString() 
   345 {
   346     return "the document is not in the VYM file format";
   347 }
   348 
   349 bool mapBuilderHandler::fatalError( const QXmlParseException& exception ) 
   350 {
   351     errorProt += QString( "Fatal parsing error: %1 in line %2, column %3\n")
   352     .arg( exception.message() )
   353     .arg( exception.lineNumber() )
   354     .arg( exception.columnNumber() );
   355 	// Try to read the bogus line
   356 	errorProt+=QString("File is: %1\n").arg(inputFile);
   357 	QString s;
   358 	if (loadStringFromDisk (inputFile,s))
   359 	{
   360 		QStringList sl=QStringList::split ("\n",s);
   361 		int i=1;
   362 		QStringList::Iterator it = sl.begin();
   363 		while (i<exception.lineNumber()-1)
   364 		{
   365 			it++;
   366 			i++;
   367 		}
   368 		s=*it;
   369 		s.insert (exception.columnNumber()-1,"<ERROR>");
   370 		errorProt+=s;
   371     }
   372     return QXmlDefaultHandler::fatalError( exception );
   373 }
   374 
   375 void mapBuilderHandler::setMapEditor (MapEditor* e)
   376 {
   377     me=e;
   378 	mc=me->getMapCenter();
   379 }
   380 
   381 void mapBuilderHandler::setTmpDir (QString tp)
   382 {
   383 	tmpDir=tp;
   384 }
   385 
   386 void mapBuilderHandler::setInputFile (QString f)
   387 {
   388 	inputFile=f;
   389 }
   390 
   391 void mapBuilderHandler::setLoadMode (const LoadMode &lm)
   392 {
   393 	loadMode=lm;
   394 }
   395 
   396 bool mapBuilderHandler::readBranchAttr (const QXmlAttributes& a)
   397 {
   398 	lastOO=lastBranch;
   399 	if (!readOOAttr(a)) return false;
   400 
   401 	if (!a.value( "scrolled").isEmpty() )
   402 		lastBranch->toggleScroll();
   403 	if (!a.value( "frameType").isEmpty() ) 
   404 		lastOO->setFrameType (a.value("frameType")); //Compatibility 1.8.1
   405 
   406 	if (!a.value( "incImgV").isEmpty() ) 
   407 	{	
   408 		if (a.value("incImgV")=="true")
   409 			lastBranch->setIncludeImagesVer(true);
   410 		else	
   411 			lastBranch->setIncludeImagesVer(false);
   412 	}	
   413 	if (!a.value( "incImgH").isEmpty() ) 
   414 	{	
   415 		if (a.value("incImgH")=="true")
   416 			lastBranch->setIncludeImagesHor(true);
   417 		else	
   418 			lastBranch->setIncludeImagesHor(false);
   419 	}	
   420 	return true;	
   421 }
   422 
   423 bool mapBuilderHandler::readFrameAttr (const QXmlAttributes& a)
   424 {
   425 	bool ok;
   426 	int x;
   427 	if (lastOO)
   428 	{
   429 		if (!a.value( "frameType").isEmpty() ) 
   430 			lastOO->setFrameType (a.value("frameType"));
   431 		if (!a.value( "penColor").isEmpty() ) 
   432 			lastOO->setFramePenColor (a.value("penColor"));
   433 		if (!a.value( "brushColor").isEmpty() ) 
   434 			lastOO->setFrameBrushColor (a.value("brushColor"));
   435 		if (!a.value( "padding").isEmpty() ) 
   436 		{
   437 			x=a.value("padding").toInt(&ok);
   438 			if (ok) lastOO->setFramePadding(x);
   439 		}	
   440 		if (!a.value( "borderWidth").isEmpty() ) 
   441 		{
   442 			x=a.value("borderWidth").toInt(&ok);
   443 			if (ok) lastOO->setFrameBorderWidth(x);
   444 		}	
   445 	}		
   446 	return true;
   447 }
   448 
   449 bool mapBuilderHandler::readOOAttr (const QXmlAttributes& a)
   450 {
   451 	if (lastOO)
   452 	{
   453 		bool okx,oky;
   454 		int x,y;
   455 		if (!a.value( "relPosX").isEmpty() ) 
   456 		{
   457 			if (!a.value( "relPosY").isEmpty() ) 
   458 			{
   459 				x=a.value("relPosX").toInt (&okx, 10);
   460 				y=a.value("relPosY").toInt (&oky, 10);
   461 				if (okx && oky  )
   462 				{
   463 					lastOO->setUseRelPos (true);
   464 					lastOO->move2RelPos (x,y);
   465 				}	
   466 				else
   467 					return false;   // Couldn't read relPos
   468 			}           
   469 		}           
   470 		if (!a.value( "absPosX").isEmpty() && loadMode==NewMap && branchDepth<2) 
   471 		{
   472 			if (!a.value( "absPosY").isEmpty() ) 
   473 			{
   474 				x=a.value("absPosX").toInt (&okx, 10);
   475 				y=a.value("absPosY").toInt (&oky, 10);
   476 				if (okx && oky  )
   477 					lastOO->move(x,y);
   478 				else
   479 					return false;   // Couldn't read absPos
   480 			}           
   481 		}           
   482 		if (!a.value( "id").isEmpty() ) 
   483 			lastOO->setID (a.value ("id"));
   484 		if (!a.value( "url").isEmpty() ) 
   485 			lastOO->setURL (a.value ("url"));
   486 		if (!a.value( "vymLink").isEmpty() ) 
   487 			lastOO->setVymLink (a.value ("vymLink"));
   488 		if (!a.value( "hideInExport").isEmpty() ) 
   489 			if (a.value("hideInExport")=="true")
   490 				lastOO->setHideInExport(true);
   491 
   492 		if (!a.value( "hideLink").isEmpty()) 
   493 		{
   494 			if (a.value ("hideLink") =="true")
   495 				lastOO->setHideLinkUnselected(true);
   496 			else	
   497 				lastOO->setHideLinkUnselected(false);
   498 		}	
   499 	}
   500 	return true;	
   501 }
   502 
   503 bool mapBuilderHandler::readNoteAttr (const QXmlAttributes& a)
   504 {	// only for backward compatibility (<1.4.6). Use htmlnote now.
   505 	no.clear();
   506 	QString fn;
   507 	if (!a.value( "href").isEmpty() ) 
   508 	{
   509 		// Load note
   510 		fn=parseHREF(a.value ("href") );
   511 		QFile file (fn);
   512 		QString s;						// Reading a note
   513 
   514 		if ( !file.open( QIODevice::ReadOnly) )
   515 		{
   516 			qWarning ("mapBuilderHandler::readNoteAttr:  Couldn't load "+fn);
   517 			return false;
   518 		}	
   519 		QTextStream stream( &file );
   520 		QString lines;
   521 		while ( !stream.atEnd() ) {
   522 			lines += stream.readLine()+"\n"; 
   523 		}
   524 		file.close();
   525 
   526 		lines ="<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body>"+lines + "</p></body></html>";
   527 		no.setNote (lines);
   528 	}		
   529 	if (!a.value( "fonthint").isEmpty() ) 
   530 		no.setFontHint(a.value ("fonthint") );
   531 	lastBranch->setNote(no);
   532 	return true;
   533 }
   534 
   535 bool mapBuilderHandler::readFloatImageAttr (const QXmlAttributes& a)
   536 {
   537 	lastOO=lastFloat;
   538 	
   539 	//if (!readOOAttr(a)) return false;
   540 
   541 	if (!a.value( "useOrientation").isEmpty() ) 
   542 	{
   543 		if (a.value ("useOrientation") =="true")
   544 			lastFloat->setUseOrientation (true);
   545 		else	
   546 			lastFloat->setUseOrientation (false);
   547 	}	
   548 	if (!a.value( "href").isEmpty() )
   549 	{
   550 		// Load FloatImage
   551 		if (!lastFloat->load (parseHREF(a.value ("href") ) ))
   552 		{
   553 			QMessageBox::warning( 0, "Warning: " ,
   554 				"Couldn't load float image\n"+parseHREF(a.value ("href") ));
   555 			lastBranch->removeFloatImage(((FloatImageObj*)(lastFloat)));
   556 			lastFloat=NULL;
   557 			return true;
   558 		}
   559 		
   560 	}	
   561 	if (!a.value( "floatExport").isEmpty() ) 
   562 	{
   563 		// Only for compatibility. THis is not used since 1.7.11 
   564 		if (a.value ("floatExport") =="true")
   565 			lastFloat->setFloatExport(true);
   566 		else	
   567 			lastFloat->setFloatExport (false);
   568 	}	
   569 	if (!a.value( "zPlane").isEmpty() ) 
   570 		lastFloat->setZValue (a.value("zPlane").toInt ());
   571     int x,y;
   572     bool okx,oky;
   573 	if (!a.value( "relPosX").isEmpty() ) 
   574 	{
   575 		if (!a.value( "relPosY").isEmpty() ) 
   576 		{
   577 			// read relPos
   578 			x=a.value("relPosX").toInt (&okx, 10);
   579 			y=a.value("relPosY").toInt (&oky, 10);
   580 			if (okx && oky) 
   581 				
   582 				{
   583 					lastFloat->setRelPos (QPoint (x,y) );
   584 					// make sure floats in mapcenter are repositioned to relative pos
   585 					if (mc==lastBranch) mc->positionContents();
   586 				}
   587 			else
   588 				// Couldn't read relPos
   589 				return false;  
   590 		}           
   591 	}	
   592 	
   593 	if (!readOOAttr(a)) return false;
   594 
   595 	if (!a.value ("orgName").isEmpty() )
   596 	{
   597 		((FloatImageObj*)(lastFloat))->setOriginalFilename (a.value("orgName"));
   598 	}
   599 	return true;
   600 }
   601 
   602 bool mapBuilderHandler::readXLinkAttr (const QXmlAttributes& a)
   603 {
   604 	QColor col;
   605 	bool okx;
   606 	bool success=false;
   607 	XLinkObj *xlo=new XLinkObj (mc->getScene());
   608 	if (!a.value( "color").isEmpty() ) 
   609 	{
   610 		col.setNamedColor(a.value("color"));
   611 		xlo->setColor (col);
   612 	}
   613 
   614 	if (!a.value( "width").isEmpty() ) 
   615 	{
   616 		xlo->setWidth(a.value ("width").toInt (&okx, 10));
   617 	}
   618 
   619 	// Connecting by select string for compatibility with version < 1.8.76
   620 	if (!a.value( "beginBranch").isEmpty() ) 
   621 	{ 
   622 		if (!a.value( "endBranch").isEmpty() ) 
   623 		{
   624 			LinkableMapObj *lmo=mc->findObjBySelect (a.value( "beginBranch"));
   625 			if (lmo && typeid (*lmo)==typeid (BranchObj))
   626 			{
   627 				xlo->setBegin ((BranchObj*)lmo);
   628 				lmo=mc->findObjBySelect (a.value( "endBranch"));
   629 				if (lmo && typeid (*lmo)==typeid (BranchObj))
   630 				{
   631 					xlo->setEnd ((BranchObj*)(lmo));
   632 					xlo->activate();
   633 				}
   634 			}
   635 			success=true; // Not all branches there yet, no error
   636 		}           
   637 	}	
   638 
   639 	// object ID is used starting in version 1.8.76
   640 	if (!a.value( "beginID").isEmpty() ) 
   641 	{ 
   642 		if (!a.value( "endID").isEmpty() ) 
   643 		{
   644 			LinkableMapObj *lmo=mc->findID (a.value( "beginBranch"));
   645 			if (lmo && typeid (*lmo)==typeid (BranchObj))
   646 			{
   647 				xlo->setBegin ((BranchObj*)lmo);
   648 				lmo=mc->findID (a.value( "endID"));
   649 				if (lmo && typeid (*lmo)==typeid (BranchObj))
   650 				{
   651 					xlo->setEnd ((BranchObj*)(lmo));
   652 					xlo->activate();
   653 				}
   654 			}
   655 			success=true; // Not all branches there yet, no error
   656 		}           
   657 	}	
   658 	if (!success) delete (xlo);
   659 	return success;
   660 }
   661 
   662 bool mapBuilderHandler::readHtmlAttr (const QXmlAttributes& a)
   663 {
   664 	for (int i=1; i<=a.count(); i++)
   665 		htmldata+=" "+a.localName(i-1)+"=\""+a.value(i-1)+"\"";
   666 	return true;
   667 }
   668 
   669 bool mapBuilderHandler::readSettingAttr (const QXmlAttributes& a)
   670 {
   671 	if (!a.value( "key").isEmpty() ) 
   672 	{
   673 		if (!a.value( "value").isEmpty() ) 
   674 			settings.setLocalEntry (me->getDestPath(), a.value ("key"), a.value ("value"));
   675 		else
   676 			return false;
   677 		
   678 	} else
   679 		return false;
   680 	
   681 	return true;
   682 }