Browse Source

Don't use QMap::firstKey() and lastKey(), which introduced in Qt5.2

master
Debao Zhang 10 years ago
parent
commit
4b1aa2bb27
  1. 37
      src/xlsx/xlsxworksheet.cpp
  2. 1
      src/xlsx/xlsxworksheet.h
  3. 1
      src/xlsx/xlsxworksheet_p.h

37
src/xlsx/xlsxworksheet.cpp

@ -2297,39 +2297,38 @@ bool Worksheet::loadFromXmlFile(QIODevice *device)
} }
} }
validateDimension(); d->validateDimension();
return true; return true;
} }
void Worksheet::validateDimension() /*
* Documents imported from Google Docs does not contain dimension data.
*/
void WorksheetPrivate::validateDimension()
{ {
Q_D(Worksheet); if (dimension.isValid() || cellTable.isEmpty())
if (d->dimension.isValid() || d->cellTable.isEmpty())
return; return;
int firstRow = d->cellTable.firstKey(); int firstRow = cellTable.constBegin().key();
int lastRow = d->cellTable.lastKey(); int lastRow = (cellTable.constEnd()-1).key();
int firstCell = -1; int firstColumn = -1;
int lastCell = -1; int lastColumn = -1;
for (QMap<int, QMap<int, QSharedPointer<Cell> > >::const_iterator it = d->cellTable.begin(), for (QMap<int, QMap<int, QSharedPointer<Cell> > >::const_iterator it = cellTable.begin(); it != cellTable.end(); ++it)
lim = d->cellTable.end(); it != lim; ++it)
{ {
if (it.value().isEmpty()) Q_ASSERT(!it.value().isEmpty());
continue;
if (firstCell == -1 || it.value().firstKey() < firstCell) if (firstColumn == -1 || it.value().constBegin().key() < firstColumn)
firstCell = it.value().firstKey(); firstColumn = it.value().constBegin().key();
if (lastCell == -1 || it.value().lastKey() > lastCell) if (lastColumn == -1 || (it.value().constEnd()-1).key() > lastColumn)
lastCell = it.value().lastKey(); lastColumn = (it.value().constEnd()-1).key();
} }
CellRange cr(firstRow, firstCell, lastRow, lastCell); CellRange cr(firstRow, firstColumn, lastRow, lastColumn);
if (cr.isValid()) if (cr.isValid())
d->dimension = cr; dimension = cr;
} }
/*! /*!

1
src/xlsx/xlsxworksheet.h

@ -152,7 +152,6 @@ 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

1
src/xlsx/xlsxworksheet_p.h

@ -160,6 +160,7 @@ public:
QString generateDimensionString() const; QString generateDimensionString() const;
void calculateSpans() const; void calculateSpans() const;
void splitColsInfo(int colFirst, int colLast); void splitColsInfo(int colFirst, int colLast);
void validateDimension();
void saveXmlSheetData(QXmlStreamWriter &writer) const; void saveXmlSheetData(QXmlStreamWriter &writer) const;
void saveXmlCellData(QXmlStreamWriter &writer, int row, int col, QSharedPointer<Cell> cell) const; void saveXmlCellData(QXmlStreamWriter &writer, int row, int col, QSharedPointer<Cell> cell) const;

Loading…
Cancel
Save