Loading...
Searching...
No Matches
QXmlStreamReaderContentXml Class Reference

`#include <qxmlstreamreadercontentxml.h>`

Inheritance diagram for QXmlStreamReaderContentXml:

## Public Member Functions

| QXmlStreamReaderContentXml (OdsDocReader &ods_reader)
virtual | ~QXmlStreamReaderContentXml ()
bool | read ()

## Private Member Functions

bool | readTable ()
bool | readTableRow ()
bool | readTableLine ()
bool | readCellContent ()
bool | readTextP ()

## Private Attributes

OdsDocReader & | m_odsReader
OdsCell | m_currentCell
uint | m_numberColumnsRepeated

## Detailed Description

Todo
  write docs

Definition at line 37 of file qxmlstreamreadercontentxml.h.

## Constructor & Destructor Documentation

## QXmlStreamReaderContentXml()

QXmlStreamReaderContentXml::QXmlStreamReaderContentXml | ( | OdsDocReader & | ods_reader | ) |

Todo
  write docs

Definition at line 31 of file qxmlstreamreadercontentxml.cpp.

: m_odsReader(ods_reader)
{
}
QXmlStreamReaderContentXml::m_odsReader
OdsDocReader & m_odsReader
Definition qxmlstreamreadercontentxml.h:60

References m_odsReader.

## ~QXmlStreamReaderContentXml()

QXmlStreamReaderContentXml::~QXmlStreamReaderContentXml | ( |  | ) |

virtual

Todo
  write docs

Definition at line 36 of file qxmlstreamreadercontentxml.cpp.

{
}

## Member Function Documentation

## read()

bool QXmlStreamReaderContentXml::read | ( |  | ) |

Definition at line 41 of file qxmlstreamreadercontentxml.cpp.

{
if(readNextStartElement())
{
qDebug() << qualifiedName();
/*
* <office:document-content
* xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
* xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
* xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
* xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
* xmlns:db="urn:oasis:names:tc:opendocument:xmlns:database:1.0"
* xmlns:dc="http://purl.org/dc/elements/1.1/"
* xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
* xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
* xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
* xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
* xmlns:grddl="http://www.w3.org/2003/g/data-view#"
* xmlns:math="http://www.w3.org/1998/Math/MathML"
* xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
* xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
* xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
* xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
* xmlns:ooo="http://openoffice.org/2004/office"
* xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
* xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
* xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
* xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
* xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
* xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
* xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
* xmlns:xforms="http://www.w3.org/2002/xforms"
* xmlns:xhtml="http://www.w3.org/1999/xhtml"
* xmlns:xlink="http://www.w3.org/1999/xlink"
* xmlns:xsd="http://www.w3.org/2001/XMLSchema"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* office:version="1.2">
* */
if(qualifiedName().toString() == "office:document-content")
{
//<office:body>
//<note type="input" label="output, histogram column width">30</note>
while(readNextStartElement())
{
qDebug() << qualifiedName();
if(qualifiedName().toString() == "office:body")
{
//<office:spreadsheet>
while(readNextStartElement())
{
qDebug() << qualifiedName();
if(qualifiedName().toString() == "office:spreadsheet")
{
//<table:table table:name="classeur"
// table:style-name="ta1" table:print="false">
qDebug() << qualifiedName();
readTable();
}
else
{
skipCurrentElement();
}
}
}
else
{
skipCurrentElement();
}
}
}
else
{
raiseError(QObject::tr("Not an OASIS content XML"));
skipCurrentElement();
}
}
return !error();
}
QXmlStreamReaderContentXml::readTable
bool readTable()
Definition qxmlstreamreadercontentxml.cpp:125

References readTable().

Referenced by OdsDocReader::parse().

## readCellContent()

bool QXmlStreamReaderContentXml::readCellContent | ( |  | ) |

private

Definition at line 301 of file qxmlstreamreadercontentxml.cpp.

{
while(readNextStartElement())
{
qDebug() << qualifiedName();
if(qualifiedName().toString() == "office:annotation")
{
//dc:date
skipCurrentElement();
}
else if(qualifiedName().toString() == "text:p")
{
readTextP();
}
else
{
raiseError(
QObject::tr("Not an OASIS content XML %1").arg(qualifiedName()));
}
}
return !error();
}
QXmlStreamReaderContentXml::readTextP
bool readTextP()
Definition qxmlstreamreadercontentxml.cpp:330

References readTextP().

Referenced by readTableLine().

## readTable()

bool QXmlStreamReaderContentXml::readTable | ( |  | ) |

private

Definition at line 125 of file qxmlstreamreadercontentxml.cpp.

{
qDebug() << qualifiedName();
while(readNextStartElement())
{
qDebug() << qualifiedName();
if(qualifiedName().toString() == "table:table")
{
QString spread_sheet_name =
attributes().value("table:name").toString();
if(spread_sheet_name.isEmpty())
{
//_errorStr = QObject::tr("spread_sheet_name is
// empty.");
// return false;
}
m_odsReader.startSheet(spread_sheet_name);
readTableRow();
}
else
{
// raiseError(QObject::tr("Not an OASIS content XML"));
skipCurrentElement();
}
}
return !error();
}
QXmlStreamReaderContentXml::readTableRow
bool readTableRow()
Definition qxmlstreamreadercontentxml.cpp:159

References m_odsReader, and readTableRow().

Referenced by read().

## readTableLine()

bool QXmlStreamReaderContentXml::readTableLine | ( |  | ) |

private

Definition at line 186 of file qxmlstreamreadercontentxml.cpp.

{
//<table:table-cell office:value-type="string" table:style-name="ce1">
// <text:p>truc</text:p>
// </table:table-cell>
qDebug() << qualifiedName();
while(readNextStartElement())
{
qDebug() << qualifiedName();
if(qualifiedName().toString() == "table:table-cell")
{
m_numberColumnsRepeated = 1;
m_currentCell.setOfficeValueType(
attributes().value("office:value-type").toString());
if(m_currentCell.getOfficeValueType().isEmpty())
{
m_currentCell.setOfficeValueType(
attributes().value("calcext:value-type").toString());
}
// table:number-columns-repeated="2"
// <table:table-cell table:number-columns-repeated="2"
// office:value-type="string"><text:p>N.A.</text:p></table:table-cell>
if(!attributes()
.value("table:number-columns-repeated")
.toString()
.isEmpty())
{
m_numberColumnsRepeated =
attributes().value("table:number-columns-repeated").toUInt();
// System.out.println("coucou " + numberColumnsRepeated);
}
if(!m_currentCell.getOfficeValueType().isEmpty())
{
QString dateStr =
attributes().value("office:date-value").toString();
if(!dateStr.isEmpty())
{
// qDebug() << "dateStr " << dateStr;
QDateTime date(QDateTime::fromString(dateStr, Qt::ISODate));
// date.fromString(dateStr,Qt::ISODate);
// qDebug() << " date.fromString " <<
// date.toString(Qt::ISODate);
m_currentCell.setDateValue(date);
}
if(m_currentCell.getOfficeValueType() == "float")
{
/*
* writer.writeAttribute("office",
* hashNamespaceURI.get("office"), "value-type",
* "float"); writer.writeAttribute("office",
* hashNamespaceURI.get("office"), "value", value);
*/
QString valueStr =
attributes().value("office:value").toString();
if(valueStr.isEmpty())
{
raiseError(QObject::tr("office:value is null"));
}
m_currentCell.setValueDouble(valueStr.toDouble());
}
else if(m_currentCell.getOfficeValueType() == "boolean")
{
// office:boolean-value="false" calcext:value-type="boolean"
// office:value-type="boolean"
QString valueStr =
attributes().value("office:boolean-value").toString();
m_currentCell.setValueBoolean(false);
if(valueStr.isEmpty())
{
m_currentCell.setValueBoolean(false);
}
else if(valueStr == "true")
{
m_currentCell.setValueBoolean(true);
}
}
}
// content cell
readCellContent();
// skipCurrentElement();
// end table cell
while(m_numberColumnsRepeated > 0)
{
m_odsReader.setInsideCell(m_currentCell);
m_numberColumnsRepeated--;
}
}
else
{
// raiseError(QObject::tr("Not an OASIS content XML"));
skipCurrentElement();
}
}
return !error();
}
QXmlStreamReaderContentXml::m_currentCell
OdsCell m_currentCell
Definition qxmlstreamreadercontentxml.h:62
QXmlStreamReaderContentXml::m_numberColumnsRepeated
uint m_numberColumnsRepeated
Definition qxmlstreamreadercontentxml.h:64
QXmlStreamReaderContentXml::readCellContent
bool readCellContent()
Definition qxmlstreamreadercontentxml.cpp:301

References m_currentCell, m_numberColumnsRepeated, m_odsReader, and readCellContent().

Referenced by readTableRow().

## readTableRow()

bool QXmlStreamReaderContentXml::readTableRow | ( |  | ) |

private

Definition at line 159 of file qxmlstreamreadercontentxml.cpp.

{
//<table:table-row table:style-name="ro1">
qDebug() << qualifiedName();
while(readNextStartElement())
{
qDebug() << qualifiedName();
if(qualifiedName().toString() == "table:table-row")
{
m_odsReader.startLine();
readTableLine();
m_odsReader.endLine();
}
else
{
// raiseError(QObject::tr("Not an OASIS content XML"));
skipCurrentElement();
}
}
return !error();
}
QXmlStreamReaderContentXml::readTableLine
bool readTableLine()
Definition qxmlstreamreadercontentxml.cpp:186

References m_odsReader, and readTableLine().

Referenced by readTable().

## readTextP()

bool QXmlStreamReaderContentXml::readTextP | ( |  | ) |

private

Definition at line 330 of file qxmlstreamreadercontentxml.cpp.

{
m_currentCell._string_value.append(
readElementText(QXmlStreamReader::IncludeChildElements));
return !error();
}

References m_currentCell.

Referenced by readCellContent().

## Member Data Documentation

## m_currentCell

OdsCell QXmlStreamReaderContentXml::m_currentCell

private

Definition at line 62 of file qxmlstreamreadercontentxml.h.

Referenced by readTableLine(), and readTextP().

## m_numberColumnsRepeated

uint QXmlStreamReaderContentXml::m_numberColumnsRepeated

private

Definition at line 64 of file qxmlstreamreadercontentxml.h.

Referenced by readTableLine().

## m_odsReader

OdsDocReader& QXmlStreamReaderContentXml::m_odsReader

private

Definition at line 60 of file qxmlstreamreadercontentxml.h.

Referenced by QXmlStreamReaderContentXml(), readTable(), readTableLine(), and readTableRow().

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

- odsstream/saxreader/qxmlstreamreadercontentxml.h
- odsstream/saxreader/qxmlstreamreadercontentxml.cpp