File indexing completed on 2024-05-19 05:05:34

0001 /***************************************************************************
0002  *   SPDX-License-Identifier: GPL-2.0-or-later
0003  *                                                                         *
0004  *   SPDX-FileCopyrightText: 2004-2023 Thomas Fischer <fischer@unix-ag.uni-kl.de>
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  *   This program is distributed in the hope that it will be useful,       *
0012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0014  *   GNU General Public License for more details.                          *
0015  *                                                                         *
0016  *   You should have received a copy of the GNU General Public License     *
0017  *   along with this program; if not, see <https://www.gnu.org/licenses/>. *
0018  ***************************************************************************/
0019 
0020 #ifndef KBIBTEX_IO_FILEEXPORTERPDF_H
0021 #define KBIBTEX_IO_FILEEXPORTERPDF_H
0022 
0023 #include <QStringList>
0024 
0025 #include <FileExporterToolchain>
0026 
0027 #ifdef HAVE_KF
0028 #include "kbibtexio_export.h"
0029 #endif // HAVE_KF
0030 
0031 /**
0032 @author Thomas Fischer
0033  */
0034 class KBIBTEXIO_EXPORT FileExporterPDF : public FileExporterToolchain
0035 {
0036     Q_OBJECT
0037 
0038 public:
0039     enum class FileEmbedding {
0040         None = 0,
0041         BibTeXFile = 1,
0042         References = 2,
0043         BibTeXFileAndReferences = BibTeXFile | References
0044     };
0045     Q_DECLARE_FLAGS(FileEmbeddings, FileEmbedding)
0046 
0047     explicit FileExporterPDF(QObject *parent);
0048     ~FileExporterPDF() override;
0049 
0050     bool save(QIODevice *iodevice, const File *bibtexfile) override;
0051     bool save(QIODevice *iodevice, const QSharedPointer<const Element> &element, const File *bibtexfile) override;
0052 
0053     void setDocumentSearchPaths(const QStringList &searchPaths);
0054     void setFileEmbedding(const FileEmbeddings fileEmbedding);
0055 
0056 private:
0057     QString m_fileBasename;
0058     QString m_fileStem;
0059     FileEmbeddings m_fileEmbeddings;
0060     QStringList m_embeddedFileList;
0061     QStringList m_searchPaths;
0062 
0063     bool generatePDF(QIODevice *iodevice);
0064     bool writeLatexFile(const QString &filename);
0065     void fillEmbeddedFileList(const File *bibtexfile);
0066     void fillEmbeddedFileList(const QSharedPointer<const Element> &element, const File *bibtexfile);
0067 };
0068 
0069 #endif // KBIBTEX_IO_FILEEXPORTERPDF_H