Loading...
Searching...
No Matches
OdsDocReader Class Reference

`#include <odsdocreader.h>`

## Public Member Functions

| OdsDocReader (OdsDocHandlerInterface &handler)
virtual | ~OdsDocReader ()
void | parse (QFile &odsFile)
void | parse (QIODevice *p_inputstream)

## Private Member Functions

void | setInsideCell (const OdsCell &cell)
void | startInsideLine ()
void | startSheet (const QString &sheet_name)
void | endSheet ()
void | startLine ()
void | endLine ()
void | setCell (const OdsCell &cell)
void | endDocument ()

## Private Attributes

friend | QXmlStreamReaderContentXml
QuaZip * | _p_quaZip = nullptr
uint | _column_number
OdsDocHandlerInterface & | _handler

## Detailed Description

Definition at line 29 of file odsdocreader.h.

## Constructor & Destructor Documentation

## OdsDocReader()

OdsDocReader::OdsDocReader | ( | OdsDocHandlerInterface & | handler | ) |

creates an ODS reader with a reader handler

@Param OdsDocHandlerInterface & the interface to implement to read ODS files

Definition at line 28 of file odsdocreader.cpp.

: _handler(handler)
{
}
OdsDocReader::_handler
OdsDocHandlerInterface & _handler
Definition odsdocreader.h:69

References _handler.

## ~OdsDocReader()

OdsDocReader::~OdsDocReader | ( |  | ) |

virtual

Definition at line 32 of file odsdocreader.cpp.

{
qDebug();
if(_p_quaZip != nullptr)
{
if(_p_quaZip->isOpen())
{
_p_quaZip->close();
delete _p_quaZip;
_p_quaZip = nullptr;
}
}
qDebug();
}
OdsDocReader::_p_quaZip
QuaZip * _p_quaZip
Definition odsdocreader.h:65

References _p_quaZip.

## Member Function Documentation

## endDocument()

void OdsDocReader::endDocument | ( |  | ) |

private

Definition at line 182 of file odsdocreader.cpp.

{
_handler.endDocument();
}

References _handler.

Referenced by parse().

## endLine()

void OdsDocReader::endLine | ( |  | ) |

private

Definition at line 171 of file odsdocreader.cpp.

{
_handler.endLine();
}

References _handler.

## endSheet()

void OdsDocReader::endSheet | ( |  | ) |

private

Definition at line 159 of file odsdocreader.cpp.

{
_handler.endSheet();
}

References _handler.

## parse() [1/2]

void OdsDocReader::parse | ( | QFile & | odsFile | ) |

Definition at line 49 of file odsdocreader.cpp.

{
qDebug() << odsFile.fileName();
QFileInfo ods_file_info(odsFile.fileName());
if(!ods_file_info.exists())
{
throw OdsException(QObject::tr("ODS file %1 does not exists")
.arg(ods_file_info.absoluteFilePath()));
}
if(!ods_file_info.isReadable())
{
throw OdsException(QObject::tr("ODS file %1 is not readable")
.arg(ods_file_info.absoluteFilePath()));
}
if(!odsFile.open(QIODevice::ReadOnly))
{
throw OdsException(QObject::tr("Unable to read ODS file %1")
.arg(ods_file_info.absoluteFilePath()));
}
qDebug() << ods_file_info.absoluteFilePath();
parse(&odsFile);
odsFile.close();
}
OdsDocReader::parse
void parse(QFile &odsFile)
Definition odsdocreader.cpp:49

References parse().

Referenced by parse().

## parse() [2/2]

void OdsDocReader::parse | ( | QIODevice * | p_inputstream | ) |

Definition at line 74 of file odsdocreader.cpp.

{
qDebug();
_p_quaZip = new QuaZip(p_inputstream);
_p_quaZip->open(QuaZip::mdUnzip);
qDebug();
for(bool more = _p_quaZip->goToFirstFile(); more;
more = _p_quaZip->goToNextFile())
{
qDebug() << _p_quaZip->getCurrentFileName();
if(_p_quaZip->getCurrentFileName() == "content.xml")
{
QuaZipFile zip_file(_p_quaZip);
QXmlStreamReaderContentXml content_reader(*this);
zip_file.open(QIODevice::ReadOnly);
content_reader.setDevice(&zip_file);
content_reader.setNamespaceProcessing(true);
content_reader.read();
if(content_reader.error())
{
zip_file.close();
qDebug() << " error " << content_reader.errorString();
throw OdsException(QObject::tr("error reading ODS input file :\n")
.append(content_reader.errorString()));
}
qDebug() << " contentXml : DONE on file '"
<< _p_quaZip->getCurrentFileName() << "'";
zip_file.close();
}
}
if(_p_quaZip != nullptr)
{
if(_p_quaZip->isOpen())
{
_p_quaZip->close();
delete _p_quaZip;
_p_quaZip = nullptr;
}
}
this->endDocument();
}
OdsDocReader::endDocument
void endDocument()
Definition odsdocreader.cpp:182
OdsDocReader::QXmlStreamReaderContentXml
friend QXmlStreamReaderContentXml
Definition odsdocreader.h:31

References _p_quaZip, endDocument(), QXmlStreamReaderContentXml, and QXmlStreamReaderContentXml::read().

## setCell()

void OdsDocReader::setCell | ( | const OdsCell & | cell | ) |

private

Definition at line 177 of file odsdocreader.cpp.

{
_handler.setCell(cell);
}

References _handler.

Referenced by setInsideCell().

## setInsideCell()

void OdsDocReader::setInsideCell | ( | const OdsCell & | cell | ) |

private

Definition at line 130 of file odsdocreader.cpp.

{
_column_number++;
qDebug() << cell.getOfficeValueType() << " " << cell.toString();
if(cell.isDate())
{
qDebug() << " date " << cell.getDateTimeValue().toString(Qt::ISODate)
<< " " << cell.getDateTimeValue().date().day() << " "
<< cell.getDateTimeValue().date().month();
}
else if(cell.isString())
{
qDebug() << " string " << cell.getStringValue();
}
else if(cell.isDouble())
{
qDebug() << " double " << cell.getDoubleValue();
}
setCell(cell);
}
OdsCell::getDateTimeValue
const QDateTime & getDateTimeValue() const
Definition odscell.cpp:97
OdsCell::toString
const QString & toString() const
Definition odscell.cpp:83
OdsCell::getDoubleValue
double getDoubleValue() const
Definition odscell.cpp:123
OdsCell::isDate
bool isDate() const
Definition odscell.cpp:154
OdsCell::isString
bool isString() const
Definition odscell.cpp:168
OdsCell::isDouble
bool isDouble() const
Definition odscell.cpp:161
OdsCell::getStringValue
const QString & getStringValue() const
Definition odscell.cpp:110
OdsCell::getOfficeValueType
const QString & getOfficeValueType() const
Definition odscell.cpp:91
OdsDocReader::setCell
void setCell(const OdsCell &cell)
Definition odsdocreader.cpp:177
OdsDocReader::_column_number
uint _column_number
Definition odsdocreader.h:67

References _column_number, OdsCell::getDateTimeValue(), OdsCell::getDoubleValue(), OdsCell::getOfficeValueType(), OdsCell::getStringValue(), OdsCell::isDate(), OdsCell::isDouble(), OdsCell::isString(), setCell(), and OdsCell::toString().

## startInsideLine()

void OdsDocReader::startInsideLine | ( |  | ) |

private

Definition at line 123 of file odsdocreader.cpp.

{
_column_number = 0;
startLine();
}
OdsDocReader::startLine
void startLine()
Definition odsdocreader.cpp:165

References _column_number, and startLine().

## startLine()

void OdsDocReader::startLine | ( |  | ) |

private

Definition at line 165 of file odsdocreader.cpp.

{
_handler.startLine();
}

References _handler.

Referenced by startInsideLine().

## startSheet()

void OdsDocReader::startSheet | ( | const QString & | sheet_name | ) |

private

Definition at line 153 of file odsdocreader.cpp.

{
_handler.startSheet(sheet_name);
}

References _handler.

## Member Data Documentation

## _column_number

uint OdsDocReader::_column_number

private

Definition at line 67 of file odsdocreader.h.

Referenced by setInsideCell(), and startInsideLine().

## _handler

OdsDocHandlerInterface& OdsDocReader::_handler

private

Definition at line 69 of file odsdocreader.h.

Referenced by OdsDocReader(), endDocument(), endLine(), endSheet(), setCell(), startLine(), and startSheet().

## _p_quaZip

QuaZip* OdsDocReader::_p_quaZip = nullptr

private

Definition at line 65 of file odsdocreader.h.

Referenced by ~OdsDocReader(), and parse().

## QXmlStreamReaderContentXml

friend OdsDocReader::QXmlStreamReaderContentXml

private

Definition at line 31 of file odsdocreader.h.

Referenced by parse().

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

- odsstream/odsdocreader.h
- odsstream/odsdocreader.cpp