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

Method loadFromXmlFile

src/3rdparty/QXlsx/source/xlsxworkbook.cpp:558–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

556}
557
558bool Workbook::loadFromXmlFile(QIODevice *device)
559{
560 Q_D(Workbook);
561
562 QXmlStreamReader reader(device);
563 while (!reader.atEnd())
564 {
565 QXmlStreamReader::TokenType token = reader.readNext();
566 if (token == QXmlStreamReader::StartElement)
567 {
568 if (reader.name() == QLatin1String("sheet"))
569 {
570 QXmlStreamAttributes attributes = reader.attributes();
571
572 const auto& name = attributes.value(QLatin1String("name")).toString();
573
574 int sheetId = attributes.value(QLatin1String("sheetId")).toInt();
575
576 const auto& rId = attributes.value(QLatin1String("r:id")).toString();
577
578 const auto& stateString = attributes.value(QLatin1String("state"));
579
580 AbstractSheet::SheetState state = AbstractSheet::SS_Visible;
581 if (stateString == QLatin1String("hidden"))
582 state = AbstractSheet::SS_Hidden;
583 else if (stateString == QLatin1String("veryHidden"))
584 state = AbstractSheet::SS_VeryHidden;
585
586 XlsxRelationship relationship = d->relationships->getRelationshipById(rId);
587
588 AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet;
589 if (relationship.type.endsWith(QLatin1String("/worksheet")))
590 {
591 type = AbstractSheet::ST_WorkSheet;
592 }
593 else if (relationship.type.endsWith(QLatin1String("/chartsheet")))
594 {
595 type = AbstractSheet::ST_ChartSheet;
596 }
597 else if (relationship.type.endsWith(QLatin1String("/dialogsheet")))
598 {
599 type = AbstractSheet::ST_DialogSheet;
600 }
601 else if (relationship.type.endsWith(QLatin1String("/xlMacrosheet")))
602 {
603 type = AbstractSheet::ST_MacroSheet;
604 }
605 else
606 {
607 qWarning() << "unknown sheet type : " << relationship.type ;
608 }
609
610 AbstractSheet *sheet = addSheet(name, sheetId, type);
611 sheet->setSheetState(state);
612 QString strFilePath = filePath();
613
614 // const QString fullPath = QDir::cleanPath(splitPath(strFilePath).constFirst() + QLatin1String("/") + relationship.target);
615 const auto parts = splitPath(strFilePath);

Callers

nothing calls this directly

Calls 10

splitPathFunction · 0.85
atEndMethod · 0.80
getRelationshipByIdMethod · 0.80
setSheetStateMethod · 0.80
setFilePathMethod · 0.80
appendMethod · 0.80
sheetIdMethod · 0.80
nameMethod · 0.45
toStringMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected