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