libodsstream
Library for mass spectrometry
Loading...
Searching...
No Matches
MetaXml Class Reference

#include <metaxml.h>

Public Member Functions

 MetaXml (QuaZip *p_quaZip)
 
virtual ~MetaXml ()
 

Static Public Member Functions

static const QString & getNamespaceURI (const QString &xml_namespace)
 

Static Public Attributes

static std::map< const QString, const QString > _hash_namespace_uri
 

Private Member Functions

void WriteHeader (QXmlStreamWriter *p_writer)
 

Private Attributes

QuaZip * _p_quaZip
 

Detailed Description

Definition at line 26 of file metaxml.h.

Constructor & Destructor Documentation

◆ MetaXml()

MetaXml::MetaXml ( QuaZip *  p_quaZip)

Definition at line 108 of file metaxml.cpp.

108 : _p_quaZip(p_quaZip)
109{
110 QuaZipFile outFile(_p_quaZip);
111 QuaZipNewInfo info("meta.xml");
112 outFile.open(QIODevice::WriteOnly, info);
113 QXmlStreamWriter *p_writer = new QXmlStreamWriter(&outFile);
114 p_writer->setAutoFormatting(true);
115
116 this->WriteHeader(p_writer);
117
118 p_writer->writeStartElement(MetaXml::getNamespaceURI("office"), "meta");
119
120 /*
121 * see RFC2616, or 3.1.1 in the oasis doc : meta:generator
122 */
123 p_writer->writeStartElement(MetaXml::getNamespaceURI("meta"), "generator");
124 p_writer->writeCharacters(LIBODS_GENERATOR_NAME);
125 p_writer->writeEndElement();
126
127 QDateTime currentdate(QDateTime::currentDateTime());
128
129 p_writer->writeStartElement(MetaXml::getNamespaceURI("meta"),
130 "creation-date");
131 p_writer->writeCharacters(currentdate.toString("yyyy-MM-dd'T'HH:mm:ss"));
132 p_writer->writeEndElement();
133
134 p_writer->writeStartElement(MetaXml::getNamespaceURI("dc"), "date");
135 p_writer->writeCharacters(currentdate.toString("yyyy-MM-dd'T'HH:mm:ss"));
136 p_writer->writeEndElement();
137
138 p_writer->writeStartElement(MetaXml::getNamespaceURI("meta"),
139 "editing-cycles");
140 p_writer->writeCharacters("1");
141 p_writer->writeEndElement();
142
143 p_writer->writeStartElement(MetaXml::getNamespaceURI("meta"),
144 "editing-duration");
145 p_writer->writeCharacters("PT0.602S");
146 p_writer->writeEndElement();
147
148 p_writer->writeEndDocument();
149
150 delete p_writer;
151
152 outFile.close();
153}
QuaZip * _p_quaZip
Definition metaxml.h:39
static const QString & getNamespaceURI(const QString &xml_namespace)
Definition metaxml.cpp:32
void WriteHeader(QXmlStreamWriter *p_writer)
Definition metaxml.cpp:156
#define LIBODS_GENERATOR_NAME
Definition metaxml.cpp:26

References _p_quaZip, getNamespaceURI(), LIBODS_GENERATOR_NAME, and WriteHeader().

◆ ~MetaXml()

MetaXml::~MetaXml ( )
virtual

Definition at line 182 of file metaxml.cpp.

183{
184}

Member Function Documentation

◆ getNamespaceURI()

const QString & MetaXml::getNamespaceURI ( const QString &  xml_namespace)
static

Definition at line 32 of file metaxml.cpp.

33{
34 if(_hash_namespace_uri.size() == 0)
35 {
36 _hash_namespace_uri.insert(std::make_pair(
37 "anim", "urn:oasis:names:tc:opendocument:xmlns:animation:1.0"));
38 _hash_namespace_uri.insert(std::make_pair(
39 "chart", "urn:oasis:names:tc:opendocument:xmlns:chart:1.0"));
40 _hash_namespace_uri.insert(std::make_pair(
41 "config", "urn:oasis:names:tc:opendocument:xmlns:config:1.0"));
42 _hash_namespace_uri.insert(std::make_pair(
43 "db", "urn:oasis:names:tc:opendocument:xmlns:database:1.0"));
45 std::make_pair("dc", "http://purl.org/dc/elements/1.1/"));
46 _hash_namespace_uri.insert(std::make_pair(
47 "dr3d", "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"));
48 _hash_namespace_uri.insert(std::make_pair(
49 "draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"));
50 _hash_namespace_uri.insert(std::make_pair(
51 "fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"));
52 _hash_namespace_uri.insert(std::make_pair(
53 "form", "urn:oasis:names:tc:opendocument:xmlns:form:1.0"));
55 std::make_pair("grddl", "http://www.w3.org/2003/g/data-view#"));
57 std::make_pair("math", "http://www.w3.org/1998/Math/MathML"));
58 _hash_namespace_uri.insert(std::make_pair(
59 "meta", "urn:oasis:names:tc:opendocument:xmlns:meta:1.0"));
60 _hash_namespace_uri.insert(std::make_pair(
61 "number", "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"));
63 std::make_pair("of", "urn:oasis:names:tc:opendocument:xmlns:of:1.2"));
64 _hash_namespace_uri.insert(std::make_pair(
65 "office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0"));
67 std::make_pair("ooo", "http://openoffice.org/2004/office"));
68 _hash_namespace_uri.insert(std::make_pair(
69 "presentation",
70 "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"));
71 _hash_namespace_uri.insert(std::make_pair(
72 "script", "urn:oasis:names:tc:opendocument:xmlns:script:1.0"));
73 _hash_namespace_uri.insert(std::make_pair(
74 "smil", "urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"));
75 _hash_namespace_uri.insert(std::make_pair(
76 "style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0"));
77 _hash_namespace_uri.insert(std::make_pair(
78 "svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"));
79 _hash_namespace_uri.insert(std::make_pair(
80 "table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0"));
81 _hash_namespace_uri.insert(std::make_pair(
82 "text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0"));
84 std::make_pair("xforms", "http://www.w3.org/2002/xforms"));
86 std::make_pair("calcext",
87 "urn:org:documentfoundation:names:experimental:calc:"
88 "xmlns:calcext:1.0"));
90 std::make_pair("xhtml", "http://www.w3.org/1999/xhtml"));
92 std::make_pair("xlink", "http://www.w3.org/1999/xlink"));
93 }
94 auto it = _hash_namespace_uri.find(xml_namespace);
95 if(it != _hash_namespace_uri.end())
96 {
97 return it->second;
98 }
99 else
100 {
101 throw OdsException(
102 QObject::tr("XML namespace %1 not defined in MetaXml object")
103 .arg(xml_namespace));
104 }
105}
static std::map< const QString, const QString > _hash_namespace_uri
Definition metaxml.h:34

References _hash_namespace_uri.

Referenced by MetaXml(), ContentXml::startSpreadsheet(), SettingsXml::write(), ContentXml::writeAnnotation(), ContentXml::writeAutomaticStyles(), StylesXml::WriteAutomaticStyles(), ContentXml::writeCell(), ContentXml::writeCell(), ContentXml::writeCell(), ContentXml::writeCell(), ContentXml::writeCellFloat(), ContentXml::writeCellPercentage(), OdsColorScale::writeConditionalFormat(), SettingsXml::writeConfigItem(), SettingsXml::writeConfigurationSettings(), ContentXml::writeEmptyCell(), ContentXml::writeEndTable(), ContentXml::writeFontFaceDecls(), StylesXml::WriteFontFaceDecls(), ContentXml::WriteHeader(), WriteHeader(), ContentXml::writeLine(), StylesXml::WriteMasterStyles(), StylesXml::WriteOfficeStyles(), ContentXml::writeSheet(), and SettingsXml::writeSheetSettings().

◆ WriteHeader()

void MetaXml::WriteHeader ( QXmlStreamWriter *  p_writer)
private

Definition at line 156 of file metaxml.cpp.

157{
158 p_writer->writeStartDocument("1.0");
159 MetaXml::getNamespaceURI("office");
160
161 std::map<const QString, const QString>::const_iterator it =
163 while(it != MetaXml::_hash_namespace_uri.end())
164 {
165 p_writer->writeNamespace(QString(it->second), it->first);
166 it++;
167 }
168
169 // <manifest:manifest
170 // xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"
171 // manifest:version="1.2" >
172 p_writer->writeStartElement(MetaXml::getNamespaceURI("office"),
173 "document-meta");
174 p_writer->writeAttribute(
175 MetaXml::getNamespaceURI("office"), "version", "1.2");
176 // writer.setPrefix("manifest", namespaceURI);
177 // writer.setDefaultNamespace(namespaceURI);
178 // writer.writeStartElement("mzXML");
179}

References _hash_namespace_uri, and getNamespaceURI().

Referenced by MetaXml().

Member Data Documentation

◆ _hash_namespace_uri

std::map< const QString, const QString > MetaXml::_hash_namespace_uri
static

Definition at line 34 of file metaxml.h.

Referenced by getNamespaceURI(), ContentXml::WriteHeader(), and WriteHeader().

◆ _p_quaZip

QuaZip* MetaXml::_p_quaZip
private

Definition at line 39 of file metaxml.h.

Referenced by MetaXml().


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