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 HTMLIMPORT_H
0023 #define HTMLIMPORT_H
0024 
0025 #include <QObject>
0026 #include <KoFilter.h>
0027 #include <QDir>
0028 #include <QUrl>
0029 #include <QByteArray>
0030 #include <QStack>
0031 #include <QVariantList>
0032 
0033 // namespace Calligra::Sheets
0034 // {
0035 // class Sheet;
0036 // }
0037 
0038 namespace DOM
0039 {
0040     class Node;
0041     class Element;
0042 }
0043 
0044 class KoOdfWriteStore;
0045 class KoXmlWriter;
0046 class KoGenStyles;
0047 
0048 class HTMLImport : public KoFilter
0049 {
0050     Q_OBJECT
0051 public:
0052     HTMLImport(QObject* parent, const QVariantList&);
0053     virtual ~HTMLImport();
0054 
0055     KoFilter::ConversionStatus convert(const QByteArray& from, const QByteArray& to) override;
0056 
0057 Q_SIGNALS:
0058     void completed();
0059 
0060 private:
0061     KoFilter::ConversionStatus loadUrl(const QUrl &url);
0062     void parseNode(DOM::Node n);
0063     bool parseTag(DOM::Element e);
0064     bool createStyle();
0065     bool createMeta();
0066 private:
0067     enum State { InNone, InFrameset, InBody, InTable, InRow, InCell };
0068     QStack<State> m_states;
0069     
0070     QDir m_inputDir;    
0071     KoOdfWriteStore* m_store;
0072     KoXmlWriter* m_manifestWriter;
0073     KoGenStyles* m_mainStyles;
0074 };
0075 
0076 #endif
0077