1 | /* This file is part of the KDE project |
2 | Copyright 2007 Stefan Nikolaus <stefan.nikolaus@kdemail.net> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef CALLIGRA_SHEETS_NAMED_AREA_MANAGER |
21 | #define CALLIGRA_SHEETS_NAMED_AREA_MANAGER |
22 | |
23 | #include <QList> |
24 | #include <QObject> |
25 | |
26 | #include <KoXmlReader.h> |
27 | |
28 | #include "Region.h" |
29 | |
30 | #include "calligra_sheets_export.h" |
31 | |
32 | class QDomDocument; |
33 | class QString; |
34 | |
35 | class KoXmlWriter; |
36 | |
37 | namespace Calligra |
38 | { |
39 | namespace Sheets |
40 | { |
41 | class Map; |
42 | class Region; |
43 | |
44 | /** |
45 | * Manages named cell areas. |
46 | */ |
47 | class CALLIGRA_SHEETS_ODF_EXPORT NamedAreaManager : public QObject |
48 | { |
49 | Q_OBJECT |
50 | |
51 | public: |
52 | /** |
53 | * Constructor. |
54 | */ |
55 | explicit NamedAreaManager(const Map *map); |
56 | |
57 | /** |
58 | * Destructor. |
59 | */ |
60 | virtual ~NamedAreaManager(); |
61 | |
62 | void remove(Sheet* sheet); |
63 | |
64 | Region namedArea(const QString& name) const; |
65 | Sheet* sheet(const QString& name) const; |
66 | bool contains(const QString& name) const; |
67 | |
68 | /** |
69 | * Returns the list of all registered named areas. |
70 | * \return the list of named areas |
71 | */ |
72 | QList<QString> areaNames() const; |
73 | |
74 | void regionChanged(const Region& region); |
75 | void updateAllNamedAreas(); |
76 | |
77 | /// \ingroup OpenDocument |
78 | void loadOdf(const KoXmlElement& body); |
79 | /// \ingroup OpenDocument |
80 | void saveOdf(KoXmlWriter& xmlWriter) const; |
81 | |
82 | /// \ingroup NativeFormat |
83 | void loadXML(const KoXmlElement& element); |
84 | /// \ingroup NativeFormat |
85 | QDomElement saveXML(QDomDocument& doc) const; |
86 | |
87 | public Q_SLOTS: |
88 | /** |
89 | * Adds a named area. |
90 | * \note The name is valid for the whole document. |
91 | * \param region the cell range to be named |
92 | * \param name the name of the new area |
93 | */ |
94 | void insert(const Region& region, const QString& name); |
95 | |
96 | void remove(const QString& name); |
97 | |
98 | Q_SIGNALS: |
99 | void namedAreaAdded(const QString&); |
100 | void namedAreaRemoved(const QString&); |
101 | void namedAreaModified(const QString&); |
102 | |
103 | private: |
104 | class Private; |
105 | Private * const d; |
106 | }; |
107 | |
108 | } // namespace Sheets |
109 | } // namespace Calligra |
110 | |
111 | #endif // CALLIGRA_SHEETS_NAMED_AREA_MANAGER |
112 | |