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 | |
25 | #include "kdebug.h" |
26 | |
27 | #include "calligra_sheets_export.h" |
28 | |
29 | namespace Calligra |
30 | { |
31 | namespace Sheets |
32 | { |
33 | class Cell; |
34 | class Map; |
35 | class Sheet; |
36 | class Region; |
37 | |
38 | /** |
39 | * \ingroup Damages |
40 | * An abstract damage. |
41 | */ |
42 | class CALLIGRA_SHEETS_ODF_EXPORT Damage |
43 | { |
44 | public: |
45 | virtual ~Damage() {} |
46 | |
47 | typedef enum { |
48 | Nothing = 0, |
49 | Document, |
50 | Workbook, |
51 | Sheet, |
52 | Range, |
53 | Cell, |
54 | Selection |
55 | } Type; |
56 | |
57 | virtual Type type() const { |
58 | return Nothing; |
59 | } |
60 | }; |
61 | |
62 | /** |
63 | * \ingroup Damages |
64 | * A cell range damage. |
65 | */ |
66 | class CALLIGRA_SHEETS_ODF_EXPORT CellDamage : public Damage |
67 | { |
68 | public: |
69 | enum Change { |
70 | Binding = 0x02, ///< on value changes; always triggered; for binding updates |
71 | Formula = 0x04, ///< triggers a dependency update |
72 | NamedArea = 0x10, ///< triggers a named area update |
73 | /// This indicates a value change. It is not triggered while a recalculation is in progress. |
74 | /// RecalcManager takes over in this case. Otherwise, circular dependencies would cause |
75 | /// infinite loops and the cells would be recalculated in arbitrary order. |
76 | Value = 0x20, |
77 | /// On style changes; invalidates the style storage cache. |
78 | StyleCache = 0x40, |
79 | /// The visual cache gets damaged, if any of CellView's data members is |
80 | /// affected. E.g. the displayed text, the cell dimension or the merging. |
81 | VisualCache = 0x80, |
82 | // TODO Stefan: Detach the style cache from the CellView cache. |
83 | /// Updates the caches and triggers a repaint of the cell region. |
84 | Appearance = StyleCache | VisualCache |
85 | }; |
86 | Q_DECLARE_FLAGS(Changes, Change) |
87 | |
88 | CellDamage(const Calligra::Sheets::Cell& cell, Changes changes); |
89 | CellDamage(Calligra::Sheets::Sheet* sheet, const Region& region, Changes changes); |
90 | |
91 | virtual ~CellDamage(); |
92 | |
93 | virtual Type type() const { |
94 | return Damage::Cell; |
95 | } |
96 | |
97 | Calligra::Sheets::Sheet* sheet() const; |
98 | const Region& region() const; |
99 | |
100 | Changes changes() const; |
101 | |
102 | private: |
103 | Q_DISABLE_COPY(CellDamage) |
104 | |
105 | class Private; |
106 | Private * const d; |
107 | }; |
108 | Q_DECLARE_OPERATORS_FOR_FLAGS(CellDamage::Changes) |
109 | |
110 | |
111 | /** |
112 | * \ingroup Damages |
113 | * A sheet damage. |
114 | */ |
115 | class CALLIGRA_SHEETS_ODF_EXPORT SheetDamage : public Damage |
116 | { |
117 | public: |
118 | |
119 | enum Change { |
120 | None = 0x00, |
121 | ContentChanged = 0x01, |
122 | PropertiesChanged = 0x02, |
123 | Hidden = 0x04, |
124 | Shown = 0x08, |
125 | Name = 0x10, |
126 | ColumnsChanged = 0x20, |
127 | RowsChanged = 0x40 |
128 | }; |
129 | Q_DECLARE_FLAGS(Changes, Change) |
130 | |
131 | SheetDamage(Calligra::Sheets::Sheet* sheet, Changes changes); |
132 | |
133 | virtual ~SheetDamage(); |
134 | |
135 | virtual Type type() const { |
136 | return Damage::Sheet; |
137 | } |
138 | |
139 | Calligra::Sheets::Sheet* sheet() const; |
140 | |
141 | Changes changes() const; |
142 | |
143 | private: |
144 | Q_DISABLE_COPY(SheetDamage) |
145 | |
146 | class Private; |
147 | Private * const d; |
148 | }; |
149 | Q_DECLARE_OPERATORS_FOR_FLAGS(SheetDamage::Changes) |
150 | |
151 | |
152 | /** |
153 | * \ingroup Damages |
154 | * A workbook damage. |
155 | */ |
156 | class WorkbookDamage : public Damage |
157 | { |
158 | public: |
159 | enum Change { |
160 | None = 0x00, |
161 | Formula = 0x01, |
162 | Value = 0x02 |
163 | }; |
164 | Q_DECLARE_FLAGS(Changes, Change) |
165 | |
166 | WorkbookDamage(Calligra::Sheets::Map* map, Changes changes); |
167 | virtual ~WorkbookDamage(); |
168 | |
169 | virtual Type type() const { |
170 | return Damage::Workbook; |
171 | } |
172 | Calligra::Sheets::Map* map() const; |
173 | Changes changes() const; |
174 | |
175 | private: |
176 | Q_DISABLE_COPY(WorkbookDamage) |
177 | |
178 | class Private; |
179 | Private * const d; |
180 | }; |
181 | Q_DECLARE_OPERATORS_FOR_FLAGS(WorkbookDamage::Changes) |
182 | |
183 | |
184 | /** |
185 | * \ingroup Damages |
186 | * A selection damage. |
187 | */ |
188 | class CALLIGRA_SHEETS_ODF_EXPORT SelectionDamage : public Damage |
189 | { |
190 | public: |
191 | explicit SelectionDamage(const Region ®ion); |
192 | virtual ~SelectionDamage(); |
193 | |
194 | virtual Type type() const { |
195 | return Damage::Selection; |
196 | } |
197 | |
198 | const Region& region() const; |
199 | |
200 | private: |
201 | Q_DISABLE_COPY(SelectionDamage) |
202 | |
203 | class Private; |
204 | Private * const d; |
205 | }; |
206 | |
207 | } // namespace Sheets |
208 | } // namespace Calligra |
209 | |
210 | |
211 | /*************************************************************************** |
212 | kDebug support |
213 | ****************************************************************************/ |
214 | |
215 | CALLIGRA_SHEETS_ODF_EXPORT QDebug operator<<(QDebug str, const Calligra::Sheets::Damage& d); |
216 | CALLIGRA_SHEETS_ODF_EXPORT QDebug operator<<(QDebug str, const Calligra::Sheets::CellDamage& d); |
217 | CALLIGRA_SHEETS_ODF_EXPORT QDebug operator<<(QDebug str, const Calligra::Sheets::SheetDamage& d); |
218 | CALLIGRA_SHEETS_ODF_EXPORT QDebug operator<<(QDebug str, const Calligra::Sheets::SelectionDamage& d); |
219 | |
220 | #endif // CALLIGRA_SHEETS_DAMAGES |
221 | |