| 349 | } |
| 350 | |
| 351 | bool SharedStrings::loadFromXmlFile(QIODevice *device) |
| 352 | { |
| 353 | QXmlStreamReader reader(device); |
| 354 | int count = 0; |
| 355 | bool hasUniqueCountAttr=true; |
| 356 | while (!reader.atEnd()) { |
| 357 | QXmlStreamReader::TokenType token = reader.readNext(); |
| 358 | if (token == QXmlStreamReader::StartElement) { |
| 359 | if (reader.name() == QLatin1String("sst")) { |
| 360 | QXmlStreamAttributes attributes = reader.attributes(); |
| 361 | if ((hasUniqueCountAttr = attributes.hasAttribute(QLatin1String("uniqueCount")))) |
| 362 | count = attributes.value(QLatin1String("uniqueCount")).toInt(); |
| 363 | } else if (reader.name() == QLatin1String("si")) { |
| 364 | readString(reader); |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | if (hasUniqueCountAttr && m_stringList.size() != count) { |
| 370 | qDebug("Error: Shared string count"); |
| 371 | return false; |
| 372 | } |
| 373 | |
| 374 | if (m_stringList.size() != m_stringTable.size()) { |
| 375 | //qDebug("Warning: Duplicated items exist in shared string table."); |
| 376 | //Nothing we can do here, as indices of the strings will be used when loading sheets. |
| 377 | } |
| 378 | |
| 379 | return true; |
| 380 | } |
| 381 | |
| 382 | QT_END_NAMESPACE_XLSX |