Loading...
Searching...
No Matches
ContentXml Class Reference

`#include <contentxml.h>`

## Public Member Functions

| ContentXml (QuaZip *p_quaZip, SettingsXml *p_settings_xml)
virtual | ~ContentXml ()
void | writeSheet (const QString &sheetName)
void | writeCell (double value, const QString &annotation)
void | writeCell (std::size_t value, const QString &annotation)
void | writeCell (int value, const QString &annotation)
void | writeCell (const QString &value, const QString &annotation)
void | writeCell (const QDate &, const QString &annotation)
void | writeCell (const QDateTime &, const QString &annotation)
void | writeCell (const QUrl &, const QString &, const QString &annotation)
void | writeCell (bool value, const QString &annotation)
void | writeCellPercentage (double value, const QString &annotation)
void | writeEmptyCell (const QString &annotation)
void | writeLine ()
void | close ()
OdsTableCellStyleRef | getTableCellStyleRef (const OdsTableCellStyle &style)
void | setTableCellStyleRef (OdsTableCellStyleRef style_ref)
void | addColorScale (const OdsColorScale &ods_color_scale)
QString | getCellCoordinate ()

## Private Member Functions

void | writeCellFloat (const QString &value, const QString &representation, const QString &annotation)
void | writeSheet ()
void | writeEndTable ()
std::vector< OdsColorScale > | getOdsColorScaleListBySheetName (const QString &sheet_name)
void | WriteHeader ()
void | writeFontFaceDecls ()
void | writeAutomaticStyles ()
void | startSpreadsheet ()
void | writeAnnotation (const QString &annotation)

## Private Attributes

QuaZipFile | _outFile
QuaZip * | _p_quaZip
QXmlStreamWriter * | _p_writer
bool | _tableStarted
bool | _tableRowStarted
bool | _automatic_styles_writed = false
bool | _spreadsheet_started = false
std::vector< OdsTableCellStyle > | _style2write
std::vector< OdsTableCellStyleRef > | _style_ref_list
OdsTableCellStyleRefInternal * | _current_style_ref = nullptr
std::vector< OdsColorScale > | _color_scale_list
QString | _current_sheet_name
unsigned int | _row_pos = 0
unsigned int | _col_pos = 0
SettingsXml * | _p_settings_xml

## Static Private Attributes

static QString | _xsdNamespaceURI = "http://www.w3.org/2001/XMLSchema"
static QString | _xsiNamespaceURI

## Detailed Description

Definition at line 34 of file contentxml.h.

## Constructor & Destructor Documentation

## ContentXml()

ContentXml::ContentXml | ( | QuaZip * | p_quaZip,
|  | SettingsXml * | p_settings_xml )

Definition at line 30 of file contentxml.cpp.

: _outFile(p_quaZip)
{
QuaZipNewInfo info("content.xml");
_outFile.open(QIODevice::WriteOnly, info);
_p_writer = new QXmlStreamWriter(&_outFile);
_p_writer->setAutoFormatting(true);
this->WriteHeader();
_p_settings_xml = p_settings_xml;
}
ContentXml::_p_settings_xml
SettingsXml * _p_settings_xml
Definition contentxml.h:97
ContentXml::WriteHeader
void WriteHeader()
Definition contentxml.cpp:46
ContentXml::_p_writer
QXmlStreamWriter * _p_writer
Definition contentxml.h:80
ContentXml::_outFile
QuaZipFile _outFile
Definition contentxml.h:73

References _outFile, _p_settings_xml, _p_writer, and WriteHeader().

## ~ContentXml()

ContentXml::~ContentXml | ( |  | ) |

virtual

Definition at line 41 of file contentxml.cpp.

{
}

## Member Function Documentation

## addColorScale()

void ContentXml::addColorScale | ( | const OdsColorScale & | ods_color_scale | ) |

Definition at line 988 of file contentxml.cpp.

{
_color_scale_list.push_back(ods_color_scale);
}
ContentXml::_color_scale_list
std::vector< OdsColorScale > _color_scale_list
Definition contentxml.h:91

References _color_scale_list.

## close()

void ContentXml::close | ( |  | ) |

Definition at line 338 of file contentxml.cpp.

{
writeAutomaticStyles();
startSpreadsheet();
writeEndTable();
_p_writer->writeEndDocument();
this->_outFile.close();
delete _p_writer;
}
ContentXml::startSpreadsheet
void startSpreadsheet()
Definition contentxml.cpp:142
ContentXml::writeAutomaticStyles
void writeAutomaticStyles()
Definition contentxml.cpp:157
ContentXml::writeEndTable
void writeEndTable()
Definition contentxml.cpp:369

References _outFile, _p_writer, startSpreadsheet(), writeAutomaticStyles(), and writeEndTable().

## getCellCoordinate()

QString ContentXml::getCellCoordinate | ( |  | ) |

Definition at line 995 of file contentxml.cpp.

{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
<< _current_sheet_name << " " << _col_pos << " " << _row_pos;
int size_col = _col_pos - 1; // supports more than 26 columns
QString ods_column_coord;
while(size_col >= 0)
{
ods_column_coord.prepend((char)(((size_col) % 26) + 65));
size_col = (size_col / 26);
if(size_col == 0)
break;
size_col--;
}
return QString("%1.%2%3")
.arg(_current_sheet_name)
.arg(ods_column_coord)
.arg(_row_pos);
}
ContentXml::_row_pos
unsigned int _row_pos
Definition contentxml.h:95
ContentXml::_col_pos
unsigned int _col_pos
Definition contentxml.h:96
ContentXml::_current_sheet_name
QString _current_sheet_name
Definition contentxml.h:92

References _col_pos, _current_sheet_name, and _row_pos.

## getOdsColorScaleListBySheetName()

std::vector< OdsColorScale > ContentXml::getOdsColorScaleListBySheetName | ( | const QString & | sheet_name | ) |

private

Definition at line 353 of file contentxml.cpp.

{
std::vector<OdsColorScale> color_scale_list;
for(OdsColorScale color_scale : _color_scale_list)
{
if(color_scale.isInSheet(sheet_name))
{
color_scale_list.push_back(color_scale);
}
}
return color_scale_list;
}

References _color_scale_list.

Referenced by writeEndTable().

## getTableCellStyleRef()

OdsTableCellStyleRef ContentXml::getTableCellStyleRef | ( | const OdsTableCellStyle & | style | ) |

Definition at line 953 of file contentxml.cpp.

{
if(_automatic_styles_writed)
{
throw OdsException(
QObject::tr("unable to get style reference : styles already written"));
}
_style2write.push_back(style);
OdsTableCellStyleRef _p_ref =
new OdsTableCellStyleRefInternal(_style2write.size());
_style_ref_list.push_back(_p_ref);
return _p_ref;
}
ContentXml::_automatic_styles_writed
bool _automatic_styles_writed
Definition contentxml.h:85
ContentXml::_style2write
std::vector< OdsTableCellStyle > _style2write
Definition contentxml.h:87
ContentXml::_style_ref_list
std::vector< OdsTableCellStyleRef > _style_ref_list
Definition contentxml.h:88
OdsTableCellStyleRef
OdsTableCellStyleRefInternal * OdsTableCellStyleRef
Definition odstablecellstyleref.h:35

References _automatic_styles_writed, _style2write, and _style_ref_list.

## setTableCellStyleRef()

void ContentXml::setTableCellStyleRef | ( | OdsTableCellStyleRef | style_ref | ) |

Definition at line 971 of file contentxml.cpp.

{
if(style_ref != nullptr)
{
auto it = find(_style_ref_list.begin(), _style_ref_list.end(), style_ref);
if(it == _style_ref_list.end())
{
throw OdsException(QObject::tr(
"this style reference was not registered in this document"));
}
}
_current_style_ref = style_ref;
}
ContentXml::_current_style_ref
OdsTableCellStyleRefInternal * _current_style_ref
Definition contentxml.h:89

References _current_style_ref, and _style_ref_list.

## startSpreadsheet()

void ContentXml::startSpreadsheet | ( |  | ) |

private

Definition at line 142 of file contentxml.cpp.

{
if(_spreadsheet_started)
return;
_spreadsheet_started = true;
// <office:body>
_p_writer->writeStartElement(MetaXml::getNamespaceURI("office"), "body");
// <office:spreadsheet>
_p_writer->writeStartElement(MetaXml::getNamespaceURI("office"),
"spreadsheet");
}
ContentXml::_spreadsheet_started
bool _spreadsheet_started
Definition contentxml.h:86
MetaXml::getNamespaceURI
static const QString & getNamespaceURI(const QString &xml_namespace)
Definition metaxml.cpp:32

References _p_writer, _spreadsheet_started, and MetaXml::getNamespaceURI().

Referenced by close(), writeCell(), writeCell(), writeCell(), writeCell(), writeCellFloat(), writeCellPercentage(), writeEmptyCell(), writeLine(), and writeSheet().

## writeAnnotation()

void ContentXml::writeAnnotation | ( | const QString & | annotation | ) |

private

Definition at line 668 of file contentxml.cpp.

{
//<office:annotation draw:style-name="gr1" draw:text-style-name="P2"
// svg:width="28.99mm" svg:height="10.69mm" svg:x="96.48mm" svg:y="0mm"
// draw:caption-point-x="-6.1mm"
// draw:caption-point-y="10.68mm"><dc:date>2016-08-19T00:00:00</dc:date>
//<text:p text:style-name="P1">Ceci est un commentaire</text:p>
//</office:annotation>
if(!annotation.isEmpty())
{
_p_writer->writeStartElement(MetaXml::getNamespaceURI("office"),
"annotation");
_p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
_p_writer->writeCharacters(annotation);
_p_writer->writeEndElement();
_p_writer->writeEndElement(); // annotation
}
}

References _p_writer, and MetaXml::getNamespaceURI().

Referenced by writeCell(), writeCell(), writeCell(), writeCell(), writeCellFloat(), writeCellPercentage(), and writeEmptyCell().

## writeAutomaticStyles()

void ContentXml::writeAutomaticStyles | ( |  | ) |

private

Definition at line 157 of file contentxml.cpp.

{
if(_automatic_styles_writed)
return;
_automatic_styles_writed = true;
/*
* <office:automatic-styles>
*
*
*
*
*
*
*
*
*
*
*
*
* </office:automatic-styles>
*/
/*
*
* <office:automatic-styles>
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("office"),
"automatic-styles");
/*
* <style:style style:name="ce1" style:family="table-cell"
* style:parent-style-name="Default" style:data-style-name="N0" />
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "ce1");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "family", "table-cell");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "parent-style-name", "Default");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "data-style-name", "N0");
_p_writer->writeEndElement();
/*
* <style:style style:name="ce2" style:family="table-cell"
* style:parent-style-name="Default" style:data-style-name="N36" />
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "ce2");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "family", "table-cell");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "parent-style-name", "Default");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "data-style-name", "N36");
_p_writer->writeEndElement();
// <style:style style:name="co1" style:family="table-column">
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "co1");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "family", "table-column");
/*
* <style:table-column-properties fo:break-before="auto"
* style:column-width="2.27541666666667cm" />
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"),
"table-column-properties");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("fo"), "break-before", "auto");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "column-width", "2.27541666666667cm");
_p_writer->writeEndElement();
// </style:style>
_p_writer->writeEndElement();
// <style:style style:name="co2" style:family="table-column">
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "co2");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "family", "table-column");
// <style:table-column-properties
// fo:break-before="auto" style:column-width="2.11666666666667cm" />
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"),
"table-column-properties");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("fo"), "break-before", "auto");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "column-width", "2.27541666666667cm");
_p_writer->writeEndElement();
// </style:style>
_p_writer->writeEndElement();
// <style:style style:name="ro1" style:family="table-row">
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "ro1");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "family", "table-row");
// <style:table-row-properties
// style:row-height="15pt" style:use-optimal-row-height="true"
// fo:break-before="auto" />
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"),
"table-row-properties");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "row-height", "15pt");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "use-optimal-row-height", "true");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("fo"), "break-before", "auto");
_p_writer->writeEndElement();
// </style:style>
_p_writer->writeEndElement();
// <style:style style:name="ta1" style:family="table"
// style:master-page-name="mp1">
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "ta1");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "family", "table");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "master-page-name", "mp1");
// <style:table-properties table:display="true"
// style:writing-mode="lr-tb" />
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"),
"table-properties");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "display", "true");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "writing-mode", "lr-tb");
_p_writer->writeEndElement();
// </style:style>
_p_writer->writeEndElement();
/*
*
<style:style style:name="ce3" style:family="table-cell"
style:parent-style-name="Default" style:data-style-name="N0">
<style:table-cell-properties fo:background-color="#ffff00"/>
<style:text-properties fo:color="#800000"/>
</style:style>
*/
for(unsigned int i = 0; i < _style2write.size(); i++)
{
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("style"),
"name",
_style_ref_list[i]->_ref_str);
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "family", "table-cell");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "parent-style-name", "Default");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "data-style-name", "N0");
if(_style2write[i]._background_color.isValid())
{
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"),
"table-cell-properties");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("fo"),
"background-color",
_style2write[i]._background_color.name());
_p_writer->writeEndElement();
}
if(_style2write[i]._text_color.isValid())
{
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"),
"text-properties");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("fo"),
"color",
_style2write[i]._text_color.name());
_p_writer->writeEndElement();
}
_p_writer->writeEndElement();
}
_p_writer->writeEndElement();
}

References _automatic_styles_writed, _p_writer, _style2write, _style_ref_list, and MetaXml::getNamespaceURI().

Referenced by close(), writeCell(), writeCell(), writeCell(), writeCell(), writeCellFloat(), writeCellPercentage(), writeEmptyCell(), writeLine(), and writeSheet().

## writeCell() [1/8]

void ContentXml::writeCell | ( | bool | value,
|  | const QString & | annotation )

Definition at line 795 of file contentxml.cpp.

{
writeAutomaticStyles();
startSpreadsheet();
if(_tableRowStarted == false)
{
writeLine();
}
/*
* <table:table-cell office:value-type="date"
* office:date-value="2011-07-16"
* ><text:p>16/07/11</text:p></table:table-cell>
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("office"), "value-type", "boolean");
if(_current_style_ref != nullptr)
{
_p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
"style-name",
_current_style_ref->_ref_str);
}
else
{
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "style-name", "ce1");
}
QString bvalue = "false";
if(value)
{
bvalue = "true";
}
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("office"), "boolean-value", bvalue);
writeAnnotation(annotation);
_p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
_p_writer->writeCharacters(bvalue);
_p_writer->writeEndElement();
/*
* </table:table-cell>
*/
_p_writer->writeEndElement();
_col_pos++;
}
ContentXml::writeLine
void writeLine()
Definition contentxml.cpp:462
ContentXml::writeAnnotation
void writeAnnotation(const QString &annotation)
Definition contentxml.cpp:668
ContentXml::_tableRowStarted
bool _tableRowStarted
Definition contentxml.h:84

References _col_pos, _current_style_ref, _p_writer, _tableRowStarted, MetaXml::getNamespaceURI(), startSpreadsheet(), writeAnnotation(), writeAutomaticStyles(), and writeLine().

## writeCell() [2/8]

void ContentXml::writeCell | ( | const QDate & | date,
|  | const QString & | annotation )

Definition at line 788 of file contentxml.cpp.

{
writeCell(date.startOfDay(), annotation);
}
ContentXml::writeCell
void writeCell(double value, const QString &annotation)
Definition contentxml.cpp:498

References writeCell().

## writeCell() [3/8]

void ContentXml::writeCell | ( | const QDateTime & | cal,
|  | const QString & | annotation )

Definition at line 732 of file contentxml.cpp.

{
writeAutomaticStyles();
startSpreadsheet();
if(_tableRowStarted == false)
{
writeLine();
}
// cal..setTimezone(0);
/*
* <table:table-cell office:value-type="date"
* office:date-value="2011-07-16"
* ><text:p>16/07/11</text:p></table:table-cell>
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("office"), "value-type", "date");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("office"),
"date-value",
cal.toString("yyyy-MM-dd'T'HH:mm:ss"));
// table:style-name="ce1"
if(_current_style_ref != nullptr)
{
_p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
"style-name",
_current_style_ref->_ref_str);
}
else
{
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "style-name", "ce2");
}
/*
* <text:p>45</text:p>
*/
writeAnnotation(annotation);
_p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
// writer.writeCharacters(cal.getDay()+"/"+cal.getMonth()+"/11");
_p_writer->writeCharacters(cal.toString("dd/MM/yyyy"));
_p_writer->writeEndElement();
/*
* </table:table-cell>
*/
_p_writer->writeEndElement();
/*
* </table:table-row> </table:table> </office:spreadsheet>
* </office:body>
*/
_col_pos++;
}

References _col_pos, _current_style_ref, _p_writer, _tableRowStarted, MetaXml::getNamespaceURI(), startSpreadsheet(), writeAnnotation(), writeAutomaticStyles(), and writeLine().

## writeCell() [4/8]

void ContentXml::writeCell | ( | const QString & | value,
|  | const QString & | annotation )

Definition at line 689 of file contentxml.cpp.

{
writeAutomaticStyles();
startSpreadsheet();
if(_tableRowStarted == false)
{
writeLine();
}
/*
* <table:table-cell office:value-type="string">
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("office"), "value-type", "string");
// table:style-name="ce1"
if(_current_style_ref != nullptr)
{
_p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
"style-name",
_current_style_ref->_ref_str);
}
else
{
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "style-name", "ce1");
}
/*
* <text:p>45</text:p>
*/
writeAnnotation(annotation);
_p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
_p_writer->writeCharacters(value);
_p_writer->writeEndElement();
_p_writer->writeEndElement();
_col_pos++;
}

References _col_pos, _current_style_ref, _p_writer, _tableRowStarted, MetaXml::getNamespaceURI(), startSpreadsheet(), writeAnnotation(), writeAutomaticStyles(), and writeLine().

## writeCell() [5/8]

void ContentXml::writeCell | ( | const QUrl & | theUri,
|  | const QString & | description,
|  | const QString & | annotation )

Definition at line 884 of file contentxml.cpp.

{
// <table:table-cell office:value-type="string"><text:p><text:a
// xlink:href="http://linuxfr.org/">linuxfr</text:a></text:p></table:table-cell>
//<table:table-cell office:value-type="string" calcext:value-type="string">
//<text:p>
//<text:a xlink:href="http://pappso.inra.fr/" xlink:type="simple">
// ceci est un lien</text:a></text:p>
//</table:table-cell>
//<table:table-cell table:style-name="ce1" office:value-type="string">
//<text:p>
//<text:a xlink:href="http://linuxfr.org/" xlink:type="simple">
// linux fr</text:a></text:p>
//</table:table-cell>
writeAutomaticStyles();
startSpreadsheet();
if(_tableRowStarted == false)
{
writeLine();
}
/*
* <table:table-cell office:value-type="string">
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
if(_current_style_ref != nullptr)
{
_p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
"style-name",
_current_style_ref->_ref_str);
}
else
{
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "style-name", "ce1");
}
//_p_writer->writeAttribute(MetaXml::getNamespaceURI("office"),"value-type",
//"string");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("calcext"), "value-type", "string");
writeAnnotation(annotation);
_p_writer->setAutoFormatting(false);
_p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
_p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "a");
// xlink:href="http://linuxfr.org/"
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("xlink"), "href", theUri.toString());
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("xlink"), "type", "simple");
_p_writer->writeCharacters(description);
_p_writer->writeEndElement();
_p_writer->writeEndElement();
_p_writer->setAutoFormatting(true);
_p_writer->writeEndElement();
_col_pos++;
}

References _col_pos, _current_style_ref, _p_writer, _tableRowStarted, MetaXml::getNamespaceURI(), startSpreadsheet(), writeAnnotation(), writeAutomaticStyles(), and writeLine().

## writeCell() [6/8]

void ContentXml::writeCell | ( | double | value,
|  | const QString & | annotation )

Definition at line 498 of file contentxml.cpp.

{
writeCellFloat(QString::number(value, 'e', 20),
QString::number(value, 'g', 20),
annotation);
}
ContentXml::writeCellFloat
void writeCellFloat(const QString &value, const QString &representation, const QString &annotation)
Definition contentxml.cpp:574

References writeCellFloat().

Referenced by writeCell().

## writeCell() [7/8]

void ContentXml::writeCell | ( | int | value,
|  | const QString & | annotation )

Definition at line 513 of file contentxml.cpp.

{
QString representation(QString::number(value));
writeCellFloat(representation, representation, annotation);
}

References writeCellFloat().

## writeCell() [8/8]

void ContentXml::writeCell | ( | std::size_t | value,
|  | const QString & | annotation )

Definition at line 506 of file contentxml.cpp.

{
QString representation(QString::number(value));
writeCellFloat(representation, representation, annotation);
}

References writeCellFloat().

## writeCellFloat()

void ContentXml::writeCellFloat | ( | const QString & | value,
|  | const QString & | representation,
|  | const QString & | annotation )

private

Definition at line 574 of file contentxml.cpp.

{
writeAutomaticStyles();
startSpreadsheet();
if(_tableRowStarted == false)
{
writeLine();
}
/*
* <table:table-cell office:value-type="float" office:value="45">
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("office"), "value-type", "float");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("office"), "value", value);
// table:style-name="ce1"
if(_current_style_ref != nullptr)
{
_p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
"style-name",
_current_style_ref->_ref_str);
}
else
{
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "style-name", "ce1");
}
/*
* <text:p>45</text:p>
*/
writeAnnotation(annotation);
_p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
_p_writer->writeCharacters(representation);
_p_writer->writeEndElement();
/*
* </table:table-cell>
*/
_p_writer->writeEndElement();
/*
* </table:table-row> </table:table> </office:spreadsheet>
* </office:body>
*/
_col_pos++;
}

References _col_pos, _current_style_ref, _p_writer, _tableRowStarted, MetaXml::getNamespaceURI(), startSpreadsheet(), writeAnnotation(), writeAutomaticStyles(), and writeLine().

Referenced by writeCell(), writeCell(), and writeCell().

## writeCellPercentage()

void ContentXml::writeCellPercentage | ( | double | value,
|  | const QString & | annotation )

Definition at line 521 of file contentxml.cpp.

{
QString representation(QString("%1 %").arg(value * 100));
writeAutomaticStyles();
startSpreadsheet();
if(_tableRowStarted == false)
{
writeLine();
}
/*
* <table:table-cell office:value-type="percentage" office:value="0.5"
* calcext:value-type="percentage">
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("office"), "value-type", "percentage");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("office"),
"value",
QString::number(value, 'f', 5));
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("calcext"), "value-type", "percentage");
// table:style-name="ce1"
if(_current_style_ref != nullptr)
{
_p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
"style-name",
_current_style_ref->_ref_str);
}
else
{
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "style-name", "ce1");
}
writeAnnotation(annotation);
_p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
//<text:p>50,00 %</text:p></table:table-cell>
_p_writer->writeCharacters(representation);
_p_writer->writeEndElement();
/*
* </table:table-cell>
*/
_p_writer->writeEndElement();
/*
* </table:table-row> </table:table> </office:spreadsheet>
* </office:body>
*/
_col_pos++;
}

References _col_pos, _current_style_ref, _p_writer, _tableRowStarted, MetaXml::getNamespaceURI(), startSpreadsheet(), writeAnnotation(), writeAutomaticStyles(), and writeLine().

## writeEmptyCell()

void ContentXml::writeEmptyCell | ( | const QString & | annotation | ) |

Definition at line 626 of file contentxml.cpp.

{
writeAutomaticStyles();
startSpreadsheet();
if(_tableRowStarted == false)
{
writeLine();
}
/*
* <table:table-cell office:value-type="string">
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("office"), "value-type", "string");
// table:style-name="ce1"
if(_current_style_ref != nullptr)
{
_p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
"style-name",
_current_style_ref->_ref_str);
}
else
{
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "style-name", "ce1");
}
/*
* <text:p>45</text:p>
*/
writeAnnotation(annotation);
_p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
_p_writer->writeCharacters("");
_p_writer->writeEndElement();
_p_writer->writeEndElement();
_col_pos++;
}

References _col_pos, _current_style_ref, _p_writer, _tableRowStarted, MetaXml::getNamespaceURI(), startSpreadsheet(), writeAnnotation(), writeAutomaticStyles(), and writeLine().

## writeEndTable()

void ContentXml::writeEndTable | ( |  | ) |

private

Definition at line 369 of file contentxml.cpp.

{
if(_tableRowStarted)
{
_p_writer->writeEndElement();
}
if(_tableStarted)
{
std::vector<OdsColorScale> sheet_color_scale_list =
getOdsColorScaleListBySheetName(_current_sheet_name);
if(sheet_color_scale_list.size() > 0)
{
/*
<calcext:conditional-formats>
<calcext:conditional-format
calcext:target-range-address="classeur.A5:classeur.E6" >
<calcext:color-scale>
<calcext:color-scale-entry calcext:value="0"
calcext:type="minimum" calcext:color="#0000ff"/>
<calcext:color-scale-entry calcext:value="50"
calcext:type="percentile" calcext:color="#ffffff"/>
<calcext:color-scale-entry calcext:value="0"
calcext:type="maximum" calcext:color="#ff0000"/>
</calcext:color-scale>
</calcext:conditional-format>
</calcext:conditional-formats>
</table:table>*/
//<calcext:conditional-formats>
_p_writer->writeStartElement(MetaXml::getNamespaceURI("calcext"),
"conditional-formats");
for(OdsColorScale color_scale : sheet_color_scale_list)
{
color_scale.writeConditionalFormat(_p_writer);
}
//</calcext:conditional-formats>
_p_writer->writeEndElement();
}
_p_writer->writeEndElement();
}
_tableStarted = false;
_tableRowStarted = false;
_row_pos = 0;
_col_pos = 0;
}
ContentXml::getOdsColorScaleListBySheetName
std::vector< OdsColorScale > getOdsColorScaleListBySheetName(const QString &sheet_name)
Definition contentxml.cpp:353
ContentXml::_tableStarted
bool _tableStarted
Definition contentxml.h:82

References _col_pos, _current_sheet_name, _p_writer, _row_pos, _tableRowStarted, _tableStarted, MetaXml::getNamespaceURI(), and getOdsColorScaleListBySheetName().

Referenced by close(), and writeSheet().

## writeFontFaceDecls()

void ContentXml::writeFontFaceDecls | ( |  | ) |

private

<style:font-face style:font-family-generic="swiss" style:font-pitch="variable" style:name="Arial" svg:font-family="Arial"/>

Definition at line 118 of file contentxml.cpp.

{
_p_writer->writeStartElement(MetaXml::getNamespaceURI("office"),
"font-face-decls");
/**
* <style:font-face style:font-family-generic="swiss"
* style:font-pitch="variable" style:name="Arial"
* svg:font-family="Arial"/>
* */
_p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "font-face");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "font-family-generic", "swiss");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("style"), "font-pitch", "variable");
_p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "Arial");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("svg"), "font-family", "Arial");
_p_writer->writeEndElement();
_p_writer->writeEndElement();
}

References _p_writer, and MetaXml::getNamespaceURI().

Referenced by WriteHeader().

## WriteHeader()

void ContentXml::WriteHeader | ( |  | ) |

private

Definition at line 46 of file contentxml.cpp.

{
_tableRowStarted = false;
_tableStarted = false;
_p_writer->writeStartDocument("1.0");
/*
* <office:document-content office:version="1.2"
* xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation: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:dom="http://www.w3.org/2001/xml-events"
* 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:oooc="http://openoffice.org/2004/calc"
* xmlns:ooow="http://openoffice.org/2004/writer" 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">
*/
MetaXml::getNamespaceURI("office");
auto it = MetaXml::_hash_namespace_uri.begin();
while(it != MetaXml::_hash_namespace_uri.end())
{
_p_writer->writeNamespace(it->second, it->first);
it++;
}
// xmlns:xsd="http://www.w3.org/2001/XMLSchema"
_p_writer->writeNamespace(_xsdNamespaceURI, "xsd");
// xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
_p_writer->writeNamespace(_xsiNamespaceURI, "xsi");
_p_writer->writeStartElement(MetaXml::getNamespaceURI("office"),
"document-content");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("office"), "version", "1.2");
// <office:scripts/>
_p_writer->writeStartElement(MetaXml::getNamespaceURI("office"), "scripts");
_p_writer->writeEndElement();
// <office:font-face-decls>
writeFontFaceDecls();
}
ContentXml::_xsdNamespaceURI
static QString _xsdNamespaceURI
Definition contentxml.h:75
ContentXml::_xsiNamespaceURI
static QString _xsiNamespaceURI
Definition contentxml.h:76
ContentXml::writeFontFaceDecls
void writeFontFaceDecls()
Definition contentxml.cpp:118
MetaXml::_hash_namespace_uri
static std::map< const QString, const QString > _hash_namespace_uri
Definition metaxml.h:34

References MetaXml::_hash_namespace_uri, _p_writer, _tableRowStarted, _tableStarted, _xsdNamespaceURI, _xsiNamespaceURI, MetaXml::getNamespaceURI(), and writeFontFaceDecls().

Referenced by ContentXml().

## writeLine()

void ContentXml::writeLine | ( |  | ) |

Definition at line 462 of file contentxml.cpp.

{
writeAutomaticStyles();
startSpreadsheet();
if(_tableStarted == false)
{
writeSheet();
}
if(_tableRowStarted)
{
// close current row
_p_writer->writeStartElement(MetaXml::getNamespaceURI("table"),
"table-cell");
_p_writer->writeEndElement();
_p_writer->writeEndElement();
}
_row_pos++;
_col_pos = 0;
_tableRowStarted = true;
/*
* <table:table-row table:style-name="ro1">
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-row");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "style-name", "ro1");
}
ContentXml::writeSheet
void writeSheet()
Definition contentxml.cpp:492

References _col_pos, _p_writer, _row_pos, _tableRowStarted, _tableStarted, MetaXml::getNamespaceURI(), startSpreadsheet(), writeAutomaticStyles(), and writeSheet().

Referenced by writeCell(), writeCell(), writeCell(), writeCell(), writeCellFloat(), writeCellPercentage(), and writeEmptyCell().

## writeSheet() [1/2]

void ContentXml::writeSheet | ( |  | ) |

private

Definition at line 492 of file contentxml.cpp.

{
writeSheet(_p_settings_xml->getDefaultSheetName());
}

References _p_settings_xml, and writeSheet().

Referenced by writeLine(), and writeSheet().

## writeSheet() [2/2]

void ContentXml::writeSheet | ( | const QString & | sheetName | ) |

Definition at line 422 of file contentxml.cpp.

{
_p_settings_xml->addSheetName(tableName);
writeAutomaticStyles();
startSpreadsheet();
writeEndTable();
_current_sheet_name = tableName;
_tableStarted = true;
/*
* <table:table table:name="Feuille1" table:style-name="ta1"
* table:print="false">
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "name", tableName);
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "style-name", "ta1");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "print", "false");
/*
* <table:table-column table:style-name="co1"
* table:default-cell-style-name="ce1" />
*/
_p_writer->writeStartElement(MetaXml::getNamespaceURI("table"),
"table-column");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "style-name", "co1");
_p_writer->writeAttribute(
MetaXml::getNamespaceURI("table"), "default-cell-style-name", "ce1");
_p_writer->writeEndElement();
_row_pos = 0;
_col_pos = 0;
}

References _col_pos, _current_sheet_name, _p_settings_xml, _p_writer, _row_pos, _tableStarted, MetaXml::getNamespaceURI(), startSpreadsheet(), writeAutomaticStyles(), and writeEndTable().

## Member Data Documentation

## _automatic_styles_writed

bool ContentXml::_automatic_styles_writed = false

private

Definition at line 85 of file contentxml.h.

Referenced by getTableCellStyleRef(), and writeAutomaticStyles().

## _col_pos

unsigned int ContentXml::_col_pos = 0

private

Definition at line 96 of file contentxml.h.

Referenced by getCellCoordinate(), writeCell(), writeCell(), writeCell(), writeCell(), writeCellFloat(), writeCellPercentage(), writeEmptyCell(), writeEndTable(), writeLine(), and writeSheet().

## _color_scale_list

std::vector<OdsColorScale> ContentXml::_color_scale_list

private

Definition at line 91 of file contentxml.h.

Referenced by addColorScale(), and getOdsColorScaleListBySheetName().

## _current_sheet_name

QString ContentXml::_current_sheet_name

private

Definition at line 92 of file contentxml.h.

Referenced by getCellCoordinate(), writeEndTable(), and writeSheet().

## _current_style_ref

OdsTableCellStyleRefInternal* ContentXml::_current_style_ref = nullptr

private

Definition at line 89 of file contentxml.h.

Referenced by setTableCellStyleRef(), writeCell(), writeCell(), writeCell(), writeCell(), writeCellFloat(), writeCellPercentage(), and writeEmptyCell().

## _outFile

QuaZipFile ContentXml::_outFile

private

Definition at line 73 of file contentxml.h.

Referenced by ContentXml(), and close().

## _p_quaZip

QuaZip* ContentXml::_p_quaZip

private

Definition at line 79 of file contentxml.h.

## _p_settings_xml

SettingsXml* ContentXml::_p_settings_xml

private

Definition at line 97 of file contentxml.h.

Referenced by ContentXml(), writeSheet(), and writeSheet().

## _p_writer

QXmlStreamWriter* ContentXml::_p_writer

private

Definition at line 80 of file contentxml.h.

Referenced by ContentXml(), close(), startSpreadsheet(), writeAnnotation(), writeAutomaticStyles(), writeCell(), writeCell(), writeCell(), writeCell(), writeCellFloat(), writeCellPercentage(), writeEmptyCell(), writeEndTable(), writeFontFaceDecls(), WriteHeader(), writeLine(), and writeSheet().

## _row_pos

unsigned int ContentXml::_row_pos = 0

private

Definition at line 95 of file contentxml.h.

Referenced by getCellCoordinate(), writeEndTable(), writeLine(), and writeSheet().

## _spreadsheet_started

bool ContentXml::_spreadsheet_started = false

private

Definition at line 86 of file contentxml.h.

Referenced by startSpreadsheet().

## _style2write

std::vector<OdsTableCellStyle> ContentXml::_style2write

private

Definition at line 87 of file contentxml.h.

Referenced by getTableCellStyleRef(), and writeAutomaticStyles().

## _style_ref_list

std::vector<OdsTableCellStyleRef> ContentXml::_style_ref_list

private

Definition at line 88 of file contentxml.h.

Referenced by getTableCellStyleRef(), setTableCellStyleRef(), and writeAutomaticStyles().

## _tableRowStarted

bool ContentXml::_tableRowStarted

private

Definition at line 84 of file contentxml.h.

Referenced by writeCell(), writeCell(), writeCell(), writeCell(), writeCellFloat(), writeCellPercentage(), writeEmptyCell(), writeEndTable(), WriteHeader(), and writeLine().

## _tableStarted

bool ContentXml::_tableStarted

private

Definition at line 82 of file contentxml.h.

Referenced by writeEndTable(), WriteHeader(), writeLine(), and writeSheet().

## _xsdNamespaceURI

QString ContentXml::_xsdNamespaceURI = "http://www.w3.org/2001/XMLSchema"

static private

Definition at line 75 of file contentxml.h.

Referenced by WriteHeader().

## _xsiNamespaceURI

QString ContentXml::_xsiNamespaceURI

static private

Initial value:
=
"http://www.w3.org/2001/XMLSchema-instance"

Definition at line 76 of file contentxml.h.

Referenced by WriteHeader().

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

- odsstream/writer/structure/contentxml.h
- odsstream/writer/structure/contentxml.cpp