|
|
|
@@ -1528,36 +1528,33 @@ void WorksheetPrivate::splitColsInfo(int colFirst, int colLast)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Worksheet::isColumnRangeValid(int colFirst, int colLast)
|
|
|
|
|
bool WorksheetPrivate::isColumnRangeValid(int colFirst, int colLast)
|
|
|
|
|
{
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
bool ignore_row = true;
|
|
|
|
|
bool ignore_col = false;
|
|
|
|
|
|
|
|
|
|
if (colFirst > colLast)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (d->checkDimensions(0, colLast, ignore_row, ignore_col))
|
|
|
|
|
if (checkDimensions(0, colLast, ignore_row, ignore_col))
|
|
|
|
|
return false;
|
|
|
|
|
if (d->checkDimensions(0, colFirst, ignore_row, ignore_col))
|
|
|
|
|
if (checkDimensions(0, colFirst, ignore_row, ignore_col))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<int> Worksheet::getColumnIndexes(int colFirst, int colLast)
|
|
|
|
|
QList<int> WorksheetPrivate ::getColumnIndexes(int colFirst, int colLast)
|
|
|
|
|
{
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
|
|
|
|
|
d->splitColsInfo(colFirst, colLast);
|
|
|
|
|
splitColsInfo(colFirst, colLast);
|
|
|
|
|
|
|
|
|
|
QList<int> nodes;
|
|
|
|
|
nodes.append(colFirst);
|
|
|
|
|
for (int col = colFirst; col <= colLast; ++col) {
|
|
|
|
|
if (d->colsInfo.contains(col)) {
|
|
|
|
|
if (colsInfo.contains(col)) {
|
|
|
|
|
if (nodes.last() != col)
|
|
|
|
|
nodes.append(col);
|
|
|
|
|
int nextCol = d->colsInfo[col]->lastColumn + 1;
|
|
|
|
|
int nextCol = colsInfo[col]->lastColumn + 1;
|
|
|
|
|
if (nextCol <= colLast)
|
|
|
|
|
nodes.append(nextCol);
|
|
|
|
|
}
|
|
|
|
@@ -1579,7 +1576,7 @@ bool Worksheet::setColumn(int colFirst, int colLast, double width, const Format
|
|
|
|
|
{
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = getColumnInfoList(colFirst, colLast);
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = d->getColumnInfoList(colFirst, colLast);
|
|
|
|
|
foreach(QSharedPointer<XlsxColumnInfo> columnInfo, columnInfoList) {
|
|
|
|
|
columnInfo->width = width;
|
|
|
|
|
columnInfo->format = format;
|
|
|
|
@@ -1660,7 +1657,9 @@ bool Worksheet::setColumnHidden(const QString &colFirst, const QString &colLast,
|
|
|
|
|
*/
|
|
|
|
|
bool Worksheet::setColumnWidth(int colFirst, int colLast, double width)
|
|
|
|
|
{
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = getColumnInfoList(colFirst, colLast);
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = d->getColumnInfoList(colFirst, colLast);
|
|
|
|
|
foreach(QSharedPointer<XlsxColumnInfo> columnInfo, columnInfoList) {
|
|
|
|
|
columnInfo->width = width;
|
|
|
|
|
}
|
|
|
|
@@ -1675,7 +1674,7 @@ bool Worksheet::setColumnFormat(int colFirst, int colLast, const Format &format)
|
|
|
|
|
{
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = getColumnInfoList(colFirst, colLast);
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = d->getColumnInfoList(colFirst, colLast);
|
|
|
|
|
foreach(QSharedPointer<XlsxColumnInfo> columnInfo, columnInfoList) {
|
|
|
|
|
columnInfo->format = format;
|
|
|
|
|
}
|
|
|
|
@@ -1693,7 +1692,9 @@ bool Worksheet::setColumnFormat(int colFirst, int colLast, const Format &format)
|
|
|
|
|
*/
|
|
|
|
|
bool Worksheet::setColumnHidden(int colFirst, int colLast, bool hidden)
|
|
|
|
|
{
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = getColumnInfoList(colFirst, colLast);
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = d->getColumnInfoList(colFirst, colLast);
|
|
|
|
|
foreach(QSharedPointer<XlsxColumnInfo> columnInfo, columnInfoList) {
|
|
|
|
|
columnInfo->hidden = hidden;
|
|
|
|
|
}
|
|
|
|
@@ -1708,7 +1709,7 @@ double Worksheet::columnWidth(int column)
|
|
|
|
|
{
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = getColumnInfoList(column, column);
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = d->getColumnInfoList(column, column);
|
|
|
|
|
if (columnInfoList.count() == 1) {
|
|
|
|
|
return columnInfoList.at(0)->width ;
|
|
|
|
|
}
|
|
|
|
@@ -1721,7 +1722,9 @@ double Worksheet::columnWidth(int column)
|
|
|
|
|
*/
|
|
|
|
|
Format Worksheet::columnFormat(int column)
|
|
|
|
|
{
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = getColumnInfoList(column, column);
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = d->getColumnInfoList(column, column);
|
|
|
|
|
if (columnInfoList.count() == 1) {
|
|
|
|
|
return columnInfoList.at(0)->format;
|
|
|
|
|
}
|
|
|
|
@@ -1734,7 +1737,9 @@ Format Worksheet::columnFormat(int column)
|
|
|
|
|
*/
|
|
|
|
|
bool Worksheet::isColumnHidden(int column)
|
|
|
|
|
{
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = getColumnInfoList(column, column);
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = d->getColumnInfoList(column, column);
|
|
|
|
|
if (columnInfoList.count() == 1) {
|
|
|
|
|
return columnInfoList.at(0)->hidden;
|
|
|
|
|
}
|
|
|
|
@@ -1752,7 +1757,8 @@ bool Worksheet::isColumnHidden(int column)
|
|
|
|
|
bool Worksheet::setRow(int rowFirst,int rowLast, double height, const Format &format, bool hidden)
|
|
|
|
|
{
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList = getRowInfoList(rowFirst,rowLast);
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList = d->getRowInfoList(rowFirst,rowLast);
|
|
|
|
|
|
|
|
|
|
foreach(QSharedPointer<XlsxRowInfo> rowInfo, rowInfoList) {
|
|
|
|
|
rowInfo->height = height;
|
|
|
|
@@ -1773,7 +1779,9 @@ bool Worksheet::setRow(int rowFirst,int rowLast, double height, const Format &fo
|
|
|
|
|
*/
|
|
|
|
|
bool Worksheet::setRowHeight(int rowFirst,int rowLast, double height)
|
|
|
|
|
{
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList = getRowInfoList(rowFirst,rowLast);
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList = d->getRowInfoList(rowFirst,rowLast);
|
|
|
|
|
|
|
|
|
|
foreach(QSharedPointer<XlsxRowInfo> rowInfo, rowInfoList) {
|
|
|
|
|
rowInfo->height = height;
|
|
|
|
@@ -1793,7 +1801,7 @@ bool Worksheet::setRowFormat(int rowFirst,int rowLast, const Format &format)
|
|
|
|
|
{
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList = getRowInfoList(rowFirst,rowLast);
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList = d->getRowInfoList(rowFirst,rowLast);
|
|
|
|
|
|
|
|
|
|
foreach(QSharedPointer<XlsxRowInfo> rowInfo, rowInfoList) {
|
|
|
|
|
rowInfo->format = format;
|
|
|
|
@@ -1811,7 +1819,9 @@ bool Worksheet::setRowFormat(int rowFirst,int rowLast, const Format &format)
|
|
|
|
|
*/
|
|
|
|
|
bool Worksheet::setRowHidden(int rowFirst,int rowLast, bool hidden)
|
|
|
|
|
{
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList = getRowInfoList(rowFirst,rowLast);
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList = d->getRowInfoList(rowFirst,rowLast);
|
|
|
|
|
|
|
|
|
|
foreach(QSharedPointer<XlsxRowInfo> rowInfo, rowInfoList) {
|
|
|
|
|
rowInfo->hidden = hidden;
|
|
|
|
@@ -1862,54 +1872,6 @@ bool Worksheet::isRowHidden(int row)
|
|
|
|
|
return d->rowsInfo[row]->hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > Worksheet::getColumnInfoList(int colFirst, int colLast)
|
|
|
|
|
{
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnsInfoList;
|
|
|
|
|
if(isColumnRangeValid(colFirst,colLast))
|
|
|
|
|
{
|
|
|
|
|
QList<int> nodes = getColumnIndexes(colFirst, colLast);
|
|
|
|
|
|
|
|
|
|
for (int idx = 0; idx < nodes.size(); ++idx) {
|
|
|
|
|
int colStart = nodes[idx];
|
|
|
|
|
if (d->colsInfo.contains(colStart)) {
|
|
|
|
|
QSharedPointer<XlsxColumnInfo> info = d->colsInfo[colStart];
|
|
|
|
|
columnsInfoList.append(info);
|
|
|
|
|
} else {
|
|
|
|
|
int colEnd = (idx == nodes.size() - 1) ? colLast : nodes[idx+1] - 1;
|
|
|
|
|
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(colStart, colEnd));
|
|
|
|
|
d->colsInfo.insert(colFirst, info);
|
|
|
|
|
columnsInfoList.append(info);
|
|
|
|
|
for (int c = colStart; c <= colEnd; ++c)
|
|
|
|
|
d->colsInfoHelper[c] = info;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return columnsInfoList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > Worksheet::getRowInfoList(int rowFirst, int rowLast)
|
|
|
|
|
{
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList;
|
|
|
|
|
|
|
|
|
|
int min_col = d->dimension.firstColumn() < 0 ? 0 : d->dimension.firstColumn();
|
|
|
|
|
|
|
|
|
|
for(int row = rowFirst; row <= rowLast; ++row) {
|
|
|
|
|
if (d->checkDimensions(row, min_col, false, true))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
QSharedPointer<XlsxRowInfo> rowInfo;
|
|
|
|
|
if ((d->rowsInfo[row]).isNull()){
|
|
|
|
|
d->rowsInfo[row] = QSharedPointer<XlsxRowInfo>(new XlsxRowInfo());
|
|
|
|
|
}
|
|
|
|
|
rowInfoList.append(d->rowsInfo[row]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rowInfoList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Groups rows from \a rowFirst to \a rowLast with the given \a collapsed.
|
|
|
|
|
|
|
|
|
@@ -2362,17 +2324,17 @@ void WorksheetPrivate::loadXmlSheetFormatProps(QXmlStreamReader &reader)
|
|
|
|
|
//Retain default values
|
|
|
|
|
foreach (QXmlStreamAttribute attrib, attributes) {
|
|
|
|
|
if(attrib.name() == QLatin1String("baseColWidth") ) {
|
|
|
|
|
formatProps.baseColWidth = attrib.value().toInt();
|
|
|
|
|
formatProps.baseColWidth = attrib.value().toString().toInt();
|
|
|
|
|
} else if(attrib.name() == QLatin1String("customHeight")) {
|
|
|
|
|
formatProps.customHeight = attrib.value() == QLatin1String("1");
|
|
|
|
|
} else if(attrib.name() == QLatin1String("defaultColWidth")) {
|
|
|
|
|
formatProps.defaultColWidth = attrib.value().toDouble();
|
|
|
|
|
formatProps.defaultColWidth = attrib.value().toString().toDouble();
|
|
|
|
|
} else if(attrib.name() == QLatin1String("defaultRowHeight")) {
|
|
|
|
|
formatProps.defaultRowHeight = attrib.value().toDouble();
|
|
|
|
|
formatProps.defaultRowHeight = attrib.value().toString().toDouble();
|
|
|
|
|
} else if(attrib.name() == QLatin1String("outlineLevelCol")) {
|
|
|
|
|
formatProps.outlineLevelCol = attrib.value().toInt();
|
|
|
|
|
formatProps.outlineLevelCol = attrib.value().toString().toInt();
|
|
|
|
|
} else if(attrib.name() == QLatin1String("outlineLevelRow")) {
|
|
|
|
|
formatProps.outlineLevelRow = attrib.value().toInt();
|
|
|
|
|
formatProps.outlineLevelRow = attrib.value().toString().toInt();
|
|
|
|
|
} else if(attrib.name() == QLatin1String("thickBottom")) {
|
|
|
|
|
formatProps.thickBottom = attrib.value() == QLatin1String("1");
|
|
|
|
|
} else if(attrib.name() == QLatin1String("thickTop")) {
|
|
|
|
@@ -2424,6 +2386,52 @@ void WorksheetPrivate::loadXmlHyperlinks(QXmlStreamReader &reader)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > WorksheetPrivate::getColumnInfoList(int colFirst, int colLast)
|
|
|
|
|
{
|
|
|
|
|
QList <QSharedPointer<XlsxColumnInfo> > columnsInfoList;
|
|
|
|
|
if(isColumnRangeValid(colFirst,colLast))
|
|
|
|
|
{
|
|
|
|
|
QList<int> nodes = getColumnIndexes(colFirst, colLast);
|
|
|
|
|
|
|
|
|
|
for (int idx = 0; idx < nodes.size(); ++idx) {
|
|
|
|
|
int colStart = nodes[idx];
|
|
|
|
|
if (colsInfo.contains(colStart)) {
|
|
|
|
|
QSharedPointer<XlsxColumnInfo> info = colsInfo[colStart];
|
|
|
|
|
columnsInfoList.append(info);
|
|
|
|
|
} else {
|
|
|
|
|
int colEnd = (idx == nodes.size() - 1) ? colLast : nodes[idx+1] - 1;
|
|
|
|
|
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(colStart, colEnd));
|
|
|
|
|
colsInfo.insert(colFirst, info);
|
|
|
|
|
columnsInfoList.append(info);
|
|
|
|
|
for (int c = colStart; c <= colEnd; ++c)
|
|
|
|
|
colsInfoHelper[c] = info;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return columnsInfoList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > WorksheetPrivate::getRowInfoList(int rowFirst, int rowLast)
|
|
|
|
|
{
|
|
|
|
|
QList <QSharedPointer<XlsxRowInfo> > rowInfoList;
|
|
|
|
|
|
|
|
|
|
int min_col = dimension.firstColumn() < 0 ? 0 : dimension.firstColumn();
|
|
|
|
|
|
|
|
|
|
for(int row = rowFirst; row <= rowLast; ++row) {
|
|
|
|
|
if (checkDimensions(row, min_col, false, true))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
QSharedPointer<XlsxRowInfo> rowInfo;
|
|
|
|
|
if ((rowsInfo[row]).isNull()){
|
|
|
|
|
rowsInfo[row] = QSharedPointer<XlsxRowInfo>(new XlsxRowInfo());
|
|
|
|
|
}
|
|
|
|
|
rowInfoList.append(rowsInfo[row]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rowInfoList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Worksheet::loadFromXmlFile(QIODevice *device)
|
|
|
|
|
{
|
|
|
|
|
Q_D(Worksheet);
|
|
|
|
|