| 556 | } |
| 557 | |
| 558 | bool 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); |
nothing calls this directly
no test coverage detected