~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to kspread/kspread_changes.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2002 Norbert Andres, nandres@web.de
 
3
 
 
4
   This library is free software; you can redistribute it and/or
 
5
   modify it under the terms of the GNU Library General Public
 
6
   License as published by the Free Software Foundation; either
 
7
   version 2 of the License, or (at your option) any later version.
 
8
 
 
9
   This library is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
   Library General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU Library General Public License
 
15
   along with this library; see the file COPYING.LIB.  If not, write to
 
16
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
   Boston, MA 02111-1307, USA.
 
18
*/
 
19
 
 
20
#ifndef __kspread_changes__
 
21
#define __kspread_changes__
 
22
 
 
23
#include <qcstring.h>
 
24
#include <qdatetime.h>
 
25
#include <qmap.h>
 
26
#include <qobject.h>
 
27
#include <qpoint.h>
 
28
#include <qptrlist.h>
 
29
#include <qstring.h>
 
30
 
 
31
class FilterMain;
 
32
 
 
33
class KSpreadAcceptDlg;
 
34
class KSpreadCell;
 
35
class KSpreadFilterDlg;
 
36
class KSpreadMap;
 
37
class KSpreadSheet;
 
38
 
 
39
class QDomDocument;
 
40
class QDomElement;
 
41
 
 
42
class FilterSettings
 
43
{
 
44
 public:
 
45
  FilterSettings();
 
46
 
 
47
  bool loadXml( QDomElement const & settings );
 
48
  void saveXml( QDomDocument & doc, QDomElement & parent ) const;
 
49
 
 
50
  void setShowChanges( bool b );
 
51
  void setShowAccepted( bool b );
 
52
  void setShowRejected( bool b );
 
53
 
 
54
  bool dateSet() const         { return m_dateSet; }
 
55
  bool authorSet() const       { return m_authorSet; }
 
56
  bool commentSet() const      { return m_commentSet; }
 
57
  bool rangeSet() const        { return m_rangeSet; }
 
58
                               
 
59
  bool showChanges() const     { return m_showChanges; }
 
60
  bool showRejected() const    { return m_showRejected; }
 
61
  bool showAccepted() const    { return m_showAccepted; }
 
62
                               
 
63
  int  dateUsage() const       { return m_dateUsage; }
 
64
                               
 
65
  QString author() const       { return m_author; }
 
66
  QString comment() const      { return m_comment; }
 
67
  QString range() const        { return m_range; }
 
68
 
 
69
  QDateTime firstTime() const  { return m_firstTime; }
 
70
  QDateTime secondTime() const { return m_secondTime; }
 
71
  
 
72
 private:
 
73
  friend class FilterMain;
 
74
 
 
75
  bool      m_dateSet;
 
76
  int       m_dateUsage;
 
77
  QDateTime m_firstTime;
 
78
  QDateTime m_secondTime;
 
79
 
 
80
  bool      m_authorSet;
 
81
  QString   m_author;
 
82
  
 
83
  bool      m_commentSet;
 
84
  QString   m_comment;
 
85
 
 
86
  bool      m_rangeSet;
 
87
  QString   m_range;
 
88
 
 
89
  bool      m_showChanges;
 
90
  bool      m_showAccepted;
 
91
  bool      m_showRejected;
 
92
};
 
93
 
 
94
class KSpreadChanges : public QObject
 
95
{
 
96
 public:
 
97
  KSpreadChanges( KSpreadMap * map );
 
98
  ~KSpreadChanges();
 
99
 
 
100
  void setProtected( QCString const & hash );
 
101
  bool isProtected() const { return !m_strPassword.isNull(); }
 
102
  void password( QCString & passwd ) const { passwd = m_strPassword; }
 
103
  bool checkPassword( QCString const & passwd ) const { return ( passwd == m_strPassword ); }
 
104
 
 
105
  void addChange( KSpreadSheet * table, KSpreadCell * cell, QPoint const & point,
 
106
                  QString const & oldFormat, QString const & oldValue, bool hasDepandancy = true );
 
107
  void fillDependancyList();
 
108
 
 
109
  void saveXml( QDomDocument & doc, QDomElement & map );
 
110
  bool loadXml( QDomElement const & changes );
 
111
 
 
112
 private:
 
113
  class ChangeRecord;
 
114
  class RecordMap : public QMap<int, ChangeRecord *> {};
 
115
 
 
116
  class AuthorInfo
 
117
  {
 
118
   public:
 
119
    AuthorInfo( int id, QString const & name )
 
120
      : m_id( id ), m_name( name ) {}
 
121
 
 
122
    int  id() const { return m_id; };
 
123
    QString name() const { return m_name; }
 
124
 
 
125
   private:
 
126
    int       m_id;
 
127
    QString   m_name;
 
128
  };
 
129
 
 
130
  class Change
 
131
  {
 
132
   public:
 
133
    Change() : timestamp( QDateTime::currentDateTime() ), comment( 0 ) {}
 
134
    Change( int _authorID, QDateTime const & _timestamp, QString const & _comment ) 
 
135
      : authorID( _authorID ), timestamp( _timestamp ), comment( new QString( _comment ) ) {}
 
136
 
 
137
    virtual ~Change();
 
138
 
 
139
    virtual bool loadXml( QDomElement const & change, KSpreadSheet const * const table,
 
140
                          QPoint const & cellRef ) = 0;
 
141
    virtual void saveXml( QDomDocument & doc, QDomElement & change ) const = 0;
 
142
 
 
143
 
 
144
// protected:
 
145
    int        authorID;
 
146
    QDateTime  timestamp;
 
147
    QString *  comment;
 
148
  };
 
149
 
 
150
  class CellChange : public Change
 
151
  {
 
152
   public:    
 
153
    CellChange() : Change(), cell( 0 ) {}
 
154
    ~CellChange();
 
155
 
 
156
 
 
157
    bool loadXml( QDomElement const & change, KSpreadSheet const * const table,
 
158
                  QPoint const & cellRef );
 
159
 
 
160
    void saveXml( QDomDocument & doc, QDomElement & change ) const;
 
161
 
 
162
    QString       formatString;
 
163
    QString       oldValue;
 
164
    KSpreadCell * cell;
 
165
  };
 
166
 
 
167
  class ChangeRecord
 
168
  {
 
169
   public:
 
170
    typedef enum E1 { ACCEPTED, FILTERED, PENDING, REJECTED } State;
 
171
    typedef enum E2 { CELL, INSERTCOLUMN, INSERTROW, INSERTTABLE, 
 
172
                      DELETECOLUMN, DELETEROW, DELETETABLE, MOVE } ChangeType;
 
173
 
 
174
 
 
175
    ChangeRecord();
 
176
    ChangeRecord( int id, State state, ChangeType type, KSpreadSheet * table, 
 
177
                  QPoint const & cellRef, Change * change );
 
178
    ~ChangeRecord();
 
179
 
 
180
    bool loadXml( QDomElement & changes, KSpreadMap * map, RecordMap & records );
 
181
    void saveXml( QDomDocument & doc, QDomElement & parent ) const;
 
182
 
 
183
    bool isDependant( KSpreadSheet const * const table, QPoint const & cell ) const;
 
184
    void addDependant( ChangeRecord * record, QPoint const & cellRef );
 
185
 
 
186
    void  setState( State state ) { m_state = state; }
 
187
    State state() const { return m_state; }
 
188
 
 
189
    int id() const { return m_id; }
 
190
    KSpreadSheet const * const table() const { return m_table; }
 
191
 
 
192
    int dependancies() const { return m_dependancies; }
 
193
    void increaseDependancyCounter() { ++m_dependancies; }
 
194
 
 
195
   private:
 
196
    friend class KSpreadAcceptDlg;
 
197
    friend class KSpreadCommentDlg;
 
198
    friend class KSpreadFilterDlg;
 
199
    
 
200
    int            m_id;
 
201
    State          m_state;
 
202
    ChangeType     m_type;
 
203
    KSpreadSheet * m_table;
 
204
    QPoint         m_cell; // Rows: (0, row), Columns: (col, 0), Cells (>0, >0)
 
205
    Change *       m_change;
 
206
    int            m_dependancies;
 
207
 
 
208
    QPtrList<ChangeRecord> m_dependants;
 
209
  };
 
210
 
 
211
  friend class KSpreadAcceptDlg;
 
212
  friend class KSpreadCommentDlg;
 
213
  friend class KSpreadFilterDlg;  
 
214
 
 
215
  QPtrList<ChangeRecord> m_dependancyList;
 
216
  QPtrList<AuthorInfo>   m_authors;
 
217
  RecordMap              m_changeRecords;
 
218
  uint                   m_counter;
 
219
  QString                m_name;
 
220
  QCString               m_strPassword;
 
221
  KSpreadMap *           m_map;
 
222
  FilterSettings         m_filterSettings;
 
223
  bool                   m_locked;
 
224
 
 
225
  int  addAuthor();
 
226
  bool loadAuthors( QDomElement const & authors );
 
227
  bool loadChanges( QDomElement const & changes );
 
228
  void saveAuthors( QDomDocument & doc, QDomElement & changes );
 
229
  void saveChanges( QDomDocument & doc, QDomElement & changes );
 
230
  QString getAuthor( int id );
 
231
};
 
232
 
 
233
#endif
 
234