File indexing completed on 2025-01-12 13:05:51

0001 /* This file is part of the KDE project
0002    Copyright (C) 2001 Eva Brucherseifer <eva@kde.org>
0003    Copyright (C) 2005 Bram Schoenmakers <bramschoenmakers@kde.nl>
0004    based on kspread csv export filter by David Faure
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This library 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 GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef HTMLEXPORT_TEST_H
0023 #define HTMLEXPORT_TEST_H
0024 
0025 #include <KoFilter.h>
0026 #include <QByteArray>
0027 #include <QVariantList>
0028 
0029 class ExportDialog;
0030 class KoDocument;
0031 
0032 namespace Calligra
0033 {
0034 namespace Sheets
0035 {
0036 class Sheet;
0037 }
0038 }
0039 
0040 class HTMLExport : public KoFilter
0041 {
0042     Q_OBJECT
0043 public:
0044     HTMLExport(QObject* parent, const QVariantList&);
0045     ~HTMLExport() override;
0046 
0047     KoFilter::ConversionStatus convert(const QByteArray& from, const QByteArray& to) override;
0048 private:
0049     /** Writes the top of the page in HTML to @par str */
0050     void openPage(Calligra::Sheets::Sheet *sheet, KoDocument *document, QString &str);
0051 
0052     /** Closes a page in HTML */
0053     void closePage(QString &);
0054 
0055     /**
0056       Converts @par sheet to HTML and writes to @par str.
0057      */
0058     void convertSheet(Calligra::Sheets::Sheet *sheet, QString &str, int, int);
0059 
0060     /** Writes a bar and a link to the top to @par str. */
0061     void createSheetSeparator(QString &);
0062 
0063     /** Writes the table of contents */
0064     void writeTOC(const QStringList &, const QString &, QString &);
0065 
0066     /**
0067       Returns a filename based on the @par base filename and the options
0068       defined in the dialog.
0069     */
0070     QString fileName(const QString &base, const QString &, bool);
0071 
0072     /**
0073       Detects which rows and columns of the given @par sheet are used and
0074       writes the number of them to @par row and @par column.
0075      */
0076     void detectFilledCells(Calligra::Sheets::Sheet *sheet, int &rows, int &columns);
0077 private:
0078     ExportDialog *m_dialog;
0079 
0080     typedef QMap<QString, int> Rows;
0081     Rows m_rowmap;
0082     typedef QMap<QString, int> Columns;
0083     Columns m_columnmap;
0084 };
0085 
0086 #endif
0087