Browse Source

Fixed review comments: Removed deprecated members. Replaced string arguments by CellRange.

master
Edwin van der Horst 11 years ago
parent
commit
cafef771a2
  1. 107
      src/xlsx/xlsxdocument.cpp
  2. 15
      src/xlsx/xlsxdocument.h
  3. 71
      src/xlsx/xlsxworksheet.cpp
  4. 10
      src/xlsx/xlsxworksheet.h

107
src/xlsx/xlsxdocument.cpp

@ -515,88 +515,68 @@ bool Document::unmergeCells(const CellRange &range)
}
/*!
Sets the column properties for all columns from \a colFirst to \a colLast with
the given \a width, \a format and \a hidden. Column
width measured as the number of characters of the maximum digit width of the
numbers 0, 1, 2, ..., 9 as rendered in the normal style's font.
\a colFirst and \a colLast are all 1-indexed.
Return false if failed.
Sets width in characters of a range of columns.
Returns true on success.
*/
bool Document::setColumn(int colFirst, int colLast, double width, const Format &format, bool hidden)
bool Document::setColumnWidth(const CellRange &range, double width)
{
if (Worksheet *sheet = currentWorksheet())
return sheet->setColumn(colFirst, colLast, width, format, hidden);
return sheet->setColumnWidth(range, width);
return false;
}
/*!
\overload
Sets column width and format for all columns from \a colFirst to \a colLast with
the given \a width and \a format. Column
\a width measured as the number of characters of the maximum digit width of the
numbers 0, 1, 2, ..., 9 as rendered in the normal style's font.
\a colFirst and \a colLast should be "A", "B", "C", ...
Sets format property of a range of columns.
Returns true on success.
*/
bool Document::setColumn(const QString &colFirst, const QString &colLast, double width, const Format &format, bool hidden)
{
if (Worksheet *sheet = currentWorksheet())
return sheet->setColumn(colFirst, colLast, width, format, hidden);
return false;
}
bool Document::setColumnWidth(const QString &column, double width)
{
return setColumnWidth(column,column,width);
}
bool Document::setColumnFormat(const QString &column, const Format &format)
{
return setColumnFormat(column,column,format);
}
bool Document::setColumnHidden(const QString &column, bool hidden)
{
return setColumnHidden(column,column,hidden);
}
bool Document::setColumnWidth(const QString &colFirst, const QString &colLast, double width)
{
if (Worksheet *sheet = currentWorksheet())
return sheet->setColumnWidth(colFirst, colLast, width);
return false;
}
bool Document::setColumnFormat(const QString &colFirst, const QString &colLast, const Format &format)
bool Document::setColumnFormat(const CellRange &range, const Format &format)
{
if (Worksheet *sheet = currentWorksheet())
return sheet->setColumnFormat(colFirst, colLast, format);
return sheet->setColumnFormat(range, format);
return false;
}
bool Document::setColumnHidden(const QString &colFirst, const QString &colLast, bool hidden)
/*!
Sets hidden property of a range of columns. Columns are 1-indexed.
Hidden columns are not visible.
Returns true on success.
*/
bool Document::setColumnHidden(const CellRange &range, bool hidden)
{
if (Worksheet *sheet = currentWorksheet())
return sheet->setColumnWidth(colFirst, colLast, hidden);
return sheet->setColumnWidth(range, hidden);
return false;
}
/*!
Sets width in characters of a range of columns. Columns are 1-indexed.
Returns true on success.
*/
bool Document::setColumnWidth(int column, double width)
{
return setColumnWidth(column,column,width);
}
/*!
Sets format property of a range of columns. Columns are 1-indexed.
*/
bool Document::setColumnFormat(int column, const Format &format)
{
return setColumnFormat(column,column,format);
}
/*!
Sets hidden property of a column. Columns are 1-indexed.
*/
bool Document::setColumnHidden(int column, bool hidden)
{
return setColumnHidden(column,column,hidden);
}
/*!
Sets width in characters of a range of columns. Columns are 1-indexed.
Returns true on success.
*/
bool Document::setColumnWidth(int colFirst, int colLast, double width)
{
if (Worksheet *sheet = currentWorksheet())
@ -604,6 +584,9 @@ bool Document::setColumnWidth(int colFirst, int colLast, double width)
return false;
}
/*!
Sets format property of a range of columns. Columns are 1-indexed.
*/
bool Document::setColumnFormat(int colFirst, int colLast, const Format &format)
{
if (Worksheet *sheet = currentWorksheet())
@ -611,6 +594,10 @@ bool Document::setColumnFormat(int colFirst, int colLast, const Format &format)
return false;
}
/*!
Sets hidden property of a range of columns. Columns are 1-indexed.
*/
bool Document::setColumnHidden(int colFirst, int colLast, bool hidden)
{
if (Worksheet *sheet = currentWorksheet())
@ -618,6 +605,9 @@ bool Document::setColumnHidden(int colFirst, int colLast, bool hidden)
return false;
}
/*!
Returns width of the column in characters of the normal font. Columns are 1-indexed.
*/
double Document::columnWidth(int column)
{
if (Worksheet *sheet = currentWorksheet())
@ -625,6 +615,9 @@ double Document::columnWidth(int column)
return 0.0;
}
/*!
Returns formatting of the column. Columns are 1-indexed.
*/
Format Document::columnFormat(int column)
{
if (Worksheet *sheet = currentWorksheet())
@ -632,23 +625,13 @@ Format Document::columnFormat(int column)
return Format();
}
bool Document::isColumnHidden(int column)
{
if (Worksheet *sheet = currentWorksheet())
return sheet->isColumnHidden(column);
return false;
}
/*!
Sets the properties of \a row with the given \a height, \a format and \a hidden.
\a row is 1-indexed.
Returns false if failed.
Returns true if column is hidden. Columns are 1-indexed.
*/
bool Document::setRow(int row, double height, const Format &format, bool hidden)
bool Document::isColumnHidden(int column)
{
if (Worksheet *sheet = currentWorksheet())
return sheet->setRow(row, row, height, format, hidden);
return sheet->isColumnHidden(column);
return false;
}

15
src/xlsx/xlsxdocument.h

@ -66,16 +66,9 @@ public:
bool unmergeCells(const CellRange &range);
bool unmergeCells(const QString &range);
Q_DECL_DEPRECATED
bool setColumn(int colFirst, int colLast, double width, const Format &format=Format(), bool hidden=false);
Q_DECL_DEPRECATED
bool setColumn(const QString &colFirst, const QString &colLast, double width, const Format &format=Format(), bool hidden=false);
bool setColumnWidth(const QString &column, double width);
bool setColumnFormat(const QString &column, const Format &format);
bool setColumnHidden(const QString &column, bool hidden);
bool setColumnWidth(const QString &colFirst, const QString &colLast, double width);
bool setColumnFormat(const QString &colFirst, const QString &colLast, const Format &format);
bool setColumnHidden(const QString &colFirst, const QString &colLast, bool hidden);
bool setColumnWidth(const CellRange &range, double width);
bool setColumnFormat(const CellRange &range, const Format &format);
bool setColumnHidden(const CellRange &range, bool hidden);
bool setColumnWidth(int column, double width);
bool setColumnFormat(int column, const Format &format);
bool setColumnHidden(int column, bool hidden);
@ -86,8 +79,6 @@ public:
Format columnFormat(int column);
bool isColumnHidden(int column);
Q_DECL_DEPRECATED
bool setRow(int row, double height, const Format &format=Format(), bool hidden=false);
bool setRowHeight(int row, double height);
bool setRowFormat(int row, const Format &format);
bool setRowHidden(int row, bool hidden);

71
src/xlsx/xlsxworksheet.cpp

@ -1564,59 +1564,14 @@ QList<int> WorksheetPrivate ::getColumnIndexes(int colFirst, int colLast)
}
/*!
Sets column \a width and \a format for all columns from \a colFirst to \a colLast. Column
width measured as the number of characters of the maximum digit width of the
numbers 0, 1, 2, ..., 9 as rendered in the normal style's font. If format
equals 0 then format is ignored. Both \a colFirst and \a colLast are all 1-indexed.
Hides the column if \a hidden is true.
Return true if success.
*/
bool Worksheet::setColumn(int colFirst, int colLast, double width, const Format &format, bool hidden)
{
Q_D(Worksheet);
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = d->getColumnInfoList(colFirst, colLast);
foreach(QSharedPointer<XlsxColumnInfo> columnInfo, columnInfoList) {
columnInfo->width = width;
columnInfo->format = format;
columnInfo->hidden = hidden;
}
if(columnInfoList.count() > 0) {
d->workbook->styles()->addXfFormat(format);
return true;
}
return false;
}
/*!
Sets column width and format for all columns from colFirst to colLast. Column
width measured as the number of characters of the maximum digit width of the
numbers 0, 1, 2, ..., 9 as rendered in the normal style's font. If format
equals 0 then format is ignored. \a colFirst and \a colLast should be "A", "B", "C", ...
*/
bool Worksheet::setColumn(const QString &colFirst, const QString &colLast, double width, const Format &format, bool hidden)
{
int col1 = xl_col_name_to_value(colFirst);
int col2 = xl_col_name_to_value(colLast);
if (col1 == -1 || col2 == -1)
return false;
return setColumn(col1, col2, width, format, hidden);
}
/*!
Sets width in characters of a range of columns. Columns can be specified as "A", "B" ... "Z".
Sets width in characters of a range of columns.
Returns true on success.
*/
bool Worksheet::setColumnWidth(const QString &colFirst, const QString &colLast, double width)
bool Worksheet::setColumnWidth(const CellRange &range, double width)
{
int col1 = xl_col_name_to_value(colFirst);
int col2 = xl_col_name_to_value(colLast);
if (col1 == -1 || col2 == -1)
int col1 = range.firstColumn();
int col2 = range.lastColumn();
if (col1 < 0|| col2 < 0)
return false;
return setColumnWidth(col1, col2, width);
@ -1626,11 +1581,11 @@ bool Worksheet::setColumnWidth(const QString &colFirst, const QString &colLast,
Sets format property of a range of columns. Columns are 1-indexed.
Returns true on success.
*/
bool Worksheet::setColumnFormat(const QString &colFirst, const QString &colLast, const Format &format)
bool Worksheet::setColumnFormat(const CellRange& range, const Format &format)
{
int col1 = xl_col_name_to_value(colFirst);
int col2 = xl_col_name_to_value(colLast);
if (col1 == -1 || col2 == -1)
int col1 = range.firstColumn();
int col2 = range.lastColumn();
if (col1 < 0|| col2 < 0)
return false;
return setColumnFormat(col1, col2, format);
@ -1641,11 +1596,11 @@ bool Worksheet::setColumnFormat(const QString &colFirst, const QString &colLast,
Hidden columns are not visible.
Returns true on success.
*/
bool Worksheet::setColumnHidden(const QString &colFirst, const QString &colLast, bool hidden)
bool Worksheet::setColumnHidden(const CellRange &range, bool hidden)
{
int col1 = xl_col_name_to_value(colFirst);
int col2 = xl_col_name_to_value(colLast);
if (col1 == -1 || col2 == -1)
int col1 = range.firstColumn();
int col2 = range.lastColumn();
if (col1 < 0|| col2 < 0)
return false;
return setColumnHidden(col1, col2, hidden);

10
src/xlsx/xlsxworksheet.h

@ -101,13 +101,9 @@ public:
bool unmergeCells(const CellRange &range);
QList<CellRange> mergedCells() const;
Q_DECL_DEPRECATED
bool setColumn(int colFirst, int colLast, double width, const Format &format=Format(), bool hidden=false);
Q_DECL_DEPRECATED
bool setColumn(const QString &colFirst, const QString &colLast, double width, const Format &format=Format(), bool hidden=false);
bool setColumnWidth(const QString &colFirst, const QString &colLast, double width);
bool setColumnFormat(const QString &colFirst, const QString &colLast, const Format &format);
bool setColumnHidden(const QString &colFirst, const QString &colLast, bool hidden);
bool setColumnWidth(const CellRange& range, double width);
bool setColumnFormat(const CellRange& range, const Format &format);
bool setColumnHidden(const CellRange& range, bool hidden);
bool setColumnWidth(int colFirst, int colLast, double width);
bool setColumnFormat(int colFirst, int colLast, const Format &format);
bool setColumnHidden(int colFirst, int colLast, bool hidden);

Loading…
Cancel
Save