File indexing completed on 2024-04-28 16:21:21
0001 /* This file is part of the KDE project 0002 Copyright 2006-2007 Stefan Nikolaus <stefan.nikolaus@kdemail.net> 0003 Copyright 2004 Ariya Hidayat <ariya@kde.org> 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; only 0008 version 2 of the License. 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 CALLIGRA_SHEETS_DAMAGES 0022 #define CALLIGRA_SHEETS_DAMAGES 0023 0024 #include "sheets_odf_export.h" 0025 0026 #include <QDebug> 0027 0028 namespace Calligra 0029 { 0030 namespace Sheets 0031 { 0032 class Cell; 0033 class Map; 0034 class Sheet; 0035 class Region; 0036 0037 /** 0038 * \ingroup Damages 0039 * An abstract damage. 0040 */ 0041 class CALLIGRA_SHEETS_ODF_EXPORT Damage 0042 { 0043 public: 0044 virtual ~Damage() {} 0045 0046 typedef enum { 0047 Nothing = 0, 0048 Document, 0049 Workbook, 0050 Sheet, 0051 Range, 0052 Cell, 0053 Selection 0054 } Type; 0055 0056 virtual Type type() const { 0057 return Nothing; 0058 } 0059 }; 0060 0061 /** 0062 * \ingroup Damages 0063 * A cell range damage. 0064 */ 0065 class CALLIGRA_SHEETS_ODF_EXPORT CellDamage : public Damage 0066 { 0067 public: 0068 enum Change { 0069 Binding = 0x02, ///< on value changes; always triggered; for binding updates 0070 Formula = 0x04, ///< triggers a dependency update 0071 NamedArea = 0x10, ///< triggers a named area update 0072 /// This indicates a value change. It is not triggered while a recalculation is in progress. 0073 /// RecalcManager takes over in this case. Otherwise, circular dependencies would cause 0074 /// infinite loops and the cells would be recalculated in arbitrary order. 0075 Value = 0x20, 0076 /// On style changes; invalidates the style storage cache. 0077 StyleCache = 0x40, 0078 /// The visual cache gets damaged, if any of CellView's data members is 0079 /// affected. E.g. the displayed text, the cell dimension or the merging. 0080 VisualCache = 0x80, 0081 // TODO Stefan: Detach the style cache from the CellView cache. 0082 /// Updates the caches and triggers a repaint of the cell region. 0083 Appearance = StyleCache | VisualCache 0084 }; 0085 Q_DECLARE_FLAGS(Changes, Change) 0086 0087 CellDamage(const Calligra::Sheets::Cell& cell, Changes changes); 0088 CellDamage(Calligra::Sheets::Sheet* sheet, const Region& region, Changes changes); 0089 0090 ~CellDamage() override; 0091 0092 Type type() const override { 0093 return Damage::Cell; 0094 } 0095 0096 Calligra::Sheets::Sheet* sheet() const; 0097 const Region& region() const; 0098 0099 Changes changes() const; 0100 0101 private: 0102 Q_DISABLE_COPY(CellDamage) 0103 0104 class Private; 0105 Private * const d; 0106 }; 0107 Q_DECLARE_OPERATORS_FOR_FLAGS(CellDamage::Changes) 0108 0109 0110 /** 0111 * \ingroup Damages 0112 * A sheet damage. 0113 */ 0114 class CALLIGRA_SHEETS_ODF_EXPORT SheetDamage : public Damage 0115 { 0116 public: 0117 0118 enum Change { 0119 None = 0x00, 0120 ContentChanged = 0x01, 0121 PropertiesChanged = 0x02, 0122 Hidden = 0x04, 0123 Shown = 0x08, 0124 Name = 0x10, 0125 ColumnsChanged = 0x20, 0126 RowsChanged = 0x40 0127 }; 0128 Q_DECLARE_FLAGS(Changes, Change) 0129 0130 SheetDamage(Calligra::Sheets::Sheet* sheet, Changes changes); 0131 0132 ~SheetDamage() override; 0133 0134 Type type() const override { 0135 return Damage::Sheet; 0136 } 0137 0138 Calligra::Sheets::Sheet* sheet() const; 0139 0140 Changes changes() const; 0141 0142 private: 0143 Q_DISABLE_COPY(SheetDamage) 0144 0145 class Private; 0146 Private * const d; 0147 }; 0148 Q_DECLARE_OPERATORS_FOR_FLAGS(SheetDamage::Changes) 0149 0150 0151 /** 0152 * \ingroup Damages 0153 * A workbook damage. 0154 */ 0155 class WorkbookDamage : public Damage 0156 { 0157 public: 0158 enum Change { 0159 None = 0x00, 0160 Formula = 0x01, 0161 Value = 0x02 0162 }; 0163 Q_DECLARE_FLAGS(Changes, Change) 0164 0165 WorkbookDamage(Calligra::Sheets::Map* map, Changes changes); 0166 ~WorkbookDamage() override; 0167 0168 Type type() const override { 0169 return Damage::Workbook; 0170 } 0171 Calligra::Sheets::Map* map() const; 0172 Changes changes() const; 0173 0174 private: 0175 Q_DISABLE_COPY(WorkbookDamage) 0176 0177 class Private; 0178 Private * const d; 0179 }; 0180 Q_DECLARE_OPERATORS_FOR_FLAGS(WorkbookDamage::Changes) 0181 0182 0183 /** 0184 * \ingroup Damages 0185 * A selection damage. 0186 */ 0187 class CALLIGRA_SHEETS_ODF_EXPORT SelectionDamage : public Damage 0188 { 0189 public: 0190 explicit SelectionDamage(const Region ®ion); 0191 ~SelectionDamage() override; 0192 0193 Type type() const override { 0194 return Damage::Selection; 0195 } 0196 0197 const Region& region() const; 0198 0199 private: 0200 Q_DISABLE_COPY(SelectionDamage) 0201 0202 class Private; 0203 Private * const d; 0204 }; 0205 0206 } // namespace Sheets 0207 } // namespace Calligra 0208 0209 0210 /*************************************************************************** 0211 QDebug support 0212 ****************************************************************************/ 0213 0214 CALLIGRA_SHEETS_ODF_EXPORT QDebug operator<<(QDebug str, const Calligra::Sheets::Damage& d); 0215 CALLIGRA_SHEETS_ODF_EXPORT QDebug operator<<(QDebug str, const Calligra::Sheets::CellDamage& d); 0216 CALLIGRA_SHEETS_ODF_EXPORT QDebug operator<<(QDebug str, const Calligra::Sheets::SheetDamage& d); 0217 CALLIGRA_SHEETS_ODF_EXPORT QDebug operator<<(QDebug str, const Calligra::Sheets::SelectionDamage& d); 0218 0219 #endif // CALLIGRA_SHEETS_DAMAGES