kspread

kspread_condition.h

00001 /* This file is part of the KDE project
00002    Copyright 1998, 1999 Torben Weis <weis@kde.org>
00003    Copyright 1999- 2006 The KSpread Team
00004                         www.koffice.org/kspread
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef __kspread_condition_h__
00023 #define __kspread_condition_h__
00024 
00025 #include <qdom.h>
00026 #include <qvaluelist.h>
00027 
00028 #include <koffice_export.h>
00029 
00030 #include "kspread_global.h"
00031 
00032 class QColor;
00033 class QFont;
00034 class QString;
00035 class KoGenStyle;
00036 
00037 namespace KSpread
00038 {
00039 class Cell;
00040 class Style;
00041 
00046 class KSPREAD_EXPORT Conditional
00047 {
00048 public:
00049   enum Type { None, Equal, Superior, Inferior, SuperiorEqual,
00050               InferiorEqual, Between, Different, DifferentTo };
00051 
00052   double         val1;
00053   double         val2;
00054   QString *      strVal1;
00055   QString *      strVal2;
00056   QColor  *      colorcond;
00057   QFont   *      fontcond;
00058   QString *      styleName;
00059   Style *        style;
00060   Type           cond;
00061 
00062   Conditional();
00063   ~Conditional();
00064   Conditional( const Conditional& );
00065   Conditional& operator=( const Conditional& );
00066   bool operator==(const Conditional& other) const;
00067   inline bool operator!=( const Conditional& other ) const { return !operator==( other ); }
00068 };
00069 
00070 
00074 class Conditions
00075 {
00076  public:
00077 
00082   Conditions( const Cell * ownerCell );
00083   virtual ~Conditions();
00084 
00095   bool currentCondition( Conditional & condition );
00096 
00100   QValueList<Conditional> conditionList() const;
00101 
00105   void setConditionList( const QValueList<Conditional> & list );
00106 
00111   QDomElement saveConditions( QDomDocument & doc ) const;
00112 
00117   void loadConditions( const QDomElement & element );
00118 
00119   void loadOasisConditions( const QDomElement & element );
00120 
00121     void saveOasisConditions( KoGenStyle &currentCellStyle );
00122 
00123 
00127   Style * matchedStyle() const { return m_matchedStyle; }
00128 
00129   void checkMatches();
00130 
00131   bool operator==( const Conditions& other ) const;
00132   inline bool operator!=( const Conditions& other ) const { return !operator==( other ); }
00133 
00134  private:
00135   Conditions() {}
00136 
00137     QString saveOasisConditionValue(Conditional &cond);
00138     void loadOasisConditionValue( const QString &styleCondition, Conditional &newCondition );
00139     void loadOasisValidationValue( const QStringList &listVal, Conditional &newCondition );
00140     void loadOasisCondition( QString &valExpression, Conditional &newCondition );
00141 
00142 
00143   const Cell * m_cell;
00144   QValueList<Conditional> m_condList;
00145   Style * m_matchedStyle;
00146 };
00147 
00148 } // namespace KSpread
00149 
00150 #endif /*defined __kspread_condition_h__  */
KDE Home | KDE Accessibility Home | Description of Access Keys