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.

3582 lines
108KB

  1. /* This file is part of the KDE project Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
  2. Copyright (C) 2000 - 2005 The KSpread Team
  3. www.koffice.org/kspread
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. * Boston, MA 02110-1301, USA.
  16. */
  17. #include <float.h>
  18. #include <iostream>
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21. #include <dcopobject.h>
  22. #include <kdebug.h>
  23. #include <tdelocale.h>
  24. #include <KoXmlNS.h>
  25. #include <KoGenStyles.h>
  26. #include <KoGlobal.h>
  27. #include <KoStyleStack.h>
  28. #include <KoOasisLoadingContext.h>
  29. #include <KoOasisStyles.h>
  30. #include "kspread_canvas.h"
  31. #include "kspread_doc.h"
  32. #include "kspread_global.h"
  33. #include "kspread_sheet.h"
  34. #include "kspread_sheetprint.h"
  35. #include "kspread_style.h"
  36. #include "kspread_style_manager.h"
  37. #include "KSpreadColumnIface.h"
  38. #include "KSpreadLayoutIface.h"
  39. #include "KSpreadRowIface.h"
  40. #include "kspread_format.h"
  41. using namespace std;
  42. using namespace KSpread;
  43. /*****************************************************************************
  44. *
  45. * Format
  46. *
  47. *****************************************************************************/
  48. // static variable construction
  49. // NOTE Stefan: These values are always overridden by the Doc c'tor.
  50. double Format::s_columnWidth = 100.0;
  51. double Format::s_rowHeight = 20.0;
  52. Format::Format( Sheet * _sheet, Style * _style )
  53. : m_pSheet( _sheet ),
  54. m_pStyle( _style ),
  55. m_mask( 0 ),
  56. m_bNoFallBack( 0 ),
  57. m_flagsMask( 0 ),
  58. m_strComment( 0 ),
  59. m_pCell( 0 )
  60. {
  61. }
  62. Format::~Format()
  63. {
  64. if ( m_pStyle->release() )
  65. delete m_pStyle;
  66. }
  67. void Format::defaultStyleFormat()
  68. {
  69. if ( m_pStyle->release() )
  70. delete m_pStyle;
  71. if ( m_pSheet )
  72. m_pStyle = m_pSheet->doc()->styleManager()->defaultStyle();
  73. delete m_strComment;
  74. }
  75. void Format::setGlobalColWidth( double width )
  76. {
  77. s_columnWidth = width;
  78. }
  79. void Format::setGlobalRowHeight( double height )
  80. {
  81. s_rowHeight = height;
  82. }
  83. double Format::globalRowHeight()
  84. {
  85. return s_rowHeight;
  86. }
  87. double Format::globalColWidth()
  88. {
  89. return s_columnWidth;
  90. }
  91. void Format::copy( const Format & _l )
  92. {
  93. // TODO why is the sheet not copied?
  94. setStyle( _l.m_pStyle );
  95. m_mask = _l.m_mask;
  96. m_flagsMask = _l.m_flagsMask;
  97. m_bNoFallBack = _l.m_bNoFallBack;
  98. if ( _l.m_strComment )
  99. {
  100. if (m_strComment)
  101. delete m_strComment;
  102. m_strComment = new TQString( *_l.m_strComment );
  103. }
  104. }
  105. void Format::setStyle( Style * style )
  106. {
  107. if ( style == m_pStyle )
  108. return;
  109. if ( m_pStyle && m_pStyle->release() )
  110. delete m_pStyle;
  111. m_bNoFallBack = 0;
  112. m_pStyle = style;
  113. m_pStyle->addRef();
  114. formatChanged();
  115. // kdDebug() << "Newly assigned style: " << m_pStyle << ", type: " << m_pStyle->type() << endl;
  116. if ( style->type() == Style::BUILTIN || style->type() == Style::CUSTOM )
  117. kdDebug() << "Style name: " << ((CustomStyle *) m_pStyle)->name() << endl;
  118. }
  119. void Format::clearFlag( FormatFlags flag )
  120. {
  121. m_flagsMask &= ~(TQ_UINT32)flag;
  122. }
  123. void Format::setFlag( FormatFlags flag )
  124. {
  125. m_flagsMask |= (TQ_UINT32)flag;
  126. }
  127. bool Format::testFlag( FormatFlags flag ) const
  128. {
  129. return ( m_flagsMask & (TQ_UINT32)flag );
  130. }
  131. void Format::clearProperties()
  132. {
  133. m_mask = 0;
  134. m_pStyle->clearFeature( (Style::FlagsSet) ~(uint)0 );
  135. formatChanged();
  136. }
  137. void Format::clearProperty( Properties p )
  138. {
  139. m_mask &= ~(uint)p;
  140. m_pStyle->clearFeature( (Style::FlagsSet) p );
  141. formatChanged();
  142. }
  143. // FIXME according to Valgrind, this function consumes too much time
  144. // find a way to optimize it !
  145. bool Format::hasProperty( Properties p, bool withoutParent ) const
  146. {
  147. if ( m_pStyle->hasFeature( (Style::FlagsSet) p, withoutParent ) )
  148. return true;
  149. return ( m_mask & (uint)p );
  150. }
  151. void Format::setProperty( Properties p )
  152. {
  153. m_mask |= (uint)p;
  154. }
  155. void Format::clearNoFallBackProperties()
  156. {
  157. m_bNoFallBack = 0;
  158. formatChanged();
  159. }
  160. void Format::clearNoFallBackProperties( Properties p )
  161. {
  162. m_bNoFallBack &= ~(uint)p;
  163. formatChanged();
  164. }
  165. bool Format::hasNoFallBackProperties( Properties p ) const
  166. {
  167. return ( m_bNoFallBack & (uint)p );
  168. }
  169. void Format::setNoFallBackProperties( Properties p )
  170. {
  171. m_bNoFallBack |= (uint)p;
  172. }
  173. /////////////
  174. //
  175. // Loading and saving
  176. //
  177. /////////////
  178. TQString Format::saveOasisCellStyle( KoGenStyle &currentCellStyle, KoGenStyles &mainStyles )
  179. {
  180. TQString styleName;
  181. styleName = m_pStyle->saveOasis( currentCellStyle, mainStyles );
  182. // user styles are already stored
  183. if ( currentCellStyle.type() == Doc::STYLE_CELL_AUTO )
  184. {
  185. styleName = mainStyles.lookup( currentCellStyle, "ce" );
  186. }
  187. return styleName;
  188. }
  189. TQDomElement Format::saveFormat( TQDomDocument & doc, int _col, int _row, bool force, bool copy ) const
  190. {
  191. TQDomElement format( doc.createElement( "format" ) );
  192. if ( m_pStyle->type() == Style::BUILTIN || m_pStyle->type() == Style::CUSTOM )
  193. {
  194. format.setAttribute( "style-name", ((CustomStyle *) m_pStyle)->name() );
  195. if ( !copy )
  196. return format;
  197. }
  198. else
  199. {
  200. if ( m_pStyle->parent() && m_pStyle->parent()->name().length() > 0 )
  201. format.setAttribute( "parent", m_pStyle->parent()->name() );
  202. }
  203. if ( hasProperty( PAlign, true ) || hasNoFallBackProperties( PAlign ) || force )
  204. format.setAttribute( "align", (int) align( _col, _row ) );
  205. if ( hasProperty( PAlignY, true ) || hasNoFallBackProperties( PAlignY ) || force )
  206. format.setAttribute( "alignY", (int)alignY( _col, _row ) );
  207. if ( ( hasProperty( PBackgroundColor, false ) || hasNoFallBackProperties( PBackgroundColor)
  208. || force ) && bgColor( _col, _row ).isValid() )
  209. format.setAttribute( "bgcolor", bgColor( _col, _row ).name() );
  210. if ( ( hasProperty( PMultiRow, true ) || hasNoFallBackProperties( PMultiRow )
  211. || force ) && multiRow( _col, _row ) )
  212. format.setAttribute( "multirow", "yes" );
  213. if ( ( hasProperty( PVerticalText, true ) || hasNoFallBackProperties( PVerticalText )
  214. || force ) && verticalText( _col, _row ) )
  215. format.setAttribute( "verticaltext", "yes" );
  216. if ( hasProperty( PPrecision, true ) || hasNoFallBackProperties( PPrecision ) || force )
  217. format.setAttribute( "precision", precision( _col, _row ) );
  218. if ( ( hasProperty( PPrefix, true ) || hasNoFallBackProperties( PPrefix ) || force )
  219. && !prefix( _col, _row ).isEmpty() )
  220. format.setAttribute( "prefix", prefix( _col, _row ) );
  221. if ( ( hasProperty( PPostfix, true ) || hasNoFallBackProperties( PPostfix ) || force )
  222. && !postfix( _col, _row ).isEmpty() )
  223. format.setAttribute( "postfix", postfix( _col, _row ) );
  224. if ( hasProperty( PFloatFormat, true ) || hasNoFallBackProperties( PFloatFormat ) || force )
  225. format.setAttribute( "float", (int) floatFormat( _col, _row ) );
  226. if ( hasProperty( PFloatColor, true ) || hasNoFallBackProperties( PFloatColor ) || force )
  227. format.setAttribute( "floatcolor", (int) floatColor( _col, _row ) );
  228. if ( hasProperty( PFormatType, true ) || hasNoFallBackProperties( PFormatType ) || force )
  229. format.setAttribute( "format", (int)getFormatType( _col, _row ));
  230. if ( hasProperty( PCustomFormat, true ) || hasNoFallBackProperties( PCustomFormat ) || force )
  231. {
  232. TQString s( getFormatString( _col, _row ) );
  233. if ( s.length() > 0 )
  234. format.setAttribute( "custom", s );
  235. }
  236. if ( getFormatType( _col, _row ) == Money_format )
  237. {
  238. format.setAttribute( "type", (int) m_pStyle->currency().type ); // TODO: fallback?
  239. format.setAttribute( "symbol", m_pStyle->currency().symbol );
  240. }
  241. if ( hasProperty( PAngle, true ) || hasNoFallBackProperties( PAngle ) || force )
  242. format.setAttribute( "angle", getAngle( _col, _row ) );
  243. if ( hasProperty( PIndent, true ) || hasNoFallBackProperties( PIndent ) || force )
  244. format.setAttribute( "indent", getIndent( _col, _row ) );
  245. if( ( hasProperty( PDontPrintText, true ) || hasNoFallBackProperties( PDontPrintText )
  246. || force ) && getDontprintText( _col, _row ) )
  247. format.setAttribute( "dontprinttext", "yes" );
  248. if( ( hasProperty( PNotProtected, true ) || hasNoFallBackProperties( PNotProtected )
  249. || force ) && notProtected( _col, _row ) )
  250. format.setAttribute( "noprotection", "yes" );
  251. if( ( hasProperty( PHideAll, true ) || hasNoFallBackProperties( PHideAll )
  252. || force ) && isHideAll( _col, _row ) )
  253. format.setAttribute( "hideall", "yes" );
  254. if( ( hasProperty( PHideFormula, true ) || hasNoFallBackProperties( PHideFormula )
  255. || force ) && isHideFormula( _col, _row ) )
  256. format.setAttribute( "hideformula", "yes" );
  257. if ( hasProperty( PFont, true ) || hasNoFallBackProperties( PFont ) || force )
  258. format.appendChild( util_createElement( "font", textFont( _col, _row ), doc ) );
  259. if ( ( hasProperty( PTextPen, true ) || hasNoFallBackProperties( PTextPen ) || force )
  260. && textPen( _col, _row ).color().isValid() )
  261. format.appendChild( util_createElement( "pen", textPen( _col, _row ), doc ) );
  262. if ( hasProperty( PBackgroundBrush, true ) || hasNoFallBackProperties( PBackgroundBrush ) || force )
  263. {
  264. format.setAttribute( "brushcolor", backGroundBrushColor( _col, _row ).name() );
  265. format.setAttribute( "brushstyle", (int)backGroundBrushStyle( _col, _row ) );
  266. }
  267. if ( hasProperty( PLeftBorder, true ) || hasNoFallBackProperties( PLeftBorder ) || force )
  268. {
  269. TQDomElement left = doc.createElement( "left-border" );
  270. left.appendChild( util_createElement( "pen", leftBorderPen( _col, _row ), doc ) );
  271. format.appendChild( left );
  272. }
  273. if ( hasProperty( PTopBorder, true ) || hasNoFallBackProperties( PTopBorder ) || force )
  274. {
  275. TQDomElement top = doc.createElement( "top-border" );
  276. top.appendChild( util_createElement( "pen", topBorderPen( _col, _row ), doc ) );
  277. format.appendChild( top );
  278. }
  279. if ( hasProperty( PRightBorder, true ) || hasNoFallBackProperties( PRightBorder ) || force )
  280. {
  281. TQDomElement right = doc.createElement( "right-border" );
  282. right.appendChild( util_createElement( "pen", rightBorderPen( _col, _row ), doc ) );
  283. format.appendChild( right );
  284. }
  285. if ( hasProperty( PBottomBorder, true ) || hasNoFallBackProperties( PBottomBorder ) || force )
  286. {
  287. TQDomElement bottom = doc.createElement( "bottom-border" );
  288. bottom.appendChild( util_createElement( "pen", bottomBorderPen( _col, _row ), doc ) );
  289. format.appendChild( bottom );
  290. }
  291. if ( hasProperty( PFallDiagonal, true ) || hasNoFallBackProperties( PFallDiagonal ) || force )
  292. {
  293. TQDomElement fallDiagonal = doc.createElement( "fall-diagonal" );
  294. fallDiagonal.appendChild( util_createElement( "pen", fallDiagonalPen( _col, _row ), doc ) );
  295. format.appendChild( fallDiagonal );
  296. }
  297. if ( hasProperty( PGoUpDiagonal, true ) || hasNoFallBackProperties( PGoUpDiagonal ) || force )
  298. {
  299. TQDomElement goUpDiagonal = doc.createElement( "up-diagonal" );
  300. goUpDiagonal.appendChild( util_createElement( "pen", goUpDiagonalPen( _col, _row ), doc ) );
  301. format.appendChild( goUpDiagonal );
  302. }
  303. return format;
  304. }
  305. TQDomElement Format::saveFormat( TQDomDocument& doc, bool force, bool copy ) const
  306. {
  307. TQDomElement format( doc.createElement( "format" ) );
  308. if ( m_pStyle->type() == Style::BUILTIN || m_pStyle->type() == Style::CUSTOM )
  309. {
  310. format.setAttribute( "style-name", ((CustomStyle *) m_pStyle)->name() );
  311. if ( !copy )
  312. return format;
  313. }
  314. else
  315. {
  316. if ( m_pStyle->parent() && m_pStyle->parentName().length() > 0 )
  317. format.setAttribute( "parent", m_pStyle->parentName() );
  318. }
  319. if ( hasProperty( PAlign, true ) || hasNoFallBackProperties( PAlign ) || force )
  320. format.setAttribute( "align", (int)m_pStyle->alignX() );
  321. if ( hasProperty( PAlignY, true ) || hasNoFallBackProperties( PAlignY ) || force )
  322. format.setAttribute( "alignY", (int)m_pStyle->alignY() );
  323. if ( ( hasProperty( PBackgroundColor, true ) || hasNoFallBackProperties( PBackgroundColor )
  324. || force ) && m_pStyle->bgColor().isValid() )
  325. format.setAttribute( "bgcolor", m_pStyle->bgColor().name() );
  326. if ( ( hasProperty( PMultiRow, true ) || hasNoFallBackProperties( PMultiRow ) || force )
  327. && m_pStyle->hasProperty( Style::PMultiRow ) )
  328. format.setAttribute( "multirow", "yes" );
  329. if ( ( hasProperty( PVerticalText, true ) || hasNoFallBackProperties( PVerticalText ) || force )
  330. && m_pStyle->hasProperty( Style::PVerticalText ) )
  331. format.setAttribute( "verticaltext", "yes" );
  332. if ( hasProperty( PPrecision, true ) || hasNoFallBackProperties( PPrecision ) || force )
  333. format.setAttribute( "precision", m_pStyle->precision() );
  334. if ( ( hasProperty( PPrefix, true ) || hasNoFallBackProperties( PPrefix ) || force )
  335. && !m_pStyle->prefix().isEmpty() )
  336. format.setAttribute( "prefix", m_pStyle->prefix() );
  337. if ( ( hasProperty( PPostfix, true ) || hasNoFallBackProperties( PPostfix ) || force )
  338. && !m_pStyle->postfix().isEmpty() )
  339. format.setAttribute( "postfix", m_pStyle->postfix() );
  340. if ( hasProperty( PFloatFormat, true ) || hasNoFallBackProperties( PFloatFormat ) || force )
  341. format.setAttribute( "float", (int) m_pStyle->floatFormat() );
  342. if ( hasProperty( PFloatColor, true ) || hasNoFallBackProperties( PFloatColor ) || force )
  343. format.setAttribute( "floatcolor", (int) m_pStyle->floatColor() );
  344. if ( hasProperty( PFormatType, true ) || hasNoFallBackProperties( PFormatType ) || force )
  345. format.setAttribute( "format", (int) m_pStyle->formatType() );
  346. if ( hasProperty( PCustomFormat, true ) || hasNoFallBackProperties( PCustomFormat ) || force )
  347. if ( m_pStyle->strFormat().length() > 0 )
  348. format.setAttribute( "custom", m_pStyle->strFormat() );
  349. if ( m_pStyle->formatType() == Money_format )
  350. {
  351. format.setAttribute( "type", (int) m_pStyle->currency().type );
  352. format.setAttribute( "symbol", m_pStyle->currency().symbol );
  353. }
  354. if ( hasProperty( PAngle, true ) || hasNoFallBackProperties( PAngle ) || force )
  355. format.setAttribute( "angle", m_pStyle->rotateAngle() );
  356. if ( hasProperty( PIndent, true ) || hasNoFallBackProperties( PIndent ) || force )
  357. format.setAttribute( "indent", m_pStyle->indent() );
  358. if ( ( hasProperty( PDontPrintText, true ) || hasNoFallBackProperties( PDontPrintText ) || force )
  359. && m_pStyle->hasProperty( Style::PDontPrintText ) )
  360. format.setAttribute( "dontprinttext", "yes" );
  361. if ( ( hasProperty( PNotProtected, true ) || hasNoFallBackProperties( PNotProtected )
  362. || force ) && m_pStyle->hasProperty( Style::PNotProtected ) )
  363. format.setAttribute( "noprotection", "yes" );
  364. if( ( hasProperty( PHideAll, true ) || hasNoFallBackProperties( PHideAll )
  365. || force ) && m_pStyle->hasProperty( Style::PHideAll ) )
  366. format.setAttribute( "hideall", "yes" );
  367. if( ( hasProperty( PHideFormula, true ) || hasNoFallBackProperties( PHideFormula )
  368. || force ) && m_pStyle->hasProperty( Style::PHideFormula ) )
  369. format.setAttribute( "hideformula", "yes" );
  370. if ( hasProperty( PFont, true ) || hasNoFallBackProperties( PFont ) || force )
  371. format.appendChild( util_createElement( "font", m_pStyle->font(), doc ) );
  372. if ( ( hasProperty( PTextPen, true ) || hasNoFallBackProperties( PTextPen ) || force )
  373. && m_pStyle->pen().color().isValid() )
  374. format.appendChild( util_createElement( "pen", m_pStyle->pen(), doc ) );
  375. if ( hasProperty( PBackgroundBrush, true ) || hasNoFallBackProperties( PBackgroundBrush ) || force )
  376. {
  377. format.setAttribute( "brushcolor", m_pStyle->backGroundBrush().color().name() );
  378. format.setAttribute( "brushstyle", (int) m_pStyle->backGroundBrush().style() );
  379. }
  380. if ( hasProperty( PLeftBorder, true ) || hasNoFallBackProperties( PLeftBorder ) || force )
  381. {
  382. TQDomElement left = doc.createElement( "left-border" );
  383. left.appendChild( util_createElement( "pen", m_pStyle->leftBorderPen(), doc ) );
  384. format.appendChild( left );
  385. }
  386. if ( hasProperty( PTopBorder, true ) || hasNoFallBackProperties( PTopBorder ) || force )
  387. {
  388. TQDomElement top = doc.createElement( "top-border" );
  389. top.appendChild( util_createElement( "pen", m_pStyle->topBorderPen(), doc ) );
  390. format.appendChild( top );
  391. }
  392. if ( hasProperty( PRightBorder, true ) || hasNoFallBackProperties( PRightBorder ) || force )
  393. {
  394. TQDomElement right = doc.createElement( "right-border" );
  395. right.appendChild( util_createElement( "pen", m_pStyle->rightBorderPen(), doc ) );
  396. format.appendChild( right );
  397. }
  398. if ( hasProperty( PBottomBorder, true ) || hasNoFallBackProperties( PBottomBorder ) || force )
  399. {
  400. TQDomElement bottom = doc.createElement( "bottom-border" );
  401. bottom.appendChild( util_createElement( "pen", m_pStyle->bottomBorderPen(), doc ) );
  402. format.appendChild( bottom );
  403. }
  404. if ( hasProperty( PFallDiagonal, true ) || hasNoFallBackProperties( PFallDiagonal ) || force )
  405. {
  406. TQDomElement fallDiagonal = doc.createElement( "fall-diagonal" );
  407. fallDiagonal.appendChild( util_createElement( "pen", m_pStyle->fallDiagonalPen(), doc ) );
  408. format.appendChild( fallDiagonal );
  409. }
  410. if ( hasProperty( PGoUpDiagonal, true ) || hasNoFallBackProperties( PGoUpDiagonal ) || force )
  411. {
  412. TQDomElement goUpDiagonal = doc.createElement( "up-diagonal" );
  413. goUpDiagonal.appendChild( util_createElement( "pen", m_pStyle->goUpDiagonalPen(), doc ) );
  414. format.appendChild( goUpDiagonal );
  415. }
  416. return format;
  417. }
  418. TQDomElement Format::save( TQDomDocument & doc, int _col, int _row, bool force, bool copy ) const
  419. {
  420. TQDomElement format = saveFormat( doc, _col, _row, force, copy );
  421. return format;
  422. }
  423. bool Format::loadFormat( const TQDomElement & f, Paste::Mode pm, bool paste )
  424. {
  425. if ( f.hasAttribute( "style-name" ) )
  426. {
  427. Style * s = m_pSheet->doc()->styleManager()->style( f.attribute( "style-name" ) );
  428. //kdDebug() << "Using style: " << f.attribute( "style-name" ) << ", s: " << s << endl;
  429. if ( s )
  430. {
  431. setStyle( s );
  432. return true;
  433. }
  434. else if ( !paste )
  435. return false;
  436. }
  437. else
  438. if ( f.hasAttribute( "parent" ) )
  439. {
  440. CustomStyle* s = static_cast<CustomStyle*>( m_pSheet->doc()->styleManager()->style( f.attribute( "parent" ) ) );
  441. //kdDebug() << "Loading Style, parent: " << s->name() << ": " << s << endl;
  442. if ( s )
  443. {
  444. if ( m_pStyle && m_pStyle->release() )
  445. delete m_pStyle;
  446. m_pStyle = new Style();
  447. m_pStyle->setParent( s );
  448. }
  449. }
  450. bool ok;
  451. if ( f.hasAttribute( "align" ) )
  452. {
  453. Align a = (Align) f.attribute( "align" ).toInt( &ok );
  454. if ( !ok )
  455. return false;
  456. // Validation
  457. if ( (unsigned int) a >= 1 || (unsigned int) a <= 4 )
  458. {
  459. setAlign( a );
  460. }
  461. }
  462. if ( f.hasAttribute( "alignY" ) )
  463. {
  464. AlignY a = (AlignY) f.attribute( "alignY" ).toInt( &ok );
  465. if ( !ok )
  466. return false;
  467. // Validation
  468. if ( (unsigned int) a >= 1 || (unsigned int) a <= 4 )
  469. {
  470. setAlignY( a );
  471. }
  472. }
  473. if ( f.hasAttribute( "bgcolor" ) ) {
  474. TQColor col( f.attribute( "bgcolor" ) );
  475. if ( col != TQt::white )
  476. setBgColor( col );
  477. }
  478. if ( f.hasAttribute( "multirow" ) )
  479. setMultiRow( true );
  480. if ( f.hasAttribute( "verticaltext" ) )
  481. setVerticalText( true );
  482. if ( f.hasAttribute( "precision" ) )
  483. {
  484. int i = f.attribute( "precision" ).toInt( &ok );
  485. if ( i < -1 )
  486. {
  487. kdDebug(36001) << "Value out of range Cell::precision=" << i << endl;
  488. return false;
  489. }
  490. // Assignment
  491. setPrecision( i );
  492. }
  493. if ( f.hasAttribute( "float" ) )
  494. {
  495. FloatFormat a = (FloatFormat) f.attribute( "float" ).toInt( &ok );
  496. if ( !ok ) return false;
  497. if ( (unsigned int) a >= 1 && (unsigned int) a <= 3 )
  498. {
  499. setFloatFormat( a );
  500. }
  501. }
  502. if ( f.hasAttribute( "floatcolor" ) )
  503. {
  504. FloatColor a = (FloatColor) f.attribute( "floatcolor" ).toInt( &ok );
  505. if ( !ok ) return false;
  506. if ( (unsigned int) a >= 1 && (unsigned int) a <= 4 )
  507. {
  508. setFloatColor( a );
  509. }
  510. }
  511. if ( f.hasAttribute( "format" ) )
  512. {
  513. int fo = f.attribute( "format" ).toInt( &ok );
  514. if ( ! ok )
  515. return false;
  516. setFormatType( ( FormatType ) fo );
  517. }
  518. if ( f.hasAttribute( "custom" ) )
  519. {
  520. setFormatString( f.attribute( "custom" ) );
  521. }
  522. if ( m_pStyle->formatType() == Money_format )
  523. {
  524. Currency c;
  525. c.type = -1;
  526. if ( f.hasAttribute( "type" ) )
  527. {
  528. c.type = f.attribute( "type" ).toInt( &ok );
  529. if ( !ok )
  530. c.type = 1;
  531. }
  532. if ( f.hasAttribute( "symbol" ) )
  533. {
  534. c.symbol = f.attribute( "symbol" );
  535. }
  536. if ( c.type != -1 )
  537. setCurrency( c );
  538. }
  539. if ( f.hasAttribute( "angle" ) )
  540. {
  541. setAngle( f.attribute( "angle" ).toInt( &ok ) );
  542. if ( !ok )
  543. return false;
  544. }
  545. if ( f.hasAttribute( "indent" ) )
  546. {
  547. setIndent( f.attribute( "indent" ).toDouble( &ok ) );
  548. if ( !ok )
  549. return false;
  550. }
  551. if ( f.hasAttribute( "dontprinttext" ) )
  552. setDontPrintText( true );
  553. if ( f.hasAttribute( "noprotection" ) )
  554. setNotProtected( true );
  555. if ( f.hasAttribute( "hideall" ) )
  556. setHideAll( true );
  557. if ( f.hasAttribute( "hideformula" ) )
  558. setHideFormula( true );
  559. if ( f.hasAttribute( "brushstyle" ) )
  560. {
  561. setBackGroundBrushStyle( (Qt::BrushStyle) f.attribute( "brushstyle" ).toInt( &ok ) );
  562. if ( !ok )
  563. return false;
  564. }
  565. if ( f.hasAttribute( "brushcolor" ) )
  566. setBackGroundBrushColor( TQColor( f.attribute( "brushcolor" ) ) );
  567. TQDomElement pen( f.namedItem( "pen" ).toElement() );
  568. if ( !pen.isNull() )
  569. setTextPen( util_toPen( pen ) );
  570. TQDomElement font( f.namedItem( "font" ).toElement() );
  571. if ( !font.isNull() )
  572. setTextFont( util_toFont( font ) );
  573. if ( ( pm != Paste::NoBorder ) && ( pm != Paste::Text ) && ( pm != Paste::Comment ) )
  574. {
  575. TQDomElement left( f.namedItem( "left-border" ).toElement() );
  576. if ( !left.isNull() )
  577. {
  578. TQDomElement pen( left.namedItem( "pen" ).toElement() );
  579. if ( !pen.isNull() )
  580. setLeftBorderPen( util_toPen( pen ) );
  581. }
  582. TQDomElement top( f.namedItem( "top-border" ).toElement() );
  583. if ( !top.isNull() )
  584. {
  585. TQDomElement pen( top.namedItem( "pen" ).toElement() );
  586. if ( !pen.isNull() )
  587. setTopBorderPen( util_toPen( pen ) );
  588. }
  589. TQDomElement right( f.namedItem( "right-border" ).toElement() );
  590. if ( !right.isNull() )
  591. {
  592. TQDomElement pen( right.namedItem( "pen" ).toElement() );
  593. if ( !pen.isNull() )
  594. setRightBorderPen( util_toPen( pen ) );
  595. }
  596. TQDomElement bottom( f.namedItem( "bottom-border" ).toElement() );
  597. if ( !bottom.isNull() )
  598. {
  599. TQDomElement pen( bottom.namedItem( "pen" ).toElement() );
  600. if ( !pen.isNull() )
  601. setBottomBorderPen( util_toPen( pen ) );
  602. }
  603. TQDomElement fallDiagonal( f.namedItem( "fall-diagonal" ).toElement() );
  604. if ( !fallDiagonal.isNull() )
  605. {
  606. TQDomElement pen( fallDiagonal.namedItem( "pen" ).toElement() );
  607. if ( !pen.isNull() )
  608. setFallDiagonalPen( util_toPen( pen ) );
  609. }
  610. TQDomElement goUpDiagonal( f.namedItem( "up-diagonal" ).toElement() );
  611. if ( !goUpDiagonal.isNull() )
  612. {
  613. TQDomElement pen( goUpDiagonal.namedItem( "pen" ).toElement() );
  614. if ( !pen.isNull() )
  615. setGoUpDiagonalPen( util_toPen( pen ) );
  616. }
  617. }
  618. if ( f.hasAttribute( "prefix" ) )
  619. setPrefix( f.attribute( "prefix" ) );
  620. if ( f.hasAttribute( "postfix" ) )
  621. setPostfix( f.attribute( "postfix" ) );
  622. return true;
  623. }
  624. bool Format::load( const TQDomElement & f, Paste::Mode pm, bool paste )
  625. {
  626. if ( !loadFormat( f, pm, paste ) )
  627. return false;
  628. return true;
  629. }
  630. #if 0
  631. bool Format::loadFontOasisStyle( KoStyleStack & font )
  632. {
  633. font.setTypeProperties( "text" ); // load all style attributes from "style:text-properties"
  634. //TODO remember to change type properties
  635. if ( font.hasAttributeNS( KoXmlNS::fo, "font-family" ) )
  636. setTextFontFamily( font.attributeNS( KoXmlNS::fo, "font-family" ) );
  637. if ( font.hasAttributeNS( KoXmlNS::fo, "color" ) )
  638. setTextColor( TQColor( font.attributeNS( KoXmlNS::fo, "color" ) ) );
  639. if ( font.hasAttributeNS( KoXmlNS::fo, "font-size" ) )
  640. setTextFontSize( (int) KoUnit::parseValue( font.attributeNS( KoXmlNS::fo, "font-size" ), 10.0 ) );
  641. if ( font.hasAttributeNS( KoXmlNS::fo, "font-style" ) && ( font.attributeNS( KoXmlNS::fo,"font-style" )== "italic" ))
  642. {
  643. kdDebug(30518) << "italic" << endl;
  644. setTextFontItalic( true ); // only thing we support
  645. }
  646. if ( font.hasAttributeNS( KoXmlNS::fo, "font-weight" )
  647. && ( font.attributeNS( KoXmlNS::fo, "font-weight" ) == "bold") )
  648. setTextFontBold( true ); // only thing we support
  649. //TODO add "style:text-underline-width" "style:text-underline-color"
  650. if ( ( font.hasAttributeNS( KoXmlNS::fo, "text-underline-style" ) && font.attributeNS( KoXmlNS::fo, "text-underline-style" ) != "none" )
  651. || ( font.hasAttributeNS( KoXmlNS::style, "text-underline-style" ) && font.attributeNS( KoXmlNS::style, "text-underline-style" )!="none" ) )
  652. setTextFontUnderline( true ); // only thing we support
  653. if ( font.hasAttributeNS( KoXmlNS::style, "text-line-through-style" )
  654. && font.attributeNS( KoXmlNS::style, "text-line-through-style" ) != "none"
  655. /*&& ( font.attributeNS( KoXmlNS::style, "text-crossing-out" ) == "single-line" )*/)
  656. setTextFontStrike( true ); // only thing we support
  657. if ( font.hasAttributeNS( KoXmlNS::style, "font-pitch" ) )
  658. {
  659. // TODO: possible values: fixed, variable
  660. }
  661. // TODO: for the future when we will use kotext
  662. // text-underline-color
  663. return true;
  664. }
  665. void Format::loadOasisStyle( /*const TQDomElement& style,*/ KoOasisLoadingContext& context )
  666. {
  667. TQString str; // multi purpose string
  668. KoOasisStyles& oasisStyles = context.oasisStyles();
  669. /* context.styleStack().save();
  670. context.addStyles( &style );*/
  671. /* KoStyleStack styleStack;
  672. styleStack.push( style );
  673. styleStack.setTypeProperties( "table-cell" );*/
  674. KoStyleStack& styleStack = context.styleStack();
  675. loadOasisStyleProperties( styleStack, context.oasisStyles() );
  676. /* loadOasisStyleProperties( context.styleStack(), context.oasisStyles() );
  677. context.styleStack().restore();*/
  678. kdDebug() << "*** Loading style attributes *****" << endl;
  679. if ( styleStack.hasAttributeNS( KoXmlNS::style, "data-style-name" ) )
  680. {
  681. str = styleStack.attributeNS( KoXmlNS::style, "data-style-name" );
  682. kdDebug() << " style:data-style-name: " << str << endl << endl;
  683. if ( !str.isEmpty() )
  684. {
  685. TQString tmp = oasisStyles.dataFormats()[str].prefix;
  686. if ( !tmp.isEmpty() )
  687. {
  688. setPrefix( tmp );
  689. }
  690. tmp = oasisStyles.dataFormats()[str].suffix;
  691. if ( !tmp.isEmpty() )
  692. {
  693. setPostfix( tmp );
  694. }
  695. tmp = oasisStyles.dataFormats()[str].formatStr;
  696. if ( !tmp.isEmpty() )
  697. {
  698. setFormatType( Style::formatType( tmp ) );
  699. }
  700. }
  701. }
  702. if ( styleStack.hasAttributeNS( KoXmlNS::style, "decimal-places" ) )
  703. {
  704. bool ok = false;
  705. int p = styleStack.attributeNS( KoXmlNS::style, "decimal-places" ).toInt( &ok );
  706. kdDebug() << " style:decimal-places: " << p << endl;
  707. if (ok )
  708. setPrecision( p );
  709. }
  710. }
  711. bool Format::loadOasisStyleProperties( KoStyleStack & styleStack, const KoOasisStyles& oasisStyles )
  712. {
  713. kdDebug() << "*** Loading style properties *****" << endl;
  714. #if 0
  715. if ( f.hasAttribute( "style-name" ) )
  716. {
  717. Style * s = m_pSheet->doc()->styleManager()->style( f.attribute( "style-name" ) );
  718. //kdDebug() << "Using style: " << f.attribute( "style-name" ) << ", s: " << s << endl;
  719. if ( s )
  720. {
  721. setStyle( s );
  722. return true;
  723. }
  724. else if ( !paste )
  725. return false;
  726. }
  727. else
  728. if ( f.hasAttribute( "parent" ) )
  729. {
  730. CustomStyle * s = (CustomStyle *) m_pSheet->doc()->styleManager()->style( f.attribute( "parent" ) );
  731. //kdDebug() << "Loading Style, parent: " << s->name() << ": " << s << endl;
  732. if ( s )
  733. {
  734. if ( m_pStyle && m_pStyle->release() )
  735. delete m_pStyle;
  736. m_pStyle = new Style();
  737. m_pStyle->setParent( s );
  738. }
  739. }
  740. #endif
  741. if ( styleStack.hasAttributeNS( KoXmlNS::style, "parent-style-name" ) )
  742. {
  743. Style * s = m_pSheet->doc()->styleManager()->style( styleStack.attributeNS( KoXmlNS::style, "parent-style-name" ) );
  744. //kdDebug() << "Using style: " << f.attribute( "style-name" ) << ", s: " << s << endl;
  745. if ( s )
  746. {
  747. setStyle( s );
  748. }
  749. }
  750. else
  751. {
  752. setStyle( m_pSheet->doc()->styleManager()->defaultStyle() );
  753. }
  754. if ( styleStack.hasAttributeNS( KoXmlNS::style, "font-name" ) )
  755. {
  756. const TQDomElement * font = oasisStyles.findStyle( styleStack.attributeNS( KoXmlNS::style, "font-name" ) );
  757. if ( font )
  758. {
  759. styleStack.save();
  760. styleStack.push( *font );
  761. loadFontOasisStyle( styleStack ); // general font style
  762. styleStack.restore();
  763. }
  764. }
  765. kdDebug() << " [text properties]" << endl;
  766. //Text properties
  767. loadFontOasisStyle( styleStack ); // specific font style
  768. //End Text properties
  769. kdDebug() << " [paragraph properties]" << endl;
  770. //Paragraph properties
  771. styleStack.setTypeProperties( "paragraph" ); // load all style attributes from "style:paragraph-properties"
  772. if ( styleStack.hasAttributeNS( KoXmlNS::fo, "margin-left" ) )
  773. {
  774. kdDebug()<<" margin-left:"<<KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "margin-left" ),0.0 )<<endl;
  775. setIndent( KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "margin-left" ),0.0 ) );
  776. }
  777. //kdDebug()<<"property.hasAttribute( fo:text-align ) :"<<styleStack.hasAttributeNS( KoXmlNS::fo, "text-align" )<<endl;
  778. if ( styleStack.hasAttributeNS( KoXmlNS::fo, "text-align" ) )
  779. {
  780. TQString s = styleStack.attributeNS( KoXmlNS::fo, "text-align" );
  781. if ( s == "center" )
  782. setAlign( Format::Center );
  783. else if ( s == "end" )
  784. setAlign( Format::Right );
  785. else if ( s == "start" )
  786. setAlign( Format::Left );
  787. else if ( s == "justify" ) // TODO in KSpread!
  788. setAlign( Format::Center );
  789. }
  790. //end paragraph properties
  791. kdDebug() << " [cell properties]" << endl;
  792. styleStack.setTypeProperties( "table-cell" ); // Default
  793. // TODO:
  794. // diagonal: fall + goup
  795. // fo:direction="ltr"
  796. // style:text-align-source ("fix")
  797. // style:shadow
  798. // style:text-outline
  799. // indents from right, top, bottom
  800. // style:condition="cell-content()=15"
  801. // => style:apply-style-name="Result" style:base-cell-address="Sheet6.A5"/>
  802. if ( styleStack.hasAttributeNS( KoXmlNS::style, "rotation-angle" ) )
  803. {
  804. bool ok = false;
  805. int a = styleStack.attributeNS( KoXmlNS::style, "rotation-angle" ).toInt( &ok );
  806. if ( ok && ( a != 0 ))
  807. setAngle( -a );
  808. }
  809. if ( styleStack.hasAttributeNS( KoXmlNS::style, "direction" ) )
  810. {
  811. TQString dir = styleStack.attributeNS( KoXmlNS::fo, "direction" );
  812. if ( dir == "ttb" )
  813. setVerticalText( true );
  814. else if ( dir == "ltr" )
  815. setVerticalText( false );
  816. }
  817. kdDebug()<<"property.hasAttribute( fo:background-color ) :"<<styleStack.hasAttributeNS( KoXmlNS::fo, "background-color" )<<endl;
  818. if ( styleStack.hasAttributeNS( KoXmlNS::fo, "background-color" ) )
  819. setBgColor( TQColor( styleStack.attributeNS( KoXmlNS::fo, "background-color" ) ) );
  820. if ( styleStack.hasAttributeNS( KoXmlNS::style, "print-content" ) )
  821. {
  822. if ( styleStack.attributeNS( KoXmlNS::style, "print-content" ) == "false" )
  823. setDontPrintText( false );
  824. }
  825. if ( styleStack.hasAttributeNS( KoXmlNS::style, "cell-protect" ) )
  826. {
  827. TQString prot( styleStack.attributeNS( KoXmlNS::style, "cell-protect" ) );
  828. if ( prot == "none" )
  829. {
  830. setNotProtected( true );
  831. setHideFormula( false );
  832. setHideAll( false );
  833. }
  834. else if ( prot == "formula-hidden" )
  835. {
  836. setNotProtected( true );
  837. setHideFormula( true );
  838. setHideAll( false );
  839. }
  840. else if ( prot == "protected formula-hidden" )
  841. {
  842. setNotProtected( false );
  843. setHideFormula( true );
  844. setHideAll( false );
  845. }
  846. else if ( prot == "hidden-and-protected" )
  847. {
  848. setNotProtected( false );
  849. setHideFormula( false );
  850. setHideAll( true );
  851. }
  852. else if ( prot == "protected" )
  853. {
  854. setNotProtected( false );
  855. setHideFormula( false );
  856. setHideAll( false );
  857. }
  858. else
  859. kdDebug()<<" Protected cell not supported :"<<prot<<endl;
  860. kdDebug() << " cell-protect: " << prot << endl;
  861. }
  862. if ( styleStack.hasAttributeNS( KoXmlNS::fo, "padding-left" ) )
  863. setIndent( KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "padding-left" ) ) );
  864. if ( styleStack.hasAttributeNS( KoXmlNS::style, "vertical-align" ) )
  865. {
  866. TQString s = styleStack.attributeNS( KoXmlNS::style, "vertical-align" );
  867. if ( s == "middle" )
  868. setAlignY( Format::Middle );
  869. else if ( s == "bottom" )
  870. setAlignY( Format::Bottom );
  871. else if ( s == "top" )
  872. setAlignY( Format::Top );
  873. }
  874. if ( styleStack.hasAttributeNS( KoXmlNS::fo, "wrap-option" ) )
  875. {
  876. // we do not support anything else yet
  877. TQString wrapOpt = styleStack.attributeNS( KoXmlNS::fo, "wrap-option" );
  878. if ( wrapOpt == "wrap" )
  879. setMultiRow( true );
  880. else if ( wrapOpt == "no-wrap" )
  881. setMultiRow( false );
  882. }
  883. if ( styleStack.hasAttributeNS( KoXmlNS::fo, "border-bottom" ) )
  884. {
  885. setBottomBorderPen( convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::fo, "border-bottom" ) ) );
  886. // TODO: style:border-line-width-bottom if double!
  887. }
  888. if ( styleStack.hasAttributeNS( KoXmlNS::fo, "border-right" ) )
  889. {
  890. setRightBorderPen( convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::fo, "border-right" ) ) );
  891. // TODO: style:border-line-width-right
  892. }
  893. if ( styleStack.hasAttributeNS( KoXmlNS::fo, "border-top" ) )
  894. {
  895. setTopBorderPen( convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::fo, "border-top" ) ) );
  896. // TODO: style:border-line-width-top
  897. }
  898. if ( styleStack.hasAttributeNS( KoXmlNS::fo, "border-left" ) )
  899. {
  900. setLeftBorderPen( convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::fo, "border-left" ) ) );
  901. // TODO: style:border-line-width-left
  902. }
  903. if ( styleStack.hasAttributeNS( KoXmlNS::fo, "border" ) )
  904. {
  905. TQPen pen = convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::fo, "border" ) );
  906. setLeftBorderPen( pen );
  907. setRightBorderPen( pen );
  908. setTopBorderPen( pen );
  909. setBottomBorderPen( pen );
  910. // TODO: style:border-line-width-left
  911. }
  912. if ( styleStack.hasAttributeNS( KoXmlNS::style, "diagonal-tl-br" ) )
  913. {
  914. setFallDiagonalPen( convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::style, "diagonal-tl-br" ) ) );
  915. }
  916. if ( styleStack.hasAttributeNS( KoXmlNS::style, "diagonal-bl-tr" ) )
  917. {
  918. setGoUpDiagonalPen( convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::style, "diagonal-bl-tr" ) ) );
  919. }
  920. if ( styleStack.hasAttributeNS( KoXmlNS::draw, "style-name" ) )
  921. {
  922. //kdDebug()<<" style name :"<<styleStack.attributeNS( KoXmlNS::draw, "style-name" )<<endl;
  923. const TQDomElement * style = oasisStyles.findStyle( styleStack.attributeNS( KoXmlNS::draw, "style-name" ), "graphic" );
  924. if ( style )
  925. {
  926. //kdDebug()<<" style :"<<style<<endl;
  927. KoStyleStack drawStyleStack;
  928. drawStyleStack.push( *style );
  929. drawStyleStack.setTypeProperties( "graphic" );
  930. if ( drawStyleStack.hasAttributeNS( KoXmlNS::draw, "fill" ) )
  931. {
  932. const TQString fill = drawStyleStack.attributeNS( KoXmlNS::draw, "fill" );
  933. kdDebug()<<" load object gradient fill type :"<<fill<<endl;
  934. if ( fill == "solid" || fill == "hatch" )
  935. {
  936. TQBrush brush=KoOasisStyles::loadOasisFillStyle( drawStyleStack, fill, oasisStyles );
  937. setBackGroundBrushStyle( brush.style() );
  938. setBackGroundBrushColor( brush.color() );
  939. }
  940. else
  941. kdDebug()<<" fill style not supported by kspread : "<<fill<<endl;
  942. }
  943. }
  944. }
  945. return true;
  946. }
  947. #endif
  948. /////////////
  949. //
  950. // Set methods
  951. //
  952. /////////////
  953. void Format::setFormatString( TQString const & format )
  954. {
  955. if ( format.isEmpty() )
  956. {
  957. clearProperty( PCustomFormat );
  958. setNoFallBackProperties( PCustomFormat );
  959. }
  960. else
  961. {
  962. setProperty( PCustomFormat );
  963. clearNoFallBackProperties( PCustomFormat );
  964. // now have a custom format...
  965. clearProperty( PPrefix );
  966. clearProperty( PPostfix );
  967. clearProperty( PPrecision );
  968. clearProperty( PFloatColor );
  969. clearProperty( PFloatFormat );
  970. setNoFallBackProperties( PPrecision );
  971. setNoFallBackProperties( PPrefix );
  972. setNoFallBackProperties( PPostfix );
  973. }
  974. m_pStyle = m_pStyle->setStrFormat( format );
  975. formatChanged();
  976. }
  977. void Format::setAlign( Align _align )
  978. {
  979. if ( _align == Format::Undefined )
  980. {
  981. clearProperty( PAlign );
  982. setNoFallBackProperties(PAlign );
  983. }
  984. else
  985. {
  986. setProperty( PAlign );
  987. clearNoFallBackProperties(PAlign );
  988. }
  989. m_pStyle = m_pStyle->setAlignX( _align );
  990. formatChanged();
  991. }
  992. void Format::setAlignY( AlignY _alignY)
  993. {
  994. //kdDebug() << "Format: AlignY: " << _alignY << endl;
  995. if ( _alignY == Format::Middle )
  996. {
  997. //kdDebug() << "Middle" << endl;
  998. clearProperty( PAlignY );
  999. setNoFallBackProperties(PAlignY );
  1000. }
  1001. else
  1002. {
  1003. //kdDebug() << "Not middle: " << _alignY << endl;
  1004. setProperty( PAlignY );
  1005. clearNoFallBackProperties( PAlignY );
  1006. }
  1007. m_pStyle = m_pStyle->setAlignY( _alignY );
  1008. formatChanged();
  1009. }
  1010. void Format::setPrefix( const TQString& _prefix )
  1011. {
  1012. if ( _prefix.isEmpty() )
  1013. {
  1014. clearProperty( PPrefix );
  1015. setNoFallBackProperties( PPrefix );
  1016. }
  1017. else
  1018. {
  1019. setProperty( PPrefix );
  1020. clearNoFallBackProperties( PPrefix );
  1021. }
  1022. m_pStyle = m_pStyle->setPrefix( _prefix );
  1023. formatChanged();
  1024. }
  1025. void Format::setPostfix( const TQString& _postfix )
  1026. {
  1027. if ( _postfix.isEmpty() )
  1028. {
  1029. clearProperty( PPostfix );
  1030. setNoFallBackProperties( PPostfix );
  1031. }
  1032. else
  1033. {
  1034. setProperty( PPostfix );
  1035. clearNoFallBackProperties( PPostfix );
  1036. }
  1037. m_pStyle = m_pStyle->setPostfix( _postfix );
  1038. formatChanged();
  1039. }
  1040. void Format::setPrecision( int _p )
  1041. {
  1042. if ( _p == -1 )
  1043. {
  1044. clearProperty( PPrecision );
  1045. setNoFallBackProperties( PPrecision );
  1046. }
  1047. else
  1048. {
  1049. setProperty( PPrecision );
  1050. clearNoFallBackProperties( PPrecision );
  1051. }
  1052. m_pStyle = m_pStyle->setPrecision( _p );
  1053. formatChanged();
  1054. }
  1055. void Format::setLeftBorderPen( const TQPen & _p )
  1056. {
  1057. if ( _p.style() == TQt::NoPen )
  1058. {
  1059. clearProperty( PLeftBorder );
  1060. setNoFallBackProperties( PLeftBorder );
  1061. }
  1062. else
  1063. {
  1064. setProperty( PLeftBorder );
  1065. clearNoFallBackProperties( PLeftBorder );
  1066. }
  1067. m_pStyle = m_pStyle->setLeftBorderPen( _p );
  1068. formatChanged();
  1069. }
  1070. void Format::setLeftBorderStyle( Qt::PenStyle s )
  1071. {
  1072. TQPen p( m_pStyle->leftBorderPen() );
  1073. p.setStyle( s );
  1074. setLeftBorderPen( p );
  1075. }
  1076. void Format::setLeftBorderColor( const TQColor & c )
  1077. {
  1078. TQPen p( m_pStyle->leftBorderPen() );
  1079. p.setColor( c );
  1080. setLeftBorderPen( p );
  1081. }
  1082. void Format::setLeftBorderWidth( int _w )
  1083. {
  1084. TQPen p( m_pStyle->leftBorderPen() );
  1085. p.setWidth( _w );
  1086. setLeftBorderPen( p );
  1087. }
  1088. void Format::setTopBorderPen( const TQPen & _p )
  1089. {
  1090. if ( _p.style() == TQt::NoPen )
  1091. {
  1092. clearProperty( PTopBorder );
  1093. setNoFallBackProperties( PTopBorder );
  1094. }
  1095. else
  1096. {
  1097. setProperty( PTopBorder );
  1098. clearNoFallBackProperties( PTopBorder );
  1099. }
  1100. m_pStyle = m_pStyle->setTopBorderPen( _p );
  1101. formatChanged();
  1102. }
  1103. void Format::setTopBorderStyle( Qt::PenStyle s )
  1104. {
  1105. TQPen p( m_pStyle->topBorderPen() );
  1106. p.setStyle( s );
  1107. setTopBorderPen( p );
  1108. }
  1109. void Format::setTopBorderColor( const TQColor& c )
  1110. {
  1111. TQPen p( m_pStyle->topBorderPen() );
  1112. p.setColor( c );
  1113. setTopBorderPen( p );
  1114. }
  1115. void Format::setTopBorderWidth( int _w )
  1116. {
  1117. TQPen p( m_pStyle->topBorderPen() );
  1118. p.setWidth( _w );
  1119. setTopBorderPen( p );
  1120. }
  1121. void Format::setRightBorderPen( const TQPen& p )
  1122. {
  1123. if ( p.style() == TQt::NoPen )
  1124. {
  1125. clearProperty( PRightBorder );
  1126. setNoFallBackProperties( PRightBorder );
  1127. }
  1128. else
  1129. {
  1130. setProperty( PRightBorder );
  1131. clearNoFallBackProperties( PRightBorder );
  1132. }
  1133. m_pStyle = m_pStyle->setRightBorderPen( p );
  1134. formatChanged();
  1135. }
  1136. void Format::setRightBorderStyle( Qt::PenStyle _s )
  1137. {
  1138. TQPen p( m_pStyle->rightBorderPen() );
  1139. p.setStyle( _s );
  1140. setRightBorderPen( p );
  1141. }
  1142. void Format::setRightBorderColor( const TQColor & _c )
  1143. {
  1144. TQPen p( m_pStyle->rightBorderPen() );
  1145. p.setColor( _c );
  1146. setRightBorderPen( p );
  1147. }
  1148. void Format::setRightBorderWidth( int _w )
  1149. {
  1150. TQPen p( m_pStyle->rightBorderPen() );
  1151. p.setWidth( _w );
  1152. setRightBorderPen( p );
  1153. }
  1154. void Format::setBottomBorderPen( const TQPen& p )
  1155. {
  1156. if ( p.style() == TQt::NoPen )
  1157. {
  1158. clearProperty( PBottomBorder );
  1159. setNoFallBackProperties( PBottomBorder );
  1160. }
  1161. else
  1162. {
  1163. setProperty( PBottomBorder );
  1164. clearNoFallBackProperties( PBottomBorder );
  1165. }
  1166. m_pStyle = m_pStyle->setBottomBorderPen( p );
  1167. formatChanged();
  1168. }
  1169. void Format::setBottomBorderStyle( Qt::PenStyle _s )
  1170. {
  1171. TQPen p( m_pStyle->bottomBorderPen() );
  1172. p.setStyle( _s );
  1173. setBottomBorderPen( p );
  1174. }
  1175. void Format::setBottomBorderColor( const TQColor & _c )
  1176. {
  1177. TQPen p( m_pStyle->bottomBorderPen() );
  1178. p.setColor( _c );
  1179. setBottomBorderPen( p );
  1180. }
  1181. void Format::setBottomBorderWidth( int _w )
  1182. {
  1183. TQPen p( m_pStyle->bottomBorderPen() );
  1184. p.setWidth( _w );
  1185. setBottomBorderPen( p );
  1186. }
  1187. void Format::setFallDiagonalPen( const TQPen & _p )
  1188. {
  1189. if ( _p.style() == TQt::NoPen )
  1190. {
  1191. clearProperty( PFallDiagonal );
  1192. setNoFallBackProperties( PFallDiagonal );
  1193. }
  1194. else
  1195. {
  1196. setProperty( PFallDiagonal );
  1197. clearNoFallBackProperties( PFallDiagonal );
  1198. }
  1199. m_pStyle = m_pStyle->setFallDiagonalPen( _p );
  1200. formatChanged();
  1201. }
  1202. void Format::setFallDiagonalStyle( Qt::PenStyle s )
  1203. {
  1204. TQPen p( m_pStyle->fallDiagonalPen() );
  1205. p.setStyle( s );
  1206. setFallDiagonalPen( p );
  1207. }
  1208. void Format::setFallDiagonalColor( const TQColor& c )
  1209. {
  1210. TQPen p( m_pStyle->fallDiagonalPen() );
  1211. p.setColor( c );
  1212. setFallDiagonalPen( p );
  1213. }
  1214. void Format::setFallDiagonalWidth( int _w )
  1215. {
  1216. TQPen p( m_pStyle->fallDiagonalPen() );
  1217. p.setWidth( _w );
  1218. setFallDiagonalPen( p );
  1219. }
  1220. void Format::setGoUpDiagonalPen( const TQPen & _p )
  1221. {
  1222. if ( _p.style() == TQt::NoPen )
  1223. {
  1224. clearProperty( PGoUpDiagonal );
  1225. setNoFallBackProperties( PGoUpDiagonal );
  1226. }
  1227. else
  1228. {
  1229. setProperty( PGoUpDiagonal );
  1230. clearNoFallBackProperties( PGoUpDiagonal );
  1231. }
  1232. m_pStyle = m_pStyle->setGoUpDiagonalPen( _p );
  1233. formatChanged();
  1234. }
  1235. void Format::setGoUpDiagonalStyle( Qt::PenStyle s )
  1236. {
  1237. TQPen p( m_pStyle->goUpDiagonalPen() );
  1238. p.setStyle( s );
  1239. setGoUpDiagonalPen( p );
  1240. }
  1241. void Format::setGoUpDiagonalColor( const TQColor& c )
  1242. {
  1243. TQPen p( m_pStyle->goUpDiagonalPen() );
  1244. p.setColor( c );
  1245. setGoUpDiagonalPen( p );
  1246. }
  1247. void Format::setGoUpDiagonalWidth( int _w )
  1248. {
  1249. TQPen p( m_pStyle->goUpDiagonalPen() );
  1250. p.setWidth( _w );
  1251. setGoUpDiagonalPen( p );
  1252. }
  1253. void Format::setBackGroundBrush( const TQBrush & _p)
  1254. {
  1255. if ( _p.style() == TQt::NoBrush )
  1256. {
  1257. clearProperty( PBackgroundBrush );
  1258. setNoFallBackProperties( PBackgroundBrush );
  1259. }
  1260. else
  1261. {
  1262. setProperty( PBackgroundBrush );
  1263. clearNoFallBackProperties( PBackgroundBrush );
  1264. }
  1265. m_pStyle = m_pStyle->setBackGroundBrush( _p );
  1266. formatChanged();
  1267. }
  1268. void Format::setBackGroundBrushStyle( Qt::BrushStyle s )
  1269. {
  1270. TQBrush b( m_pStyle->backGroundBrush() );
  1271. b.setStyle( s );
  1272. setBackGroundBrush( b );
  1273. }
  1274. void Format::setBackGroundBrushColor( const TQColor & c )
  1275. {
  1276. TQBrush b( m_pStyle->backGroundBrush() );
  1277. b.setColor( c );
  1278. setBackGroundBrush( b );
  1279. }
  1280. void Format::setTextFont( const TQFont & _f )
  1281. {
  1282. if( m_pStyle->parent() && _f == m_pStyle->parent()->font())
  1283. {
  1284. clearProperty( PFont );
  1285. setNoFallBackProperties( PFont );
  1286. }
  1287. else if( !m_pStyle->parent() && _f == KoGlobal::defaultFont() )
  1288. {
  1289. clearProperty( PFont );
  1290. setNoFallBackProperties( PFont );
  1291. }
  1292. else
  1293. {
  1294. setProperty( PFont );
  1295. clearNoFallBackProperties( PFont );
  1296. }
  1297. m_pStyle = m_pStyle->setFont( _f );
  1298. formatChanged();
  1299. }
  1300. void Format::setTextFontSize( int _s )
  1301. {
  1302. TQFont f( m_pStyle->font() );
  1303. f.setPointSize( _s );
  1304. setTextFont( f );
  1305. }
  1306. void Format::setTextFontFamily( const TQString & _f )
  1307. {
  1308. TQFont f( m_pStyle->font() );
  1309. f.setFamily( _f );
  1310. setTextFont( f );
  1311. }
  1312. void Format::setTextFontBold( bool _b )
  1313. {
  1314. TQFont f( m_pStyle->font() );
  1315. f.setBold( _b );
  1316. setTextFont( f );
  1317. }
  1318. void Format::setTextFontItalic( bool _i )
  1319. {
  1320. TQFont f( m_pStyle->font() );
  1321. f.setItalic( _i );
  1322. setTextFont( f );
  1323. }
  1324. void Format::setTextFontUnderline( bool _i )
  1325. {
  1326. TQFont f( m_pStyle->font() );
  1327. f.setUnderline( _i );
  1328. setTextFont( f );
  1329. }
  1330. void Format::setTextFontStrike( bool _i )
  1331. {
  1332. TQFont f( m_pStyle->font() );
  1333. f.setStrikeOut( _i );
  1334. setTextFont( f );
  1335. }
  1336. void Format::setTextPen( const TQPen & _p )
  1337. {
  1338. // An invalid color means "the default text color, from the color scheme"
  1339. // It doesn't mean "no setting here, look at fallback"
  1340. // Maybe we should look at the fallback color, in fact.
  1341. /*if(!_p.color().isValid())
  1342. {
  1343. clearProperty( PTextPen );
  1344. setNoFallBackProperties( PTextPen );
  1345. }
  1346. else*/
  1347. {
  1348. setProperty( PTextPen );
  1349. clearNoFallBackProperties( PTextPen );
  1350. }
  1351. //setProperty( PTextPen );
  1352. m_pStyle = m_pStyle->setPen( _p );
  1353. //kdDebug(36001) << "setTextPen: this=" << this << " pen=" << m_textPen.color().name() << " valid:" << m_textPen.color().isValid() << endl;
  1354. formatChanged();
  1355. }
  1356. void Format::setTextColor( const TQColor & _c )
  1357. {
  1358. TQPen p( m_pStyle->pen() );
  1359. p.setColor( _c );
  1360. setTextPen( p );
  1361. }
  1362. void Format::setBgColor( const TQColor & _c )
  1363. {
  1364. if ( !_c.isValid() )
  1365. {
  1366. clearProperty( PBackgroundColor );
  1367. setNoFallBackProperties( PBackgroundColor );
  1368. }
  1369. else
  1370. {
  1371. setProperty( PBackgroundColor );
  1372. clearNoFallBackProperties( PBackgroundColor );
  1373. }
  1374. m_pStyle = m_pStyle->setBgColor( _c );
  1375. formatChanged();
  1376. }
  1377. void Format::setFloatFormat( FloatFormat _f )
  1378. {
  1379. setProperty( PFloatFormat );
  1380. m_pStyle = m_pStyle->setFloatFormat( _f );
  1381. formatChanged();
  1382. }
  1383. void Format::setFloatColor( FloatColor _c )
  1384. {
  1385. setProperty( PFloatColor );
  1386. m_pStyle = m_pStyle->setFloatColor( _c );
  1387. formatChanged();
  1388. }
  1389. void Format::setMultiRow( bool _b )
  1390. {
  1391. if ( _b == false )
  1392. {
  1393. m_pStyle = m_pStyle->clearProperty( Style::PMultiRow );
  1394. clearProperty( PMultiRow );
  1395. setNoFallBackProperties( PMultiRow );
  1396. }
  1397. else
  1398. {
  1399. m_pStyle = m_pStyle->setProperty( Style::PMultiRow );
  1400. setProperty( PMultiRow );
  1401. clearNoFallBackProperties( PMultiRow );
  1402. }
  1403. formatChanged();
  1404. }
  1405. void Format::setVerticalText( bool _b )
  1406. {
  1407. if ( _b == false )
  1408. {
  1409. m_pStyle = m_pStyle->clearProperty( Style::PVerticalText );
  1410. setNoFallBackProperties( PVerticalText);
  1411. clearFlag( Flag_VerticalText );
  1412. }
  1413. else
  1414. {
  1415. m_pStyle = m_pStyle->setProperty( Style::PVerticalText );
  1416. clearNoFallBackProperties( PVerticalText);
  1417. setFlag( Flag_VerticalText );
  1418. }
  1419. formatChanged();
  1420. }
  1421. void Format::setFormatType( FormatType _format )
  1422. {
  1423. if ( _format == Number_format )
  1424. {
  1425. clearProperty( PFormatType );
  1426. setNoFallBackProperties( PFormatType);
  1427. }
  1428. else
  1429. {
  1430. setProperty( PFormatType );
  1431. clearNoFallBackProperties( PFormatType);
  1432. }
  1433. m_pStyle = m_pStyle->setFormatType( _format );
  1434. formatChanged();
  1435. }
  1436. void Format::setAngle( int _angle )
  1437. {
  1438. if ( _angle == 0 )
  1439. {
  1440. clearProperty( PAngle );
  1441. setNoFallBackProperties( PAngle);
  1442. }
  1443. else
  1444. {
  1445. setProperty( PAngle );
  1446. clearNoFallBackProperties( PAngle);
  1447. }
  1448. m_pStyle = m_pStyle->setRotateAngle( _angle );
  1449. formatChanged();
  1450. }
  1451. void Format::setIndent( double _indent )
  1452. {
  1453. if ( _indent == 0.0 )
  1454. {
  1455. clearProperty( PIndent );
  1456. setNoFallBackProperties( PIndent );
  1457. }
  1458. else
  1459. {
  1460. setProperty( PIndent );
  1461. clearNoFallBackProperties( PIndent );
  1462. }
  1463. m_pStyle = m_pStyle->setIndent( _indent );
  1464. formatChanged();
  1465. }
  1466. void Format::setComment( const TQString & _comment )
  1467. {
  1468. if ( _comment.isEmpty() )
  1469. {
  1470. clearProperty( PComment );
  1471. setNoFallBackProperties( PComment );
  1472. }
  1473. else
  1474. {
  1475. setProperty( PComment );
  1476. clearNoFallBackProperties( PComment );
  1477. }
  1478. // not part of the style
  1479. delete m_strComment;
  1480. if ( !_comment.isEmpty() )
  1481. m_strComment = new TQString( _comment );
  1482. else
  1483. m_strComment = 0;
  1484. formatChanged();
  1485. }
  1486. void Format::setNotProtected( bool _b)
  1487. {
  1488. if ( _b == false )
  1489. {
  1490. m_pStyle = m_pStyle->clearProperty( Style::PNotProtected );
  1491. setNoFallBackProperties( PNotProtected );
  1492. clearFlag( Flag_NotProtected );
  1493. }
  1494. else
  1495. {
  1496. m_pStyle = m_pStyle->setProperty( Style::PNotProtected );
  1497. clearNoFallBackProperties( PNotProtected );
  1498. setFlag( Flag_NotProtected );
  1499. }
  1500. formatChanged();
  1501. }
  1502. void Format::setDontPrintText( bool _b )
  1503. {
  1504. if ( _b == false )
  1505. {
  1506. m_pStyle = m_pStyle->clearProperty( Style::PDontPrintText );
  1507. setNoFallBackProperties(PDontPrintText);
  1508. clearFlag( Flag_DontPrintText );
  1509. }
  1510. else
  1511. {
  1512. m_pStyle = m_pStyle->setProperty( Style::PDontPrintText );
  1513. clearNoFallBackProperties( PDontPrintText);
  1514. setFlag( Flag_DontPrintText );
  1515. }
  1516. formatChanged();
  1517. }
  1518. void Format::setHideAll( bool _b )
  1519. {
  1520. if ( _b == false )
  1521. {
  1522. m_pStyle = m_pStyle->clearProperty( Style::PHideAll );
  1523. setNoFallBackProperties(PHideAll);
  1524. clearFlag( Flag_HideAll );
  1525. }
  1526. else
  1527. {
  1528. m_pStyle = m_pStyle->setProperty( Style::PHideAll );
  1529. clearNoFallBackProperties( PHideAll);
  1530. setFlag( Flag_HideAll );
  1531. }
  1532. formatChanged();
  1533. }
  1534. void Format::setHideFormula( bool _b )
  1535. {
  1536. if ( _b == false )
  1537. {
  1538. m_pStyle = m_pStyle->clearProperty( Style::PHideFormula );
  1539. setNoFallBackProperties( PHideFormula );
  1540. clearFlag( Flag_HideFormula );
  1541. }
  1542. else
  1543. {
  1544. m_pStyle = m_pStyle->setProperty( Style::PHideFormula );
  1545. clearNoFallBackProperties( PHideFormula );
  1546. setFlag( Flag_HideFormula );
  1547. }
  1548. formatChanged();
  1549. }
  1550. void Format::setCurrency( Currency const & c )
  1551. {
  1552. m_pStyle = m_pStyle->setCurrency( c );
  1553. }
  1554. void Format::setCurrency( int type, TQString const & symbol )
  1555. {
  1556. Currency c;
  1557. c.symbol = symbol.simplifyWhiteSpace();
  1558. c.type = type;
  1559. if (c.symbol.length() == 0)
  1560. {
  1561. c.type = 0;
  1562. c.symbol = sheet()->doc()->locale()->currencySymbol();
  1563. }
  1564. m_pStyle = m_pStyle->setCurrency( c );
  1565. }
  1566. /////////////
  1567. //
  1568. // Get methods
  1569. //
  1570. /////////////
  1571. TQString const & Format::getFormatString( int col, int row ) const
  1572. {
  1573. if ( !hasProperty( PCustomFormat, false ) && !hasNoFallBackProperties( PCustomFormat ))
  1574. {
  1575. const Format * l = fallbackFormat( col, row );
  1576. if ( l )
  1577. return l->getFormatString( col, row );
  1578. }
  1579. return m_pStyle->strFormat();
  1580. }
  1581. TQString Format::prefix( int col, int row ) const
  1582. {
  1583. if ( !hasProperty( PPrefix, false ) && !hasNoFallBackProperties(PPrefix ))
  1584. {
  1585. const Format * l = fallbackFormat( col, row );
  1586. if ( l )
  1587. return l->prefix( col, row );
  1588. }
  1589. return m_pStyle->prefix();
  1590. }
  1591. TQString Format::postfix( int col, int row ) const
  1592. {
  1593. if ( !hasProperty( PPostfix, false ) && !hasNoFallBackProperties(PPostfix ))
  1594. {
  1595. const Format * l = fallbackFormat( col, row );
  1596. if ( l )
  1597. return l->postfix( col, row );
  1598. }
  1599. return m_pStyle->postfix();
  1600. }
  1601. const TQPen& Format::fallDiagonalPen( int col, int row ) const
  1602. {
  1603. if ( !hasProperty( PFallDiagonal, false ) && !hasNoFallBackProperties(PFallDiagonal ))
  1604. {
  1605. const Format* l = fallbackFormat( col, row );
  1606. if ( l )
  1607. return l->fallDiagonalPen( col, row );
  1608. }
  1609. return m_pStyle->fallDiagonalPen();
  1610. }
  1611. int Format::fallDiagonalWidth( int col, int row ) const
  1612. {
  1613. return fallDiagonalPen( col, row ).width();
  1614. }
  1615. Qt::PenStyle Format::fallDiagonalStyle( int col, int row ) const
  1616. {
  1617. return fallDiagonalPen( col, row ).style();
  1618. }
  1619. const TQColor & Format::fallDiagonalColor( int col, int row ) const
  1620. {
  1621. return fallDiagonalPen( col, row ).color();
  1622. }
  1623. const TQPen & Format::goUpDiagonalPen( int col, int row ) const
  1624. {
  1625. if ( !hasProperty( PGoUpDiagonal, false ) && !hasNoFallBackProperties( PGoUpDiagonal ) )
  1626. {
  1627. const Format* l = fallbackFormat( col, row );
  1628. if ( l )
  1629. return l->goUpDiagonalPen( col, row );
  1630. }
  1631. return m_pStyle->goUpDiagonalPen();
  1632. }
  1633. int Format::goUpDiagonalWidth( int col, int row ) const
  1634. {
  1635. return goUpDiagonalPen( col, row ).width();
  1636. }
  1637. Qt::PenStyle Format::goUpDiagonalStyle( int col, int row ) const
  1638. {
  1639. return goUpDiagonalPen( col, row ).style();
  1640. }
  1641. const TQColor& Format::goUpDiagonalColor( int col, int row ) const
  1642. {
  1643. return goUpDiagonalPen( col, row ).color();
  1644. }
  1645. uint Format::bottomBorderValue( int col, int row ) const
  1646. {
  1647. if ( !hasProperty( PBottomBorder, false ) && !hasNoFallBackProperties( PBottomBorder ) )
  1648. {
  1649. const Format * l = fallbackFormat( col, row );
  1650. if ( l )
  1651. return l->bottomBorderValue( col, row );
  1652. return 0;
  1653. }
  1654. return m_pStyle->bottomPenValue();
  1655. }
  1656. uint Format::rightBorderValue( int col, int row ) const
  1657. {
  1658. if ( !hasProperty( PRightBorder, false ) && !hasNoFallBackProperties( PRightBorder ) )
  1659. {
  1660. const Format * l = fallbackFormat( col, row );
  1661. if ( l )
  1662. return l->rightBorderValue( col, row );
  1663. return 0;
  1664. }
  1665. return m_pStyle->rightPenValue();
  1666. }
  1667. uint Format::leftBorderValue( int col, int row ) const
  1668. {
  1669. if ( !hasProperty( PLeftBorder, false ) && !hasNoFallBackProperties( PLeftBorder ) )
  1670. {
  1671. const Format * l = fallbackFormat( col, row );
  1672. if ( l )
  1673. return l->leftBorderValue( col, row );
  1674. return 0;
  1675. }
  1676. return m_pStyle->leftPenValue();
  1677. }
  1678. uint Format::topBorderValue( int col, int row ) const
  1679. {
  1680. if ( !hasProperty( PTopBorder, false ) && !hasNoFallBackProperties( PTopBorder ) )
  1681. {
  1682. const Format * l = fallbackFormat( col, row );
  1683. if ( l )
  1684. return l->topBorderValue( col, row );
  1685. return 0;
  1686. }
  1687. return m_pStyle->topPenValue();
  1688. }
  1689. const TQPen& Format::leftBorderPen( int col, int row ) const
  1690. {
  1691. if ( !hasProperty( PLeftBorder, false ) && !hasNoFallBackProperties( PLeftBorder ) )
  1692. {
  1693. const Format * l = fallbackFormat( col, row );
  1694. if ( l )
  1695. return l->leftBorderPen( col, row );
  1696. return sheet()->emptyPen();
  1697. }
  1698. return m_pStyle->leftBorderPen();
  1699. }
  1700. Qt::PenStyle Format::leftBorderStyle( int col, int row ) const
  1701. {
  1702. return leftBorderPen( col, row ).style();
  1703. }
  1704. const TQColor& Format::leftBorderColor( int col, int row ) const
  1705. {
  1706. return leftBorderPen( col, row ).color();
  1707. }
  1708. int Format::leftBorderWidth( int col, int row ) const
  1709. {
  1710. return leftBorderPen( col, row ).width();
  1711. }
  1712. const TQPen& Format::topBorderPen( int col, int row ) const
  1713. {
  1714. if ( !hasProperty( PTopBorder, false ) && !hasNoFallBackProperties( PTopBorder ) )
  1715. {
  1716. const Format* l = fallbackFormat( col, row );
  1717. if ( l )
  1718. return l->topBorderPen( col, row );
  1719. return sheet()->emptyPen();
  1720. }
  1721. return m_pStyle->topBorderPen();
  1722. }
  1723. const TQColor& Format::topBorderColor( int col, int row ) const
  1724. {
  1725. return topBorderPen( col, row ).color();
  1726. }
  1727. Qt::PenStyle Format::topBorderStyle( int col, int row ) const
  1728. {
  1729. return topBorderPen( col, row ).style();
  1730. }
  1731. int Format::topBorderWidth( int col, int row ) const
  1732. {
  1733. return topBorderPen( col, row ).width();
  1734. }
  1735. const TQPen& Format::rightBorderPen( int col, int row ) const
  1736. {
  1737. if ( !hasProperty( PRightBorder, false ) && !hasNoFallBackProperties( PRightBorder ) )
  1738. {
  1739. const Format * l = fallbackFormat( col, row );
  1740. if ( l )
  1741. return l->rightBorderPen( col, row );
  1742. return sheet()->emptyPen();
  1743. }
  1744. return m_pStyle->rightBorderPen();
  1745. }
  1746. int Format::rightBorderWidth( int col, int row ) const
  1747. {
  1748. return rightBorderPen( col, row ).width();
  1749. }
  1750. Qt::PenStyle Format::rightBorderStyle( int col, int row ) const
  1751. {
  1752. return rightBorderPen( col, row ).style();
  1753. }
  1754. const TQColor& Format::rightBorderColor( int col, int row ) const
  1755. {
  1756. return rightBorderPen( col, row ).color();
  1757. }
  1758. const TQPen& Format::bottomBorderPen( int col, int row ) const
  1759. {
  1760. if ( !hasProperty( PBottomBorder, false )&& !hasNoFallBackProperties( PBottomBorder ) )
  1761. {
  1762. const Format * l = fallbackFormat( col, row );
  1763. if ( l )
  1764. return l->bottomBorderPen( col, row );
  1765. return sheet()->emptyPen();
  1766. }
  1767. return m_pStyle->bottomBorderPen();
  1768. }
  1769. int Format::bottomBorderWidth( int col, int row ) const
  1770. {
  1771. return bottomBorderPen( col, row ).width();
  1772. }
  1773. Qt::PenStyle Format::bottomBorderStyle( int col, int row ) const
  1774. {
  1775. return bottomBorderPen( col, row ).style();
  1776. }
  1777. const TQColor& Format::bottomBorderColor( int col, int row ) const
  1778. {
  1779. return bottomBorderPen( col, row ).color();
  1780. }
  1781. const TQBrush& Format::backGroundBrush( int col, int row ) const
  1782. {
  1783. if ( !hasProperty( PBackgroundBrush, false ) && !hasNoFallBackProperties(PBackgroundBrush ))
  1784. {
  1785. const Format* l = fallbackFormat( col, row );
  1786. if ( l )
  1787. return l->backGroundBrush( col, row );
  1788. }
  1789. return m_pStyle->backGroundBrush();
  1790. }
  1791. Qt::BrushStyle Format::backGroundBrushStyle( int col, int row ) const
  1792. {
  1793. return backGroundBrush( col, row ).style();
  1794. }
  1795. const TQColor& Format::backGroundBrushColor( int col, int row ) const
  1796. {
  1797. return backGroundBrush( col, row ).color();
  1798. }
  1799. int Format::precision( int col, int row ) const
  1800. {
  1801. if ( !hasProperty( PPrecision, false )&& !hasNoFallBackProperties( PPrecision ) )
  1802. {
  1803. const Format * l = fallbackFormat( col, row );
  1804. if ( l )
  1805. return l->precision( col, row );
  1806. }
  1807. return m_pStyle->precision();
  1808. }
  1809. Format::FloatFormat Format::floatFormat( int col, int row ) const
  1810. {
  1811. if ( !hasProperty( PFloatFormat, false ) && !hasNoFallBackProperties( PFloatFormat ) )
  1812. {
  1813. const Format * l = fallbackFormat( col, row );
  1814. if ( l )
  1815. return l->floatFormat( col, row );
  1816. }
  1817. return m_pStyle->floatFormat();
  1818. }
  1819. Format::FloatColor Format::floatColor( int col, int row ) const
  1820. {
  1821. if ( !hasProperty( PFloatColor, false ) && !hasNoFallBackProperties( PFloatColor ) )
  1822. {
  1823. const Format * l = fallbackFormat( col, row );
  1824. if ( l )
  1825. return l->floatColor( col, row );
  1826. }
  1827. return m_pStyle->floatColor();
  1828. }
  1829. const TQColor& Format::bgColor( int col, int row ) const
  1830. {
  1831. if ( !hasProperty( PBackgroundColor, false ) && !hasNoFallBackProperties( PBackgroundColor ) )
  1832. {
  1833. const Format * l = fallbackFormat( col, row );
  1834. if ( l )
  1835. return l->bgColor( col, row );
  1836. }
  1837. return m_pStyle->bgColor();
  1838. }
  1839. const TQPen& Format::textPen( int col, int row ) const
  1840. {
  1841. if ( !hasProperty( PTextPen, false ) && !hasNoFallBackProperties( PTextPen ) )
  1842. {
  1843. const Format * l = fallbackFormat( col, row );
  1844. if ( l )
  1845. return l->textPen( col, row );
  1846. }
  1847. return m_pStyle->pen();
  1848. }
  1849. const TQColor& Format::textColor( int col, int row ) const
  1850. {
  1851. return textPen( col, row ).color();
  1852. }
  1853. const TQFont Format::textFont( int col, int row ) const
  1854. {
  1855. if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
  1856. {
  1857. const Format * l = fallbackFormat( col, row );
  1858. if ( l )
  1859. return l->textFont( col, row );
  1860. }
  1861. return m_pStyle->font();
  1862. }
  1863. int Format::textFontSize( int col, int row ) const
  1864. {
  1865. if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
  1866. {
  1867. const Format * l = fallbackFormat( col, row );
  1868. if ( l )
  1869. return l->textFontSize( col, row );
  1870. }
  1871. return m_pStyle->fontSize();
  1872. }
  1873. TQString const & Format::textFontFamily( int col, int row ) const
  1874. {
  1875. if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
  1876. {
  1877. const Format * l = fallbackFormat( col, row );
  1878. if ( l )
  1879. return l->textFontFamily( col, row );
  1880. }
  1881. return m_pStyle->fontFamily();
  1882. }
  1883. bool Format::textFontBold( int col, int row ) const
  1884. {
  1885. if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
  1886. {
  1887. const Format * l = fallbackFormat( col, row );
  1888. if ( l )
  1889. return l->textFontBold( col, row );
  1890. }
  1891. return ( m_pStyle->fontFlags() & Style::FBold );
  1892. }
  1893. bool Format::textFontItalic( int col, int row ) const
  1894. {
  1895. if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
  1896. {
  1897. const Format * l = fallbackFormat( col, row );
  1898. if ( l )
  1899. return l->textFontItalic( col, row );
  1900. }
  1901. return ( m_pStyle->fontFlags() & Style::FItalic );
  1902. }
  1903. bool Format::textFontUnderline( int col, int row ) const
  1904. {
  1905. if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
  1906. {
  1907. const Format * l = fallbackFormat( col, row );
  1908. if ( l )
  1909. return l->textFontUnderline( col, row );
  1910. }
  1911. return ( m_pStyle->fontFlags() & Style::FUnderline );
  1912. }
  1913. bool Format::textFontStrike( int col, int row ) const
  1914. {
  1915. if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
  1916. {
  1917. const Format * l = fallbackFormat( col, row );
  1918. if ( l )
  1919. return l->textFontStrike( col, row );
  1920. }
  1921. return ( m_pStyle->fontFlags() & Style::FStrike );
  1922. }
  1923. Format::Align Format::align( int col, int row ) const
  1924. {
  1925. if ( !hasProperty( PAlign, false ) && !hasNoFallBackProperties( PAlign ) )
  1926. {
  1927. const Format * l = fallbackFormat( col, row );
  1928. if ( l )
  1929. return l->align( col, row );
  1930. }
  1931. return m_pStyle->alignX();
  1932. }
  1933. Format::AlignY Format::alignY( int col, int row ) const
  1934. {
  1935. if ( !hasProperty( PAlignY, false )&& !hasNoFallBackProperties( PAlignY ) )
  1936. {
  1937. const Format * l = fallbackFormat( col, row );
  1938. if ( l )
  1939. return l->alignY( col, row );
  1940. }
  1941. return m_pStyle->alignY();
  1942. }
  1943. bool Format::multiRow( int col, int row ) const
  1944. {
  1945. if ( !hasProperty( PMultiRow, false ) && !hasNoFallBackProperties( PMultiRow ) )
  1946. {
  1947. const Format * l = fallbackFormat( col, row );
  1948. if ( l )
  1949. return l->multiRow( col, row );
  1950. }
  1951. return m_pStyle->hasProperty( Style::PMultiRow );
  1952. }
  1953. bool Format::verticalText( int col, int row ) const
  1954. {
  1955. if ( !hasProperty( PVerticalText, false )&& !hasNoFallBackProperties( PVerticalText ) )
  1956. {
  1957. const Format * l = fallbackFormat( col, row );
  1958. if ( l )
  1959. return l->verticalText( col, row );
  1960. }
  1961. return m_pStyle->hasProperty( Style::PVerticalText );
  1962. }
  1963. FormatType Format::getFormatType( int col, int row ) const
  1964. {
  1965. if ( !hasProperty( PFormatType, false ) && !hasNoFallBackProperties( PFormatType ) )
  1966. {
  1967. const Format* l = fallbackFormat( col, row );
  1968. if ( l )
  1969. return l->getFormatType( col, row );
  1970. }
  1971. return m_pStyle->formatType();
  1972. }
  1973. int Format::getAngle( int col, int row ) const
  1974. {
  1975. if ( !hasProperty( PAngle, false ) && !hasNoFallBackProperties( PAngle ) )
  1976. {
  1977. const Format* l = fallbackFormat( col, row );
  1978. if ( l )
  1979. return l->getAngle( col, row );
  1980. }
  1981. return m_pStyle->rotateAngle();
  1982. }
  1983. TQString Format::comment( int col, int row ) const
  1984. {
  1985. if ( !hasProperty( PComment, false ) && !hasNoFallBackProperties( PComment ))
  1986. {
  1987. const Format* l = fallbackFormat( col, row );
  1988. if ( l )
  1989. return l->comment( col, row );
  1990. }
  1991. if ( !m_strComment )
  1992. return TQString();
  1993. // not part of the style
  1994. return *m_strComment;
  1995. }
  1996. TQString * Format::commentP( int col, int row ) const
  1997. {
  1998. if ( !hasProperty( PComment, false ) && !hasNoFallBackProperties( PComment ))
  1999. {
  2000. const Format* l = fallbackFormat( col, row );
  2001. if ( l )
  2002. return l->commentP( col, row );
  2003. }
  2004. return m_strComment;
  2005. }
  2006. double Format::getIndent( int col, int row ) const
  2007. {
  2008. if ( !hasProperty( PIndent, false ) && !hasNoFallBackProperties( PIndent ) )
  2009. {
  2010. const Format* l = fallbackFormat( col, row );
  2011. if ( l )
  2012. return l->getIndent( col, row );
  2013. }
  2014. return m_pStyle->indent();
  2015. }
  2016. bool Format::getDontprintText( int col, int row ) const
  2017. {
  2018. if ( !hasProperty( PDontPrintText, false )&& !hasNoFallBackProperties( PDontPrintText ) )
  2019. {
  2020. const Format* l = fallbackFormat( col, row );
  2021. if ( l )
  2022. return l->getDontprintText( col, row );
  2023. }
  2024. return m_pStyle->hasProperty( Style::PDontPrintText );
  2025. }
  2026. bool Format::isProtected( int col, int row ) const
  2027. {
  2028. return ( m_pSheet->isProtected() && !notProtected( col, row ) );
  2029. }
  2030. bool Format::notProtected( int col, int row) const
  2031. {
  2032. if ( !hasProperty( PNotProtected, false )&& !hasNoFallBackProperties( PNotProtected ) )
  2033. {
  2034. const Format * l = fallbackFormat( col, row );
  2035. if ( l )
  2036. return l->notProtected( col, row );
  2037. }
  2038. return m_pStyle->hasProperty( Style::PNotProtected );
  2039. }
  2040. bool Format::isHideAll( int col, int row) const
  2041. {
  2042. if ( !hasProperty( PHideAll, false )&& !hasNoFallBackProperties( PHideAll ) )
  2043. {
  2044. const Format * l = fallbackFormat( col, row );
  2045. if ( l )
  2046. return l->isHideAll( col, row );
  2047. }
  2048. return m_pStyle->hasProperty( Style::PHideAll );
  2049. }
  2050. bool Format::isHideFormula( int col, int row) const
  2051. {
  2052. if ( !hasProperty( PHideFormula, false )&& !hasNoFallBackProperties( PHideFormula ) )
  2053. {
  2054. const Format * l = fallbackFormat( col, row );
  2055. if ( l )
  2056. return l->isHideFormula( col, row );
  2057. }
  2058. return m_pStyle->hasProperty( Style::PHideFormula );
  2059. }
  2060. bool Format::currencyInfo( Currency & currency) const
  2061. {
  2062. // TODO: fallback ?
  2063. if ( m_pStyle->formatType() != Money_format )
  2064. return false;
  2065. currency.symbol = m_pStyle->currency().symbol;
  2066. currency.type = m_pStyle->currency().type;
  2067. return true;
  2068. }
  2069. TQString Format::getCurrencySymbol() const
  2070. {
  2071. // TODO: fallback ?
  2072. return m_pStyle->currency().symbol;
  2073. }
  2074. TQFont Format::font() const
  2075. {
  2076. return m_pStyle->font();
  2077. }
  2078. /////////////
  2079. //
  2080. // Get methods
  2081. //
  2082. /////////////
  2083. const TQPen & Format::leftBorderPen() const
  2084. {
  2085. return m_pStyle->leftBorderPen();
  2086. }
  2087. const TQPen & Format::topBorderPen() const
  2088. {
  2089. return m_pStyle->topBorderPen();
  2090. }
  2091. const TQPen & Format::rightBorderPen() const
  2092. {
  2093. return m_pStyle->rightBorderPen();
  2094. }
  2095. const TQPen & Format::bottomBorderPen() const
  2096. {
  2097. return m_pStyle->bottomBorderPen();
  2098. }
  2099. const TQPen & Format::fallDiagonalPen() const
  2100. {
  2101. return m_pStyle->fallDiagonalPen();
  2102. }
  2103. const TQPen & Format::goUpDiagonalPen() const
  2104. {
  2105. return m_pStyle->goUpDiagonalPen();
  2106. }
  2107. const TQBrush & Format::backGroundBrush() const
  2108. {
  2109. return m_pStyle->backGroundBrush();
  2110. }
  2111. const TQFont Format::textFont() const
  2112. {
  2113. return m_pStyle->font();
  2114. }
  2115. const TQPen & Format::textPen() const
  2116. {
  2117. return m_pStyle->pen();
  2118. }
  2119. /////////////
  2120. //
  2121. // Misc
  2122. //
  2123. /////////////
  2124. void Format::formatChanged()
  2125. {
  2126. if (m_pCell)
  2127. {
  2128. m_pCell->setFlag(Cell::Flag_LayoutDirty);
  2129. m_pCell->setFlag(Cell::Flag_TextFormatDirty);
  2130. }
  2131. }
  2132. Format* Format::fallbackFormat( int, int row )
  2133. {
  2134. return m_pCell ? m_pSheet->rowFormat( row ) : 0;
  2135. }
  2136. const Format* Format::fallbackFormat( int, int row ) const
  2137. {
  2138. return m_pCell ? m_pSheet->rowFormat( row ) : 0;
  2139. }
  2140. bool Format::isDefault() const
  2141. {
  2142. // NOTE Stefan: Don't compare sheet and cell.
  2143. // Because of the comment we have to check m_mask.
  2144. if ( ( m_mask & PComment ) && m_strComment != 0 )
  2145. return false;
  2146. #if 0 // These are copied in Style.
  2147. if ( m_mask ) // Properties
  2148. return false;
  2149. if ( m_flagsMask != 0 ) // FormatFlags
  2150. return false;
  2151. #endif
  2152. if ( m_bNoFallBack != 0 )
  2153. return false;
  2154. return ( *m_pStyle == *m_pSheet->doc()->styleManager()->defaultStyle() );
  2155. }
  2156. bool Format::operator==( const Format& other ) const
  2157. {
  2158. // NOTE Stefan: Don't compare sheet and cell.
  2159. // Because of the comment we have to check m_mask.
  2160. if ( ( m_mask & other.m_mask & PComment ) && m_strComment != other.m_strComment )
  2161. return false;
  2162. #if 0 // These are copied in Style.
  2163. if ( m_mask != other.m_mask ) // Properties
  2164. return false;
  2165. if ( m_flagsMask != other.m_flagsMask ) // FormatFlags
  2166. return false;
  2167. #endif
  2168. if ( m_bNoFallBack != other.m_bNoFallBack )
  2169. return false;
  2170. return ( *m_pStyle == *other.m_pStyle );
  2171. }
  2172. /*****************************************************************************
  2173. *
  2174. * RowFormat
  2175. *
  2176. *****************************************************************************/
  2177. //#define UPDATE_BEGIN bool b_update_begin = m_bDisplayDirtyFlag; m_bDisplayDirtyFlag = true;
  2178. //#define UPDATE_END if ( !b_update_begin && m_bDisplayDirtyFlag ) m_pSheet->emit_updateRow( this, m_iRow );
  2179. RowFormat::RowFormat( Sheet * _sheet, int _row )
  2180. : Format( _sheet, _sheet->doc()->styleManager()->defaultStyle() )
  2181. {
  2182. m_next = 0;
  2183. m_prev = 0;
  2184. m_bDisplayDirtyFlag = false;
  2185. m_fHeight = s_rowHeight;
  2186. m_iRow = _row;
  2187. m_bDefault = false;
  2188. m_bHide = false;
  2189. m_dcop = 0L;
  2190. }
  2191. RowFormat::~RowFormat()
  2192. {
  2193. if ( m_next )
  2194. m_next->setPrevious( m_prev );
  2195. if ( m_prev )
  2196. m_prev->setNext( m_next );
  2197. delete m_dcop;
  2198. }
  2199. DCOPObject * RowFormat::dcopObject()
  2200. {
  2201. if ( !m_dcop )
  2202. m_dcop = new RowIface( this );
  2203. return m_dcop;
  2204. }
  2205. void RowFormat::setMMHeight( double _h )
  2206. {
  2207. setDblHeight( MM_TO_POINT ( _h ) );
  2208. }
  2209. void RowFormat::setHeight( int _h, const Canvas * _canvas )
  2210. {
  2211. setDblHeight( (double) _h, _canvas );
  2212. }
  2213. void RowFormat::setDblHeight( double _h, const Canvas * _canvas )
  2214. {
  2215. Sheet *_sheet = _canvas ? _canvas->activeSheet() : m_pSheet;
  2216. // avoid unnecessary updates
  2217. if ( kAbs( _h - dblHeight( _canvas ) ) < DBL_EPSILON )
  2218. return;
  2219. // UPDATE_BEGIN;
  2220. // Lower maximum size by old height
  2221. _sheet->adjustSizeMaxY ( - dblHeight() );
  2222. if ( _canvas )
  2223. m_fHeight = ( _h / _canvas->zoom() );
  2224. else
  2225. m_fHeight = _h;
  2226. // Rise maximum size by new height
  2227. _sheet->adjustSizeMaxY ( dblHeight() );
  2228. _sheet->print()->updatePrintRepeatRowsHeight();
  2229. _sheet->print()->updateNewPageListY ( row() );
  2230. _sheet->emit_updateRow(this,m_iRow);
  2231. // UPDATE_END;
  2232. }
  2233. int RowFormat::height( const Canvas *_canvas ) const
  2234. {
  2235. return (int) dblHeight( _canvas );
  2236. }
  2237. double RowFormat::dblHeight( const Canvas *_canvas ) const
  2238. {
  2239. if( m_bHide )
  2240. return 0.0;
  2241. if ( _canvas )
  2242. return _canvas->zoom() * (m_iRow == 0) ? s_rowHeight : m_fHeight;
  2243. else
  2244. return (m_iRow == 0) ? s_rowHeight : m_fHeight;
  2245. }
  2246. double RowFormat::mmHeight() const
  2247. {
  2248. return POINT_TO_MM ( dblHeight() );
  2249. }
  2250. TQDomElement RowFormat::save( TQDomDocument& doc, int yshift, bool copy ) const
  2251. {
  2252. TQDomElement row = doc.createElement( "row" );
  2253. row.setAttribute( "height", m_fHeight );
  2254. row.setAttribute( "row", m_iRow - yshift );
  2255. if( m_bHide )
  2256. row.setAttribute( "hide", (int) m_bHide );
  2257. TQDomElement format( saveFormat( doc, false, copy ) );
  2258. row.appendChild( format );
  2259. return row;
  2260. }
  2261. #if 0
  2262. bool RowFormat::loadOasis( const TQDomElement& /*row*/, TQDomElement * /*rowStyle*/ )
  2263. {
  2264. return true;
  2265. }
  2266. #endif
  2267. bool RowFormat::load( const TQDomElement & row, int yshift, Paste::Mode sp, bool paste )
  2268. {
  2269. bool ok;
  2270. m_iRow = row.attribute( "row" ).toInt( &ok ) + yshift;
  2271. if ( !ok )
  2272. return false;
  2273. if ( row.hasAttribute( "height" ) )
  2274. {
  2275. if ( m_pSheet->doc()->syntaxVersion() < 1 ) //compatibility with old format - was in millimeter
  2276. m_fHeight = tqRound( MM_TO_POINT( row.attribute( "height" ).toDouble( &ok ) ) );
  2277. else
  2278. m_fHeight = row.attribute( "height" ).toDouble( &ok );
  2279. if ( !ok ) return false;
  2280. }
  2281. // Validation
  2282. if ( m_fHeight < 0 )
  2283. {
  2284. kdDebug(36001) << "Value height=" << m_fHeight << " out of range" << endl;
  2285. return false;
  2286. }
  2287. if ( m_iRow < 1 || m_iRow > KS_rowMax )
  2288. {
  2289. kdDebug(36001) << "Value row=" << m_iRow << " out of range" << endl;
  2290. return false;
  2291. }
  2292. if ( row.hasAttribute( "hide" ) )
  2293. {
  2294. setHide( (int) row.attribute( "hide" ).toInt( &ok ) );
  2295. if ( !ok )
  2296. return false;
  2297. }
  2298. TQDomElement f( row.namedItem( "format" ).toElement() );
  2299. if ( !f.isNull() && ( sp == Paste::Normal || sp == Paste::Format || sp == Paste::NoBorder ) )
  2300. {
  2301. if ( !loadFormat( f, sp, paste ) )
  2302. return false;
  2303. return true;
  2304. }
  2305. return true;
  2306. }
  2307. const TQPen & RowFormat::topBorderPen( int _col, int _row ) const
  2308. {
  2309. // First look at the row above us
  2310. if ( !hasProperty( PTopBorder, false ) )
  2311. {
  2312. const RowFormat * rl = sheet()->rowFormat( _row - 1 );
  2313. if ( rl->hasProperty( PBottomBorder ) )
  2314. return rl->bottomBorderPen( _col, _row - 1 );
  2315. }
  2316. return Format::topBorderPen( _col, _row );
  2317. }
  2318. void RowFormat::setTopBorderPen( const TQPen & p )
  2319. {
  2320. RowFormat * cl = sheet()->nonDefaultRowFormat( row() - 1, false );
  2321. if ( cl )
  2322. cl->clearProperty( PBottomBorder );
  2323. Format::setTopBorderPen( p );
  2324. }
  2325. const TQPen & RowFormat::bottomBorderPen( int _col, int _row ) const
  2326. {
  2327. // First look at the row below of us
  2328. if ( !hasProperty( PBottomBorder, false ) && ( _row < KS_rowMax ) )
  2329. {
  2330. const RowFormat * rl = sheet()->rowFormat( _row + 1 );
  2331. if ( rl->hasProperty( PTopBorder ) )
  2332. return rl->topBorderPen( _col, _row + 1 );
  2333. }
  2334. return Format::bottomBorderPen( _col, _row );
  2335. }
  2336. void RowFormat::setBottomBorderPen( const TQPen & p )
  2337. {
  2338. if ( row() < KS_rowMax )
  2339. {
  2340. RowFormat * cl = sheet()->nonDefaultRowFormat( row() + 1, false );
  2341. if ( cl )
  2342. cl->clearProperty( PTopBorder );
  2343. }
  2344. Format::setBottomBorderPen( p );
  2345. }
  2346. void RowFormat::setHide( bool _hide, bool repaint )
  2347. {
  2348. if ( _hide != m_bHide ) // only if we change the status
  2349. {
  2350. if ( _hide )
  2351. {
  2352. // Lower maximum size by height of row
  2353. m_pSheet->adjustSizeMaxY ( - dblHeight() );
  2354. m_bHide = _hide; //hide must be set after we requested the height
  2355. m_pSheet->emit_updateRow( this, m_iRow, repaint );
  2356. }
  2357. else
  2358. {
  2359. // Rise maximum size by height of row
  2360. m_bHide = _hide; //unhide must be set before we request the height
  2361. m_pSheet->adjustSizeMaxY ( dblHeight() );
  2362. m_pSheet->emit_updateRow( this, m_iRow, repaint );
  2363. }
  2364. }
  2365. }
  2366. Format* RowFormat::fallbackFormat( int col, int )
  2367. {
  2368. return sheet()->columnFormat( col );
  2369. }
  2370. const Format* RowFormat::fallbackFormat( int col, int ) const
  2371. {
  2372. return sheet()->columnFormat( col );
  2373. }
  2374. bool RowFormat::isDefault() const
  2375. {
  2376. if ( m_fHeight != s_rowHeight )
  2377. return false;
  2378. if ( m_bHide == true )
  2379. return false;
  2380. return Format::isDefault();
  2381. }
  2382. bool RowFormat::operator==( const RowFormat& other ) const
  2383. {
  2384. // NOTE Stefan: Don't compare sheet and cell.
  2385. if ( m_fHeight != other.m_fHeight )
  2386. return false;
  2387. if ( m_bHide != other.m_bHide )
  2388. return false;
  2389. return Format::operator==( other );
  2390. }
  2391. /*****************************************************************************
  2392. *
  2393. * ColumnFormat
  2394. *
  2395. *****************************************************************************/
  2396. #undef UPDATE_BEGIN
  2397. #undef UPDATE_END
  2398. #define UPDATE_BEGIN bool b_update_begin = m_bDisplayDirtyFlag; m_bDisplayDirtyFlag = true;
  2399. #define UPDATE_END if ( !b_update_begin && m_bDisplayDirtyFlag ) m_pSheet->emit_updateColumn( this, m_iColumn );
  2400. ColumnFormat::ColumnFormat( Sheet * _sheet, int _column )
  2401. : Format( _sheet, _sheet->doc()->styleManager()->defaultStyle() )
  2402. {
  2403. m_bDisplayDirtyFlag = false;
  2404. m_fWidth = s_columnWidth;
  2405. m_iColumn = _column;
  2406. m_bDefault=false;
  2407. m_bHide=false;
  2408. m_prev = 0;
  2409. m_next = 0;
  2410. m_dcop = 0;
  2411. }
  2412. ColumnFormat::~ColumnFormat()
  2413. {
  2414. if ( m_next )
  2415. m_next->setPrevious( m_prev );
  2416. if ( m_prev )
  2417. m_prev->setNext( m_next );
  2418. delete m_dcop;
  2419. }
  2420. DCOPObject * ColumnFormat::dcopObject()
  2421. {
  2422. if ( !m_dcop )
  2423. m_dcop = new ColumnIface( this );
  2424. return m_dcop;
  2425. }
  2426. void ColumnFormat::setMMWidth( double _w )
  2427. {
  2428. setDblWidth( MM_TO_POINT ( _w ) );
  2429. }
  2430. void ColumnFormat::setWidth( int _w, const Canvas * _canvas )
  2431. {
  2432. setDblWidth( (double)_w, _canvas );
  2433. }
  2434. void ColumnFormat::setDblWidth( double _w, const Canvas * _canvas )
  2435. {
  2436. Sheet *_sheet = _canvas ? _canvas->activeSheet() : m_pSheet;
  2437. // avoid unnecessary updates
  2438. if ( kAbs( _w - dblWidth( _canvas ) ) < DBL_EPSILON )
  2439. return;
  2440. // UPDATE_BEGIN;
  2441. // Lower maximum size by old width
  2442. _sheet->adjustSizeMaxX ( - dblWidth() );
  2443. if ( _canvas )
  2444. m_fWidth = ( _w / _canvas->zoom() );
  2445. else
  2446. m_fWidth = _w;
  2447. // Rise maximum size by new width
  2448. _sheet->adjustSizeMaxX ( dblWidth() );
  2449. _sheet->print()->updatePrintRepeatColumnsWidth();
  2450. _sheet->print()->updateNewPageListX ( column() );
  2451. _sheet->emit_updateColumn(this,m_iColumn);
  2452. // UPDATE_END;
  2453. }
  2454. int ColumnFormat::width( const Canvas * _canvas ) const
  2455. {
  2456. return (int) dblWidth( _canvas );
  2457. }
  2458. double ColumnFormat::dblWidth( const Canvas * _canvas ) const
  2459. {
  2460. if ( m_bHide )
  2461. return 0.0;
  2462. if ( _canvas )
  2463. return _canvas->zoom() * (m_iColumn == 0) ? s_columnWidth : m_fWidth;
  2464. else
  2465. return (m_iColumn == 0) ? s_columnWidth : m_fWidth;
  2466. }
  2467. double ColumnFormat::mmWidth() const
  2468. {
  2469. return POINT_TO_MM( dblWidth() );
  2470. }
  2471. TQDomElement ColumnFormat::save( TQDomDocument& doc, int xshift, bool copy ) const
  2472. {
  2473. TQDomElement col( doc.createElement( "column" ) );
  2474. col.setAttribute( "width", m_fWidth );
  2475. col.setAttribute( "column", m_iColumn - xshift );
  2476. if ( m_bHide )
  2477. col.setAttribute( "hide", (int) m_bHide );
  2478. TQDomElement format( saveFormat( doc, false, copy ) );
  2479. col.appendChild( format );
  2480. return col;
  2481. }
  2482. bool ColumnFormat::load( const TQDomElement & col, int xshift, Paste::Mode sp, bool paste )
  2483. {
  2484. bool ok;
  2485. if ( col.hasAttribute( "width" ) )
  2486. {
  2487. if ( m_pSheet->doc()->syntaxVersion() < 1 ) //combatibility to old format - was in millimeter
  2488. m_fWidth = tqRound( MM_TO_POINT ( col.attribute( "width" ).toDouble( &ok ) ) );
  2489. else
  2490. m_fWidth = col.attribute( "width" ).toDouble( &ok );
  2491. if ( !ok )
  2492. return false;
  2493. }
  2494. m_iColumn = col.attribute( "column" ).toInt( &ok ) + xshift;
  2495. if ( !ok )
  2496. return false;
  2497. // Validation
  2498. if ( m_fWidth < 0 )
  2499. {
  2500. kdDebug(36001) << "Value width=" << m_fWidth << " out of range" << endl;
  2501. return false;
  2502. }
  2503. if ( m_iColumn < 1 || m_iColumn > KS_colMax )
  2504. {
  2505. kdDebug(36001) << "Value col=" << m_iColumn << " out of range" << endl;
  2506. return false;
  2507. }
  2508. if ( col.hasAttribute( "hide" ) )
  2509. {
  2510. setHide( (int) col.attribute( "hide" ).toInt( &ok ) );
  2511. if ( !ok )
  2512. return false;
  2513. }
  2514. TQDomElement f( col.namedItem( "format" ).toElement() );
  2515. if ( !f.isNull() && ( sp == Paste::Normal || sp == Paste::Format || sp == Paste::NoBorder ))
  2516. {
  2517. if ( !loadFormat( f, sp, paste ) )
  2518. return false;
  2519. return true;
  2520. }
  2521. return true;
  2522. }
  2523. const TQPen & ColumnFormat::leftBorderPen( int _col, int _row ) const
  2524. {
  2525. // First look ar the right column at the right
  2526. if ( !hasProperty( PLeftBorder, false ) )
  2527. {
  2528. const ColumnFormat * cl = sheet()->columnFormat( _col - 1 );
  2529. if ( cl->hasProperty( PRightBorder ) )
  2530. return cl->rightBorderPen( _col - 1, _row );
  2531. }
  2532. return Format::leftBorderPen( _col, _row );
  2533. }
  2534. void ColumnFormat::setLeftBorderPen( const TQPen & p )
  2535. {
  2536. ColumnFormat * cl = sheet()->nonDefaultColumnFormat( column() - 1, false );
  2537. if ( cl )
  2538. cl->clearProperty( PRightBorder );
  2539. Format::setLeftBorderPen( p );
  2540. }
  2541. const TQPen & ColumnFormat::rightBorderPen( int _col, int _row ) const
  2542. {
  2543. // First look ar the right column at the right
  2544. if ( !hasProperty( PRightBorder, false ) && ( _col < KS_colMax ) )
  2545. {
  2546. const ColumnFormat * cl = sheet()->columnFormat( _col + 1 );
  2547. if ( cl->hasProperty( PLeftBorder ) )
  2548. return cl->leftBorderPen( _col + 1, _row );
  2549. }
  2550. return Format::rightBorderPen( _col, _row );
  2551. }
  2552. void ColumnFormat::setRightBorderPen( const TQPen & p )
  2553. {
  2554. if ( column() < KS_colMax )
  2555. {
  2556. ColumnFormat * cl = sheet()->nonDefaultColumnFormat( column() + 1, false );
  2557. if ( cl )
  2558. cl->clearProperty( PLeftBorder );
  2559. }
  2560. Format::setRightBorderPen( p );
  2561. }
  2562. Format * ColumnFormat::fallbackFormat( int, int )
  2563. {
  2564. return sheet()->defaultFormat();
  2565. }
  2566. void ColumnFormat::setHide( bool _hide )
  2567. {
  2568. if ( _hide != m_bHide ) // only if we change the status
  2569. {
  2570. if ( _hide )
  2571. {
  2572. // Lower maximum size by width of column
  2573. m_pSheet->adjustSizeMaxX ( - dblWidth() );
  2574. m_bHide = _hide; //hide must be set after we requested the width
  2575. // m_pSheet->emit_updateColumn( this, m_iColumn );
  2576. }
  2577. else
  2578. {
  2579. // Rise maximum size by width of column
  2580. m_bHide = _hide; //unhide must be set before we request the width
  2581. m_pSheet->adjustSizeMaxX ( dblWidth() );
  2582. // m_pSheet->emit_updateColumn( this, m_iColumn );
  2583. }
  2584. }
  2585. }
  2586. const Format * ColumnFormat::fallbackFormat( int, int ) const
  2587. {
  2588. return sheet()->defaultFormat();
  2589. }
  2590. bool ColumnFormat::isDefault() const
  2591. {
  2592. if ( m_fWidth != s_columnWidth )
  2593. return false;
  2594. if ( m_bHide == true )
  2595. return false;
  2596. return Format::isDefault();
  2597. }
  2598. bool ColumnFormat::operator==( const ColumnFormat& other ) const
  2599. {
  2600. // NOTE Stefan: Don't compare sheet and cell.
  2601. if ( m_fWidth != other.m_fWidth )
  2602. return false;
  2603. if ( m_bHide != other.m_bHide )
  2604. return false;
  2605. return Format::operator==( other );
  2606. }
  2607. namespace Currency_LNS
  2608. {
  2609. typedef struct
  2610. {
  2611. char const * code;
  2612. char const * country;
  2613. char const * name;
  2614. char const * display;
  2615. } Money;
  2616. // codes and names as defined in ISO 3166-1
  2617. // first column: saved code
  2618. // second column: country name (localized)
  2619. // third column: currency name (localized)
  2620. // fourth column: displayed currency code (localized but maybe only in
  2621. // the country language it belongs to)
  2622. // WARNING: change the "24" in getChooseString if you change this array
  2623. static const Money lMoney[] = {
  2624. { "", "", "", ""}, // auto
  2625. { "", "", "", ""}, // extension (codes imported)
  2626. { "$", "", "Dollar", "$" }, // unspecified
  2627. { "$", I18N_NOOP("Australia"), I18N_NOOP("Dollar"), "$" },
  2628. { "$", I18N_NOOP("Canada"), I18N_NOOP("Dollar"), "$" },
  2629. { "$", I18N_NOOP("Caribbea"), I18N_NOOP("Dollar"), "$" },
  2630. { "$", I18N_NOOP("New Zealand"), I18N_NOOP("Dollar"), "$" },
  2631. { "$", I18N_NOOP("United States"), I18N_NOOP("Dollar"), "$" },
  2632. // € == Euro sign in utf8
  2633. { "€", "", "€", "€" }, // unspecified
  2634. { "€", I18N_NOOP("Austria"), I18N_NOOP("Euro"), "€" },
  2635. { "€", I18N_NOOP("Belgium"), I18N_NOOP("Euro"), "€" },
  2636. { "€", I18N_NOOP("Finland"), I18N_NOOP("Euro"), "€" },
  2637. { "€", I18N_NOOP("France"), I18N_NOOP("Euro"), "€" },
  2638. { "€", I18N_NOOP("Germany"), I18N_NOOP("Euro"), "€" },
  2639. { "€", I18N_NOOP("Greece"), I18N_NOOP("Euro"), "€" },
  2640. { "€", I18N_NOOP("Ireland"), I18N_NOOP("Euro"), "€" },
  2641. { "€", I18N_NOOP("Italy"), I18N_NOOP("Euro"), "€" },
  2642. { "€", I18N_NOOP("Luxembourg"), I18N_NOOP("Euro"), "€" },
  2643. { "€", I18N_NOOP("Monaco"), I18N_NOOP("Euro"), "€" },
  2644. { "€", I18N_NOOP("Netherlands"), I18N_NOOP("Euro"), "€" },
  2645. { "€", I18N_NOOP("Portugal"), I18N_NOOP("Euro"), "€" },
  2646. { "€", I18N_NOOP("Spain"), I18N_NOOP("Euro"), "€" },
  2647. { "£", I18N_NOOP("United Kingdom"), I18N_NOOP("Pound"), "£" },
  2648. { "¥", I18N_NOOP("Japan"), I18N_NOOP("Yen"), "¥" },
  2649. { "AFA", I18N_NOOP("Afghanistan"), I18N_NOOP("Afghani"), I18N_NOOP("AFA") },
  2650. { "ALL", I18N_NOOP("Albania"), I18N_NOOP("Lek"), I18N_NOOP("Lek") },
  2651. { "DZD", I18N_NOOP("Algeria"), I18N_NOOP("Algerian Dinar"), I18N_NOOP("DZD") },
  2652. { "USD", I18N_NOOP("American Samoa"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2653. { "EUR", I18N_NOOP("Andorra"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2654. { "ADP", I18N_NOOP("Andorra"), I18N_NOOP("Andorran Peseta"), I18N_NOOP("ADP") },
  2655. { "AOA", I18N_NOOP("Angola"), I18N_NOOP("Kwanza"), I18N_NOOP("AOA") },
  2656. { "XCD", I18N_NOOP("Anguilla"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("XCD") },
  2657. { "XCD", I18N_NOOP("Antigua And Barbuda"), I18N_NOOP("East Carribean Dollar"), I18N_NOOP("XCD") },
  2658. { "ARS", I18N_NOOP("Argentina"), I18N_NOOP("Argentine Peso"), I18N_NOOP("ARS") },
  2659. { "AMD", I18N_NOOP("Armenia"), I18N_NOOP("Armenian Dram"), I18N_NOOP("AMD") },
  2660. { "AWG", I18N_NOOP("Aruba"), I18N_NOOP("Aruban Guilder"), I18N_NOOP("AWG") },
  2661. { "AUD", I18N_NOOP("Australia"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
  2662. { "EUR", I18N_NOOP("Austria"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2663. { "ATS", I18N_NOOP("Austria"), I18N_NOOP("Schilling"), I18N_NOOP("S") },
  2664. { "AZM", I18N_NOOP("Azerbaijan"), I18N_NOOP("Azerbaijanian Manat"), I18N_NOOP("AZM") },
  2665. { "BSD", I18N_NOOP("Bahamas"), I18N_NOOP("Bahamian Dollar"), I18N_NOOP("BSD") },
  2666. { "BHD", I18N_NOOP("Bahrain"), I18N_NOOP("Bahraini Dinar"), I18N_NOOP("BHD") },
  2667. { "BDT", I18N_NOOP("Bangladesh"), I18N_NOOP("Taka"), I18N_NOOP("BDT") },
  2668. { "BBD", I18N_NOOP("Barbados"), I18N_NOOP("Barbados Dollar"), I18N_NOOP("BBD") },
  2669. { "BYR", I18N_NOOP("Belarus"), I18N_NOOP("Belarussian Ruble"), I18N_NOOP("p.") },
  2670. { "EUR", I18N_NOOP("Belgium"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2671. { "BEF", I18N_NOOP("Belgium"), I18N_NOOP("Franc"), I18N_NOOP("BF") },
  2672. { "BZD", I18N_NOOP("Belize"), I18N_NOOP("Belize Dollar"), I18N_NOOP("BZ$") },
  2673. { "XOF", I18N_NOOP("Benin"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
  2674. { "BMD", I18N_NOOP("Bermuda"), I18N_NOOP("Bermudian Dollar"), I18N_NOOP("BMD") },
  2675. { "INR", I18N_NOOP("Bhutan"), I18N_NOOP("Indian Rupee"), I18N_NOOP("INR") },
  2676. { "BTN", I18N_NOOP("Bhutan"), I18N_NOOP("Ngultrum"), I18N_NOOP("BTN") },
  2677. { "BOB", I18N_NOOP("Bolivia"), I18N_NOOP("Boliviano"), I18N_NOOP("Bs") },
  2678. { "BOV", I18N_NOOP("Bolivia"), I18N_NOOP("Mvdol"), I18N_NOOP("BOV") },
  2679. { "BAM", I18N_NOOP("Bosnia And Herzegovina"), I18N_NOOP("Convertible Marks"), I18N_NOOP("BAM") },
  2680. { "BWP", I18N_NOOP("Botswana"), I18N_NOOP("Pula"), I18N_NOOP("BWP") },
  2681. { "NOK", I18N_NOOP("Bouvet Island"), I18N_NOOP("Norvegian Krone"), I18N_NOOP("NOK") },
  2682. { "BRL", I18N_NOOP("Brazil"), I18N_NOOP("Brazilian Real"), I18N_NOOP("R$") },
  2683. { "USD", I18N_NOOP("British Indian Ocean Territory"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2684. { "BND", I18N_NOOP("Brunei Darussalam"), I18N_NOOP("Brunei Dollar"), I18N_NOOP("BND") },
  2685. { "BGL", I18N_NOOP("Bulgaria"), I18N_NOOP("Lev"), I18N_NOOP("BGL") },
  2686. { "BGN", I18N_NOOP("Bulgaria"), I18N_NOOP("Bulgarian Lev"), I18N_NOOP("BGN") },
  2687. { "XOF", I18N_NOOP("Burkina Faso"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
  2688. { "BIF", I18N_NOOP("Burundi"), I18N_NOOP("Burundi Franc"), I18N_NOOP("BIF") },
  2689. { "KHR", I18N_NOOP("Cambodia"), I18N_NOOP("Riel"), I18N_NOOP("KHR") },
  2690. { "XAF", I18N_NOOP("Cameroon"), I18N_NOOP("CFA Franc BEAC"), I18N_NOOP("XAF") },
  2691. { "CAD", I18N_NOOP("Canada"), I18N_NOOP("Canadian Dollar"), I18N_NOOP("CAD") },
  2692. { "CVE", I18N_NOOP("Cape Verde"), I18N_NOOP("Cape Verde Escudo"), I18N_NOOP("CVE") },
  2693. { "KYD", I18N_NOOP("Cayman Islands"), I18N_NOOP("Cayman Islands Dollar"), I18N_NOOP("KYD") },
  2694. { "XAF", I18N_NOOP("Central African Republic"), I18N_NOOP("CFA Franc BEAC"), I18N_NOOP("XAF") },
  2695. { "XAF", I18N_NOOP("Chad"), I18N_NOOP("CFA Franc BEAC"), I18N_NOOP("XAF") },
  2696. { "CLP", I18N_NOOP("Chile"), I18N_NOOP("Chilean Peso"), I18N_NOOP("Ch$") },
  2697. { "CLF", I18N_NOOP("Chile"), I18N_NOOP("Unidades de fomento"), I18N_NOOP("CLF") },
  2698. { "CNY", I18N_NOOP("China"), I18N_NOOP("Yuan Renminbi"), I18N_NOOP("CNY") },
  2699. { "AUD", I18N_NOOP("Christmas Island"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
  2700. { "AUD", I18N_NOOP("Cocos (Keeling) Islands"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
  2701. { "COP", I18N_NOOP("Colombia"), I18N_NOOP("Colombian Peso"), I18N_NOOP("C$") },
  2702. { "KMF", I18N_NOOP("Comoros"), I18N_NOOP("Comoro Franc"), I18N_NOOP("KMF") },
  2703. { "XAF", I18N_NOOP("Congo"), I18N_NOOP("CFA Franc BEAC"), I18N_NOOP("XAF") },
  2704. { "CDF", I18N_NOOP("Congo, The Democratic Republic Of"), I18N_NOOP("Franc Congolais"), I18N_NOOP("CDF") },
  2705. { "NZD", I18N_NOOP("Cook Islands"), I18N_NOOP("New Zealand Dollar"), I18N_NOOP("NZD") },
  2706. { "CRC", I18N_NOOP("Costa Rica"), I18N_NOOP("Costa Rican Colon"), I18N_NOOP("C") },
  2707. { "XOF", I18N_NOOP("Cote D'Ivoire"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
  2708. { "HRK", I18N_NOOP("Croatia"), I18N_NOOP("Croatian kuna"), I18N_NOOP("kn") },
  2709. { "CUP", I18N_NOOP("Cuba"), I18N_NOOP("Cuban Peso"), I18N_NOOP("CUP") },
  2710. { "CYP", I18N_NOOP("Cyprus"), I18N_NOOP("Cyprus Pound"), I18N_NOOP("CYP") },
  2711. { "CZK", I18N_NOOP("Czech Republic"), I18N_NOOP("Czech Koruna"), I18N_NOOP("Kc") },
  2712. { "DKK", I18N_NOOP("Denmark"), I18N_NOOP("Danish Krone"), I18N_NOOP("kr") },
  2713. { "DJF", I18N_NOOP("Djibouti"), I18N_NOOP("Djibouti Franc"), I18N_NOOP("DJF") },
  2714. { "XCD", I18N_NOOP("Dominica"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("RD$") },
  2715. { "DOP", I18N_NOOP("Dominican Republic"), I18N_NOOP("Dominican Peso"), I18N_NOOP("DOP") },
  2716. { "TPE", I18N_NOOP("East Timor"), I18N_NOOP("Timor Escudo"), I18N_NOOP("TPE") },
  2717. { "USD", I18N_NOOP("East Timor"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2718. { "USD", I18N_NOOP("Ecuador"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2719. { "EGP", I18N_NOOP("Egypt"), I18N_NOOP("Egyptian Pound"), I18N_NOOP("EGP") },
  2720. { "SVC", I18N_NOOP("El Salvador"), I18N_NOOP("El Salvador Colon"), I18N_NOOP("C") },
  2721. { "USD", I18N_NOOP("El Salvador"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2722. { "XAF", I18N_NOOP("Equatorial Guinea"), I18N_NOOP("CFA Franc BEAC"), I18N_NOOP("XAF") },
  2723. { "ERN", I18N_NOOP("Eritrea"), I18N_NOOP("Nakfa"), I18N_NOOP("ERN") },
  2724. { "EEK", I18N_NOOP("Estonia"), I18N_NOOP("Kroon"), I18N_NOOP("kr") },
  2725. { "ETB", I18N_NOOP("Ethiopia"), I18N_NOOP("Ethiopian Birr"), I18N_NOOP("ETB") },
  2726. { "FKP", I18N_NOOP("Falkland Island (Malvinas)"), I18N_NOOP("Falkland Islands Pound"), I18N_NOOP("FKP") },
  2727. { "DKK", I18N_NOOP("Faeroe Islands"), I18N_NOOP("Danish Krone"), I18N_NOOP("kr") },
  2728. { "FJD", I18N_NOOP("Fiji"), I18N_NOOP("Fiji Dollar"), I18N_NOOP("FJD") },
  2729. { "EUR", I18N_NOOP("Finland"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2730. { "FIM", I18N_NOOP("Finland"), I18N_NOOP("Markka"), I18N_NOOP("mk") },
  2731. { "EUR", I18N_NOOP("France"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2732. { "FRF", I18N_NOOP("France"), I18N_NOOP("Franc"), I18N_NOOP("F") },
  2733. { "EUR", I18N_NOOP("French Guiana"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2734. { "XPF", I18N_NOOP("French Polynesia"), I18N_NOOP("CFP Franc"), I18N_NOOP("XPF") },
  2735. { "EUR", I18N_NOOP("Franc Southern Territories"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2736. { "XAF", I18N_NOOP("Gabon"), I18N_NOOP("CFA Franc BEAC"), I18N_NOOP("XAF") },
  2737. { "GMD", I18N_NOOP("Gambia"), I18N_NOOP("Dalasi"), I18N_NOOP("GMD") },
  2738. { "GEL", I18N_NOOP("Georgia"), I18N_NOOP("Lari"), I18N_NOOP("GEL") },
  2739. { "EUR", I18N_NOOP("Germany"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2740. { "DEM", I18N_NOOP("Germany"), I18N_NOOP("German Mark"), I18N_NOOP("DM") },
  2741. { "GHC", I18N_NOOP("Ghana"), I18N_NOOP("Cedi"), I18N_NOOP("GHC") },
  2742. { "GIP", I18N_NOOP("Gibraltar"), I18N_NOOP("Gibraltar Pound"), I18N_NOOP("GIP") },
  2743. { "EUR", I18N_NOOP("Greece"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2744. { "GRD", I18N_NOOP("Greece"), I18N_NOOP("Drachma"), I18N_NOOP("GRD") },
  2745. { "DKK", I18N_NOOP("Greenland"), I18N_NOOP("Danish Krone"), I18N_NOOP("DKK") },
  2746. { "XCD", I18N_NOOP("Grenada"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("XCD") },
  2747. { "EUR", I18N_NOOP("Guadeloupe"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2748. { "USD", I18N_NOOP("Guam"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2749. { "GTQ", I18N_NOOP("Guatemala"), I18N_NOOP("Quetzal"), I18N_NOOP("Q") },
  2750. { "GNF", I18N_NOOP("Guinea"), I18N_NOOP("Guinea Franc"), I18N_NOOP("GNF") },
  2751. { "GWP", I18N_NOOP("Guinea-Bissau"), I18N_NOOP("Guinea-Bissau Peso"), I18N_NOOP("GWP") },
  2752. { "XOF", I18N_NOOP("Guinea-Bissau"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
  2753. { "GYD", I18N_NOOP("Guyana"), I18N_NOOP("Guyana Dollar"), I18N_NOOP("GYD") },
  2754. { "HTG", I18N_NOOP("Haiti"), I18N_NOOP("Gourde"), I18N_NOOP("HTG") },
  2755. { "USD", I18N_NOOP("Haiti"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2756. { "AUD", I18N_NOOP("Heard Island And McDonald Islands"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
  2757. { "EUR", I18N_NOOP("Holy See (Vatican City State)"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2758. { "HNL", I18N_NOOP("Honduras"), I18N_NOOP("Lempira"), I18N_NOOP("L") },
  2759. { "HKD", I18N_NOOP("Hong Kong"), I18N_NOOP("Hong Kong Dollar"), I18N_NOOP("HKD") },
  2760. { "HUF", I18N_NOOP("Hungary"), I18N_NOOP("Forint"), I18N_NOOP("Ft") },
  2761. { "ISK", I18N_NOOP("Iceland"), I18N_NOOP("Iceland Krona"), I18N_NOOP("kr.") },
  2762. { "INR", I18N_NOOP("India"), I18N_NOOP("Indian Rupee"), I18N_NOOP("INR") },
  2763. { "IDR", I18N_NOOP("Indonesia"), I18N_NOOP("Rupiah"), I18N_NOOP("Rp") },
  2764. { "IRR", I18N_NOOP("Iran, Islamic Republic Of"), I18N_NOOP("Iranian Rial"), I18N_NOOP("IRR") },
  2765. { "IQD", I18N_NOOP("Iraq"), I18N_NOOP("Iraqi Dinar"), I18N_NOOP("IQD") },
  2766. { "EUR", I18N_NOOP("Ireland"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2767. { "IEP", I18N_NOOP("Ireland"), I18N_NOOP("Punt"), I18N_NOOP("IR----") },
  2768. { "IEX", I18N_NOOP("Ireland"), I18N_NOOP("Pence"), I18N_NOOP("IEX") },
  2769. { "ILS", I18N_NOOP("Israel"), I18N_NOOP("New Israeli Sheqel"), I18N_NOOP("ILS") },
  2770. { "EUR", I18N_NOOP("Italy"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2771. { "ITL", I18N_NOOP("Italy"), I18N_NOOP("Lira"), I18N_NOOP("L.") },
  2772. { "JMD", I18N_NOOP("Jamaica"), I18N_NOOP("Jamaican Dollar"), I18N_NOOP("J$") },
  2773. { "JPY", I18N_NOOP("Japan"), I18N_NOOP("Yen"), I18N_NOOP("JPY") },
  2774. { "JOD", I18N_NOOP("Jordan"), I18N_NOOP("Jordanian Dinar"), I18N_NOOP("JOD") },
  2775. { "KZT", I18N_NOOP("Kazakhstan"), I18N_NOOP("Tenge"), I18N_NOOP("KZT") },
  2776. { "KES", I18N_NOOP("Kenya"), I18N_NOOP("Kenyan Shilling"), I18N_NOOP("KES") },
  2777. { "AUD", I18N_NOOP("Kiribati"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
  2778. { "KPW", I18N_NOOP("Korea, Democratic People's Republic Of"), I18N_NOOP("North Korean Won"), I18N_NOOP("KPW") },
  2779. { "KRW", I18N_NOOP("Korea, Republic Of"), I18N_NOOP("Won"), I18N_NOOP("KRW") },
  2780. { "KWD", I18N_NOOP("Kuwait"), I18N_NOOP("Kuwaiti Dinar"), I18N_NOOP("KWD") },
  2781. { "KGS", I18N_NOOP("Kyrgyzstan"), I18N_NOOP("Som"), I18N_NOOP("KGS") },
  2782. { "LAK", I18N_NOOP("Lao People's Democratic Republic"), I18N_NOOP("Kip"), I18N_NOOP("LAK") },
  2783. { "LVL", I18N_NOOP("Latvia"), I18N_NOOP("Latvian Lats"), I18N_NOOP("Ls") },
  2784. { "LBP", I18N_NOOP("Lebanon"), I18N_NOOP("Lebanese Pound"), I18N_NOOP("LBP") },
  2785. { "ZAR", I18N_NOOP("Lesotho"), I18N_NOOP("Rand"), I18N_NOOP("ZAR") },
  2786. { "LSL", I18N_NOOP("Lesotho"), I18N_NOOP("Loti"), I18N_NOOP("LSL") },
  2787. { "LRD", I18N_NOOP("Liberia"), I18N_NOOP("Liberian Dollar"), I18N_NOOP("LRD") },
  2788. { "LYD", I18N_NOOP("Libyan Arab Jamahiriya"), I18N_NOOP("Lybian Dinar"), I18N_NOOP("LYD") },
  2789. { "CHF", I18N_NOOP("Liechtenstein"), I18N_NOOP("Swiss Franc"), I18N_NOOP("CHF") },
  2790. { "LTL", I18N_NOOP("Lithuania"), I18N_NOOP("Lithuanian Litus"), I18N_NOOP("Lt") },
  2791. { "EUR", I18N_NOOP("Luxembourg"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2792. { "LUF", I18N_NOOP("Luxembourg"), I18N_NOOP("Franc"), I18N_NOOP("F") },
  2793. { "MOP", I18N_NOOP("Macao"), I18N_NOOP("Pataca"), I18N_NOOP("MOP") },
  2794. { "MKD", I18N_NOOP("Macedonia, The Former Yugoslav Republic Of"), I18N_NOOP("Denar"), I18N_NOOP("MKD") },
  2795. { "MGF", I18N_NOOP("Madagascar"), I18N_NOOP("Malagasy Franc"), I18N_NOOP("MGF") },
  2796. { "MWK", I18N_NOOP("Malawi"), I18N_NOOP("Kwacha"), I18N_NOOP("MWK") },
  2797. { "MYR", I18N_NOOP("Malaysia"), I18N_NOOP("Malaysian Ringgit"), I18N_NOOP("MYR") },
  2798. { "MVR", I18N_NOOP("Maldives"), I18N_NOOP("Rufiyaa"), I18N_NOOP("MVR") },
  2799. { "XOF", I18N_NOOP("Mali"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
  2800. { "MTL", I18N_NOOP("Malta"), I18N_NOOP("Maltese Lira"), I18N_NOOP("MTL") },
  2801. { "USD", I18N_NOOP("Marshall Islands"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2802. { "EUR", I18N_NOOP("Martinique"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2803. { "MRO", I18N_NOOP("Mauritania"), I18N_NOOP("Ouguiya"), I18N_NOOP("MRO") },
  2804. { "MUR", I18N_NOOP("Mauritius"), I18N_NOOP("Mauritius Rupee"), I18N_NOOP("MUR") },
  2805. { "EUR", I18N_NOOP("Mayotte"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2806. { "MXN", I18N_NOOP("Mexico"), I18N_NOOP("Mexican Peso"), I18N_NOOP("MXN") },
  2807. { "MXV", I18N_NOOP("Mexico"), I18N_NOOP("Mexican Unidad de Inversion (UDI)"), I18N_NOOP("MXV") },
  2808. { "USD", I18N_NOOP("Micronesia, Federated States Of"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2809. { "MDL", I18N_NOOP("Moldova, Republic Of"), I18N_NOOP("Moldovan Leu"), I18N_NOOP("MDL") },
  2810. { "EUR", I18N_NOOP("Monaco"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2811. { "MNT", I18N_NOOP("Mongolia"), I18N_NOOP("Tugrik"), I18N_NOOP("MNT") },
  2812. { "XCD", I18N_NOOP("Montserrat"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("XCD") },
  2813. { "MAD", I18N_NOOP("Morocco"), I18N_NOOP("Moroccan Dirham"), I18N_NOOP("MAD") },
  2814. { "MZM", I18N_NOOP("Mozambique"), I18N_NOOP("Metical"), I18N_NOOP("MZM") },
  2815. { "MMK", I18N_NOOP("Myanmar"), I18N_NOOP("Kyat"), I18N_NOOP("MMK") },
  2816. { "ZAR", I18N_NOOP("Namibia"), I18N_NOOP("Rand"), I18N_NOOP("ZAR") },
  2817. { "NAD", I18N_NOOP("Namibia"), I18N_NOOP("Namibia Dollar"), I18N_NOOP("NAD") },
  2818. { "AUD", I18N_NOOP("Nauru"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
  2819. { "NPR", I18N_NOOP("Nepal"), I18N_NOOP("Nepalese Rupee"), I18N_NOOP("NPR") },
  2820. { "EUR", I18N_NOOP("Netherlands"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2821. { "NLG", I18N_NOOP("Netherlands"), I18N_NOOP("Guilder"), I18N_NOOP("fl") },
  2822. { "ANG", I18N_NOOP("Netherlands Antilles"), I18N_NOOP("Netherlands Antillan Guilder"), I18N_NOOP("ANG") },
  2823. { "XPF", I18N_NOOP("New Caledonia"), I18N_NOOP("CFP Franc"), I18N_NOOP("XPF") },
  2824. { "NZD", I18N_NOOP("New Zealand"), I18N_NOOP("New Zealand Dollar"), I18N_NOOP("NZD") },
  2825. { "NIO", I18N_NOOP("Nicaragua"), I18N_NOOP("Cordoba Oro"), I18N_NOOP("NIO") },
  2826. { "XOF", I18N_NOOP("Niger"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
  2827. { "NGN", I18N_NOOP("Nigeria"), I18N_NOOP("Naira"), I18N_NOOP("NGN") },
  2828. { "NZD", I18N_NOOP("Niue"), I18N_NOOP("New Zealand Dollar"), I18N_NOOP("NZD") },
  2829. { "AUD", I18N_NOOP("Norfolk Islands"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
  2830. { "USD", I18N_NOOP("Northern Mariana Islands"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2831. { "NOK", I18N_NOOP("Norway"), I18N_NOOP("Norwegian Krone"), I18N_NOOP("kr") },
  2832. { "OMR", I18N_NOOP("Oman"), I18N_NOOP("Rial Omani"), I18N_NOOP("OMR") },
  2833. { "PKR", I18N_NOOP("Pakistan"), I18N_NOOP("Pakistan Rupee"), I18N_NOOP("PKR") },
  2834. { "USD", I18N_NOOP("Palau"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2835. { "PAB", I18N_NOOP("Panama"), I18N_NOOP("Balboa"), I18N_NOOP("PAB") },
  2836. { "USD", I18N_NOOP("Panama"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2837. { "PGK", I18N_NOOP("Papua New Guinea"), I18N_NOOP("Kina"), I18N_NOOP("PGK") },
  2838. { "PYG", I18N_NOOP("Paraguay"), I18N_NOOP("Guarani"), I18N_NOOP("G") },
  2839. { "PEN", I18N_NOOP("Peru"), I18N_NOOP("Nuevo Sol"), I18N_NOOP("PEN") },
  2840. { "PHP", I18N_NOOP("Philippines"), I18N_NOOP("Philippine Peso"), I18N_NOOP("PHP") },
  2841. { "NZD", I18N_NOOP("Pitcairn"), I18N_NOOP("New Zealand Dollar"), I18N_NOOP("NZD") },
  2842. { "PLN", I18N_NOOP("Poland"), I18N_NOOP("Zloty"), I18N_NOOP("zt") },
  2843. { "EUR", I18N_NOOP("Portugal"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2844. { "PTE", I18N_NOOP("Portugal"), I18N_NOOP("Escudo"), I18N_NOOP("Esc.") },
  2845. { "USD", I18N_NOOP("Puerto Rico"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2846. { "QAR", I18N_NOOP("Qatar"), I18N_NOOP("Qatari Rial"), I18N_NOOP("QAR") },
  2847. { "ROL", I18N_NOOP("Romania"), I18N_NOOP("Leu"), I18N_NOOP("LEI") },
  2848. { "RUR", I18N_NOOP("Russian Federation"), I18N_NOOP("Russian Ruble"), I18N_NOOP("RUR") },
  2849. { "RUB", I18N_NOOP("Russian Federation"), I18N_NOOP("Russian Ruble"), I18N_NOOP("RUB") },
  2850. { "RWF", I18N_NOOP("Rwanda"), I18N_NOOP("Rwanda Franc"), I18N_NOOP("RWF") },
  2851. { "SHP", I18N_NOOP("Saint Helena"), I18N_NOOP("Saint Helena Pound"), I18N_NOOP("SHP") },
  2852. { "XCD", I18N_NOOP("Saint Kitts And Nevis"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("XCD") },
  2853. { "XCD", I18N_NOOP("Saint Lucia"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("XCD") },
  2854. { "EUR", I18N_NOOP("Saint Pierre And Miquelon"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2855. { "XCD", I18N_NOOP("Saint Vincent And The Grenadines"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("XCD") },
  2856. { "WST", I18N_NOOP("Samoa"), I18N_NOOP("Tala"), I18N_NOOP("WST") },
  2857. { "EUR", I18N_NOOP("San Marino"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2858. { "STD", I18N_NOOP("Sao Tome And Principe"), I18N_NOOP("Dobra"), I18N_NOOP("STD") },
  2859. { "SAR", I18N_NOOP("Saudi Arabia"), I18N_NOOP("Saudi Riyal"), I18N_NOOP("SAR") },
  2860. { "XOF", I18N_NOOP("Senegal"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
  2861. { "SCR", I18N_NOOP("Seychelles"), I18N_NOOP("Seychelles Rupee"), I18N_NOOP("SCR") },
  2862. { "SLL", I18N_NOOP("Sierra Leone"), I18N_NOOP("Leone"), I18N_NOOP("SLL") },
  2863. { "SGD", I18N_NOOP("Singapore"), I18N_NOOP("Singapore Dollar"), I18N_NOOP("SGD") },
  2864. { "SKK", I18N_NOOP("Slovakia"), I18N_NOOP("Slovak Koruna"), I18N_NOOP("Sk") },
  2865. { "EUR", I18N_NOOP("Slovenia"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2866. { "SBD", I18N_NOOP("Solomon Islands"), I18N_NOOP("Solomon Islands Dollar"), I18N_NOOP("SBD") },
  2867. { "SOS", I18N_NOOP("Somalia"), I18N_NOOP("Somali Shilling"), I18N_NOOP("SOS") },
  2868. { "ZAR", I18N_NOOP("South Africa"), I18N_NOOP("Rand"), I18N_NOOP("R") },
  2869. { "EUR", I18N_NOOP("Spain"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
  2870. { "ESP", I18N_NOOP("Spain"), I18N_NOOP("Peseta"), I18N_NOOP("Pts") },
  2871. { "LKR", I18N_NOOP("Sri Lanka"), I18N_NOOP("Sri Lanka Rupee"), I18N_NOOP("LKR") },
  2872. { "SDD", I18N_NOOP("Sudan"), I18N_NOOP("Sudanese Dinar"), I18N_NOOP("SDD") },
  2873. { "SRG", I18N_NOOP("Suriname"), I18N_NOOP("Suriname Guilder"), I18N_NOOP("SRG") },
  2874. { "NOK", I18N_NOOP("Svalbard And Jan Mayen"), I18N_NOOP("Norwegian Krone"), I18N_NOOP("NOK") },
  2875. { "SZL", I18N_NOOP("Swaziland"), I18N_NOOP("Lilangeni"), I18N_NOOP("SZL") },
  2876. { "SEK", I18N_NOOP("Sweden"), I18N_NOOP("Swedish Krona"), I18N_NOOP("kr") },
  2877. { "CHF", I18N_NOOP("Switzerland"), I18N_NOOP("Swiss Franc"), I18N_NOOP("SFr.") },
  2878. { "SYP", I18N_NOOP("Syrian Arab Republic"), I18N_NOOP("Syrian Pound"), I18N_NOOP("SYP") },
  2879. { "TWD", I18N_NOOP("Taiwan, Province Of China"), I18N_NOOP("New Taiwan Dollar"), I18N_NOOP("TWD") },
  2880. { "TJS", I18N_NOOP("Tajikistan"), I18N_NOOP("Somoni"), I18N_NOOP("TJS") },
  2881. { "TZS", I18N_NOOP("Tanzania, United Republic Of"), I18N_NOOP("Tanzanian Shilling"), I18N_NOOP("TZS") },
  2882. { "THB", I18N_NOOP("Thailand"), I18N_NOOP("Baht"), I18N_NOOP("THB") },
  2883. { "XOF", I18N_NOOP("Togo"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
  2884. { "NZD", I18N_NOOP("Tokelau"), I18N_NOOP("New Zealand Dollar"), I18N_NOOP("NZD") },
  2885. { "TOP", I18N_NOOP("Tonga"), I18N_NOOP("Pa'anga"), I18N_NOOP("TOP") },
  2886. { "TTD", I18N_NOOP("Trinidad And Tobago"), I18N_NOOP("Trinidad and Tobago Dollar"), I18N_NOOP("TT$") },
  2887. { "TND", I18N_NOOP("Tunisia"), I18N_NOOP("Tunisian Dinar"), I18N_NOOP("TND") },
  2888. { "TRL", I18N_NOOP("Turkey"), I18N_NOOP("Turkish Lira"), I18N_NOOP("TL") },
  2889. { "TMM", I18N_NOOP("Turkmenistan"), I18N_NOOP("Manat"), I18N_NOOP("TMM") },
  2890. { "USD", I18N_NOOP("Turks And Caicos Islands"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2891. { "AUD", I18N_NOOP("Tuvalu"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
  2892. { "UGX", I18N_NOOP("Uganda"), I18N_NOOP("Uganda Shilling"), I18N_NOOP("UGX") },
  2893. { "UAH", I18N_NOOP("Ukraine"), I18N_NOOP("Hryvnia"), I18N_NOOP("UAH") },
  2894. { "AED", I18N_NOOP("United Arab Emirates"), I18N_NOOP("UAE Dirham"), I18N_NOOP("AED") },
  2895. { "GBP", I18N_NOOP("United Kingdom"), I18N_NOOP("Pound Sterling"), I18N_NOOP("GBP") },
  2896. { "USD", I18N_NOOP("United States"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2897. { "USN", I18N_NOOP("United States"), I18N_NOOP("US Dollar (Next day)"), I18N_NOOP("USN") },
  2898. { "USS", I18N_NOOP("United States"), I18N_NOOP("US Dollar (Same day)"), I18N_NOOP("USS") },
  2899. { "UYU", I18N_NOOP("Uruguay"), I18N_NOOP("Peso Uruguayo"), I18N_NOOP("NU$") },
  2900. { "UZS", I18N_NOOP("Uzbekistan"), I18N_NOOP("Uzbekistan Sum"), I18N_NOOP("UZS") },
  2901. { "VUV", I18N_NOOP("Vanuatu"), I18N_NOOP("Vatu"), I18N_NOOP("VUV") },
  2902. { "VEB", I18N_NOOP("Venezuela"), I18N_NOOP("Bolivar"), I18N_NOOP("Bs") },
  2903. { "VND", I18N_NOOP("Viet Nam"), I18N_NOOP("Dong"), I18N_NOOP("VND") },
  2904. { "USD", I18N_NOOP("Virgin Islands"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
  2905. { "XPF", I18N_NOOP("Wallis And Futuna"), I18N_NOOP("CFP Franc"), I18N_NOOP("XPF") },
  2906. { "MAD", I18N_NOOP("Western Sahara"), I18N_NOOP("Moroccan Dirham"), I18N_NOOP("MAD") },
  2907. { "YER", I18N_NOOP("Yemen"), I18N_NOOP("Yemeni Rial"), I18N_NOOP("YER") },
  2908. { "YUM", I18N_NOOP("Yugoslavia"), I18N_NOOP("Yugoslavian Dinar"), I18N_NOOP("YUM") },
  2909. { "ZMK", I18N_NOOP("Zambia"), I18N_NOOP("Kwacha"), I18N_NOOP("ZMK") },
  2910. { "ZWD", I18N_NOOP("Zimbabwe"), I18N_NOOP("Zimbabwe Dollar"), I18N_NOOP("ZWD") },
  2911. { 0, 0, 0, 0}, // Last must be empty!
  2912. };
  2913. class CurrencyMap
  2914. {
  2915. public:
  2916. CurrencyMap()
  2917. : m_List(lMoney)
  2918. {
  2919. }
  2920. // Those return the _untranslated_ strings from the above array
  2921. TQString getCode(int t) const
  2922. {
  2923. return TQString::fromUtf8( m_List[t].code );
  2924. }
  2925. TQString getCountry(int t) const
  2926. {
  2927. return TQString::fromUtf8( m_List[t].country );
  2928. }
  2929. TQString getName(int t) const
  2930. {
  2931. return TQString::fromUtf8( m_List[t].name );
  2932. }
  2933. TQString getDisplayCode(int t) const
  2934. {
  2935. return TQString::fromUtf8( m_List[t].display );
  2936. }
  2937. int getIndex(const TQString& code) const
  2938. {
  2939. int index = 0;
  2940. while (m_List[index].code != 0 && m_List[index].code != code)
  2941. ++index;
  2942. return (m_List[index].code != 0) ? index : 1 /*undef*/;
  2943. }
  2944. private:
  2945. const Money * m_List;
  2946. };
  2947. const CurrencyMap gCurrencyMap;
  2948. const Money * gMoneyList(lMoney);
  2949. }
  2950. using namespace Currency_LNS;
  2951. Currency::Currency()
  2952. : m_type( 0 )
  2953. {
  2954. }
  2955. Currency::~Currency()
  2956. {
  2957. }
  2958. Currency::Currency(int index)
  2959. : m_type( index ),
  2960. m_code( gCurrencyMap.getCode( index ) )
  2961. {
  2962. }
  2963. Currency::Currency(int index, TQString const & code)
  2964. : m_type ( 1 ), // unspec
  2965. m_code( code )
  2966. {
  2967. if ( gCurrencyMap.getCode( index ) == code )
  2968. m_type = index;
  2969. }
  2970. Currency::Currency(TQString const & code, currencyFormat format)
  2971. : m_type( 1 ), // unspec
  2972. m_code( code )
  2973. {
  2974. if ( format == Gnumeric )
  2975. {
  2976. // I use TQChar(c,r) here so that this file can be opened in any encoding...
  2977. if ( code.find( TQChar( 172, 32 ) ) != -1 ) // Euro sign
  2978. m_code = TQChar( 172, 32 );
  2979. else if ( code.find( TQChar( 163, 0 ) ) != -1 ) // Pound sign
  2980. m_code = TQChar( 163, 0 );
  2981. else if ( code.find( TQChar( 165, 0 ) ) != -1 ) // Yen sign
  2982. m_code = TQChar( 165, 0 );
  2983. else if ( code[0] == '[' && code[1] == '$' )
  2984. {
  2985. int n = code.find(']');
  2986. if (n != -1)
  2987. {
  2988. m_code = code.mid( 2, n - 2 );
  2989. }
  2990. else
  2991. {
  2992. m_type = 0;
  2993. }
  2994. }
  2995. else if ( code.find( '$' ) != -1 )
  2996. m_code = "$";
  2997. } // end gnumeric
  2998. m_type = gCurrencyMap.getIndex( m_code );
  2999. }
  3000. Currency & Currency::operator=(int type)
  3001. {
  3002. m_type = type;
  3003. m_code = gCurrencyMap.getCode( m_type );
  3004. return *this;
  3005. }
  3006. Currency & Currency::operator=(char const * code)
  3007. {
  3008. m_type = 1;
  3009. m_code = code;
  3010. return *this;
  3011. }
  3012. bool Currency::operator==(Currency const & cur) const
  3013. {
  3014. if ( m_type == cur.m_type )
  3015. return true;
  3016. if ( m_code == cur.m_code )
  3017. return true;
  3018. return false;
  3019. }
  3020. bool Currency::operator==(int type) const
  3021. {
  3022. if ( m_type == type )
  3023. return true;
  3024. return false;
  3025. }
  3026. Currency::operator int() const
  3027. {
  3028. return m_type;
  3029. }
  3030. TQString Currency::getCode() const
  3031. {
  3032. return m_code;
  3033. }
  3034. TQString Currency::getCountry() const
  3035. {
  3036. return gCurrencyMap.getCountry( m_type );
  3037. }
  3038. TQString Currency::getName() const
  3039. {
  3040. return gCurrencyMap.getName( m_type );
  3041. }
  3042. TQString Currency::getDisplayCode() const
  3043. {
  3044. return gMoneyList[m_type].display;
  3045. }
  3046. int Currency::getIndex() const
  3047. {
  3048. return m_type;
  3049. }
  3050. TQString Currency::getExportCode( currencyFormat format ) const
  3051. {
  3052. if ( format == Gnumeric )
  3053. {
  3054. if ( m_code.length() == 1 ) // symbol
  3055. return m_code;
  3056. TQString ret( "[$");
  3057. ret += m_code;
  3058. ret += "]";
  3059. return ret;
  3060. }
  3061. return m_code;
  3062. }
  3063. TQString Currency::getChooseString( int type, bool & ok )
  3064. {
  3065. if ( !gMoneyList[type].country )
  3066. {
  3067. ok = false;
  3068. return TQString();
  3069. }
  3070. if ( type < 24 )
  3071. {
  3072. TQString ret( i18n( gMoneyList[type].name ) );
  3073. if ( gMoneyList[type].country[0] )
  3074. {
  3075. ret += " (";
  3076. ret += i18n( gMoneyList[type].country );
  3077. ret += ")";
  3078. }
  3079. return ret;
  3080. }
  3081. else
  3082. {
  3083. TQString ret( i18n( gMoneyList[type].country ) );
  3084. if ( gMoneyList[type].name[0] )
  3085. {
  3086. ret += " (";
  3087. ret += i18n( gMoneyList[type].name );
  3088. ret += ")";
  3089. }
  3090. return ret;
  3091. }
  3092. }
  3093. TQString Currency::getDisplaySymbol( int type )
  3094. {
  3095. return i18n( gMoneyList[type].display );
  3096. }
  3097. // Currently unused
  3098. TQString Currency::getCurrencyCode( int type )
  3099. {
  3100. return TQString::fromUtf8( gMoneyList[type].code );
  3101. }
  3102. #undef UPDATE_BEGIN
  3103. #undef UPDATE_END