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

31 : _outFile(p_quaZip)
32{
33 QuaZipNewInfo info("content.xml");
34 _outFile.open(QIODevice::WriteOnly, info);
35 _p_writer = new QXmlStreamWriter(&_outFile);
36 _p_writer->setAutoFormatting(true);
37 this->WriteHeader();
38 _p_settings_xml = p_settings_xml;
39}
SettingsXml * _p_settings_xml
Definition contentxml.h:97
void WriteHeader()
QXmlStreamWriter * _p_writer
Definition contentxml.h:80
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.

42{
43}

Member Function Documentation

◆ addColorScale()

void ContentXml::addColorScale ( const OdsColorScale ods_color_scale)

Definition at line 988 of file contentxml.cpp.

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

References _color_scale_list.

Referenced by OdsDocWriter::addColorScale().

◆ close()

void ContentXml::close ( )

Definition at line 338 of file contentxml.cpp.

339{
340
343
345 _p_writer->writeEndDocument();
346
347 this->_outFile.close();
348
349 delete _p_writer;
350}
void startSpreadsheet()
void writeAutomaticStyles()
void writeEndTable()

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

Referenced by OdsDocWriter::close().

◆ getCellCoordinate()

QString ContentXml::getCellCoordinate ( )

Definition at line 995 of file contentxml.cpp.

996{
997 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
998 << _current_sheet_name << " " << _col_pos << " " << _row_pos;
999
1000 int size_col = _col_pos - 1; // supports more than 26 columns
1001 QString ods_column_coord;
1002 while(size_col >= 0)
1003 {
1004 ods_column_coord.prepend((char)(((size_col) % 26) + 65));
1005 size_col = (size_col / 26);
1006 if(size_col == 0)
1007 break;
1008 size_col--;
1009 }
1010
1011 return QString("%1.%2%3")
1013 .arg(ods_column_coord)
1014 .arg(_row_pos);
1015}
unsigned int _row_pos
Definition contentxml.h:95
unsigned int _col_pos
Definition contentxml.h:96
QString _current_sheet_name
Definition contentxml.h:92

References _col_pos, _current_sheet_name, and _row_pos.

Referenced by OdsDocWriter::getOdsCellCoordinate().

◆ getOdsColorScaleListBySheetName()

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

Definition at line 353 of file contentxml.cpp.

354{
355 std::vector<OdsColorScale> color_scale_list;
356
357 for(OdsColorScale color_scale : _color_scale_list)
358 {
359 if(color_scale.isInSheet(sheet_name))
360 {
361 color_scale_list.push_back(color_scale);
362 }
363 }
364
365 return color_scale_list;
366}

References _color_scale_list.

Referenced by writeEndTable().

◆ getTableCellStyleRef()

OdsTableCellStyleRef ContentXml::getTableCellStyleRef ( const OdsTableCellStyle style)

Definition at line 953 of file contentxml.cpp.

954{
956 {
957 throw OdsException(
958 QObject::tr("unable to get style reference : styles already written"));
959 }
960
961 _style2write.push_back(style);
962
963 OdsTableCellStyleRef _p_ref =
965 _style_ref_list.push_back(_p_ref);
966 return _p_ref;
967}
bool _automatic_styles_writed
Definition contentxml.h:85
std::vector< OdsTableCellStyle > _style2write
Definition contentxml.h:87
std::vector< OdsTableCellStyleRef > _style_ref_list
Definition contentxml.h:88

References _automatic_styles_writed, _style2write, and _style_ref_list.

Referenced by OdsDocWriter::getTableCellStyleRef().

◆ setTableCellStyleRef()

void ContentXml::setTableCellStyleRef ( OdsTableCellStyleRef  style_ref)

Definition at line 971 of file contentxml.cpp.

972{
973 if(style_ref != nullptr)
974 {
975 auto it = find(_style_ref_list.begin(), _style_ref_list.end(), style_ref);
976 if(it == _style_ref_list.end())
977 {
978 throw OdsException(QObject::tr(
979 "this style reference was not registered in this document"));
980 }
981 }
982
983 _current_style_ref = style_ref;
984}
OdsTableCellStyleRefInternal * _current_style_ref
Definition contentxml.h:89

References _current_style_ref, and _style_ref_list.

Referenced by OdsDocWriter::setTableCellStyleRef().

◆ startSpreadsheet()

void ContentXml::startSpreadsheet ( )
private

Definition at line 142 of file contentxml.cpp.

143{
144
146 return;
148
149 // <office:body>
150 _p_writer->writeStartElement(MetaXml::getNamespaceURI("office"), "body");
151 // <office:spreadsheet>
152 _p_writer->writeStartElement(MetaXml::getNamespaceURI("office"),
153 "spreadsheet");
154}
bool _spreadsheet_started
Definition contentxml.h:86
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.

669{
670 //<office:annotation draw:style-name="gr1" draw:text-style-name="P2"
671 // svg:width="28.99mm" svg:height="10.69mm" svg:x="96.48mm" svg:y="0mm"
672 // draw:caption-point-x="-6.1mm"
673 // draw:caption-point-y="10.68mm"><dc:date>2016-08-19T00:00:00</dc:date>
674 //<text:p text:style-name="P1">Ceci est un commentaire</text:p>
675 //</office:annotation>
676 if(!annotation.isEmpty())
677 {
678 _p_writer->writeStartElement(MetaXml::getNamespaceURI("office"),
679 "annotation");
680 _p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
681 _p_writer->writeCharacters(annotation);
682 _p_writer->writeEndElement();
683
684 _p_writer->writeEndElement(); // annotation
685 }
686}

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.

158{
159
161 return;
163
164 /*
165 * <office:automatic-styles>
166 *
167 *
168 *
169 *
170 *
171 *
172 *
173 *
174 *
175 *
176 *
177 *
178 * </office:automatic-styles>
179 */
180 /*
181 *
182 * <office:automatic-styles>
183 */
184 _p_writer->writeStartElement(MetaXml::getNamespaceURI("office"),
185 "automatic-styles");
186 /*
187 * <style:style style:name="ce1" style:family="table-cell"
188 * style:parent-style-name="Default" style:data-style-name="N0" />
189 */
190 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
191 _p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "ce1");
192 _p_writer->writeAttribute(
193 MetaXml::getNamespaceURI("style"), "family", "table-cell");
194 _p_writer->writeAttribute(
195 MetaXml::getNamespaceURI("style"), "parent-style-name", "Default");
196 _p_writer->writeAttribute(
197 MetaXml::getNamespaceURI("style"), "data-style-name", "N0");
198 _p_writer->writeEndElement();
199
200 /*
201 * <style:style style:name="ce2" style:family="table-cell"
202 * style:parent-style-name="Default" style:data-style-name="N36" />
203 */
204 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
205 _p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "ce2");
206 _p_writer->writeAttribute(
207 MetaXml::getNamespaceURI("style"), "family", "table-cell");
208 _p_writer->writeAttribute(
209 MetaXml::getNamespaceURI("style"), "parent-style-name", "Default");
210 _p_writer->writeAttribute(
211 MetaXml::getNamespaceURI("style"), "data-style-name", "N36");
212 _p_writer->writeEndElement();
213 // <style:style style:name="co1" style:family="table-column">
214 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
215 _p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "co1");
216 _p_writer->writeAttribute(
217 MetaXml::getNamespaceURI("style"), "family", "table-column");
218
219 /*
220 * <style:table-column-properties fo:break-before="auto"
221 * style:column-width="2.27541666666667cm" />
222 */
223 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"),
224 "table-column-properties");
225 _p_writer->writeAttribute(
226 MetaXml::getNamespaceURI("fo"), "break-before", "auto");
227 _p_writer->writeAttribute(
228 MetaXml::getNamespaceURI("style"), "column-width", "2.27541666666667cm");
229 _p_writer->writeEndElement();
230 // </style:style>
231 _p_writer->writeEndElement();
232
233 // <style:style style:name="co2" style:family="table-column">
234 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
235 _p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "co2");
236 _p_writer->writeAttribute(
237 MetaXml::getNamespaceURI("style"), "family", "table-column");
238 // <style:table-column-properties
239 // fo:break-before="auto" style:column-width="2.11666666666667cm" />
240 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"),
241 "table-column-properties");
242 _p_writer->writeAttribute(
243 MetaXml::getNamespaceURI("fo"), "break-before", "auto");
244 _p_writer->writeAttribute(
245 MetaXml::getNamespaceURI("style"), "column-width", "2.27541666666667cm");
246 _p_writer->writeEndElement();
247 // </style:style>
248 _p_writer->writeEndElement();
249 // <style:style style:name="ro1" style:family="table-row">
250 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
251 _p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "ro1");
252 _p_writer->writeAttribute(
253 MetaXml::getNamespaceURI("style"), "family", "table-row");
254
255 // <style:table-row-properties
256 // style:row-height="15pt" style:use-optimal-row-height="true"
257 // fo:break-before="auto" />
258 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"),
259 "table-row-properties");
260 _p_writer->writeAttribute(
261 MetaXml::getNamespaceURI("style"), "row-height", "15pt");
262 _p_writer->writeAttribute(
263 MetaXml::getNamespaceURI("style"), "use-optimal-row-height", "true");
264 _p_writer->writeAttribute(
265 MetaXml::getNamespaceURI("fo"), "break-before", "auto");
266 _p_writer->writeEndElement();
267 // </style:style>
268 _p_writer->writeEndElement();
269
270 // <style:style style:name="ta1" style:family="table"
271 // style:master-page-name="mp1">
272 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
273 _p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "ta1");
274 _p_writer->writeAttribute(
275 MetaXml::getNamespaceURI("style"), "family", "table");
276 _p_writer->writeAttribute(
277 MetaXml::getNamespaceURI("style"), "master-page-name", "mp1");
278 // <style:table-properties table:display="true"
279 // style:writing-mode="lr-tb" />
280 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"),
281 "table-properties");
282 _p_writer->writeAttribute(
283 MetaXml::getNamespaceURI("table"), "display", "true");
284 _p_writer->writeAttribute(
285 MetaXml::getNamespaceURI("style"), "writing-mode", "lr-tb");
286 _p_writer->writeEndElement();
287
288 // </style:style>
289 _p_writer->writeEndElement();
290
291 /*
292 *
293 <style:style style:name="ce3" style:family="table-cell"
294 style:parent-style-name="Default" style:data-style-name="N0">
295 <style:table-cell-properties fo:background-color="#ffff00"/>
296 <style:text-properties fo:color="#800000"/>
297 </style:style>
298 */
299
300 for(unsigned int i = 0; i < _style2write.size(); i++)
301 {
302 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "style");
303 _p_writer->writeAttribute(MetaXml::getNamespaceURI("style"),
304 "name",
305 _style_ref_list[i]->_ref_str);
306 _p_writer->writeAttribute(
307 MetaXml::getNamespaceURI("style"), "family", "table-cell");
308 _p_writer->writeAttribute(
309 MetaXml::getNamespaceURI("style"), "parent-style-name", "Default");
310 _p_writer->writeAttribute(
311 MetaXml::getNamespaceURI("style"), "data-style-name", "N0");
312
313 if(_style2write[i]._background_color.isValid())
314 {
315 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"),
316 "table-cell-properties");
317 _p_writer->writeAttribute(MetaXml::getNamespaceURI("fo"),
318 "background-color",
319 _style2write[i]._background_color.name());
320 _p_writer->writeEndElement();
321 }
322 if(_style2write[i]._text_color.isValid())
323 {
324 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"),
325 "text-properties");
326 _p_writer->writeAttribute(MetaXml::getNamespaceURI("fo"),
327 "color",
328 _style2write[i]._text_color.name());
329 _p_writer->writeEndElement();
330 }
331
332 _p_writer->writeEndElement();
333 }
334 _p_writer->writeEndElement();
335}

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.

796{
797
800
801 if(_tableRowStarted == false)
802 {
803 writeLine();
804 }
805 /*
806 * <table:table-cell office:value-type="date"
807 * office:date-value="2011-07-16"
808 * ><text:p>16/07/11</text:p></table:table-cell>
809 */
810 _p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
811 _p_writer->writeAttribute(
812 MetaXml::getNamespaceURI("office"), "value-type", "boolean");
813 if(_current_style_ref != nullptr)
814 {
815 _p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
816 "style-name",
818 }
819 else
820 {
821 _p_writer->writeAttribute(
822 MetaXml::getNamespaceURI("table"), "style-name", "ce1");
823 }
824
825 QString bvalue = "false";
826 if(value)
827 {
828 bvalue = "true";
829 }
830 _p_writer->writeAttribute(
831 MetaXml::getNamespaceURI("office"), "boolean-value", bvalue);
832 writeAnnotation(annotation);
833 _p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
834 _p_writer->writeCharacters(bvalue);
835 _p_writer->writeEndElement();
836
837 /*
838 * </table:table-cell>
839 */
840 _p_writer->writeEndElement();
841 _col_pos++;
842}
void writeLine()
void writeAnnotation(const QString &annotation)
bool _tableRowStarted
Definition contentxml.h:84

References _col_pos, _current_style_ref, _p_writer, OdsTableCellStyleRefInternal::_ref_str, _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.

789{
790
791 writeCell(date.startOfDay(), annotation);
792}
void writeCell(double value, const QString &annotation)

References writeCell().

◆ writeCell() [3/8]

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

Definition at line 732 of file contentxml.cpp.

733{
734
737
738
739 if(_tableRowStarted == false)
740 {
741 writeLine();
742 }
743 // cal..setTimezone(0);
744 /*
745 * <table:table-cell office:value-type="date"
746 * office:date-value="2011-07-16"
747 * ><text:p>16/07/11</text:p></table:table-cell>
748 */
749 _p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
750 _p_writer->writeAttribute(
751 MetaXml::getNamespaceURI("office"), "value-type", "date");
752 _p_writer->writeAttribute(MetaXml::getNamespaceURI("office"),
753 "date-value",
754 cal.toString("yyyy-MM-dd'T'HH:mm:ss"));
755 // table:style-name="ce1"
756 if(_current_style_ref != nullptr)
757 {
758 _p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
759 "style-name",
761 }
762 else
763 {
764 _p_writer->writeAttribute(
765 MetaXml::getNamespaceURI("table"), "style-name", "ce2");
766 }
767 /*
768 * <text:p>45</text:p>
769 */
770 writeAnnotation(annotation);
771 _p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
772 // writer.writeCharacters(cal.getDay()+"/"+cal.getMonth()+"/11");
773 _p_writer->writeCharacters(cal.toString("dd/MM/yyyy"));
774 _p_writer->writeEndElement();
775
776 /*
777 * </table:table-cell>
778 */
779 _p_writer->writeEndElement();
780 /*
781 * </table:table-row> </table:table> </office:spreadsheet>
782 * </office:body>
783 */
784 _col_pos++;
785}

References _col_pos, _current_style_ref, _p_writer, OdsTableCellStyleRefInternal::_ref_str, _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.

690{
691
694
695 if(_tableRowStarted == false)
696 {
697 writeLine();
698 }
699 /*
700 * <table:table-cell office:value-type="string">
701 */
702 _p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
703 _p_writer->writeAttribute(
704 MetaXml::getNamespaceURI("office"), "value-type", "string");
705 // table:style-name="ce1"
706
707
708 if(_current_style_ref != nullptr)
709 {
710 _p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
711 "style-name",
713 }
714 else
715 {
716 _p_writer->writeAttribute(
717 MetaXml::getNamespaceURI("table"), "style-name", "ce1");
718 }
719 /*
720 * <text:p>45</text:p>
721 */
722 writeAnnotation(annotation);
723 _p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
724 _p_writer->writeCharacters(value);
725 _p_writer->writeEndElement();
726
727 _p_writer->writeEndElement();
728 _col_pos++;
729}

References _col_pos, _current_style_ref, _p_writer, OdsTableCellStyleRefInternal::_ref_str, _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.

887{
888 // <table:table-cell office:value-type="string"><text:p><text:a
889 // xlink:href="http://linuxfr.org/">linuxfr</text:a></text:p></table:table-cell>
890
891 //<table:table-cell office:value-type="string" calcext:value-type="string">
892 //<text:p>
893 //<text:a xlink:href="http://pappso.inra.fr/" xlink:type="simple">
894 // ceci est un lien</text:a></text:p>
895 //</table:table-cell>
896
897 //<table:table-cell table:style-name="ce1" office:value-type="string">
898 //<text:p>
899 //<text:a xlink:href="http://linuxfr.org/" xlink:type="simple">
900 // linux fr</text:a></text:p>
901 //</table:table-cell>
904
905 if(_tableRowStarted == false)
906 {
907 writeLine();
908 }
909 /*
910 * <table:table-cell office:value-type="string">
911 */
912 _p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
913
914 if(_current_style_ref != nullptr)
915 {
916 _p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
917 "style-name",
919 }
920 else
921 {
922 _p_writer->writeAttribute(
923 MetaXml::getNamespaceURI("table"), "style-name", "ce1");
924 }
925
926 //_p_writer->writeAttribute(MetaXml::getNamespaceURI("office"),"value-type",
927 //"string");
928 _p_writer->writeAttribute(
929 MetaXml::getNamespaceURI("calcext"), "value-type", "string");
930
931 writeAnnotation(annotation);
932
933 _p_writer->setAutoFormatting(false);
934 _p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
935 _p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "a");
936 // xlink:href="http://linuxfr.org/"
937 _p_writer->writeAttribute(
938 MetaXml::getNamespaceURI("xlink"), "href", theUri.toString());
939 _p_writer->writeAttribute(
940 MetaXml::getNamespaceURI("xlink"), "type", "simple");
941 _p_writer->writeCharacters(description);
942 _p_writer->writeEndElement();
943 _p_writer->writeEndElement();
944
945 _p_writer->setAutoFormatting(true);
946
947 _p_writer->writeEndElement();
948
949 _col_pos++;
950}

References _col_pos, _current_style_ref, _p_writer, OdsTableCellStyleRefInternal::_ref_str, _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.

499{
500 writeCellFloat(QString::number(value, 'e', 20),
501 QString::number(value, 'g', 20),
502 annotation);
503}
void writeCellFloat(const QString &value, const QString &representation, const QString &annotation)

References writeCellFloat().

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

◆ writeCell() [7/8]

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

Definition at line 513 of file contentxml.cpp.

514{
515 QString representation(QString::number(value));
516 writeCellFloat(representation, representation, annotation);
517}

References writeCellFloat().

◆ writeCell() [8/8]

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

Definition at line 506 of file contentxml.cpp.

507{
508 QString representation(QString::number(value));
509 writeCellFloat(representation, representation, annotation);
510}

References writeCellFloat().

◆ writeCellFloat()

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

Definition at line 574 of file contentxml.cpp.

577{
578
581
582 if(_tableRowStarted == false)
583 {
584 writeLine();
585 }
586 /*
587 * <table:table-cell office:value-type="float" office:value="45">
588 */
589 _p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
590 _p_writer->writeAttribute(
591 MetaXml::getNamespaceURI("office"), "value-type", "float");
592 _p_writer->writeAttribute(MetaXml::getNamespaceURI("office"), "value", value);
593 // table:style-name="ce1"
594 if(_current_style_ref != nullptr)
595 {
596 _p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
597 "style-name",
599 }
600 else
601 {
602 _p_writer->writeAttribute(
603 MetaXml::getNamespaceURI("table"), "style-name", "ce1");
604 }
605 /*
606 * <text:p>45</text:p>
607 */
608 writeAnnotation(annotation);
609 _p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
610 _p_writer->writeCharacters(representation);
611 _p_writer->writeEndElement();
612
613 /*
614 * </table:table-cell>
615 */
616 _p_writer->writeEndElement();
617 /*
618 * </table:table-row> </table:table> </office:spreadsheet>
619 * </office:body>
620 */
621 _col_pos++;
622}

References _col_pos, _current_style_ref, _p_writer, OdsTableCellStyleRefInternal::_ref_str, _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.

522{
523 QString representation(QString("%1 %").arg(value * 100));
526
527 if(_tableRowStarted == false)
528 {
529 writeLine();
530 }
531 /*
532 * <table:table-cell office:value-type="percentage" office:value="0.5"
533 * calcext:value-type="percentage">
534 */
535 _p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
536 _p_writer->writeAttribute(
537 MetaXml::getNamespaceURI("office"), "value-type", "percentage");
538 _p_writer->writeAttribute(MetaXml::getNamespaceURI("office"),
539 "value",
540 QString::number(value, 'f', 5));
541 _p_writer->writeAttribute(
542 MetaXml::getNamespaceURI("calcext"), "value-type", "percentage");
543 // table:style-name="ce1"
544 if(_current_style_ref != nullptr)
545 {
546 _p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
547 "style-name",
549 }
550 else
551 {
552 _p_writer->writeAttribute(
553 MetaXml::getNamespaceURI("table"), "style-name", "ce1");
554 }
555 writeAnnotation(annotation);
556 _p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
557 //<text:p>50,00 %</text:p></table:table-cell>
558 _p_writer->writeCharacters(representation);
559 _p_writer->writeEndElement();
560
561 /*
562 * </table:table-cell>
563 */
564 _p_writer->writeEndElement();
565 /*
566 * </table:table-row> </table:table> </office:spreadsheet>
567 * </office:body>
568 */
569 _col_pos++;
570}

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

Referenced by OdsDocWriter::writeCellPercentage().

◆ writeEmptyCell()

void ContentXml::writeEmptyCell ( const QString &  annotation)

Definition at line 626 of file contentxml.cpp.

627{
628
631
632 if(_tableRowStarted == false)
633 {
634 writeLine();
635 }
636 /*
637 * <table:table-cell office:value-type="string">
638 */
639 _p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-cell");
640 _p_writer->writeAttribute(
641 MetaXml::getNamespaceURI("office"), "value-type", "string");
642 // table:style-name="ce1"
643 if(_current_style_ref != nullptr)
644 {
645 _p_writer->writeAttribute(MetaXml::getNamespaceURI("table"),
646 "style-name",
648 }
649 else
650 {
651 _p_writer->writeAttribute(
652 MetaXml::getNamespaceURI("table"), "style-name", "ce1");
653 }
654 /*
655 * <text:p>45</text:p>
656 */
657 writeAnnotation(annotation);
658 _p_writer->writeStartElement(MetaXml::getNamespaceURI("text"), "p");
659 _p_writer->writeCharacters("");
660 _p_writer->writeEndElement();
661
662 _p_writer->writeEndElement();
663 _col_pos++;
664}

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

Referenced by OdsDocWriter::writeEmptyCell().

◆ writeEndTable()

void ContentXml::writeEndTable ( )
private

Definition at line 369 of file contentxml.cpp.

370{
372 {
373 _p_writer->writeEndElement();
374 }
375
376 if(_tableStarted)
377 {
378 std::vector<OdsColorScale> sheet_color_scale_list =
380 if(sheet_color_scale_list.size() > 0)
381 {
382 /*
383 <calcext:conditional-formats>
384 <calcext:conditional-format
385 calcext:target-range-address="classeur.A5:classeur.E6" >
386 <calcext:color-scale>
387 <calcext:color-scale-entry calcext:value="0"
388 calcext:type="minimum" calcext:color="#0000ff"/>
389 <calcext:color-scale-entry calcext:value="50"
390 calcext:type="percentile" calcext:color="#ffffff"/>
391 <calcext:color-scale-entry calcext:value="0"
392 calcext:type="maximum" calcext:color="#ff0000"/>
393 </calcext:color-scale>
394 </calcext:conditional-format>
395 </calcext:conditional-formats>
396 </table:table>*/
397 //<calcext:conditional-formats>
398 _p_writer->writeStartElement(MetaXml::getNamespaceURI("calcext"),
399 "conditional-formats");
400
401 for(OdsColorScale color_scale : sheet_color_scale_list)
402 {
403 color_scale.writeConditionalFormat(_p_writer);
404 }
405
406 //</calcext:conditional-formats>
407 _p_writer->writeEndElement();
408 }
409
410
411 _p_writer->writeEndElement();
412 }
413
414 _tableStarted = false;
415 _tableRowStarted = false;
416 _row_pos = 0;
417 _col_pos = 0;
418}
std::vector< OdsColorScale > getOdsColorScaleListBySheetName(const QString &sheet_name)
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.

119{
120 _p_writer->writeStartElement(MetaXml::getNamespaceURI("office"),
121 "font-face-decls");
122 /**
123 * <style:font-face style:font-family-generic="swiss"
124 * style:font-pitch="variable" style:name="Arial"
125 * svg:font-family="Arial"/>
126 * */
127 _p_writer->writeStartElement(MetaXml::getNamespaceURI("style"), "font-face");
128 _p_writer->writeAttribute(
129 MetaXml::getNamespaceURI("style"), "font-family-generic", "swiss");
130 _p_writer->writeAttribute(
131 MetaXml::getNamespaceURI("style"), "font-pitch", "variable");
132 _p_writer->writeAttribute(MetaXml::getNamespaceURI("style"), "name", "Arial");
133 _p_writer->writeAttribute(
134 MetaXml::getNamespaceURI("svg"), "font-family", "Arial");
135 _p_writer->writeEndElement();
136
137 _p_writer->writeEndElement();
138}

References _p_writer, and MetaXml::getNamespaceURI().

Referenced by WriteHeader().

◆ WriteHeader()

void ContentXml::WriteHeader ( )
private

Definition at line 46 of file contentxml.cpp.

47{
48 _tableRowStarted = false;
49 _tableStarted = false;
50 _p_writer->writeStartDocument("1.0");
51 /*
52 * <office:document-content office:version="1.2"
53 * xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
54 * xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
55 * xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
56 * xmlns:db="urn:oasis:names:tc:opendocument:xmlns:database:1.0"
57 * xmlns:dc="http://purl.org/dc/elements/1.1/"
58 * xmlns:dom="http://www.w3.org/2001/xml-events"
59 * xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
60 * xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
61 * xmlns:fo
62 * ="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
63 * xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
64 * xmlns:grddl="http://www.w3.org/2003/g/data-view#"
65 * xmlns:math="http://www.w3.org/1998/Math/MathML"
66 * xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
67 * xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
68 * xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
69 * xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
70 * xmlns:ooo="http://openoffice.org/2004/office"
71 * xmlns:oooc="http://openoffice.org/2004/calc"
72 * xmlns:ooow="http://openoffice.org/2004/writer" xmlns:presentation=
73 * "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
74 * xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
75 * xmlns:
76 * smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
77 * xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
78 * xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
79 * xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
80 * xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
81 * xmlns:xforms="http://www.w3.org/2002/xforms"
82 * xmlns:xhtml="http://www.w3.org/1999/xhtml"
83 * xmlns:xlink="http://www.w3.org/1999/xlink"
84 * xmlns:xsd="http://www.w3.org/2001/XMLSchema"
85 * xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
86 */
87
89
90 auto it = MetaXml::_hash_namespace_uri.begin();
91 while(it != MetaXml::_hash_namespace_uri.end())
92 {
93 _p_writer->writeNamespace(it->second, it->first);
94 it++;
95 }
96 // xmlns:xsd="http://www.w3.org/2001/XMLSchema"
97 _p_writer->writeNamespace(_xsdNamespaceURI, "xsd");
98
99 // xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
100 _p_writer->writeNamespace(_xsiNamespaceURI, "xsi");
101
102 _p_writer->writeStartElement(MetaXml::getNamespaceURI("office"),
103 "document-content");
104 _p_writer->writeAttribute(
105 MetaXml::getNamespaceURI("office"), "version", "1.2");
106
107
108 // <office:scripts/>
109 _p_writer->writeStartElement(MetaXml::getNamespaceURI("office"), "scripts");
110 _p_writer->writeEndElement();
111
112 // <office:font-face-decls>
114}
static QString _xsdNamespaceURI
Definition contentxml.h:75
static QString _xsiNamespaceURI
Definition contentxml.h:76
void writeFontFaceDecls()
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.

463{
464
467
468 if(_tableStarted == false)
469 {
470 writeSheet();
471 }
473 {
474 // close current row
475 _p_writer->writeStartElement(MetaXml::getNamespaceURI("table"),
476 "table-cell");
477 _p_writer->writeEndElement();
478 _p_writer->writeEndElement();
479 }
480 _row_pos++;
481 _col_pos = 0;
482 _tableRowStarted = true;
483 /*
484 * <table:table-row table:style-name="ro1">
485 */
486 _p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table-row");
487 _p_writer->writeAttribute(
488 MetaXml::getNamespaceURI("table"), "style-name", "ro1");
489}
void writeSheet()

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

Referenced by writeCell(), writeCell(), writeCell(), writeCell(), writeCellFloat(), writeCellPercentage(), writeEmptyCell(), and OdsDocWriter::writeLine().

◆ writeSheet() [1/2]

void ContentXml::writeSheet ( )
private

Definition at line 492 of file contentxml.cpp.

493{
495}
const QString getDefaultSheetName() const

References _p_settings_xml, SettingsXml::getDefaultSheetName(), and writeSheet().

Referenced by writeLine(), and writeSheet().

◆ writeSheet() [2/2]

void ContentXml::writeSheet ( const QString &  sheetName)

Definition at line 422 of file contentxml.cpp.

423{
424
425 _p_settings_xml->addSheetName(tableName);
428
430 _current_sheet_name = tableName;
431 _tableStarted = true;
432
433 /*
434 * <table:table table:name="Feuille1" table:style-name="ta1"
435 * table:print="false">
436 */
437 _p_writer->writeStartElement(MetaXml::getNamespaceURI("table"), "table");
438 _p_writer->writeAttribute(
439 MetaXml::getNamespaceURI("table"), "name", tableName);
440 _p_writer->writeAttribute(
441 MetaXml::getNamespaceURI("table"), "style-name", "ta1");
442 _p_writer->writeAttribute(
443 MetaXml::getNamespaceURI("table"), "print", "false");
444
445 /*
446 * <table:table-column table:style-name="co1"
447 * table:default-cell-style-name="ce1" />
448 */
449 _p_writer->writeStartElement(MetaXml::getNamespaceURI("table"),
450 "table-column");
451 _p_writer->writeAttribute(
452 MetaXml::getNamespaceURI("table"), "style-name", "co1");
453 _p_writer->writeAttribute(
454 MetaXml::getNamespaceURI("table"), "default-cell-style-name", "ce1");
455 _p_writer->writeEndElement();
456
457 _row_pos = 0;
458 _col_pos = 0;
459}
void addSheetName(const QString &name)

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

Referenced by OdsDocWriter::writeSheet().

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

◆ _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

◆ _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

◆ _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

◆ _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"
staticprivate

Definition at line 75 of file contentxml.h.

Referenced by WriteHeader().

◆ _xsiNamespaceURI

QString ContentXml::_xsiNamespaceURI
staticprivate
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: