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

« back to all changes in this revision

Viewing changes to kspread/plugins/insertcalendar/kspread_insertcalendardialog.cc

  • 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
 /***************************************************************************
 
2
 *   Copyright (C) 2005 by Raphael Langerhorst                             *
 
3
 *   raphael-langerhorst@gmx.at                                            *
 
4
 *                                                                         *
 
5
 *   Permission is hereby granted, free of charge, to any person obtaining *
 
6
 *   a copy of this software and associated documentation files (the       *
 
7
 *   "Software"), to deal in the Software without restriction, including   *
 
8
 *   without limitation the rights to use, copy, modify, merge, publish,   *
 
9
 *   distribute, sublicense, and/or sell copies of the Software, and to    *
 
10
 *   permit persons to whom the Software is furnished to do so, subject to *
 
11
 *   the following conditions:                                             *
 
12
 *                                                                         *
 
13
 *   The above copyright notice and this permission notice shall be        *
 
14
 *   included in all copies or substantial portions of the Software.       *
 
15
 *                                                                         *
 
16
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
 
17
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
 
18
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
 
19
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
 
20
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
 
21
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
 
22
 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
 
23
 ***************************************************************************/
 
24
 
 
25
#include <kspread_insertcalendardialog.h>
 
26
 
 
27
#include <kdatepicker.h>
 
28
#include <kdatewidget.h>
 
29
#include <kdebug.h>
 
30
 
 
31
#include <qpushbutton.h>
 
32
 
 
33
namespace KSpread
 
34
{
 
35
 
 
36
InsertCalendarDialog::InsertCalendarDialog(QWidget* parent, const char* name)
 
37
: InsertCalendarDialogBase(parent,name)
 
38
{
 
39
  this->m_datePicker = NULL;
 
40
  
 
41
  //we start with a default calendar for the current month;
 
42
 
 
43
  QDate first_day_in_month = QDate::currentDate();
 
44
  first_day_in_month.setYMD(first_day_in_month.year(),first_day_in_month.month(),1);
 
45
  
 
46
  QDate last_day_in_month(first_day_in_month.year(),first_day_in_month.month(),first_day_in_month.daysInMonth());
 
47
  
 
48
  this->m_startDateWidget->setDate(first_day_in_month);
 
49
  this->m_endDateWidget->setDate(last_day_in_month);
 
50
  
 
51
  connect(this->m_selectStartDateButton,SIGNAL(clicked()),this,SLOT(showStartDatePicker()));
 
52
  connect(this->m_selectEndDateButton,SIGNAL(clicked()),this,SLOT(showEndDatePicker()));
 
53
  
 
54
  connect(this->m_insertButton,SIGNAL(clicked()),this,SLOT(accept()));
 
55
  connect(this->m_cancelButton,SIGNAL(clicked()),this,SLOT(reject()));
 
56
}
 
57
 
 
58
InsertCalendarDialog::~InsertCalendarDialog()
 
59
{
 
60
}
 
61
 
 
62
bool InsertCalendarDialog::buildDatePickerFrame()
 
63
{
 
64
  if (m_datePicker)
 
65
  {
 
66
    delete m_datePicker; //destroyed signal is connected to datePickerDeleted()
 
67
  }
 
68
  
 
69
  m_datePicker = new KDatePicker(NULL,"date picker");
 
70
  
 
71
  Q_ASSERT(m_datePicker);
 
72
  
 
73
  if (!m_datePicker)
 
74
    return false;
 
75
  
 
76
  connect(m_datePicker,SIGNAL(destroyed()),this,SLOT(datePickerDeleted()));
 
77
  
 
78
  m_datePicker->setCloseButton(true);
 
79
  m_datePicker->move(this->x()+this->width(),this->y());
 
80
  m_datePicker->show();
 
81
  
 
82
  return true;
 
83
}
 
84
 
 
85
void InsertCalendarDialog::datePickerDeleted()
 
86
{
 
87
  kdDebug() << "date picker deleted" << endl;
 
88
  m_datePicker = NULL;
 
89
}
 
90
 
 
91
void InsertCalendarDialog::accept()
 
92
{
 
93
  if (m_datePicker)
 
94
    m_datePicker->deleteLater();
 
95
  kdDebug() << "insert calendar dialog accepted (insert button clicked)" << endl;
 
96
  done(QDialog::Accepted);
 
97
  emit insertCalendar(startDate(),endDate());
 
98
}
 
99
 
 
100
void InsertCalendarDialog::reject()
 
101
{
 
102
  if (m_datePicker)
 
103
    m_datePicker->deleteLater();
 
104
  kdDebug() << "insert calendar dialog rejected (cancel button clicked)" << endl;
 
105
  done(QDialog::Rejected);
 
106
}
 
107
 
 
108
void InsertCalendarDialog::showStartDatePicker()
 
109
{
 
110
  if (buildDatePickerFrame())
 
111
  {
 
112
    connect(m_datePicker,SIGNAL(dateSelected(QDate)),this,SLOT(setStartDate(QDate)));
 
113
    connect(m_datePicker,SIGNAL(dateEntered(QDate)),this,SLOT(setStartDate(QDate)));
 
114
    m_datePicker->setDate(startDate());
 
115
  }
 
116
}
 
117
 
 
118
void InsertCalendarDialog::showEndDatePicker()
 
119
{
 
120
  if (buildDatePickerFrame())
 
121
  {
 
122
    connect(m_datePicker,SIGNAL(dateSelected(QDate)),this,SLOT(setEndDate(QDate)));
 
123
    connect(m_datePicker,SIGNAL(dateEntered(QDate)),this,SLOT(setEndDate(QDate)));
 
124
    m_datePicker->setDate(endDate());
 
125
  }
 
126
}
 
127
 
 
128
void InsertCalendarDialog::setStartDate(QDate date)
 
129
{
 
130
  this->m_startDateWidget->setDate(date);
 
131
}
 
132
 
 
133
void InsertCalendarDialog::setEndDate(QDate date)
 
134
{
 
135
  this->m_endDateWidget->setDate(date);
 
136
}
 
137
 
 
138
QDate InsertCalendarDialog::startDate() const
 
139
{
 
140
  return this->m_startDateWidget->date();
 
141
}
 
142
 
 
143
QDate InsertCalendarDialog::endDate() const
 
144
{
 
145
  return this->m_endDateWidget->date();
 
146
}
 
147
 
 
148
}
 
149
 
 
150
#include "kspread_insertcalendardialog.moc"