File indexing completed on 2025-01-19 13:27:30
0001 /* 0002 This file is part of the KDE project 0003 Copyright (C) 2002 Fred Malabre <fmalabre@yahoo.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 KSPREAD_LEADER_H 0022 #define KSPREAD_LEADER_H 0023 0024 #include <kspreadbaseworker.h.h> 0025 #include <KoFilterChain.h> 0026 #include <kdebug.h> 0027 #include <kspread_doc.h> 0028 #include <KoDocumentInfo.h> 0029 #include <kspread_map.h> 0030 0031 namespace KSpread 0032 { 0033 0034 /** 0035 * This class is a leader which will call the callbacks 0036 * to the worker with your own implementation for your export filter. 0037 * 0038 * To write an export filter, just instantiate a leader and 0039 * implement you own worker based on the BaseWorker. 0040 * 0041 * @short A Leader for an KSpread export filter 0042 * @author Fred Malabre 0043 * @see KSpreadBaseWorker 0044 * @see KoFilter 0045 */ 0046 class Leader 0047 { 0048 public: 0049 /** 0050 * Default constructor. 0051 * Call setWorker() before starting to convert the KSpread document. 0052 * 0053 * @param filterChain the filter chain of the filter using the lib. 0054 */ 0055 explicit Leader(KoFilterChain *filterChain); 0056 0057 /** 0058 * This constructor set up the Worker at initialization. 0059 * convert can be called right away after instantiation of the Leader. 0060 * 0061 * @param filterChain the filter chain of the filter using the lib. 0062 * @param newWorker implementation of a class derived from KSpreadWorker. 0063 */ 0064 Leader(KoFilterChain *filterChain, KSpreadBaseWorker *newWorker); 0065 0066 /** 0067 * Default destructor. 0068 * It does nothing. 0069 */ 0070 virtual ~Leader(); 0071 0072 private: 0073 KSpreadBaseWorker *m_worker; 0074 KoFilterChain *m_filterChain; 0075 int m_maxCellColumn; 0076 int m_maxCellRow; 0077 void updateMaxCells(KSpreadSheet *spreadSheet); 0078 0079 protected: 0080 KSpreadBaseWorker *getWorker() const; 0081 KoFilter::ConversionStatus doSpreadCell(const Cell& spreadCell, int column, int row); 0082 KoFilter::ConversionStatus doSpreadSheet(Sheet *spreadSheet); 0083 KoFilter::ConversionStatus doSpreadBook(Doc *document); 0084 KoFilter::ConversionStatus doInfo(KoDocumentInfo *info); 0085 0086 public: 0087 /** 0088 * Set your own implementation of the Worker. 0089 * 0090 * @param newWorker implementation of a class derived from KSpreadWorker. 0091 */ 0092 void setWorker(KSpreadBaseWorker *newWorker); 0093 0094 /** 0095 * Start the conversion process. 0096 * The callbacks of your Worker will be called at this time. 0097 * 0098 * @return status of the conversion. 0099 */ 0100 KoFilter::ConversionStatus convert(); 0101 }; 0102 0103 } // namespace KSpread 0104 0105 #endif /* KSPREAD_LEADER_H */