kspread

kspread_genvalidationstyle.h

00001 /* This file is part of the KDE project
00002 
00003    Copyright 2004 Laurent Montel <montel@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 
00022 #ifndef KSPREAD_GENVALIDATIONSTYLE
00023 #define KSPREAD_GENVALIDATIONSTYLE
00024 
00025 #include <qdict.h>
00026 #include <qmap.h>
00027 
00028 class KoXmlWriter;
00029 
00030 namespace KSpread
00031 {
00032 class Validity;
00033 class GenValidationStyle;
00034 
00035 class GenValidationStyles
00036 {
00037 public:
00038     GenValidationStyles();
00039     ~GenValidationStyles();
00040     QString lookup( const GenValidationStyle& style );
00041 
00042     typedef QMap<GenValidationStyle, QString> StyleMap;
00043     void writeStyle( KoXmlWriter& writer );
00044 
00045 private:
00046     QString makeUniqueName( const QString& base ) const;
00047 
00049     StyleMap m_styles;
00051     typedef QMap<QString, bool> NameMap;
00052     NameMap m_names;
00053 
00054 };
00055 
00056 class GenValidationStyle
00057 {
00058 public:
00059     explicit GenValidationStyle(Validity *_val=0) { initVal( _val ); }
00060 
00061 
00062     bool operator<( const GenValidationStyle &other ) const {
00063         if ( allowEmptyCell != other.allowEmptyCell ) return ( allowEmptyCell < other.allowEmptyCell );
00064         if ( condition != other.condition ) return ( condition < other.condition );
00065         if ( titleInfo != other.titleInfo ) return ( titleInfo < other.titleInfo );
00066         if ( displayValidationInformation != other.displayValidationInformation ) return ( displayValidationInformation < other.displayValidationInformation );
00067         if ( messageInfo != other.messageInfo ) return ( messageInfo < other.messageInfo );
00068         if ( messageType != other.messageType ) return ( messageType < other.messageType );
00069         if ( displayMessage != other.displayMessage ) return ( displayMessage < other.displayMessage );
00070         if ( message != other.message ) return ( message < other.message );
00071         if ( title != other.title ) return ( title < other.title );
00072 
00073         return false;
00074     }
00075 private:
00076     QString createValidationCondition( Validity* _val );
00077     QString createTextValidationCondition( Validity* _val );
00078     QString createTimeValidationCondition( Validity* _val );
00079     QString createDateValidationCondition( Validity* _val );
00080     QString createNumberValidationCondition( Validity* _val );
00081     QString createListValidationCondition( Validity* _val );
00082 
00083     void initVal( Validity *_val );
00084 
00085     QString allowEmptyCell;
00086     QString condition;
00087     QString titleInfo;
00088     QString displayValidationInformation;
00089     QString messageInfo;
00090     QString messageType;
00091     QString displayMessage;
00092     QString message;
00093     QString title;
00094     friend class GenValidationStyles;
00095 };
00096 
00097 } // namespace KSpread
00098 
00099 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys