1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
/* This file is part of the KDE project
Copyright 2006 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
Copyright 2004 Tomas Mecir <mecirt@gmail.com>
Copyright 1999-2002,2004 Laurent Montel <montel@kde.org>
Copyright 2002,2004 Ariya Hidayat <ariya@kde.org>
Copyright 2002-2003 Norbert Andres <nandres@web.de>
Copyright 2003 Stefan Hetzl <shetzl@chello.at>
Copyright 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
Copyright 2002 Harri Porten <porten@kde.org>
Copyright 2002 John Dailey <dailey@vt.edu>
Copyright 1999-2001 David Faure <faure@kde.org>
Copyright 2000-2001 Werner Trobin <trobin@kde.org>
Copyright 2000 Simon Hausmann <hausmann@kde.org
Copyright 1998-1999 Torben Weis <weis@kde.org>
Copyright 1999 Michael Reiher <michael.reiher@gmx.de>
Copyright 1999 Reginald Stadlbauer <reggie@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CALLIGRA_SHEETS_VALIDITY
#define CALLIGRA_SHEETS_VALIDITY
// Qt
#include <QDate>
#include <QHash>
#include <QSharedDataPointer>
#include <QStringList>
#include <QTime>
#include <QVariant>
// Calligra
#include "calligra_sheets_export.h"
// KSpread
#include "Condition.h"
#include "KoXmlReaderForward.h"
namespace Calligra
{
namespace Sheets
{
class OdfLoadingContext;
class ValueConverter;
class ValueParser;
/**
* \class Validity
* \ingroup Value
*
* Validates cell contents.
*
* \author Stefan Nikolaus <stefan.nikolaus@kdemail.net>
*/
class CALLIGRA_SHEETS_ODF_EXPORT Validity
{
public:
/// The action invoked, if the validity check fails.
enum Action {
Stop, ///< Stop
Warning, ///< Warn
Information ///< Inform
};
/// The type of the restriction.
enum Restriction {
None, ///< No restriction
Number, ///< Restrict to numbers
Text, ///< Restrict to texts
Time, ///< Restrict to times
Date, ///< Restrict to dates
Integer, ///< Restrict to integers
TextLength, ///< Restrict text length
List ///< Restrict to lists
};
/**
* Constructor.
* Creates a validity check, that allows any content.
*/
Validity();
/**
* Copy Constructor.
* Copies the validity \p other .
*/
Validity(const Validity& other);
/**
* Destructor.
*/
~Validity();
/**
* \return \c true if this validity check allows any content
*/
bool isEmpty() const;
/**
* Tests whether the content of \p cell is allowed.
* \return \c true if the content is valid
*/
bool testValidity(const Cell* cell) const;
/**
* \ingroup NativeFormat
* Loads validity checks.
*/
bool loadXML(Cell* const cell, const KoXmlElement& validityElement);
/**
* \ingroup NativeFormat
* Saves validity checks.
*/
QDomElement saveXML(QDomDocument& doc, const ValueConverter *converter) const;
/**
* \ingroup OpenDocument
* Loads validity checks.
*/
void loadOdfValidation(Cell* const cell, const QString& validationName,
OdfLoadingContext& tableContext);
Action action() const;
bool allowEmptyCell() const;
Conditional::Type condition() const;
bool displayMessage() const;
bool displayValidationInformation() const;
const QString& messageInfo() const;
const QString& message() const;
const Value &maximumValue() const;
const Value &minimumValue() const;
Restriction restriction() const;
const QString& title() const;
const QString& titleInfo() const;
const QStringList& validityList() const;
void setAction(Action action);
void setAllowEmptyCell(bool allow);
void setCondition(Conditional::Type condition);
void setDisplayMessage(bool display);
void setDisplayValidationInformation(bool display);
void setMessage(const QString& message);
void setMessageInfo(const QString& info);
void setMaximumValue(const Value &value);
void setMinimumValue(const Value &value);
void setRestriction(Restriction restriction);
void setTitle(const QString& title);
void setTitleInfo(const QString& info);
void setValidityList(const QStringList& list);
/// \note fake implementation to make QMap happy
bool operator<(const Validity&) const {
return true;
}
void operator=(const Validity&);
bool operator==(const Validity& other) const;
inline bool operator!=(const Validity& other) const {
return !operator==(other);
}
static QHash<QString, KoXmlElement> preloadValidities(const KoXmlElement& body);
private:
/**
* \ingroup OpenDocument
* Helper method for loadOdfValidation().
*/
void loadOdfValidationCondition(QString &valExpression, const ValueParser *parser);
/**
* \ingroup OpenDocument
* Helper method for loadOdfValidation().
*/
void loadOdfValidationValue(const QStringList &listVal, const ValueParser *parser);
class Private;
QSharedDataPointer<Private> d;
};
} // namespace Sheets
} // namespace Calligra
Q_DECLARE_METATYPE(Calligra::Sheets::Validity)
Q_DECLARE_TYPEINFO(Calligra::Sheets::Validity, Q_MOVABLE_TYPE);
#endif // CALLIGRA_SHEETS_VALIDITY
|