Loading...
Searching...
No Matches
OdsCell Class Reference

`#include <odscell.h>`

## Public Member Functions

| OdsCell ()
virtual | ~OdsCell ()
const QString & | toString () const
const QString & | getOfficeValueType () const
const QDateTime & | getDateTimeValue () const
const QString & | getStringValue () const
bool | getBooleanValue () const
double | getDoubleValue () const
bool | isBoolean () const
bool | isDate () const
bool | isDouble () const
bool | isString () const
bool | isEmpty () const

## Protected Member Functions

void | setOfficeValueType (const QString &type)
void | setDateValue (const QDateTime &date)
void | setValueString (const QString &value)
void | setValueDouble (double value_num)
void | setValueBoolean (bool value_bool)
void | setValueOfUndefinedType (const QString &value)

## Protected Attributes

QString | _string_value
QString | _office_value_type
QDateTime | _date_value
double | _double_value
bool | _bool_value
bool | _is_empty

## Private Attributes

friend | QXmlStreamReaderContentXml
friend | TsvReader

## Detailed Description

Definition at line 28 of file odscell.h.

## Constructor & Destructor Documentation

## OdsCell()

OdsCell::OdsCell | ( |  | ) |

Definition at line 24 of file odscell.cpp.

{
}

## ~OdsCell()

OdsCell::~OdsCell | ( |  | ) |

virtual

Definition at line 28 of file odscell.cpp.

{
}

## Member Function Documentation

## getBooleanValue()

bool OdsCell::getBooleanValue | ( |  | ) | const

Definition at line 136 of file odscell.cpp.

{
if(isBoolean())
{
return _bool_value;
}
else
{
throw OdsException(
QObject::tr("this cell is not a boolean :\n").append(toString()));
}
};
OdsCell::_bool_value
bool _bool_value
Definition odscell.h:61
OdsCell::toString
const QString & toString() const
Definition odscell.cpp:83
OdsCell::isBoolean
bool isBoolean() const
Definition odscell.cpp:181

References _bool_value, isBoolean(), and toString().

## getDateTimeValue()

const QDateTime & OdsCell::getDateTimeValue | ( |  | ) | const

Definition at line 97 of file odscell.cpp.

{
if(isDate())
{
return _date_value;
}
else
{
throw OdsException(
QObject::tr("this cell is not a date :\n").append(toString()));
}
};
OdsCell::_date_value
QDateTime _date_value
Definition odscell.h:59
OdsCell::isDate
bool isDate() const
Definition odscell.cpp:154

References _date_value, isDate(), and toString().

Referenced by OdsDocReader::setInsideCell().

## getDoubleValue()

double OdsCell::getDoubleValue | ( |  | ) | const

Definition at line 123 of file odscell.cpp.

{
if(isDouble())
{
return _double_value;
}
else
{
throw OdsException(
QObject::tr("this cell is not a double :\n").append(toString()));
}
};
OdsCell::isDouble
bool isDouble() const
Definition odscell.cpp:161
OdsCell::_double_value
double _double_value
Definition odscell.h:60

References _double_value, isDouble(), and toString().

Referenced by OdsDocReader::setInsideCell().

## getOfficeValueType()

const QString & OdsCell::getOfficeValueType | ( |  | ) | const

Definition at line 91 of file odscell.cpp.

{
return _office_value_type;
};
OdsCell::_office_value_type
QString _office_value_type
Definition odscell.h:58

References _office_value_type.

Referenced by OdsDocReader::setInsideCell().

## getStringValue()

const QString & OdsCell::getStringValue | ( |  | ) | const

Definition at line 110 of file odscell.cpp.

{
if(isString())
{
return _string_value;
}
else
{
throw OdsException(
QObject::tr("this cell is not a string :\n").append(toString()));
}
};
OdsCell::isString
bool isString() const
Definition odscell.cpp:168
OdsCell::_string_value
QString _string_value
Definition odscell.h:57

References _string_value, isString(), and toString().

Referenced by OdsDocReader::setInsideCell().

## isBoolean()

bool OdsCell::isBoolean | ( |  | ) | const

Definition at line 181 of file odscell.cpp.

{
if(_office_value_type == "boolean")
return true;
return false;
};

References _office_value_type.

Referenced by getBooleanValue(), and isString().

## isDate()

bool OdsCell::isDate | ( |  | ) | const

Definition at line 154 of file odscell.cpp.

{
if(_office_value_type == "date")
return true;
return false;
};

References _office_value_type.

Referenced by getDateTimeValue(), isString(), and OdsDocReader::setInsideCell().

## isDouble()

bool OdsCell::isDouble | ( |  | ) | const

Definition at line 161 of file odscell.cpp.

{
if(_office_value_type == "float")
return true;
return false;
};

References _office_value_type.

Referenced by getDoubleValue(), isString(), and OdsDocReader::setInsideCell().

## isEmpty()

bool OdsCell::isEmpty | ( |  | ) | const

Definition at line 149 of file odscell.cpp.

{
return _is_empty;
};
OdsCell::_is_empty
bool _is_empty
Definition odscell.h:62

References _is_empty.

Referenced by isString().

## isString()

bool OdsCell::isString | ( |  | ) | const

Definition at line 168 of file odscell.cpp.

{
if(isDate())
return false;
if(isDouble())
return false;
if(isBoolean())
return false;
if(isEmpty())
return false;
return true;
};
OdsCell::isEmpty
bool isEmpty() const
Definition odscell.cpp:149

References isBoolean(), isDate(), isDouble(), and isEmpty().

Referenced by getStringValue(), and OdsDocReader::setInsideCell().

## setDateValue()

void OdsCell::setDateValue | ( | const QDateTime & | date | ) |

protected

Definition at line 56 of file odscell.cpp.

{
// qDebug() << "setDateValue date.fromString " <<
// date.toString(Qt::ISODate);
_date_value = date;
_string_value = date.toString();
};

References _date_value, and _string_value.

## setOfficeValueType()

void OdsCell::setOfficeValueType | ( | const QString & | type | ) |

protected

Definition at line 33 of file odscell.cpp.

{
// float
// percentage
// currency
// date
// time
// boolean
// string
if(type.isEmpty())
{
_is_empty = true;
qDebug() << "empty cell";
_office_value_type = "";
}
else
{
_is_empty = false;
_office_value_type = type;
}
_string_value = "";
};

References _is_empty, _office_value_type, and _string_value.

Referenced by TsvReader::readCsvRow().

## setValueBoolean()

void OdsCell::setValueBoolean | ( | bool | value_bool | ) |

protected

Definition at line 76 of file odscell.cpp.

{
_bool_value = value_bool;
_string_value.setNum(value_bool);
};

References _bool_value, and _string_value.

## setValueDouble()

void OdsCell::setValueDouble | ( | double | value_num | ) |

protected

Definition at line 70 of file odscell.cpp.

{
_double_value = value_num;
_string_value.setNum(value_num);
};

References _double_value, and _string_value.

## setValueOfUndefinedType()

void OdsCell::setValueOfUndefinedType | ( | const QString & | value | ) |

protected

Definition at line 190 of file odscell.cpp.

{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
<< value;
_office_value_type = "string";
_string_value = value;
// float
// percentage
// currency
// date
// time
// boolean
// string
bool ok;
_double_value = _string_value.toDouble(&ok);
if(ok)
{
_office_value_type = "float";
return;
}
else
{
// test for french decimal separator
_double_value = QString(_string_value).replace(",", ".").toDouble(&ok);
if(ok)
{
_office_value_type = "float";
_string_value = QString(_string_value).replace(",", ".");
return;
}
}
if((_string_value == "T") || (_string_value == "TRUE") ||
(_string_value == "VRAI"))
{
_bool_value = true;
_office_value_type = "boolean";
return;
}
if((_string_value == "F") || (_string_value == "FALSE") ||
(_string_value == "FAUX"))
{
_bool_value = false;
_office_value_type = "boolean";
return;
}
QDateTime date = QDateTime::fromString(_string_value, "yyyy-MM-ddThh:mm:ss");
if(date.isValid())
{
_date_value = date;
_office_value_type = "date";
return;
}
date = QDateTime::fromString(_string_value, "yyyy-MM-dd");
if(date.isValid())
{
_date_value = date;
_office_value_type = "date";
return;
}
if(!_string_value.isEmpty())
{
_is_empty = false;
}
};

References _bool_value, _date_value, _double_value, _is_empty, _office_value_type, and _string_value.

Referenced by TsvReader::readCsvRow().

## setValueString()

void OdsCell::setValueString | ( | const QString & | value | ) |

protected

Definition at line 65 of file odscell.cpp.

{
_string_value = value;
};

References _string_value.

Referenced by TsvReader::readCsvRow().

## toString()

const QString & OdsCell::toString | ( |  | ) | const

Definition at line 83 of file odscell.cpp.

{
// if (isDate()) return QString (_date_value.toString());
// if (isDouble()) return QString(""+_double_value);
return _string_value;
};

References _string_value.

Referenced by getBooleanValue(), getDateTimeValue(), getDoubleValue(), getStringValue(), and OdsDocReader::setInsideCell().

## Member Data Documentation

## _bool_value

bool OdsCell::_bool_value

protected

Definition at line 61 of file odscell.h.

Referenced by getBooleanValue(), setValueBoolean(), and setValueOfUndefinedType().

## _date_value

QDateTime OdsCell::_date_value

protected

Definition at line 59 of file odscell.h.

Referenced by getDateTimeValue(), setDateValue(), and setValueOfUndefinedType().

## _double_value

double OdsCell::_double_value

protected

Definition at line 60 of file odscell.h.

Referenced by getDoubleValue(), setValueDouble(), and setValueOfUndefinedType().

## _is_empty

bool OdsCell::_is_empty

protected

Definition at line 62 of file odscell.h.

Referenced by isEmpty(), setOfficeValueType(), and setValueOfUndefinedType().

## _office_value_type

QString OdsCell::_office_value_type

protected

Definition at line 58 of file odscell.h.

Referenced by getOfficeValueType(), isBoolean(), isDate(), isDouble(), setOfficeValueType(), and setValueOfUndefinedType().

## _string_value

QString OdsCell::_string_value

protected

Definition at line 57 of file odscell.h.

Referenced by getStringValue(), setDateValue(), setOfficeValueType(), setValueBoolean(), setValueDouble(), setValueOfUndefinedType(), setValueString(), and toString().

## QXmlStreamReaderContentXml

friend OdsCell::QXmlStreamReaderContentXml

private

Definition at line 30 of file odscell.h.

## TsvReader

friend OdsCell::TsvReader

private

Definition at line 31 of file odscell.h.

The documentation for this class was generated from the following files:

- odsstream/reader/odscell.h
- odsstream/reader/odscell.cpp