xml.cpp
author insilmaril
Thu, 23 Nov 2006 16:18:26 +0000
changeset 407 5db8dfd30ea2
parent 406 1c8ff1928b97
child 408 c2a05fa925a1
permissions -rw-r--r--
Removed even more QT3 stuff. Drag & Drop not 100% functional at the moment
     1 #include "xml.h"
     2 
     3 #include <QMessageBox>
     4 #include <QColor>
     5 // #include <q3stylesheet.h>
     6 #include <QTextStream>
     7 #include <iostream>
     8 
     9 #include "misc.h"
    10 #include "settings.h"
    11 #include "linkablemapobj.h"
    12 #include "version.h"
    13 
    14 static BranchObj *lastBranch;
    15 static FloatObj *lastFloat;
    16 static OrnamentedObj *lastOO;
    17 
    18 extern Settings settings;
    19 extern QString vymVersion;
    20 
    21 mapBuilderHandler::mapBuilderHandler() {}
    22 
    23 mapBuilderHandler::~mapBuilderHandler() {}
    24 
    25 QString mapBuilderHandler::errorProtocol() { return errorProt; }
    26 
    27 bool mapBuilderHandler::startDocument()
    28 {
    29     errorProt = "";
    30     state = StateInit;
    31     laststate = StateInit;
    32     branchDepth=0;
    33 	htmldata="";
    34 	isVymPart=false;
    35     return true;
    36 }
    37 
    38 
    39 QString mapBuilderHandler::parseHREF(QString href)
    40 {
    41 	QString type=href.section(":",0,0);
    42 	QString path=href.section(":",1,1);
    43 	if (!tmpDir.endsWith("/"))
    44 		return tmpDir + "/" + path;
    45 	else	
    46 		return tmpDir + path;
    47 }
    48 
    49 bool mapBuilderHandler::startElement  ( const QString&, const QString&,
    50                     const QString& eName, const QXmlAttributes& atts ) 
    51 {
    52     QColor col;
    53 	/* Testing
    54 	cout << "startElement <"<< eName.ascii()<<
    55 		">  state="<<state <<
    56 		"  laststate="<<laststate<<
    57 		"   loadMode="<<loadMode<<endl;
    58 	*/	
    59     if ( state == StateInit && (eName == "vymmap")  ) 
    60 	{
    61         state = StateMap;
    62 		if (!atts.value( "version").isEmpty() ) 
    63 		{
    64 			if (!checkVersion(atts.value("version")))
    65 				QMessageBox::warning( 0, "Warning: Version Problem" ,
    66 				   "<h3>Map is newer than VYM</h3>"
    67 				   "<p>The map you are just trying to load was "
    68 				   "saved using vym " +atts.value("version")+". "
    69 				   "The version of this vym is " + vymVersion + 
    70 				   ". If you run into problems after pressing "
    71 				   "the ok-button below, updating vym should help.");
    72 			else	   
    73 				mc->setVersion(atts.value( "version" ));
    74 
    75 		}
    76 		if (loadMode==NewMap || 
    77 			(loadMode==ImportReplace && me->getSelection()==mc))
    78 		{
    79 			if (!atts.value( "author").isEmpty() )
    80 			{
    81 				mc->setAuthor(atts.value( "author" ) );
    82 			}
    83 			if (!atts.value( "comment").isEmpty() )
    84 			{
    85 				mc->setComment (atts.value( "comment" ) );
    86 			}
    87 			if (!atts.value( "backgroundColor").isEmpty() )
    88 			{
    89 				col.setNamedColor(atts.value("backgroundColor"));
    90 				mc->getCanvas()->setBackgroundColor(col);
    91 			}	    
    92 			if (!atts.value( "linkColorHint").isEmpty() ) 
    93 			{
    94 				if (atts.value("linkColorHint")=="HeadingColor")
    95 					me->setMapLinkColorHint(HeadingColor);
    96 				else
    97 					me->setMapLinkColorHint(DefaultColor);
    98 			}
    99 			if (!atts.value( "linkStyle").isEmpty() ) 
   100 			{
   101 				me->setMapLinkStyle(atts.value("linkStyle"));
   102 			}	
   103 			if (!atts.value( "linkColor").isEmpty() ) 
   104 			{
   105 				col.setNamedColor(atts.value("linkColor"));
   106 				me->setMapDefLinkColor(col);
   107 			}	
   108 			if (!atts.value( "defXLinkColor").isEmpty() ) 
   109 			{
   110 				col.setNamedColor(atts.value("defXLinkColor"));
   111 				me->setMapDefXLinkColor(col);
   112 			}	
   113 			if (!atts.value( "defXLinkWidth").isEmpty() ) 
   114 			{
   115 				me->setMapDefXLinkWidth(atts.value("defXLinkWidth").toInt ());
   116 			}	
   117 		}	
   118 	} else if ( eName == "select" && state == StateMap ) 
   119 	{
   120 		state=StateMapSelect;
   121 	} else if ( eName == "setting" && state == StateMap ) 
   122 	{
   123 		state=StateMapSetting;
   124 		if (loadMode==NewMap)
   125 			readSettingAttr (atts);
   126 	} else if ( eName == "mapcenter" && state == StateMap ) 
   127 	{
   128 		state=StateMapCenter;
   129 		if (loadMode==NewMap)
   130 		{	
   131 			// Really use the found mapcenter as MCO in a new map
   132 			lastBranch=mc;	// avoid empty pointer
   133 		} else
   134 		{
   135 			// Treat the found mapcenter as a branch 
   136 			// in an existing map
   137 			LinkableMapObj* lmo=me->getSelection();
   138 			if (lmo && (typeid(*lmo) == typeid(BranchObj) ) 
   139 			        || (typeid(*lmo) == typeid(MapCenterObj) ) )
   140 			{
   141 				lastBranch=(BranchObj*)lmo;
   142 				if (loadMode==ImportAdd)
   143 				{
   144 					lastBranch->addBranch();
   145 					lastBranch=lastBranch->getLastBranch();
   146 				} else
   147 					lastBranch->clear();
   148 			} else
   149 				return false;
   150 		}
   151 		readBranchAttr (atts);
   152 	} else if ( (eName == "standardflag" ||eName == "standardFlag") && state == StateMapCenter) 
   153 	{
   154 		state=StateMapCenterStandardFlag;
   155 	} else if ( eName == "heading" && state == StateMapCenter) 
   156 	{
   157 		state=StateMapCenterHeading;
   158 		if (!atts.value( "textColor").isEmpty() ) 
   159 		{
   160 			col.setNamedColor(atts.value("textColor"));
   161 			lastBranch->setColor(col );
   162 		}	    
   163 	} else if ( eName == "note" && state == StateMapCenter) 
   164 	{	// only for backward compatibility (<1.4.6). Use htmlnote now.
   165 		state=StateMapCenterNote;
   166 		if (!readNoteAttr (atts) ) return false;
   167 	} else if ( eName == "htmlnote" && state == StateMapCenter) 
   168 	{
   169 		laststate=state;
   170 		state=StateHtmlNote;
   171     } else if ( eName == "floatimage" && state == StateMapCenter ) 
   172 	{
   173 		state=StateMapCenterFloatImage;
   174         lastBranch->addFloatImage();
   175 		lastFloat=lastBranch->getLastFloatImage();
   176 		if (!readFloatImageAttr(atts)) return false;
   177 	} else if ( (eName == "branch"||eName=="floatimage") && state == StateMap) 
   178 	{
   179 		// This is used in vymparts, which have no mapcenter!
   180 		isVymPart=true;
   181 		LinkableMapObj* lmo=me->getSelection();
   182 		if (!lmo)
   183 		{
   184 			// If a vym part is _loaded_ (not imported), 
   185 			// selection==lmo==NULL
   186 			// Treat it like ImportAdd then...
   187 			loadMode=ImportAdd;
   188 			lmo=mc;
   189 		}	
   190 		if (lmo && (typeid(*lmo) == typeid(BranchObj) ) 
   191 				|| (typeid(*lmo) == typeid(MapCenterObj) ) )
   192 		{
   193 			lastBranch=(BranchObj*)(lmo);
   194 			if (eName=="branch")
   195 			{
   196 				state=StateBranch;
   197 				if (loadMode==ImportAdd)
   198 				{
   199 					lastBranch->addBranch();
   200 					lastBranch=lastBranch->getLastBranch();
   201 					
   202 				} else
   203 					lastBranch->clear();
   204 				branchDepth=1;
   205 				readBranchAttr (atts);
   206 			} else if (eName=="floatimage")
   207 			{
   208 				state=StateFloatImage;
   209 				lastBranch->addFloatImage();
   210 				lastFloat=lastBranch->getLastFloatImage();
   211 				if (!readFloatImageAttr(atts)) return false;
   212 			} else return false;
   213 		} else return false;
   214 	} else if ( eName == "branch" && state == StateMapCenter) 
   215 	{
   216 		state=StateBranch;
   217 		branchDepth=1;
   218 		lastBranch->addBranch();
   219 		lastBranch=lastBranch->getLastBranch();
   220 		readBranchAttr (atts);
   221 	} else if ( (eName=="standardflag" ||eName == "standardFlag") && state == StateBranch) 
   222 	{
   223 		state=StateBranchStandardFlag;
   224 	} else if ( eName == "heading" && state == StateBranch) 
   225 	{
   226 		state=StateBranchHeading;
   227 		if (!atts.value( "textColor").isEmpty() ) 
   228 		{
   229 			col.setNamedColor(atts.value("textColor"));
   230 			lastBranch->setColor(col );
   231 		}	    
   232     } else if ( eName == "note" && state == StateBranch) 
   233 	{
   234         state=StateBranchNote;
   235 		if (!readNoteAttr (atts) ) return false;
   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 == "floatimage" && state == StateBranch ) 
   244 	{
   245 		state=StateBranchFloatImage;
   246         lastBranch->addFloatImage();
   247 		lastFloat=lastBranch->getLastFloatImage();
   248 		if (!readFloatImageAttr(atts)) return false;
   249     } else if ( eName == "xlink" && state == StateBranch ) 
   250 	{
   251 		state=StateBranchXLink;
   252 		if (!readXLinkAttr (atts)) return false;
   253     } else if ( eName == "branch" && state == StateBranch ) 
   254 	{
   255         lastBranch->addBranch();
   256 		lastBranch=lastBranch->getLastBranch();		
   257         branchDepth++;
   258 		readBranchAttr (atts);
   259     } else if ( eName == "html" && state == StateHtmlNote ) 
   260 	{
   261 		state=StateHtml;
   262 		htmldata="<"+eName;
   263 		readHtmlAttr(atts);
   264 		htmldata+=">";
   265     } else if ( state == StateHtml ) 
   266 	{
   267 		// accept all while in html mode,
   268 		htmldata+="<"+eName;
   269 		readHtmlAttr(atts);
   270 		htmldata+=">";
   271     } else
   272         return false;   // Error
   273     return true;
   274 }
   275 
   276 bool mapBuilderHandler::endElement  ( const QString&, const QString&, const QString &eName)
   277 {
   278 //	cout << "endElement </"<<eName<<">  state="<<state <<"  laststate="<<laststate<<endl;
   279     switch ( state ) 
   280 	{
   281         case StateMapSelect: state=StateMap;  return true;
   282         case StateMapSetting: state=StateMap;  return true;
   283         case StateMapCenter: state=StateMap;  return true;
   284         case StateMapCenterStandardFlag: state=StateMapCenter;  return true;
   285         case StateMapCenterHeading: state=StateMapCenter;  return true;
   286         case StateMapCenterNote: state=StateMapCenter;  return true;
   287         case StateMapCenterFloatImage: state=StateMapCenter;  return true;
   288         case StateFloatImage: state=StateMap; return true;
   289         case StateBranch: 
   290             if (branchDepth>1) 
   291 			{
   292                 branchDepth--;
   293                 state=StateBranch;
   294             } else  
   295 			{
   296                 branchDepth=0;
   297 				if (isVymPart)
   298 					state=StateMap;
   299 				else
   300 					state=StateMapCenter;
   301             }   
   302 			lastBranch=(BranchObj*)(lastBranch->getParObj());
   303              return true;
   304         case StateBranchStandardFlag: state=StateBranch;  return true;
   305         case StateBranchHeading: state=StateBranch;  return true;
   306         case StateBranchNote: state=StateBranch; return true;
   307         case StateBranchFloatImage: state=StateBranch;  return true;
   308         case StateBranchXLink: state=StateBranch;  return true;
   309         case StateHtmlNote: state=laststate; return true;
   310         case StateHtml: 
   311 			htmldata+="</"+eName+">";
   312 			if (eName=="html")
   313 			{
   314 				state=StateHtmlNote;  
   315 				htmldata.replace ("<br></br>","<br />");
   316 				no.setNote (htmldata);
   317 				lastBranch->setNote (no);
   318 				return true;
   319 			}	else
   320 			{
   321 				return true;
   322 			}	
   323         case StateMap: state=StateInit;  return true;
   324         default : 
   325 			// even for HTML includes, this should never be reached
   326 			return false;
   327     }   
   328 }
   329 
   330 bool mapBuilderHandler::characters   ( const QString& ch)
   331 {
   332 	//cout << "characters \""<<ch<<"\"  state="<<state <<"  laststate="<<laststate<<endl;
   333 
   334 	QString ch_org=quotemeta (ch);
   335     QString ch_simplified=ch.simplifyWhiteSpace();
   336     if ( ch_simplified.isEmpty() ) return true;
   337 
   338     switch ( state ) 
   339     {
   340         case StateInit: break;
   341         case StateMap: break; 
   342 		case StateMapSelect:
   343 			me->select(ch_simplified);
   344 			break;
   345 		case StateMapSetting:break;
   346         case StateMapCenter: break;
   347         case StateMapCenterStandardFlag: 
   348             lastBranch->activateStandardFlag(ch_simplified); 
   349             break;
   350         case StateMapCenterHeading: 
   351             lastBranch->setHeading(ch_simplified); 
   352             break;
   353         case StateMapCenterNote:
   354 			lastBranch->setNote(ch_simplified);
   355 			break;
   356         case StateBranch: break;
   357         case StateBranchStandardFlag: 
   358             lastBranch->activateStandardFlag(ch_simplified); 
   359             break;
   360         case StateBranchHeading: 
   361             lastBranch->setHeading(ch_simplified);
   362             break;
   363         case StateBranchNote: 
   364 			lastBranch->setNote(ch_simplified);
   365 			break;
   366         case StateBranchFloatImage: break;
   367         case StateHtmlNote: break;
   368         case StateHtml:
   369 			htmldata+=ch_org;
   370 			break;
   371         default: 
   372 			return false;
   373     }
   374     return true;
   375 }
   376 
   377 QString mapBuilderHandler::errorString() 
   378 {
   379     return "the document is not in the VYM file format";
   380 }
   381 
   382 bool mapBuilderHandler::fatalError( const QXmlParseException& exception ) 
   383 {
   384     errorProt += QString( "Fatal parsing error: %1 in line %2, column %3\n")
   385     .arg( exception.message() )
   386     .arg( exception.lineNumber() )
   387     .arg( exception.columnNumber() );
   388 	// Try to read the bogus line
   389 	errorProt+=QString("File is: %1\n").arg(inputFile);
   390 	QString s;
   391 	if (loadStringFromDisk (inputFile,s))
   392 	{
   393 		QStringList sl=QStringList::split ("\n",s);
   394 		int i=1;
   395 		QStringList::Iterator it = sl.begin();
   396 		while (i<exception.lineNumber()-1)
   397 		{
   398 			it++;
   399 			i++;
   400 		}
   401 		s=*it;
   402 		s.insert (exception.columnNumber()-1,"<ERROR>");
   403 		errorProt+=s;
   404     }
   405     return QXmlDefaultHandler::fatalError( exception );
   406 }
   407 
   408 void mapBuilderHandler::setMapEditor (MapEditor* e)
   409 {
   410     me=e;
   411 	mc=me->getMapCenter();
   412 }
   413 
   414 void mapBuilderHandler::setTmpDir (QString tp)
   415 {
   416 	tmpDir=tp;
   417 }
   418 
   419 void mapBuilderHandler::setInputFile (QString f)
   420 {
   421 	inputFile=f;
   422 }
   423 
   424 void mapBuilderHandler::setLoadMode (const LoadMode &lm)
   425 {
   426 	loadMode=lm;
   427 }
   428 
   429 bool mapBuilderHandler::readBranchAttr (const QXmlAttributes& a)
   430 {
   431 	lastOO=lastBranch;
   432 	if (!readOOAttr(a)) return false;
   433 
   434 	if (!a.value( "scrolled").isEmpty() )
   435 		lastBranch->toggleScroll();
   436 	if (!a.value( "frameType").isEmpty() ) 
   437 		lastBranch->setFrameType (a.value("frameType"));
   438 
   439 	if (!a.value( "incImgV").isEmpty() ) 
   440 	{	
   441 		if (a.value("incImgV")=="true")
   442 			lastBranch->setIncludeImagesVer(true);
   443 		else	
   444 			lastBranch->setIncludeImagesVer(false);
   445 	}	
   446 	if (!a.value( "incImgH").isEmpty() ) 
   447 	{	
   448 		if (a.value("incImgH")=="true")
   449 			lastBranch->setIncludeImagesHor(true);
   450 		else	
   451 			lastBranch->setIncludeImagesHor(false);
   452 	}	
   453 	return true;	
   454 }
   455 
   456 bool mapBuilderHandler::readOOAttr (const QXmlAttributes& a)
   457 {
   458 	if (lastOO)
   459 	{
   460 		bool okx,oky;
   461 		int x,y;
   462 		if (!a.value( "relPosX").isEmpty() ) 
   463 		{
   464 			if (!a.value( "relPosY").isEmpty() ) 
   465 			{
   466 				x=a.value("relPosX").toInt (&okx, 10);
   467 				y=a.value("relPosY").toInt (&oky, 10);
   468 				if (okx && oky  )
   469 				{
   470 					lastOO->setUseRelPos (true);
   471 					lastOO->move2RelPos (x,y);
   472 				}	
   473 				else
   474 					return false;   // Couldn't read relPos
   475 			}           
   476 		}           
   477 		if (!a.value( "absPosX").isEmpty() && loadMode==NewMap && branchDepth<2) 
   478 		{
   479 			if (!a.value( "absPosY").isEmpty() ) 
   480 			{
   481 				x=a.value("absPosX").toInt (&okx, 10);
   482 				y=a.value("absPosY").toInt (&oky, 10);
   483 				if (okx && oky  )
   484 					lastOO->move(x,y);
   485 				else
   486 					return false;   // Couldn't read absPos
   487 			}           
   488 		}           
   489 		if (!a.value( "url").isEmpty() ) 
   490 			lastOO->setURL (a.value ("url"));
   491 		if (!a.value( "vymLink").isEmpty() ) 
   492 			lastOO->setVymLink (a.value ("vymLink"));
   493 		if (!a.value( "hideInExport").isEmpty() ) 
   494 			if (a.value("hideInExport")=="true")
   495 				lastOO->setHideInExport(true);
   496 
   497 		if (!a.value( "hideLink").isEmpty()) 
   498 		{
   499 			if (a.value ("hideLink") =="true")
   500 				lastOO->setHideLinkUnselected(true);
   501 			else	
   502 				lastOO->setHideLinkUnselected(false);
   503 		}	
   504 	}
   505 	return true;	
   506 }
   507 
   508 bool mapBuilderHandler::readNoteAttr (const QXmlAttributes& a)
   509 {	// only for backward compatibility (<1.4.6). Use htmlnote now.
   510 	no.clear();
   511 	QString fn;
   512 	if (!a.value( "href").isEmpty() ) 
   513 	{
   514 		// Load note
   515 		fn=parseHREF(a.value ("href") );
   516 		QFile file (fn);
   517 		QString s;						// Reading a note
   518 
   519 		if ( !file.open( QIODevice::ReadOnly) )
   520 		{
   521 			qWarning ("mapBuilderHandler::readNoteAttr:  Couldn't load "+fn);
   522 			return false;
   523 		}	
   524 		QTextStream stream( &file );
   525 		QString lines;
   526 		while ( !stream.atEnd() ) {
   527 			lines += stream.readLine()+"\n"; 
   528 		}
   529 		file.close();
   530 
   531 		/* TODO very likely not needed any longer
   532 		// Convert to richtext
   533 		if ( !Q3StyleSheet::mightBeRichText( lines ) )
   534 		{
   535 			// Here we are workarounding the QT conversion method:
   536 			// convertFromPlainText does not generate valid xml, needed
   537 			// for the parser, but just <p> and <br> without closing tags.
   538 			// So we have to add those by ourselves
   539 			//lines=quotemeta (lines);
   540 			qWarning ("xml.cpp: Still using Q3StyleSheet::mightBeRichText");
   541 			lines = Q3StyleSheet::convertFromPlainText( lines, Q3StyleSheetItem::WhiteSpaceNormal );
   542 			lines.replace ("<br>","<br />");
   543 		}	
   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 }