kspread

KSpreadCellIface.cc

00001 /* This file is part of the KDE project
00002 
00003    Copyright 2002-2004 Ariya Hidayat <ariya@kde.org>
00004    Copyright 2002-2003 Philipp Mueller <philipp.mueller@gmx.de>
00005    Copyright 2002-2003 Norbert Andres <nandres@web.de>
00006    Copyright 2002-2003 Joseph Wenninger <jowenn@kde.org>
00007    Copyright 2002 John Dailey <dailey@vt.edu>
00008    Copyright 1999-2002 Laurent Montel <montel@kde.org>
00009    Copyright 2000-2001 David Faure <faure@kde.org>
00010    Copyright 1999-2000 Torben Weis <weis@kde.org>
00011 
00012    This library is free software; you can redistribute it and/or
00013    modify it under the terms of the GNU Library General Public
00014    License as published by the Free Software Foundation; either
00015    version 2 of the License, or (at your option) any later version.
00016 
00017    This library is distributed in the hope that it will be useful,
00018    but WITHOUT ANY WARRANTY; without even the implied warranty of
00019    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020    Library General Public License for more details.
00021 
00022    You should have received a copy of the GNU Library General Public License
00023    along with this library; see the file COPYING.LIB.  If not, write to
00024    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00025  * Boston, MA 02110-1301, USA.
00026 
00027 */
00028 
00029 #include "KSpreadCellIface.h"
00030 
00031 #include "kspread_doc.h"
00032 #include "kspread_sheet.h"
00033 #include "kspread_value.h"
00034 #include "valueconverter.h"
00035 
00036 using namespace KSpread;
00037 
00038 CellIface::CellIface()
00039   : m_point( 0, 0 ), m_sheet( 0 )
00040 {
00041 }
00042 
00043 void CellIface::setCell( Sheet* sheet, const QPoint& point )
00044 {
00045     m_sheet = sheet;
00046     m_point = point;
00047 }
00048 
00049 bool CellIface::isDefault() const
00050 {
00051     if( !m_sheet ) return false;
00052     Cell* cell = m_sheet->cellAt( m_point );
00053     return cell->isDefault();
00054 }
00055 
00056 bool CellIface::isEmpty() const
00057 {
00058     if (!m_sheet) return true;
00059     Cell *cell=m_sheet->cellAt(m_point);
00060     return cell->isEmpty();
00061 }
00062 
00063 QString CellIface::text() const
00064 {
00065     if( !m_sheet ) return QString::null;
00066     Cell* cell = m_sheet->cellAt( m_point );
00067     return m_sheet->doc()->converter()->asString (cell->value()).asString();
00068 }
00069 
00070 void CellIface::setText( const QString& text )
00071 {
00072     if( !m_sheet ) return;
00073     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00074     cell->setCellText( text );
00075 }
00076 
00077 QString CellIface::visibleContentAsString() const
00078 {
00079     if( !m_sheet ) return QString::null;
00080     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00081     if (cell->isEmpty()) return QString::null;
00082     QString ret;
00083     ret=cell->value().asString();
00084 
00085     if (ret.isEmpty())
00086     {
00087     ret=QString::number(cell->value().asFloat());
00088     }
00089     return ret;
00090 }
00091 
00092 QString CellIface::comment() const
00093 {
00094     if( !m_sheet ) return QString::null;
00095     Cell* cell = m_sheet->cellAt( m_point );
00096     return cell->format()->comment(m_point.x(), m_point.y());
00097 }
00098 
00099 void CellIface::setComment( const QString& comment )
00100 {
00101     if( !m_sheet ) return;
00102     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00103     cell->format()->setComment( comment);
00104     m_sheet->setRegionPaintDirty(cell->cellRect());
00105 }
00106 
00107 void CellIface::setValue( int value )
00108 {
00109     if( !m_sheet ) return;
00110     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00111     cell->setValue( (double)value );
00112 }
00113 
00114 void CellIface::setValue( double value )
00115 {
00116     if( !m_sheet ) return;
00117     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00118     cell->setValue( value );
00119 }
00120 
00121 double CellIface::value() const
00122 {
00123     if( !m_sheet ) return 0.0;
00124     Cell* cell = m_sheet->cellAt( m_point );
00125     return m_sheet->doc()->converter()->asFloat (cell->value()).asFloat();
00126 }
00127 
00128 void CellIface::setBgColor(const QString& _c)
00129 {
00130     if( !m_sheet ) return;
00131     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00132     QColor c(_c);
00133     cell->format()->setBgColor(c);
00134     m_sheet->setRegionPaintDirty(cell->cellRect());
00135 }
00136 
00137 void CellIface::setBgColor(int r,int g,int b)
00138 {
00139     if( !m_sheet ) return;
00140     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00141     QColor c(r,g,b);
00142     cell->format()->setBgColor(c);
00143     m_sheet->setRegionPaintDirty(cell->cellRect());
00144 }
00145 
00146 QString CellIface::bgColor() const
00147 {
00148     if( !m_sheet ) return QString::null;
00149     Cell* cell = m_sheet->cellAt( m_point );
00150     return cell->bgColor( m_point.x(), m_point.y() ).name();
00151 }
00152 
00153 QString CellIface::textColor() const
00154 {
00155     if( !m_sheet ) return QString::null;
00156     Cell* cell = m_sheet->cellAt( m_point );
00157     return cell->format()->textColor( m_point.x(), m_point.y() ).name();
00158 }
00159 
00160 void CellIface::setTextColor(int r,int g,int b)
00161 {
00162     if( !m_sheet ) return;
00163     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00164     QColor c(r,g,b);
00165     cell->format()->setTextColor(c);
00166     m_sheet->setRegionPaintDirty(cell->cellRect());
00167 }
00168 
00169 void CellIface::setTextColor(const QString& _c)
00170 {
00171     if( !m_sheet ) return;
00172     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00173     QColor c(_c);
00174     cell->format()->setTextColor(c);
00175     m_sheet->setRegionPaintDirty(cell->cellRect());
00176 }
00177 
00178 void CellIface::setAngle(int angle)
00179 {
00180     if( !m_sheet ) return;
00181     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00182     cell->format()->setAngle(angle);
00183     m_sheet->setRegionPaintDirty(cell->cellRect());
00184 }
00185 
00186 int  CellIface::angle() const
00187 {
00188     if( !m_sheet ) return 0;
00189     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00190     return cell->format()->getAngle(m_point.x(), m_point.y());
00191 }
00192 
00193 void CellIface::setVerticalText(bool _vertical)
00194 {
00195     if( !m_sheet ) return;
00196     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00197     cell->format()->setVerticalText(_vertical);
00198     m_sheet->setRegionPaintDirty(cell->cellRect());
00199 }
00200 
00201 bool CellIface::verticalText() const
00202 {
00203     if( !m_sheet ) return false;
00204     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00205     return cell->format()->verticalText( m_point.x(), m_point.y() );
00206 }
00207 
00208 
00209 void CellIface::setMultiRow(bool _multi)
00210 {
00211     if( !m_sheet ) return;
00212     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00213     cell->format()->setMultiRow( _multi );
00214     m_sheet->setRegionPaintDirty(cell->cellRect());
00215 }
00216 
00217 bool CellIface::multiRow() const
00218 {
00219     if( !m_sheet ) return false;
00220     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00221     return cell->format()->multiRow( m_point.x(), m_point.y() );
00222 }
00223 
00224 void CellIface::setAlign( const QString& _Align )
00225 {
00226     if( !m_sheet ) return;
00227     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00228     Format::Align Align;
00229     if(_Align=="Left")
00230         Align=Format::Left;
00231     else if(_Align=="Right")
00232         Align=Format::Right;
00233     else if(_Align=="Center")
00234         Align=Format::Center;
00235     else
00236         Align=Format::Undefined;
00237     cell->format()->setAlign( Align);
00238     m_sheet->setRegionPaintDirty(cell->cellRect());
00239 }
00240 
00241 QString CellIface::align() const
00242 {
00243     if( !m_sheet ) return QString::null;
00244     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00245     QString alignString;
00246     switch( cell->format()->align( m_point.x(), m_point.y() ) )
00247         {
00248         case Format::Left :
00249                 alignString="Left";
00250                 break;
00251         case Format::Right :
00252                 alignString="Right";
00253                 break;
00254         case Format::Center :
00255                 alignString="Center";
00256                 break;
00257         case Format::Undefined :
00258                 alignString="Undefined";
00259                 break;
00260         }
00261     return alignString;
00262 }
00263 
00264 void CellIface::setAlignY( const QString& _AlignY )
00265 {
00266     if( !m_sheet ) return;
00267     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00268     Format::AlignY AlignY;
00269     if(_AlignY=="Top")
00270         AlignY=Format::Top;
00271     else if(_AlignY=="Middle")
00272         AlignY=Format::Middle;
00273     else if(_AlignY=="Bottom")
00274         AlignY=Format::Bottom;
00275     else
00276         AlignY=Format::Middle;
00277     cell->format()->setAlignY( AlignY);
00278     m_sheet->setRegionPaintDirty(cell->cellRect());
00279 }
00280 
00281 QString CellIface::alignY() const
00282 {
00283     if( !m_sheet ) return QString::null;
00284     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00285     QString alignString;
00286     switch( cell->format()->alignY( m_point.x(), m_point.y() ) )
00287         {
00288         case Format::Top :
00289                 alignString="Top";
00290                 break;
00291         case Format::Middle :
00292                 alignString="Middle";
00293                 break;
00294         case Format::Bottom :
00295                 alignString="Bottom";
00296                 break;
00297         case Format::UndefinedY :
00298                 alignString="UndefinedY";
00299                 break;
00300         }
00301     return alignString;
00302 }
00303 
00304 void CellIface::setPostfix(const QString &_postfix)
00305 {
00306     if( !m_sheet ) return;
00307     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00308     cell->format()->setPostfix( _postfix );
00309     m_sheet->setRegionPaintDirty(cell->cellRect());
00310 }
00311 
00312 QString CellIface::prefix() const
00313 {
00314     if( !m_sheet ) return QString::null;
00315     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00316     return cell->format()->prefix( m_point.x(), m_point.y() );
00317 }
00318 
00319 void CellIface::setPrefix(const QString &_prefix)
00320 {
00321     if( !m_sheet ) return;
00322     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00323     cell->format()->setPrefix( _prefix );
00324     m_sheet->setRegionPaintDirty(cell->cellRect());
00325 }
00326 
00327 QString CellIface::postfix() const
00328 {
00329     if( !m_sheet ) return QString::null;
00330     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00331     return cell->format()->postfix( m_point.x(), m_point.y() );
00332 }
00333 
00334 void CellIface::setFormatType(const QString &_formatType)
00335 {
00336     if( !m_sheet ) return;
00337 
00338     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00339     FormatType format;
00340     cell->format()->setPrecision(2);
00341     if (_formatType=="Generic")
00342         format = Generic_format;
00343     else if(_formatType=="Number")
00344         format=Number_format;
00345     else if (_formatType=="Text")
00346         format=Text_format;
00347     else if(_formatType=="Money")
00348         format=Money_format;
00349     else if(_formatType=="Percentage")
00350         format=Percentage_format;
00351     else if(_formatType=="Scientific")
00352         format=Scientific_format;
00353     else if(_formatType=="ShortDate")
00354         format=ShortDate_format;
00355     else if(_formatType=="TextDate")
00356         format=TextDate_format;
00357     else if(_formatType=="Time")
00358         format=Time_format;
00359     else if(_formatType=="SecondeTime")
00360         format=SecondeTime_format;
00361     else if(_formatType=="fraction_half")
00362         format=fraction_half;
00363     else if(_formatType=="fraction_quarter")
00364         format=fraction_quarter;
00365     else if(_formatType=="fraction_eighth")
00366         format=fraction_eighth;
00367     else if(_formatType=="fraction_sixteenth")
00368         format=fraction_sixteenth;
00369     else if(_formatType=="fraction_tenth")
00370         format=fraction_tenth;
00371     else if(_formatType=="fraction_hundredth")
00372         format=fraction_hundredth;
00373     else if(_formatType=="fraction_one_digit")
00374         format=fraction_one_digit;
00375     else if(_formatType=="fraction_two_digits")
00376         format=fraction_two_digits;
00377     else if(_formatType=="fraction_three_digits")
00378         format=fraction_three_digits;
00379     else
00380         format=Generic_format;
00381     cell->format()->setFormatType( format);
00382     m_sheet->setRegionPaintDirty(cell->cellRect());
00383 }
00384 
00385 QString CellIface::getFormatType() const
00386 {
00387     if( !m_sheet ) return QString::null;
00388 
00389     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00390     QString stringFormat;
00391     switch( cell->format()->getFormatType(m_point.x(), m_point.y()))
00392         {
00393         case Text_format:
00394             stringFormat="Text";
00395             break;
00396         case Number_format:
00397                 stringFormat="Number";
00398                 break;
00399         case Money_format:
00400                 stringFormat="Money";
00401                 break;
00402         case Percentage_format:
00403                 stringFormat="Percentage";
00404                 break;
00405         case Scientific_format:
00406                 stringFormat="Scientific";
00407                 break;
00408         case ShortDate_format:
00409                 stringFormat="ShortDate";
00410                 break;
00411         case TextDate_format:
00412                 stringFormat="TextDate";
00413                 break;
00414         case date_format1:
00415         case date_format2:
00416         case date_format3:
00417         case date_format4:
00418         case date_format5:
00419         case date_format6:
00420         case date_format7:
00421         case date_format8:
00422         case date_format9:
00423         case date_format10:
00424         case date_format11:
00425         case date_format12:
00426         case date_format13:
00427         case date_format14:
00428         case date_format15:
00429         case date_format16:
00430     case date_format17:
00431     case date_format18:
00432     case date_format19:
00433     case date_format20:
00434     case date_format21:
00435     case date_format22:
00436     case date_format23:
00437     case date_format24:
00438     case date_format25:
00439     case date_format26:
00440                 stringFormat="date format";
00441                 break;
00442         case Time_format:
00443                 stringFormat="Time";
00444                 break;
00445         case SecondeTime_format:
00446                 stringFormat="SecondeTime";
00447                 break;
00448         case Time_format1:
00449         case Time_format2:
00450         case Time_format3:
00451         case Time_format4:
00452         case Time_format5:
00453         case Time_format6:
00454         case Time_format7:
00455         case Time_format8:
00456                 stringFormat="time format";
00457                 break;
00458         case fraction_half:
00459                 stringFormat="fraction_half";
00460                 break;
00461         case fraction_quarter:
00462                 stringFormat="fraction_quarter";
00463                 break;
00464         case fraction_eighth:
00465                 stringFormat="fraction_eighth";
00466                 break;
00467         case fraction_sixteenth:
00468                 stringFormat="fraction_sixteenth";
00469                 break;
00470         case fraction_tenth:
00471                 stringFormat="fraction_tenth";
00472                 break;
00473         case fraction_hundredth:
00474                 stringFormat="fraction_hundredth";
00475                 break;
00476         case fraction_one_digit:
00477                 stringFormat="fraction_one_digit";
00478                 break;
00479         case fraction_two_digits:
00480                 stringFormat="fraction_two_digits";
00481                 break;
00482         case fraction_three_digits:
00483                 stringFormat="fraction_three_digits";
00484                 break;
00485         default:
00486                 break;
00487         }
00488     return stringFormat;
00489 }
00490 
00491 void CellIface::setPrecision(int _p)
00492 {
00493     if( !m_sheet ) return;
00494     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00495     cell->format()->setPrecision( _p );
00496     m_sheet->setRegionPaintDirty(cell->cellRect());
00497 }
00498 
00499 int CellIface::precision() const
00500 {
00501     if( !m_sheet ) return 0;
00502     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00503     return cell->format()->precision( m_point.x(), m_point.y() );
00504 }
00505 
00506 void CellIface::setTextFontBold(bool _b)
00507 {
00508     if( !m_sheet ) return;
00509     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00510     cell->format()->setTextFontBold( _b );
00511     m_sheet->setRegionPaintDirty(cell->cellRect());
00512 }
00513 
00514 bool CellIface::textFontBold() const
00515 {
00516     if( !m_sheet ) return false;
00517     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00518     return cell->format()->textFontBold( m_point.x(), m_point.y() );
00519 }
00520 
00521 void CellIface::setTextFontItalic(bool _b)
00522 {
00523     if( !m_sheet ) return;
00524     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00525     cell->format()->setTextFontItalic( _b );
00526     m_sheet->setRegionPaintDirty(cell->cellRect());
00527 }
00528 
00529 bool CellIface::textFontItalic() const
00530 {
00531     if( !m_sheet ) return false;
00532     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00533     return cell->format()->textFontItalic( m_point.x(), m_point.y() );
00534 }
00535 
00536 
00537 void CellIface::setTextFontUnderline(bool _b)
00538 {
00539     if( !m_sheet ) return;
00540     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00541     cell->format()->setTextFontUnderline( _b );
00542     m_sheet->setRegionPaintDirty(cell->cellRect());
00543 }
00544 
00545 bool CellIface::textFontUnderline() const
00546 {
00547     if( !m_sheet ) return false;
00548     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00549     return cell->format()->textFontUnderline( m_point.x(), m_point.y() );
00550 }
00551 
00552 void CellIface::setTextFontStrike(bool _b)
00553 {
00554     if( !m_sheet ) return;
00555     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00556     cell->format()->setTextFontStrike( _b );
00557     m_sheet->setRegionPaintDirty(cell->cellRect());
00558 }
00559 
00560 bool CellIface::textFontStrike() const
00561 {
00562     if( !m_sheet ) return false;
00563     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00564     return cell->format()->textFontStrike( m_point.x(), m_point.y() );
00565 }
00566 
00567 void CellIface::setTextFontSize( int _size )
00568 {
00569     if( !m_sheet ) return;
00570     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00571     cell->format()->setTextFontSize( _size );
00572     m_sheet->setRegionPaintDirty(cell->cellRect());
00573 }
00574 
00575 int CellIface::textFontSize() const
00576 {
00577     if( !m_sheet ) return 10;
00578     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00579     return cell->format()->textFontSize( m_point.x(), m_point.y() );
00580 }
00581 
00582 void CellIface::setTextFontFamily( const QString& _font )
00583 {
00584     if( !m_sheet ) return;
00585     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00586     cell->format()->setTextFontFamily( _font );
00587     m_sheet->setRegionPaintDirty(cell->cellRect());
00588 }
00589 
00590 QString CellIface::textFontFamily() const
00591 {
00592     if( !m_sheet ) return QString::null;
00593     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00594     return cell->format()->textFontFamily( m_point.x(), m_point.y() );
00595 }
00596 
00597 //border left
00598 void CellIface::setLeftBorderStyle( const QString& _style )
00599 {
00600     if( !m_sheet ) return;
00601     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00602     if(_style=="DotLine")
00603       cell->format()->setLeftBorderStyle(Qt::DotLine);
00604     else if(_style=="DashLine")
00605       cell->format()->setLeftBorderStyle(Qt::DashLine);
00606     else if(_style=="DashDotLine")
00607       cell->format()->setLeftBorderStyle(Qt::DashDotLine);
00608     else if(_style=="DashDotDotLine")
00609       cell->format()->setLeftBorderStyle(Qt::DashDotDotLine);
00610     else if(_style=="SolidLine")
00611       cell->format()->setLeftBorderStyle(Qt::SolidLine);
00612     else
00613       cell->format()->setLeftBorderStyle(Qt::SolidLine);
00614     m_sheet->setRegionPaintDirty(cell->cellRect());
00615 
00616 }
00617 
00618 void CellIface::setLeftBorderColor(const QString& _c)
00619 {
00620     if( !m_sheet ) return;
00621     QColor c(_c);
00622     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00623     cell->format()->setLeftBorderColor(c );
00624     m_sheet->setRegionPaintDirty(cell->cellRect());
00625 
00626 }
00627 
00628 void CellIface::setLeftBorderColor(int r,int g,int b)
00629 {
00630     if( !m_sheet ) return;
00631     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00632     QColor c(r,g,b);
00633     cell->format()->setLeftBorderColor(c );
00634     m_sheet->setRegionPaintDirty(cell->cellRect());
00635 }
00636 
00637 void CellIface::setLeftBorderWidth( int _size )
00638 {
00639     if( !m_sheet ) return;
00640     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00641     cell->format()->setLeftBorderWidth( _size );
00642     m_sheet->setRegionPaintDirty(cell->cellRect());
00643 }
00644 
00645 
00646 int  CellIface::leftBorderWidth() const
00647 {
00648     if( !m_sheet ) return 0;
00649     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00650     return cell->format()->leftBorderWidth(m_point.x(), m_point.y());
00651 }
00652 
00653 QString CellIface::leftBorderColor() const
00654 {
00655     if( !m_sheet ) return QString::null;
00656     Cell* cell = m_sheet->cellAt( m_point );
00657     return cell->format()->leftBorderColor( m_point.x(), m_point.y() ).name();
00658 }
00659 
00660 QString CellIface::leftBorderStyle() const
00661 {
00662     if( !m_sheet ) return QString::null;
00663     Cell* cell = m_sheet->cellAt( m_point );
00664     Qt::PenStyle penStyle=cell->format()->leftBorderStyle( m_point.x(), m_point.y() );
00665     QString tmp;
00666     if( penStyle==Qt::DotLine)
00667         tmp="DotLine";
00668     else if( penStyle==Qt::DashLine)
00669         tmp="DashLine";
00670     else if( penStyle==Qt::DashDotLine)
00671         tmp="DashDotLine";
00672     else if( penStyle==Qt::DashDotDotLine)
00673         tmp="DashDotDotLine";
00674     else if( penStyle==Qt::SolidLine)
00675         tmp="SolidLine";
00676     else
00677         tmp="SolidLine";
00678     return tmp;
00679 }
00680 
00681 //border right
00682 void CellIface::setRightBorderStyle( const QString& _style )
00683 {
00684     if( !m_sheet ) return;
00685     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00686     if(_style=="DotLine")
00687       cell->format()->setRightBorderStyle(Qt::DotLine);
00688     else if(_style=="DashLine")
00689       cell->format()->setRightBorderStyle(Qt::DashLine);
00690     else if(_style=="DashDotLine")
00691       cell->format()->setRightBorderStyle(Qt::DashDotLine);
00692     else if(_style=="DashDotDotLine")
00693       cell->format()->setRightBorderStyle(Qt::DashDotDotLine);
00694     else if(_style=="SolidLine")
00695       cell->format()->setRightBorderStyle(Qt::SolidLine);
00696     else
00697       cell->format()->setRightBorderStyle(Qt::SolidLine);
00698     m_sheet->setRegionPaintDirty(cell->cellRect());
00699 
00700 }
00701 
00702 void CellIface::setRightBorderColor(const QString& _c)
00703 {
00704     if( !m_sheet ) return;
00705     QColor c(_c);
00706     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00707     cell->format()->setRightBorderColor(c );
00708     m_sheet->setRegionPaintDirty(cell->cellRect());
00709 
00710 }
00711 void CellIface::setRightBorderColor(int r,int g,int b)
00712 {
00713     if( !m_sheet ) return;
00714     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00715     QColor c(r,g,b);
00716     cell->format()->setRightBorderColor(c );
00717     m_sheet->setRegionPaintDirty(cell->cellRect());
00718 }
00719 
00720 void CellIface::setRightBorderWidth( int _size )
00721 {
00722     if( !m_sheet ) return;
00723     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00724     cell->format()->setRightBorderWidth( _size );
00725     m_sheet->setRegionPaintDirty(cell->cellRect());
00726 
00727 }
00728 
00729 int  CellIface::rightBorderWidth() const
00730 {
00731     if( !m_sheet ) return 0;
00732     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00733     return cell->format()->rightBorderWidth(m_point.x(), m_point.y());
00734 }
00735 
00736 QString CellIface::rightBorderColor() const
00737 {
00738     if( !m_sheet ) return QString::null;
00739     Cell* cell = m_sheet->cellAt( m_point );
00740     return cell->format()->rightBorderColor( m_point.x(), m_point.y() ).name();
00741 }
00742 
00743 QString CellIface::rightBorderStyle() const
00744 {
00745     if( !m_sheet ) return QString::null;
00746     Cell* cell = m_sheet->cellAt( m_point );
00747     Qt::PenStyle penStyle=cell->format()->rightBorderStyle( m_point.x(), m_point.y() );
00748     QString tmp;
00749     if( penStyle==Qt::DotLine)
00750         tmp="DotLine";
00751     else if( penStyle==Qt::DashLine)
00752         tmp="DashLine";
00753     else if( penStyle==Qt::DashDotLine)
00754         tmp="DashDotLine";
00755     else if( penStyle==Qt::DashDotDotLine)
00756         tmp="DashDotDotLine";
00757     else if( penStyle==Qt::SolidLine)
00758         tmp="SolidLine";
00759     else
00760         tmp="SolidLine";
00761     return tmp;
00762 }
00763 
00764 //border top
00765 void CellIface::setTopBorderStyle( const QString& _style )
00766 {
00767     if( !m_sheet ) return;
00768     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00769     if(_style=="DotLine")
00770       cell->format()->setTopBorderStyle(Qt::DotLine);
00771     else if(_style=="DashLine")
00772       cell->format()->setTopBorderStyle(Qt::DashLine);
00773     else if(_style=="DashDotLine")
00774       cell->format()->setTopBorderStyle(Qt::DashDotLine);
00775     else if(_style=="DashDotDotLine")
00776       cell->format()->setTopBorderStyle(Qt::DashDotDotLine);
00777     else if(_style=="SolidLine")
00778       cell->format()->setTopBorderStyle(Qt::SolidLine);
00779     else
00780       cell->format()->setTopBorderStyle(Qt::SolidLine);
00781     m_sheet->setRegionPaintDirty(cell->cellRect());
00782 
00783 }
00784 
00785 void CellIface::setTopBorderColor(const QString& _c)
00786 {
00787     if( !m_sheet ) return;
00788     QColor c(_c);
00789     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00790     cell->format()->setTopBorderColor(c );
00791     m_sheet->setRegionPaintDirty(cell->cellRect());
00792 
00793 }
00794 void CellIface::setTopBorderColor(int r,int g,int b)
00795 {
00796     if( !m_sheet ) return;
00797     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00798     QColor c(r,g,b);
00799     cell->format()->setTopBorderColor(c );
00800     m_sheet->setRegionPaintDirty(cell->cellRect());
00801 }
00802 
00803 void CellIface::setTopBorderWidth( int _size )
00804 {
00805     if( !m_sheet ) return;
00806     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00807     cell->format()->setTopBorderWidth( _size );
00808     m_sheet->setRegionPaintDirty(cell->cellRect());
00809 }
00810 
00811 int  CellIface::topBorderWidth() const
00812 {
00813     if( !m_sheet ) return 0;
00814     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00815     return cell->format()->topBorderWidth(m_point.x(), m_point.y());
00816 }
00817 
00818 QString CellIface::topBorderColor() const
00819 {
00820     if( !m_sheet ) return QString::null;
00821     Cell* cell = m_sheet->cellAt( m_point );
00822     return cell->format()->topBorderColor( m_point.x(), m_point.y() ).name();
00823 }
00824 
00825 QString CellIface::topBorderStyle() const
00826 {
00827     if( !m_sheet ) return QString::null;
00828     Cell* cell = m_sheet->cellAt( m_point );
00829     Qt::PenStyle penStyle=cell->format()->topBorderStyle( m_point.x(), m_point.y() );
00830     QString tmp;
00831     if( penStyle==Qt::DotLine)
00832         tmp="DotLine";
00833     else if( penStyle==Qt::DashLine)
00834         tmp="DashLine";
00835     else if( penStyle==Qt::DashDotLine)
00836         tmp="DashDotLine";
00837     else if( penStyle==Qt::DashDotDotLine)
00838         tmp="DashDotDotLine";
00839     else if( penStyle==Qt::SolidLine)
00840         tmp="SolidLine";
00841     else
00842         tmp="SolidLine";
00843     return tmp;
00844 }
00845 
00846 //border bottom
00847 void CellIface::setBottomBorderStyle( const QString& _style )
00848 {
00849     if( !m_sheet ) return;
00850     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00851     if(_style=="DotLine")
00852       cell->format()->setBottomBorderStyle(Qt::DotLine);
00853     else if(_style=="DashLine")
00854       cell->format()->setBottomBorderStyle(Qt::DashLine);
00855     else if(_style=="DashDotLine")
00856       cell->format()->setBottomBorderStyle(Qt::DashDotLine);
00857     else if(_style=="DashDotDotLine")
00858       cell->format()->setBottomBorderStyle(Qt::DashDotDotLine);
00859     else if(_style=="SolidLine")
00860       cell->format()->setBottomBorderStyle(Qt::SolidLine);
00861     else
00862       cell->format()->setBottomBorderStyle(Qt::SolidLine);
00863     m_sheet->setRegionPaintDirty(cell->cellRect());
00864 
00865 }
00866 
00867 void CellIface::setBottomBorderColor(const QString& _c)
00868 {
00869     if( !m_sheet ) return;
00870     QColor c(_c);
00871     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00872     cell->format()->setBottomBorderColor(c );
00873     m_sheet->setRegionPaintDirty(cell->cellRect());
00874 
00875 }
00876 void CellIface::setBottomBorderColor(int r,int g,int b)
00877 {
00878     if( !m_sheet ) return;
00879     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00880     QColor c(r,g,b);
00881     cell->format()->setBottomBorderColor(c );
00882     m_sheet->setRegionPaintDirty(cell->cellRect());
00883 }
00884 
00885 void CellIface::setBottomBorderWidth( int _size )
00886 {
00887     if( !m_sheet ) return;
00888     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00889     cell->format()->setBottomBorderWidth( _size );
00890     m_sheet->setRegionPaintDirty(cell->cellRect());
00891 }
00892 
00893 int  CellIface::bottomBorderWidth() const
00894 {
00895     if( !m_sheet ) return 0;
00896     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00897     return cell->format()->bottomBorderWidth(m_point.x(), m_point.y());
00898 }
00899 
00900 QString CellIface::bottomBorderColor() const
00901 {
00902     if( !m_sheet ) return QString::null;
00903     Cell* cell = m_sheet->cellAt( m_point );
00904     return cell->format()->bottomBorderColor( m_point.x(), m_point.y() ).name();
00905 }
00906 
00907 QString CellIface::bottomBorderStyle() const
00908 {
00909     if( !m_sheet ) return QString::null;
00910     Cell* cell = m_sheet->cellAt( m_point );
00911     Qt::PenStyle penStyle=cell->format()->bottomBorderStyle( m_point.x(), m_point.y() );
00912     QString tmp;
00913     if( penStyle==Qt::DotLine)
00914         tmp="DotLine";
00915     else if( penStyle==Qt::DashLine)
00916         tmp="DashLine";
00917     else if( penStyle==Qt::DashDotLine)
00918         tmp="DashDotLine";
00919     else if( penStyle==Qt::DashDotDotLine)
00920         tmp="DashDotDotLine";
00921     else if( penStyle==Qt::SolidLine)
00922         tmp="SolidLine";
00923     else
00924         tmp="SolidLine";
00925     return tmp;
00926 }
00927 
00928 //fall back diagonal
00929 void CellIface::setFallDiagonalStyle( const QString& _style )
00930 {
00931     if( !m_sheet ) return;
00932     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00933     if(_style=="DotLine")
00934       cell->format()->setFallDiagonalStyle(Qt::DotLine);
00935     else if(_style=="DashLine")
00936       cell->format()->setFallDiagonalStyle(Qt::DashLine);
00937     else if(_style=="DashDotLine")
00938       cell->format()->setFallDiagonalStyle(Qt::DashDotLine);
00939     else if(_style=="DashDotDotLine")
00940       cell->format()->setFallDiagonalStyle(Qt::DashDotDotLine);
00941     else if(_style=="SolidLine")
00942       cell->format()->setFallDiagonalStyle(Qt::SolidLine);
00943     else
00944       cell->format()->setFallDiagonalStyle(Qt::SolidLine);
00945     m_sheet->setRegionPaintDirty(cell->cellRect());
00946 
00947 }
00948 
00949 void CellIface::setFallDiagonalColor(const QString& _c)
00950 {
00951     if( !m_sheet ) return;
00952     QColor c(_c);
00953     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00954     cell->format()->setFallDiagonalColor(c );
00955     m_sheet->setRegionPaintDirty(cell->cellRect());
00956 
00957 }
00958 void CellIface::setFallDiagonalColor(int r,int g,int b)
00959 {
00960     if( !m_sheet ) return;
00961     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00962     QColor c(r,g,b);
00963     cell->format()->setFallDiagonalColor(c );
00964     m_sheet->setRegionPaintDirty(cell->cellRect());
00965 }
00966 
00967 void CellIface::setFallDiagonalWidth( int _size )
00968 {
00969     if( !m_sheet ) return;
00970     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00971     cell->format()->setFallDiagonalWidth( _size );
00972     m_sheet->setRegionPaintDirty(cell->cellRect());
00973 }
00974 
00975 int  CellIface::fallDiagonalWidth() const
00976 {
00977     if( !m_sheet ) return 0;
00978     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
00979     return cell->format()->fallDiagonalWidth(m_point.x(), m_point.y());
00980 }
00981 
00982 QString CellIface::fallDiagonalColor() const
00983 {
00984     if( !m_sheet ) return QString::null;
00985     Cell* cell = m_sheet->cellAt( m_point );
00986     return cell->format()->fallDiagonalColor( m_point.x(), m_point.y() ).name();
00987 }
00988 
00989 QString CellIface::fallDiagonalStyle() const
00990 {
00991     if( !m_sheet ) return QString::null;
00992     Cell* cell = m_sheet->cellAt( m_point );
00993     Qt::PenStyle penStyle=cell->format()->fallDiagonalStyle( m_point.x(), m_point.y() );
00994     QString tmp;
00995     if( penStyle==Qt::DotLine)
00996         tmp="DotLine";
00997     else if( penStyle==Qt::DashLine)
00998         tmp="DashLine";
00999     else if( penStyle==Qt::DashDotLine)
01000         tmp="DashDotLine";
01001     else if( penStyle==Qt::DashDotDotLine)
01002         tmp="DashDotDotLine";
01003     else if( penStyle==Qt::SolidLine)
01004         tmp="SolidLine";
01005     else
01006         tmp="SolidLine";
01007     return tmp;
01008 }
01009 
01010 
01011 //GoUpDiagonal
01012 void CellIface::setGoUpDiagonalStyle( const QString& _style )
01013 {
01014     if( !m_sheet ) return;
01015     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01016     if(_style=="DotLine")
01017       cell->format()->setGoUpDiagonalStyle(Qt::DotLine);
01018     else if(_style=="DashLine")
01019       cell->format()->setGoUpDiagonalStyle(Qt::DashLine);
01020     else if(_style=="DashDotLine")
01021       cell->format()->setGoUpDiagonalStyle(Qt::DashDotLine);
01022     else if(_style=="DashDotDotLine")
01023       cell->format()->setGoUpDiagonalStyle(Qt::DashDotDotLine);
01024     else if(_style=="SolidLine")
01025       cell->format()->setGoUpDiagonalStyle(Qt::SolidLine);
01026     else
01027       cell->format()->setGoUpDiagonalStyle(Qt::SolidLine);
01028     m_sheet->setRegionPaintDirty(cell->cellRect());
01029 
01030 }
01031 
01032 void CellIface::setGoUpDiagonalColor(const QString& _c)
01033 {
01034     if( !m_sheet ) return;
01035     QColor c(_c);
01036     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01037     cell->format()->setGoUpDiagonalColor(c );
01038     m_sheet->setRegionPaintDirty(cell->cellRect());
01039 
01040 }
01041 void CellIface::setGoUpDiagonalColor(int r,int g,int b)
01042 {
01043     if( !m_sheet ) return;
01044     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01045     QColor c(r,g,b);
01046     cell->format()->setGoUpDiagonalColor(c );
01047     m_sheet->setRegionPaintDirty(cell->cellRect());
01048 }
01049 
01050 void CellIface::setGoUpDiagonalWidth( int _size )
01051 {
01052     if( !m_sheet ) return;
01053     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01054     cell->format()->setGoUpDiagonalWidth( _size );
01055     m_sheet->setRegionPaintDirty(cell->cellRect());
01056 }
01057 
01058 int  CellIface::goUpDiagonalWidth() const
01059 {
01060     if( !m_sheet ) return 0;
01061     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01062     return cell->format()->goUpDiagonalWidth(m_point.x(), m_point.y());
01063 }
01064 
01065 QString CellIface::goUpDiagonalColor() const
01066 {
01067     if( !m_sheet ) return QString::null;
01068     Cell* cell = m_sheet->cellAt( m_point );
01069     return cell->format()->goUpDiagonalColor( m_point.x(), m_point.y() ).name();
01070 }
01071 
01072 QString CellIface::goUpDiagonalStyle() const
01073 {
01074     if( !m_sheet ) return QString::null;
01075     Cell* cell = m_sheet->cellAt( m_point );
01076     Qt::PenStyle penStyle=cell->format()->goUpDiagonalStyle( m_point.x(), m_point.y() );
01077     QString tmp;
01078     if( penStyle==Qt::DotLine)
01079         tmp="DotLine";
01080     else if( penStyle==Qt::DashLine)
01081         tmp="DashLine";
01082     else if( penStyle==Qt::DashDotLine)
01083         tmp="DashDotLine";
01084     else if( penStyle==Qt::DashDotDotLine)
01085         tmp="DashDotDotLine";
01086     else if( penStyle==Qt::SolidLine)
01087         tmp="SolidLine";
01088     else
01089         tmp="SolidLine";
01090     return tmp;
01091 }
01092 
01093 void CellIface::setIndent(double indent)
01094 {
01095     if( !m_sheet ) return;
01096     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01097     if( indent >= 0.0 )
01098       cell->format()->setIndent( indent );
01099     else
01100       cell->format()->setIndent( 0.0 );
01101     m_sheet->setRegionPaintDirty(cell->cellRect());
01102 }
01103 
01104 double CellIface::getIndent() const
01105 {
01106     if( !m_sheet ) return 0.0;
01107     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01108     return cell->format()->getIndent( m_point.x(), m_point.y() );
01109 }
01110 
01111 void CellIface::setDontPrintText ( bool _print)
01112 {
01113     if( !m_sheet ) return;
01114     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01115     cell->format()->setDontPrintText ( _print);
01116 }
01117 
01118 bool CellIface::getDontprintText() const
01119 {
01120     if( !m_sheet ) return false;
01121     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01122     return cell->format()->getDontprintText(m_point.x(), m_point.y());
01123 }
01124 
01125 bool CellIface::hasValidation() const
01126 {
01127     if( !m_sheet ) return false;
01128     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01129     if ( cell->getValidity( 0  ) )
01130         return true;
01131     else
01132         return false;
01133 }
01134 
01135 QString CellIface::validationTitle() const
01136 {
01137     if( !m_sheet ) return "";
01138     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01139     if ( cell->getValidity( 0  ) )
01140     {
01141         return cell->getValidity( 0  )->title;
01142     }
01143     else
01144         return "";
01145 }
01146 
01147 QString CellIface::validationMessage() const
01148 {
01149     if( !m_sheet ) return "";
01150     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01151     if ( cell->getValidity( 0  ) )
01152     {
01153         return cell->getValidity( 0  )->message;
01154     }
01155     else
01156         return "";
01157 }
01158 
01159 QStringList CellIface::listValidation() const
01160 {
01161     if( !m_sheet ) return QStringList();
01162     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01163     if ( cell->getValidity( 0  ) )
01164     {
01165         return cell->getValidity( 0  )->listValidity;
01166     }
01167     else
01168         return QStringList();
01169 }
01170 
01171 
01172 QString CellIface::validationTitleInfo() const
01173 {
01174     if( !m_sheet ) return "";
01175     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01176     if ( cell->getValidity( 0  ) )
01177     {
01178         return cell->getValidity( 0  )->titleInfo;
01179     }
01180     else
01181         return "";
01182 }
01183 
01184 QString CellIface::validationMessageInfo() const
01185 {
01186     if( !m_sheet ) return "";
01187     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01188     if ( cell->getValidity( 0  ) )
01189     {
01190         return cell->getValidity( 0  )->messageInfo;
01191     }
01192     else
01193         return "";
01194 }
01195 
01196 
01197 bool CellIface::displayValidationInformation() const
01198 {
01199     if( !m_sheet ) return false;
01200     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01201     if ( cell->getValidity( 0  ) )
01202     {
01203         return cell->getValidity( 0  )->displayValidationInformation;
01204     }
01205     else
01206         return false;
01207 }
01208 
01209 bool CellIface::displayValidationMessage() const
01210 {
01211     if( !m_sheet ) return false;
01212     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01213     if ( cell->getValidity( 0  ) )
01214     {
01215         return cell->getValidity( 0  )->displayMessage;
01216     }
01217     else
01218         return false;
01219 }
01220 
01221 bool CellIface::validationAllowEmptyCell() const
01222 {
01223     if( !m_sheet ) return false;
01224     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01225     if ( cell->getValidity( 0  ) )
01226     {
01227         return cell->getValidity( 0  )->allowEmptyCell;
01228     }
01229     else
01230         return false;
01231 }
01232 
01233 void CellIface::removeValidity()
01234 {
01235     if( !m_sheet ) return;
01236     Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
01237     cell->removeValidity();
01238 }
KDE Home | KDE Accessibility Home | Description of Access Keys