MCPcopy Create free account
hub / github.com/KDE/labplot / load

Method load

src/backend/notebook/Notebook.cpp:400–471  ·  view source on GitHub ↗

Load from XML

Source from the content-addressed store, hash-verified

398
399//! Load from XML
400bool Notebook::load(XmlStreamReader* reader, bool preview) {
401 // reset the status of the reader differentiating between
402 //"failed because of the missing CAS" and "failed because of the broken XML"
403 reader->setFailedCASMissing(false);
404
405 if (!readBasicAttributes(reader))
406 return false;
407
408 QXmlStreamAttributes attribs;
409 bool rc = false;
410
411 QString name;
412 if (Project::xmlVersion() < 14)
413 name = QLatin1String("cantorWorksheet");
414 else
415 name = QLatin1String("notebook");
416
417 while (!reader->atEnd()) {
418 reader->readNext();
419 if (reader->isEndElement() && reader->name() == name)
420 break;
421
422 if (!reader->isStartElement())
423 continue;
424
425 if (reader->name() == QLatin1String("comment")) {
426 if (!readCommentElement(reader))
427 return false;
428 } else if (!preview && reader->name() == QLatin1String("general")) {
429 attribs = reader->attributes();
430
431 m_backendName = attribs.value(QStringLiteral("backend_name")).toString().trimmed();
432 if (m_backendName.isEmpty())
433 reader->raiseMissingAttributeWarning(QStringLiteral("backend_name"));
434 } else if (!preview && reader->name() == QLatin1String("worksheet")) {
435 attribs = reader->attributes();
436
437 QString str = attribs.value(QStringLiteral("content")).toString().trimmed();
438 if (str.isEmpty())
439 reader->raiseMissingAttributeWarning(QStringLiteral("content"));
440
441 QByteArray content = QByteArray::fromBase64(str.toLatin1());
442 rc = init(&content);
443 if (!rc) {
444 reader->raiseMissingCASWarning(m_backendName);
445
446 // failed to load this object because of the missing CAS plugin
447 // and not because of the broken project XML. Set this flag to
448 // handle this case correctly.
449 // TODO: we also can fail in the limit in cases where Cantor's content is broken
450 // and not because of the missing CAS plugin. This also needs to be treated accrodingly...
451 reader->setFailedCASMissing(true);
452 return false;
453 }
454 } else if (!preview && reader->name() == QLatin1String("column")) {
455 Column* column = new Column(QString());
456 column->setUndoAware(false);
457 if (!column->load(reader, preview)) {

Callers

nothing calls this directly

Calls 13

setFailedCASMissingMethod · 0.80
atEndMethod · 0.80
setUndoAwareMethod · 0.80
setFixedMethod · 0.80
skipToEndElementMethod · 0.80
QStringClass · 0.70
nameMethod · 0.45
toStringMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected