1 /*************************************************************************** 2 * Copyright (C) 2004-2017 by Thomas Fischer <fischer@unix-ag.uni-kl.de> * 3 * * 4 * This program is free software; you can redistribute it and/or modify * 5 * it under the terms of the GNU General Public License as published by * 6 * the Free Software Foundation; either version 2 of the License, or * 7 * (at your option) any later version. * 8 * * 9 * This program is distributed in the hope that it will be useful, * 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 * GNU General Public License for more details. * 13 * * 14 * You should have received a copy of the GNU General Public License * 15 * along with this program; if not, see <https://www.gnu.org/licenses/>. * 16 ***************************************************************************/ 17 #ifndef BIBTEXFILEEXPORTERXML_H 18 #define BIBTEXFILEEXPORTERXML_H 19 20 #include <QTextStream> 21 22 #include "element.h" 23 #include "value.h" 24 #include "fileexporter.h" 25 26 class Entry; 27 class Macro; 28 class Comment; 29 30 /** 31 * @author Thomas Fischer <fischer@unix-ag.uni-kl.de> 32 */ 33 class KBIBTEXIO_EXPORT FileExporterXML : public FileExporter 34 { 35 Q_OBJECT 36 37 public: 38 explicit FileExporterXML(QObject *parent); 39 ~FileExporterXML() override; 40 41 bool save(QIODevice *iodevice, const File *bibtexfile, QStringList *errorLog = nullptr) override; 42 bool save(QIODevice *iodevice, const QSharedPointer<const Element> element, const File *bibtexfile, QStringList *errorLog = nullptr) override; 43 44 static QString valueToXML(const Value &value, const QString &fieldType = QString()); 45 46 public slots: 47 void cancel() override; 48 49 private: 50 bool m_cancelFlag; 51 52 bool write(QTextStream &stream, const Element *element, const File *bibtexfile = nullptr); 53 bool writeEntry(QTextStream &stream, const Entry *entry); 54 bool writeMacro(QTextStream &stream, const Macro *macro); 55 bool writeComment(QTextStream &stream, const Comment *comment); 56 57 static QString cleanXML(const QString &text); 58 }; 59 60 #endif 61