1 | /* This file is part of the KDE project |
2 | |
3 | Copyright 2004 Laurent Montel <montel@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; either |
8 | version 2 of the License, or (at your option) any later version. |
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 | |
22 | #ifndef CALLIGRA_SHEETS_GENVALIDATIONSTYLE |
23 | #define CALLIGRA_SHEETS_GENVALIDATIONSTYLE |
24 | |
25 | #include "calligra_sheets_export.h" |
26 | |
27 | #include <QMap> |
28 | #include <QString> |
29 | |
30 | class KoXmlWriter; |
31 | |
32 | namespace Calligra |
33 | { |
34 | namespace Sheets |
35 | { |
36 | class Validity; |
37 | class ValueConverter; |
38 | class GenValidationStyles; |
39 | |
40 | /** |
41 | * \class GenValidationStyle |
42 | * \ingroup OpenDocument |
43 | */ |
44 | class GenValidationStyle |
45 | { |
46 | public: |
47 | explicit GenValidationStyle(Validity *_val = 0, const ValueConverter *converter = 0) { |
48 | initVal(_val, converter); |
49 | } |
50 | |
51 | |
52 | bool operator<(const GenValidationStyle &other) const { |
53 | if (allowEmptyCell != other.allowEmptyCell) return (allowEmptyCell < other.allowEmptyCell); |
54 | if (condition != other.condition) return (condition < other.condition); |
55 | if (titleInfo != other.titleInfo) return (titleInfo < other.titleInfo); |
56 | if (displayValidationInformation != other.displayValidationInformation) return (displayValidationInformation < other.displayValidationInformation); |
57 | if (messageInfo != other.messageInfo) return (messageInfo < other.messageInfo); |
58 | if (messageType != other.messageType) return (messageType < other.messageType); |
59 | if (displayMessage != other.displayMessage) return (displayMessage < other.displayMessage); |
60 | if (message != other.message) return (message < other.message); |
61 | if (title != other.title) return (title < other.title); |
62 | |
63 | return false; |
64 | } |
65 | private: |
66 | QString createValidationCondition(Validity* _val, const ValueConverter *converter); |
67 | QString createTextValidationCondition(Validity* _val); |
68 | QString createTimeValidationCondition(Validity* _val, const ValueConverter *converter); |
69 | QString createDateValidationCondition(Validity* _val, const ValueConverter *converter); |
70 | QString createNumberValidationCondition(Validity* _val); |
71 | QString createListValidationCondition(Validity* _val); |
72 | |
73 | void initVal(Validity *_val, const ValueConverter *converter); |
74 | |
75 | QString allowEmptyCell; |
76 | QString condition; |
77 | QString titleInfo; |
78 | QString displayValidationInformation; |
79 | QString messageInfo; |
80 | QString messageType; |
81 | QString displayMessage; |
82 | QString message; |
83 | QString title; |
84 | friend class GenValidationStyles; |
85 | }; |
86 | |
87 | /** |
88 | * \class GenValidationStyles |
89 | * \ingroup OpenDocument |
90 | */ |
91 | class CALLIGRA_SHEETS_ODF_EXPORT GenValidationStyles |
92 | { |
93 | public: |
94 | GenValidationStyles(); |
95 | ~GenValidationStyles(); |
96 | QString insert(const GenValidationStyle& style); |
97 | |
98 | typedef QMap<GenValidationStyle, QString> StyleMap; |
99 | void writeStyle(KoXmlWriter& writer); |
100 | |
101 | private: |
102 | QString makeUniqueName(const QString& base) const; |
103 | |
104 | /// style definition -> name |
105 | StyleMap m_styles; |
106 | /// name -> style (used to check for name uniqueness) |
107 | typedef QMap<QString, bool> NameMap; |
108 | NameMap m_names; |
109 | |
110 | }; |
111 | |
112 | } // namespace Sheets |
113 | } // namespace Calligra |
114 | |
115 | #endif |
116 | |