1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/xml-vym.cpp Mon Jul 27 12:53:19 2009 +0000
1.3 @@ -0,0 +1,641 @@
1.4 +#include "xml-vym.h"
1.5 +
1.6 +#include <QMessageBox>
1.7 +#include <QColor>
1.8 +#include <QTextStream>
1.9 +#include <iostream>
1.10 +#include <typeinfo>
1.11 +
1.12 +#include "misc.h"
1.13 +#include "settings.h"
1.14 +#include "linkablemapobj.h"
1.15 +#include "version.h"
1.16 +
1.17 +static BranchObj *lastBranch;
1.18 +static FloatObj *lastFloat;
1.19 +static OrnamentedObj *lastOO;
1.20 +
1.21 +extern Settings settings;
1.22 +extern QString vymVersion;
1.23 +
1.24 +/*
1.25 +parseVYMHandler::parseVYMHandler() {}
1.26 +
1.27 +parseVYMHandler::~parseVYMHandler() {}
1.28 +
1.29 +QString parseVYMHandler::errorProtocol() { return errorProt; }
1.30 +
1.31 +*/
1.32 +
1.33 +bool parseVYMHandler::startDocument()
1.34 +{
1.35 + errorProt = "";
1.36 + state = StateInit;
1.37 + laststate = StateInit;
1.38 + stateStack.clear();
1.39 + stateStack.append(StateInit);
1.40 + htmldata="";
1.41 + isVymPart=false;
1.42 + return true;
1.43 +}
1.44 +
1.45 +
1.46 +/*
1.47 +QString parseVYMHandler::parseHREF(QString href)
1.48 +{
1.49 + QString type=href.section(":",0,0);
1.50 + QString path=href.section(":",1,1);
1.51 + if (!tmpDir.endsWith("/"))
1.52 + return tmpDir + "/" + path;
1.53 + else
1.54 + return tmpDir + path;
1.55 +}
1.56 +*/
1.57 +bool parseVYMHandler::startElement ( const QString&, const QString&,
1.58 + const QString& eName, const QXmlAttributes& atts )
1.59 +{
1.60 + QColor col;
1.61 + /* Testing
1.62 + cout << "startElement <"<< qPrintable(eName)
1.63 + <<"> state="<<state
1.64 + <<" laststate="<<stateStack.last()
1.65 + <<" loadMode="<<loadMode
1.66 + <<" line="<<QXmlDefaultHandler::lineNumber()
1.67 + <<endl;
1.68 + */
1.69 + stateStack.append (state);
1.70 + if ( state == StateInit && (eName == "vymmap") )
1.71 + {
1.72 + state = StateMap;
1.73 +
1.74 + if (loadMode==NewMap)
1.75 + model->clear(); // remove existing mapCenter
1.76 +
1.77 + // Check version
1.78 + if (!atts.value( "version").isEmpty() )
1.79 + {
1.80 + if (!checkVersion(atts.value("version")))
1.81 + QMessageBox::warning( 0, "Warning: Version Problem" ,
1.82 + "<h3>Map is newer than VYM</h3>"
1.83 + "<p>The map you are just trying to load was "
1.84 + "saved using vym " +atts.value("version")+". "
1.85 + "The version of this vym is " + vymVersion +
1.86 + ". If you run into problems after pressing "
1.87 + "the ok-button below, updating vym should help.");
1.88 + else
1.89 + model->setVersion(atts.value( "version" ));
1.90 +
1.91 + }
1.92 +
1.93 + if (loadMode==NewMap )
1.94 + {
1.95 + // Create mapCenter
1.96 + model->clear();
1.97 + lastBranch=model->first(); // avoid empty pointer
1.98 +
1.99 + if (!atts.value( "author").isEmpty() )
1.100 + model->setAuthor(atts.value( "author" ) );
1.101 + if (!atts.value( "comment").isEmpty() )
1.102 + model->setComment (atts.value( "comment" ) );
1.103 + if (!atts.value( "backgroundColor").isEmpty() )
1.104 + {
1.105 + col.setNamedColor(atts.value("backgroundColor"));
1.106 + model->getScene()->setBackgroundBrush(col);
1.107 + }
1.108 + if (!atts.value( "selectionColor").isEmpty() )
1.109 + {
1.110 + col.setNamedColor(atts.value("selectionColor"));
1.111 + model->getMapEditor()->setSelectionColor(col);
1.112 + }
1.113 + if (!atts.value( "linkColorHint").isEmpty() )
1.114 + {
1.115 + if (atts.value("linkColorHint")=="HeadingColor")
1.116 + model->getMapEditor()->setMapLinkColorHint(LinkableMapObj::HeadingColor);
1.117 + else
1.118 + model->getMapEditor()->setMapLinkColorHint(LinkableMapObj::DefaultColor);
1.119 + }
1.120 + if (!atts.value( "linkStyle").isEmpty() )
1.121 + model->getMapEditor()->setMapLinkStyle(atts.value("linkStyle"));
1.122 + if (!atts.value( "linkColor").isEmpty() )
1.123 + {
1.124 + col.setNamedColor(atts.value("linkColor"));
1.125 + model->getMapEditor()->setMapDefLinkColor(col);
1.126 + }
1.127 + if (!atts.value( "defXLinkColor").isEmpty() )
1.128 + {
1.129 + col.setNamedColor(atts.value("defXLinkColor"));
1.130 + model->getMapEditor()->setMapDefXLinkColor(col);
1.131 + }
1.132 + if (!atts.value( "defXLinkWidth").isEmpty() )
1.133 + model->getMapEditor()->setMapDefXLinkWidth(atts.value("defXLinkWidth").toInt ());
1.134 + }
1.135 + } else if ( eName == "select" && state == StateMap )
1.136 + {
1.137 + state=StateMapSelect;
1.138 + } else if ( eName == "setting" && state == StateMap )
1.139 + {
1.140 + state=StateMapSetting;
1.141 + if (loadMode==NewMap)
1.142 + readSettingAttr (atts);
1.143 + } else if ( eName == "mapcenter" && state == StateMap )
1.144 + {
1.145 + state=StateMapCenter;
1.146 + if (loadMode==NewMap)
1.147 + {
1.148 + // Really use the found mapcenter as MCO in a new map
1.149 +
1.150 + lastBranch=model->addMapCenter();
1.151 + } else
1.152 + {
1.153 + // Treat the found mapcenter as a branch
1.154 + // in an existing map
1.155 + LinkableMapObj* lmo=model->getSelection();
1.156 + if (lmo && ((typeid(*lmo) == typeid(BranchObj) )
1.157 + || typeid(*lmo) == typeid(MapCenterObj) ) )
1.158 + {
1.159 + lastBranch=(BranchObj*)lmo;
1.160 + if (loadMode==ImportAdd)
1.161 + {
1.162 + lastBranch->addBranch();
1.163 + lastBranch=lastBranch->getLastBranch();
1.164 + } else
1.165 + lastBranch->clear();
1.166 + } else
1.167 + return false;
1.168 + }
1.169 + readBranchAttr (atts);
1.170 + } else if (
1.171 + (eName == "standardflag" ||eName == "standardFlag") &&
1.172 + (state == StateMapCenter || state==StateBranch))
1.173 + {
1.174 + state=StateStandardFlag;
1.175 + } else if ( eName == "heading" && (state == StateMapCenter||state==StateBranch))
1.176 + {
1.177 + laststate=state;
1.178 + state=StateHeading;
1.179 + if (!atts.value( "textColor").isEmpty() )
1.180 + {
1.181 + col.setNamedColor(atts.value("textColor"));
1.182 + lastBranch->setColor(col );
1.183 + }
1.184 + } else if ( eName == "note" &&
1.185 + (state == StateMapCenter ||state==StateBranch))
1.186 + { // only for backward compatibility (<1.4.6). Use htmlnote now.
1.187 + state=StateNote;
1.188 + if (!readNoteAttr (atts) ) return false;
1.189 + } else if ( eName == "htmlnote" && state == StateMapCenter)
1.190 + {
1.191 + laststate=state;
1.192 + state=StateHtmlNote;
1.193 + } else if ( eName == "floatimage" &&
1.194 + (state == StateMapCenter ||state==StateBranch))
1.195 + {
1.196 + state=StateFloatImage;
1.197 + lastBranch->addFloatImage();
1.198 + lastFloat=lastBranch->getLastFloatImage();
1.199 + if (!readFloatImageAttr(atts)) return false;
1.200 + } else if ( (eName == "branch"||eName=="floatimage") && state == StateMap)
1.201 + {
1.202 + // This is used in vymparts, which have no mapcenter!
1.203 + isVymPart=true;
1.204 + LinkableMapObj* lmo=model->getSelection();
1.205 + if (!lmo)
1.206 + {
1.207 + // If a vym part is _loaded_ (not imported),
1.208 + // selection==lmo==NULL
1.209 + // Treat it like ImportAdd then...
1.210 + loadMode=ImportAdd;
1.211 + lmo=model->first(); // FIXME this used to be lmo=mc before
1.212 + }
1.213 + if (lmo && ((typeid(*lmo) == typeid(BranchObj) )
1.214 + || typeid(*lmo) == typeid(MapCenterObj) ) )
1.215 + {
1.216 + lastBranch=(BranchObj*)(lmo);
1.217 + if (eName=="branch")
1.218 + {
1.219 + state=StateBranch;
1.220 + if (loadMode==ImportAdd)
1.221 + {
1.222 + lastBranch->addBranch();
1.223 + lastBranch=lastBranch->getLastBranch();
1.224 +
1.225 + } else
1.226 + lastBranch->clear();
1.227 + readBranchAttr (atts);
1.228 + } else if (eName=="floatimage")
1.229 + {
1.230 + state=StateFloatImage;
1.231 + lastBranch->addFloatImage();
1.232 + lastFloat=lastBranch->getLastFloatImage();
1.233 + if (!readFloatImageAttr(atts)) return false;
1.234 + } else return false;
1.235 + } else return false;
1.236 + } else if ( eName == "branch" && state == StateMapCenter)
1.237 + {
1.238 + state=StateBranch;
1.239 + lastBranch->addBranch();
1.240 + lastBranch=lastBranch->getLastBranch();
1.241 + readBranchAttr (atts);
1.242 + } else if ( eName == "htmlnote" && state == StateBranch)
1.243 + {
1.244 + laststate=state;
1.245 + state=StateHtmlNote;
1.246 + no.clear();
1.247 + if (!atts.value( "fonthint").isEmpty() )
1.248 + no.setFontHint(atts.value ("fonthint") );
1.249 + } else if ( eName == "frame" && (state == StateBranch||state==StateMapCenter))
1.250 + {
1.251 + laststate=state;
1.252 + state=StateFrame;
1.253 + if (!readFrameAttr(atts)) return false;
1.254 + } else if ( eName == "xlink" && state == StateBranch )
1.255 + {
1.256 + state=StateBranchXLink;
1.257 + if (!readXLinkAttr (atts)) return false;
1.258 + } else if ( eName == "branch" && state == StateBranch )
1.259 + {
1.260 + lastBranch->addBranch();
1.261 + lastBranch=lastBranch->getLastBranch();
1.262 + readBranchAttr (atts);
1.263 + } else if ( eName == "html" && state == StateHtmlNote )
1.264 + {
1.265 + state=StateHtml;
1.266 + htmldata="<"+eName;
1.267 + readHtmlAttr(atts);
1.268 + htmldata+=">";
1.269 + } else if ( state == StateHtml )
1.270 + {
1.271 + // accept all while in html mode,
1.272 + htmldata+="<"+eName;
1.273 + readHtmlAttr(atts);
1.274 + htmldata+=">";
1.275 + } else
1.276 + return false; // Error
1.277 + return true;
1.278 +}
1.279 +
1.280 +bool parseVYMHandler::endElement ( const QString&, const QString&, const QString &eName)
1.281 +{
1.282 + /* Testing
1.283 + cout << "endElement </" <<qPrintable(eName)
1.284 + <<"> state=" <<state
1.285 + <<" laststate=" <<laststate
1.286 + <<" stateStack="<<stateStack.last()
1.287 + <<endl;
1.288 + */
1.289 + switch ( state )
1.290 + {
1.291 + case StateBranch:
1.292 + // Empty branches may not be scrolled
1.293 + // (happens if bookmarks are imported)
1.294 + if (lastBranch->isScrolled() && lastBranch->countBranches()==0)
1.295 + lastBranch->unScroll();
1.296 + lastBranch=(BranchObj*)(lastBranch->getParObj());
1.297 + break;
1.298 + case StateHtml:
1.299 + htmldata+="</"+eName+">";
1.300 + if (eName=="html")
1.301 + {
1.302 + state=StateHtmlNote;
1.303 + htmldata.replace ("<br></br>","<br />");
1.304 + no.setNote (htmldata);
1.305 + lastBranch->setNote (no);
1.306 + }
1.307 + break;
1.308 + default:
1.309 + break;
1.310 + }
1.311 + state=stateStack.takeLast();
1.312 + return true;
1.313 +}
1.314 +
1.315 +bool parseVYMHandler::characters ( const QString& ch)
1.316 +{
1.317 + //cout << "characters \""<<ch<<"\" state="<<state <<" laststate="<<laststate<<endl;
1.318 +
1.319 + QString ch_org=quotemeta (ch);
1.320 + QString ch_simplified=ch.simplifyWhiteSpace();
1.321 + if ( ch_simplified.isEmpty() ) return true;
1.322 +
1.323 + switch ( state )
1.324 + {
1.325 + case StateInit: break;
1.326 + case StateMap: break;
1.327 + case StateMapSelect:
1.328 + model->select(ch_simplified);
1.329 + break;
1.330 + case StateMapSetting:break;
1.331 + case StateMapCenter: break;
1.332 + case StateNote:
1.333 + lastBranch->setNote(ch_simplified);
1.334 + break;
1.335 + case StateBranch: break;
1.336 + case StateStandardFlag:
1.337 + lastBranch->activateStandardFlag(ch_simplified);
1.338 + break;
1.339 + case StateFloatImage: break;
1.340 + case StateHtmlNote: break;
1.341 + case StateHtml:
1.342 + htmldata+=ch_org;
1.343 + break;
1.344 + case StateHeading:
1.345 + lastBranch->setHeading(ch_simplified);
1.346 + break;
1.347 + default:
1.348 + return false;
1.349 + }
1.350 + return true;
1.351 +}
1.352 +
1.353 +QString parseVYMHandler::errorString()
1.354 +{
1.355 + return "the document is not in the VYM file format";
1.356 +}
1.357 +
1.358 +bool parseVYMHandler::readBranchAttr (const QXmlAttributes& a)
1.359 +{
1.360 + lastOO=lastBranch;
1.361 + if (!readOOAttr(a)) return false;
1.362 +
1.363 + if (!a.value( "scrolled").isEmpty() )
1.364 + lastBranch->toggleScroll();
1.365 + if (!a.value( "frameType").isEmpty() )
1.366 + lastOO->setFrameType (a.value("frameType")); //Compatibility 1.8.1
1.367 +
1.368 + if (!a.value( "incImgV").isEmpty() )
1.369 + {
1.370 + if (a.value("incImgV")=="true")
1.371 + lastBranch->setIncludeImagesVer(true);
1.372 + else
1.373 + lastBranch->setIncludeImagesVer(false);
1.374 + }
1.375 + if (!a.value( "incImgH").isEmpty() )
1.376 + {
1.377 + if (a.value("incImgH")=="true")
1.378 + lastBranch->setIncludeImagesHor(true);
1.379 + else
1.380 + lastBranch->setIncludeImagesHor(false);
1.381 + }
1.382 + return true;
1.383 +}
1.384 +
1.385 +bool parseVYMHandler::readFrameAttr (const QXmlAttributes& a)
1.386 +{
1.387 + bool ok;
1.388 + int x;
1.389 + if (lastOO)
1.390 + {
1.391 + if (!a.value( "frameType").isEmpty() )
1.392 + lastOO->setFrameType (a.value("frameType"));
1.393 + if (!a.value( "penColor").isEmpty() )
1.394 + lastOO->setFramePenColor (a.value("penColor"));
1.395 + if (!a.value( "brushColor").isEmpty() )
1.396 + lastOO->setFrameBrushColor (a.value("brushColor"));
1.397 + if (!a.value( "padding").isEmpty() )
1.398 + {
1.399 + x=a.value("padding").toInt(&ok);
1.400 + if (ok) lastOO->setFramePadding(x);
1.401 + }
1.402 + if (!a.value( "borderWidth").isEmpty() )
1.403 + {
1.404 + x=a.value("borderWidth").toInt(&ok);
1.405 + if (ok) lastOO->setFrameBorderWidth(x);
1.406 + }
1.407 + }
1.408 + return true;
1.409 +}
1.410 +
1.411 +bool parseVYMHandler::readOOAttr (const QXmlAttributes& a)
1.412 +{
1.413 + if (lastOO)
1.414 + {
1.415 + bool okx,oky;
1.416 + float x,y;
1.417 + if (!a.value( "relPosX").isEmpty() )
1.418 + {
1.419 + if (!a.value( "relPosY").isEmpty() )
1.420 + {
1.421 + x=a.value("relPosX").toFloat (&okx);
1.422 + y=a.value("relPosY").toFloat (&oky);
1.423 + if (okx && oky )
1.424 + {
1.425 + lastOO->setUseRelPos (true);
1.426 + lastOO->move2RelPos (x,y);
1.427 + }
1.428 + else
1.429 + return false; // Couldn't read relPos
1.430 + }
1.431 + }
1.432 + if (!a.value( "absPosX").isEmpty() && loadMode==NewMap )
1.433 + {
1.434 + if (!a.value( "absPosY").isEmpty() )
1.435 + {
1.436 + x=a.value("absPosX").toFloat (&okx);
1.437 + y=a.value("absPosY").toFloat (&oky);
1.438 + if (okx && oky )
1.439 + lastOO->move(x,y);
1.440 + else
1.441 + return false; // Couldn't read absPos
1.442 + }
1.443 + }
1.444 + if (!a.value( "id").isEmpty() )
1.445 + lastOO->setID (a.value ("id"));
1.446 + if (!a.value( "url").isEmpty() )
1.447 + lastOO->setURL (a.value ("url"));
1.448 + if (!a.value( "vymLink").isEmpty() )
1.449 + lastOO->setVymLink (a.value ("vymLink"));
1.450 + if (!a.value( "hideInExport").isEmpty() )
1.451 + if (a.value("hideInExport")=="true")
1.452 + lastOO->setHideInExport(true);
1.453 +
1.454 + if (!a.value( "hideLink").isEmpty())
1.455 + {
1.456 + if (a.value ("hideLink") =="true")
1.457 + lastOO->setHideLinkUnselected(true);
1.458 + else
1.459 + lastOO->setHideLinkUnselected(false);
1.460 + }
1.461 + }
1.462 + return true;
1.463 +}
1.464 +
1.465 +bool parseVYMHandler::readNoteAttr (const QXmlAttributes& a)
1.466 +{ // only for backward compatibility (<1.4.6). Use htmlnote now.
1.467 + no.clear();
1.468 + QString fn;
1.469 + if (!a.value( "href").isEmpty() )
1.470 + {
1.471 + // Load note
1.472 + fn=parseHREF(a.value ("href") );
1.473 + QFile file (fn);
1.474 + QString s; // Reading a note
1.475 +
1.476 + if ( !file.open( QIODevice::ReadOnly) )
1.477 + {
1.478 + qWarning ("parseVYMHandler::readNoteAttr: Couldn't load "+fn);
1.479 + return false;
1.480 + }
1.481 + QTextStream stream( &file );
1.482 + QString lines;
1.483 + while ( !stream.atEnd() ) {
1.484 + lines += stream.readLine()+"\n";
1.485 + }
1.486 + file.close();
1.487 +
1.488 + lines ="<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body>"+lines + "</p></body></html>";
1.489 + no.setNote (lines);
1.490 + }
1.491 + if (!a.value( "fonthint").isEmpty() )
1.492 + no.setFontHint(a.value ("fonthint") );
1.493 + lastBranch->setNote(no);
1.494 + return true;
1.495 +}
1.496 +
1.497 +bool parseVYMHandler::readFloatImageAttr (const QXmlAttributes& a)
1.498 +{
1.499 + lastOO=lastFloat;
1.500 +
1.501 + //if (!readOOAttr(a)) return false;
1.502 +
1.503 + if (!a.value( "useOrientation").isEmpty() )
1.504 + {
1.505 + if (a.value ("useOrientation") =="true")
1.506 + lastFloat->setUseOrientation (true);
1.507 + else
1.508 + lastFloat->setUseOrientation (false);
1.509 + }
1.510 + if (!a.value( "href").isEmpty() )
1.511 + {
1.512 + // Load FloatImage
1.513 + if (!lastFloat->load (parseHREF(a.value ("href") ) ))
1.514 + {
1.515 + QMessageBox::warning( 0, "Warning: " ,
1.516 + "Couldn't load float image\n"+parseHREF(a.value ("href") ));
1.517 + lastBranch->removeFloatImage(((FloatImageObj*)(lastFloat)));
1.518 + lastFloat=NULL;
1.519 + return true;
1.520 + }
1.521 +
1.522 + }
1.523 + if (!a.value( "floatExport").isEmpty() )
1.524 + {
1.525 + // Only for compatibility. THis is not used since 1.7.11
1.526 + if (a.value ("floatExport") =="true")
1.527 + lastFloat->setFloatExport(true);
1.528 + else
1.529 + lastFloat->setFloatExport (false);
1.530 + }
1.531 + if (!a.value( "zPlane").isEmpty() )
1.532 + lastFloat->setZValue (a.value("zPlane").toInt ());
1.533 + float x,y;
1.534 + bool okx,oky;
1.535 + if (!a.value( "relPosX").isEmpty() )
1.536 + {
1.537 + if (!a.value( "relPosY").isEmpty() )
1.538 + {
1.539 + // read relPos
1.540 + x=a.value("relPosX").toFloat (&okx);
1.541 + y=a.value("relPosY").toFloat (&oky);
1.542 + if (okx && oky)
1.543 +
1.544 + {
1.545 + lastFloat->setRelPos (QPointF (x,y) );
1.546 + // make sure floats in mapcenter are repositioned to relative pos
1.547 + if (lastBranch->getDepth()==0) lastBranch->positionContents();
1.548 + }
1.549 + else
1.550 + // Couldn't read relPos
1.551 + return false;
1.552 + }
1.553 + }
1.554 +
1.555 + if (!readOOAttr(a)) return false;
1.556 +
1.557 + if (!a.value ("orgName").isEmpty() )
1.558 + {
1.559 + ((FloatImageObj*)(lastFloat))->setOriginalFilename (a.value("orgName"));
1.560 + }
1.561 + return true;
1.562 +}
1.563 +
1.564 +bool parseVYMHandler::readXLinkAttr (const QXmlAttributes& a)
1.565 +{
1.566 + QColor col;
1.567 + bool okx;
1.568 + bool success=false;
1.569 + XLinkObj *xlo=new XLinkObj (model->getScene());
1.570 + if (!a.value( "color").isEmpty() )
1.571 + {
1.572 + col.setNamedColor(a.value("color"));
1.573 + xlo->setColor (col);
1.574 + }
1.575 +
1.576 + if (!a.value( "width").isEmpty() )
1.577 + {
1.578 + xlo->setWidth(a.value ("width").toInt (&okx, 10));
1.579 + }
1.580 +
1.581 + // Connecting by select string for compatibility with version < 1.8.76
1.582 + if (!a.value( "beginBranch").isEmpty() )
1.583 + {
1.584 + if (!a.value( "endBranch").isEmpty() )
1.585 + {
1.586 + LinkableMapObj *lmo=model->findObjBySelect (a.value( "beginBranch"));
1.587 + if (lmo && typeid (*lmo)==typeid (BranchObj))
1.588 + {
1.589 + xlo->setBegin ((BranchObj*)lmo);
1.590 + lmo=model->findObjBySelect (a.value( "endBranch"));
1.591 + if (lmo && typeid (*lmo)==typeid (BranchObj))
1.592 + {
1.593 + xlo->setEnd ((BranchObj*)(lmo));
1.594 + xlo->activate();
1.595 + success=true;
1.596 + }
1.597 + }
1.598 + }
1.599 + }
1.600 +
1.601 + // object ID is used starting in version 1.8.76
1.602 + if (!a.value( "beginID").isEmpty() )
1.603 + {
1.604 + if (!a.value( "endID").isEmpty() )
1.605 + {
1.606 + LinkableMapObj *lmo=model->findID (a.value( "beginID"));
1.607 + if (lmo && typeid (*lmo)==typeid (BranchObj))
1.608 + {
1.609 + xlo->setBegin ((BranchObj*)lmo);
1.610 + lmo=model->findID (a.value( "endID"));
1.611 + if (lmo && typeid (*lmo)==typeid (BranchObj))
1.612 + {
1.613 + xlo->setEnd ((BranchObj*)(lmo));
1.614 + xlo->activate();
1.615 + success=true;
1.616 + }
1.617 + }
1.618 + }
1.619 + }
1.620 + if (!success) delete (xlo);
1.621 + return true; // xLinks can only be established at the "end branch", return true
1.622 +}
1.623 +
1.624 +bool parseVYMHandler::readHtmlAttr (const QXmlAttributes& a)
1.625 +{
1.626 + for (int i=1; i<=a.count(); i++)
1.627 + htmldata+=" "+a.localName(i-1)+"=\""+a.value(i-1)+"\"";
1.628 + return true;
1.629 +}
1.630 +
1.631 +bool parseVYMHandler::readSettingAttr (const QXmlAttributes& a)
1.632 +{
1.633 + if (!a.value( "key").isEmpty() )
1.634 + {
1.635 + if (!a.value( "value").isEmpty() )
1.636 + settings.setLocalEntry (model->getMapEditor()->getDestPath(), a.value ("key"), a.value ("value"));
1.637 + else
1.638 + return false;
1.639 +
1.640 + } else
1.641 + return false;
1.642 +
1.643 + return true;
1.644 +}