summaryrefslogtreecommitdiffstats
path: root/filters/kspread/libkspreadexport/KSpreadLeader.h
blob: eee950b921b162b7fe7be3e93467c89ecb01794a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
This file is part of the KDE project
Copyright (C) 2002 Fred Malabre <fmalabre@yahoo.com>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB.  If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef KSPREAD_LEADER_H
#define KSPREAD_LEADER_H

#include <KSpreadBaseWorker.h>
#include <KoFilterChain.h>
#include <kdebug.h>
#include <kspread_doc.h>
#include <KoDocumentInfo.h>
#include <kspread_map.h>

namespace KSpread
{

/**
* This class is a leader which will call the callbacks
* to the worker with your own implementation for your export filter.
*
* To write an export filter, just instanciate a leader and
* implement you own worker based on the BaseWorker.
*
* @short A Leader for an KSpread export filter
* @author Fred Malabre
* @see KSpreadBaseWorker
* @see KoFilter
*/
class Leader
{
public:
	/**
	* Default constructor.
	* Call setWorker() before starting to convert the KSpread document.
	*
	* @param the filter chain of the filter using the lib.
	*/
	Leader(KoFilterChain *filterChain);

	/**
	* This constructor set up the Worker at initialization.
	* convert can be called right away after instanciation of the Leader.
	*
	* @param the filter chain of the filter using the lib.
	* @param implementation of a class derived from KSpreadWorker.
	*/
	Leader(KoFilterChain *filterChain, KSpreadBaseWorker *newWorker);

	/**
	* Default destructor.
	* It does nothing.
	*/
	virtual ~Leader();

private:
	KSpreadBaseWorker *m_worker;
	KoFilterChain *m_filterChain;
	int m_maxCellColumn;
	int m_maxCellRow;
	void updateMaxCells(KSpreadSheet *spreadSheet);

protected:
	KSpreadBaseWorker *getWorker() const;
	KoFilter::ConversionStatus doSpreadCell(Cell *spreadCell, int column, int row);
	KoFilter::ConversionStatus doSpreadSheet(Sheet *spreadSheet);
	KoFilter::ConversionStatus doSpreadBook(Doc *document);
	KoFilter::ConversionStatus doInfo(KoDocumentInfo *info);

public:
	/**
	* Set your own implementation of the Worker.
	*
	* @param implementation of a class derived from KSpreadWorker.
	*/
	void setWorker(KSpreadBaseWorker *newWorker);

	/**
	* Start the conversion process.
	* The callbacks of your Worker will be called at this time.
	*
	* @return status of the conversion.
	*/
	KoFilter::ConversionStatus convert();
};

} // namespace KSpread

#endif /* KSPREAD_LEADER_H */