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
106
107
108
109
110
111
112
113
114
|
/* This file is part of the KDE project
Copyright (C) 2006 Tomas Mecir <mecirt@gmail.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.
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_MANIPULATOR_DATA
#define KSPREAD_MANIPULATOR_DATA
#include "manipulator.h"
#include "kspread_global.h"
#include "kspread_value.h"
namespace KSpread {
/**
* AbstractDataManipulator - provides storage of old cell data (for undo)
* and has an abstract method for the actual setting of new values
*/
struct ADMStorage {
Value val;
TQString text;
FormatType format;
};
class AbstractDataManipulator : public Manipulator {
public:
AbstractDataManipulator ();
virtual ~AbstractDataManipulator ();
virtual bool process (Element* element);
/** this abstract method should return a value that will be set
for a given cell */
protected:
/** Return new value. row/col are relative to sheet, not element.
If the function sets *parse to true, the value will be treated as an
user-entered string and parsed by Cell. */
virtual Value newValue (Element *element, int col, int row,
bool *parse, FormatType *fmtType) = 0;
/** preProcessing will store the old cell's data */
virtual bool preProcessing ();
TQMap<int, TQMap<int, ADMStorage> > oldData;
};
/**
* DataManipulator - allows setting values on one range.
* If multiple ranges are selected, they all get set to the same values
*/
class DataManipulator : public AbstractDataManipulator {
public:
DataManipulator ();
virtual ~DataManipulator ();
void setParsing (bool val) { m_parsing = val; };
/** set the values for the range. Can be either a single value, or
a value array */
void setValue (Value val) { data = val; };
/** If set, all cells shall be switched to this format. Will do
nothing if parsing is true. */
void setFormat (FormatType fmtType) { m_format = fmtType; };
protected:
virtual Value newValue (Element *element, int col, int row, bool *,
FormatType *);
Value data;
FormatType m_format;
bool m_parsing : 1;
};
class ArrayFormulaManipulator : public AbstractDataManipulator {
public:
ArrayFormulaManipulator ();
virtual ~ArrayFormulaManipulator ();
void setText (const TQString text) { m_text = text; };
protected:
virtual Value newValue (Element *element, int col, int row, bool *,
FormatType *);
TQString cellRef, m_text;
};
/** class ProtectedCheck can be used to check, whether a particular
range is protected or not */
class ProtectedCheck : public Region {
public:
ProtectedCheck ();
virtual ~ProtectedCheck ();
void setSheet (Sheet *sheet) { m_sheet = sheet; };
bool check ();
protected:
Sheet *m_sheet;
};
} // namespace KSpread
#endif // KSPREAD_MANIPULATOR_DATA
|