validate dimension

This commit is contained in:
Paul Kolomiets
2014-06-14 17:01:22 +04:00
committed by Debao Zhang
parent 12e781eb4e
commit b9f3ca5371
2 changed files with 36 additions and 3 deletions
+32
View File
@@ -2309,9 +2309,41 @@ bool Worksheet::loadFromXmlFile(QIODevice *device)
} }
} }
validateDimension();
return true; return true;
} }
void Worksheet::validateDimension()
{
Q_D(Worksheet);
if (d->dimension.isValid() || d->cellTable.isEmpty())
return;
int firstRow = d->cellTable.firstKey();
int lastRow = d->cellTable.lastKey();
int firstCell = -1;
int lastCell = -1;
for (QMap<int, QMap<int, QSharedPointer<Cell> > >::const_iterator it = d->cellTable.begin(),
lim = d->cellTable.end(); it != lim; ++it)
{
if (it.value().isEmpty())
continue;
if (firstCell == -1 || it.value().firstKey() < firstCell)
firstCell = it.value().firstKey();
if (lastCell == -1 || it.value().lastKey() > lastCell)
lastCell = it.value().lastKey();
}
CellRange cr(firstRow, firstCell, lastRow, lastCell);
if (cr.isValid())
d->dimension = cr;
}
/*! /*!
* \internal * \internal
* Unit test can use this member to get sharedString object. * Unit test can use this member to get sharedString object.
+1
View File
@@ -153,6 +153,7 @@ private:
void saveToXmlFile(QIODevice *device) const; void saveToXmlFile(QIODevice *device) const;
bool loadFromXmlFile(QIODevice *device); bool loadFromXmlFile(QIODevice *device);
void validateDimension();
}; };
QT_END_NAMESPACE_XLSX QT_END_NAMESPACE_XLSX