00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <float.h>
00023 #include <iostream>
00024 #include <stdlib.h>
00025 #include <stdio.h>
00026
00027 #include <dcopobject.h>
00028 #include <kdebug.h>
00029 #include <klocale.h>
00030
00031 #include <KoXmlNS.h>
00032 #include <KoGenStyles.h>
00033 #include <KoGlobal.h>
00034 #include <KoStyleStack.h>
00035 #include <KoOasisLoadingContext.h>
00036 #include <KoOasisStyles.h>
00037
00038 #include "kspread_canvas.h"
00039 #include "kspread_doc.h"
00040 #include "kspread_global.h"
00041 #include "kspread_sheet.h"
00042 #include "kspread_sheetprint.h"
00043 #include "kspread_style.h"
00044 #include "kspread_style_manager.h"
00045 #include "KSpreadColumnIface.h"
00046 #include "KSpreadLayoutIface.h"
00047 #include "KSpreadRowIface.h"
00048
00049 #include "kspread_format.h"
00050
00051 using namespace std;
00052 using namespace KSpread;
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 double Format::s_columnWidth = 100.0;
00063 double Format::s_rowHeight = 20.0;
00064
00065 Format::Format( Sheet * _sheet, Style * _style )
00066 : m_pSheet( _sheet ),
00067 m_pStyle( _style ),
00068 m_mask( 0 ),
00069 m_bNoFallBack( 0 ),
00070 m_flagsMask( 0 ),
00071 m_strComment( 0 ),
00072 m_pCell( 0 )
00073 {
00074 }
00075
00076 Format::~Format()
00077 {
00078 if ( m_pStyle->release() )
00079 delete m_pStyle;
00080 }
00081
00082 void Format::defaultStyleFormat()
00083 {
00084 if ( m_pStyle->release() )
00085 delete m_pStyle;
00086
00087 if ( m_pSheet )
00088 m_pStyle = m_pSheet->doc()->styleManager()->defaultStyle();
00089
00090 delete m_strComment;
00091 }
00092
00093
00094 void Format::setGlobalColWidth( double width )
00095 {
00096 s_columnWidth = width;
00097 }
00098
00099 void Format::setGlobalRowHeight( double height )
00100 {
00101 s_rowHeight = height;
00102 }
00103
00104 double Format::globalRowHeight()
00105 {
00106 return s_rowHeight;
00107 }
00108
00109 double Format::globalColWidth()
00110 {
00111 return s_columnWidth;
00112 }
00113
00114 void Format::copy( const Format & _l )
00115 {
00116
00117
00118 setStyle( _l.m_pStyle );
00119
00120 m_mask = _l.m_mask;
00121 m_flagsMask = _l.m_flagsMask;
00122 m_bNoFallBack = _l.m_bNoFallBack;
00123
00124 if ( _l.m_strComment )
00125 {
00126 if (m_strComment)
00127 delete m_strComment;
00128 m_strComment = new QString( *_l.m_strComment );
00129 }
00130 }
00131
00132 void Format::setStyle( Style * style )
00133 {
00134 if ( style == m_pStyle )
00135 return;
00136
00137 if ( m_pStyle && m_pStyle->release() )
00138 delete m_pStyle;
00139
00140 m_bNoFallBack = 0;
00141 m_pStyle = style;
00142 m_pStyle->addRef();
00143 formatChanged();
00144
00145 if ( style->type() == Style::BUILTIN || style->type() == Style::CUSTOM )
00146 kdDebug() << "Style name: " << ((CustomStyle *) m_pStyle)->name() << endl;
00147 }
00148
00149 void Format::clearFlag( FormatFlags flag )
00150 {
00151 m_flagsMask &= ~(Q_UINT32)flag;
00152 }
00153
00154 void Format::setFlag( FormatFlags flag )
00155 {
00156 m_flagsMask |= (Q_UINT32)flag;
00157 }
00158
00159 bool Format::testFlag( FormatFlags flag ) const
00160 {
00161 return ( m_flagsMask & (Q_UINT32)flag );
00162 }
00163
00164 void Format::clearProperties()
00165 {
00166 m_mask = 0;
00167 m_pStyle->clearFeature( (Style::FlagsSet) ~(uint)0 );
00168 formatChanged();
00169 }
00170
00171 void Format::clearProperty( Properties p )
00172 {
00173 m_mask &= ~(uint)p;
00174 m_pStyle->clearFeature( (Style::FlagsSet) p );
00175 formatChanged();
00176 }
00177
00178
00179
00180 bool Format::hasProperty( Properties p, bool withoutParent ) const
00181 {
00182 if ( m_pStyle->hasFeature( (Style::FlagsSet) p, withoutParent ) )
00183 return true;
00184
00185 return ( m_mask & (uint)p );
00186 }
00187
00188 void Format::setProperty( Properties p )
00189 {
00190 m_mask |= (uint)p;
00191 }
00192
00193 void Format::clearNoFallBackProperties()
00194 {
00195 m_bNoFallBack = 0;
00196
00197 formatChanged();
00198 }
00199
00200 void Format::clearNoFallBackProperties( Properties p )
00201 {
00202 m_bNoFallBack &= ~(uint)p;
00203
00204 formatChanged();
00205 }
00206
00207 bool Format::hasNoFallBackProperties( Properties p ) const
00208 {
00209 return ( m_bNoFallBack & (uint)p );
00210 }
00211
00212 void Format::setNoFallBackProperties( Properties p )
00213 {
00214 m_bNoFallBack |= (uint)p;
00215 }
00216
00217
00219
00220
00221
00223
00224
00225 QString Format::saveOasisCellStyle( KoGenStyle ¤tCellStyle, KoGenStyles &mainStyles )
00226 {
00227 QString styleName;
00228 styleName = m_pStyle->saveOasis( currentCellStyle, mainStyles );
00229
00230
00231 if ( currentCellStyle.type() == Doc::STYLE_CELL_AUTO )
00232 {
00233 styleName = mainStyles.lookup( currentCellStyle, "ce" );
00234 }
00235
00236 return styleName;
00237 }
00238
00239 QDomElement Format::saveFormat( QDomDocument & doc, int _col, int _row, bool force, bool copy ) const
00240 {
00241 QDomElement format( doc.createElement( "format" ) );
00242
00243 if ( m_pStyle->type() == Style::BUILTIN || m_pStyle->type() == Style::CUSTOM )
00244 {
00245 format.setAttribute( "style-name", ((CustomStyle *) m_pStyle)->name() );
00246
00247 if ( !copy )
00248 return format;
00249 }
00250 else
00251 {
00252 if ( m_pStyle->parent() && m_pStyle->parent()->name().length() > 0 )
00253 format.setAttribute( "parent", m_pStyle->parent()->name() );
00254 }
00255
00256 if ( hasProperty( PAlign, true ) || hasNoFallBackProperties( PAlign ) || force )
00257 format.setAttribute( "align", (int) align( _col, _row ) );
00258 if ( hasProperty( PAlignY, true ) || hasNoFallBackProperties( PAlignY ) || force )
00259 format.setAttribute( "alignY", (int)alignY( _col, _row ) );
00260 if ( ( hasProperty( PBackgroundColor, false ) || hasNoFallBackProperties( PBackgroundColor)
00261 || force ) && bgColor( _col, _row ).isValid() )
00262 format.setAttribute( "bgcolor", bgColor( _col, _row ).name() );
00263 if ( ( hasProperty( PMultiRow, true ) || hasNoFallBackProperties( PMultiRow )
00264 || force ) && multiRow( _col, _row ) )
00265 format.setAttribute( "multirow", "yes" );
00266 if ( ( hasProperty( PVerticalText, true ) || hasNoFallBackProperties( PVerticalText )
00267 || force ) && verticalText( _col, _row ) )
00268 format.setAttribute( "verticaltext", "yes" );
00269 if ( hasProperty( PPrecision, true ) || hasNoFallBackProperties( PPrecision ) || force )
00270 format.setAttribute( "precision", precision( _col, _row ) );
00271 if ( ( hasProperty( PPrefix, true ) || hasNoFallBackProperties( PPrefix ) || force )
00272 && !prefix( _col, _row ).isEmpty() )
00273 format.setAttribute( "prefix", prefix( _col, _row ) );
00274 if ( ( hasProperty( PPostfix, true ) || hasNoFallBackProperties( PPostfix ) || force )
00275 && !postfix( _col, _row ).isEmpty() )
00276 format.setAttribute( "postfix", postfix( _col, _row ) );
00277 if ( hasProperty( PFloatFormat, true ) || hasNoFallBackProperties( PFloatFormat ) || force )
00278 format.setAttribute( "float", (int) floatFormat( _col, _row ) );
00279 if ( hasProperty( PFloatColor, true ) || hasNoFallBackProperties( PFloatColor ) || force )
00280 format.setAttribute( "floatcolor", (int) floatColor( _col, _row ) );
00281 if ( hasProperty( PFormatType, true ) || hasNoFallBackProperties( PFormatType ) || force )
00282 format.setAttribute( "format", (int)getFormatType( _col, _row ));
00283 if ( hasProperty( PCustomFormat, true ) || hasNoFallBackProperties( PCustomFormat ) || force )
00284 {
00285 QString s( getFormatString( _col, _row ) );
00286 if ( s.length() > 0 )
00287 format.setAttribute( "custom", s );
00288 }
00289 if ( getFormatType( _col, _row ) == Money_format )
00290 {
00291 format.setAttribute( "type", (int) m_pStyle->currency().type );
00292 format.setAttribute( "symbol", m_pStyle->currency().symbol );
00293 }
00294 if ( hasProperty( PAngle, true ) || hasNoFallBackProperties( PAngle ) || force )
00295 format.setAttribute( "angle", getAngle( _col, _row ) );
00296 if ( hasProperty( PIndent, true ) || hasNoFallBackProperties( PIndent ) || force )
00297 format.setAttribute( "indent", getIndent( _col, _row ) );
00298 if( ( hasProperty( PDontPrintText, true ) || hasNoFallBackProperties( PDontPrintText )
00299 || force ) && getDontprintText( _col, _row ) )
00300 format.setAttribute( "dontprinttext", "yes" );
00301 if( ( hasProperty( PNotProtected, true ) || hasNoFallBackProperties( PNotProtected )
00302 || force ) && notProtected( _col, _row ) )
00303 format.setAttribute( "noprotection", "yes" );
00304 if( ( hasProperty( PHideAll, true ) || hasNoFallBackProperties( PHideAll )
00305 || force ) && isHideAll( _col, _row ) )
00306 format.setAttribute( "hideall", "yes" );
00307 if( ( hasProperty( PHideFormula, true ) || hasNoFallBackProperties( PHideFormula )
00308 || force ) && isHideFormula( _col, _row ) )
00309 format.setAttribute( "hideformula", "yes" );
00310 if ( hasProperty( PFont, true ) || hasNoFallBackProperties( PFont ) || force )
00311 format.appendChild( util_createElement( "font", textFont( _col, _row ), doc ) );
00312 if ( ( hasProperty( PTextPen, true ) || hasNoFallBackProperties( PTextPen ) || force )
00313 && textPen( _col, _row ).color().isValid() )
00314 format.appendChild( util_createElement( "pen", textPen( _col, _row ), doc ) );
00315 if ( hasProperty( PBackgroundBrush, true ) || hasNoFallBackProperties( PBackgroundBrush ) || force )
00316 {
00317 format.setAttribute( "brushcolor", backGroundBrushColor( _col, _row ).name() );
00318 format.setAttribute( "brushstyle", (int)backGroundBrushStyle( _col, _row ) );
00319 }
00320 if ( hasProperty( PLeftBorder, true ) || hasNoFallBackProperties( PLeftBorder ) || force )
00321 {
00322 QDomElement left = doc.createElement( "left-border" );
00323 left.appendChild( util_createElement( "pen", leftBorderPen( _col, _row ), doc ) );
00324 format.appendChild( left );
00325 }
00326 if ( hasProperty( PTopBorder, true ) || hasNoFallBackProperties( PTopBorder ) || force )
00327 {
00328 QDomElement top = doc.createElement( "top-border" );
00329 top.appendChild( util_createElement( "pen", topBorderPen( _col, _row ), doc ) );
00330 format.appendChild( top );
00331 }
00332 if ( hasProperty( PRightBorder, true ) || hasNoFallBackProperties( PRightBorder ) || force )
00333 {
00334 QDomElement right = doc.createElement( "right-border" );
00335 right.appendChild( util_createElement( "pen", rightBorderPen( _col, _row ), doc ) );
00336 format.appendChild( right );
00337 }
00338 if ( hasProperty( PBottomBorder, true ) || hasNoFallBackProperties( PBottomBorder ) || force )
00339 {
00340 QDomElement bottom = doc.createElement( "bottom-border" );
00341 bottom.appendChild( util_createElement( "pen", bottomBorderPen( _col, _row ), doc ) );
00342 format.appendChild( bottom );
00343 }
00344 if ( hasProperty( PFallDiagonal, true ) || hasNoFallBackProperties( PFallDiagonal ) || force )
00345 {
00346 QDomElement fallDiagonal = doc.createElement( "fall-diagonal" );
00347 fallDiagonal.appendChild( util_createElement( "pen", fallDiagonalPen( _col, _row ), doc ) );
00348 format.appendChild( fallDiagonal );
00349 }
00350 if ( hasProperty( PGoUpDiagonal, true ) || hasNoFallBackProperties( PGoUpDiagonal ) || force )
00351 {
00352 QDomElement goUpDiagonal = doc.createElement( "up-diagonal" );
00353 goUpDiagonal.appendChild( util_createElement( "pen", goUpDiagonalPen( _col, _row ), doc ) );
00354 format.appendChild( goUpDiagonal );
00355 }
00356 return format;
00357 }
00358
00359
00360 QDomElement Format::saveFormat( QDomDocument& doc, bool force, bool copy ) const
00361 {
00362 QDomElement format( doc.createElement( "format" ) );
00363
00364 if ( m_pStyle->type() == Style::BUILTIN || m_pStyle->type() == Style::CUSTOM )
00365 {
00366 format.setAttribute( "style-name", ((CustomStyle *) m_pStyle)->name() );
00367
00368 if ( !copy )
00369 return format;
00370 }
00371 else
00372 {
00373 if ( m_pStyle->parent() && m_pStyle->parentName().length() > 0 )
00374 format.setAttribute( "parent", m_pStyle->parentName() );
00375 }
00376
00377 if ( hasProperty( PAlign, true ) || hasNoFallBackProperties( PAlign ) || force )
00378 format.setAttribute( "align", (int)m_pStyle->alignX() );
00379 if ( hasProperty( PAlignY, true ) || hasNoFallBackProperties( PAlignY ) || force )
00380 format.setAttribute( "alignY", (int)m_pStyle->alignY() );
00381 if ( ( hasProperty( PBackgroundColor, true ) || hasNoFallBackProperties( PBackgroundColor )
00382 || force ) && m_pStyle->bgColor().isValid() )
00383 format.setAttribute( "bgcolor", m_pStyle->bgColor().name() );
00384
00385 if ( ( hasProperty( PMultiRow, true ) || hasNoFallBackProperties( PMultiRow ) || force )
00386 && m_pStyle->hasProperty( Style::PMultiRow ) )
00387 format.setAttribute( "multirow", "yes" );
00388 if ( ( hasProperty( PVerticalText, true ) || hasNoFallBackProperties( PVerticalText ) || force )
00389 && m_pStyle->hasProperty( Style::PVerticalText ) )
00390 format.setAttribute( "verticaltext", "yes" );
00391
00392 if ( hasProperty( PPrecision, true ) || hasNoFallBackProperties( PPrecision ) || force )
00393 format.setAttribute( "precision", m_pStyle->precision() );
00394 if ( ( hasProperty( PPrefix, true ) || hasNoFallBackProperties( PPrefix ) || force )
00395 && !m_pStyle->prefix().isEmpty() )
00396 format.setAttribute( "prefix", m_pStyle->prefix() );
00397 if ( ( hasProperty( PPostfix, true ) || hasNoFallBackProperties( PPostfix ) || force )
00398 && !m_pStyle->postfix().isEmpty() )
00399 format.setAttribute( "postfix", m_pStyle->postfix() );
00400
00401 if ( hasProperty( PFloatFormat, true ) || hasNoFallBackProperties( PFloatFormat ) || force )
00402 format.setAttribute( "float", (int) m_pStyle->floatFormat() );
00403 if ( hasProperty( PFloatColor, true ) || hasNoFallBackProperties( PFloatColor ) || force )
00404 format.setAttribute( "floatcolor", (int) m_pStyle->floatColor() );
00405 if ( hasProperty( PFormatType, true ) || hasNoFallBackProperties( PFormatType ) || force )
00406 format.setAttribute( "format", (int) m_pStyle->formatType() );
00407 if ( hasProperty( PCustomFormat, true ) || hasNoFallBackProperties( PCustomFormat ) || force )
00408 if ( m_pStyle->strFormat().length() > 0 )
00409 format.setAttribute( "custom", m_pStyle->strFormat() );
00410 if ( m_pStyle->formatType() == Money_format )
00411 {
00412 format.setAttribute( "type", (int) m_pStyle->currency().type );
00413 format.setAttribute( "symbol", m_pStyle->currency().symbol );
00414 }
00415 if ( hasProperty( PAngle, true ) || hasNoFallBackProperties( PAngle ) || force )
00416 format.setAttribute( "angle", m_pStyle->rotateAngle() );
00417 if ( hasProperty( PIndent, true ) || hasNoFallBackProperties( PIndent ) || force )
00418 format.setAttribute( "indent", m_pStyle->indent() );
00419 if ( ( hasProperty( PDontPrintText, true ) || hasNoFallBackProperties( PDontPrintText ) || force )
00420 && m_pStyle->hasProperty( Style::PDontPrintText ) )
00421 format.setAttribute( "dontprinttext", "yes" );
00422 if ( ( hasProperty( PNotProtected, true ) || hasNoFallBackProperties( PNotProtected )
00423 || force ) && m_pStyle->hasProperty( Style::PNotProtected ) )
00424 format.setAttribute( "noprotection", "yes" );
00425 if( ( hasProperty( PHideAll, true ) || hasNoFallBackProperties( PHideAll )
00426 || force ) && m_pStyle->hasProperty( Style::PHideAll ) )
00427 format.setAttribute( "hideall", "yes" );
00428 if( ( hasProperty( PHideFormula, true ) || hasNoFallBackProperties( PHideFormula )
00429 || force ) && m_pStyle->hasProperty( Style::PHideFormula ) )
00430 format.setAttribute( "hideformula", "yes" );
00431 if ( hasProperty( PFont, true ) || hasNoFallBackProperties( PFont ) || force )
00432 format.appendChild( util_createElement( "font", m_pStyle->font(), doc ) );
00433 if ( ( hasProperty( PTextPen, true ) || hasNoFallBackProperties( PTextPen ) || force )
00434 && m_pStyle->pen().color().isValid() )
00435 format.appendChild( util_createElement( "pen", m_pStyle->pen(), doc ) );
00436 if ( hasProperty( PBackgroundBrush, true ) || hasNoFallBackProperties( PBackgroundBrush ) || force )
00437 {
00438 format.setAttribute( "brushcolor", m_pStyle->backGroundBrush().color().name() );
00439 format.setAttribute( "brushstyle", (int) m_pStyle->backGroundBrush().style() );
00440 }
00441 if ( hasProperty( PLeftBorder, true ) || hasNoFallBackProperties( PLeftBorder ) || force )
00442 {
00443 QDomElement left = doc.createElement( "left-border" );
00444 left.appendChild( util_createElement( "pen", m_pStyle->leftBorderPen(), doc ) );
00445 format.appendChild( left );
00446 }
00447 if ( hasProperty( PTopBorder, true ) || hasNoFallBackProperties( PTopBorder ) || force )
00448 {
00449 QDomElement top = doc.createElement( "top-border" );
00450 top.appendChild( util_createElement( "pen", m_pStyle->topBorderPen(), doc ) );
00451 format.appendChild( top );
00452 }
00453 if ( hasProperty( PRightBorder, true ) || hasNoFallBackProperties( PRightBorder ) || force )
00454 {
00455 QDomElement right = doc.createElement( "right-border" );
00456 right.appendChild( util_createElement( "pen", m_pStyle->rightBorderPen(), doc ) );
00457 format.appendChild( right );
00458 }
00459 if ( hasProperty( PBottomBorder, true ) || hasNoFallBackProperties( PBottomBorder ) || force )
00460 {
00461 QDomElement bottom = doc.createElement( "bottom-border" );
00462 bottom.appendChild( util_createElement( "pen", m_pStyle->bottomBorderPen(), doc ) );
00463 format.appendChild( bottom );
00464 }
00465 if ( hasProperty( PFallDiagonal, true ) || hasNoFallBackProperties( PFallDiagonal ) || force )
00466 {
00467 QDomElement fallDiagonal = doc.createElement( "fall-diagonal" );
00468 fallDiagonal.appendChild( util_createElement( "pen", m_pStyle->fallDiagonalPen(), doc ) );
00469 format.appendChild( fallDiagonal );
00470 }
00471 if ( hasProperty( PGoUpDiagonal, true ) || hasNoFallBackProperties( PGoUpDiagonal ) || force )
00472 {
00473 QDomElement goUpDiagonal = doc.createElement( "up-diagonal" );
00474 goUpDiagonal.appendChild( util_createElement( "pen", m_pStyle->goUpDiagonalPen(), doc ) );
00475 format.appendChild( goUpDiagonal );
00476 }
00477 return format;
00478 }
00479
00480 QDomElement Format::save( QDomDocument & doc, int _col, int _row, bool force, bool copy ) const
00481 {
00482 QDomElement format = saveFormat( doc, _col, _row, force, copy );
00483 return format;
00484 }
00485
00486 bool Format::loadFormat( const QDomElement & f, Paste::Mode pm, bool paste )
00487 {
00488 if ( f.hasAttribute( "style-name" ) )
00489 {
00490 Style * s = m_pSheet->doc()->styleManager()->style( f.attribute( "style-name" ) );
00491
00492
00493 if ( s )
00494 {
00495 setStyle( s );
00496
00497 return true;
00498 }
00499 else if ( !paste )
00500 return false;
00501 }
00502 else
00503 if ( f.hasAttribute( "parent" ) )
00504 {
00505 CustomStyle* s = static_cast<CustomStyle*>( m_pSheet->doc()->styleManager()->style( f.attribute( "parent" ) ) );
00506
00507
00508 if ( s )
00509 {
00510 if ( m_pStyle && m_pStyle->release() )
00511 delete m_pStyle;
00512
00513 m_pStyle = new Style();
00514 m_pStyle->setParent( s );
00515 }
00516 }
00517
00518 bool ok;
00519 if ( f.hasAttribute( "align" ) )
00520 {
00521 Align a = (Align) f.attribute( "align" ).toInt( &ok );
00522 if ( !ok )
00523 return false;
00524
00525 if ( (unsigned int) a >= 1 || (unsigned int) a <= 4 )
00526 {
00527 setAlign( a );
00528 }
00529 }
00530 if ( f.hasAttribute( "alignY" ) )
00531 {
00532 AlignY a = (AlignY) f.attribute( "alignY" ).toInt( &ok );
00533 if ( !ok )
00534 return false;
00535
00536 if ( (unsigned int) a >= 1 || (unsigned int) a <= 4 )
00537 {
00538 setAlignY( a );
00539 }
00540 }
00541
00542 if ( f.hasAttribute( "bgcolor" ) ) {
00543 QColor col( f.attribute( "bgcolor" ) );
00544 if ( col != Qt::white )
00545 setBgColor( col );
00546 }
00547
00548 if ( f.hasAttribute( "multirow" ) )
00549 setMultiRow( true );
00550
00551 if ( f.hasAttribute( "verticaltext" ) )
00552 setVerticalText( true );
00553
00554 if ( f.hasAttribute( "precision" ) )
00555 {
00556 int i = f.attribute( "precision" ).toInt( &ok );
00557 if ( i < -1 )
00558 {
00559 kdDebug(36001) << "Value out of range Cell::precision=" << i << endl;
00560 return false;
00561 }
00562
00563 setPrecision( i );
00564 }
00565
00566 if ( f.hasAttribute( "float" ) )
00567 {
00568 FloatFormat a = (FloatFormat) f.attribute( "float" ).toInt( &ok );
00569 if ( !ok ) return false;
00570 if ( (unsigned int) a >= 1 && (unsigned int) a <= 3 )
00571 {
00572 setFloatFormat( a );
00573 }
00574 }
00575
00576 if ( f.hasAttribute( "floatcolor" ) )
00577 {
00578 FloatColor a = (FloatColor) f.attribute( "floatcolor" ).toInt( &ok );
00579 if ( !ok ) return false;
00580 if ( (unsigned int) a >= 1 && (unsigned int) a <= 4 )
00581 {
00582 setFloatColor( a );
00583 }
00584 }
00585
00586 if ( f.hasAttribute( "format" ) )
00587 {
00588 int fo = f.attribute( "format" ).toInt( &ok );
00589 if ( ! ok )
00590 return false;
00591 setFormatType( ( FormatType ) fo );
00592 }
00593 if ( f.hasAttribute( "custom" ) )
00594 {
00595 setFormatString( f.attribute( "custom" ) );
00596 }
00597 if ( m_pStyle->formatType() == Money_format )
00598 {
00599 Currency c;
00600 c.type = -1;
00601 if ( f.hasAttribute( "type" ) )
00602 {
00603 c.type = f.attribute( "type" ).toInt( &ok );
00604 if ( !ok )
00605 c.type = 1;
00606 }
00607 if ( f.hasAttribute( "symbol" ) )
00608 {
00609 c.symbol = f.attribute( "symbol" );
00610 }
00611 if ( c.type != -1 )
00612 setCurrency( c );
00613 }
00614 if ( f.hasAttribute( "angle" ) )
00615 {
00616 setAngle( f.attribute( "angle" ).toInt( &ok ) );
00617 if ( !ok )
00618 return false;
00619 }
00620 if ( f.hasAttribute( "indent" ) )
00621 {
00622 setIndent( f.attribute( "indent" ).toDouble( &ok ) );
00623 if ( !ok )
00624 return false;
00625 }
00626 if ( f.hasAttribute( "dontprinttext" ) )
00627 setDontPrintText( true );
00628
00629 if ( f.hasAttribute( "noprotection" ) )
00630 setNotProtected( true );
00631
00632 if ( f.hasAttribute( "hideall" ) )
00633 setHideAll( true );
00634
00635 if ( f.hasAttribute( "hideformula" ) )
00636 setHideFormula( true );
00637
00638 if ( f.hasAttribute( "brushstyle" ) )
00639 {
00640 setBackGroundBrushStyle( (Qt::BrushStyle) f.attribute( "brushstyle" ).toInt( &ok ) );
00641 if ( !ok )
00642 return false;
00643 }
00644
00645 if ( f.hasAttribute( "brushcolor" ) )
00646 setBackGroundBrushColor( QColor( f.attribute( "brushcolor" ) ) );
00647
00648 QDomElement pen( f.namedItem( "pen" ).toElement() );
00649 if ( !pen.isNull() )
00650 setTextPen( util_toPen( pen ) );
00651
00652 QDomElement font( f.namedItem( "font" ).toElement() );
00653 if ( !font.isNull() )
00654 setTextFont( util_toFont( font ) );
00655
00656 if ( ( pm != Paste::NoBorder ) && ( pm != Paste::Text ) && ( pm != Paste::Comment ) )
00657 {
00658 QDomElement left( f.namedItem( "left-border" ).toElement() );
00659 if ( !left.isNull() )
00660 {
00661 QDomElement pen( left.namedItem( "pen" ).toElement() );
00662 if ( !pen.isNull() )
00663 setLeftBorderPen( util_toPen( pen ) );
00664 }
00665
00666 QDomElement top( f.namedItem( "top-border" ).toElement() );
00667 if ( !top.isNull() )
00668 {
00669 QDomElement pen( top.namedItem( "pen" ).toElement() );
00670 if ( !pen.isNull() )
00671 setTopBorderPen( util_toPen( pen ) );
00672 }
00673
00674 QDomElement right( f.namedItem( "right-border" ).toElement() );
00675 if ( !right.isNull() )
00676 {
00677 QDomElement pen( right.namedItem( "pen" ).toElement() );
00678 if ( !pen.isNull() )
00679 setRightBorderPen( util_toPen( pen ) );
00680 }
00681
00682 QDomElement bottom( f.namedItem( "bottom-border" ).toElement() );
00683 if ( !bottom.isNull() )
00684 {
00685 QDomElement pen( bottom.namedItem( "pen" ).toElement() );
00686 if ( !pen.isNull() )
00687 setBottomBorderPen( util_toPen( pen ) );
00688 }
00689
00690 QDomElement fallDiagonal( f.namedItem( "fall-diagonal" ).toElement() );
00691 if ( !fallDiagonal.isNull() )
00692 {
00693 QDomElement pen( fallDiagonal.namedItem( "pen" ).toElement() );
00694 if ( !pen.isNull() )
00695 setFallDiagonalPen( util_toPen( pen ) );
00696 }
00697
00698 QDomElement goUpDiagonal( f.namedItem( "up-diagonal" ).toElement() );
00699 if ( !goUpDiagonal.isNull() )
00700 {
00701 QDomElement pen( goUpDiagonal.namedItem( "pen" ).toElement() );
00702 if ( !pen.isNull() )
00703 setGoUpDiagonalPen( util_toPen( pen ) );
00704 }
00705 }
00706
00707 if ( f.hasAttribute( "prefix" ) )
00708 setPrefix( f.attribute( "prefix" ) );
00709 if ( f.hasAttribute( "postfix" ) )
00710 setPostfix( f.attribute( "postfix" ) );
00711
00712 return true;
00713 }
00714
00715 bool Format::load( const QDomElement & f, Paste::Mode pm, bool paste )
00716 {
00717 if ( !loadFormat( f, pm, paste ) )
00718 return false;
00719 return true;
00720 }
00721
00722
00723 #if 0
00724 bool Format::loadFontOasisStyle( KoStyleStack & font )
00725 {
00726 font.setTypeProperties( "text" );
00727
00728
00729 if ( font.hasAttributeNS( KoXmlNS::fo, "font-family" ) )
00730 setTextFontFamily( font.attributeNS( KoXmlNS::fo, "font-family" ) );
00731
00732 if ( font.hasAttributeNS( KoXmlNS::fo, "color" ) )
00733 setTextColor( QColor( font.attributeNS( KoXmlNS::fo, "color" ) ) );
00734
00735 if ( font.hasAttributeNS( KoXmlNS::fo, "font-size" ) )
00736 setTextFontSize( (int) KoUnit::parseValue( font.attributeNS( KoXmlNS::fo, "font-size" ), 10.0 ) );
00737
00738 if ( font.hasAttributeNS( KoXmlNS::fo, "font-style" ) && ( font.attributeNS( KoXmlNS::fo,"font-style" )== "italic" ))
00739 {
00740 kdDebug(30518) << "italic" << endl;
00741 setTextFontItalic( true );
00742 }
00743 if ( font.hasAttributeNS( KoXmlNS::fo, "font-weight" )
00744 && ( font.attributeNS( KoXmlNS::fo, "font-weight" ) == "bold") )
00745 setTextFontBold( true );
00746
00747
00748 if ( ( font.hasAttributeNS( KoXmlNS::fo, "text-underline-style" ) && font.attributeNS( KoXmlNS::fo, "text-underline-style" ) != "none" )
00749 || ( font.hasAttributeNS( KoXmlNS::style, "text-underline-style" ) && font.attributeNS( KoXmlNS::style, "text-underline-style" )!="none" ) )
00750 setTextFontUnderline( true );
00751
00752 if ( font.hasAttributeNS( KoXmlNS::style, "text-line-through-style" )
00753 && font.attributeNS( KoXmlNS::style, "text-line-through-style" ) != "none"
00754 )
00755 setTextFontStrike( true );
00756
00757 if ( font.hasAttributeNS( KoXmlNS::style, "font-pitch" ) )
00758 {
00759
00760 }
00761
00762
00763
00764 return true;
00765 }
00766
00767 void Format::loadOasisStyle( KoOasisLoadingContext& context )
00768 {
00769 QString str;
00770 KoOasisStyles& oasisStyles = context.oasisStyles();
00771
00772
00773
00774
00775
00776
00777
00778 KoStyleStack& styleStack = context.styleStack();
00779 loadOasisStyleProperties( styleStack, context.oasisStyles() );
00780
00781
00782
00783 kdDebug() << "*** Loading style attributes *****" << endl;
00784
00785 if ( styleStack.hasAttributeNS( KoXmlNS::style, "data-style-name" ) )
00786 {
00787 str = styleStack.attributeNS( KoXmlNS::style, "data-style-name" );
00788 kdDebug() << " style:data-style-name: " << str << endl << endl;
00789
00790 if ( !str.isEmpty() )
00791 {
00792 QString tmp = oasisStyles.dataFormats()[str].prefix;
00793 if ( !tmp.isEmpty() )
00794 {
00795 setPrefix( tmp );
00796 }
00797 tmp = oasisStyles.dataFormats()[str].suffix;
00798 if ( !tmp.isEmpty() )
00799 {
00800 setPostfix( tmp );
00801 }
00802 tmp = oasisStyles.dataFormats()[str].formatStr;
00803 if ( !tmp.isEmpty() )
00804 {
00805 setFormatType( Style::formatType( tmp ) );
00806 }
00807 }
00808 }
00809
00810 if ( styleStack.hasAttributeNS( KoXmlNS::style, "decimal-places" ) )
00811 {
00812 bool ok = false;
00813 int p = styleStack.attributeNS( KoXmlNS::style, "decimal-places" ).toInt( &ok );
00814 kdDebug() << " style:decimal-places: " << p << endl;
00815 if (ok )
00816 setPrecision( p );
00817 }
00818 }
00819
00820 bool Format::loadOasisStyleProperties( KoStyleStack & styleStack, const KoOasisStyles& oasisStyles )
00821 {
00822 kdDebug() << "*** Loading style properties *****" << endl;
00823 #if 0
00824 if ( f.hasAttribute( "style-name" ) )
00825 {
00826 Style * s = m_pSheet->doc()->styleManager()->style( f.attribute( "style-name" ) );
00827
00828
00829 if ( s )
00830 {
00831 setStyle( s );
00832
00833 return true;
00834 }
00835 else if ( !paste )
00836 return false;
00837 }
00838 else
00839 if ( f.hasAttribute( "parent" ) )
00840 {
00841 CustomStyle * s = (CustomStyle *) m_pSheet->doc()->styleManager()->style( f.attribute( "parent" ) );
00842
00843
00844 if ( s )
00845 {
00846 if ( m_pStyle && m_pStyle->release() )
00847 delete m_pStyle;
00848
00849 m_pStyle = new Style();
00850 m_pStyle->setParent( s );
00851 }
00852 }
00853 #endif
00854 if ( styleStack.hasAttributeNS( KoXmlNS::style, "parent-style-name" ) )
00855 {
00856 Style * s = m_pSheet->doc()->styleManager()->style( styleStack.attributeNS( KoXmlNS::style, "parent-style-name" ) );
00857
00858
00859 if ( s )
00860 {
00861 setStyle( s );
00862 }
00863 }
00864 else
00865 {
00866 setStyle( m_pSheet->doc()->styleManager()->defaultStyle() );
00867 }
00868
00869
00870 if ( styleStack.hasAttributeNS( KoXmlNS::style, "font-name" ) )
00871 {
00872 const QDomElement * font = oasisStyles.findStyle( styleStack.attributeNS( KoXmlNS::style, "font-name" ) );
00873 if ( font )
00874 {
00875 styleStack.save();
00876 styleStack.push( *font );
00877 loadFontOasisStyle( styleStack );
00878 styleStack.restore();
00879 }
00880 }
00881
00882 kdDebug() << " [text properties]" << endl;
00883
00884 loadFontOasisStyle( styleStack );
00885
00886
00887 kdDebug() << " [paragraph properties]" << endl;
00888
00889 styleStack.setTypeProperties( "paragraph" );
00890 if ( styleStack.hasAttributeNS( KoXmlNS::fo, "margin-left" ) )
00891 {
00892 kdDebug()<<" margin-left:"<<KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "margin-left" ),0.0 )<<endl;
00893 setIndent( KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "margin-left" ),0.0 ) );
00894 }
00895
00896 if ( styleStack.hasAttributeNS( KoXmlNS::fo, "text-align" ) )
00897 {
00898 QString s = styleStack.attributeNS( KoXmlNS::fo, "text-align" );
00899 if ( s == "center" )
00900 setAlign( Format::Center );
00901 else if ( s == "end" )
00902 setAlign( Format::Right );
00903 else if ( s == "start" )
00904 setAlign( Format::Left );
00905 else if ( s == "justify" )
00906 setAlign( Format::Center );
00907 }
00908
00909
00910 kdDebug() << " [cell properties]" << endl;
00911 styleStack.setTypeProperties( "table-cell" );
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923 if ( styleStack.hasAttributeNS( KoXmlNS::style, "rotation-angle" ) )
00924 {
00925 bool ok = false;
00926 int a = styleStack.attributeNS( KoXmlNS::style, "rotation-angle" ).toInt( &ok );
00927 if ( ok && ( a != 0 ))
00928 setAngle( -a );
00929 }
00930 if ( styleStack.hasAttributeNS( KoXmlNS::style, "direction" ) )
00931 {
00932 QString dir = styleStack.attributeNS( KoXmlNS::fo, "direction" );
00933 if ( dir == "ttb" )
00934 setVerticalText( true );
00935 else if ( dir == "ltr" )
00936 setVerticalText( false );
00937 }
00938
00939 kdDebug()<<"property.hasAttribute( fo:background-color ) :"<<styleStack.hasAttributeNS( KoXmlNS::fo, "background-color" )<<endl;
00940
00941 if ( styleStack.hasAttributeNS( KoXmlNS::fo, "background-color" ) )
00942 setBgColor( QColor( styleStack.attributeNS( KoXmlNS::fo, "background-color" ) ) );
00943
00944 if ( styleStack.hasAttributeNS( KoXmlNS::style, "print-content" ) )
00945 {
00946 if ( styleStack.attributeNS( KoXmlNS::style, "print-content" ) == "false" )
00947 setDontPrintText( false );
00948 }
00949 if ( styleStack.hasAttributeNS( KoXmlNS::style, "cell-protect" ) )
00950 {
00951 QString prot( styleStack.attributeNS( KoXmlNS::style, "cell-protect" ) );
00952 if ( prot == "none" )
00953 {
00954 setNotProtected( true );
00955 setHideFormula( false );
00956 setHideAll( false );
00957 }
00958 else if ( prot == "formula-hidden" )
00959 {
00960 setNotProtected( true );
00961 setHideFormula( true );
00962 setHideAll( false );
00963 }
00964 else if ( prot == "protected formula-hidden" )
00965 {
00966 setNotProtected( false );
00967 setHideFormula( true );
00968 setHideAll( false );
00969 }
00970 else if ( prot == "hidden-and-protected" )
00971 {
00972 setNotProtected( false );
00973 setHideFormula( false );
00974 setHideAll( true );
00975 }
00976 else if ( prot == "protected" )
00977 {
00978 setNotProtected( false );
00979 setHideFormula( false );
00980 setHideAll( false );
00981 }
00982 else
00983 kdDebug()<<" Protected cell not supported :"<<prot<<endl;
00984 kdDebug() << " cell-protect: " << prot << endl;
00985 }
00986
00987 if ( styleStack.hasAttributeNS( KoXmlNS::fo, "padding-left" ) )
00988 setIndent( KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::fo, "padding-left" ) ) );
00989
00990 if ( styleStack.hasAttributeNS( KoXmlNS::style, "vertical-align" ) )
00991 {
00992 QString s = styleStack.attributeNS( KoXmlNS::style, "vertical-align" );
00993 if ( s == "middle" )
00994 setAlignY( Format::Middle );
00995 else if ( s == "bottom" )
00996 setAlignY( Format::Bottom );
00997 else if ( s == "top" )
00998 setAlignY( Format::Top );
00999 }
01000
01001 if ( styleStack.hasAttributeNS( KoXmlNS::fo, "wrap-option" ) )
01002 {
01003
01004 QString wrapOpt = styleStack.attributeNS( KoXmlNS::fo, "wrap-option" );
01005 if ( wrapOpt == "wrap" )
01006 setMultiRow( true );
01007 else if ( wrapOpt == "no-wrap" )
01008 setMultiRow( false );
01009 }
01010 if ( styleStack.hasAttributeNS( KoXmlNS::fo, "border-bottom" ) )
01011 {
01012 setBottomBorderPen( convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::fo, "border-bottom" ) ) );
01013
01014 }
01015
01016 if ( styleStack.hasAttributeNS( KoXmlNS::fo, "border-right" ) )
01017 {
01018 setRightBorderPen( convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::fo, "border-right" ) ) );
01019
01020 }
01021
01022 if ( styleStack.hasAttributeNS( KoXmlNS::fo, "border-top" ) )
01023 {
01024 setTopBorderPen( convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::fo, "border-top" ) ) );
01025
01026 }
01027
01028 if ( styleStack.hasAttributeNS( KoXmlNS::fo, "border-left" ) )
01029 {
01030 setLeftBorderPen( convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::fo, "border-left" ) ) );
01031
01032 }
01033
01034 if ( styleStack.hasAttributeNS( KoXmlNS::fo, "border" ) )
01035 {
01036 QPen pen = convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::fo, "border" ) );
01037 setLeftBorderPen( pen );
01038 setRightBorderPen( pen );
01039 setTopBorderPen( pen );
01040 setBottomBorderPen( pen );
01041
01042
01043 }
01044 if ( styleStack.hasAttributeNS( KoXmlNS::style, "diagonal-tl-br" ) )
01045 {
01046 setFallDiagonalPen( convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::style, "diagonal-tl-br" ) ) );
01047 }
01048 if ( styleStack.hasAttributeNS( KoXmlNS::style, "diagonal-bl-tr" ) )
01049 {
01050 setGoUpDiagonalPen( convertOasisStringToPen( styleStack.attributeNS( KoXmlNS::style, "diagonal-bl-tr" ) ) );
01051 }
01052
01053 if ( styleStack.hasAttributeNS( KoXmlNS::draw, "style-name" ) )
01054 {
01055
01056
01057 const QDomElement * style = oasisStyles.findStyle( styleStack.attributeNS( KoXmlNS::draw, "style-name" ), "graphic" );
01058 if ( style )
01059 {
01060
01061 KoStyleStack drawStyleStack;
01062 drawStyleStack.push( *style );
01063 drawStyleStack.setTypeProperties( "graphic" );
01064 if ( drawStyleStack.hasAttributeNS( KoXmlNS::draw, "fill" ) )
01065 {
01066 const QString fill = drawStyleStack.attributeNS( KoXmlNS::draw, "fill" );
01067 kdDebug()<<" load object gradient fill type :"<<fill<<endl;
01068
01069 if ( fill == "solid" || fill == "hatch" )
01070 {
01071 QBrush brush=KoOasisStyles::loadOasisFillStyle( drawStyleStack, fill, oasisStyles );
01072 setBackGroundBrushStyle( brush.style() );
01073 setBackGroundBrushColor( brush.color() );
01074 }
01075 else
01076 kdDebug()<<" fill style not supported by kspread : "<<fill<<endl;
01077 }
01078 }
01079 }
01080
01081 return true;
01082 }
01083 #endif
01084
01085
01087
01088
01089
01091
01092 void Format::setFormatString( QString const & format )
01093 {
01094 if ( format.isEmpty() )
01095 {
01096 clearProperty( PCustomFormat );
01097 setNoFallBackProperties( PCustomFormat );
01098 }
01099 else
01100 {
01101 setProperty( PCustomFormat );
01102 clearNoFallBackProperties( PCustomFormat );
01103
01104
01105 clearProperty( PPrefix );
01106 clearProperty( PPostfix );
01107 clearProperty( PPrecision );
01108 clearProperty( PFloatColor );
01109 clearProperty( PFloatFormat );
01110
01111 setNoFallBackProperties( PPrecision );
01112 setNoFallBackProperties( PPrefix );
01113 setNoFallBackProperties( PPostfix );
01114 }
01115
01116 m_pStyle = m_pStyle->setStrFormat( format );
01117 formatChanged();
01118 }
01119
01120 void Format::setAlign( Align _align )
01121 {
01122 if ( _align == Format::Undefined )
01123 {
01124 clearProperty( PAlign );
01125 setNoFallBackProperties(PAlign );
01126 }
01127 else
01128 {
01129 setProperty( PAlign );
01130 clearNoFallBackProperties(PAlign );
01131 }
01132
01133 m_pStyle = m_pStyle->setAlignX( _align );
01134 formatChanged();
01135 }
01136
01137 void Format::setAlignY( AlignY _alignY)
01138 {
01139
01140 if ( _alignY == Format::Middle )
01141 {
01142
01143 clearProperty( PAlignY );
01144 setNoFallBackProperties(PAlignY );
01145 }
01146 else
01147 {
01148
01149 setProperty( PAlignY );
01150 clearNoFallBackProperties( PAlignY );
01151 }
01152
01153 m_pStyle = m_pStyle->setAlignY( _alignY );
01154 formatChanged();
01155 }
01156
01157 void Format::setPrefix( const QString& _prefix )
01158 {
01159 if ( _prefix.isEmpty() )
01160 {
01161 clearProperty( PPrefix );
01162 setNoFallBackProperties( PPrefix );
01163 }
01164 else
01165 {
01166 setProperty( PPrefix );
01167 clearNoFallBackProperties( PPrefix );
01168 }
01169
01170 m_pStyle = m_pStyle->setPrefix( _prefix );
01171 formatChanged();
01172 }
01173
01174 void Format::setPostfix( const QString& _postfix )
01175 {
01176 if ( _postfix.isEmpty() )
01177 {
01178 clearProperty( PPostfix );
01179 setNoFallBackProperties( PPostfix );
01180 }
01181 else
01182 {
01183 setProperty( PPostfix );
01184 clearNoFallBackProperties( PPostfix );
01185 }
01186
01187 m_pStyle = m_pStyle->setPostfix( _postfix );
01188 formatChanged();
01189 }
01190
01191 void Format::setPrecision( int _p )
01192 {
01193 if ( _p == -1 )
01194 {
01195 clearProperty( PPrecision );
01196 setNoFallBackProperties( PPrecision );
01197 }
01198 else
01199 {
01200 setProperty( PPrecision );
01201 clearNoFallBackProperties( PPrecision );
01202 }
01203
01204 m_pStyle = m_pStyle->setPrecision( _p );
01205 formatChanged();
01206 }
01207
01208 void Format::setLeftBorderPen( const QPen & _p )
01209 {
01210 if ( _p.style() == Qt::NoPen )
01211 {
01212 clearProperty( PLeftBorder );
01213 setNoFallBackProperties( PLeftBorder );
01214 }
01215 else
01216 {
01217 setProperty( PLeftBorder );
01218 clearNoFallBackProperties( PLeftBorder );
01219 }
01220
01221 m_pStyle = m_pStyle->setLeftBorderPen( _p );
01222 formatChanged();
01223 }
01224
01225 void Format::setLeftBorderStyle( Qt::PenStyle s )
01226 {
01227 QPen p( m_pStyle->leftBorderPen() );
01228 p.setStyle( s );
01229 setLeftBorderPen( p );
01230 }
01231
01232 void Format::setLeftBorderColor( const QColor & c )
01233 {
01234 QPen p( m_pStyle->leftBorderPen() );
01235 p.setColor( c );
01236 setLeftBorderPen( p );
01237 }
01238
01239 void Format::setLeftBorderWidth( int _w )
01240 {
01241 QPen p( m_pStyle->leftBorderPen() );
01242 p.setWidth( _w );
01243 setLeftBorderPen( p );
01244 }
01245
01246 void Format::setTopBorderPen( const QPen & _p )
01247 {
01248 if ( _p.style() == Qt::NoPen )
01249 {
01250 clearProperty( PTopBorder );
01251 setNoFallBackProperties( PTopBorder );
01252 }
01253 else
01254 {
01255 setProperty( PTopBorder );
01256 clearNoFallBackProperties( PTopBorder );
01257 }
01258
01259 m_pStyle = m_pStyle->setTopBorderPen( _p );
01260 formatChanged();
01261 }
01262
01263 void Format::setTopBorderStyle( Qt::PenStyle s )
01264 {
01265 QPen p( m_pStyle->topBorderPen() );
01266 p.setStyle( s );
01267 setTopBorderPen( p );
01268 }
01269
01270 void Format::setTopBorderColor( const QColor& c )
01271 {
01272 QPen p( m_pStyle->topBorderPen() );
01273 p.setColor( c );
01274 setTopBorderPen( p );
01275 }
01276
01277 void Format::setTopBorderWidth( int _w )
01278 {
01279 QPen p( m_pStyle->topBorderPen() );
01280 p.setWidth( _w );
01281 setTopBorderPen( p );
01282 }
01283
01284 void Format::setRightBorderPen( const QPen& p )
01285 {
01286 if ( p.style() == Qt::NoPen )
01287 {
01288 clearProperty( PRightBorder );
01289 setNoFallBackProperties( PRightBorder );
01290 }
01291 else
01292 {
01293 setProperty( PRightBorder );
01294 clearNoFallBackProperties( PRightBorder );
01295 }
01296
01297 m_pStyle = m_pStyle->setRightBorderPen( p );
01298 formatChanged();
01299 }
01300
01301 void Format::setRightBorderStyle( Qt::PenStyle _s )
01302 {
01303 QPen p( m_pStyle->rightBorderPen() );
01304 p.setStyle( _s );
01305 setRightBorderPen( p );
01306 }
01307
01308 void Format::setRightBorderColor( const QColor & _c )
01309 {
01310 QPen p( m_pStyle->rightBorderPen() );
01311 p.setColor( _c );
01312 setRightBorderPen( p );
01313 }
01314
01315 void Format::setRightBorderWidth( int _w )
01316 {
01317 QPen p( m_pStyle->rightBorderPen() );
01318 p.setWidth( _w );
01319 setRightBorderPen( p );
01320 }
01321
01322 void Format::setBottomBorderPen( const QPen& p )
01323 {
01324 if ( p.style() == Qt::NoPen )
01325 {
01326 clearProperty( PBottomBorder );
01327 setNoFallBackProperties( PBottomBorder );
01328 }
01329 else
01330 {
01331 setProperty( PBottomBorder );
01332 clearNoFallBackProperties( PBottomBorder );
01333 }
01334
01335 m_pStyle = m_pStyle->setBottomBorderPen( p );
01336 formatChanged();
01337 }
01338
01339 void Format::setBottomBorderStyle( Qt::PenStyle _s )
01340 {
01341 QPen p( m_pStyle->bottomBorderPen() );
01342 p.setStyle( _s );
01343 setBottomBorderPen( p );
01344 }
01345
01346 void Format::setBottomBorderColor( const QColor & _c )
01347 {
01348 QPen p( m_pStyle->bottomBorderPen() );
01349 p.setColor( _c );
01350 setBottomBorderPen( p );
01351 }
01352
01353 void Format::setBottomBorderWidth( int _w )
01354 {
01355 QPen p( m_pStyle->bottomBorderPen() );
01356 p.setWidth( _w );
01357 setBottomBorderPen( p );
01358 }
01359
01360 void Format::setFallDiagonalPen( const QPen & _p )
01361 {
01362 if ( _p.style() == Qt::NoPen )
01363 {
01364 clearProperty( PFallDiagonal );
01365 setNoFallBackProperties( PFallDiagonal );
01366 }
01367 else
01368 {
01369 setProperty( PFallDiagonal );
01370 clearNoFallBackProperties( PFallDiagonal );
01371 }
01372
01373 m_pStyle = m_pStyle->setFallDiagonalPen( _p );
01374 formatChanged();
01375 }
01376
01377 void Format::setFallDiagonalStyle( Qt::PenStyle s )
01378 {
01379 QPen p( m_pStyle->fallDiagonalPen() );
01380 p.setStyle( s );
01381 setFallDiagonalPen( p );
01382 }
01383
01384 void Format::setFallDiagonalColor( const QColor& c )
01385 {
01386 QPen p( m_pStyle->fallDiagonalPen() );
01387 p.setColor( c );
01388 setFallDiagonalPen( p );
01389 }
01390
01391 void Format::setFallDiagonalWidth( int _w )
01392 {
01393 QPen p( m_pStyle->fallDiagonalPen() );
01394 p.setWidth( _w );
01395 setFallDiagonalPen( p );
01396 }
01397
01398 void Format::setGoUpDiagonalPen( const QPen & _p )
01399 {
01400 if ( _p.style() == Qt::NoPen )
01401 {
01402 clearProperty( PGoUpDiagonal );
01403 setNoFallBackProperties( PGoUpDiagonal );
01404 }
01405 else
01406 {
01407 setProperty( PGoUpDiagonal );
01408 clearNoFallBackProperties( PGoUpDiagonal );
01409 }
01410
01411 m_pStyle = m_pStyle->setGoUpDiagonalPen( _p );
01412 formatChanged();
01413 }
01414
01415 void Format::setGoUpDiagonalStyle( Qt::PenStyle s )
01416 {
01417 QPen p( m_pStyle->goUpDiagonalPen() );
01418 p.setStyle( s );
01419 setGoUpDiagonalPen( p );
01420 }
01421
01422 void Format::setGoUpDiagonalColor( const QColor& c )
01423 {
01424 QPen p( m_pStyle->goUpDiagonalPen() );
01425 p.setColor( c );
01426 setGoUpDiagonalPen( p );
01427 }
01428
01429 void Format::setGoUpDiagonalWidth( int _w )
01430 {
01431 QPen p( m_pStyle->goUpDiagonalPen() );
01432 p.setWidth( _w );
01433 setGoUpDiagonalPen( p );
01434 }
01435
01436 void Format::setBackGroundBrush( const QBrush & _p)
01437 {
01438 if ( _p.style() == Qt::NoBrush )
01439 {
01440 clearProperty( PBackgroundBrush );
01441 setNoFallBackProperties( PBackgroundBrush );
01442 }
01443 else
01444 {
01445 setProperty( PBackgroundBrush );
01446 clearNoFallBackProperties( PBackgroundBrush );
01447 }
01448
01449 m_pStyle = m_pStyle->setBackGroundBrush( _p );
01450 formatChanged();
01451 }
01452
01453 void Format::setBackGroundBrushStyle( Qt::BrushStyle s )
01454 {
01455 QBrush b( m_pStyle->backGroundBrush() );
01456 b.setStyle( s );
01457 setBackGroundBrush( b );
01458 }
01459
01460 void Format::setBackGroundBrushColor( const QColor & c )
01461 {
01462 QBrush b( m_pStyle->backGroundBrush() );
01463 b.setColor( c );
01464 setBackGroundBrush( b );
01465 }
01466
01467 void Format::setTextFont( const QFont & _f )
01468 {
01469 if( m_pStyle->parent() && _f == m_pStyle->parent()->font())
01470 {
01471 clearProperty( PFont );
01472 setNoFallBackProperties( PFont );
01473 }
01474 else if( !m_pStyle->parent() && _f == KoGlobal::defaultFont() )
01475 {
01476 clearProperty( PFont );
01477 setNoFallBackProperties( PFont );
01478 }
01479 else
01480 {
01481 setProperty( PFont );
01482 clearNoFallBackProperties( PFont );
01483 }
01484
01485
01486 m_pStyle = m_pStyle->setFont( _f );
01487 formatChanged();
01488 }
01489
01490 void Format::setTextFontSize( int _s )
01491 {
01492 QFont f( m_pStyle->font() );
01493 f.setPointSize( _s );
01494 setTextFont( f );
01495 }
01496
01497 void Format::setTextFontFamily( const QString & _f )
01498 {
01499 QFont f( m_pStyle->font() );
01500 f.setFamily( _f );
01501 setTextFont( f );
01502 }
01503
01504 void Format::setTextFontBold( bool _b )
01505 {
01506 QFont f( m_pStyle->font() );
01507 f.setBold( _b );
01508 setTextFont( f );
01509 }
01510
01511 void Format::setTextFontItalic( bool _i )
01512 {
01513 QFont f( m_pStyle->font() );
01514 f.setItalic( _i );
01515 setTextFont( f );
01516 }
01517
01518 void Format::setTextFontUnderline( bool _i )
01519 {
01520 QFont f( m_pStyle->font() );
01521 f.setUnderline( _i );
01522 setTextFont( f );
01523 }
01524
01525 void Format::setTextFontStrike( bool _i )
01526 {
01527 QFont f( m_pStyle->font() );
01528 f.setStrikeOut( _i );
01529 setTextFont( f );
01530 }
01531
01532 void Format::setTextPen( const QPen & _p )
01533 {
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543 {
01544 setProperty( PTextPen );
01545 clearNoFallBackProperties( PTextPen );
01546 }
01547
01548
01549 m_pStyle = m_pStyle->setPen( _p );
01550
01551 formatChanged();
01552 }
01553
01554 void Format::setTextColor( const QColor & _c )
01555 {
01556 QPen p( m_pStyle->pen() );
01557 p.setColor( _c );
01558 setTextPen( p );
01559 }
01560
01561 void Format::setBgColor( const QColor & _c )
01562 {
01563 if ( !_c.isValid() )
01564 {
01565 clearProperty( PBackgroundColor );
01566 setNoFallBackProperties( PBackgroundColor );
01567 }
01568 else
01569 {
01570 setProperty( PBackgroundColor );
01571 clearNoFallBackProperties( PBackgroundColor );
01572 }
01573
01574 m_pStyle = m_pStyle->setBgColor( _c );
01575 formatChanged();
01576 }
01577
01578 void Format::setFloatFormat( FloatFormat _f )
01579 {
01580 setProperty( PFloatFormat );
01581
01582 m_pStyle = m_pStyle->setFloatFormat( _f );
01583 formatChanged();
01584 }
01585
01586 void Format::setFloatColor( FloatColor _c )
01587 {
01588 setProperty( PFloatColor );
01589
01590 m_pStyle = m_pStyle->setFloatColor( _c );
01591 formatChanged();
01592 }
01593
01594 void Format::setMultiRow( bool _b )
01595 {
01596 if ( _b == false )
01597 {
01598 m_pStyle = m_pStyle->clearProperty( Style::PMultiRow );
01599 clearProperty( PMultiRow );
01600 setNoFallBackProperties( PMultiRow );
01601 }
01602 else
01603 {
01604 m_pStyle = m_pStyle->setProperty( Style::PMultiRow );
01605 setProperty( PMultiRow );
01606 clearNoFallBackProperties( PMultiRow );
01607 }
01608 formatChanged();
01609 }
01610
01611 void Format::setVerticalText( bool _b )
01612 {
01613 if ( _b == false )
01614 {
01615 m_pStyle = m_pStyle->clearProperty( Style::PVerticalText );
01616 setNoFallBackProperties( PVerticalText);
01617 clearFlag( Flag_VerticalText );
01618 }
01619 else
01620 {
01621 m_pStyle = m_pStyle->setProperty( Style::PVerticalText );
01622 clearNoFallBackProperties( PVerticalText);
01623 setFlag( Flag_VerticalText );
01624 }
01625 formatChanged();
01626 }
01627
01628 void Format::setFormatType( FormatType _format )
01629 {
01630 if ( _format == Number_format )
01631 {
01632 clearProperty( PFormatType );
01633 setNoFallBackProperties( PFormatType);
01634 }
01635 else
01636 {
01637 setProperty( PFormatType );
01638 clearNoFallBackProperties( PFormatType);
01639 }
01640
01641 m_pStyle = m_pStyle->setFormatType( _format );
01642 formatChanged();
01643 }
01644
01645 void Format::setAngle( int _angle )
01646 {
01647 if ( _angle == 0 )
01648 {
01649 clearProperty( PAngle );
01650 setNoFallBackProperties( PAngle);
01651 }
01652 else
01653 {
01654 setProperty( PAngle );
01655 clearNoFallBackProperties( PAngle);
01656 }
01657
01658 m_pStyle = m_pStyle->setRotateAngle( _angle );
01659 formatChanged();
01660 }
01661
01662 void Format::setIndent( double _indent )
01663 {
01664 if ( _indent == 0.0 )
01665 {
01666 clearProperty( PIndent );
01667 setNoFallBackProperties( PIndent );
01668 }
01669 else
01670 {
01671 setProperty( PIndent );
01672 clearNoFallBackProperties( PIndent );
01673 }
01674
01675 m_pStyle = m_pStyle->setIndent( _indent );
01676 formatChanged();
01677 }
01678
01679 void Format::setComment( const QString & _comment )
01680 {
01681 if ( _comment.isEmpty() )
01682 {
01683 clearProperty( PComment );
01684 setNoFallBackProperties( PComment );
01685 }
01686 else
01687 {
01688 setProperty( PComment );
01689 clearNoFallBackProperties( PComment );
01690 }
01691
01692
01693 delete m_strComment;
01694 if ( !_comment.isEmpty() )
01695 m_strComment = new QString( _comment );
01696 else
01697 m_strComment = 0;
01698 formatChanged();
01699 }
01700
01701 void Format::setNotProtected( bool _b)
01702 {
01703 if ( _b == false )
01704 {
01705 m_pStyle = m_pStyle->clearProperty( Style::PNotProtected );
01706 setNoFallBackProperties( PNotProtected );
01707 clearFlag( Flag_NotProtected );
01708 }
01709 else
01710 {
01711 m_pStyle = m_pStyle->setProperty( Style::PNotProtected );
01712 clearNoFallBackProperties( PNotProtected );
01713 setFlag( Flag_NotProtected );
01714 }
01715 formatChanged();
01716 }
01717
01718 void Format::setDontPrintText( bool _b )
01719 {
01720 if ( _b == false )
01721 {
01722 m_pStyle = m_pStyle->clearProperty( Style::PDontPrintText );
01723 setNoFallBackProperties(PDontPrintText);
01724 clearFlag( Flag_DontPrintText );
01725 }
01726 else
01727 {
01728 m_pStyle = m_pStyle->setProperty( Style::PDontPrintText );
01729 clearNoFallBackProperties( PDontPrintText);
01730 setFlag( Flag_DontPrintText );
01731 }
01732 formatChanged();
01733 }
01734
01735 void Format::setHideAll( bool _b )
01736 {
01737 if ( _b == false )
01738 {
01739 m_pStyle = m_pStyle->clearProperty( Style::PHideAll );
01740 setNoFallBackProperties(PHideAll);
01741 clearFlag( Flag_HideAll );
01742 }
01743 else
01744 {
01745 m_pStyle = m_pStyle->setProperty( Style::PHideAll );
01746 clearNoFallBackProperties( PHideAll);
01747 setFlag( Flag_HideAll );
01748 }
01749 formatChanged();
01750 }
01751
01752 void Format::setHideFormula( bool _b )
01753 {
01754 if ( _b == false )
01755 {
01756 m_pStyle = m_pStyle->clearProperty( Style::PHideFormula );
01757 setNoFallBackProperties( PHideFormula );
01758 clearFlag( Flag_HideFormula );
01759 }
01760 else
01761 {
01762 m_pStyle = m_pStyle->setProperty( Style::PHideFormula );
01763 clearNoFallBackProperties( PHideFormula );
01764 setFlag( Flag_HideFormula );
01765 }
01766 formatChanged();
01767 }
01768
01769 void Format::setCurrency( Currency const & c )
01770 {
01771 m_pStyle = m_pStyle->setCurrency( c );
01772 }
01773
01774 void Format::setCurrency( int type, QString const & symbol )
01775 {
01776 Currency c;
01777
01778 c.symbol = symbol.simplifyWhiteSpace();
01779 c.type = type;
01780
01781 if (c.symbol.length() == 0)
01782 {
01783 c.type = 0;
01784 c.symbol = sheet()->doc()->locale()->currencySymbol();
01785 }
01786
01787 m_pStyle = m_pStyle->setCurrency( c );
01788 }
01789
01791
01792
01793
01795
01796 QString const & Format::getFormatString( int col, int row ) const
01797 {
01798 if ( !hasProperty( PCustomFormat, false ) && !hasNoFallBackProperties( PCustomFormat ))
01799 {
01800 const Format * l = fallbackFormat( col, row );
01801 if ( l )
01802 return l->getFormatString( col, row );
01803 }
01804 return m_pStyle->strFormat();
01805 }
01806
01807 QString Format::prefix( int col, int row ) const
01808 {
01809 if ( !hasProperty( PPrefix, false ) && !hasNoFallBackProperties(PPrefix ))
01810 {
01811 const Format * l = fallbackFormat( col, row );
01812 if ( l )
01813 return l->prefix( col, row );
01814 }
01815 return m_pStyle->prefix();
01816 }
01817
01818 QString Format::postfix( int col, int row ) const
01819 {
01820 if ( !hasProperty( PPostfix, false ) && !hasNoFallBackProperties(PPostfix ))
01821 {
01822 const Format * l = fallbackFormat( col, row );
01823 if ( l )
01824 return l->postfix( col, row );
01825 }
01826 return m_pStyle->postfix();
01827 }
01828
01829 const QPen& Format::fallDiagonalPen( int col, int row ) const
01830 {
01831 if ( !hasProperty( PFallDiagonal, false ) && !hasNoFallBackProperties(PFallDiagonal ))
01832 {
01833 const Format* l = fallbackFormat( col, row );
01834 if ( l )
01835 return l->fallDiagonalPen( col, row );
01836 }
01837 return m_pStyle->fallDiagonalPen();
01838 }
01839
01840 int Format::fallDiagonalWidth( int col, int row ) const
01841 {
01842 return fallDiagonalPen( col, row ).width();
01843 }
01844
01845 Qt::PenStyle Format::fallDiagonalStyle( int col, int row ) const
01846 {
01847 return fallDiagonalPen( col, row ).style();
01848 }
01849
01850 const QColor & Format::fallDiagonalColor( int col, int row ) const
01851 {
01852 return fallDiagonalPen( col, row ).color();
01853 }
01854
01855 const QPen & Format::goUpDiagonalPen( int col, int row ) const
01856 {
01857 if ( !hasProperty( PGoUpDiagonal, false ) && !hasNoFallBackProperties( PGoUpDiagonal ) )
01858 {
01859 const Format* l = fallbackFormat( col, row );
01860 if ( l )
01861 return l->goUpDiagonalPen( col, row );
01862 }
01863 return m_pStyle->goUpDiagonalPen();
01864 }
01865
01866 int Format::goUpDiagonalWidth( int col, int row ) const
01867 {
01868 return goUpDiagonalPen( col, row ).width();
01869 }
01870
01871 Qt::PenStyle Format::goUpDiagonalStyle( int col, int row ) const
01872 {
01873 return goUpDiagonalPen( col, row ).style();
01874 }
01875
01876 const QColor& Format::goUpDiagonalColor( int col, int row ) const
01877 {
01878 return goUpDiagonalPen( col, row ).color();
01879 }
01880
01881 uint Format::bottomBorderValue( int col, int row ) const
01882 {
01883 if ( !hasProperty( PBottomBorder, false ) && !hasNoFallBackProperties( PBottomBorder ) )
01884 {
01885 const Format * l = fallbackFormat( col, row );
01886 if ( l )
01887 return l->bottomBorderValue( col, row );
01888
01889 return 0;
01890 }
01891
01892 return m_pStyle->bottomPenValue();
01893 }
01894
01895 uint Format::rightBorderValue( int col, int row ) const
01896 {
01897 if ( !hasProperty( PRightBorder, false ) && !hasNoFallBackProperties( PRightBorder ) )
01898 {
01899 const Format * l = fallbackFormat( col, row );
01900 if ( l )
01901 return l->rightBorderValue( col, row );
01902
01903 return 0;
01904 }
01905
01906 return m_pStyle->rightPenValue();
01907 }
01908
01909 uint Format::leftBorderValue( int col, int row ) const
01910 {
01911 if ( !hasProperty( PLeftBorder, false ) && !hasNoFallBackProperties( PLeftBorder ) )
01912 {
01913 const Format * l = fallbackFormat( col, row );
01914 if ( l )
01915 return l->leftBorderValue( col, row );
01916
01917 return 0;
01918 }
01919
01920 return m_pStyle->leftPenValue();
01921 }
01922
01923 uint Format::topBorderValue( int col, int row ) const
01924 {
01925 if ( !hasProperty( PTopBorder, false ) && !hasNoFallBackProperties( PTopBorder ) )
01926 {
01927 const Format * l = fallbackFormat( col, row );
01928 if ( l )
01929 return l->topBorderValue( col, row );
01930
01931 return 0;
01932 }
01933
01934 return m_pStyle->topPenValue();
01935 }
01936
01937 const QPen& Format::leftBorderPen( int col, int row ) const
01938 {
01939 if ( !hasProperty( PLeftBorder, false ) && !hasNoFallBackProperties( PLeftBorder ) )
01940 {
01941 const Format * l = fallbackFormat( col, row );
01942 if ( l )
01943 return l->leftBorderPen( col, row );
01944 return sheet()->emptyPen();
01945 }
01946
01947 return m_pStyle->leftBorderPen();
01948 }
01949
01950 Qt::PenStyle Format::leftBorderStyle( int col, int row ) const
01951 {
01952 return leftBorderPen( col, row ).style();
01953 }
01954
01955 const QColor& Format::leftBorderColor( int col, int row ) const
01956 {
01957 return leftBorderPen( col, row ).color();
01958 }
01959
01960 int Format::leftBorderWidth( int col, int row ) const
01961 {
01962 return leftBorderPen( col, row ).width();
01963 }
01964
01965 const QPen& Format::topBorderPen( int col, int row ) const
01966 {
01967 if ( !hasProperty( PTopBorder, false ) && !hasNoFallBackProperties( PTopBorder ) )
01968 {
01969 const Format* l = fallbackFormat( col, row );
01970 if ( l )
01971 return l->topBorderPen( col, row );
01972 return sheet()->emptyPen();
01973 }
01974
01975 return m_pStyle->topBorderPen();
01976 }
01977
01978 const QColor& Format::topBorderColor( int col, int row ) const
01979 {
01980 return topBorderPen( col, row ).color();
01981 }
01982
01983 Qt::PenStyle Format::topBorderStyle( int col, int row ) const
01984 {
01985 return topBorderPen( col, row ).style();
01986 }
01987
01988 int Format::topBorderWidth( int col, int row ) const
01989 {
01990 return topBorderPen( col, row ).width();
01991 }
01992
01993 const QPen& Format::rightBorderPen( int col, int row ) const
01994 {
01995 if ( !hasProperty( PRightBorder, false ) && !hasNoFallBackProperties( PRightBorder ) )
01996 {
01997 const Format * l = fallbackFormat( col, row );
01998 if ( l )
01999 return l->rightBorderPen( col, row );
02000 return sheet()->emptyPen();
02001 }
02002
02003 return m_pStyle->rightBorderPen();
02004 }
02005
02006 int Format::rightBorderWidth( int col, int row ) const
02007 {
02008 return rightBorderPen( col, row ).width();
02009 }
02010
02011 Qt::PenStyle Format::rightBorderStyle( int col, int row ) const
02012 {
02013 return rightBorderPen( col, row ).style();
02014 }
02015
02016 const QColor& Format::rightBorderColor( int col, int row ) const
02017 {
02018 return rightBorderPen( col, row ).color();
02019 }
02020
02021 const QPen& Format::bottomBorderPen( int col, int row ) const
02022 {
02023 if ( !hasProperty( PBottomBorder, false )&& !hasNoFallBackProperties( PBottomBorder ) )
02024 {
02025 const Format * l = fallbackFormat( col, row );
02026 if ( l )
02027 return l->bottomBorderPen( col, row );
02028 return sheet()->emptyPen();
02029 }
02030
02031 return m_pStyle->bottomBorderPen();
02032 }
02033
02034 int Format::bottomBorderWidth( int col, int row ) const
02035 {
02036 return bottomBorderPen( col, row ).width();
02037 }
02038
02039 Qt::PenStyle Format::bottomBorderStyle( int col, int row ) const
02040 {
02041 return bottomBorderPen( col, row ).style();
02042 }
02043
02044 const QColor& Format::bottomBorderColor( int col, int row ) const
02045 {
02046 return bottomBorderPen( col, row ).color();
02047 }
02048
02049 const QBrush& Format::backGroundBrush( int col, int row ) const
02050 {
02051 if ( !hasProperty( PBackgroundBrush, false ) && !hasNoFallBackProperties(PBackgroundBrush ))
02052 {
02053 const Format* l = fallbackFormat( col, row );
02054 if ( l )
02055 return l->backGroundBrush( col, row );
02056 }
02057 return m_pStyle->backGroundBrush();
02058 }
02059
02060 Qt::BrushStyle Format::backGroundBrushStyle( int col, int row ) const
02061 {
02062 return backGroundBrush( col, row ).style();
02063 }
02064
02065 const QColor& Format::backGroundBrushColor( int col, int row ) const
02066 {
02067 return backGroundBrush( col, row ).color();
02068 }
02069
02070 int Format::precision( int col, int row ) const
02071 {
02072 if ( !hasProperty( PPrecision, false )&& !hasNoFallBackProperties( PPrecision ) )
02073 {
02074 const Format * l = fallbackFormat( col, row );
02075 if ( l )
02076 return l->precision( col, row );
02077 }
02078 return m_pStyle->precision();
02079 }
02080
02081 Format::FloatFormat Format::floatFormat( int col, int row ) const
02082 {
02083 if ( !hasProperty( PFloatFormat, false ) && !hasNoFallBackProperties( PFloatFormat ) )
02084 {
02085 const Format * l = fallbackFormat( col, row );
02086 if ( l )
02087 return l->floatFormat( col, row );
02088 }
02089 return m_pStyle->floatFormat();
02090 }
02091
02092 Format::FloatColor Format::floatColor( int col, int row ) const
02093 {
02094 if ( !hasProperty( PFloatColor, false ) && !hasNoFallBackProperties( PFloatColor ) )
02095 {
02096 const Format * l = fallbackFormat( col, row );
02097 if ( l )
02098 return l->floatColor( col, row );
02099 }
02100 return m_pStyle->floatColor();
02101 }
02102
02103 const QColor& Format::bgColor( int col, int row ) const
02104 {
02105 if ( !hasProperty( PBackgroundColor, false ) && !hasNoFallBackProperties( PBackgroundColor ) )
02106 {
02107 const Format * l = fallbackFormat( col, row );
02108 if ( l )
02109 return l->bgColor( col, row );
02110 }
02111
02112 return m_pStyle->bgColor();
02113 }
02114
02115 const QPen& Format::textPen( int col, int row ) const
02116 {
02117 if ( !hasProperty( PTextPen, false ) && !hasNoFallBackProperties( PTextPen ) )
02118 {
02119 const Format * l = fallbackFormat( col, row );
02120 if ( l )
02121 return l->textPen( col, row );
02122 }
02123 return m_pStyle->pen();
02124 }
02125
02126 const QColor& Format::textColor( int col, int row ) const
02127 {
02128 return textPen( col, row ).color();
02129 }
02130
02131 const QFont Format::textFont( int col, int row ) const
02132 {
02133 if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
02134 {
02135 const Format * l = fallbackFormat( col, row );
02136 if ( l )
02137 return l->textFont( col, row );
02138 }
02139
02140 return m_pStyle->font();
02141 }
02142
02143 int Format::textFontSize( int col, int row ) const
02144 {
02145 if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
02146 {
02147 const Format * l = fallbackFormat( col, row );
02148 if ( l )
02149 return l->textFontSize( col, row );
02150 }
02151
02152 return m_pStyle->fontSize();
02153 }
02154
02155 QString const & Format::textFontFamily( int col, int row ) const
02156 {
02157 if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
02158 {
02159 const Format * l = fallbackFormat( col, row );
02160 if ( l )
02161 return l->textFontFamily( col, row );
02162 }
02163
02164 return m_pStyle->fontFamily();
02165 }
02166
02167 bool Format::textFontBold( int col, int row ) const
02168 {
02169 if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
02170 {
02171 const Format * l = fallbackFormat( col, row );
02172 if ( l )
02173 return l->textFontBold( col, row );
02174 }
02175
02176 return ( m_pStyle->fontFlags() & Style::FBold );
02177 }
02178
02179 bool Format::textFontItalic( int col, int row ) const
02180 {
02181 if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
02182 {
02183 const Format * l = fallbackFormat( col, row );
02184 if ( l )
02185 return l->textFontItalic( col, row );
02186 }
02187
02188 return ( m_pStyle->fontFlags() & Style::FItalic );
02189 }
02190
02191 bool Format::textFontUnderline( int col, int row ) const
02192 {
02193 if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
02194 {
02195 const Format * l = fallbackFormat( col, row );
02196 if ( l )
02197 return l->textFontUnderline( col, row );
02198 }
02199
02200 return ( m_pStyle->fontFlags() & Style::FUnderline );
02201 }
02202
02203 bool Format::textFontStrike( int col, int row ) const
02204 {
02205 if ( !hasProperty( PFont, false ) && !hasNoFallBackProperties( PFont ) )
02206 {
02207 const Format * l = fallbackFormat( col, row );
02208 if ( l )
02209 return l->textFontStrike( col, row );
02210 }
02211
02212 return ( m_pStyle->fontFlags() & Style::FStrike );
02213 }
02214
02215 Format::Align Format::align( int col, int row ) const
02216 {
02217 if ( !hasProperty( PAlign, false ) && !hasNoFallBackProperties( PAlign ) )
02218 {
02219 const Format * l = fallbackFormat( col, row );
02220 if ( l )
02221 return l->align( col, row );
02222 }
02223
02224 return m_pStyle->alignX();
02225 }
02226
02227 Format::AlignY Format::alignY( int col, int row ) const
02228 {
02229 if ( !hasProperty( PAlignY, false )&& !hasNoFallBackProperties( PAlignY ) )
02230 {
02231 const Format * l = fallbackFormat( col, row );
02232 if ( l )
02233 return l->alignY( col, row );
02234 }
02235
02236 return m_pStyle->alignY();
02237 }
02238
02239 bool Format::multiRow( int col, int row ) const
02240 {
02241 if ( !hasProperty( PMultiRow, false ) && !hasNoFallBackProperties( PMultiRow ) )
02242 {
02243 const Format * l = fallbackFormat( col, row );
02244 if ( l )
02245 return l->multiRow( col, row );
02246 }
02247
02248 return m_pStyle->hasProperty( Style::PMultiRow );
02249 }
02250
02251 bool Format::verticalText( int col, int row ) const
02252 {
02253 if ( !hasProperty( PVerticalText, false )&& !hasNoFallBackProperties( PVerticalText ) )
02254 {
02255 const Format * l = fallbackFormat( col, row );
02256 if ( l )
02257 return l->verticalText( col, row );
02258 }
02259
02260 return m_pStyle->hasProperty( Style::PVerticalText );
02261 }
02262
02263 FormatType Format::getFormatType( int col, int row ) const
02264 {
02265 if ( !hasProperty( PFormatType, false ) && !hasNoFallBackProperties( PFormatType ) )
02266 {
02267 const Format* l = fallbackFormat( col, row );
02268 if ( l )
02269 return l->getFormatType( col, row );
02270 }
02271
02272 return m_pStyle->formatType();
02273 }
02274
02275 int Format::getAngle( int col, int row ) const
02276 {
02277 if ( !hasProperty( PAngle, false ) && !hasNoFallBackProperties( PAngle ) )
02278 {
02279 const Format* l = fallbackFormat( col, row );
02280 if ( l )
02281 return l->getAngle( col, row );
02282 }
02283
02284 return m_pStyle->rotateAngle();
02285 }
02286
02287 QString Format::comment( int col, int row ) const
02288 {
02289 if ( !hasProperty( PComment, false ) && !hasNoFallBackProperties( PComment ))
02290 {
02291 const Format* l = fallbackFormat( col, row );
02292 if ( l )
02293 return l->comment( col, row );
02294 }
02295
02296 if ( !m_strComment )
02297 return QString::null;
02298
02299
02300 return *m_strComment;
02301 }
02302
02303 QString * Format::commentP( int col, int row ) const
02304 {
02305 if ( !hasProperty( PComment, false ) && !hasNoFallBackProperties( PComment ))
02306 {
02307 const Format* l = fallbackFormat( col, row );
02308 if ( l )
02309 return l->commentP( col, row );
02310 }
02311
02312 return m_strComment;
02313 }
02314
02315 double Format::getIndent( int col, int row ) const
02316 {
02317 if ( !hasProperty( PIndent, false ) && !hasNoFallBackProperties( PIndent ) )
02318 {
02319 const Format* l = fallbackFormat( col, row );
02320 if ( l )
02321 return l->getIndent( col, row );
02322 }
02323
02324 return m_pStyle->indent();
02325 }
02326
02327 bool Format::getDontprintText( int col, int row ) const
02328 {
02329 if ( !hasProperty( PDontPrintText, false )&& !hasNoFallBackProperties( PDontPrintText ) )
02330 {
02331 const Format* l = fallbackFormat( col, row );
02332 if ( l )
02333 return l->getDontprintText( col, row );
02334 }
02335
02336 return m_pStyle->hasProperty( Style::PDontPrintText );
02337 }
02338
02339 bool Format::isProtected( int col, int row ) const
02340 {
02341 return ( m_pSheet->isProtected() && !notProtected( col, row ) );
02342 }
02343
02344
02345 bool Format::notProtected( int col, int row) const
02346 {
02347 if ( !hasProperty( PNotProtected, false )&& !hasNoFallBackProperties( PNotProtected ) )
02348 {
02349 const Format * l = fallbackFormat( col, row );
02350 if ( l )
02351 return l->notProtected( col, row );
02352 }
02353
02354 return m_pStyle->hasProperty( Style::PNotProtected );
02355 }
02356
02357 bool Format::isHideAll( int col, int row) const
02358 {
02359 if ( !hasProperty( PHideAll, false )&& !hasNoFallBackProperties( PHideAll ) )
02360 {
02361 const Format * l = fallbackFormat( col, row );
02362 if ( l )
02363 return l->isHideAll( col, row );
02364 }
02365
02366 return m_pStyle->hasProperty( Style::PHideAll );
02367 }
02368
02369 bool Format::isHideFormula( int col, int row) const
02370 {
02371 if ( !hasProperty( PHideFormula, false )&& !hasNoFallBackProperties( PHideFormula ) )
02372 {
02373 const Format * l = fallbackFormat( col, row );
02374 if ( l )
02375 return l->isHideFormula( col, row );
02376 }
02377
02378 return m_pStyle->hasProperty( Style::PHideFormula );
02379 }
02380
02381 bool Format::currencyInfo( Currency & currency) const
02382 {
02383
02384 if ( m_pStyle->formatType() != Money_format )
02385 return false;
02386
02387 currency.symbol = m_pStyle->currency().symbol;
02388 currency.type = m_pStyle->currency().type;
02389
02390 return true;
02391 }
02392
02393 QString Format::getCurrencySymbol() const
02394 {
02395
02396 return m_pStyle->currency().symbol;
02397 }
02398
02399 QFont Format::font() const
02400 {
02401 return m_pStyle->font();
02402 }
02403
02404
02406
02407
02408
02410
02411 const QPen & Format::leftBorderPen() const
02412 {
02413 return m_pStyle->leftBorderPen();
02414 }
02415
02416 const QPen & Format::topBorderPen() const
02417 {
02418 return m_pStyle->topBorderPen();
02419 }
02420
02421 const QPen & Format::rightBorderPen() const
02422 {
02423 return m_pStyle->rightBorderPen();
02424 }
02425
02426 const QPen & Format::bottomBorderPen() const
02427 {
02428 return m_pStyle->bottomBorderPen();
02429 }
02430
02431 const QPen & Format::fallDiagonalPen() const
02432 {
02433 return m_pStyle->fallDiagonalPen();
02434 }
02435
02436 const QPen & Format::goUpDiagonalPen() const
02437 {
02438 return m_pStyle->goUpDiagonalPen();
02439 }
02440
02441 const QBrush & Format::backGroundBrush() const
02442 {
02443 return m_pStyle->backGroundBrush();
02444 }
02445
02446 const QFont Format::textFont() const
02447 {
02448 return m_pStyle->font();
02449 }
02450
02451 const QPen & Format::textPen() const
02452 {
02453 return m_pStyle->pen();
02454 }
02455
02457
02458
02459
02461
02462 void Format::formatChanged()
02463 {
02464 if (m_pCell)
02465 {
02466 m_pCell->setFlag(Cell::Flag_LayoutDirty);
02467 m_pCell->setFlag(Cell::Flag_TextFormatDirty);
02468 }
02469 }
02470
02471 Format* Format::fallbackFormat( int, int row )
02472 {
02473 return m_pCell ? m_pSheet->rowFormat( row ) : 0;
02474 }
02475
02476 const Format* Format::fallbackFormat( int, int row ) const
02477 {
02478 return m_pCell ? m_pSheet->rowFormat( row ) : 0;
02479 }
02480
02481 bool Format::isDefault() const
02482 {
02483
02484
02485 if ( ( m_mask & PComment ) && m_strComment != 0 )
02486 return false;
02487 #if 0 // These are copied in Style.
02488 if ( m_mask )
02489 return false;
02490 if ( m_flagsMask != 0 )
02491 return false;
02492 #endif
02493 if ( m_bNoFallBack != 0 )
02494 return false;
02495 return ( *m_pStyle == *m_pSheet->doc()->styleManager()->defaultStyle() );
02496 }
02497
02498 bool Format::operator==( const Format& other ) const
02499 {
02500
02501
02502 if ( ( m_mask & other.m_mask & PComment ) && m_strComment != other.m_strComment )
02503 return false;
02504 #if 0 // These are copied in Style.
02505 if ( m_mask != other.m_mask )
02506 return false;
02507 if ( m_flagsMask != other.m_flagsMask )
02508 return false;
02509 #endif
02510 if ( m_bNoFallBack != other.m_bNoFallBack )
02511 return false;
02512 return ( *m_pStyle == *other.m_pStyle );
02513 }
02514
02515
02516
02517
02518
02519
02520
02521
02522
02523
02524 RowFormat::RowFormat( Sheet * _sheet, int _row )
02525 : Format( _sheet, _sheet->doc()->styleManager()->defaultStyle() )
02526 {
02527 m_next = 0;
02528 m_prev = 0;
02529
02530 m_bDisplayDirtyFlag = false;
02531 m_fHeight = s_rowHeight;
02532 m_iRow = _row;
02533 m_bDefault = false;
02534 m_bHide = false;
02535 m_dcop = 0L;
02536 }
02537
02538 RowFormat::~RowFormat()
02539 {
02540 if ( m_next )
02541 m_next->setPrevious( m_prev );
02542 if ( m_prev )
02543 m_prev->setNext( m_next );
02544 delete m_dcop;
02545 }
02546
02547 DCOPObject * RowFormat::dcopObject()
02548 {
02549 if ( !m_dcop )
02550 m_dcop = new RowIface( this );
02551 return m_dcop;
02552 }
02553
02554
02555 void RowFormat::setMMHeight( double _h )
02556 {
02557 setDblHeight( MM_TO_POINT ( _h ) );
02558 }
02559
02560 void RowFormat::setHeight( int _h, const Canvas * _canvas )
02561 {
02562 setDblHeight( (double) _h, _canvas );
02563 }
02564
02565 void RowFormat::setDblHeight( double _h, const Canvas * _canvas )
02566 {
02567 Sheet *_sheet = _canvas ? _canvas->activeSheet() : m_pSheet;
02568
02569
02570 if ( kAbs( _h - dblHeight( _canvas ) ) < DBL_EPSILON )
02571 return;
02572
02573
02574
02575
02576 _sheet->adjustSizeMaxY ( - dblHeight() );
02577
02578 if ( _canvas )
02579 m_fHeight = ( _h / _canvas->zoom() );
02580 else
02581 m_fHeight = _h;
02582
02583
02584 _sheet->adjustSizeMaxY ( dblHeight() );
02585 _sheet->print()->updatePrintRepeatRowsHeight();
02586 _sheet->print()->updateNewPageListY ( row() );
02587
02588 _sheet->emit_updateRow(this,m_iRow);
02589
02590 }
02591
02592 int RowFormat::height( const Canvas *_canvas ) const
02593 {
02594 return (int) dblHeight( _canvas );
02595 }
02596
02597 double RowFormat::dblHeight( const Canvas *_canvas ) const
02598 {
02599 if( m_bHide )
02600 return 0.0;
02601
02602 if ( _canvas )
02603 return _canvas->zoom() * (m_iRow == 0) ? s_rowHeight : m_fHeight;
02604 else
02605 return (m_iRow == 0) ? s_rowHeight : m_fHeight;
02606 }
02607
02608 double RowFormat::mmHeight() const
02609 {
02610 return POINT_TO_MM ( dblHeight() );
02611 }
02612
02613 QDomElement RowFormat::save( QDomDocument& doc, int yshift, bool copy ) const
02614 {
02615 QDomElement row = doc.createElement( "row" );
02616 row.setAttribute( "height", m_fHeight );
02617 row.setAttribute( "row", m_iRow - yshift );
02618 if( m_bHide )
02619 row.setAttribute( "hide", (int) m_bHide );
02620
02621 QDomElement format( saveFormat( doc, false, copy ) );
02622 row.appendChild( format );
02623 return row;
02624 }
02625
02626 #if 0
02627 bool RowFormat::loadOasis( const QDomElement& , QDomElement * )
02628 {
02629 return true;
02630 }
02631 #endif
02632
02633 bool RowFormat::load( const QDomElement & row, int yshift, Paste::Mode sp, bool paste )
02634 {
02635 bool ok;
02636
02637 m_iRow = row.attribute( "row" ).toInt( &ok ) + yshift;
02638 if ( !ok )
02639 return false;
02640
02641 if ( row.hasAttribute( "height" ) )
02642 {
02643 if ( m_pSheet->doc()->syntaxVersion() < 1 )
02644 m_fHeight = qRound( MM_TO_POINT( row.attribute( "height" ).toDouble( &ok ) ) );
02645 else
02646 m_fHeight = row.attribute( "height" ).toDouble( &ok );
02647
02648 if ( !ok ) return false;
02649 }
02650
02651
02652 if ( m_fHeight < 0 )
02653 {
02654 kdDebug(36001) << "Value height=" << m_fHeight << " out of range" << endl;
02655 return false;
02656 }
02657 if ( m_iRow < 1 || m_iRow > KS_rowMax )
02658 {
02659 kdDebug(36001) << "Value row=" << m_iRow << " out of range" << endl;
02660 return false;
02661 }
02662
02663 if ( row.hasAttribute( "hide" ) )
02664 {
02665 setHide( (int) row.attribute( "hide" ).toInt( &ok ) );
02666 if ( !ok )
02667 return false;
02668 }
02669
02670 QDomElement f( row.namedItem( "format" ).toElement() );
02671
02672 if ( !f.isNull() && ( sp == Paste::Normal || sp == Paste::Format || sp == Paste::NoBorder ) )
02673 {
02674 if ( !loadFormat( f, sp, paste ) )
02675 return false;
02676 return true;
02677 }
02678
02679 return true;
02680 }
02681
02682 const QPen & RowFormat::topBorderPen( int _col, int _row ) const
02683 {
02684
02685 if ( !hasProperty( PTopBorder, false ) )
02686 {
02687 const RowFormat * rl = sheet()->rowFormat( _row - 1 );
02688 if ( rl->hasProperty( PBottomBorder ) )
02689 return rl->bottomBorderPen( _col, _row - 1 );
02690 }
02691
02692 return Format::topBorderPen( _col, _row );
02693 }
02694
02695 void RowFormat::setTopBorderPen( const QPen & p )
02696 {
02697 RowFormat * cl = sheet()->nonDefaultRowFormat( row() - 1, false );
02698 if ( cl )
02699 cl->clearProperty( PBottomBorder );
02700
02701 Format::setTopBorderPen( p );
02702 }
02703
02704 const QPen & RowFormat::bottomBorderPen( int _col, int _row ) const
02705 {
02706
02707 if ( !hasProperty( PBottomBorder, false ) && ( _row < KS_rowMax ) )
02708 {
02709 const RowFormat * rl = sheet()->rowFormat( _row + 1 );
02710 if ( rl->hasProperty( PTopBorder ) )
02711 return rl->topBorderPen( _col, _row + 1 );
02712 }
02713
02714 return Format::bottomBorderPen( _col, _row );
02715 }
02716
02717 void RowFormat::setBottomBorderPen( const QPen & p )
02718 {
02719 if ( row() < KS_rowMax )
02720 {
02721 RowFormat * cl = sheet()->nonDefaultRowFormat( row() + 1, false );
02722 if ( cl )
02723 cl->clearProperty( PTopBorder );
02724 }
02725
02726 Format::setBottomBorderPen( p );
02727 }
02728
02729 void RowFormat::setHide( bool _hide, bool repaint )
02730 {
02731 if ( _hide != m_bHide )
02732 {
02733 if ( _hide )
02734 {
02735
02736 m_pSheet->adjustSizeMaxY ( - dblHeight() );
02737 m_bHide = _hide;
02738 m_pSheet->emit_updateRow( this, m_iRow, repaint );
02739 }
02740 else
02741 {
02742
02743 m_bHide = _hide;
02744 m_pSheet->adjustSizeMaxY ( dblHeight() );
02745 m_pSheet->emit_updateRow( this, m_iRow, repaint );
02746 }
02747 }
02748 }
02749
02750 Format* RowFormat::fallbackFormat( int col, int )
02751 {
02752 return sheet()->columnFormat( col );
02753 }
02754
02755 const Format* RowFormat::fallbackFormat( int col, int ) const
02756 {
02757 return sheet()->columnFormat( col );
02758 }
02759
02760 bool RowFormat::isDefault() const
02761 {
02762 if ( m_fHeight != s_rowHeight )
02763 return false;
02764 if ( m_bHide == true )
02765 return false;
02766 return Format::isDefault();
02767 }
02768
02769 bool RowFormat::operator==( const RowFormat& other ) const
02770 {
02771
02772 if ( m_fHeight != other.m_fHeight )
02773 return false;
02774 if ( m_bHide != other.m_bHide )
02775 return false;
02776 return Format::operator==( other );
02777 }
02778
02779
02780
02781
02782
02783
02784
02785 #undef UPDATE_BEGIN
02786 #undef UPDATE_END
02787
02788 #define UPDATE_BEGIN bool b_update_begin = m_bDisplayDirtyFlag; m_bDisplayDirtyFlag = true;
02789 #define UPDATE_END if ( !b_update_begin && m_bDisplayDirtyFlag ) m_pSheet->emit_updateColumn( this, m_iColumn );
02790
02791 ColumnFormat::ColumnFormat( Sheet * _sheet, int _column )
02792 : Format( _sheet, _sheet->doc()->styleManager()->defaultStyle() )
02793 {
02794 m_bDisplayDirtyFlag = false;
02795 m_fWidth = s_columnWidth;
02796 m_iColumn = _column;
02797 m_bDefault=false;
02798 m_bHide=false;
02799 m_prev = 0;
02800 m_next = 0;
02801 m_dcop = 0;
02802 }
02803
02804 ColumnFormat::~ColumnFormat()
02805 {
02806 if ( m_next )
02807 m_next->setPrevious( m_prev );
02808 if ( m_prev )
02809 m_prev->setNext( m_next );
02810 delete m_dcop;
02811 }
02812
02813 DCOPObject * ColumnFormat::dcopObject()
02814 {
02815 if ( !m_dcop )
02816 m_dcop = new ColumnIface( this );
02817 return m_dcop;
02818 }
02819
02820 void ColumnFormat::setMMWidth( double _w )
02821 {
02822 setDblWidth( MM_TO_POINT ( _w ) );
02823 }
02824
02825 void ColumnFormat::setWidth( int _w, const Canvas * _canvas )
02826 {
02827 setDblWidth( (double)_w, _canvas );
02828 }
02829
02830 void ColumnFormat::setDblWidth( double _w, const Canvas * _canvas )
02831 {
02832 Sheet *_sheet = _canvas ? _canvas->activeSheet() : m_pSheet;
02833
02834
02835 if ( kAbs( _w - dblWidth( _canvas ) ) < DBL_EPSILON )
02836 return;
02837
02838
02839
02840
02841 _sheet->adjustSizeMaxX ( - dblWidth() );
02842
02843 if ( _canvas )
02844 m_fWidth = ( _w / _canvas->zoom() );
02845 else
02846 m_fWidth = _w;
02847
02848
02849 _sheet->adjustSizeMaxX ( dblWidth() );
02850 _sheet->print()->updatePrintRepeatColumnsWidth();
02851 _sheet->print()->updateNewPageListX ( column() );
02852
02853 _sheet->emit_updateColumn(this,m_iColumn);
02854
02855 }
02856
02857 int ColumnFormat::width( const Canvas * _canvas ) const
02858 {
02859 return (int) dblWidth( _canvas );
02860 }
02861
02862 double ColumnFormat::dblWidth( const Canvas * _canvas ) const
02863 {
02864 if ( m_bHide )
02865 return 0.0;
02866
02867 if ( _canvas )
02868 return _canvas->zoom() * (m_iColumn == 0) ? s_columnWidth : m_fWidth;
02869 else
02870 return (m_iColumn == 0) ? s_columnWidth : m_fWidth;
02871 }
02872
02873 double ColumnFormat::mmWidth() const
02874 {
02875 return POINT_TO_MM( dblWidth() );
02876 }
02877
02878
02879 QDomElement ColumnFormat::save( QDomDocument& doc, int xshift, bool copy ) const
02880 {
02881 QDomElement col( doc.createElement( "column" ) );
02882 col.setAttribute( "width", m_fWidth );
02883 col.setAttribute( "column", m_iColumn - xshift );
02884
02885 if ( m_bHide )
02886 col.setAttribute( "hide", (int) m_bHide );
02887
02888 QDomElement format( saveFormat( doc, false, copy ) );
02889 col.appendChild( format );
02890
02891 return col;
02892 }
02893
02894 bool ColumnFormat::load( const QDomElement & col, int xshift, Paste::Mode sp, bool paste )
02895 {
02896 bool ok;
02897 if ( col.hasAttribute( "width" ) )
02898 {
02899 if ( m_pSheet->doc()->syntaxVersion() < 1 )
02900 m_fWidth = qRound( MM_TO_POINT ( col.attribute( "width" ).toDouble( &ok ) ) );
02901 else
02902 m_fWidth = col.attribute( "width" ).toDouble( &ok );
02903
02904 if ( !ok )
02905 return false;
02906 }
02907
02908 m_iColumn = col.attribute( "column" ).toInt( &ok ) + xshift;
02909
02910 if ( !ok )
02911 return false;
02912
02913
02914 if ( m_fWidth < 0 )
02915 {
02916 kdDebug(36001) << "Value width=" << m_fWidth << " out of range" << endl;
02917 return false;
02918 }
02919 if ( m_iColumn < 1 || m_iColumn > KS_colMax )
02920 {
02921 kdDebug(36001) << "Value col=" << m_iColumn << " out of range" << endl;
02922 return false;
02923 }
02924 if ( col.hasAttribute( "hide" ) )
02925 {
02926 setHide( (int) col.attribute( "hide" ).toInt( &ok ) );
02927 if ( !ok )
02928 return false;
02929 }
02930
02931 QDomElement f( col.namedItem( "format" ).toElement() );
02932
02933 if ( !f.isNull() && ( sp == Paste::Normal || sp == Paste::Format || sp == Paste::NoBorder ))
02934 {
02935 if ( !loadFormat( f, sp, paste ) )
02936 return false;
02937 return true;
02938 }
02939
02940 return true;
02941 }
02942
02943 const QPen & ColumnFormat::leftBorderPen( int _col, int _row ) const
02944 {
02945
02946 if ( !hasProperty( PLeftBorder, false ) )
02947 {
02948 const ColumnFormat * cl = sheet()->columnFormat( _col - 1 );
02949 if ( cl->hasProperty( PRightBorder ) )
02950 return cl->rightBorderPen( _col - 1, _row );
02951 }
02952
02953 return Format::leftBorderPen( _col, _row );
02954 }
02955
02956 void ColumnFormat::setLeftBorderPen( const QPen & p )
02957 {
02958 ColumnFormat * cl = sheet()->nonDefaultColumnFormat( column() - 1, false );
02959 if ( cl )
02960 cl->clearProperty( PRightBorder );
02961
02962 Format::setLeftBorderPen( p );
02963 }
02964
02965 const QPen & ColumnFormat::rightBorderPen( int _col, int _row ) const
02966 {
02967
02968 if ( !hasProperty( PRightBorder, false ) && ( _col < KS_colMax ) )
02969 {
02970 const ColumnFormat * cl = sheet()->columnFormat( _col + 1 );
02971 if ( cl->hasProperty( PLeftBorder ) )
02972 return cl->leftBorderPen( _col + 1, _row );
02973 }
02974
02975 return Format::rightBorderPen( _col, _row );
02976 }
02977
02978 void ColumnFormat::setRightBorderPen( const QPen & p )
02979 {
02980 if ( column() < KS_colMax )
02981 {
02982 ColumnFormat * cl = sheet()->nonDefaultColumnFormat( column() + 1, false );
02983 if ( cl )
02984 cl->clearProperty( PLeftBorder );
02985 }
02986
02987 Format::setRightBorderPen( p );
02988 }
02989
02990 Format * ColumnFormat::fallbackFormat( int, int )
02991 {
02992 return sheet()->defaultFormat();
02993 }
02994
02995 void ColumnFormat::setHide( bool _hide )
02996 {
02997 if ( _hide != m_bHide )
02998 {
02999 if ( _hide )
03000 {
03001
03002 m_pSheet->adjustSizeMaxX ( - dblWidth() );
03003 m_bHide = _hide;
03004
03005 }
03006 else
03007 {
03008
03009 m_bHide = _hide;
03010 m_pSheet->adjustSizeMaxX ( dblWidth() );
03011
03012 }
03013 }
03014 }
03015
03016 const Format * ColumnFormat::fallbackFormat( int, int ) const
03017 {
03018 return sheet()->defaultFormat();
03019 }
03020
03021 bool ColumnFormat::isDefault() const
03022 {
03023 if ( m_fWidth != s_columnWidth )
03024 return false;
03025 if ( m_bHide == true )
03026 return false;
03027 return Format::isDefault();
03028 }
03029
03030 bool ColumnFormat::operator==( const ColumnFormat& other ) const
03031 {
03032
03033 if ( m_fWidth != other.m_fWidth )
03034 return false;
03035 if ( m_bHide != other.m_bHide )
03036 return false;
03037 return Format::operator==( other );
03038 }
03039
03040
03041
03042 namespace Currency_LNS
03043 {
03044 typedef struct
03045 {
03046 char const * code;
03047 char const * country;
03048 char const * name;
03049 char const * display;
03050 } Money;
03051
03052
03053
03054
03055
03056
03057
03058
03059 static const Money lMoney[] = {
03060 { "", "", "", ""},
03061 { "", "", "", ""},
03062 { "$", "", "Dollar", "$" },
03063 { "$", I18N_NOOP("Australia"), I18N_NOOP("Dollar"), "$" },
03064 { "$", I18N_NOOP("Canada"), I18N_NOOP("Dollar"), "$" },
03065 { "$", I18N_NOOP("Caribbea"), I18N_NOOP("Dollar"), "$" },
03066 { "$", I18N_NOOP("New Zealand"), I18N_NOOP("Dollar"), "$" },
03067 { "$", I18N_NOOP("United States"), I18N_NOOP("Dollar"), "$" },
03068
03069
03070 { "€", "", "€", "€" },
03071 { "€", I18N_NOOP("Austria"), I18N_NOOP("Euro"), "€" },
03072 { "€", I18N_NOOP("Belgium"), I18N_NOOP("Euro"), "€" },
03073 { "€", I18N_NOOP("Finland"), I18N_NOOP("Euro"), "€" },
03074 { "€", I18N_NOOP("France"), I18N_NOOP("Euro"), "€" },
03075 { "€", I18N_NOOP("Germany"), I18N_NOOP("Euro"), "€" },
03076 { "€", I18N_NOOP("Greece"), I18N_NOOP("Euro"), "€" },
03077 { "€", I18N_NOOP("Ireland"), I18N_NOOP("Euro"), "€" },
03078 { "€", I18N_NOOP("Italy"), I18N_NOOP("Euro"), "€" },
03079 { "€", I18N_NOOP("Luxembourg"), I18N_NOOP("Euro"), "€" },
03080 { "€", I18N_NOOP("Monaco"), I18N_NOOP("Euro"), "€" },
03081 { "€", I18N_NOOP("Netherlands"), I18N_NOOP("Euro"), "€" },
03082 { "€", I18N_NOOP("Portugal"), I18N_NOOP("Euro"), "€" },
03083 { "€", I18N_NOOP("Spain"), I18N_NOOP("Euro"), "€" },
03084
03085 { "£", I18N_NOOP("United Kingdom"), I18N_NOOP("Pound"), "£" },
03086
03087 { "Â¥", I18N_NOOP("Japan"), I18N_NOOP("Yen"), "Â¥" },
03088
03089 { "AFA", I18N_NOOP("Afghanistan"), I18N_NOOP("Afghani"), I18N_NOOP("AFA") },
03090 { "ALL", I18N_NOOP("Albania"), I18N_NOOP("Lek"), I18N_NOOP("Lek") },
03091 { "DZD", I18N_NOOP("Algeria"), I18N_NOOP("Algerian Dinar"), I18N_NOOP("DZD") },
03092 { "USD", I18N_NOOP("American Samoa"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03093 { "EUR", I18N_NOOP("Andorra"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03094 { "ADP", I18N_NOOP("Andorra"), I18N_NOOP("Andorran Peseta"), I18N_NOOP("ADP") },
03095 { "AOA", I18N_NOOP("Angola"), I18N_NOOP("Kwanza"), I18N_NOOP("AOA") },
03096 { "XCD", I18N_NOOP("Anguilla"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("XCD") },
03097 { "XCD", I18N_NOOP("Antigua And Barbuda"), I18N_NOOP("East Carribean Dollar"), I18N_NOOP("XCD") },
03098 { "ARS", I18N_NOOP("Argentina"), I18N_NOOP("Argentine Peso"), I18N_NOOP("ARS") },
03099 { "AMD", I18N_NOOP("Armenia"), I18N_NOOP("Armenian Dram"), I18N_NOOP("AMD") },
03100 { "AWG", I18N_NOOP("Aruba"), I18N_NOOP("Aruban Guilder"), I18N_NOOP("AWG") },
03101 { "AUD", I18N_NOOP("Australia"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
03102 { "EUR", I18N_NOOP("Austria"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03103 { "ATS", I18N_NOOP("Austria"), I18N_NOOP("Schilling"), I18N_NOOP("S") },
03104 { "AZM", I18N_NOOP("Azerbaijan"), I18N_NOOP("Azerbaijanian Manat"), I18N_NOOP("AZM") },
03105 { "BSD", I18N_NOOP("Bahamas"), I18N_NOOP("Bahamian Dollar"), I18N_NOOP("BSD") },
03106 { "BHD", I18N_NOOP("Bahrain"), I18N_NOOP("Bahraini Dinar"), I18N_NOOP("BHD") },
03107 { "BDT", I18N_NOOP("Bangladesh"), I18N_NOOP("Taka"), I18N_NOOP("BDT") },
03108 { "BBD", I18N_NOOP("Barbados"), I18N_NOOP("Barbados Dollar"), I18N_NOOP("BBD") },
03109 { "BYR", I18N_NOOP("Belarus"), I18N_NOOP("Belarussian Ruble"), I18N_NOOP("p.") },
03110 { "EUR", I18N_NOOP("Belgium"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03111 { "BEF", I18N_NOOP("Belgium"), I18N_NOOP("Franc"), I18N_NOOP("BF") },
03112 { "BZD", I18N_NOOP("Belize"), I18N_NOOP("Belize Dollar"), I18N_NOOP("BZ$") },
03113 { "XOF", I18N_NOOP("Benin"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
03114 { "BMD", I18N_NOOP("Bermuda"), I18N_NOOP("Bermudian Dollar"), I18N_NOOP("BMD") },
03115 { "INR", I18N_NOOP("Bhutan"), I18N_NOOP("Indian Rupee"), I18N_NOOP("INR") },
03116 { "BTN", I18N_NOOP("Bhutan"), I18N_NOOP("Ngultrum"), I18N_NOOP("BTN") },
03117 { "BOB", I18N_NOOP("Bolivia"), I18N_NOOP("Boliviano"), I18N_NOOP("Bs") },
03118 { "BOV", I18N_NOOP("Bolivia"), I18N_NOOP("Mvdol"), I18N_NOOP("BOV") },
03119 { "BAM", I18N_NOOP("Bosnia And Herzegovina"), I18N_NOOP("Convertible Marks"), I18N_NOOP("BAM") },
03120 { "BWP", I18N_NOOP("Botswana"), I18N_NOOP("Pula"), I18N_NOOP("BWP") },
03121 { "NOK", I18N_NOOP("Bouvet Island"), I18N_NOOP("Norvegian Krone"), I18N_NOOP("NOK") },
03122 { "BRL", I18N_NOOP("Brazil"), I18N_NOOP("Brazilian Real"), I18N_NOOP("R$") },
03123 { "USD", I18N_NOOP("British Indian Ocean Territory"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03124 { "BND", I18N_NOOP("Brunei Darussalam"), I18N_NOOP("Brunei Dollar"), I18N_NOOP("BND") },
03125 { "BGL", I18N_NOOP("Bulgaria"), I18N_NOOP("Lev"), I18N_NOOP("BGL") },
03126 { "BGN", I18N_NOOP("Bulgaria"), I18N_NOOP("Bulgarian Lev"), I18N_NOOP("BGN") },
03127 { "XOF", I18N_NOOP("Burkina Faso"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
03128 { "BIF", I18N_NOOP("Burundi"), I18N_NOOP("Burundi Franc"), I18N_NOOP("BIF") },
03129 { "KHR", I18N_NOOP("Cambodia"), I18N_NOOP("Riel"), I18N_NOOP("KHR") },
03130 { "XAF", I18N_NOOP("Cameroon"), I18N_NOOP("CFA Franc BEAC"), I18N_NOOP("XAF") },
03131 { "CAD", I18N_NOOP("Canada"), I18N_NOOP("Canadian Dollar"), I18N_NOOP("CAD") },
03132 { "CVE", I18N_NOOP("Cape Verde"), I18N_NOOP("Cape Verde Escudo"), I18N_NOOP("CVE") },
03133 { "KYD", I18N_NOOP("Cayman Islands"), I18N_NOOP("Cayman Islands Dollar"), I18N_NOOP("KYD") },
03134 { "XAF", I18N_NOOP("Central African Republic"), I18N_NOOP("CFA Franc BEAC"), I18N_NOOP("XAF") },
03135 { "XAF", I18N_NOOP("Chad"), I18N_NOOP("CFA Franc BEAC"), I18N_NOOP("XAF") },
03136 { "CLP", I18N_NOOP("Chile"), I18N_NOOP("Chilean Peso"), I18N_NOOP("Ch$") },
03137 { "CLF", I18N_NOOP("Chile"), I18N_NOOP("Unidades de fomento"), I18N_NOOP("CLF") },
03138 { "CNY", I18N_NOOP("China"), I18N_NOOP("Yuan Renminbi"), I18N_NOOP("CNY") },
03139 { "AUD", I18N_NOOP("Christmas Island"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
03140 { "AUD", I18N_NOOP("Cocos (Keeling) Islands"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
03141 { "COP", I18N_NOOP("Colombia"), I18N_NOOP("Colombian Peso"), I18N_NOOP("C$") },
03142 { "KMF", I18N_NOOP("Comoros"), I18N_NOOP("Comoro Franc"), I18N_NOOP("KMF") },
03143 { "XAF", I18N_NOOP("Congo"), I18N_NOOP("CFA Franc BEAC"), I18N_NOOP("XAF") },
03144 { "CDF", I18N_NOOP("Congo, The Democratic Republic Of"), I18N_NOOP("Franc Congolais"), I18N_NOOP("CDF") },
03145 { "NZD", I18N_NOOP("Cook Islands"), I18N_NOOP("New Zealand Dollar"), I18N_NOOP("NZD") },
03146 { "CRC", I18N_NOOP("Costa Rica"), I18N_NOOP("Costa Rican Colon"), I18N_NOOP("C") },
03147 { "XOF", I18N_NOOP("Cote D'Ivoire"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
03148 { "HRK", I18N_NOOP("Croatia"), I18N_NOOP("Croatian kuna"), I18N_NOOP("kn") },
03149 { "CUP", I18N_NOOP("Cuba"), I18N_NOOP("Cuban Peso"), I18N_NOOP("CUP") },
03150 { "CYP", I18N_NOOP("Cyprus"), I18N_NOOP("Cyprus Pound"), I18N_NOOP("CYP") },
03151 { "CZK", I18N_NOOP("Czech Republic"), I18N_NOOP("Czech Koruna"), I18N_NOOP("Kc") },
03152 { "DKK", I18N_NOOP("Denmark"), I18N_NOOP("Danish Krone"), I18N_NOOP("kr") },
03153 { "DJF", I18N_NOOP("Djibouti"), I18N_NOOP("Djibouti Franc"), I18N_NOOP("DJF") },
03154 { "XCD", I18N_NOOP("Dominica"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("RD$") },
03155 { "DOP", I18N_NOOP("Dominican Republic"), I18N_NOOP("Dominican Peso"), I18N_NOOP("DOP") },
03156 { "TPE", I18N_NOOP("East Timor"), I18N_NOOP("Timor Escudo"), I18N_NOOP("TPE") },
03157 { "USD", I18N_NOOP("East Timor"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03158 { "USD", I18N_NOOP("Ecuador"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03159 { "EGP", I18N_NOOP("Egypt"), I18N_NOOP("Egyptian Pound"), I18N_NOOP("EGP") },
03160 { "SVC", I18N_NOOP("El Salvador"), I18N_NOOP("El Salvador Colon"), I18N_NOOP("C") },
03161 { "USD", I18N_NOOP("El Salvador"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03162 { "XAF", I18N_NOOP("Equatorial Guinea"), I18N_NOOP("CFA Franc BEAC"), I18N_NOOP("XAF") },
03163 { "ERN", I18N_NOOP("Eritrea"), I18N_NOOP("Nakfa"), I18N_NOOP("ERN") },
03164 { "EEK", I18N_NOOP("Estonia"), I18N_NOOP("Kroon"), I18N_NOOP("kr") },
03165 { "ETB", I18N_NOOP("Ethiopia"), I18N_NOOP("Ethiopian Birr"), I18N_NOOP("ETB") },
03166 { "FKP", I18N_NOOP("Falkland Island (Malvinas)"), I18N_NOOP("Falkland Islands Pound"), I18N_NOOP("FKP") },
03167 { "DKK", I18N_NOOP("Faeroe Islands"), I18N_NOOP("Danish Krone"), I18N_NOOP("kr") },
03168 { "FJD", I18N_NOOP("Fiji"), I18N_NOOP("Fiji Dollar"), I18N_NOOP("FJD") },
03169 { "EUR", I18N_NOOP("Finland"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03170 { "FIM", I18N_NOOP("Finland"), I18N_NOOP("Markka"), I18N_NOOP("mk") },
03171 { "EUR", I18N_NOOP("France"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03172 { "FRF", I18N_NOOP("France"), I18N_NOOP("Franc"), I18N_NOOP("F") },
03173 { "EUR", I18N_NOOP("French Guiana"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03174 { "XPF", I18N_NOOP("French Polynesia"), I18N_NOOP("CFP Franc"), I18N_NOOP("XPF") },
03175 { "EUR", I18N_NOOP("Franc Southern Territories"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03176 { "XAF", I18N_NOOP("Gabon"), I18N_NOOP("CFA Franc BEAC"), I18N_NOOP("XAF") },
03177 { "GMD", I18N_NOOP("Gambia"), I18N_NOOP("Dalasi"), I18N_NOOP("GMD") },
03178 { "GEL", I18N_NOOP("Georgia"), I18N_NOOP("Lari"), I18N_NOOP("GEL") },
03179 { "EUR", I18N_NOOP("Germany"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03180 { "DEM", I18N_NOOP("Germany"), I18N_NOOP("German Mark"), I18N_NOOP("DM") },
03181 { "GHC", I18N_NOOP("Ghana"), I18N_NOOP("Cedi"), I18N_NOOP("GHC") },
03182 { "GIP", I18N_NOOP("Gibraltar"), I18N_NOOP("Gibraltar Pound"), I18N_NOOP("GIP") },
03183 { "EUR", I18N_NOOP("Greece"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03184 { "GRD", I18N_NOOP("Greece"), I18N_NOOP("Drachma"), I18N_NOOP("GRD") },
03185 { "DKK", I18N_NOOP("Greenland"), I18N_NOOP("Danish Krone"), I18N_NOOP("DKK") },
03186 { "XCD", I18N_NOOP("Grenada"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("XCD") },
03187 { "EUR", I18N_NOOP("Guadeloupe"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03188 { "USD", I18N_NOOP("Guam"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03189 { "GTQ", I18N_NOOP("Guatemala"), I18N_NOOP("Quetzal"), I18N_NOOP("Q") },
03190 { "GNF", I18N_NOOP("Guinea"), I18N_NOOP("Guinea Franc"), I18N_NOOP("GNF") },
03191 { "GWP", I18N_NOOP("Guinea-Bissau"), I18N_NOOP("Guinea-Bissau Peso"), I18N_NOOP("GWP") },
03192 { "XOF", I18N_NOOP("Guinea-Bissau"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
03193 { "GYD", I18N_NOOP("Guyana"), I18N_NOOP("Guyana Dollar"), I18N_NOOP("GYD") },
03194 { "HTG", I18N_NOOP("Haiti"), I18N_NOOP("Gourde"), I18N_NOOP("HTG") },
03195 { "USD", I18N_NOOP("Haiti"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03196 { "AUD", I18N_NOOP("Heard Island And McDonald Islands"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
03197 { "EUR", I18N_NOOP("Holy See (Vatican City State)"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03198 { "HNL", I18N_NOOP("Honduras"), I18N_NOOP("Lempira"), I18N_NOOP("L") },
03199 { "HKD", I18N_NOOP("Hong Kong"), I18N_NOOP("Hong Kong Dollar"), I18N_NOOP("HKD") },
03200 { "HUF", I18N_NOOP("Hungary"), I18N_NOOP("Forint"), I18N_NOOP("Ft") },
03201 { "ISK", I18N_NOOP("Iceland"), I18N_NOOP("Iceland Krona"), I18N_NOOP("kr.") },
03202 { "INR", I18N_NOOP("India"), I18N_NOOP("Indian Rupee"), I18N_NOOP("INR") },
03203 { "IDR", I18N_NOOP("Indonesia"), I18N_NOOP("Rupiah"), I18N_NOOP("Rp") },
03204 { "IRR", I18N_NOOP("Iran, Islamic Republic Of"), I18N_NOOP("Iranian Rial"), I18N_NOOP("IRR") },
03205 { "IQD", I18N_NOOP("Iraq"), I18N_NOOP("Iraqi Dinar"), I18N_NOOP("IQD") },
03206 { "EUR", I18N_NOOP("Ireland"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03207 { "IEP", I18N_NOOP("Ireland"), I18N_NOOP("Punt"), I18N_NOOP("IR----") },
03208 { "IEX", I18N_NOOP("Ireland"), I18N_NOOP("Pence"), I18N_NOOP("IEX") },
03209 { "ILS", I18N_NOOP("Israel"), I18N_NOOP("New Israeli Sheqel"), I18N_NOOP("ILS") },
03210 { "EUR", I18N_NOOP("Italy"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03211 { "ITL", I18N_NOOP("Italy"), I18N_NOOP("Lira"), I18N_NOOP("L.") },
03212 { "JMD", I18N_NOOP("Jamaica"), I18N_NOOP("Jamaican Dollar"), I18N_NOOP("J$") },
03213 { "JPY", I18N_NOOP("Japan"), I18N_NOOP("Yen"), I18N_NOOP("JPY") },
03214 { "JOD", I18N_NOOP("Jordan"), I18N_NOOP("Jordanian Dinar"), I18N_NOOP("JOD") },
03215 { "KZT", I18N_NOOP("Kazakhstan"), I18N_NOOP("Tenge"), I18N_NOOP("KZT") },
03216 { "KES", I18N_NOOP("Kenya"), I18N_NOOP("Kenyan Shilling"), I18N_NOOP("KES") },
03217 { "AUD", I18N_NOOP("Kiribati"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
03218 { "KPW", I18N_NOOP("Korea, Democratic People's Republic Of"), I18N_NOOP("North Korean Won"), I18N_NOOP("KPW") },
03219 { "KRW", I18N_NOOP("Korea, Republic Of"), I18N_NOOP("Won"), I18N_NOOP("KRW") },
03220 { "KWD", I18N_NOOP("Kuwait"), I18N_NOOP("Kuwaiti Dinar"), I18N_NOOP("KWD") },
03221 { "KGS", I18N_NOOP("Kyrgyzstan"), I18N_NOOP("Som"), I18N_NOOP("KGS") },
03222 { "LAK", I18N_NOOP("Lao People's Democratic Republic"), I18N_NOOP("Kip"), I18N_NOOP("LAK") },
03223 { "LVL", I18N_NOOP("Latvia"), I18N_NOOP("Latvian Lats"), I18N_NOOP("Ls") },
03224 { "LBP", I18N_NOOP("Lebanon"), I18N_NOOP("Lebanese Pound"), I18N_NOOP("LBP") },
03225 { "ZAR", I18N_NOOP("Lesotho"), I18N_NOOP("Rand"), I18N_NOOP("ZAR") },
03226 { "LSL", I18N_NOOP("Lesotho"), I18N_NOOP("Loti"), I18N_NOOP("LSL") },
03227 { "LRD", I18N_NOOP("Liberia"), I18N_NOOP("Liberian Dollar"), I18N_NOOP("LRD") },
03228 { "LYD", I18N_NOOP("Libyan Arab Jamahiriya"), I18N_NOOP("Lybian Dinar"), I18N_NOOP("LYD") },
03229 { "CHF", I18N_NOOP("Liechtenstein"), I18N_NOOP("Swiss Franc"), I18N_NOOP("CHF") },
03230 { "LTL", I18N_NOOP("Lithuania"), I18N_NOOP("Lithuanian Litus"), I18N_NOOP("Lt") },
03231 { "EUR", I18N_NOOP("Luxembourg"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03232 { "LUF", I18N_NOOP("Luxembourg"), I18N_NOOP("Franc"), I18N_NOOP("F") },
03233 { "MOP", I18N_NOOP("Macao"), I18N_NOOP("Pataca"), I18N_NOOP("MOP") },
03234 { "MKD", I18N_NOOP("Macedonia, The Former Yugoslav Republic Of"), I18N_NOOP("Denar"), I18N_NOOP("MKD") },
03235 { "MGF", I18N_NOOP("Madagascar"), I18N_NOOP("Malagasy Franc"), I18N_NOOP("MGF") },
03236 { "MWK", I18N_NOOP("Malawi"), I18N_NOOP("Kwacha"), I18N_NOOP("MWK") },
03237 { "MYR", I18N_NOOP("Malaysia"), I18N_NOOP("Malaysian Ringgit"), I18N_NOOP("MYR") },
03238 { "MVR", I18N_NOOP("Maldives"), I18N_NOOP("Rufiyaa"), I18N_NOOP("MVR") },
03239 { "XOF", I18N_NOOP("Mali"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
03240 { "MTL", I18N_NOOP("Malta"), I18N_NOOP("Maltese Lira"), I18N_NOOP("MTL") },
03241 { "USD", I18N_NOOP("Marshall Islands"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03242 { "EUR", I18N_NOOP("Martinique"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03243 { "MRO", I18N_NOOP("Mauritania"), I18N_NOOP("Ouguiya"), I18N_NOOP("MRO") },
03244 { "MUR", I18N_NOOP("Mauritius"), I18N_NOOP("Mauritius Rupee"), I18N_NOOP("MUR") },
03245 { "EUR", I18N_NOOP("Mayotte"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03246 { "MXN", I18N_NOOP("Mexico"), I18N_NOOP("Mexican Peso"), I18N_NOOP("MXN") },
03247 { "MXV", I18N_NOOP("Mexico"), I18N_NOOP("Mexican Unidad de Inversion (UDI)"), I18N_NOOP("MXV") },
03248 { "USD", I18N_NOOP("Micronesia, Federated States Of"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03249 { "MDL", I18N_NOOP("Moldova, Republic Of"), I18N_NOOP("Moldovan Leu"), I18N_NOOP("MDL") },
03250 { "EUR", I18N_NOOP("Monaco"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03251 { "MNT", I18N_NOOP("Mongolia"), I18N_NOOP("Tugrik"), I18N_NOOP("MNT") },
03252 { "XCD", I18N_NOOP("Montserrat"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("XCD") },
03253 { "MAD", I18N_NOOP("Morocco"), I18N_NOOP("Moroccan Dirham"), I18N_NOOP("MAD") },
03254 { "MZM", I18N_NOOP("Mozambique"), I18N_NOOP("Metical"), I18N_NOOP("MZM") },
03255 { "MMK", I18N_NOOP("Myanmar"), I18N_NOOP("Kyat"), I18N_NOOP("MMK") },
03256 { "ZAR", I18N_NOOP("Namibia"), I18N_NOOP("Rand"), I18N_NOOP("ZAR") },
03257 { "NAD", I18N_NOOP("Namibia"), I18N_NOOP("Namibia Dollar"), I18N_NOOP("NAD") },
03258 { "AUD", I18N_NOOP("Nauru"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
03259 { "NPR", I18N_NOOP("Nepal"), I18N_NOOP("Nepalese Rupee"), I18N_NOOP("NPR") },
03260 { "EUR", I18N_NOOP("Netherlands"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03261 { "NLG", I18N_NOOP("Netherlands"), I18N_NOOP("Guilder"), I18N_NOOP("fl") },
03262 { "ANG", I18N_NOOP("Netherlands Antilles"), I18N_NOOP("Netherlands Antillan Guilder"), I18N_NOOP("ANG") },
03263 { "XPF", I18N_NOOP("New Caledonia"), I18N_NOOP("CFP Franc"), I18N_NOOP("XPF") },
03264 { "NZD", I18N_NOOP("New Zealand"), I18N_NOOP("New Zealand Dollar"), I18N_NOOP("NZD") },
03265 { "NIO", I18N_NOOP("Nicaragua"), I18N_NOOP("Cordoba Oro"), I18N_NOOP("NIO") },
03266 { "XOF", I18N_NOOP("Niger"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
03267 { "NGN", I18N_NOOP("Nigeria"), I18N_NOOP("Naira"), I18N_NOOP("NGN") },
03268 { "NZD", I18N_NOOP("Niue"), I18N_NOOP("New Zealand Dollar"), I18N_NOOP("NZD") },
03269 { "AUD", I18N_NOOP("Norfolk Islands"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
03270 { "USD", I18N_NOOP("Northern Mariana Islands"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03271 { "NOK", I18N_NOOP("Norway"), I18N_NOOP("Norwegian Krone"), I18N_NOOP("kr") },
03272 { "OMR", I18N_NOOP("Oman"), I18N_NOOP("Rial Omani"), I18N_NOOP("OMR") },
03273 { "PKR", I18N_NOOP("Pakistan"), I18N_NOOP("Pakistan Rupee"), I18N_NOOP("PKR") },
03274 { "USD", I18N_NOOP("Palau"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03275 { "PAB", I18N_NOOP("Panama"), I18N_NOOP("Balboa"), I18N_NOOP("PAB") },
03276 { "USD", I18N_NOOP("Panama"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03277 { "PGK", I18N_NOOP("Papua New Guinea"), I18N_NOOP("Kina"), I18N_NOOP("PGK") },
03278 { "PYG", I18N_NOOP("Paraguay"), I18N_NOOP("Guarani"), I18N_NOOP("G") },
03279 { "PEN", I18N_NOOP("Peru"), I18N_NOOP("Nuevo Sol"), I18N_NOOP("PEN") },
03280 { "PHP", I18N_NOOP("Philippines"), I18N_NOOP("Philippine Peso"), I18N_NOOP("PHP") },
03281 { "NZD", I18N_NOOP("Pitcairn"), I18N_NOOP("New Zealand Dollar"), I18N_NOOP("NZD") },
03282 { "PLN", I18N_NOOP("Poland"), I18N_NOOP("Zloty"), I18N_NOOP("zt") },
03283 { "EUR", I18N_NOOP("Portugal"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03284 { "PTE", I18N_NOOP("Portugal"), I18N_NOOP("Escudo"), I18N_NOOP("Esc.") },
03285 { "USD", I18N_NOOP("Puerto Rico"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03286 { "QAR", I18N_NOOP("Qatar"), I18N_NOOP("Qatari Rial"), I18N_NOOP("QAR") },
03287 { "ROL", I18N_NOOP("Romania"), I18N_NOOP("Leu"), I18N_NOOP("LEI") },
03288 { "RUR", I18N_NOOP("Russian Federation"), I18N_NOOP("Russian Ruble"), I18N_NOOP("RUR") },
03289 { "RUB", I18N_NOOP("Russian Federation"), I18N_NOOP("Russian Ruble"), I18N_NOOP("RUB") },
03290 { "RWF", I18N_NOOP("Rwanda"), I18N_NOOP("Rwanda Franc"), I18N_NOOP("RWF") },
03291 { "SHP", I18N_NOOP("Saint Helena"), I18N_NOOP("Saint Helena Pound"), I18N_NOOP("SHP") },
03292 { "XCD", I18N_NOOP("Saint Kitts And Nevis"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("XCD") },
03293 { "XCD", I18N_NOOP("Saint Lucia"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("XCD") },
03294 { "EUR", I18N_NOOP("Saint Pierre And Miquelon"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03295 { "XCD", I18N_NOOP("Saint Vincent And The Grenadines"), I18N_NOOP("East Caribbean Dollar"), I18N_NOOP("XCD") },
03296 { "WST", I18N_NOOP("Samoa"), I18N_NOOP("Tala"), I18N_NOOP("WST") },
03297 { "EUR", I18N_NOOP("San Marino"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03298 { "STD", I18N_NOOP("Sao Tome And Principe"), I18N_NOOP("Dobra"), I18N_NOOP("STD") },
03299 { "SAR", I18N_NOOP("Saudi Arabia"), I18N_NOOP("Saudi Riyal"), I18N_NOOP("SAR") },
03300 { "XOF", I18N_NOOP("Senegal"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
03301 { "SCR", I18N_NOOP("Seychelles"), I18N_NOOP("Seychelles Rupee"), I18N_NOOP("SCR") },
03302 { "SLL", I18N_NOOP("Sierra Leone"), I18N_NOOP("Leone"), I18N_NOOP("SLL") },
03303 { "SGD", I18N_NOOP("Singapore"), I18N_NOOP("Singapore Dollar"), I18N_NOOP("SGD") },
03304 { "SKK", I18N_NOOP("Slovakia"), I18N_NOOP("Slovak Koruna"), I18N_NOOP("Sk") },
03305 { "SIT", I18N_NOOP("Slovenia"), I18N_NOOP("Tolar"), I18N_NOOP("SIT") },
03306 { "SBD", I18N_NOOP("Solomon Islands"), I18N_NOOP("Solomon Islands Dollar"), I18N_NOOP("SBD") },
03307 { "SOS", I18N_NOOP("Somalia"), I18N_NOOP("Somali Shilling"), I18N_NOOP("SOS") },
03308 { "ZAR", I18N_NOOP("South Africa"), I18N_NOOP("Rand"), I18N_NOOP("R") },
03309 { "EUR", I18N_NOOP("Spain"), I18N_NOOP("Euro"), I18N_NOOP("EUR") },
03310 { "ESP", I18N_NOOP("Spain"), I18N_NOOP("Peseta"), I18N_NOOP("Pts") },
03311 { "LKR", I18N_NOOP("Sri Lanka"), I18N_NOOP("Sri Lanka Rupee"), I18N_NOOP("LKR") },
03312 { "SDD", I18N_NOOP("Sudan"), I18N_NOOP("Sudanese Dinar"), I18N_NOOP("SDD") },
03313 { "SRG", I18N_NOOP("Suriname"), I18N_NOOP("Suriname Guilder"), I18N_NOOP("SRG") },
03314 { "NOK", I18N_NOOP("Svalbard And Jan Mayen"), I18N_NOOP("Norwegian Krone"), I18N_NOOP("NOK") },
03315 { "SZL", I18N_NOOP("Swaziland"), I18N_NOOP("Lilangeni"), I18N_NOOP("SZL") },
03316 { "SEK", I18N_NOOP("Sweden"), I18N_NOOP("Swedish Krona"), I18N_NOOP("kr") },
03317 { "CHF", I18N_NOOP("Switzerland"), I18N_NOOP("Swiss Franc"), I18N_NOOP("SFr.") },
03318 { "SYP", I18N_NOOP("Syrian Arab Republic"), I18N_NOOP("Syrian Pound"), I18N_NOOP("SYP") },
03319 { "TWD", I18N_NOOP("Taiwan, Province Of China"), I18N_NOOP("New Taiwan Dollar"), I18N_NOOP("TWD") },
03320 { "TJS", I18N_NOOP("Tajikistan"), I18N_NOOP("Somoni"), I18N_NOOP("TJS") },
03321 { "TZS", I18N_NOOP("Tanzania, United Republic Of"), I18N_NOOP("Tanzanian Shilling"), I18N_NOOP("TZS") },
03322 { "THB", I18N_NOOP("Thailand"), I18N_NOOP("Baht"), I18N_NOOP("THB") },
03323 { "XOF", I18N_NOOP("Togo"), I18N_NOOP("CFA Franc BCEAO"), I18N_NOOP("XOF") },
03324 { "NZD", I18N_NOOP("Tokelau"), I18N_NOOP("New Zealand Dollar"), I18N_NOOP("NZD") },
03325 { "TOP", I18N_NOOP("Tonga"), I18N_NOOP("Pa'anga"), I18N_NOOP("TOP") },
03326 { "TTD", I18N_NOOP("Trinidad And Tobago"), I18N_NOOP("Trinidad and Tobago Dollar"), I18N_NOOP("TT$") },
03327 { "TND", I18N_NOOP("Tunisia"), I18N_NOOP("Tunisian Dinar"), I18N_NOOP("TND") },
03328 { "TRL", I18N_NOOP("Turkey"), I18N_NOOP("Turkish Lira"), I18N_NOOP("TL") },
03329 { "TMM", I18N_NOOP("Turkmenistan"), I18N_NOOP("Manat"), I18N_NOOP("TMM") },
03330 { "USD", I18N_NOOP("Turks And Caicos Islands"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03331 { "AUD", I18N_NOOP("Tuvalu"), I18N_NOOP("Australian Dollar"), I18N_NOOP("AUD") },
03332 { "UGX", I18N_NOOP("Uganda"), I18N_NOOP("Uganda Shilling"), I18N_NOOP("UGX") },
03333 { "UAH", I18N_NOOP("Ukraine"), I18N_NOOP("Hryvnia"), I18N_NOOP("UAH") },
03334 { "AED", I18N_NOOP("United Arab Emirates"), I18N_NOOP("UAE Dirham"), I18N_NOOP("AED") },
03335 { "GBP", I18N_NOOP("United Kingdom"), I18N_NOOP("Pound Sterling"), I18N_NOOP("GBP") },
03336 { "USD", I18N_NOOP("United States"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03337 { "USN", I18N_NOOP("United States"), I18N_NOOP("US Dollar (Next day)"), I18N_NOOP("USN") },
03338 { "USS", I18N_NOOP("United States"), I18N_NOOP("US Dollar (Same day)"), I18N_NOOP("USS") },
03339 { "UYU", I18N_NOOP("Uruguay"), I18N_NOOP("Peso Uruguayo"), I18N_NOOP("NU$") },
03340 { "UZS", I18N_NOOP("Uzbekistan"), I18N_NOOP("Uzbekistan Sum"), I18N_NOOP("UZS") },
03341 { "VUV", I18N_NOOP("Vanuatu"), I18N_NOOP("Vatu"), I18N_NOOP("VUV") },
03342 { "VEB", I18N_NOOP("Venezuela"), I18N_NOOP("Bolivar"), I18N_NOOP("Bs") },
03343 { "VND", I18N_NOOP("Viet Nam"), I18N_NOOP("Dong"), I18N_NOOP("VND") },
03344 { "USD", I18N_NOOP("Virgin Islands"), I18N_NOOP("US Dollar"), I18N_NOOP("USD") },
03345 { "XPF", I18N_NOOP("Wallis And Futuna"), I18N_NOOP("CFP Franc"), I18N_NOOP("XPF") },
03346 { "MAD", I18N_NOOP("Western Sahara"), I18N_NOOP("Moroccan Dirham"), I18N_NOOP("MAD") },
03347 { "YER", I18N_NOOP("Yemen"), I18N_NOOP("Yemeni Rial"), I18N_NOOP("YER") },
03348 { "YUM", I18N_NOOP("Yugoslavia"), I18N_NOOP("Yugoslavian Dinar"), I18N_NOOP("YUM") },
03349 { "ZMK", I18N_NOOP("Zambia"), I18N_NOOP("Kwacha"), I18N_NOOP("ZMK") },
03350 { "ZWD", I18N_NOOP("Zimbabwe"), I18N_NOOP("Zimbabwe Dollar"), I18N_NOOP("ZWD") },
03351 { 0, 0, 0, 0},
03352 };
03353
03354
03355 class CurrencyMap
03356 {
03357 public:
03358 CurrencyMap()
03359 : m_List(lMoney)
03360 {
03361 }
03362
03363
03364 QString getCode(int t) const
03365 {
03366 return QString::fromUtf8( m_List[t].code );
03367 }
03368
03369 QString getCountry(int t) const
03370 {
03371 return QString::fromUtf8( m_List[t].country );
03372 }
03373
03374 QString getName(int t) const
03375 {
03376 return QString::fromUtf8( m_List[t].name );
03377 }
03378
03379 QString getDisplayCode(int t) const
03380 {
03381 return QString::fromUtf8( m_List[t].display );
03382 }
03383
03384 int getIndex(const QString& code) const
03385 {
03386 int index = 0;
03387 while (m_List[index].code != 0 && m_List[index].code != code)
03388 ++index;
03389 return (m_List[index].code != 0) ? index : 1 ;
03390 }
03391
03392 private:
03393 const Money * m_List;
03394 };
03395
03396 const CurrencyMap gCurrencyMap;
03397 const Money * gMoneyList(lMoney);
03398 }
03399
03400
03401 using namespace Currency_LNS;
03402
03403 Currency::Currency()
03404 : m_type( 0 )
03405 {
03406 }
03407
03408 Currency::~Currency()
03409 {
03410 }
03411
03412 Currency::Currency(int index)
03413 : m_type( index ),
03414 m_code( gCurrencyMap.getCode( index ) )
03415 {
03416 }
03417
03418 Currency::Currency(int index, QString const & code)
03419 : m_type ( 1 ),
03420 m_code( code )
03421 {
03422 if ( gCurrencyMap.getCode( index ) == code )
03423 m_type = index;
03424 }
03425
03426 Currency::Currency(QString const & code, currencyFormat format)
03427 : m_type( 1 ),
03428 m_code( code )
03429 {
03430 if ( format == Gnumeric )
03431 {
03432
03433 if ( code.find( QChar( 172, 32 ) ) != -1 )
03434 m_code = QChar( 172, 32 );
03435 else if ( code.find( QChar( 163, 0 ) ) != -1 )
03436 m_code = QChar( 163, 0 );
03437 else if ( code.find( QChar( 165, 0 ) ) != -1 )
03438 m_code = QChar( 165, 0 );
03439 else if ( code[0] == '[' && code[1] == '$' )
03440 {
03441 int n = code.find(']');
03442 if (n != -1)
03443 {
03444 m_code = code.mid( 2, n - 2 );
03445 }
03446 else
03447 {
03448 m_type = 0;
03449 }
03450 }
03451 else if ( code.find( '$' ) != -1 )
03452 m_code = "$";
03453 }
03454 m_type = gCurrencyMap.getIndex( m_code );
03455 }
03456
03457 Currency & Currency::operator=(int type)
03458 {
03459 m_type = type;
03460 m_code = gCurrencyMap.getCode( m_type );
03461
03462 return *this;
03463 }
03464
03465 Currency & Currency::operator=(char const * code)
03466 {
03467 m_type = 1;
03468 m_code = code;
03469
03470 return *this;
03471 }
03472
03473 bool Currency::operator==(Currency const & cur) const
03474 {
03475 if ( m_type == cur.m_type )
03476 return true;
03477
03478 if ( m_code == cur.m_code )
03479 return true;
03480
03481 return false;
03482 }
03483
03484 bool Currency::operator==(int type) const
03485 {
03486 if ( m_type == type )
03487 return true;
03488
03489 return false;
03490 }
03491
03492 Currency::operator int() const
03493 {
03494 return m_type;
03495 }
03496
03497 QString Currency::getCode() const
03498 {
03499 return m_code;
03500 }
03501
03502 QString Currency::getCountry() const
03503 {
03504 return gCurrencyMap.getCountry( m_type );
03505 }
03506
03507 QString Currency::getName() const
03508 {
03509 return gCurrencyMap.getName( m_type );
03510 }
03511
03512 QString Currency::getDisplayCode() const
03513 {
03514 return gMoneyList[m_type].display;
03515 }
03516
03517 int Currency::getIndex() const
03518 {
03519 return m_type;
03520 }
03521
03522 QString Currency::getExportCode( currencyFormat format ) const
03523 {
03524 if ( format == Gnumeric )
03525 {
03526 if ( m_code.length() == 1 )
03527 return m_code;
03528
03529 QString ret( "[$");
03530 ret += m_code;
03531 ret += "]";
03532
03533 return ret;
03534 }
03535
03536 return m_code;
03537 }
03538
03539 QString Currency::getChooseString( int type, bool & ok )
03540 {
03541 if ( !gMoneyList[type].country )
03542 {
03543 ok = false;
03544 return QString::null;
03545 }
03546 if ( type < 24 )
03547 {
03548 QString ret( i18n( gMoneyList[type].name ) );
03549 if ( gMoneyList[type].country[0] )
03550 {
03551 ret += " (";
03552 ret += i18n( gMoneyList[type].country );
03553 ret += ")";
03554 }
03555 return ret;
03556 }
03557 else
03558 {
03559 QString ret( i18n( gMoneyList[type].country ) );
03560 if ( gMoneyList[type].name[0] )
03561 {
03562 ret += " (";
03563 ret += i18n( gMoneyList[type].name );
03564 ret += ")";
03565 }
03566 return ret;
03567 }
03568 }
03569
03570 QString Currency::getDisplaySymbol( int type )
03571 {
03572 return i18n( gMoneyList[type].display );
03573 }
03574
03575
03576 QString Currency::getCurrencyCode( int type )
03577 {
03578 return QString::fromUtf8( gMoneyList[type].code );
03579 }
03580
03581 #undef UPDATE_BEGIN
03582 #undef UPDATE_END