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

« back to all changes in this revision

Viewing changes to kexi/widget/tableview/kexibooltableedit.cpp

  • 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) 2004 Jaroslaw Staniek <js@iidea.pl>
 
3
 
 
4
   This program 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 program 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 program; see the file COPYING.  If not, write to
 
16
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
   Boston, MA 02111-1307, USA.
 
18
 */
 
19
 
 
20
#include "kexibooltableedit.h"
 
21
 
 
22
#include <kexidb/field.h>
 
23
 
 
24
#include <qpainter.h>
 
25
 
 
26
#include <kglobal.h>
 
27
#include <klocale.h>
 
28
#include <kdebug.h>
 
29
#include <kglobalsettings.h>
 
30
 
 
31
 
 
32
KexiBoolTableEdit::KexiBoolTableEdit(KexiTableViewColumn &column, QScrollView *parent)
 
33
 : KexiTableEdit(column, parent, "KexiBoolTableEdit")
 
34
{
 
35
        init();
 
36
}
 
37
 
 
38
KexiBoolTableEdit::~KexiBoolTableEdit()
 
39
{
 
40
}
 
41
 
 
42
void KexiBoolTableEdit::init()
 
43
{
 
44
        kdDebug() << "KexiBoolTableEdit: m_origValue.typeName()==" << m_origValue.typeName() << endl;
 
45
        kdDebug() << "KexiBoolTableEdit: type== " << field()->typeName() << endl;
 
46
 
 
47
        m_hasFocusableWidget = false;
 
48
}
 
49
        
 
50
void KexiBoolTableEdit::setValueInternal(const QVariant& /*add*/, bool /*removeOld*/)
 
51
{
 
52
        m_currentValue = m_origValue;
 
53
        //nothing to do more...
 
54
}
 
55
 
 
56
/*bool KexiBoolTableEdit::valueChanged()
 
57
{
 
58
        if (m_lineedit->text()!=m_origText)
 
59
                return true;
 
60
        return KexiTableEdit::valueChanged();
 
61
}*/
 
62
 
 
63
bool KexiBoolTableEdit::valueIsNull()
 
64
{
 
65
        return m_currentValue.isNull();
 
66
}
 
67
 
 
68
bool KexiBoolTableEdit::valueIsEmpty()
 
69
{
 
70
        return m_currentValue.isNull();
 
71
}
 
72
 
 
73
QVariant KexiBoolTableEdit::value()
 
74
{
 
75
//      ok = true;
 
76
        return m_currentValue;
 
77
}
 
78
 
 
79
void KexiBoolTableEdit::clear()
 
80
{
 
81
        m_currentValue = QVariant();
 
82
}
 
83
 
 
84
bool KexiBoolTableEdit::cursorAtStart()
 
85
{
 
86
        return true;
 
87
}
 
88
 
 
89
bool KexiBoolTableEdit::cursorAtEnd()
 
90
{
 
91
        return true;
 
92
}
 
93
 
 
94
/*QSize KexiBoolTableEdit::totalSize()
 
95
{
 
96
        if (!m_lineedit)
 
97
                return size();
 
98
        return m_lineedit->size();
 
99
}*/
 
100
 
 
101
void KexiBoolTableEdit::setupContents( QPainter *p, bool /*focused*/, QVariant val, 
 
102
        QString &/*txt*/, int &/*align*/, int &/*x*/, int &y_offset, int &w, int &h  )
 
103
{
 
104
#ifdef Q_WS_WIN
 
105
//      x = 1;
 
106
        y_offset = -1;
 
107
#else
 
108
//      x = 1;
 
109
        y_offset = 0;
 
110
#endif
 
111
        int s = QMAX(h - 5, 12);
 
112
        s = QMIN( h-3, s );
 
113
        s = QMIN( w-3, s );//avoid too large box
 
114
//              QRect r(w/2 - s/2 + x, h/2 - s/2 - 1, s, s);
 
115
        QRect r( QMAX( w/2 - s/2, 0 ) , h/2 - s/2 /*- 1*/, s, s);
 
116
        p->setPen(QPen(colorGroup().text(), 1));
 
117
        p->drawRect(r);
 
118
        if (val.asBool()) {
 
119
                p->drawLine(r.x(), r.y(), r.right(), r.bottom());
 
120
                p->drawLine(r.x(), r.bottom(), r.right(), r.y());
 
121
//                      p->drawLine(r.x() + 2, r.y() + 2, r.right() - 1, r.bottom() - 1);
 
122
//                      p->drawLine(r.x() + 2, r.bottom() - 2, r.right() - 1, r.y() + 1);
 
123
        }
 
124
}
 
125
 
 
126
void KexiBoolTableEdit::clickedOnContents()
 
127
{
 
128
        m_currentValue = QVariant( !m_currentValue.toBool(), 0 );
 
129
}
 
130
 
 
131
//======================================================
 
132
 
 
133
KexiBoolEditorFactoryItem::KexiBoolEditorFactoryItem()
 
134
{
 
135
}
 
136
 
 
137
KexiBoolEditorFactoryItem::~KexiBoolEditorFactoryItem()
 
138
{
 
139
}
 
140
 
 
141
KexiTableEdit* KexiBoolEditorFactoryItem::createEditor(
 
142
        KexiTableViewColumn &column, QScrollView* parent)
 
143
{
 
144
        return new KexiBoolTableEdit(column, parent);
 
145
}
 
146
 
 
147
#include "kexibooltableedit.moc"
 
148