File indexing completed on 2025-02-02 12:00:48

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2001 Eva Brucherseifer <eva@kde.org>
0003    SPDX-FileCopyrightText: 2005 Bram Schoenmakers <bramschoenmakers@kde.nl>
0004    based on kspread csv export filter by David Faure
0005 
0006    SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef HTMLEXPORT_TEST_H
0010 #define HTMLEXPORT_TEST_H
0011 
0012 #include <KoFilter.h>
0013 #include <QByteArray>
0014 #include <QLoggingCategory>
0015 #include <QVariantList>
0016 
0017 class ExportDialog;
0018 class KoDocument;
0019 
0020 namespace Calligra
0021 {
0022 namespace Sheets
0023 {
0024 class Sheet;
0025 }
0026 }
0027 
0028 Q_DECLARE_LOGGING_CATEGORY(lcHtml)
0029 
0030 class HTMLExport : public KoFilter
0031 {
0032     Q_OBJECT
0033 public:
0034     HTMLExport(QObject* parent, const QVariantList&);
0035     ~HTMLExport() override;
0036 
0037     KoFilter::ConversionStatus convert(const QByteArray& from, const QByteArray& to) override;
0038 private:
0039     /** Writes the top of the page in HTML to @par str */
0040     void openPage(Calligra::Sheets::Sheet *sheet, KoDocument *document, QString &str);
0041 
0042     /** Closes a page in HTML */
0043     void closePage(QString &);
0044 
0045     /**
0046       Converts @par sheet to HTML and writes to @par str.
0047      */
0048     void convertSheet(Calligra::Sheets::Sheet *sheet, QString &str, int, int);
0049 
0050     /** Writes a bar and a link to the top to @par str. */
0051     void createSheetSeparator(QString &);
0052 
0053     /** Writes the table of contents */
0054     void writeTOC(const QStringList &, const QString &, QString &);
0055 
0056     /**
0057       Returns a filename based on the @par base filename and the options
0058       defined in the dialog.
0059     */
0060     QString fileName(const QString &base, const QString &, bool);
0061 
0062     /**
0063       Detects which rows and columns of the given @par sheet are used and
0064       writes the number of them to @par row and @par column.
0065      */
0066     void detectFilledCells(Calligra::Sheets::Sheet *sheet, int &rows, int &columns);
0067 private:
0068     ExportDialog *m_dialog;
0069 
0070     typedef QMap<QString, int> Rows;
0071     Rows m_rowmap;
0072     typedef QMap<QString, int> Columns;
0073     Columns m_columnmap;
0074 };
0075 
0076 #endif
0077