File indexing completed on 2024-04-28 16:21:26
0001 /* This file is part of the KDE project 0002 Copyright 2006-2007 Stefan Nikolaus <stefan.nikolaus@kdemail.net> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef CALLIGRA_SHEETS_RECALC_MANAGER 0021 #define CALLIGRA_SHEETS_RECALC_MANAGER 0022 0023 #include <Region.h> 0024 0025 #include <QObject> 0026 0027 class KoUpdater; 0028 0029 namespace Calligra 0030 { 0031 namespace Sheets 0032 { 0033 class Cell; 0034 class Map; 0035 class Sheet; 0036 0037 /** 0038 * \class RecalcManager 0039 * \brief Manages the recalculations of cells containing a formula. 0040 * \ingroup Value 0041 * 0042 * The recalculations of a cell region, a sheet or the map are based 0043 * on the following principle: 0044 * 0045 * A cell could refer to other cells, which need to be recalculated 0046 * before. The order of recalculation is determined by the depth of 0047 * references, i.e. first the cells, which do not refer to other cells, 0048 * are recalculated. Cells referring to those are next. Then cells, which 0049 * refer to the ones in the last step follow and so on until all cells 0050 * have been updated. 0051 * 0052 * Cell value changes are blocked while doing this, i.e. they do not 0053 * trigger a new recalculation event. 0054 */ 0055 class CALLIGRA_SHEETS_ODF_EXPORT RecalcManager : public QObject 0056 { 0057 Q_OBJECT 0058 public: 0059 /** 0060 * Creates a RecalcManager. It is used for a whole map. 0061 * 0062 * \param map The Map which this RecalcManager belongs to. 0063 */ 0064 explicit RecalcManager(Map *const map); 0065 0066 /** 0067 * Destructor. 0068 */ 0069 ~RecalcManager() override; 0070 0071 /** 0072 * Recalculates the cells referring to cells in \p region . 0073 * The cells are recalculated sorted by the reference depth in ascending order. 0074 * 0075 * \see recalc() 0076 */ 0077 void regionChanged(const Region& region); 0078 0079 /** 0080 * Recalculates the sheet \p sheet . 0081 * The cells are recalculated sorted by the reference depth in ascending order. 0082 * 0083 * \see recalc() 0084 */ 0085 void recalcSheet(Sheet* const sheet); 0086 0087 /** 0088 * Recalculates the whole map. 0089 * The cells are recalculated sorted by the reference depth in ascending order. 0090 * 0091 * \see recalc() 0092 */ 0093 void recalcMap(KoUpdater *updater = 0); 0094 0095 /** 0096 * Returns the recalculation state. 0097 * \return \c true, if recalculations are in progress 0098 */ 0099 bool isActive() const; 0100 0101 /** 0102 * Prints out the cell depths in the current recalculation event. 0103 */ 0104 void dump() const; 0105 0106 public Q_SLOTS: 0107 /** 0108 * Called after a sheet was added. 0109 */ 0110 void addSheet(Sheet *sheet); 0111 0112 /** 0113 * Called after a sheet was removed. 0114 */ 0115 void removeSheet(Sheet *sheet); 0116 0117 protected: 0118 /** 0119 * Iterates over the map of cell with their reference depths 0120 * and calls recalcCell(). 0121 * 0122 * \see recalcCell() 0123 */ 0124 void recalc(KoUpdater *updater = 0); 0125 0126 private: 0127 Q_DISABLE_COPY(RecalcManager) 0128 0129 class Private; 0130 Private * const d; 0131 }; 0132 0133 } // namespace Sheets 0134 } // namespace Calligra 0135 0136 #endif // CALLIGRA_SHEETS_RECALC_MANAGER