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