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