KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1239 lines
36KB

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