libodsstream
Library for mass spectrometry
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

OdsDocReaderm_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.

32 : m_odsReader(ods_reader)
33{
34}

◆ ~QXmlStreamReaderContentXml()

QXmlStreamReaderContentXml::~QXmlStreamReaderContentXml ( )
virtual
Todo:
write docs

Definition at line 36 of file qxmlstreamreadercontentxml.cpp.

37{
38}

Member Function Documentation

◆ read()

bool QXmlStreamReaderContentXml::read ( )

Definition at line 41 of file qxmlstreamreadercontentxml.cpp.

42{
43
44 if(readNextStartElement())
45 {
46 qDebug() << qualifiedName();
47 /*
48 * <office:document-content
49 * xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
50 * xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
51 * xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
52 * xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
53 * xmlns:db="urn:oasis:names:tc:opendocument:xmlns:database:1.0"
54 * xmlns:dc="http://purl.org/dc/elements/1.1/"
55 * xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
56 * xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
57 * xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
58 * xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
59 * xmlns:grddl="http://www.w3.org/2003/g/data-view#"
60 * xmlns:math="http://www.w3.org/1998/Math/MathML"
61 * xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
62 * xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
63 * xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
64 * xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
65 * xmlns:ooo="http://openoffice.org/2004/office"
66 * xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
67 * xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
68 * xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
69 * xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
70 * xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
71 * xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
72 * xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
73 * xmlns:xforms="http://www.w3.org/2002/xforms"
74 * xmlns:xhtml="http://www.w3.org/1999/xhtml"
75 * xmlns:xlink="http://www.w3.org/1999/xlink"
76 * xmlns:xsd="http://www.w3.org/2001/XMLSchema"
77 * xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
78 * office:version="1.2">
79 * */
80 if(qualifiedName().toString() == "office:document-content")
81 {
82 //<office:body>
83
84 //<note type="input" label="output, histogram column width">30</note>
85 while(readNextStartElement())
86 {
87 qDebug() << qualifiedName();
88 if(qualifiedName().toString() == "office:body")
89 {
90
91 //<office:spreadsheet>
92 while(readNextStartElement())
93 {
94 qDebug() << qualifiedName();
95 if(qualifiedName().toString() == "office:spreadsheet")
96 {
97 //<table:table table:name="classeur"
98 // table:style-name="ta1" table:print="false">
99 qDebug() << qualifiedName();
100 readTable();
101 }
102 else
103 {
104 skipCurrentElement();
105 }
106 }
107 }
108 else
109 {
110 skipCurrentElement();
111 }
112 }
113 }
114 else
115 {
116 raiseError(QObject::tr("Not an OASIS content XML"));
117 skipCurrentElement();
118 }
119 }
120 return !error();
121}

References readTable().

Referenced by OdsDocReader::parse().

◆ readCellContent()

bool QXmlStreamReaderContentXml::readCellContent ( )
private

Definition at line 301 of file qxmlstreamreadercontentxml.cpp.

302{
303
304 while(readNextStartElement())
305 {
306
307 qDebug() << qualifiedName();
308 if(qualifiedName().toString() == "office:annotation")
309 {
310 //dc:date
311 skipCurrentElement();
312 }
313 else if(qualifiedName().toString() == "text:p")
314 {
315 readTextP();
316 }
317 else
318 {
319 raiseError(
320 QObject::tr("Not an OASIS content XML %1").arg(qualifiedName()));
321 }
322 }
323
324
325 return !error();
326}

References readTextP().

Referenced by readTableLine().

◆ readTable()

bool QXmlStreamReaderContentXml::readTable ( )
private

Definition at line 125 of file qxmlstreamreadercontentxml.cpp.

126{
127
128 qDebug() << qualifiedName();
129 while(readNextStartElement())
130 {
131
132 qDebug() << qualifiedName();
133 if(qualifiedName().toString() == "table:table")
134 {
135 QString spread_sheet_name =
136 attributes().value("table:name").toString();
137 if(spread_sheet_name.isEmpty())
138 {
139 //_errorStr = QObject::tr("spread_sheet_name is
140 // empty.");
141 // return false;
142 }
143 m_odsReader.startSheet(spread_sheet_name);
144
145 readTableRow();
146 }
147 else
148 {
149 // raiseError(QObject::tr("Not an OASIS content XML"));
150 skipCurrentElement();
151 }
152 }
153
154 return !error();
155}
void startSheet(const QString &sheet_name)

References m_odsReader, readTableRow(), and OdsDocReader::startSheet().

Referenced by read().

◆ readTableLine()

bool QXmlStreamReaderContentXml::readTableLine ( )
private

Definition at line 186 of file qxmlstreamreadercontentxml.cpp.

187{
188
189 //<table:table-cell office:value-type="string" table:style-name="ce1">
190 // <text:p>truc</text:p>
191 // </table:table-cell>
192 qDebug() << qualifiedName();
193 while(readNextStartElement())
194 {
195
196 qDebug() << qualifiedName();
197 if(qualifiedName().toString() == "table:table-cell")
198 {
199
202 attributes().value("office:value-type").toString());
203 if(m_currentCell.getOfficeValueType().isEmpty())
204 {
206 attributes().value("calcext:value-type").toString());
207 }
208
209
210 // table:number-columns-repeated="2"
211 // <table:table-cell table:number-columns-repeated="2"
212 // office:value-type="string"><text:p>N.A.</text:p></table:table-cell>
213
214 if(!attributes()
215 .value("table:number-columns-repeated")
216 .toString()
217 .isEmpty())
218 {
220 attributes().value("table:number-columns-repeated").toUInt();
221 // System.out.println("coucou " + numberColumnsRepeated);
222 }
223
224 if(!m_currentCell.getOfficeValueType().isEmpty())
225 {
226
227 QString dateStr =
228 attributes().value("office:date-value").toString();
229 if(!dateStr.isEmpty())
230 {
231 // qDebug() << "dateStr " << dateStr;
232 QDateTime date(QDateTime::fromString(dateStr, Qt::ISODate));
233 // date.fromString(dateStr,Qt::ISODate);
234 // qDebug() << " date.fromString " <<
235 // date.toString(Qt::ISODate);
237 }
238
239
240 if(m_currentCell.getOfficeValueType() == "float")
241 {
242 /*
243 * writer.writeAttribute("office",
244 * hashNamespaceURI.get("office"), "value-type",
245 * "float"); writer.writeAttribute("office",
246 * hashNamespaceURI.get("office"), "value", value);
247 */
248 QString valueStr =
249 attributes().value("office:value").toString();
250 if(valueStr.isEmpty())
251 {
252 raiseError(QObject::tr("office:value is null"));
253 }
254 m_currentCell.setValueDouble(valueStr.toDouble());
255 }
256 else if(m_currentCell.getOfficeValueType() == "boolean")
257 {
258 // office:boolean-value="false" calcext:value-type="boolean"
259 // office:value-type="boolean"
260 QString valueStr =
261 attributes().value("office:boolean-value").toString();
263 if(valueStr.isEmpty())
264 {
266 }
267 else if(valueStr == "true")
268 {
270 }
271 }
272 }
273
274 // content cell
275
277
278 // skipCurrentElement();
279
280 // end table cell
281 while(m_numberColumnsRepeated > 0)
282 {
285 }
286 }
287
288
289 else
290 {
291 // raiseError(QObject::tr("Not an OASIS content XML"));
292 skipCurrentElement();
293 }
294 }
295
296 return !error();
297}
void setOfficeValueType(const QString &type)
Definition odscell.cpp:33
void setValueBoolean(bool value_bool)
Definition odscell.cpp:76
void setValueDouble(double value_num)
Definition odscell.cpp:70
void setDateValue(const QDateTime &date)
Definition odscell.cpp:56
const QString & getOfficeValueType() const
Definition odscell.cpp:91
void setInsideCell(const OdsCell &cell)

References OdsCell::getOfficeValueType(), m_currentCell, m_numberColumnsRepeated, m_odsReader, readCellContent(), OdsCell::setDateValue(), OdsDocReader::setInsideCell(), OdsCell::setOfficeValueType(), OdsCell::setValueBoolean(), and OdsCell::setValueDouble().

Referenced by readTableRow().

◆ readTableRow()

bool QXmlStreamReaderContentXml::readTableRow ( )
private

Definition at line 159 of file qxmlstreamreadercontentxml.cpp.

160{
161
162 //<table:table-row table:style-name="ro1">
163 qDebug() << qualifiedName();
164 while(readNextStartElement())
165 {
166
167 qDebug() << qualifiedName();
168 if(qualifiedName().toString() == "table:table-row")
169 {
173 }
174 else
175 {
176 // raiseError(QObject::tr("Not an OASIS content XML"));
177 skipCurrentElement();
178 }
179 }
180
181 return !error();
182}

References OdsDocReader::endLine(), m_odsReader, readTableLine(), and OdsDocReader::startLine().

Referenced by readTable().

◆ readTextP()

bool QXmlStreamReaderContentXml::readTextP ( )
private

Definition at line 330 of file qxmlstreamreadercontentxml.cpp.

331{
333 readElementText(QXmlStreamReader::IncludeChildElements));
334
335 return !error();
336}
QString _string_value
Definition odscell.h:57

References OdsCell::_string_value, and 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 readTable(), readTableLine(), and readTableRow().


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