From koffice-devel Sat Sep 27 11:14:45 2003 From: Norbert Andres Date: Sat, 27 Sep 2003 11:14:45 +0000 To: koffice-devel Subject: KSpread patch X-MARC-Message: https://marc.info/?l=koffice-devel&m=106466120620233 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_lEXd/nbjzhOICyX" --Boundary-00=_lEXd/nbjzhOICyX Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, here is a patch to fix the KSpread bugs 64794 and 61570. Can somebody please take a look at it? Regards Norbert (This patch doesn't mean that I will have more time for KSpread during the next 2 or 3 weeks, but after some public ranting against KSpread developers I want at least show that I am interested in fixing bugs but just can't due to lack of time...) --Boundary-00=_lEXd/nbjzhOICyX Content-Type: text/x-diff; charset="us-ascii"; name="patch.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch.diff" ? patch.diff Index: kspread_dlg_layout.cc =================================================================== RCS file: /home/kde/koffice/kspread/kspread_dlg_layout.cc,v retrieving revision 1.205 diff -u -r1.205 kspread_dlg_layout.cc --- kspread_dlg_layout.cc 26 Aug 2003 23:49:37 -0000 1.205 +++ kspread_dlg_layout.cc 27 Sep 2003 11:08:23 -0000 @@ -4241,8 +4241,8 @@ for ( int x = dlg->left; x <= dlg->right; x++ ) { KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x, dlg->top ); - if ( obj->isObscuringForced() && dlg->isSingleCell() ) - continue; + if ( obj->isObscuringForced() /* && dlg->isSingleCell() */ ) + obj = obj->obscuringCells().first(); obj->setTopBorderPen( tmpPen ); } } @@ -4275,7 +4275,7 @@ for ( int x = dlg->left; x <= dlg->right; x++ ) { KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x, dlg->bottom ); - if ( obj->isObscuringForced() && dlg->isSingleCell() ) + if ( obj->isObscuringForced() /* && dlg->isSingleCell() */ ) obj = obj->obscuringCells().first(); obj->setBottomBorderPen( tmpPen ); } @@ -4307,7 +4307,7 @@ for ( int y = dlg->top; y <= dlg->bottom; y++ ) { KSpreadCell *obj = dlg->getTable()->nonDefaultCell( dlg->left, y ); - if ( obj->isObscuringForced() && dlg->isSingleCell() ) + if ( obj->isObscuringForced() /* && dlg->isSingleCell() */ ) continue; obj->setLeftBorderPen( tmpPen ); } @@ -4355,7 +4355,7 @@ for ( int y = dlg->top; y <= dlg->bottom; y++ ) { KSpreadCell * obj = dlg->getTable()->nonDefaultCell( dlg->right, y ); - if ( obj->isObscuringForced() && dlg->isSingleCell() ) + if ( obj->isObscuringForced() /* && dlg->isSingleCell() */ ) obj = obj->obscuringCells().first(); obj->setRightBorderPen( tmpPen ); } @@ -4383,7 +4383,7 @@ { KSpreadCell *cell = dlg->getTable()->nonDefaultCell( i, rw->row() ); - if ( cell->isObscuringForced() && dlg->isSingleCell() ) + if ( cell->isObscuringForced() /* && dlg->isSingleCell() */ ) cell = cell->obscuringCells().first(); cell->setRightBorderPen( tmpPen ); } Index: kspread_functions_datetime.cc =================================================================== RCS file: /home/kde/koffice/kspread/kspread_functions_datetime.cc,v retrieving revision 1.9 diff -u -r1.9 kspread_functions_datetime.cc --- kspread_functions_datetime.cc 8 Feb 2003 14:47:33 -0000 1.9 +++ kspread_functions_datetime.cc 27 Sep 2003 11:08:23 -0000 @@ -37,6 +37,7 @@ #include #include #include +#include // prototypes, sorted bool kspreadfunc_currentDate( KSContext& context ); @@ -130,12 +131,9 @@ QDate date; - kdDebug() << "EDATE 0" << endl; if ( !getDate( context, args[0], date ) ) return false; - kdDebug() << "EDATE" << endl; - int months; if ( !KSUtil::checkType( context, args[1], KSValue::IntType, true ) ) @@ -183,8 +181,6 @@ months = (int) args[1]->doubleValue(); } - kdDebug() << "EOMONTH" << endl; - if ( !getDate( context, args[0], date ) ) return false; @@ -225,8 +221,6 @@ european = args[2]->boolValue(); } - kdDebug() << "DAYS360" << endl; - if ( !getDate( context, args[0], date1 ) ) return false; @@ -296,8 +290,6 @@ return true; } - kdDebug() << "YEAR" << endl; - QDate date; if ( !getDate( context, args[0], date ) ) return false; @@ -317,8 +309,6 @@ return true; } - kdDebug() << "Month"<< endl; - QDate date; if ( !getDate( context, args[0], date ) ) return false; @@ -338,7 +328,6 @@ return true; } - kdDebug() << "Day"<< endl; QDate date; if ( !getDate( context, args[0], date ) ) return false; @@ -498,7 +487,6 @@ QDate date; - kdDebug() << "Weekday"<< endl; if ( !getDate( context, args[0], date ) ) return false; @@ -526,12 +514,9 @@ QDate date; - kdDebug() << "Datevalue"<< endl; if ( !getDate( context, args[0], date ) ) return false; - kdDebug() << "Date: " << date.day() << "." << date.month() << "." << date.year() << endl; - long int result = (long int) EDate::greg2jul( date ); context.setValue( new KSValue( result ) ); @@ -548,23 +533,8 @@ QTime time; - if ( !KSUtil::checkType( context, args[0], KSValue::TimeType, true ) ) - { - if ( !KSUtil::checkType( context, args[0], KSValue::StringType, true ) ) - return false; - - QString s = args[0]->stringValue(); - bool valid = false; - QTime tmpTime = KGlobal::locale()->readTime( s, &valid ); - if ( valid ) - time = tmpTime; - else - return false; - } - else - time = args[0]->timeValue(); - - kdDebug() << "Time: " << time.hour() << ":" << time.minute() << ":" << time.second() << endl; + if ( !getTime( context, args[0], time ) ) + return false; double result = time.hour() * 3600 + time.minute() * 60 + time.second(); result = result / (double) SECSPERDAY; @@ -588,7 +558,6 @@ if (!KSUtil::checkType( context, args[2], KSValue::IntType, true )) return false; - kdDebug() << "years"<< endl; if ( !getDate( context, args[0], date1 ) ) return false; @@ -658,7 +627,6 @@ if (!KSUtil::checkType( context, args[2], KSValue::IntType, true )) return false; - kdDebug() << "Months"<< endl; if ( !getDate( context, args[0], date1 ) ) return false; @@ -721,7 +689,6 @@ if (!KSUtil::checkType( context, args[2], KSValue::IntType, true )) return false; - kdDebug() << "Weeks"<< endl; if ( !getDate( context, args[0], date1 ) ) return false; @@ -781,7 +748,6 @@ QDate date1; QDate date2; - kdDebug() << "Days"<< endl; if ( !getDate( context, args[0], date1 ) ) return false; @@ -804,75 +770,54 @@ bool kspreadfunc_hours( KSContext& context ) { QValueList& args = context.value()->listValue(); - if ( !KSUtil::checkArgumentsCount( context,1, "hours",true ) ) + + if ( !KSUtil::checkArgumentsCount( context, 1, "hours", true ) ) return false; - if (!KSUtil::checkType( context, args[0], KSValue::TimeType, true ) ) - { - if ( !KSUtil::checkType( context, args[0], KSValue::StringType, true ) ) - return false; - QTime tmp=KGlobal::locale()->readTime(args[0]->stringValue()); - if(tmp.isValid()) - context.setValue(new KSValue(tmp.hour())); - else - context.setValue(new KSValue(i18n("Err"))); - return true; - } - else - { - QTime tmp=args[0]->timeValue(); - context.setValue(new KSValue(tmp.hour())); - } - return true; + + QTime tmpTime; + + if (!getTime(context, args[0], tmpTime)) + return false; + + context.setValue( new KSValue( tmpTime.hour() ) ); + + return true; } // Function: minutes bool kspreadfunc_minutes( KSContext& context ) { QValueList& args = context.value()->listValue(); - if ( !KSUtil::checkArgumentsCount( context,1, "minutes",true ) ) + + if ( !KSUtil::checkArgumentsCount( context, 1, "minutes", true ) ) return false; - if (!KSUtil::checkType( context, args[0], KSValue::TimeType, true ) ) - { - if ( !KSUtil::checkType( context, args[0], KSValue::StringType, true ) ) - return false; - QTime tmp=KGlobal::locale()->readTime(args[0]->stringValue()); - if(tmp.isValid()) - context.setValue(new KSValue(tmp.minute())); - else - context.setValue(new KSValue(i18n("Err"))); - return true; - } - else - { - QTime tmp=args[0]->timeValue(); - context.setValue(new KSValue(tmp.minute())); - } - return true; + + QTime tmpTime; + + if (!getTime(context, args[0], tmpTime)) + return false; + + context.setValue( new KSValue( tmpTime.minute() ) ); + + return true; } // Function: seconds bool kspreadfunc_seconds( KSContext& context ) { QValueList& args = context.value()->listValue(); - if ( !KSUtil::checkArgumentsCount( context,1, "seconds",true ) ) + + if ( !KSUtil::checkArgumentsCount( context, 1, "seconds", true ) ) return false; - if (!KSUtil::checkType( context, args[0], KSValue::TimeType, true ) ) - { - if ( !KSUtil::checkType( context, args[0], KSValue::StringType, true ) ) - return false; - QTime tmp=KGlobal::locale()->readTime(args[0]->stringValue()); - if(tmp.isValid()) - context.setValue(new KSValue(tmp.second())); - else - context.setValue(new KSValue(i18n("Err"))); - return true; - } - else - { - QTime tmp=args[0]->timeValue(); - context.setValue(new KSValue(tmp.second())); - } - return true; + + QTime tmpTime; + + if (!getTime(context, args[0], tmpTime)) + return false; + + context.setValue( new KSValue( tmpTime.second() ) ); + + return true; } // Function: date Index: kspread_functions_helper.cc =================================================================== RCS file: /home/kde/koffice/kspread/kspread_functions_helper.cc,v retrieving revision 1.3 diff -u -r1.3 kspread_functions_helper.cc --- kspread_functions_helper.cc 13 Dec 2002 04:16:52 -0000 1.3 +++ kspread_functions_helper.cc 27 Sep 2003 11:08:24 -0000 @@ -115,6 +115,43 @@ return false; } +bool getTime( KSContext & context, KSValue::Ptr & arg, QTime & time ) +{ + if ( !KSUtil::checkType( context, arg, KSValue::TimeType, true ) ) + { + if ( !KSUtil::checkType( context, arg, KSValue::StringType, true ) ) + { + if ( !KSUtil::checkType( context, arg, KSValue::DoubleType, true ) ) + return false; + + double d = arg->doubleValue(); + + KSpreadValue v(d); + time = v.asDateTime().time(); + + return true; + } + else + { + QString s = arg->stringValue(); + bool valid = false; + + time = KGlobal::locale()->readTime( s, &valid ); + if ( !valid ) + return false; + + return true; + } + } + else + { + time = arg->timeValue(); + return true; + } + + return false; +} + void addMonths( QDate & date, int months ) { int d = date.day(); Index: kspread_functions_helper.h =================================================================== RCS file: /home/kde/koffice/kspread/kspread_functions_helper.h,v retrieving revision 1.2 diff -u -r1.2 kspread_functions_helper.h --- kspread_functions_helper.h 27 Feb 2003 00:54:37 -0000 1.2 +++ kspread_functions_helper.h 27 Sep 2003 11:08:24 -0000 @@ -43,6 +43,7 @@ }; bool getDate( KSContext & context, KSValue::Ptr & arg, QDate & date ); +bool getTime( KSContext & context, KSValue::Ptr & arg, QTime & time ); void addMonths( QDate & date, int months ); --Boundary-00=_lEXd/nbjzhOICyX Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ koffice-devel mailing list koffice-devel@mail.kde.org http://mail.kde.org/mailman/listinfo/koffice-devel --Boundary-00=_lEXd/nbjzhOICyX--