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