File indexing completed on 2024-06-23 03:45:56

0001 // xlsxvalidation.h
0002 
0003 #ifndef QXLSX_XLSXDATAVALIDATION_H
0004 #define QXLSX_XLSXDATAVALIDATION_H
0005 
0006 #include <QtGlobal>
0007 #include <QSharedDataPointer>
0008 #include <QString>
0009 #include <QList>
0010 #include <QXmlStreamReader>
0011 #include <QXmlStreamWriter>
0012 
0013 #include "xlsxglobal.h"
0014 
0015 class QXmlStreamReader;
0016 class QXmlStreamWriter;
0017 
0018 QT_BEGIN_NAMESPACE_XLSX
0019 
0020 class Worksheet;
0021 class CellRange;
0022 class CellReference;
0023 
0024 class DataValidationPrivate;
0025 class QXLSX_EXPORT DataValidation
0026 {
0027 public:
0028     enum ValidationType
0029     {
0030         None,
0031         Whole,
0032         Decimal,
0033         List,
0034         Date,
0035         Time,
0036         TextLength,
0037         Custom
0038     };
0039 
0040     enum ValidationOperator
0041     {
0042         Between,
0043         NotBetween,
0044         Equal,
0045         NotEqual,
0046         LessThan,
0047         LessThanOrEqual,
0048         GreaterThan,
0049         GreaterThanOrEqual
0050     };
0051 
0052     enum ErrorStyle
0053     {
0054         Stop,
0055         Warning,
0056         Information
0057     };
0058 
0059     DataValidation();
0060     DataValidation(ValidationType type, ValidationOperator op=Between, const QString &formula1=QString()
0061             , const QString &formula2=QString(), bool allowBlank=false);
0062     DataValidation(const DataValidation &other);
0063     ~DataValidation();
0064 
0065     ValidationType validationType() const;
0066     ValidationOperator validationOperator() const;
0067     ErrorStyle errorStyle() const;
0068     QString formula1() const;
0069     QString formula2() const;
0070     bool allowBlank() const;
0071     QString errorMessage() const;
0072     QString errorMessageTitle() const;
0073     QString promptMessage() const;
0074     QString promptMessageTitle() const;
0075     bool isPromptMessageVisible() const;
0076     bool isErrorMessageVisible() const;
0077     QList<CellRange> ranges() const;
0078 
0079     void setValidationType(ValidationType type);
0080     void setValidationOperator(ValidationOperator op);
0081     void setErrorStyle(ErrorStyle es);
0082     void setFormula1(const QString &formula);
0083     void setFormula2(const QString &formula);
0084     void setErrorMessage(const QString &error, const QString &title=QString());
0085     void setPromptMessage(const QString &prompt, const QString &title=QString());
0086     void setAllowBlank(bool enable);
0087     void setPromptMessageVisible(bool visible);
0088     void setErrorMessageVisible(bool visible);
0089 
0090     void addCell(const CellReference &cell);
0091     void addCell(int row, int col);
0092     void addRange(int firstRow, int firstCol, int lastRow, int lastCol);
0093     void addRange(const CellRange &range);
0094 
0095     DataValidation &operator=(const DataValidation &other);
0096 
0097     bool saveToXml(QXmlStreamWriter &writer) const;
0098     static DataValidation loadFromXml(QXmlStreamReader &reader);
0099 private:
0100     QSharedDataPointer<DataValidationPrivate> d;
0101 };
0102 
0103 QT_END_NAMESPACE_XLSX
0104 
0105 #endif // QXLSX_XLSXDATAVALIDATION_H