kspread

KSpreadCellIface.cpp
1/* This file is part of the KDE project
2
3 Copyright 2002-2004 Ariya Hidayat <ariya@kde.org>
4 Copyright 2002-2003 Philipp Mueller <philipp.mueller@gmx.de>
5 Copyright 2002-2003 Norbert Andres <nandres@web.de>
6 Copyright 2002-2003 Joseph Wenninger <jowenn@kde.org>
7 Copyright 2002 John Dailey <dailey@vt.edu>
8 Copyright 1999-2002 Laurent Montel <montel@kde.org>
9 Copyright 2000-2001 David Faure <faure@kde.org>
10 Copyright 1999-2000 Torben Weis <weis@kde.org>
11
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Library General Public
14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version.
16
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Library General Public License for more details.
21
22 You should have received a copy of the GNU Library General Public License
23 along with this library; see the file COPYING.LIB. If not, write to
24 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 * Boston, MA 02110-1301, USA.
26
27*/
28
29#include "KSpreadCellIface.h"
30
31#include "kspread_doc.h"
32#include "kspread_sheet.h"
33#include "kspread_value.h"
34#include "valueconverter.h"
35
36using namespace KSpread;
37
38CellIface::CellIface()
39 : m_point( 0, 0 ), m_sheet( 0 )
40{
41}
42
43void CellIface::setCell( Sheet* sheet, const TQPoint& point )
44{
45 m_sheet = sheet;
46 m_point = point;
47}
48
49bool CellIface::isDefault() const
50{
51 if( !m_sheet ) return false;
52 Cell* cell = m_sheet->cellAt( m_point );
53 return cell->isDefault();
54}
55
56bool CellIface::isEmpty() const
57{
58 if (!m_sheet) return true;
59 Cell *cell=m_sheet->cellAt(m_point);
60 return cell->isEmpty();
61}
62
63TQString CellIface::text() const
64{
65 if( !m_sheet ) return TQString();
66 Cell* cell = m_sheet->cellAt( m_point );
67 return m_sheet->doc()->converter()->asString (cell->value()).asString();
68}
69
70void CellIface::setText( const TQString& text )
71{
72 if( !m_sheet ) return;
73 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
74 cell->setCellText( text );
75}
76
77TQString CellIface::visibleContentAsString() const
78{
79 if( !m_sheet ) return TQString();
80 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
81 if (cell->isEmpty()) return TQString();
82 TQString ret;
83 ret=cell->value().asString();
84
85 if (ret.isEmpty())
86 {
87 ret=TQString::number(cell->value().asFloat());
88 }
89 return ret;
90}
91
92TQString CellIface::comment() const
93{
94 if( !m_sheet ) return TQString();
95 Cell* cell = m_sheet->cellAt( m_point );
96 return cell->format()->comment(m_point.x(), m_point.y());
97}
98
99void CellIface::setComment( const TQString& comment )
100{
101 if( !m_sheet ) return;
102 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
103 cell->format()->setComment( comment);
104 m_sheet->setRegionPaintDirty(cell->cellRect());
105}
106
107void CellIface::setValue( int value )
108{
109 if( !m_sheet ) return;
110 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
111 cell->setValue( (double)value );
112}
113
114void CellIface::setValue( double value )
115{
116 if( !m_sheet ) return;
117 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
118 cell->setValue( value );
119}
120
121double CellIface::value() const
122{
123 if( !m_sheet ) return 0.0;
124 Cell* cell = m_sheet->cellAt( m_point );
125 return m_sheet->doc()->converter()->asFloat (cell->value()).asFloat();
126}
127
128void CellIface::setBgColor(const TQString& _c)
129{
130 if( !m_sheet ) return;
131 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
132 TQColor c(_c);
133 cell->format()->setBgColor(c);
134 m_sheet->setRegionPaintDirty(cell->cellRect());
135}
136
137void CellIface::setBgColor(int r,int g,int b)
138{
139 if( !m_sheet ) return;
140 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
141 TQColor c(r,g,b);
142 cell->format()->setBgColor(c);
143 m_sheet->setRegionPaintDirty(cell->cellRect());
144}
145
146TQString CellIface::bgColor() const
147{
148 if( !m_sheet ) return TQString();
149 Cell* cell = m_sheet->cellAt( m_point );
150 return cell->bgColor( m_point.x(), m_point.y() ).name();
151}
152
153TQString CellIface::textColor() const
154{
155 if( !m_sheet ) return TQString();
156 Cell* cell = m_sheet->cellAt( m_point );
157 return cell->format()->textColor( m_point.x(), m_point.y() ).name();
158}
159
160void CellIface::setTextColor(int r,int g,int b)
161{
162 if( !m_sheet ) return;
163 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
164 TQColor c(r,g,b);
165 cell->format()->setTextColor(c);
166 m_sheet->setRegionPaintDirty(cell->cellRect());
167}
168
169void CellIface::setTextColor(const TQString& _c)
170{
171 if( !m_sheet ) return;
172 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
173 TQColor c(_c);
174 cell->format()->setTextColor(c);
175 m_sheet->setRegionPaintDirty(cell->cellRect());
176}
177
178void CellIface::setAngle(int angle)
179{
180 if( !m_sheet ) return;
181 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
182 cell->format()->setAngle(angle);
183 m_sheet->setRegionPaintDirty(cell->cellRect());
184}
185
186int CellIface::angle() const
187{
188 if( !m_sheet ) return 0;
189 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
190 return cell->format()->getAngle(m_point.x(), m_point.y());
191}
192
193void CellIface::setVerticalText(bool _vertical)
194{
195 if( !m_sheet ) return;
196 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
197 cell->format()->setVerticalText(_vertical);
198 m_sheet->setRegionPaintDirty(cell->cellRect());
199}
200
201bool CellIface::verticalText() const
202{
203 if( !m_sheet ) return false;
204 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
205 return cell->format()->verticalText( m_point.x(), m_point.y() );
206}
207
208
209void CellIface::setMultiRow(bool _multi)
210{
211 if( !m_sheet ) return;
212 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
213 cell->format()->setMultiRow( _multi );
214 m_sheet->setRegionPaintDirty(cell->cellRect());
215}
216
217bool CellIface::multiRow() const
218{
219 if( !m_sheet ) return false;
220 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
221 return cell->format()->multiRow( m_point.x(), m_point.y() );
222}
223
224void CellIface::setAlign( const TQString& _Align )
225{
226 if( !m_sheet ) return;
227 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
228 Format::Align Align;
229 if(_Align=="Left")
230 Align=Format::Left;
231 else if(_Align=="Right")
232 Align=Format::Right;
233 else if(_Align=="Center")
234 Align=Format::Center;
235 else
236 Align=Format::Undefined;
237 cell->format()->setAlign( Align);
238 m_sheet->setRegionPaintDirty(cell->cellRect());
239}
240
241TQString CellIface::align() const
242{
243 if( !m_sheet ) return TQString();
244 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
245 TQString alignString;
246 switch( cell->format()->align( m_point.x(), m_point.y() ) )
247 {
248 case Format::Left :
249 alignString="Left";
250 break;
251 case Format::Right :
252 alignString="Right";
253 break;
254 case Format::Center :
255 alignString="Center";
256 break;
257 case Format::Undefined :
258 alignString="Undefined";
259 break;
260 }
261 return alignString;
262}
263
264void CellIface::setAlignY( const TQString& _AlignY )
265{
266 if( !m_sheet ) return;
267 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
268 Format::AlignY AlignY;
269 if(_AlignY=="Top")
270 AlignY=Format::Top;
271 else if(_AlignY=="Middle")
272 AlignY=Format::Middle;
273 else if(_AlignY=="Bottom")
274 AlignY=Format::Bottom;
275 else
276 AlignY=Format::Middle;
277 cell->format()->setAlignY( AlignY);
278 m_sheet->setRegionPaintDirty(cell->cellRect());
279}
280
281TQString CellIface::alignY() const
282{
283 if( !m_sheet ) return TQString();
284 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
285 TQString alignString;
286 switch( cell->format()->alignY( m_point.x(), m_point.y() ) )
287 {
288 case Format::Top :
289 alignString="Top";
290 break;
291 case Format::Middle :
292 alignString="Middle";
293 break;
294 case Format::Bottom :
295 alignString="Bottom";
296 break;
297 case Format::UndefinedY :
298 alignString="UndefinedY";
299 break;
300 }
301 return alignString;
302}
303
304void CellIface::setPostfix(const TQString &_postfix)
305{
306 if( !m_sheet ) return;
307 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
308 cell->format()->setPostfix( _postfix );
309 m_sheet->setRegionPaintDirty(cell->cellRect());
310}
311
312TQString CellIface::prefix() const
313{
314 if( !m_sheet ) return TQString();
315 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
316 return cell->format()->prefix( m_point.x(), m_point.y() );
317}
318
319void CellIface::setPrefix(const TQString &_prefix)
320{
321 if( !m_sheet ) return;
322 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
323 cell->format()->setPrefix( _prefix );
324 m_sheet->setRegionPaintDirty(cell->cellRect());
325}
326
327TQString CellIface::postfix() const
328{
329 if( !m_sheet ) return TQString();
330 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
331 return cell->format()->postfix( m_point.x(), m_point.y() );
332}
333
334void CellIface::setFormatType(const TQString &_formatType)
335{
336 if( !m_sheet ) return;
337
338 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
339 FormatType format;
340 cell->format()->setPrecision(2);
341 if (_formatType=="Generic")
342 format = Generic_format;
343 else if(_formatType=="Number")
344 format=Number_format;
345 else if (_formatType=="Text")
346 format=Text_format;
347 else if(_formatType=="Money")
348 format=Money_format;
349 else if(_formatType=="Percentage")
350 format=Percentage_format;
351 else if(_formatType=="Scientific")
352 format=Scientific_format;
353 else if(_formatType=="ShortDate")
354 format=ShortDate_format;
355 else if(_formatType=="TextDate")
356 format=TextDate_format;
357 else if(_formatType=="Time")
358 format=Time_format;
359 else if(_formatType=="SecondeTime")
360 format=SecondeTime_format;
361 else if(_formatType=="fraction_half")
362 format=fraction_half;
363 else if(_formatType=="fraction_quarter")
364 format=fraction_quarter;
365 else if(_formatType=="fraction_eighth")
366 format=fraction_eighth;
367 else if(_formatType=="fraction_sixteenth")
368 format=fraction_sixteenth;
369 else if(_formatType=="fraction_tenth")
370 format=fraction_tenth;
371 else if(_formatType=="fraction_hundredth")
372 format=fraction_hundredth;
373 else if(_formatType=="fraction_one_digit")
374 format=fraction_one_digit;
375 else if(_formatType=="fraction_two_digits")
376 format=fraction_two_digits;
377 else if(_formatType=="fraction_three_digits")
378 format=fraction_three_digits;
379 else
380 format=Generic_format;
381 cell->format()->setFormatType( format);
382 m_sheet->setRegionPaintDirty(cell->cellRect());
383}
384
385TQString CellIface::getFormatType() const
386{
387 if( !m_sheet ) return TQString();
388
389 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
390 TQString stringFormat;
391 switch( cell->format()->getFormatType(m_point.x(), m_point.y()))
392 {
393 case Text_format:
394 stringFormat="Text";
395 break;
396 case Number_format:
397 stringFormat="Number";
398 break;
399 case Money_format:
400 stringFormat="Money";
401 break;
402 case Percentage_format:
403 stringFormat="Percentage";
404 break;
405 case Scientific_format:
406 stringFormat="Scientific";
407 break;
408 case ShortDate_format:
409 stringFormat="ShortDate";
410 break;
411 case TextDate_format:
412 stringFormat="TextDate";
413 break;
414 case date_format1:
415 case date_format2:
416 case date_format3:
417 case date_format4:
418 case date_format5:
419 case date_format6:
420 case date_format7:
421 case date_format8:
422 case date_format9:
423 case date_format10:
424 case date_format11:
425 case date_format12:
426 case date_format13:
427 case date_format14:
428 case date_format15:
429 case date_format16:
430 case date_format17:
431 case date_format18:
432 case date_format19:
433 case date_format20:
434 case date_format21:
435 case date_format22:
436 case date_format23:
437 case date_format24:
438 case date_format25:
439 case date_format26:
440 stringFormat="date format";
441 break;
442 case Time_format:
443 stringFormat="Time";
444 break;
445 case SecondeTime_format:
446 stringFormat="SecondeTime";
447 break;
448 case Time_format1:
449 case Time_format2:
450 case Time_format3:
451 case Time_format4:
452 case Time_format5:
453 case Time_format6:
454 case Time_format7:
455 case Time_format8:
456 stringFormat="time format";
457 break;
458 case fraction_half:
459 stringFormat="fraction_half";
460 break;
461 case fraction_quarter:
462 stringFormat="fraction_quarter";
463 break;
464 case fraction_eighth:
465 stringFormat="fraction_eighth";
466 break;
467 case fraction_sixteenth:
468 stringFormat="fraction_sixteenth";
469 break;
470 case fraction_tenth:
471 stringFormat="fraction_tenth";
472 break;
473 case fraction_hundredth:
474 stringFormat="fraction_hundredth";
475 break;
476 case fraction_one_digit:
477 stringFormat="fraction_one_digit";
478 break;
479 case fraction_two_digits:
480 stringFormat="fraction_two_digits";
481 break;
482 case fraction_three_digits:
483 stringFormat="fraction_three_digits";
484 break;
485 default:
486 break;
487 }
488 return stringFormat;
489}
490
491void CellIface::setPrecision(int _p)
492{
493 if( !m_sheet ) return;
494 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
495 cell->format()->setPrecision( _p );
496 m_sheet->setRegionPaintDirty(cell->cellRect());
497}
498
499int CellIface::precision() const
500{
501 if( !m_sheet ) return 0;
502 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
503 return cell->format()->precision( m_point.x(), m_point.y() );
504}
505
506void CellIface::setTextFontBold(bool _b)
507{
508 if( !m_sheet ) return;
509 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
510 cell->format()->setTextFontBold( _b );
511 m_sheet->setRegionPaintDirty(cell->cellRect());
512}
513
514bool CellIface::textFontBold() const
515{
516 if( !m_sheet ) return false;
517 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
518 return cell->format()->textFontBold( m_point.x(), m_point.y() );
519}
520
521void CellIface::setTextFontItalic(bool _b)
522{
523 if( !m_sheet ) return;
524 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
525 cell->format()->setTextFontItalic( _b );
526 m_sheet->setRegionPaintDirty(cell->cellRect());
527}
528
529bool CellIface::textFontItalic() const
530{
531 if( !m_sheet ) return false;
532 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
533 return cell->format()->textFontItalic( m_point.x(), m_point.y() );
534}
535
536
537void CellIface::setTextFontUnderline(bool _b)
538{
539 if( !m_sheet ) return;
540 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
541 cell->format()->setTextFontUnderline( _b );
542 m_sheet->setRegionPaintDirty(cell->cellRect());
543}
544
545bool CellIface::textFontUnderline() const
546{
547 if( !m_sheet ) return false;
548 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
549 return cell->format()->textFontUnderline( m_point.x(), m_point.y() );
550}
551
552void CellIface::setTextFontStrike(bool _b)
553{
554 if( !m_sheet ) return;
555 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
556 cell->format()->setTextFontStrike( _b );
557 m_sheet->setRegionPaintDirty(cell->cellRect());
558}
559
560bool CellIface::textFontStrike() const
561{
562 if( !m_sheet ) return false;
563 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
564 return cell->format()->textFontStrike( m_point.x(), m_point.y() );
565}
566
567void CellIface::setTextFontSize( int _size )
568{
569 if( !m_sheet ) return;
570 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
571 cell->format()->setTextFontSize( _size );
572 m_sheet->setRegionPaintDirty(cell->cellRect());
573}
574
575int CellIface::textFontSize() const
576{
577 if( !m_sheet ) return 10;
578 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
579 return cell->format()->textFontSize( m_point.x(), m_point.y() );
580}
581
582void CellIface::setTextFontFamily( const TQString& _font )
583{
584 if( !m_sheet ) return;
585 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
586 cell->format()->setTextFontFamily( _font );
587 m_sheet->setRegionPaintDirty(cell->cellRect());
588}
589
590TQString CellIface::textFontFamily() const
591{
592 if( !m_sheet ) return TQString();
593 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
594 return cell->format()->textFontFamily( m_point.x(), m_point.y() );
595}
596
597//border left
598void CellIface::setLeftBorderStyle( const TQString& _style )
599{
600 if( !m_sheet ) return;
601 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
602 if(_style=="DotLine")
603 cell->format()->setLeftBorderStyle(TQt::DotLine);
604 else if(_style=="DashLine")
605 cell->format()->setLeftBorderStyle(TQt::DashLine);
606 else if(_style=="DashDotLine")
607 cell->format()->setLeftBorderStyle(TQt::DashDotLine);
608 else if(_style=="DashDotDotLine")
609 cell->format()->setLeftBorderStyle(TQt::DashDotDotLine);
610 else if(_style=="SolidLine")
611 cell->format()->setLeftBorderStyle(TQt::SolidLine);
612 else
613 cell->format()->setLeftBorderStyle(TQt::SolidLine);
614 m_sheet->setRegionPaintDirty(cell->cellRect());
615
616}
617
618void CellIface::setLeftBorderColor(const TQString& _c)
619{
620 if( !m_sheet ) return;
621 TQColor c(_c);
622 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
623 cell->format()->setLeftBorderColor(c );
624 m_sheet->setRegionPaintDirty(cell->cellRect());
625
626}
627
628void CellIface::setLeftBorderColor(int r,int g,int b)
629{
630 if( !m_sheet ) return;
631 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
632 TQColor c(r,g,b);
633 cell->format()->setLeftBorderColor(c );
634 m_sheet->setRegionPaintDirty(cell->cellRect());
635}
636
637void CellIface::setLeftBorderWidth( int _size )
638{
639 if( !m_sheet ) return;
640 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
641 cell->format()->setLeftBorderWidth( _size );
642 m_sheet->setRegionPaintDirty(cell->cellRect());
643}
644
645
646int CellIface::leftBorderWidth() const
647{
648 if( !m_sheet ) return 0;
649 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
650 return cell->format()->leftBorderWidth(m_point.x(), m_point.y());
651}
652
653TQString CellIface::leftBorderColor() const
654{
655 if( !m_sheet ) return TQString();
656 Cell* cell = m_sheet->cellAt( m_point );
657 return cell->format()->leftBorderColor( m_point.x(), m_point.y() ).name();
658}
659
660TQString CellIface::leftBorderStyle() const
661{
662 if( !m_sheet ) return TQString();
663 Cell* cell = m_sheet->cellAt( m_point );
664 TQt::PenStyle penStyle=cell->format()->leftBorderStyle( m_point.x(), m_point.y() );
665 TQString tmp;
666 if( penStyle==TQt::DotLine)
667 tmp="DotLine";
668 else if( penStyle==TQt::DashLine)
669 tmp="DashLine";
670 else if( penStyle==TQt::DashDotLine)
671 tmp="DashDotLine";
672 else if( penStyle==TQt::DashDotDotLine)
673 tmp="DashDotDotLine";
674 else if( penStyle==TQt::SolidLine)
675 tmp="SolidLine";
676 else
677 tmp="SolidLine";
678 return tmp;
679}
680
681//border right
682void CellIface::setRightBorderStyle( const TQString& _style )
683{
684 if( !m_sheet ) return;
685 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
686 if(_style=="DotLine")
687 cell->format()->setRightBorderStyle(TQt::DotLine);
688 else if(_style=="DashLine")
689 cell->format()->setRightBorderStyle(TQt::DashLine);
690 else if(_style=="DashDotLine")
691 cell->format()->setRightBorderStyle(TQt::DashDotLine);
692 else if(_style=="DashDotDotLine")
693 cell->format()->setRightBorderStyle(TQt::DashDotDotLine);
694 else if(_style=="SolidLine")
695 cell->format()->setRightBorderStyle(TQt::SolidLine);
696 else
697 cell->format()->setRightBorderStyle(TQt::SolidLine);
698 m_sheet->setRegionPaintDirty(cell->cellRect());
699
700}
701
702void CellIface::setRightBorderColor(const TQString& _c)
703{
704 if( !m_sheet ) return;
705 TQColor c(_c);
706 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
707 cell->format()->setRightBorderColor(c );
708 m_sheet->setRegionPaintDirty(cell->cellRect());
709
710}
711void CellIface::setRightBorderColor(int r,int g,int b)
712{
713 if( !m_sheet ) return;
714 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
715 TQColor c(r,g,b);
716 cell->format()->setRightBorderColor(c );
717 m_sheet->setRegionPaintDirty(cell->cellRect());
718}
719
720void CellIface::setRightBorderWidth( int _size )
721{
722 if( !m_sheet ) return;
723 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
724 cell->format()->setRightBorderWidth( _size );
725 m_sheet->setRegionPaintDirty(cell->cellRect());
726
727}
728
729int CellIface::rightBorderWidth() const
730{
731 if( !m_sheet ) return 0;
732 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
733 return cell->format()->rightBorderWidth(m_point.x(), m_point.y());
734}
735
736TQString CellIface::rightBorderColor() const
737{
738 if( !m_sheet ) return TQString();
739 Cell* cell = m_sheet->cellAt( m_point );
740 return cell->format()->rightBorderColor( m_point.x(), m_point.y() ).name();
741}
742
743TQString CellIface::rightBorderStyle() const
744{
745 if( !m_sheet ) return TQString();
746 Cell* cell = m_sheet->cellAt( m_point );
747 TQt::PenStyle penStyle=cell->format()->rightBorderStyle( m_point.x(), m_point.y() );
748 TQString tmp;
749 if( penStyle==TQt::DotLine)
750 tmp="DotLine";
751 else if( penStyle==TQt::DashLine)
752 tmp="DashLine";
753 else if( penStyle==TQt::DashDotLine)
754 tmp="DashDotLine";
755 else if( penStyle==TQt::DashDotDotLine)
756 tmp="DashDotDotLine";
757 else if( penStyle==TQt::SolidLine)
758 tmp="SolidLine";
759 else
760 tmp="SolidLine";
761 return tmp;
762}
763
764//border top
765void CellIface::setTopBorderStyle( const TQString& _style )
766{
767 if( !m_sheet ) return;
768 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
769 if(_style=="DotLine")
770 cell->format()->setTopBorderStyle(TQt::DotLine);
771 else if(_style=="DashLine")
772 cell->format()->setTopBorderStyle(TQt::DashLine);
773 else if(_style=="DashDotLine")
774 cell->format()->setTopBorderStyle(TQt::DashDotLine);
775 else if(_style=="DashDotDotLine")
776 cell->format()->setTopBorderStyle(TQt::DashDotDotLine);
777 else if(_style=="SolidLine")
778 cell->format()->setTopBorderStyle(TQt::SolidLine);
779 else
780 cell->format()->setTopBorderStyle(TQt::SolidLine);
781 m_sheet->setRegionPaintDirty(cell->cellRect());
782
783}
784
785void CellIface::setTopBorderColor(const TQString& _c)
786{
787 if( !m_sheet ) return;
788 TQColor c(_c);
789 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
790 cell->format()->setTopBorderColor(c );
791 m_sheet->setRegionPaintDirty(cell->cellRect());
792
793}
794void CellIface::setTopBorderColor(int r,int g,int b)
795{
796 if( !m_sheet ) return;
797 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
798 TQColor c(r,g,b);
799 cell->format()->setTopBorderColor(c );
800 m_sheet->setRegionPaintDirty(cell->cellRect());
801}
802
803void CellIface::setTopBorderWidth( int _size )
804{
805 if( !m_sheet ) return;
806 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
807 cell->format()->setTopBorderWidth( _size );
808 m_sheet->setRegionPaintDirty(cell->cellRect());
809}
810
811int CellIface::topBorderWidth() const
812{
813 if( !m_sheet ) return 0;
814 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
815 return cell->format()->topBorderWidth(m_point.x(), m_point.y());
816}
817
818TQString CellIface::topBorderColor() const
819{
820 if( !m_sheet ) return TQString();
821 Cell* cell = m_sheet->cellAt( m_point );
822 return cell->format()->topBorderColor( m_point.x(), m_point.y() ).name();
823}
824
825TQString CellIface::topBorderStyle() const
826{
827 if( !m_sheet ) return TQString();
828 Cell* cell = m_sheet->cellAt( m_point );
829 TQt::PenStyle penStyle=cell->format()->topBorderStyle( m_point.x(), m_point.y() );
830 TQString tmp;
831 if( penStyle==TQt::DotLine)
832 tmp="DotLine";
833 else if( penStyle==TQt::DashLine)
834 tmp="DashLine";
835 else if( penStyle==TQt::DashDotLine)
836 tmp="DashDotLine";
837 else if( penStyle==TQt::DashDotDotLine)
838 tmp="DashDotDotLine";
839 else if( penStyle==TQt::SolidLine)
840 tmp="SolidLine";
841 else
842 tmp="SolidLine";
843 return tmp;
844}
845
846//border bottom
847void CellIface::setBottomBorderStyle( const TQString& _style )
848{
849 if( !m_sheet ) return;
850 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
851 if(_style=="DotLine")
852 cell->format()->setBottomBorderStyle(TQt::DotLine);
853 else if(_style=="DashLine")
854 cell->format()->setBottomBorderStyle(TQt::DashLine);
855 else if(_style=="DashDotLine")
856 cell->format()->setBottomBorderStyle(TQt::DashDotLine);
857 else if(_style=="DashDotDotLine")
858 cell->format()->setBottomBorderStyle(TQt::DashDotDotLine);
859 else if(_style=="SolidLine")
860 cell->format()->setBottomBorderStyle(TQt::SolidLine);
861 else
862 cell->format()->setBottomBorderStyle(TQt::SolidLine);
863 m_sheet->setRegionPaintDirty(cell->cellRect());
864
865}
866
867void CellIface::setBottomBorderColor(const TQString& _c)
868{
869 if( !m_sheet ) return;
870 TQColor c(_c);
871 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
872 cell->format()->setBottomBorderColor(c );
873 m_sheet->setRegionPaintDirty(cell->cellRect());
874
875}
876void CellIface::setBottomBorderColor(int r,int g,int b)
877{
878 if( !m_sheet ) return;
879 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
880 TQColor c(r,g,b);
881 cell->format()->setBottomBorderColor(c );
882 m_sheet->setRegionPaintDirty(cell->cellRect());
883}
884
885void CellIface::setBottomBorderWidth( int _size )
886{
887 if( !m_sheet ) return;
888 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
889 cell->format()->setBottomBorderWidth( _size );
890 m_sheet->setRegionPaintDirty(cell->cellRect());
891}
892
893int CellIface::bottomBorderWidth() const
894{
895 if( !m_sheet ) return 0;
896 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
897 return cell->format()->bottomBorderWidth(m_point.x(), m_point.y());
898}
899
900TQString CellIface::bottomBorderColor() const
901{
902 if( !m_sheet ) return TQString();
903 Cell* cell = m_sheet->cellAt( m_point );
904 return cell->format()->bottomBorderColor( m_point.x(), m_point.y() ).name();
905}
906
907TQString CellIface::bottomBorderStyle() const
908{
909 if( !m_sheet ) return TQString();
910 Cell* cell = m_sheet->cellAt( m_point );
911 TQt::PenStyle penStyle=cell->format()->bottomBorderStyle( m_point.x(), m_point.y() );
912 TQString tmp;
913 if( penStyle==TQt::DotLine)
914 tmp="DotLine";
915 else if( penStyle==TQt::DashLine)
916 tmp="DashLine";
917 else if( penStyle==TQt::DashDotLine)
918 tmp="DashDotLine";
919 else if( penStyle==TQt::DashDotDotLine)
920 tmp="DashDotDotLine";
921 else if( penStyle==TQt::SolidLine)
922 tmp="SolidLine";
923 else
924 tmp="SolidLine";
925 return tmp;
926}
927
928//fall back diagonal
929void CellIface::setFallDiagonalStyle( const TQString& _style )
930{
931 if( !m_sheet ) return;
932 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
933 if(_style=="DotLine")
934 cell->format()->setFallDiagonalStyle(TQt::DotLine);
935 else if(_style=="DashLine")
936 cell->format()->setFallDiagonalStyle(TQt::DashLine);
937 else if(_style=="DashDotLine")
938 cell->format()->setFallDiagonalStyle(TQt::DashDotLine);
939 else if(_style=="DashDotDotLine")
940 cell->format()->setFallDiagonalStyle(TQt::DashDotDotLine);
941 else if(_style=="SolidLine")
942 cell->format()->setFallDiagonalStyle(TQt::SolidLine);
943 else
944 cell->format()->setFallDiagonalStyle(TQt::SolidLine);
945 m_sheet->setRegionPaintDirty(cell->cellRect());
946
947}
948
949void CellIface::setFallDiagonalColor(const TQString& _c)
950{
951 if( !m_sheet ) return;
952 TQColor c(_c);
953 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
954 cell->format()->setFallDiagonalColor(c );
955 m_sheet->setRegionPaintDirty(cell->cellRect());
956
957}
958void CellIface::setFallDiagonalColor(int r,int g,int b)
959{
960 if( !m_sheet ) return;
961 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
962 TQColor c(r,g,b);
963 cell->format()->setFallDiagonalColor(c );
964 m_sheet->setRegionPaintDirty(cell->cellRect());
965}
966
967void CellIface::setFallDiagonalWidth( int _size )
968{
969 if( !m_sheet ) return;
970 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
971 cell->format()->setFallDiagonalWidth( _size );
972 m_sheet->setRegionPaintDirty(cell->cellRect());
973}
974
975int CellIface::fallDiagonalWidth() const
976{
977 if( !m_sheet ) return 0;
978 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
979 return cell->format()->fallDiagonalWidth(m_point.x(), m_point.y());
980}
981
982TQString CellIface::fallDiagonalColor() const
983{
984 if( !m_sheet ) return TQString();
985 Cell* cell = m_sheet->cellAt( m_point );
986 return cell->format()->fallDiagonalColor( m_point.x(), m_point.y() ).name();
987}
988
989TQString CellIface::fallDiagonalStyle() const
990{
991 if( !m_sheet ) return TQString();
992 Cell* cell = m_sheet->cellAt( m_point );
993 TQt::PenStyle penStyle=cell->format()->fallDiagonalStyle( m_point.x(), m_point.y() );
994 TQString tmp;
995 if( penStyle==TQt::DotLine)
996 tmp="DotLine";
997 else if( penStyle==TQt::DashLine)
998 tmp="DashLine";
999 else if( penStyle==TQt::DashDotLine)
1000 tmp="DashDotLine";
1001 else if( penStyle==TQt::DashDotDotLine)
1002 tmp="DashDotDotLine";
1003 else if( penStyle==TQt::SolidLine)
1004 tmp="SolidLine";
1005 else
1006 tmp="SolidLine";
1007 return tmp;
1008}
1009
1010
1011//GoUpDiagonal
1012void CellIface::setGoUpDiagonalStyle( const TQString& _style )
1013{
1014 if( !m_sheet ) return;
1015 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1016 if(_style=="DotLine")
1017 cell->format()->setGoUpDiagonalStyle(TQt::DotLine);
1018 else if(_style=="DashLine")
1019 cell->format()->setGoUpDiagonalStyle(TQt::DashLine);
1020 else if(_style=="DashDotLine")
1021 cell->format()->setGoUpDiagonalStyle(TQt::DashDotLine);
1022 else if(_style=="DashDotDotLine")
1023 cell->format()->setGoUpDiagonalStyle(TQt::DashDotDotLine);
1024 else if(_style=="SolidLine")
1025 cell->format()->setGoUpDiagonalStyle(TQt::SolidLine);
1026 else
1027 cell->format()->setGoUpDiagonalStyle(TQt::SolidLine);
1028 m_sheet->setRegionPaintDirty(cell->cellRect());
1029
1030}
1031
1032void CellIface::setGoUpDiagonalColor(const TQString& _c)
1033{
1034 if( !m_sheet ) return;
1035 TQColor c(_c);
1036 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1037 cell->format()->setGoUpDiagonalColor(c );
1038 m_sheet->setRegionPaintDirty(cell->cellRect());
1039
1040}
1041void CellIface::setGoUpDiagonalColor(int r,int g,int b)
1042{
1043 if( !m_sheet ) return;
1044 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1045 TQColor c(r,g,b);
1046 cell->format()->setGoUpDiagonalColor(c );
1047 m_sheet->setRegionPaintDirty(cell->cellRect());
1048}
1049
1050void CellIface::setGoUpDiagonalWidth( int _size )
1051{
1052 if( !m_sheet ) return;
1053 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1054 cell->format()->setGoUpDiagonalWidth( _size );
1055 m_sheet->setRegionPaintDirty(cell->cellRect());
1056}
1057
1058int CellIface::goUpDiagonalWidth() const
1059{
1060 if( !m_sheet ) return 0;
1061 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1062 return cell->format()->goUpDiagonalWidth(m_point.x(), m_point.y());
1063}
1064
1065TQString CellIface::goUpDiagonalColor() const
1066{
1067 if( !m_sheet ) return TQString();
1068 Cell* cell = m_sheet->cellAt( m_point );
1069 return cell->format()->goUpDiagonalColor( m_point.x(), m_point.y() ).name();
1070}
1071
1072TQString CellIface::goUpDiagonalStyle() const
1073{
1074 if( !m_sheet ) return TQString();
1075 Cell* cell = m_sheet->cellAt( m_point );
1076 TQt::PenStyle penStyle=cell->format()->goUpDiagonalStyle( m_point.x(), m_point.y() );
1077 TQString tmp;
1078 if( penStyle==TQt::DotLine)
1079 tmp="DotLine";
1080 else if( penStyle==TQt::DashLine)
1081 tmp="DashLine";
1082 else if( penStyle==TQt::DashDotLine)
1083 tmp="DashDotLine";
1084 else if( penStyle==TQt::DashDotDotLine)
1085 tmp="DashDotDotLine";
1086 else if( penStyle==TQt::SolidLine)
1087 tmp="SolidLine";
1088 else
1089 tmp="SolidLine";
1090 return tmp;
1091}
1092
1093void CellIface::setIndent(double indent)
1094{
1095 if( !m_sheet ) return;
1096 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1097 if( indent >= 0.0 )
1098 cell->format()->setIndent( indent );
1099 else
1100 cell->format()->setIndent( 0.0 );
1101 m_sheet->setRegionPaintDirty(cell->cellRect());
1102}
1103
1104double CellIface::getIndent() const
1105{
1106 if( !m_sheet ) return 0.0;
1107 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1108 return cell->format()->getIndent( m_point.x(), m_point.y() );
1109}
1110
1111void CellIface::setDontPrintText ( bool _print)
1112{
1113 if( !m_sheet ) return;
1114 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1115 cell->format()->setDontPrintText ( _print);
1116}
1117
1118bool CellIface::getDontprintText() const
1119{
1120 if( !m_sheet ) return false;
1121 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1122 return cell->format()->getDontprintText(m_point.x(), m_point.y());
1123}
1124
1125bool CellIface::hasValidation() const
1126{
1127 if( !m_sheet ) return false;
1128 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1129 if ( cell->getValidity( 0 ) )
1130 return true;
1131 else
1132 return false;
1133}
1134
1135TQString CellIface::validationTitle() const
1136{
1137 if( !m_sheet ) return "";
1138 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1139 if ( cell->getValidity( 0 ) )
1140 {
1141 return cell->getValidity( 0 )->title;
1142 }
1143 else
1144 return "";
1145}
1146
1147TQString CellIface::validationMessage() const
1148{
1149 if( !m_sheet ) return "";
1150 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1151 if ( cell->getValidity( 0 ) )
1152 {
1153 return cell->getValidity( 0 )->message;
1154 }
1155 else
1156 return "";
1157}
1158
1159TQStringList CellIface::listValidation() const
1160{
1161 if( !m_sheet ) return TQStringList();
1162 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1163 if ( cell->getValidity( 0 ) )
1164 {
1165 return cell->getValidity( 0 )->listValidity;
1166 }
1167 else
1168 return TQStringList();
1169}
1170
1171
1172TQString CellIface::validationTitleInfo() const
1173{
1174 if( !m_sheet ) return "";
1175 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1176 if ( cell->getValidity( 0 ) )
1177 {
1178 return cell->getValidity( 0 )->titleInfo;
1179 }
1180 else
1181 return "";
1182}
1183
1184TQString CellIface::validationMessageInfo() const
1185{
1186 if( !m_sheet ) return "";
1187 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1188 if ( cell->getValidity( 0 ) )
1189 {
1190 return cell->getValidity( 0 )->messageInfo;
1191 }
1192 else
1193 return "";
1194}
1195
1196
1197bool CellIface::displayValidationInformation() const
1198{
1199 if( !m_sheet ) return false;
1200 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1201 if ( cell->getValidity( 0 ) )
1202 {
1203 return cell->getValidity( 0 )->displayValidationInformation;
1204 }
1205 else
1206 return false;
1207}
1208
1209bool CellIface::displayValidationMessage() const
1210{
1211 if( !m_sheet ) return false;
1212 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1213 if ( cell->getValidity( 0 ) )
1214 {
1215 return cell->getValidity( 0 )->displayMessage;
1216 }
1217 else
1218 return false;
1219}
1220
1221bool CellIface::validationAllowEmptyCell() const
1222{
1223 if( !m_sheet ) return false;
1224 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1225 if ( cell->getValidity( 0 ) )
1226 {
1227 return cell->getValidity( 0 )->allowEmptyCell;
1228 }
1229 else
1230 return false;
1231}
1232
1233void CellIface::removeValidity()
1234{
1235 if( !m_sheet ) return;
1236 Cell* cell = m_sheet->nonDefaultCell( m_point.x(), m_point.y() );
1237 cell->removeValidity();
1238}
const Value value() const
Returns the value that this cell holds.
void setValue(const Value &value)
Sets the value for this cell.
bool isEmpty() const
Returns true if this cell has no content, i.e no text and no formula.
void setCellText(const TQString &_text, bool asString=false)
The high-level method for setting text, when the user inputs it.
Format * format() const
Returns the format object of this cell.
bool isDefault() const
Returns true if this is a default cell (with row and column equal to zero).
const TQColor & bgColor(int col, int row) const
double asFloat() const
Returns the floating-point value of this value.
TQString asString() const
Returns the string value of this value.
The KSpread namespace.
Definition commands.h:39