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

« back to all changes in this revision

Viewing changes to kexi/formeditor/objecttree.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 Lucijan Busch <lucijan@gmx.at>
 
3
   Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
 
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 KFORMDESIGNEROBJECTTREE_H
 
22
#define KFORMDESIGNEROBJECTTREE_H
 
23
 
 
24
#include <qptrlist.h>
 
25
#include <qmap.h>
 
26
#include <qdict.h>
 
27
#include <qvariant.h>
 
28
#include <qstring.h>
 
29
#include <qguardedptr.h>
 
30
 
 
31
class QWidget;
 
32
class QDomElement;
 
33
 
 
34
namespace KFormDesigner {
 
35
 
 
36
class ObjectTreeItem;
 
37
class Container;
 
38
class EventEater;
 
39
typedef QPtrList<ObjectTreeItem> ObjectTreeList;
 
40
typedef QPtrListIterator<ObjectTreeItem> ObjectTreeListIterator;
 
41
typedef QDict<ObjectTreeItem> ObjectTreeDict;
 
42
typedef QDictIterator<ObjectTreeItem> ObjectTreeDictIterator;
 
43
typedef QMap<QString, QVariant> QVariantMap;
 
44
 
 
45
/*! This class holds the properties of a widget (classname, name, parent, children ..).
 
46
    \author Lucijan Busch <lucijan@kde.org>
 
47
 */
 
48
 //! An item representing a widget
 
49
class KFORMEDITOR_EXPORT ObjectTreeItem
 
50
{
 
51
 
 
52
        public:
 
53
                ObjectTreeItem(const QString &className, const QString &name, QWidget *widget, Container *parentContainer, Container *container=0);
 
54
                virtual ~ObjectTreeItem();
 
55
 
 
56
                QString name() const { return m_name; }
 
57
                QString className() const { return m_className; }
 
58
                QWidget* widget() const { return m_widget; }
 
59
                EventEater* eventEater() const { return m_eater; }
 
60
                ObjectTreeItem* parent() const { return m_parent; }
 
61
                ObjectTreeList* children() { return &m_children; }
 
62
                /*! \return a QMap<QString, QVariant> of all modified properties for this widget.
 
63
                  The QVariant is the old value (ie first value) of the property whose name is the QString. */
 
64
                const QVariantMap* modifiedProperties() { return &m_props;}
 
65
                //! \return the widget's Container, or 0if the widget is not a Container.
 
66
                Container*      container() const { return m_container;}
 
67
 
 
68
                void setWidget(QWidget *w) { m_widget = w; }
 
69
                void setParent(ObjectTreeItem *parent)  { m_parent = parent;}
 
70
 
 
71
                void debug(int ident);
 
72
                void rename(const QString &name);
 
73
 
 
74
                void addChild(ObjectTreeItem *it);
 
75
                void removeChild(ObjectTreeItem *it);
 
76
 
 
77
                /*! Adds \a property in the list of the modified properties for this object.
 
78
                    These modified properties are written in the .ui files when saving the form.
 
79
                */
 
80
                void addModifiedProperty(const QCString &property, const QVariant &value);
 
81
                void storeUnknownProperty(QDomElement &el);
 
82
 
 
83
                void addPixmapName(const QCString &property, const QString &name);
 
84
                QString pixmapName(const QCString &property);
 
85
 
 
86
                void setEnabled(bool enabled)  { m_enabled = enabled; }
 
87
                bool isEnabled() const { return m_enabled; }
 
88
 
 
89
                int gridRow() const { return m_row; }
 
90
                int gridCol() const { return m_col; }
 
91
                int gridRowSpan() const { return m_rowspan; }
 
92
                int gridColSpan() const { return m_colspan; }
 
93
                bool spanMultipleCells() const { return m_span; }
 
94
                void setGridPos(int row, int col, int rowspan, int colspan);
 
95
 
 
96
        protected:
 
97
                QString m_className;
 
98
                QString m_name;
 
99
                ObjectTreeList  m_children;
 
100
                QGuardedPtr<Container> m_container;
 
101
                QMap<QString, QVariant> m_props;
 
102
                QString  m_unknownProps;
 
103
                QMap<QCString, QString> m_pixmapNames;
 
104
                ObjectTreeItem* m_parent;
 
105
                QGuardedPtr<QWidget> m_widget;
 
106
                QGuardedPtr<EventEater> m_eater;
 
107
 
 
108
                bool  m_enabled;
 
109
 
 
110
                int m_row, m_col, m_rowspan, m_colspan;
 
111
                bool m_span;
 
112
 
 
113
                friend class ObjectTree;
 
114
                friend class FormIO;
 
115
};
 
116
 
 
117
//! A class representing all the objects in a Form
 
118
/*! This class holds ObjectTreeItem for each widget in a Form.
 
119
 */
 
120
class KFORMEDITOR_EXPORT ObjectTree : public ObjectTreeItem
 
121
{
 
122
        public:
 
123
                ObjectTree(const QString &className=QString::null, const QString &name=QString::null, 
 
124
                        QWidget *widget=0, Container *container=0);
 
125
                virtual ~ObjectTree();
 
126
 
 
127
                /*! Renames the item named \a oldname to \a newname. \return false if widget named \a newname
 
128
                 already exists and renaming failed. */
 
129
                bool rename(const QString &oldname, const QString &newname );
 
130
                /*! Sets \a newparent as new parent for the item whose name is \a name. */
 
131
                bool reparent(const QString &name, const QString &newparent);
 
132
 
 
133
                /*! \return the ObjectTreeItem named \a name, or 0 if doesn't exist. */
 
134
                ObjectTreeItem* lookup(const QString &name);
 
135
                /*! \return a dict containing all ObjectTreeItem in this ObjectTree. If you want to iterate on
 
136
                this dict, iterate on a copy. */
 
137
                ObjectTreeDict* dict() { return &m_treeDict; }
 
138
 
 
139
                void addItem(ObjectTreeItem *parent, ObjectTreeItem *c);
 
140
                void removeItem(const QString &name);
 
141
                void removeItem(ObjectTreeItem *c);
 
142
 
 
143
                /*! Generates a new name with \a base as beginning (eg if base is "QLineEdit", it returns "QLineEdit1"). */
 
144
                QString genName(const QString &base);
 
145
 
 
146
        private:
 
147
                ObjectTreeDict  m_treeDict;
 
148
};
 
149
 
 
150
}
 
151
 
 
152
#endif