File indexing completed on 2025-01-19 13:27:31
0001 /* This file is part of the KDE project 0002 Copyright (C) 2000 - 2003 David Faure <faure@kde.org> 0003 Copyright (C) 2003 Norbert Andres <nandres@web.de> 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 OPENCALCEXPORT_H 0022 #define OPENCALCEXPORT_H 0023 0024 #include "opencalcstyleexport.h" 0025 0026 #include <KoFilter.h> 0027 #include <QByteArray> 0028 #include <QVariantList> 0029 0030 class QDomDocument; 0031 class QDomElement; 0032 class KLocale; 0033 class KoStore; 0034 0035 namespace Calligra 0036 { 0037 namespace Sheets 0038 { 0039 class Doc; 0040 class Sheet; 0041 } 0042 } 0043 0044 class OpenCalcExport : public KoFilter 0045 { 0046 Q_OBJECT 0047 0048 public: 0049 OpenCalcExport(QObject* parent, const QVariantList &); 0050 ~OpenCalcExport() override {} 0051 0052 KoFilter::ConversionStatus convert(const QByteArray & from, 0053 const QByteArray & to) override; 0054 0055 private: 0056 enum files { metaXML = 0x01, contentXML = 0x02, stylesXML = 0x04, settingsXML = 0x08 }; 0057 OpenCalcStyles m_styles; 0058 0059 bool writeFile(const Calligra::Sheets::Doc * ksdoc); 0060 0061 bool exportDocInfo(KoStore * store, const Calligra::Sheets::Doc * ksdoc); 0062 bool exportStyles(KoStore * store, const Calligra::Sheets::Doc * ksdoc); 0063 bool exportContent(KoStore * store, const Calligra::Sheets::Doc * ksdoc); 0064 bool exportSettings(KoStore * store, const Calligra::Sheets::Doc * ksdoc); 0065 0066 bool exportBody(QDomDocument & doc, QDomElement & content, const Calligra::Sheets::Doc * ksdoc); 0067 void exportSheet(QDomDocument & doc, QDomElement & tabElem, 0068 const Calligra::Sheets::Sheet * sheet, int maxCols, int maxRows); 0069 void exportCells(QDomDocument & doc, QDomElement & rowElem, 0070 const Calligra::Sheets::Sheet * sheet, int row, int maxCols); 0071 void exportDefaultCellStyle(QDomDocument & doc, QDomElement & officeStyles); 0072 void exportPageAutoStyles(QDomDocument & doc, QDomElement & autoStyles, 0073 const Calligra::Sheets::Doc * ksdoc); 0074 void exportMasterStyles(QDomDocument & doc, QDomElement & masterStyles, 0075 const Calligra::Sheets::Doc *ksdoc); 0076 0077 bool writeMetaFile(KoStore * store, uint filesWritten); 0078 0079 void convertPart(QString const & part, QDomDocument & doc, 0080 QDomElement & parent, const Calligra::Sheets::Doc * ksdoc); 0081 void addText(QString const & text, QDomDocument & doc, 0082 QDomElement & parent); 0083 0084 void createDefaultStyles(); 0085 QString convertFormula(QString const & formula) const; 0086 private: 0087 /// Pointer to the Calligra::Sheets locale 0088 KLocale* m_locale; 0089 }; 0090 0091 #endif