libodsstream
Library for mass spectrometry
Loading...
Searching...
No Matches
manifestxml.cpp
Go to the documentation of this file.
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#include "manifestxml.h"
21#include <QXmlStreamWriter>
22
23#include <quazipfile.h>
24
26 "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0";
27
28ManifestXml::ManifestXml(QuaZip *p_quaZip) : _p_quaZip(p_quaZip)
29{
30 QuaZipFile outFile(_p_quaZip);
31 QuaZipNewInfo info("META-INF/manifest.xml");
32 outFile.open(QIODevice::WriteOnly, info);
33 _p_writer = new QXmlStreamWriter(&outFile);
34 _p_writer->setAutoFormatting(true);
35
36 this->WriteHeader();
37
38 _p_writer->writeStartElement(_namespaceURI, "file-entry");
39 _p_writer->writeAttribute(_namespaceURI, "full-path", "/");
40 _p_writer->writeAttribute(_namespaceURI,
41 "media-type",
42 "application/vnd.oasis.opendocument.spreadsheet");
43 _p_writer->writeEndElement();
44
45 _p_writer->writeStartElement(_namespaceURI, "file-entry");
46 _p_writer->writeAttribute(_namespaceURI, "full-path", "styles.xml");
47 _p_writer->writeAttribute(_namespaceURI, "media-type", "text/xml");
48 _p_writer->writeEndElement();
49
50 _p_writer->writeStartElement(_namespaceURI, "file-entry");
51 _p_writer->writeAttribute(_namespaceURI, "full-path", "content.xml");
52 _p_writer->writeAttribute(_namespaceURI, "media-type", "text/xml");
53 _p_writer->writeEndElement();
54
55 _p_writer->writeStartElement(_namespaceURI, "file-entry");
56 _p_writer->writeAttribute(_namespaceURI, "full-path", "meta.xml");
57 _p_writer->writeAttribute(_namespaceURI, "media-type", "text/xml");
58 _p_writer->writeEndElement();
59
60 //<manifest:file-entry manifest:full-path="mimetype"
61 // manifest:media-type="text/plain" />
62 /*
63 _p_writer->writeStartElement(_namespaceURI, "file-entry");
64 _p_writer->writeAttribute(_namespaceURI, "full-path", "mimetype");
65 _p_writer->writeAttribute(_namespaceURI, "media-type", "text/plain");
66 _p_writer->writeEndElement();
67*/
68 //<manifest:file-entry manifest:full-path="META-INF/manifest.xml"
69 // manifest:media-type="text/xml" />
70 /*
71 _p_writer->writeStartElement(_namespaceURI,"file-entry");
72 _p_writer->writeAttribute(_namespaceURI, "full-path",
73 "META-INF/manifest.xml"); _p_writer->writeAttribute(_namespaceURI,
74 "media-type", "text/xml"); _p_writer->writeEndElement();
75 */
76
77 //<manifest:file-entry manifest:full-path="settings.xml"
78 //manifest:media-type="text/xml"/>
79 _p_writer->writeStartElement(_namespaceURI, "file-entry");
80 _p_writer->writeAttribute(_namespaceURI, "full-path", "settings.xml");
81 _p_writer->writeAttribute(_namespaceURI, "media-type", "text/xml");
82 _p_writer->writeEndElement();
83
84
85 _p_writer->writeEndDocument();
86
87 delete _p_writer;
88
89 outFile.close();
90}
91
95
96void
98{
99 _p_writer->writeStartDocument("1.0");
100 //<manifest:manifest
101 //xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"
102 //manifest:version="1.2" >
103 _p_writer->writeNamespace(_namespaceURI, "manifest");
104 _p_writer->writeStartElement(_namespaceURI, "manifest");
105
106 _p_writer->writeAttribute(_namespaceURI, "version", "1.2");
107 //_p_writer->setPrefix("manifest", namespaceURI);
108 //_p_writer->setDefaultNamespace(namespaceURI);
109 //_p_writer->writeStartElement("mzXML");
110
111 //_p_writer->writeAttribute(xmlnsxsi, "schemaLocation", xsischemaLocation);
112
113
114 // not compatible with MS office 2010 :
115 //_p_writer->writeAttribute("manifest", namespaceURI, "version", "1.2");
116}
void WriteHeader()
virtual ~ManifestXml()
static QString _namespaceURI
Definition manifestxml.h:34
QXmlStreamWriter * _p_writer
Definition manifestxml.h:38
QuaZip * _p_quaZip
Definition manifestxml.h:37
ManifestXml(QuaZip *p_quaZip)