~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to kspread/kspread_format.cc

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

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