Skip to content

Commit

Permalink
Update QtXlsx from github.com/VSRonin/QtXlsxWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultMndr committed Jul 3, 2019
1 parent 322cb9f commit 1df4383
Show file tree
Hide file tree
Showing 31 changed files with 1,534 additions and 434 deletions.
7 changes: 5 additions & 2 deletions QtXlsx/xlsx/qtxlsx.pri
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ HEADERS += $$PWD/xlsxdocpropscore_p.h \
$$PWD/xlsxabstractooxmlfile_p.h \
$$PWD/xlsxchart.h \
$$PWD/xlsxchart_p.h \
$$PWD/xlsxsimpleooxmlfile_p.h
$$PWD/xlsxsimpleooxmlfile_p.h \
$$PWD/xlsxcellformula.h \
$$PWD/xlsxcellformula_p.h

SOURCES += $$PWD/xlsxdocpropscore.cpp \
$$PWD/xlsxdocpropsapp.cpp \
Expand Down Expand Up @@ -77,5 +79,6 @@ SOURCES += $$PWD/xlsxdocpropscore.cpp \
$$PWD/xlsxmediafile.cpp \
$$PWD/xlsxabstractooxmlfile.cpp \
$$PWD/xlsxchart.cpp \
$$PWD/xlsxsimpleooxmlfile.cpp
$$PWD/xlsxsimpleooxmlfile.cpp \
$$PWD/xlsxcellformula.cpp

74 changes: 65 additions & 9 deletions QtXlsx/xlsx/xlsxabstractsheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ QT_BEGIN_NAMESPACE_XLSX
AbstractSheetPrivate::AbstractSheetPrivate(AbstractSheet *p, AbstractSheet::CreateFlag flag)
: AbstractOOXmlFilePrivate(p, flag)
{
hidden = false;
type = AbstractSheet::ST_WorkSheet;
sheetState = AbstractSheet::SS_Visible;
}

AbstractSheetPrivate::~AbstractSheetPrivate()
Expand All @@ -48,11 +48,26 @@ AbstractSheetPrivate::~AbstractSheetPrivate()
/*!
\enum AbstractSheet::SheetType
\value ST_WorkSheet,
\value ST_ChartSheet,
\omitvalue ST_DialogSheet,
\value ST_WorkSheet
\value ST_ChartSheet
\omitvalue ST_DialogSheet
\omitvalue ST_MacroSheet
*/
*/

/*!
\enum AbstractSheet::SheetState
\value SS_Visible
\value SS_Hidden
\value SS_VeryHidden User cann't make a veryHidden sheet visible in normal way.
*/

/*!
\fn AbstractSheet::copy(const QString &distName, int distId) const
Copies the current sheet to a sheet called \a distName with \a distId.
Returns the new sheet.
*/

/*!
* \internal
Expand Down Expand Up @@ -103,21 +118,62 @@ void AbstractSheet::setSheetType(SheetType type)
}

/*!
* \internal
* Returns the state of the sheet.
*
* \sa isHidden(), isVisible(), setSheetState()
*/
AbstractSheet::SheetState AbstractSheet::sheetState() const
{
Q_D(const AbstractSheet);
return d->sheetState;
}

/*!
* Set the state of the sheet to \a state.
*/
void AbstractSheet::setSheetState(SheetState state)
{
Q_D(AbstractSheet);
d->sheetState = state;
}

/*!
* Returns true if the sheet is not visible, otherwise false will be returned.
*
* \sa sheetState(), setHidden()
*/
bool AbstractSheet::isHidden() const
{
Q_D(const AbstractSheet);
return d->hidden;
return d->sheetState != SS_Visible;
}

/*!
* \internal
* Returns true if the sheet is visible.
*/
bool AbstractSheet::isVisible() const
{
return !isHidden();
}

/*!
* Make the sheet hiden or visible based on \a hidden.
*/
void AbstractSheet::setHidden(bool hidden)
{
Q_D(AbstractSheet);
d->hidden = hidden;
if (hidden == isHidden())
return;

d->sheetState = hidden ? SS_Hidden : SS_Visible;
}

/*!
* Convenience function, equivalent to setHidden(! \a visible).
*/
void AbstractSheet::setVisible(bool visible)
{
setHidden(!visible);
}

/*!
Expand Down
18 changes: 14 additions & 4 deletions QtXlsx/xlsx/xlsxabstractsheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,35 @@ class Q_XLSX_EXPORT AbstractSheet : public AbstractOOXmlFile
{
Q_DECLARE_PRIVATE(AbstractSheet)
public:
enum SheetType
{
enum SheetType {
ST_WorkSheet,
ST_ChartSheet,
ST_DialogSheet,
ST_MacroSheet
};

SheetType sheetType() const;
enum SheetState {
SS_Visible,
SS_Hidden,
SS_VeryHidden
};

QString sheetName() const;
SheetType sheetType() const;
SheetState sheetState() const;
void setSheetState(SheetState ss);
bool isHidden() const;
bool isVisible() const;
void setHidden(bool hidden);
void setVisible(bool visible);

Workbook *workbook() const;

protected:
friend class Workbook;
AbstractSheet(const QString &sheetName, int sheetId, Workbook *book, AbstractSheetPrivate *d);
virtual AbstractSheet *copy(const QString &distName, int distId) const = 0;
void setSheetName(const QString &sheetName);
void setHidden(bool hidden);
void setSheetType(SheetType type);
int sheetId() const;

Expand Down
2 changes: 1 addition & 1 deletion QtXlsx/xlsx/xlsxabstractsheet_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class XLSX_AUTOTEST_EXPORT AbstractSheetPrivate : public AbstractOOXmlFilePrivat

QString name;
int id;
bool hidden;
AbstractSheet::SheetState sheetState;
AbstractSheet::SheetType type;
};

Expand Down
46 changes: 26 additions & 20 deletions QtXlsx/xlsx/xlsxcell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ CellPrivate::CellPrivate(Cell *p) :
}

CellPrivate::CellPrivate(const CellPrivate * const cp)
: value(cp->value), formula(cp->formula), dataType(cp->dataType)
, format(cp->format), range(cp->range), richString(cp->richString)
, parent(cp->parent)
: value(cp->value), formula(cp->formula), cellType(cp->cellType)
, format(cp->format), richString(cp->richString), parent(cp->parent)
{

}
Expand All @@ -55,27 +54,24 @@ CellPrivate::CellPrivate(const CellPrivate * const cp)
*/

/*!
\enum Cell::DataType
\value Blank,
\value String,
\value Numeric,
\value Formula,
\value Boolean,
\value Error,
\value InlineString,
\value ArrayFormula
\enum Cell::CellType
\value BooleanType Boolean type
\value NumberType Number type, can be blank or used with forumula
\value ErrorType Error type
\value SharedStringType Shared string type
\value StringType String type, can be used with forumula
\value InlineStringType Inline string type
*/

/*!
* \internal
* Created by Worksheet only.
*/
Cell::Cell(const QVariant &data, DataType type, const Format &format, Worksheet *parent) :
Cell::Cell(const QVariant &data, CellType type, const Format &format, Worksheet *parent) :
d_ptr(new CellPrivate(this))
{
d_ptr->value = data;
d_ptr->dataType = type;
d_ptr->cellType = type;
d_ptr->format = format;
d_ptr->parent = parent;
}
Expand All @@ -100,10 +96,10 @@ Cell::~Cell()
/*!
* Return the dataType of this Cell
*/
Cell::DataType Cell::dataType() const
Cell::CellType Cell::cellType() const
{
Q_D(const Cell);
return d->dataType;
return d->cellType;
}

/*!
Expand All @@ -124,10 +120,19 @@ Format Cell::format() const
return d->format;
}

/*!
* Returns true if the cell has one formula.
*/
bool Cell::hasFormula() const
{
Q_D(const Cell);
return d->formula.isValid();
}

/*!
* Return the formula contents if the dataType is Formula
*/
QString Cell::formula() const
CellFormula Cell::formula() const
{
Q_D(const Cell);
return d->formula;
Expand All @@ -139,7 +144,7 @@ QString Cell::formula() const
bool Cell::isDateTime() const
{
Q_D(const Cell);
if (d->dataType == Numeric && d->value.toDouble() >=0
if (d->cellType == NumberType && d->value.toDouble() >=0
&& d->format.isValid() && d->format.isDateTimeFormat()) {
return true;
}
Expand All @@ -163,7 +168,8 @@ QDateTime Cell::dateTime() const
bool Cell::isRichString() const
{
Q_D(const Cell);
if (d->dataType != String && d->dataType != InlineString)
if (d->cellType != SharedStringType && d->cellType != InlineStringType
&& d->cellType != StringType)
return false;

return d->richString.isRichString();
Expand Down
25 changes: 13 additions & 12 deletions QtXlsx/xlsx/xlsxcell.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,29 @@ QT_BEGIN_NAMESPACE_XLSX

class Worksheet;
class Format;
class CellFormula;
class CellPrivate;
class WorksheetPrivate;

class Q_XLSX_EXPORT Cell
{
Q_DECLARE_PRIVATE(Cell)
public:
enum DataType {
Blank,
String,
Numeric,
Formula,
Boolean,
Error,
InlineString,
ArrayFormula
enum CellType {
BooleanType, //t="b"
NumberType, //t="n" (default)
ErrorType, //t="e"
SharedStringType, //t="s"
StringType, //t="str"
InlineStringType //t="inlineStr"
};

DataType dataType() const;
CellType cellType() const;
QVariant value() const;
Format format() const;
QString formula() const;

bool hasFormula() const;
CellFormula formula() const;

bool isDateTime() const;
QDateTime dateTime() const;
Expand All @@ -66,7 +67,7 @@ class Q_XLSX_EXPORT Cell
friend class Worksheet;
friend class WorksheetPrivate;

Cell(const QVariant &data=QVariant(), DataType type=Blank, const Format &format=Format(), Worksheet *parent=0);
Cell(const QVariant &data=QVariant(), CellType type=NumberType, const Format &format=Format(), Worksheet *parent = Q_NULLPTR);
Cell(const Cell * const cell);
CellPrivate * const d_ptr;
};
Expand Down
6 changes: 3 additions & 3 deletions QtXlsx/xlsx/xlsxcell_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "xlsxcell.h"
#include "xlsxcellrange.h"
#include "xlsxrichstring.h"
#include "xlsxcellformula.h"
#include <QList>
#include <QSharedPointer>

Expand All @@ -53,10 +54,9 @@ class CellPrivate
CellPrivate(const CellPrivate * const cp);

QVariant value;
QString formula;
Cell::DataType dataType;
CellFormula formula;
Cell::CellType cellType;
Format format;
CellRange range; //used for arrayFormula

RichString richString;

Expand Down
Loading

0 comments on commit 1df4383

Please sign in to comment.