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

« back to all changes in this revision

Viewing changes to kexi/kexidb/tableschema.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-10-11 14:49:50 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051011144950-lwpngbifzp8nk0ds
Tags: 1:1.4.1-0ubuntu7
* SECURITY UPDATE: fix heap based buffer overflow in the RTF importer of KWord
* Opening specially crafted RTF files in KWord can cause
  execution of abitrary code.
* Add kubuntu_01_rtfimport_heap_overflow.diff
* References:
  CAN-2005-2971
  CESA-2005-005
  http://www.koffice.org/security/advisory-20051011-1.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
 
3
   Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
 
4
 
 
5
   This library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Library General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2 of the License, or (at your option) any later version.
 
9
 
 
10
   This library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Library General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Library General Public License
 
16
   along with this library; see the file COPYING.LIB.  If not, write to
 
17
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
18
   Boston, MA 02111-1307, USA.
 
19
*/
 
20
 
 
21
#ifndef KEXIDB_TABLE_H
 
22
#define KEXIDB_TABLE_H
 
23
 
 
24
#include <qvaluelist.h>
 
25
#include <qptrlist.h>
 
26
#include <qstring.h>
 
27
 
 
28
#include <kexidb/fieldlist.h>
 
29
#include <kexidb/schemadata.h>
 
30
#include <kexidb/indexschema.h>
 
31
#include <kexidb/relationship.h>
 
32
 
 
33
namespace KexiDB {
 
34
 
 
35
class Connection;
 
36
 
 
37
/*! KexiDB::TableSchema provides information about native database table 
 
38
        that can be stored using SQL database engine. 
 
39
*/      
 
40
 
 
41
class KEXI_DB_EXPORT TableSchema : public FieldList, public SchemaData
 
42
{
 
43
        public:
 
44
                typedef QPtrList<TableSchema> List; //!< Type of tables list
 
45
                typedef QPtrListIterator<TableSchema> ListIterator; //!< Iterator for tables list
 
46
 
 
47
                TableSchema(const QString & name);
 
48
                TableSchema(const SchemaData& sdata);
 
49
                TableSchema();
 
50
 
 
51
                /*! Copy constructor. */
 
52
                TableSchema(const TableSchema& ts);
 
53
                
 
54
                virtual ~TableSchema();
 
55
                
 
56
                /*! Inserts \a field into a specified position (\a index).
 
57
                 'order' property of \a field is set automatically. */
 
58
                virtual FieldList& insertField(uint index, Field *field);
 
59
 
 
60
                /*! Reimplemented for internal reasons. */
 
61
                virtual void removeField(KexiDB::Field *field);
 
62
 
 
63
                /*! \return list of fields that are primary key of this table.
 
64
                 This method never returns NULL value,
 
65
                 if there is no primary key, empty IndexSchema object is returned.
 
66
                 IndexSchema object is owned by the table schema. */
 
67
                IndexSchema* primaryKey() const { return m_pkey; }
 
68
 
 
69
                /*! Sets table's primary key index to \a pkey. Pass pkey==NULL if you want to unassign
 
70
                 existing primary key ("primary" property of given IndexSchema object will be
 
71
                 cleared then so this index becomes ordinary index, still existing on table indeices list). 
 
72
                 
 
73
                 If this table already has primary key assigned, 
 
74
                 it is unassigned using setPrimaryKey(NULL) call.
 
75
                 
 
76
                 Before assigning as primary key, you should add the index to indices list 
 
77
                 with addIndex() (this is not done automatically!).
 
78
                */
 
79
                void setPrimaryKey(IndexSchema *pkey);
 
80
 
 
81
                const IndexSchema::ListIterator indicesIterator() const 
 
82
                        { return IndexSchema::ListIterator(m_indices); }
 
83
 
 
84
                const IndexSchema::List* indices() { return &m_indices; }
 
85
 
 
86
                /*! Removes all fields from the list, clears name and all other properties. 
 
87
                        \sa FieldList::clear() */
 
88
                virtual void clear();
 
89
 
 
90
                /*! \return String for debugging purposes. */
 
91
                virtual QString debugString();
 
92
 
 
93
                /*! if table was created using a connection, 
 
94
                        returns this connection object, otherwise NULL. */
 
95
                Connection* connection() const { return m_conn; }
 
96
 
 
97
                /*! \return true if this is KexiDB storage system's table 
 
98
                 (used internally by KexiDB). This helps in hiding such tables
 
99
                 in applications (if desired) and will also enable lookup of system 
 
100
                 tables for schema export/import functionality. 
 
101
                 
 
102
                 Any internal KexiDB system table's schema (kexi__*) has 
 
103
                 cleared its SchemaData part, e.g. id=-1 for such table,
 
104
                 and no description, caption and so on. This is because
 
105
                 it represents a native database table rather that extended Kexi table.
 
106
                 
 
107
                 isKexiDBSystem()==true implies isNative()==true.
 
108
                 
 
109
                 By default (after allocation), TableSchema object 
 
110
                 has this property set to false. */
 
111
                bool isKexiDBSystem() const { return m_isKexiDBSystem; }
 
112
 
 
113
                /*! Sets KexiDBSystem flag to on or off. When on, native flag is forced to be on.
 
114
                 When off, native flag is not affected.
 
115
                 \sa isKexiDBSystem() */
 
116
                void setKexiDBSystem(bool set);
 
117
 
 
118
                /*! \return true if this is schema of native database object,
 
119
                 When this is kexiDBSystem table, native flag is forced to be on. */
 
120
                virtual bool isNative() const { return m_native || m_isKexiDBSystem; }
 
121
                
 
122
                /* Sets native flag. Does not allow to set this off for system KexiDB table. */
 
123
                virtual void setNative(bool set);
 
124
 
 
125
                /*! \return query schema object that is defined by "select * from <this_table_name>"
 
126
                 This query schema object is owned by the table schema object.
 
127
                 It is convenient way to get such a query when it is available otherwise.
 
128
                 Always return non-null.
 
129
                */
 
130
                QuerySchema* query();
 
131
 
 
132
                /*! */
 
133
                Field* anyNonPKField();
 
134
 
 
135
        protected:
 
136
                /*! Automatically retrieves table schema via connection. */
 
137
                TableSchema(Connection *conn, const QString & name = QString::null);
 
138
 
 
139
                void init();
 
140
 
 
141
                IndexSchema::List m_indices;
 
142
 
 
143
                Connection *m_conn;
 
144
                
 
145
                IndexSchema *m_pkey;
 
146
 
 
147
                QuerySchema *m_query; //!< cached query schema that is defined by "select * from <this_table_name>"
 
148
 
 
149
                class Private;
 
150
                Private *d;
 
151
 
 
152
        private:
 
153
                bool m_isKexiDBSystem : 1;
 
154
 
 
155
        friend class Connection;
 
156
};
 
157
 
 
158
} //namespace KexiDB
 
159
 
 
160
#endif