File indexing completed on 2024-05-12 16:36:43

0001 /* This file is part of the KDE project
0002    Copyright (C) 2009-2010 Benjamin Port <port.benjamin@gmail.com>
0003    Copyright (C) 2009 Yannick Motta <yannick.motta@gmail.com>
0004 
0005    This library is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License as published by the Free Software Foundation; either
0008    version 2 of the License, or (at your option) any later version.
0009 
0010    This library is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013    Library General Public License for more details.
0014 
0015    You should have received a copy of the GNU Library General Public License
0016    along with this library; see the file COPYING.LIB.  If not, write to
0017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #ifndef KPRHTMLEXPORT_H
0022 #define KPRHTMLEXPORT_H
0023 
0024 #include <QUrl>
0025 #include <QStringList>
0026 #include <QObject>
0027 
0028 class KPrView;
0029 class KoPAPageBase;
0030 class KJob;
0031 
0032 class KPrHtmlExport : public QObject
0033 {
0034     Q_OBJECT
0035 public:
0036     struct Parameter {
0037         Parameter() {}
0038 
0039         Parameter(const QUrl &styleUrl, KPrView *kprView, const QList<KoPAPageBase*> &slides, const QUrl &destination,
0040                   const QString &author, const QString &title, const QStringList &slidesNames, bool openBrowser)
0041                       : styleUrl(styleUrl)
0042                       , kprView(kprView)
0043                       , slides(slides)
0044                       , destination(destination)
0045                       , author(author)
0046                       , title(title)
0047                       , slidesNames(slidesNames)
0048                       , openBrowser(openBrowser)
0049         {
0050         }
0051 
0052         QUrl styleUrl;
0053         KPrView *kprView;
0054         QList<KoPAPageBase*> slides;
0055         QUrl destination;
0056         QString author;
0057         QString title;
0058         QStringList slidesNames;
0059         bool openBrowser;
0060     };
0061 
0062     KPrHtmlExport();
0063     ~KPrHtmlExport() override;
0064     void exportHtml(const Parameter &parameters);
0065 
0066     /**
0067      * Generates a preview of 1 frame into a tempoary directory
0068      * @param parameters Presentation data (only 1 slide should be provided in "slides" filed)
0069      */
0070     QUrl exportPreview(const Parameter &parameters);
0071 
0072 protected:
0073     void extractStyle();
0074     void generateHtml();
0075     void generateToc();
0076     void exportImageToTmpDir();
0077     void writeHtmlFileToTmpDir(const QString &fileName, const QString &htmlBody);
0078     void copyFromTmpToDest();
0079 
0080 private Q_SLOTS:
0081     void moveResult(KJob *job);
0082 
0083 private:
0084     QString m_tmpDirPath;
0085     Parameter m_parameters;
0086 };
0087 
0088 #endif /* KPRHTMLEXPORT_H */