1 /* This file is part of the KDE project
2 Copyright 2006-2007 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
3 Copyright 2004 Ariya Hidayat <ariya@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; only
8 version 2 of the License.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19 */
20
21 #ifndef CALLIGRA_SHEETS_DAMAGES
22 #define CALLIGRA_SHEETS_DAMAGES
23
24 #include "sheets_odf_export.h"
25
26 #include <QDebug>
27
28 namespace Calligra
29 {
30 namespace Sheets
31 {
32 class Cell;
33 class Map;
34 class Sheet;
35 class Region;
36
37 /**
38 * \ingroup Damages
39 * An abstract damage.
40 */
41 class CALLIGRA_SHEETS_ODF_EXPORT Damage
42 {
43 public:
~Damage()44 virtual ~Damage() {}
45
46 typedef enum {
47 Nothing = 0,
48 Document,
49 Workbook,
50 Sheet,
51 Range,
52 Cell,
53 Selection
54 } Type;
55
type()56 virtual Type type() const {
57 return Nothing;
58 }
59 };
60
61 /**
62 * \ingroup Damages
63 * A cell range damage.
64 */
65 class CALLIGRA_SHEETS_ODF_EXPORT CellDamage : public Damage
66 {
67 public:
68 enum Change {
69 Binding = 0x02, ///< on value changes; always triggered; for binding updates
70 Formula = 0x04, ///< triggers a dependency update
71 NamedArea = 0x10, ///< triggers a named area update
72 /// This indicates a value change. It is not triggered while a recalculation is in progress.
73 /// RecalcManager takes over in this case. Otherwise, circular dependencies would cause
74 /// infinite loops and the cells would be recalculated in arbitrary order.
75 Value = 0x20,
76 /// On style changes; invalidates the style storage cache.
77 StyleCache = 0x40,
78 /// The visual cache gets damaged, if any of CellView's data members is
79 /// affected. E.g. the displayed text, the cell dimension or the merging.
80 VisualCache = 0x80,
81 // TODO Stefan: Detach the style cache from the CellView cache.
82 /// Updates the caches and triggers a repaint of the cell region.
83 Appearance = StyleCache | VisualCache
84 };
85 Q_DECLARE_FLAGS(Changes, Change)
86
87 CellDamage(const Calligra::Sheets::Cell& cell, Changes changes);
88 CellDamage(Calligra::Sheets::Sheet* sheet, const Region& region, Changes changes);
89
90 ~CellDamage() override;
91
type()92 Type type() const override {
93 return Damage::Cell;
94 }
95
96 Calligra::Sheets::Sheet* sheet() const;
97 const Region& region() const;
98
99 Changes changes() const;
100
101 private:
102 Q_DISABLE_COPY(CellDamage)
103
104 class Private;
105 Private * const d;
106 };
Q_DECLARE_OPERATORS_FOR_FLAGS(CellDamage::Changes)107 Q_DECLARE_OPERATORS_FOR_FLAGS(CellDamage::Changes)
108
109
110 /**
111 * \ingroup Damages
112 * A sheet damage.
113 */
114 class CALLIGRA_SHEETS_ODF_EXPORT SheetDamage : public Damage
115 {
116 public:
117
118 enum Change {
119 None = 0x00,
120 ContentChanged = 0x01,
121 PropertiesChanged = 0x02,
122 Hidden = 0x04,
123 Shown = 0x08,
124 Name = 0x10,
125 ColumnsChanged = 0x20,
126 RowsChanged = 0x40
127 };
128 Q_DECLARE_FLAGS(Changes, Change)
129
130 SheetDamage(Calligra::Sheets::Sheet* sheet, Changes changes);
131
132 ~SheetDamage() override;
133
134 Type type() const override {
135 return Damage::Sheet;
136 }
137
138 Calligra::Sheets::Sheet* sheet() const;
139
140 Changes changes() const;
141
142 private:
143 Q_DISABLE_COPY(SheetDamage)
144
145 class Private;
146 Private * const d;
147 };
Q_DECLARE_OPERATORS_FOR_FLAGS(SheetDamage::Changes)148 Q_DECLARE_OPERATORS_FOR_FLAGS(SheetDamage::Changes)
149
150
151 /**
152 * \ingroup Damages
153 * A workbook damage.
154 */
155 class WorkbookDamage : public Damage
156 {
157 public:
158 enum Change {
159 None = 0x00,
160 Formula = 0x01,
161 Value = 0x02
162 };
163 Q_DECLARE_FLAGS(Changes, Change)
164
165 WorkbookDamage(Calligra::Sheets::Map* map, Changes changes);
166 ~WorkbookDamage() override;
167
168 Type type() const override {
169 return Damage::Workbook;
170 }
171 Calligra::Sheets::Map* map() const;
172 Changes changes() const;
173
174 private:
175 Q_DISABLE_COPY(WorkbookDamage)
176
177 class Private;
178 Private * const d;
179 };
Q_DECLARE_OPERATORS_FOR_FLAGS(WorkbookDamage::Changes)180 Q_DECLARE_OPERATORS_FOR_FLAGS(WorkbookDamage::Changes)
181
182
183 /**
184 * \ingroup Damages
185 * A selection damage.
186 */
187 class CALLIGRA_SHEETS_ODF_EXPORT SelectionDamage : public Damage
188 {
189 public:
190 explicit SelectionDamage(const Region ®ion);
191 ~SelectionDamage() override;
192
193 Type type() const override {
194 return Damage::Selection;
195 }
196
197 const Region& region() const;
198
199 private:
200 Q_DISABLE_COPY(SelectionDamage)
201
202 class Private;
203 Private * const d;
204 };
205
206 } // namespace Sheets
207 } // namespace Calligra
208
209
210 /***************************************************************************
211 QDebug support
212 ****************************************************************************/
213
214 CALLIGRA_SHEETS_ODF_EXPORT QDebug operator<<(QDebug str, const Calligra::Sheets::Damage& d);
215 CALLIGRA_SHEETS_ODF_EXPORT QDebug operator<<(QDebug str, const Calligra::Sheets::CellDamage& d);
216 CALLIGRA_SHEETS_ODF_EXPORT QDebug operator<<(QDebug str, const Calligra::Sheets::SheetDamage& d);
217 CALLIGRA_SHEETS_ODF_EXPORT QDebug operator<<(QDebug str, const Calligra::Sheets::SelectionDamage& d);
218
219 #endif // CALLIGRA_SHEETS_DAMAGES
220