odsstream
contentxml.h
1 /*
2  libodsstream is a library to read and write ODS documents as streams
3  Copyright (C) 2013 Olivier Langella <Olivier.Langella@moulon.inra.fr>
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 
20 #pragma once
21 
22 #include <quazip5/quazip.h>
23 #include <quazip5/quazipfile.h>
24 #include <QXmlStreamWriter>
25 #include <QUrl>
26 #include <QDate>
27 #include <QDateTime>
28 #include "../options/odstablecellstyle.h"
29 #include "../options/odstablecellstyleref.h"
30 #include "../options/odscolorscale.h"
31 #include "settingsxml.h"
32 
33 
35 {
36  public:
37  ContentXml(QuaZip *p_quaZip, SettingsXml *p_settings_xml);
38  virtual ~ContentXml();
39  void writeSheet(const QString &sheetName);
40  void writeCell(double value, const QString &annotation);
41  void writeCell(std::size_t value, const QString &annotation);
42  void writeCell(int value, const QString &annotation);
43  void writeCell(const QString &value, const QString &annotation);
44  void writeCell(const QDate &, const QString &annotation);
45  void writeCell(const QDateTime &, const QString &annotation);
46  void writeCell(const QUrl &, const QString &, const QString &annotation);
47  void writeCell(bool value, const QString &annotation);
48  void writeCellPercentage(double value, const QString &annotation);
49  void writeEmptyCell(const QString &annotation);
50  void writeLine();
51  void close();
52 
53  OdsTableCellStyleRef getTableCellStyleRef(const OdsTableCellStyle &style);
54  void setTableCellStyleRef(OdsTableCellStyleRef style_ref);
55  void addColorScale(const OdsColorScale &ods_color_scale);
56  QString getCellCoordinate();
57 
58  private:
59  void writeCellFloat(const QString &value,
60  const QString &representation,
61  const QString &annotation);
62  void writeSheet();
63  void writeEndTable();
64  std::vector<OdsColorScale>
65  getOdsColorScaleListBySheetName(const QString &sheet_name);
66 
67  void WriteHeader();
68  void writeFontFaceDecls();
69  void writeAutomaticStyles();
70  void startSpreadsheet();
71  void writeAnnotation(const QString &annotation);
72 
73  QuaZipFile _outFile;
74 
75  static QString _xsdNamespaceURI;
76  static QString _xsiNamespaceURI;
77 
78 
79  QuaZip *_p_quaZip;
80  QXmlStreamWriter *_p_writer;
81 
82  bool _tableStarted;
83 
84  bool _tableRowStarted;
85  bool _automatic_styles_writed = false;
86  bool _spreadsheet_started = false;
87  std::vector<OdsTableCellStyle> _style2write;
88  std::vector<OdsTableCellStyleRef> _style_ref_list;
89  OdsTableCellStyleRefInternal *_current_style_ref = nullptr;
90 
91  std::vector<OdsColorScale> _color_scale_list;
92  QString _current_sheet_name;
93 
94 
95  unsigned int _row_pos = 0;
96  unsigned int _col_pos = 0;
97  SettingsXml *_p_settings_xml;
98 };
ContentXml
Definition: contentxml.h:35
OdsTableCellStyle
Definition: odstablecellstyle.h:34
OdsColorScale
Definition: odscolorscale.h:44
SettingsXml
Definition: settingsxml.h:45
OdsTableCellStyleRefInternal
Definition: odstablecellstyleref.h:39