kspread

kspread_autofill.h

00001 /* This file is part of the KDE project
00002    
00003    Copyright 2003 Ariya Hidayat <ariya@kde.org>
00004    Copyright 2002 Norbert Andres <nandres@web.de>
00005    Copyright 2001-2002 Laurent Montel <montel@kde.org>
00006    Copyright 2001 David Faure <faure@kde.org>
00007    Copyright 2000 Werner Trobin <trobin@kde.org>
00008    Copyright 1998-1999 Torben Weis <weis@kde.org>
00009    
00010    This library is free software; you can redistribute it and/or
00011    modify it under the terms of the GNU Library General Public
00012    License as published by the Free Software Foundation; either
00013    version 2 of the License, or (at your option) any later version.
00014 
00015    This library is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018    Library General Public License for more details.
00019 
00020    You should have received a copy of the GNU Library General Public License
00021    along with this library; see the file COPYING.LIB.  If not, write to
00022    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00023  * Boston, MA 02110-1301, USA.
00024 */
00025 
00026 #ifndef __kspread_autofill_h__
00027 #define __kspread_autofill_h__
00028 
00029 #include <qdatetime.h>
00030 #include <qmemarray.h>
00031 #include <qstring.h>
00032 #include <qptrlist.h>
00033 #include <qstringlist.h>
00034 
00035 namespace KSpread
00036 {
00037 class AutoFillDeltaSequence;
00038 class AutoFillSequenceItem;
00039 class AutoFillSequence;
00040 class Cell;
00041 
00042 class AutoFillSequenceItem
00043 {
00044 public:
00045     enum Type { INTEGER, FLOAT, STRING, DAY, SHORTDAY,
00046       MONTH, SHORTMONTH, FORMULA, OTHER, DATE, TIME };
00047 
00048     AutoFillSequenceItem( int _i );
00049     AutoFillSequenceItem( double _d );
00050     AutoFillSequenceItem( const QString &_str );
00051 
00052     bool getDelta( AutoFillSequenceItem *_seq, double &delta );
00053 
00054     QString getSuccessor( int _no, double _delta );
00055     QString getPredecessor( int _no, double _delta );
00056 
00057     Type getType()const { return m_Type; }
00058     int getIValue()const { return m_IValue; }
00059     double getDValue()const { return m_DValue; }
00060     QString getString()const { return m_String; }
00061     int getIOtherEnd()const {return m_OtherEnd; }
00062     int getIOtherBegin()const {return m_OtherBegin; }
00063     static QStringList *other;
00064     static QStringList *month;
00065     static QStringList *day;
00066     static QStringList *shortMonth;
00067     static QStringList *shortDay;
00068 protected:
00069     int    m_IValue;
00070     double m_DValue;
00071     int    m_OtherBegin;
00072     int    m_OtherEnd;
00073 
00074     QString m_String;
00075 
00076     Type m_Type;
00077 };
00078 
00079 class AutoFillSequence
00080 {
00081 public:
00082     AutoFillSequence( Cell *_obj );
00083 
00084     int count()const { return sequence.count(); }
00085 
00086     AutoFillSequenceItem* getFirst() { return sequence.first(); }
00087     AutoFillSequenceItem* getNext() { return sequence.next(); }
00088 
00089     bool matches( AutoFillSequence* _seq, AutoFillDeltaSequence *_delta );
00090 
00091     void fillCell( Cell *src, Cell *dest, AutoFillDeltaSequence *delta, int _block, bool down = true );
00092 
00093 protected:
00094     QPtrList<AutoFillSequenceItem> sequence;
00095 };
00096 
00097 class AutoFillDeltaSequence
00098 {
00099 public:
00100     AutoFillDeltaSequence( AutoFillSequence *_first, AutoFillSequence *_next );
00101     ~AutoFillDeltaSequence();
00102 
00103     bool isOk()const { return m_ok; }
00104 
00105     bool equals( AutoFillDeltaSequence *_delta );
00106 
00107     QMemArray<double>* getSequence() { return m_sequence; }
00108 
00109     double getItemDelta( int _pos );
00110 
00111 protected:
00112     bool m_ok;
00113     QMemArray<double>* m_sequence;
00114 };
00115 
00116 } // namespace KSpread
00117 
00118 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys