1
/* This file is part of the KDE project
3
Copyright (C) 2012 Mojtaba Shahi Senobari <mojtaba.shahi3000@gmail.com>
4
Copyright (C) 2012 Inge Wallin <inge@lysator.liu.se>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Library General Public License
17
along with this library; see the file COPYING.LIB. If not, write to
18
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
* Boston, MA 02110-1301, USA.
24
#include "OdfParser.h"
27
#include <QSvgGenerator>
33
#include <kpluginfactory.h>
36
#include <KoFilterChain.h>
37
#include <KoOdfWriteStore.h>
38
#include <KoGenStyles.h>
39
#include <KoXmlWriter.h>
40
#include <KoStoreDevice.h>
41
#include <KoXmlReader.h>
44
OdfParser::OdfParser()
48
OdfParser::~OdfParser()
54
KoFilter::ConversionStatus OdfParser::parseMetadata(KoStore *odfStore,
55
QHash<QString, QString> &metadata)
57
if (!odfStore->open("meta.xml")) {
58
kDebug(30517) << "Cannot open meta.xml";
59
return KoFilter::FileNotFound;
66
if (!doc.setContent(odfStore->device(), true, &errorMsg, &errorLine, &errorColumn)) {
67
kDebug() << "Error occurred while parsing meta.xml "
68
<< errorMsg << " in Line: " << errorLine
69
<< " Column: " << errorColumn;
71
return KoFilter::ParsingError;
74
KoXmlNode childNode = doc.documentElement();
75
childNode = KoXml::namedItemNS(childNode, KoXmlNS::office, "meta");
77
forEachElement (element, childNode) {
78
metadata.insert(element.tagName(), element.text());
86
KoFilter::ConversionStatus OdfParser::parseManifest(KoStore *odfStore,
87
QHash<QString, QString> &manifest)
89
if (!odfStore->open("META-INF/manifest.xml")) {
90
kDebug(30517) << "Cannot to open manifest.xml.";
91
return KoFilter::FileNotFound;
96
int errorLine, errorColumn;
97
if (!doc.setContent(odfStore->device(), true, &errorMsg, &errorLine, &errorColumn)) {
98
kDebug() << "Error occurred while parsing meta.xml "
99
<< errorMsg << " in Line: " << errorLine
100
<< " Column: " << errorColumn;
101
return KoFilter::ParsingError;
104
KoXmlNode childNode = doc.documentElement();
105
KoXmlElement nodeElement;
106
forEachElement (nodeElement, childNode) {
107
QString path = nodeElement.attribute("full-path");
108
QString type = nodeElement.attribute("media-type");
110
manifest.insert(path, type);