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

« back to all changes in this revision

Viewing changes to kspread/kspread_dlg_layout.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
1
/* This file is part of the KDE project
2
 
   Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
 
2
   Copyright (C) 1998, 1999  Torben Weis <weis@kde.org>
 
3
   Copyright (C) 1999 - 2003 The KSpread Team
 
4
                             www.koffice.org/kspread
3
5
 
4
6
   This library is free software; you can redistribute it and/or
5
7
   modify it under the terms of the GNU Library General Public
17
19
   Boston, MA 02111-1307, USA.
18
20
*/
19
21
 
20
 
#include <qprinter.h>
21
22
#include <stdlib.h>
22
23
#include <math.h>
23
24
 
 
25
#include "kspread_canvas.h"
24
26
#include "kspread_dlg_layout.h"
 
27
#include "kspread_sheet.h"
 
28
#include "kspread_style.h"
 
29
#include "kspread_style_manager.h"
25
30
#include "kspread_undo.h"
26
 
#include "kspread_table.h"
27
 
#include "kspread_cell.h"
28
 
#include "kspread_doc.h"
29
 
#include "kspread_view.h"
30
31
#include "kspread_util.h"
31
 
#include "kspread_canvas.h"
32
32
 
 
33
#include <qbitmap.h>
33
34
#include <qlabel.h>
34
 
#include <qpainter.h>
35
35
#include <qlayout.h>
36
36
#include <qfontdatabase.h>
37
 
#include <kcolordlg.h>
38
 
#include <klocale.h>
39
37
#include <kdebug.h>
40
 
#include <kstddirs.h>
 
38
#include <kmessagebox.h>
41
39
#include <knumvalidator.h>
42
40
#include <qradiobutton.h>
43
 
#include <qpixmap.h>
44
41
#include <klineedit.h>
45
 
 
46
 
KSpreadPatternSelect::KSpreadPatternSelect( QWidget *parent, const char * ) : QFrame( parent )
 
42
#include <qcheckbox.h>
 
43
#include <kcolorbutton.h>
 
44
#include <kcombobox.h>
 
45
#include <qcombobox.h>
 
46
 
 
47
 
 
48
KSpreadPatternSelect::KSpreadPatternSelect( QWidget *parent, const char * ) 
 
49
  : QFrame( parent )
47
50
{
48
51
    penStyle = NoPen;
49
52
    penWidth = 1;
50
53
    penColor = colorGroup().text();
51
 
    selected = FALSE;
52
 
    undefined = FALSE;
 
54
    selected = false;
 
55
    undefined = false;
53
56
}
54
57
 
55
58
void KSpreadPatternSelect::setPattern( const QColor &_color, int _width, PenStyle _style )
62
65
 
63
66
void KSpreadPatternSelect::setUndefined()
64
67
{
65
 
    undefined = TRUE;
 
68
    undefined = true;
66
69
}
67
70
 
68
71
void KSpreadPatternSelect::paintEvent( QPaintEvent *_ev )
69
72
{
70
73
    QFrame::paintEvent( _ev );
71
74
 
72
 
    QPainter painter;
73
 
    QPen pen;
 
75
    QPainter painter( this );
74
76
 
75
77
    if ( !undefined )
76
78
    {
77
 
        pen=QPen( penColor,penWidth,penStyle);
78
 
        painter.begin( this );
 
79
        QPen pen( penColor, penWidth, penStyle);
79
80
        painter.setPen( pen );
80
81
        painter.drawLine( 6, height()/2, width() - 6,height()/2  );
81
 
        painter.end();
82
82
    }
83
83
    else
84
84
    {
85
 
        painter.begin( this );
86
85
        painter.fillRect( 2, 2, width() - 4, height() - 4, BDiagPattern );
87
 
        painter.end();
88
86
    }
89
87
}
90
88
 
97
95
 
98
96
void KSpreadPatternSelect::slotUnselect()
99
97
{
100
 
    selected = FALSE;
 
98
    selected = false;
101
99
 
102
100
    setLineWidth( 1 );
103
101
    setFrameStyle( QFrame::Panel | QFrame::Sunken );
106
104
 
107
105
void KSpreadPatternSelect::slotSelect()
108
106
{
109
 
    selected = TRUE;
 
107
    selected = true;
110
108
 
111
109
    setLineWidth( 2 );
112
110
    setFrameStyle( QFrame::Panel | QFrame::Plain );
113
111
    repaint();
114
112
}
115
113
 
116
 
CellLayoutDlg::CellLayoutDlg( KSpreadView *_view, KSpreadTable *_table, int _left, int _top,
117
 
                              int _right, int _bottom ) : QObject()
118
 
{
119
 
    undefinedPixmap = 0L;
120
 
    formatOnlyNegSignedPixmap = 0L;
121
 
    formatRedOnlyNegSignedPixmap = 0L;
122
 
    formatRedNeverSignedPixmap = 0L;
123
 
    formatAlwaysSignedPixmap = 0L;
124
 
    formatRedAlwaysSignedPixmap = 0L;
125
 
    undefinedPixmap = 0L;
126
 
    table = _table;
127
 
    left = _left;
128
 
    top = _top;
129
 
    right = _right;
130
 
    bottom = _bottom;
131
 
    m_pView = _view;
132
 
 
133
 
    m_bValue=false;
134
 
    m_bDate=false;
135
 
    m_bTime=false;
136
 
 
137
 
    // We assume, that all other objects have the same values
138
 
    bLeftBorderStyle = TRUE;
139
 
    bLeftBorderColor = TRUE;
140
 
    bRightBorderStyle = TRUE;
141
 
    bRightBorderColor = TRUE;
142
 
    bTopBorderStyle = TRUE;
143
 
    bTopBorderColor = TRUE;
144
 
    bBottomBorderColor = TRUE;
145
 
    bBottomBorderStyle = TRUE;
146
 
    bVerticalBorderColor = TRUE;
147
 
    bVerticalBorderStyle = TRUE;
148
 
    bHorizontalBorderColor = TRUE;
149
 
    bHorizontalBorderStyle = TRUE;
150
 
    bFallDiagonalStyle = TRUE;
151
 
    bfallDiagonalColor = TRUE;
152
 
    bGoUpDiagonalStyle = TRUE;
153
 
    bGoUpDiagonalColor = TRUE;
154
 
    bFloatFormat = TRUE;
155
 
    bFloatColor = TRUE;
156
 
    bTextColor = TRUE;
157
 
    bBgColor = TRUE;
158
 
    bTextFontFamily = TRUE;
159
 
    bTextFontSize = TRUE;
160
 
    bTextFontBold = TRUE;
161
 
    bTextFontItalic = TRUE;
162
 
    bStrike = TRUE;
163
 
    bUnderline = TRUE;
164
 
    bTextRotation = TRUE;
165
 
    bFormatNumber = TRUE;
166
 
    bDontprintText = TRUE;
167
 
 
168
 
    if( left == right )
169
 
        oneCol = TRUE;
170
 
    else
171
 
        oneCol = FALSE;
172
 
 
173
 
    if( top == bottom )
174
 
        oneRow = TRUE;
175
 
    else
176
 
        oneRow = FALSE;
177
 
 
178
 
 
179
 
    KSpreadCell *obj = table->cellAt( _left, _top );
180
 
    oneCell=false;
181
 
    if( left==right && top==bottom)
182
 
        {
183
 
        if(obj->extraXCells()!=0 ||obj->extraYCells()!=0)
184
 
                isMerged=true;
 
114
 
 
115
 
 
116
GeneralTab::GeneralTab( QWidget* parent, CellFormatDlg * dlg )
 
117
  : QWidget( parent ),
 
118
    m_dlg( dlg )
 
119
{
 
120
  QGridLayout * layout = new QGridLayout( this, 1, 1, KDialog::marginHint(), KDialog::spacingHint(), "layout");
 
121
 
 
122
  QGroupBox * groupBox = new QGroupBox( this, "groupBox1" );
 
123
  groupBox->setColumnLayout(0, Qt::Vertical );
 
124
  groupBox->setTitle( i18n( "Style" ) );
 
125
  groupBox->layout()->setSpacing( KDialog::spacingHint() );
 
126
  groupBox->layout()->setMargin( KDialog::marginHint() );
 
127
 
 
128
  QGridLayout * groupBoxLayout = new QGridLayout( groupBox->layout() );
 
129
  groupBoxLayout->setAlignment( Qt::AlignTop );
 
130
 
 
131
  QLabel * label1 = new QLabel( groupBox, "label1" );
 
132
  label1->setText( i18n( "Name:" ) );
 
133
  groupBoxLayout->addWidget( label1, 0, 0 );
 
134
 
 
135
  m_nameEdit = new KLineEdit( groupBox, "m_nameEdit" );
 
136
  m_nameEdit->setText( m_dlg->styleName );
 
137
  groupBoxLayout->addWidget( m_nameEdit, 0, 1 );
 
138
 
 
139
  QLabel * label2 = new QLabel( groupBox, "label2" );  
 
140
  label2->setText( i18n( "Inherit style:" ) );
 
141
  groupBoxLayout->addWidget( label2, 1, 0 );
 
142
 
 
143
  m_parentBox = new KComboBox( false, groupBox, "m_parentBox" );
 
144
  m_parentBox->clear();
 
145
  m_parentBox->insertItem( i18n( "<None>" ) );
 
146
  m_parentBox->insertStringList( m_dlg->getStyleManager()->styleNames() );
 
147
 
 
148
  if ( m_dlg->getStyle()->parent() )
 
149
    m_parentBox->setCurrentText( m_dlg->getStyle()->parentName() );
 
150
  else
 
151
  {
 
152
    m_parentBox->setCurrentText( i18n( "<None>" ) );
 
153
 
 
154
    if ( m_dlg->getStyle()->definesAll() )
 
155
      m_parentBox->setEnabled( false );
 
156
  }
 
157
 
 
158
  connect( m_parentBox, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotNewParent( const QString & ) ) );
 
159
  connect( m_nameEdit, SIGNAL( lostFocus() ), this, SLOT( slotNameChanged() ) );
 
160
 
 
161
  groupBoxLayout->addWidget( m_parentBox, 1, 1 );
 
162
 
 
163
  QSpacerItem * spacer = new QSpacerItem( 20, 260, QSizePolicy::Minimum, QSizePolicy::Expanding );
 
164
 
 
165
  layout->addWidget( groupBox, 0, 0 );
 
166
  layout->addItem( spacer, 1, 0 );
 
167
 
 
168
  if ( m_dlg->getStyle()->type() == KSpreadStyle::BUILTIN )
 
169
  {
 
170
    m_nameEdit->setEnabled( false );
 
171
    m_parentBox->setEnabled( false );
 
172
  }
 
173
 
 
174
  resize( QSize( 534, 447 ).expandedTo(minimumSizeHint()) );
 
175
}
 
176
 
 
177
GeneralTab::~GeneralTab()
 
178
{
 
179
}
 
180
 
 
181
void GeneralTab::slotNameChanged()
 
182
{
 
183
  checkName();
 
184
}
 
185
 
 
186
void GeneralTab::slotNewParent( const QString & parentName )
 
187
{
 
188
  kdDebug() << "New Parent" << endl;
 
189
  if ( !checkParent( parentName ) )
 
190
    return;
 
191
 
 
192
  if ( parentName.isEmpty() || parentName == i18n( "<None>" ) )
 
193
    m_dlg->getStyle()->setParent( 0 );
 
194
  else
 
195
    m_dlg->getStyle()->setParent( m_dlg->getStyleManager()->style( parentName ) );
 
196
 
 
197
  // Set difference to new parent, set GUI to parent values, add changes made before
 
198
  //  m_dlg->initGUI();
 
199
}
 
200
 
 
201
bool GeneralTab::checkName()
 
202
{
 
203
  if ( m_nameEdit->isEnabled() )
 
204
  {
 
205
    if ( !m_dlg->getStyleManager()->validateStyleName( m_nameEdit->text(), m_dlg->getStyle() ) )
 
206
    {
 
207
      KMessageBox::sorry( this, i18n( "A style with this name already exists." ) );
 
208
      return false;
 
209
    }
 
210
  }
 
211
 
 
212
  return true;
 
213
}
 
214
 
 
215
bool GeneralTab::checkParent( const QString & parentName )
 
216
{
 
217
  if ( m_dlg->getStyle()->parentName() != parentName 
 
218
       && m_parentBox->isEnabled() && parentName != i18n( "<None>" ) && !parentName.isEmpty() )
 
219
  {
 
220
    if ( m_nameEdit->text() == parentName )
 
221
    {
 
222
      KMessageBox::sorry( this, i18n( "A style cannot inherit from itself." ) );
 
223
      return false;
 
224
    }
 
225
    if ( !m_dlg->checkCircle( m_nameEdit->text(), parentName ) )
 
226
    {
 
227
      KMessageBox::sorry( this, 
 
228
                          i18n( "The style cannot inherit from '%1' because of recursive references." )
 
229
                          .arg( m_parentBox->currentText() ) );
 
230
      return false;
 
231
    }
 
232
 
 
233
    KSpreadCustomStyle * p = m_dlg->getStyleManager()->style( parentName );
 
234
 
 
235
    if ( !p )
 
236
    {
 
237
      KMessageBox::sorry( this, i18n( "The parent style doesn't exist." ) );
 
238
      return false;
 
239
    }
 
240
  }
 
241
 
 
242
  return true;
 
243
}
 
244
 
 
245
bool GeneralTab::apply( KSpreadCustomStyle * style )
 
246
{
 
247
  if ( !checkParent( m_parentBox->currentText() ) )
 
248
    return false;
 
249
 
 
250
  if ( !checkName() )
 
251
    return false;
 
252
 
 
253
  if ( m_nameEdit->isEnabled() )
 
254
  {
 
255
    if ( style->type() != KSpreadStyle::BUILTIN )
 
256
    {
 
257
      QString name( style->name() );
 
258
      style->setName( m_nameEdit->text() );
 
259
      if ( m_parentBox->isEnabled() )
 
260
      {
 
261
        if ( m_parentBox->currentText() == i18n( "None" ) || m_parentBox->currentText().isEmpty() )
 
262
          style->setParent( 0 );
185
263
        else
186
 
                {
187
 
                oneCell=true;
188
 
                isMerged=false;
189
 
                }
190
 
        }
191
 
    else
192
 
        isMerged=false;
193
 
    // Initialize with the upper left object.
194
 
    leftBorderStyle = obj->leftBorderStyle( _left, _top );
195
 
    leftBorderWidth = obj->leftBorderWidth( _left, _top );
196
 
    leftBorderColor = obj->leftBorderColor( _left, _top );
197
 
    topBorderStyle = obj->topBorderStyle( _left, _top );
198
 
    topBorderWidth = obj->topBorderWidth( _left, _top );
199
 
    topBorderColor = obj->topBorderColor( _left, _top );
200
 
    fallDiagonalStyle = obj->fallDiagonalStyle( _left, _top );
201
 
    fallDiagonalWidth = obj->fallDiagonalWidth( _left, _top );
202
 
    fallDiagonalColor = obj->fallDiagonalColor( _left, _top );
203
 
    goUpDiagonalStyle = obj->goUpDiagonalStyle( _left, _top );
204
 
    goUpDiagonalWidth = obj->goUpDiagonalWidth( _left, _top );
205
 
    goUpDiagonalColor = obj->goUpDiagonalColor( _left, _top );
206
 
 
207
 
    // Look at the upper right one for the right border.
208
 
    obj = table->cellAt( _right, _top );
209
 
    rightBorderStyle = obj->rightBorderStyle( _right, _top );
210
 
    rightBorderWidth = obj->rightBorderWidth( _right, _top );
211
 
    rightBorderColor = obj->rightBorderColor( _right, _top );
212
 
 
213
 
    // Look at the bottom left cell for the bottom border.
214
 
    obj = table->cellAt( _left, _bottom );
215
 
    bottomBorderStyle = obj->bottomBorderStyle( _left, _bottom );
216
 
    bottomBorderWidth = obj->bottomBorderWidth( _left, _bottom );
217
 
    bottomBorderColor = obj->bottomBorderColor( _left, _bottom );
218
 
 
219
 
    // Just an assumption
220
 
    obj = table->cellAt( _right, _top );
221
 
    if(obj->isObscuringForced())
222
 
        {
223
 
        int moveX=obj->obscuringCellsColumn();
224
 
        int moveY=_top;
225
 
        obj = table->cellAt( moveX,  moveY );
226
 
        verticalBorderStyle = obj->leftBorderStyle( moveX,moveY );
227
 
        verticalBorderWidth = obj->leftBorderWidth( moveX, moveY);
228
 
        verticalBorderColor = obj->leftBorderColor( moveX, moveY );
229
 
        }
230
 
    else
231
 
        {
232
 
        verticalBorderStyle = obj->leftBorderStyle( _right, _top );
233
 
        verticalBorderWidth = obj->leftBorderWidth( _right, _top );
234
 
        verticalBorderColor = obj->leftBorderColor( _right, _top );
235
 
        }
236
 
 
237
 
    if(obj->isObscuringForced())
238
 
        {
239
 
        int moveX=_right;
240
 
        int moveY=obj->obscuringCellsRow();
241
 
        obj = table->cellAt( moveX,  moveY );
242
 
        horizontalBorderStyle = obj->topBorderStyle( moveX, moveY );
243
 
        horizontalBorderWidth = obj->topBorderWidth( moveX, moveY );
244
 
        horizontalBorderColor = obj->topBorderColor( moveX, moveY );
245
 
        }
246
 
    else
247
 
        {
248
 
        horizontalBorderStyle = obj->topBorderStyle( _right, _bottom );
249
 
        horizontalBorderWidth = obj->topBorderWidth( _right, _bottom );
250
 
        horizontalBorderColor = obj->topBorderColor( _right, _bottom );
251
 
        }
252
 
 
253
 
    obj = table->cellAt( _left, _top );
254
 
    prefix = obj->prefix( _left, _top );
255
 
    postfix = obj->postfix( _left, _top );
256
 
    precision = obj->precision( _left, _top );
257
 
    floatFormat = obj->floatFormat( _left, _top );
258
 
    floatColor = obj->floatColor( _left, _top );
259
 
    alignX = obj->align( _left, _top );
260
 
    alignY = obj->alignY( _left, _top );
261
 
    textColor = obj->textColor( _left, _top );
262
 
    bgColor = obj->bgColor( _left, _top );
263
 
    textFontSize = obj->textFontSize( _left, _top );
264
 
    textFontFamily = obj->textFontFamily( _left, _top );
265
 
    textFontBold = obj->textFontBold( _left, _top );
266
 
    textFontItalic = obj->textFontItalic( _left, _top );
267
 
    strike=obj->textFontStrike( _left, _top );
268
 
    underline=obj->textFontUnderline( _left, _top );
269
 
    // Needed to initialize the font correctly ( bug in Qt )
270
 
    textFont = obj->textFont( _left, _top );
271
 
    eStyle = obj->style();
272
 
    actionText = obj->action();
273
 
 
274
 
    brushColor = obj->backGroundBrushColor( _left, _top );
275
 
    brushStyle = obj->backGroundBrushStyle( _left,_top );
276
 
 
277
 
    bMultiRow = obj->multiRow( _left, _top );
278
 
    bVerticalText=obj->verticalText( _left, _top );
279
 
    bDontprintText=obj->getDontprintText( _left, _top );
280
 
    textRotation = obj->getAngle(_left, _top);
281
 
    formatNumber = obj->getFormatNumber(_left, _top);
282
 
 
283
 
    indent = obj->getIndent(_left, _top);
284
 
 
285
 
    cellText=obj->text();
286
 
 
287
 
    if( obj->isValue())
288
 
        {
289
 
        m_bValue=true;
290
 
        m_value=obj->valueDouble();
291
 
        }
292
 
    else if(obj->isDate())
293
 
        {
294
 
        m_bDate=true;
295
 
        m_date=obj->valueDate();
296
 
        }
297
 
    else if(obj->isTime())
298
 
        {
299
 
        m_bTime=true;
300
 
        m_time=obj->valueTime();
301
 
        }
302
 
 
303
 
    RowLayout *rl;
304
 
    ColumnLayout *cl;
305
 
    widthSize = 0;
306
 
    heigthSize = 0;
307
 
 
308
 
    if( _right!=0x7FFF)
309
 
        {
310
 
        for ( int x = _left; x <= _right; x++ )
311
 
                {
312
 
                cl = m_pView->activeTable()->columnLayout( x );
313
 
                widthSize = QMAX( cl->width( /* m_pView->canvasWidget() */ ), widthSize );
314
 
                }
315
 
        }
316
 
 
317
 
    if(_bottom!=0x7FFF)
318
 
        {
319
 
        for ( int y = _top; y <= _bottom; y++ )
320
 
                {
321
 
                rl = m_pView->activeTable()->rowLayout(y);
322
 
                heigthSize = QMAX( rl->height( /* m_pView->canvasWidget() */ ),heigthSize );
323
 
                }
324
 
        }
325
 
 
326
 
    //select column(s)
327
 
    if( _bottom==0x7FFF)
328
 
    {
329
 
      int y=1;
330
 
      for(int x=_left;x<=_right;x++)
331
 
        {
332
 
                ColumnLayout *obj=table->nonDefaultColumnLayout(x);
333
 
                initParameters( obj,x,y);
334
 
        }
335
 
      KSpreadCell* c = table->firstCell();
336
 
      for( ;c; c = c->nextCell() )
337
 
        {
338
 
        int col = c->column();
339
 
        if ( _left <= col && _right >= col
340
 
        &&!c->isObscuringForced())
341
 
                {
342
 
                initParameters( c ,col,c->row());
343
 
                if ( eStyle != c->style() )
344
 
                        eStyle = KSpreadCell::ST_Undef;
345
 
                }
346
 
        }
347
 
 
348
 
    }
349
 
    else if( _right==0x7FFF)
350
 
    {
351
 
      int x=1;
352
 
      for(int y=_top;y<=_bottom;y++)
353
 
        {
354
 
                RowLayout *obj=table->nonDefaultRowLayout(y);
355
 
                initParameters( obj,x,y);
356
 
 
357
 
        }
358
 
 
359
 
      KSpreadCell* c = table->firstCell();
360
 
      for( ;c; c = c->nextCell() )
361
 
      {
362
 
        int row = c->row();
363
 
        if ( _top <= row && _bottom >= row
364
 
        &&!c->isObscuringForced())
365
 
                {
366
 
                initParameters( c ,c->column(),row);
367
 
                if ( eStyle != c->style() )
368
 
                        eStyle = KSpreadCell::ST_Undef;
369
 
                }
370
 
        }
371
 
    }
372
 
    else
373
 
    {
 
264
          style->setParent( m_dlg->getStyleManager()->style( m_parentBox->currentText() ) );
 
265
      }
 
266
      m_dlg->getStyleManager()->changeName( name, m_nameEdit->text() );
 
267
    }
 
268
  }
 
269
 
 
270
  if ( style->type() == KSpreadStyle::TENTATIVE )
 
271
    style->setType( KSpreadStyle::CUSTOM );
 
272
 
 
273
  return true;
 
274
}
 
275
 
 
276
 
 
277
 
 
278
CellFormatDlg::CellFormatDlg( KSpreadView * _view, KSpreadSheet * _table,
 
279
                              int _left, int _top, int _right, int _bottom )
 
280
  : QObject(),
 
281
    m_doc( _table->doc() ),
 
282
    m_table( _table ),
 
283
    m_pView( _view ),
 
284
    m_style( 0 )
 
285
{
 
286
  initMembers();
 
287
 
 
288
  //We need both conditions quite often, so store the condition here too
 
289
  isRowSelected    = util_isRowSelected(_view->selection());
 
290
  isColumnSelected = util_isColumnSelected(_view->selection());
 
291
 
 
292
  //Do we really need these as arguments? (_view->selection())
 
293
  left = _left;
 
294
  top = _top;
 
295
  right = _right;
 
296
  bottom = _bottom;
 
297
 
 
298
  if ( left == right )
 
299
    oneCol = true;
 
300
  else
 
301
    oneCol = false;
 
302
  
 
303
  if ( top == bottom )
 
304
    oneRow = true;
 
305
  else
 
306
    oneRow = false;
 
307
 
 
308
  KSpreadCell * obj = m_table->cellAt( _left, _top );
 
309
  oneCell = (left == right && top == bottom &&
 
310
             !obj->isForceExtraCells());
 
311
  
 
312
  isMerged = ((obj->isForceExtraCells() &&
 
313
               left + obj->extraXCells() >= right &&
 
314
               top + obj->extraYCells() >= bottom));
 
315
  
 
316
  // Initialize with the upper left object.
 
317
  borders[BorderType_Left].style = obj->leftBorderStyle( _left, _top );
 
318
  borders[BorderType_Left].width = obj->leftBorderWidth( _left, _top );
 
319
  borders[BorderType_Left].color = obj->leftBorderColor( _left, _top );
 
320
  borders[BorderType_Top].style = obj->topBorderStyle( _left, _top );
 
321
  borders[BorderType_Top].width = obj->topBorderWidth( _left, _top );
 
322
  borders[BorderType_Top].color = obj->topBorderColor( _left, _top );
 
323
  borders[BorderType_FallingDiagonal].style =
 
324
    obj->fallDiagonalStyle( _left, _top );
 
325
  borders[BorderType_FallingDiagonal].width =
 
326
    obj->fallDiagonalWidth( _left, _top );
 
327
  borders[BorderType_FallingDiagonal].color =
 
328
    obj->fallDiagonalColor( _left, _top );
 
329
  borders[BorderType_RisingDiagonal].style =
 
330
    obj->goUpDiagonalStyle( _left, _top );
 
331
  borders[BorderType_RisingDiagonal].width =
 
332
    obj->goUpDiagonalWidth( _left, _top );
 
333
  borders[BorderType_RisingDiagonal].color =
 
334
    obj->goUpDiagonalColor( _left, _top );
 
335
  
 
336
  // Look at the upper right one for the right border.
 
337
  obj = m_table->cellAt( _right, _top );
 
338
  borders[BorderType_Right].style = obj->rightBorderStyle( _right, _top );
 
339
  borders[BorderType_Right].width = obj->rightBorderWidth( _right, _top );
 
340
  borders[BorderType_Right].color = obj->rightBorderColor( _right, _top );
 
341
  
 
342
  // Look at the bottom left cell for the bottom border.
 
343
  obj = m_table->cellAt( _left, _bottom );
 
344
  borders[BorderType_Bottom].style = obj->bottomBorderStyle( _left, _bottom );
 
345
  borders[BorderType_Bottom].width = obj->bottomBorderWidth( _left, _bottom );
 
346
  borders[BorderType_Bottom].color = obj->bottomBorderColor( _left, _bottom );
 
347
  
 
348
  // Just an assumption
 
349
  obj = m_table->cellAt( _right, _top );
 
350
  if ( obj->isObscuringForced() )
 
351
  {
 
352
    obj = obj->obscuringCells().first();
 
353
    int moveX  = obj->column();
 
354
    int moveY  = _top;
 
355
    int moveX2 = _right;
 
356
    int moveY2 = obj->row();
 
357
    borders[BorderType_Vertical].style = obj->leftBorderStyle( moveX, moveY );
 
358
    borders[BorderType_Vertical].width = obj->leftBorderWidth( moveX, moveY );
 
359
    borders[BorderType_Vertical].color = obj->leftBorderColor( moveX, moveY );
 
360
    
 
361
    obj = m_table->cellAt( moveX2,  moveY2 );
 
362
    borders[BorderType_Horizontal].style = obj->topBorderStyle( moveX2, moveY2 );
 
363
    borders[BorderType_Horizontal].width = obj->topBorderWidth( moveX2, moveY2 );
 
364
    borders[BorderType_Horizontal].color = obj->topBorderColor( moveX2, moveY2 );
 
365
  }
 
366
  else
 
367
  {
 
368
    borders[BorderType_Vertical].style = obj->leftBorderStyle( _right, _top );
 
369
    borders[BorderType_Vertical].width = obj->leftBorderWidth( _right, _top );
 
370
    borders[BorderType_Vertical].color = obj->leftBorderColor( _right, _top );
 
371
    borders[BorderType_Horizontal].style = obj->topBorderStyle(_right, _bottom);
 
372
    borders[BorderType_Horizontal].width = obj->topBorderWidth(_right, _bottom);
 
373
    borders[BorderType_Horizontal].color = obj->topBorderColor(_right, _bottom);
 
374
  }
 
375
  
 
376
  obj = m_table->cellAt( _left, _top );
 
377
  prefix = obj->prefix( _left, _top );
 
378
  postfix = obj->postfix( _left, _top );
 
379
  precision = obj->precision( _left, _top );
 
380
  floatFormat = obj->floatFormat( _left, _top );
 
381
  floatColor = obj->floatColor( _left, _top );
 
382
  alignX = obj->align( _left, _top );
 
383
  alignY = obj->alignY( _left, _top );
 
384
  textColor = obj->textColor( _left, _top );
 
385
  bgColor = obj->bgColor( _left, _top );
 
386
  textFontSize = obj->textFontSize( _left, _top );
 
387
  textFontFamily = obj->textFontFamily( _left, _top );
 
388
  textFontBold = obj->textFontBold( _left, _top );
 
389
  textFontItalic = obj->textFontItalic( _left, _top );
 
390
  strike=obj->textFontStrike( _left, _top );
 
391
  underline = obj->textFontUnderline( _left, _top );
 
392
  // Needed to initialize the font correctly ( bug in Qt )
 
393
  textFont = obj->textFont( _left, _top );
 
394
  eStyle = obj->style();
 
395
  actionText = obj->action();
 
396
  obj->currencyInfo( cCurrency );
 
397
 
 
398
  brushColor = obj->backGroundBrushColor( _left, _top );
 
399
  brushStyle = obj->backGroundBrushStyle( _left,_top );
 
400
 
 
401
  bMultiRow = obj->multiRow( _left, _top );
 
402
  bVerticalText = obj->verticalText( _left, _top );
 
403
  textRotation = obj->getAngle(_left, _top);
 
404
  formatType = obj->getFormatType(_left, _top);
 
405
 
 
406
  bDontPrintText = obj->getDontprintText( _left, _top );
 
407
  bHideFormula   = obj->isHideFormula( _left, _top );
 
408
  bHideAll       = obj->isHideAll( _left, _top );
 
409
  bIsProtected   = !obj->notProtected( _left, _top );
 
410
 
 
411
  indent = obj->getIndent(_left, _top);
 
412
 
 
413
  cellText = obj->text();
 
414
 
 
415
  if ( obj->value().isNumber() || obj->value().isBoolean() )
 
416
  {
 
417
    m_bValue = true;
 
418
    m_value  = obj->value().asFloat();
 
419
  }
 
420
  else if (obj->isDate())
 
421
  {
 
422
    m_bDate=true;
 
423
    m_time  = obj->value().asDateTime();
 
424
  }
 
425
  else if (obj->isTime())
 
426
  {
 
427
    m_bTime = true;
 
428
    m_time  = obj->value().asDateTime();
 
429
  }
 
430
 
 
431
  RowFormat *rl;
 
432
  ColumnFormat *cl;
 
433
  widthSize = 0.0;
 
434
  heightSize = 0.0;
 
435
 
 
436
  if ( !isRowSelected )
 
437
  {
 
438
    for ( int x = _left; x <= _right; x++ )
 
439
    {
 
440
      cl = m_pView->activeTable()->columnFormat( x );
 
441
      widthSize = QMAX( cl->dblWidth(), widthSize );
 
442
    }
 
443
  }
 
444
 
 
445
  if ( !isColumnSelected )
 
446
  {
 
447
    for ( int y = _top; y <= _bottom; y++ )
 
448
    {
 
449
      rl = m_pView->activeTable()->rowFormat(y);
 
450
      heightSize = QMAX( rl->dblHeight(), heightSize );
 
451
    }
 
452
  }
 
453
 
 
454
  //select column(s)
 
455
  if ( isColumnSelected )
 
456
  {
 
457
    int y = 1;
 
458
    KSpreadCell* c = NULL;
 
459
    for (int x = _left;x <= _right; x++)
 
460
    {
 
461
      ColumnFormat *obj = m_table->nonDefaultColumnFormat(x);
 
462
      initParameters( obj,x,y);
 
463
      
 
464
      for (c = m_table->getFirstCellColumn(x); c != NULL;
 
465
           c = m_table->getNextCellDown(c->column(), c->row()))
 
466
      {
 
467
        initParameters( c, x, c->row());
 
468
        if ( eStyle != c->style() )
 
469
          eStyle = KSpreadCell::ST_Undef;
 
470
      }
 
471
    }
 
472
    
 
473
  }
 
474
  else if ( isRowSelected )
 
475
  {
 
476
    int x = 1;
 
477
    KSpreadCell* c = NULL;
 
478
    for ( int y = _top;y<=_bottom;y++)
 
479
    {
 
480
      RowFormat *obj = m_table->nonDefaultRowFormat(y);
 
481
      initParameters( obj,x,y);
 
482
      
 
483
      for (c = m_table->getFirstCellRow(y); c != NULL;
 
484
           c = m_table->getNextCellRight(c->column(), c->row()) )
 
485
      {
 
486
        initParameters( c, c->column(), c->row());
 
487
        if ( eStyle != c->style() )
 
488
          eStyle = KSpreadCell::ST_Undef;
 
489
      }
 
490
      }
 
491
  }
 
492
  else
 
493
  {
374
494
    // Do the other objects have the same values ?
375
495
    for ( int x = _left; x <= _right; x++ )
376
496
    {
377
 
        for ( int y = _top; y <= _bottom; y++ )
378
 
        {
379
 
            KSpreadCell *obj = table->cellAt( x, y );
380
 
            if(!obj->isObscuringForced())
381
 
                {
382
 
                initParameters( obj,x,y);
383
 
                if ( eStyle != obj->style() )
384
 
                        eStyle = KSpreadCell::ST_Undef;
385
 
                }
386
 
        }
387
 
    }
388
 
    }
389
 
    if( !bTextRotation )
390
 
        textRotation = 0;
391
 
 
392
 
    if( _bottom==0x7FFF)
393
 
    {
394
 
     int y=1;
395
 
     ColumnLayout *obj=table->nonDefaultColumnLayout(_left);
396
 
     checkBorderLeft( obj,_left, y);
397
 
 
398
 
     KSpreadCell* c = table->firstCell();
399
 
     for( ;c; c = c->nextCell() )
400
 
        {
401
 
        int col = c->column();
402
 
        if ( _left == col &&!c->isObscuringForced())
403
 
                checkBorderLeft( c,col,c->row());
404
 
        }
405
 
 
406
 
 
407
 
     obj=table->nonDefaultColumnLayout(_right);
408
 
     checkBorderRight(obj,_right,y);
409
 
     c = table->firstCell();
410
 
     for( ;c; c = c->nextCell() )
411
 
        {
412
 
        int col = c->column();
413
 
        if ( _right == col &&!c->isObscuringForced())
414
 
                checkBorderRight(c,col,c->row());
415
 
        }
416
 
 
417
 
     bool once=false;
418
 
     for ( int x = _left; x <= _right; x++ )
419
 
        {
420
 
        KSpreadCell *obj = table->cellAt( x, _top );
421
 
        if(!obj->isObscuringForced())
422
 
                checkBorderTop(obj,x, _top);
423
 
        }
424
 
        once = false;
425
 
     for ( int x = _left; x <= _right; x++ )
426
 
        {
427
 
        KSpreadCell *obj = table->cellAt( x, _bottom );
428
 
        if(!obj->isObscuringForced())
429
 
                checkBorderBottom(obj,x, _bottom);
430
 
        else if( obj->isObscuringForced() && !once)
431
 
                {
432
 
                once=true;
433
 
                int moveX=obj->obscuringCellsColumn();
434
 
                int moveY=obj->obscuringCellsRow();
435
 
                obj = table->nonDefaultCell( moveX,  moveY );
436
 
                checkBorderBottom(obj,moveX,  moveY );
437
 
                }
438
 
        }
439
 
 
440
 
     for ( int x = _left+1; x <= _right; x++ )
441
 
        {
442
 
        obj=table->nonDefaultColumnLayout(x);
443
 
        checkBorderHorizontal(obj,x, y);
444
 
        checkBorderVertical(obj,x, y);
445
 
        }
446
 
 
447
 
    }
448
 
    else if( _right==0x7FFF)
449
 
    {
450
 
      int x=1;
451
 
      bool once=false;
452
 
      for ( int y = _top; y <= _bottom; y++ )
453
 
        {
454
 
        KSpreadCell *obj = table->cellAt( _right, y );
455
 
        if(!obj->isObscuringForced())
456
 
                checkBorderRight(obj,_right,y);
457
 
        else if( obj->isObscuringForced() && !once)
458
 
                {
459
 
                once=true;
460
 
                int moveX=obj->obscuringCellsColumn();
461
 
                int moveY=obj->obscuringCellsRow();
462
 
                obj = table->nonDefaultCell( moveX,  moveY );
463
 
                checkBorderRight(obj,moveX,  moveY);
464
 
                }
465
 
        }
466
 
 
467
 
        for ( int y = _top; y <= _bottom; y++ )
468
 
        {
469
 
                KSpreadCell *obj = table->cellAt( _left, y );
470
 
                if(!obj->isObscuringForced())
471
 
                        checkBorderLeft( obj,_left, y);
472
 
        }
473
 
 
474
 
 
475
 
     RowLayout *obj=table->nonDefaultRowLayout(_top);
476
 
     checkBorderTop(obj,x, _top);
477
 
     obj=table->nonDefaultRowLayout(_bottom);
478
 
     checkBorderBottom(obj,x, _bottom);
479
 
 
480
 
     for ( int y = _top+1; y <= _bottom; y++ )
481
 
        {
482
 
        obj=table->nonDefaultRowLayout(y);
483
 
        checkBorderHorizontal(obj,x, y);
484
 
        checkBorderVertical(obj,x, y);
485
 
        }
486
 
 
487
 
    }
488
 
    else
489
 
    {
490
 
        for ( int y = _top; y <= _bottom; y++ )
491
 
        {
492
 
                KSpreadCell *obj = table->cellAt( _left, y );
493
 
                if(!obj->isObscuringForced())
494
 
                        checkBorderLeft( obj,_left, y);
495
 
        }
496
 
 
497
 
        bool once=false;
498
 
        for ( int y = _top; y <= _bottom; y++ )
499
 
        {
500
 
        KSpreadCell *obj = table->cellAt( _right, y );
501
 
        if(!obj->isObscuringForced())
502
 
                checkBorderRight(obj,_right,y);
503
 
        else if( obj->isObscuringForced() && !once)
504
 
                {
505
 
                once=true;
506
 
                int moveX=obj->obscuringCellsColumn();
507
 
                int moveY=obj->obscuringCellsRow();
508
 
                obj = table->nonDefaultCell( moveX,  moveY );
509
 
                checkBorderRight(obj,moveX,  moveY);
510
 
                }
511
 
        }
512
 
 
513
 
        for ( int x = _left; x <= _right; x++ )
514
 
        {
515
 
        KSpreadCell *obj = table->cellAt( x, _top );
516
 
        if(!obj->isObscuringForced())
517
 
                checkBorderTop(obj,x, _top);
518
 
        }
519
 
 
520
 
        once = false;
521
 
        for ( int x = _left; x <= _right; x++ )
522
 
        {
523
 
        KSpreadCell *obj = table->cellAt( x, _bottom );
524
 
        if(!obj->isObscuringForced())
525
 
                checkBorderBottom(obj,x, _bottom);
526
 
        else if( obj->isObscuringForced() && !once)
527
 
                {
528
 
                once=true;
529
 
                int moveX=obj->obscuringCellsColumn();
530
 
                int moveY=obj->obscuringCellsRow();
531
 
                obj = table->nonDefaultCell( moveX,  moveY );
532
 
                checkBorderBottom(obj,moveX,  moveY );
533
 
                }
534
 
        }
535
 
 
536
 
 
537
 
        // Look for the Outline
538
 
        for ( int x = _left; x <= _right; x++ )
539
 
        {
540
 
                for ( int y = _top+1; y <= _bottom; y++ )
541
 
                {
542
 
                        KSpreadCell *obj = table->cellAt( x, y );
543
 
                        if(!obj->isObscuringForced())
544
 
                                checkBorderHorizontal(obj,x, y);
545
 
                }
546
 
        }
547
 
 
548
 
        for ( int x = _left+1; x <= _right; x++ )
549
 
        {
550
 
                for ( int y = _top; y <= _bottom; y++ )
551
 
                {
552
 
                KSpreadCell *obj = table->cellAt( x, y );
553
 
                if(!obj->isObscuringForced())
554
 
                        checkBorderVertical(obj,x,y);
555
 
                }
556
 
        }
557
 
    }
558
 
    init();
559
 
}
560
 
 
561
 
CellLayoutDlg::~CellLayoutDlg()
562
 
{
563
 
  delete undefinedPixmap;
 
497
      for ( int y = _top; y <= _bottom; y++ )
 
498
      {
 
499
        KSpreadCell *obj = m_table->cellAt( x, y );
 
500
        
 
501
        if ( obj->isObscuringForced() )
 
502
          continue;
 
503
        
 
504
        initParameters( obj,x,y);
 
505
        if ( eStyle != obj->style() )
 
506
          eStyle = KSpreadCell::ST_Undef;
 
507
      }
 
508
    }
 
509
  }
 
510
  if ( !bTextRotation )
 
511
    textRotation = 0;
 
512
 
 
513
  if ( isColumnSelected )
 
514
  {
 
515
    int y=1;
 
516
    ColumnFormat *obj=m_table->nonDefaultColumnFormat(_left);
 
517
    checkBorderLeft( obj,_left, y);
 
518
    
 
519
    KSpreadCell* c = NULL;
 
520
    for (c = m_table->getFirstCellColumn(_left); c != NULL;
 
521
         c = m_table->getNextCellDown(c->column(), c->row()) )
 
522
    {
 
523
      checkBorderLeft(c, c->column(), c->row());
 
524
    }
 
525
    
 
526
    
 
527
    obj=m_table->nonDefaultColumnFormat(_right);
 
528
    checkBorderRight(obj,_right,y);
 
529
    c = NULL;
 
530
    for (c = m_table->getFirstCellColumn(_right); c != NULL;
 
531
         c = m_table->getNextCellDown(c->column(), c->row()) )
 
532
    {
 
533
      checkBorderRight(c, c->column(), c->row());
 
534
    }
 
535
    
 
536
    for ( int x = _left; x <= _right; x++ )
 
537
    {
 
538
      KSpreadCell *obj = m_table->cellAt( x, _top );
 
539
      checkBorderTop(obj,x, _top);
 
540
      obj = m_table->cellAt( x, _bottom );
 
541
      checkBorderBottom(obj,x, _bottom);
 
542
      if ( x > _left )
 
543
      {
 
544
        ColumnFormat *obj = m_table->nonDefaultColumnFormat(x);
 
545
        checkBorderHorizontal(obj,x, y);
 
546
        checkBorderVertical(obj,x, y);
 
547
      }
 
548
    }
 
549
  }
 
550
  else if ( isRowSelected )
 
551
  {
 
552
    int x=1;
 
553
    for ( int y = _top; y <= _bottom; y++ )
 
554
    {
 
555
      KSpreadCell *obj = m_table->cellAt( _right, y );
 
556
      checkBorderRight(obj,_right,y);
 
557
      obj = m_table->cellAt( _left, y );
 
558
      checkBorderLeft( obj,_left, y);
 
559
      if ( y > _top )
 
560
      {
 
561
        RowFormat* obj = m_table->nonDefaultRowFormat(y);
 
562
        checkBorderHorizontal(obj,x, y);
 
563
        checkBorderVertical(obj,x, y);
 
564
      }
 
565
    }
 
566
    
 
567
    RowFormat *obj=m_table->nonDefaultRowFormat(_top);
 
568
    checkBorderTop(obj,x, _top);
 
569
    obj=m_table->nonDefaultRowFormat(_bottom);
 
570
    checkBorderBottom(obj,x, _bottom);
 
571
  }
 
572
  else
 
573
  {
 
574
    for ( int y = _top; y <= _bottom; y++ )
 
575
    {
 
576
      KSpreadCell *obj = m_table->cellAt( _left, y );
 
577
      checkBorderLeft( obj,_left, y);
 
578
      obj = m_table->cellAt( _right, y );
 
579
      checkBorderRight(obj,_right,y);
 
580
    }
 
581
    
 
582
    for ( int x = _left; x <= _right; x++ )
 
583
    {
 
584
      KSpreadCell *obj = m_table->cellAt( x, _top );
 
585
      checkBorderTop( obj, x, _top );
 
586
      obj = m_table->cellAt( x, _bottom );
 
587
      checkBorderBottom( obj, x, _bottom );
 
588
    }
 
589
 
 
590
    // Look for the Outline
 
591
    for ( int x = _left; x <= _right; x++ )
 
592
    {
 
593
      for ( int y = _top+1; y <= _bottom; y++ )
 
594
      {
 
595
        KSpreadCell *obj = m_table->cellAt( x, y );
 
596
        checkBorderHorizontal(obj,x, y);
 
597
      }
 
598
    }
 
599
 
 
600
    for ( int x = _left+1; x <= _right; x++ )
 
601
    {
 
602
      for ( int y = _top; y <= _bottom; y++ )
 
603
      {
 
604
        KSpreadCell *obj = m_table->cellAt( x, y );
 
605
        checkBorderVertical(obj,x,y);
 
606
      }
 
607
    }
 
608
  }
 
609
 
 
610
  init();
 
611
}
 
612
 
 
613
CellFormatDlg::CellFormatDlg( KSpreadView * _view, KSpreadCustomStyle * _style, 
 
614
                              KSpreadStyleManager * _manager, KSpreadDoc * doc )
 
615
  : QObject(),
 
616
    m_doc( doc ),
 
617
    m_table( 0 ),
 
618
    m_pView( _view ),
 
619
    m_style( _style ),
 
620
    m_styleManager( _manager )
 
621
{
 
622
  initMembers();
 
623
  initGUI();
 
624
  init();
 
625
}
 
626
 
 
627
void CellFormatDlg::initGUI()
 
628
{
 
629
  isRowSelected    = false;
 
630
  isColumnSelected = false;
 
631
  styleName = m_style->name();
 
632
  
 
633
  borders[BorderType_Left].style = m_style->leftBorderPen().style();
 
634
  borders[BorderType_Left].width = m_style->leftBorderPen().width();
 
635
  borders[BorderType_Left].color = m_style->leftBorderPen().color();
 
636
 
 
637
  borders[BorderType_Top].style  = m_style->topBorderPen().style();
 
638
  borders[BorderType_Top].width  = m_style->topBorderPen().width();
 
639
  borders[BorderType_Top].color  = m_style->topBorderPen().color();
 
640
 
 
641
  borders[BorderType_Right].style = m_style->rightBorderPen().style();
 
642
  borders[BorderType_Right].width = m_style->rightBorderPen().width();
 
643
  borders[BorderType_Right].color = m_style->rightBorderPen().color();
 
644
 
 
645
  borders[BorderType_Bottom].style = m_style->bottomBorderPen().style();
 
646
  borders[BorderType_Bottom].width = m_style->bottomBorderPen().width();
 
647
  borders[BorderType_Bottom].color = m_style->bottomBorderPen().color();
 
648
 
 
649
  borders[BorderType_FallingDiagonal].style = m_style->fallDiagonalPen().style();
 
650
  borders[BorderType_FallingDiagonal].width = m_style->fallDiagonalPen().width();
 
651
  borders[BorderType_FallingDiagonal].color = m_style->fallDiagonalPen().color();
 
652
 
 
653
  borders[BorderType_RisingDiagonal].style  = m_style->goUpDiagonalPen().style();
 
654
  borders[BorderType_RisingDiagonal].width  = m_style->goUpDiagonalPen().width();
 
655
  borders[BorderType_RisingDiagonal].color  = m_style->goUpDiagonalPen().color();
 
656
 
 
657
  borders[BorderType_Vertical].style = m_style->leftBorderPen().style();
 
658
  borders[BorderType_Vertical].width = m_style->leftBorderPen().width();
 
659
  borders[BorderType_Vertical].color = m_style->leftBorderPen().color();
 
660
  borders[BorderType_Horizontal].style = m_style->topBorderPen().style();
 
661
  borders[BorderType_Horizontal].width = m_style->topBorderPen().width();
 
662
  borders[BorderType_Horizontal].color = m_style->topBorderPen().color();
 
663
 
 
664
  prefix         = m_style->prefix();
 
665
  postfix        = m_style->postfix();
 
666
  precision      = m_style->precision();
 
667
  floatFormat    = m_style->floatFormat();
 
668
  floatColor     = m_style->floatColor();
 
669
  alignX         = m_style->alignX();
 
670
  alignY         = m_style->alignY();
 
671
  textColor      = m_style->pen().color();
 
672
  bgColor        = m_style->bgColor();
 
673
  textFontSize   = m_style->fontSize();
 
674
  textFontFamily = m_style->fontFamily();
 
675
 
 
676
  uint flags     = m_style->fontFlags();
 
677
  textFontBold   = ( flags & (uint) KSpreadStyle::FBold );
 
678
  textFontItalic = ( flags & (uint) KSpreadStyle::FItalic );
 
679
  strike         = ( flags & (uint) KSpreadStyle::FStrike );
 
680
  underline      = ( flags & (uint) KSpreadStyle::FUnderline );
 
681
 
 
682
  // Needed to initialize the font correctly ( bug in Qt )
 
683
  textFont   = m_style->font();
 
684
  cCurrency  = m_style->currency();
 
685
  brushColor = m_style->backGroundBrush().color();
 
686
  brushStyle = m_style->backGroundBrush().style();
 
687
 
 
688
  bMultiRow     = m_style->hasProperty( KSpreadStyle::PMultiRow );
 
689
  bVerticalText = m_style->hasProperty( KSpreadStyle::PVerticalText );
 
690
  textRotation  = m_style->rotateAngle();
 
691
  formatType    = m_style->formatType();
 
692
  indent        = m_style->indent();
 
693
 
 
694
  bDontPrintText = m_style->hasProperty( KSpreadStyle::PDontPrintText );
 
695
  bHideFormula   = m_style->hasProperty( KSpreadStyle::PHideFormula );
 
696
  bHideAll       = m_style->hasProperty( KSpreadStyle::PHideAll );
 
697
  bIsProtected   = !m_style->hasProperty( KSpreadStyle::PNotProtected );
 
698
 
 
699
  cellText = i18n( "The quick brown fox jumps over the lazy dog" );
 
700
}
 
701
 
 
702
CellFormatDlg::~CellFormatDlg()
 
703
{
564
704
  delete formatOnlyNegSignedPixmap;
565
705
  delete formatRedOnlyNegSignedPixmap;
566
706
  delete formatRedNeverSignedPixmap;
568
708
  delete formatRedAlwaysSignedPixmap;
569
709
}
570
710
 
571
 
void CellLayoutDlg::checkBorderRight(KSpreadLayout *obj,int x,int y)
572
 
{
573
 
if ( rightBorderStyle != obj->rightBorderStyle( x, y ) )
574
 
        bRightBorderStyle = FALSE;
575
 
if ( rightBorderWidth != obj->rightBorderWidth( x, y ) )
576
 
        bRightBorderStyle = FALSE;
577
 
if ( rightBorderColor != obj->rightBorderColor( x, y ) )
578
 
        bRightBorderColor = FALSE;
579
 
}
580
 
 
581
 
void CellLayoutDlg::checkBorderLeft(KSpreadLayout *obj,int x,int y)
582
 
{
583
 
if ( leftBorderStyle != obj->leftBorderStyle( x, y ) )
584
 
        bLeftBorderStyle = FALSE;
585
 
if ( leftBorderWidth != obj->leftBorderWidth( x, y ) )
586
 
        bLeftBorderStyle = FALSE;
587
 
if ( leftBorderColor != obj->leftBorderColor( x, y ) )
588
 
        bLeftBorderColor = FALSE;
589
 
}
590
 
 
591
 
void CellLayoutDlg::checkBorderTop(KSpreadLayout *obj,int x,int y)
592
 
{
593
 
if (  topBorderStyle != obj->topBorderStyle( x, y ) )
594
 
        bTopBorderStyle = FALSE;
595
 
if ( topBorderWidth != obj->topBorderWidth( x, y ) )
596
 
        bTopBorderStyle = FALSE;
597
 
if ( topBorderColor != obj->topBorderColor( x, y ) )
598
 
        bTopBorderColor = FALSE;
599
 
}
600
 
 
601
 
void CellLayoutDlg::checkBorderBottom(KSpreadLayout *obj,int x,int y)
602
 
{
603
 
if ( bottomBorderStyle != obj->bottomBorderStyle( x, y ) )
604
 
        bBottomBorderStyle = FALSE;
605
 
if ( bottomBorderWidth != obj->bottomBorderWidth( x,y ) )
606
 
        bBottomBorderStyle = FALSE;
607
 
if ( bottomBorderColor != obj->bottomBorderColor( x, y ) )
608
 
        bBottomBorderColor = FALSE;
609
 
}
610
 
 
611
 
void CellLayoutDlg::checkBorderVertical(KSpreadLayout *obj,int x,int y)
612
 
{
613
 
if ( verticalBorderStyle != obj->leftBorderStyle( x, y ) )
614
 
        bVerticalBorderStyle = FALSE;
615
 
if ( verticalBorderWidth != obj->leftBorderWidth( x, y ) )
616
 
        bVerticalBorderStyle = FALSE;
617
 
if ( verticalBorderColor != obj->leftBorderColor( x, y ) )
618
 
        bVerticalBorderColor = FALSE;
619
 
}
620
 
 
621
 
void CellLayoutDlg::checkBorderHorizontal(KSpreadLayout *obj,int x,int y)
622
 
{
623
 
if ( horizontalBorderStyle != obj->topBorderStyle( x, y ) )
624
 
        bHorizontalBorderStyle = FALSE;
625
 
if ( horizontalBorderWidth != obj->topBorderWidth( x, y ) )
626
 
        bHorizontalBorderStyle = FALSE;
627
 
if ( horizontalBorderColor != obj->topBorderColor( x, y ) )
628
 
        bHorizontalBorderColor = FALSE;
629
 
}
630
 
 
631
 
 
632
 
void CellLayoutDlg::initParameters(KSpreadLayout *obj,int x,int y)
633
 
{
634
 
        if ( fallDiagonalStyle != obj->fallDiagonalStyle( x, y ) )
635
 
                bFallDiagonalStyle = FALSE;
636
 
        if ( fallDiagonalWidth != obj->fallDiagonalWidth( x, y ) )
637
 
                bFallDiagonalStyle = FALSE;
638
 
        if ( fallDiagonalColor != obj->fallDiagonalColor( x, y ) )
639
 
                bfallDiagonalColor = FALSE;
640
 
        if ( goUpDiagonalStyle != obj->goUpDiagonalStyle( x, y ) )
641
 
                bGoUpDiagonalStyle = FALSE;
642
 
        if ( goUpDiagonalWidth != obj->goUpDiagonalWidth( x, y ) )
643
 
                bGoUpDiagonalStyle = FALSE;
644
 
        if ( goUpDiagonalColor != obj->goUpDiagonalColor( x, y ) )
645
 
                bGoUpDiagonalColor = FALSE;
646
 
        if ( strike != obj->textFontStrike( x, y ) )
647
 
                bStrike = FALSE;
648
 
        if ( underline != obj->textFontUnderline( x, y ) )
649
 
                bUnderline = FALSE;
650
 
        if ( prefix != obj->prefix( x, y ) )
651
 
                prefix = QString::null;
652
 
        if ( postfix != obj->postfix( x, y ) )
653
 
                postfix = QString::null;
654
 
        if ( floatFormat != obj->floatFormat( x, y ) )
655
 
                bFloatFormat = FALSE;
656
 
        if ( floatColor != obj->floatColor( x, y ) )
657
 
                bFloatColor = FALSE;
658
 
        if ( textColor != obj->textColor( x, y ) )
659
 
                bTextColor = FALSE;
660
 
        if ( textFontFamily != obj->textFontFamily( x, y ) )
661
 
                bTextFontFamily = FALSE;
662
 
        if ( textFontSize != obj->textFontSize( x, y ) )
663
 
                bTextFontSize = FALSE;
664
 
        if ( textFontBold != obj->textFontBold( x, y ) )
665
 
                bTextFontBold = FALSE;
666
 
        if ( textFontItalic != obj->textFontItalic( x, y ) )
667
 
                bTextFontItalic = FALSE;
668
 
        if ( bgColor != obj->bgColor( x, y ) )
669
 
                bBgColor = FALSE;
670
 
        if( textRotation != obj->getAngle(left, top) )
671
 
                bTextRotation = FALSE;
672
 
        if( formatNumber != obj->getFormatNumber(left, top) )
673
 
                bFormatNumber = FALSE;
674
 
        if( bMultiRow != obj->multiRow( left, top ) )
675
 
                bMultiRow = FALSE;
676
 
        if( bVerticalText!=obj->verticalText( left, top ) )
677
 
                bVerticalText = FALSE;
678
 
        if(  bDontprintText!=obj->getDontprintText( left, top ) )
679
 
          bDontprintText= FALSE;
680
 
}
681
 
 
682
 
void CellLayoutDlg::init()
683
 
{
684
 
    QColorGroup colorGroup = QApplication::palette().active();
685
 
    // Did we initialize the bitmaps ?
686
 
    if ( formatOnlyNegSignedPixmap == 0L )
687
 
    {
688
 
        QColor black = colorGroup.text(); // not necessarily black :)
689
 
        formatOnlyNegSignedPixmap = paintFormatPixmap( "123.456", black, "-123.456", black );
690
 
        formatRedOnlyNegSignedPixmap = paintFormatPixmap( "123.456", black, "-123.456", Qt::red );
691
 
        formatRedNeverSignedPixmap = paintFormatPixmap( "123.456", black, "123.456", Qt::red );
692
 
        formatAlwaysSignedPixmap = paintFormatPixmap( "+123.456", black, "-123.456", black );
693
 
        formatRedAlwaysSignedPixmap = paintFormatPixmap( "+123.456", black, "-123.456", Qt::red );
694
 
 
695
 
        // Make the undefined pixmap
696
 
        undefinedPixmap = new QPixmap( 100, 12 );
697
 
        QPainter painter;
698
 
        painter.begin( undefinedPixmap );
699
 
        painter.setBackgroundColor( colorGroup.base() );
700
 
        painter.setPen( colorGroup.text() );
701
 
        painter.fillRect( 0, 0, 100, 12, BDiagPattern );
702
 
        painter.end();
703
 
    }
704
 
 
705
 
    tab = new QTabDialog( (QWidget*)m_pView, 0L, TRUE );
706
 
    tab->setGeometry( tab->x(), tab->y(), 420, 400 );
707
 
 
708
 
    borderPage = new CellLayoutPageBorder( tab, this );
709
 
    tab->addTab( borderPage, i18n("&Border") );
710
 
 
711
 
    floatPage = new CellLayoutPageFloat( tab, this );
712
 
    tab->addTab( floatPage, i18n("&Number Format") );
713
 
 
714
 
    miscPage = new CellLayoutPageMisc( tab, this );
715
 
    tab->addTab( miscPage, i18n("&Misc") );
716
 
 
717
 
    fontPage = new CellLayoutPageFont( tab, this );
718
 
    tab->addTab( fontPage, i18n("&Text") );
719
 
 
720
 
    positionPage = new CellLayoutPagePosition( tab, this);
721
 
    tab->addTab( positionPage, i18n("&Position") );
722
 
 
723
 
    patternPage=new CellLayoutPagePattern(tab,this);
724
 
    tab->addTab( patternPage,i18n("Back&ground"));
725
 
 
726
 
    tab->setCancelButton();
727
 
 
728
 
    tab->setCaption(i18n("Cell Layout"));
729
 
 
730
 
    connect( tab, SIGNAL( applyButtonPressed() ), this, SLOT( slotApply() ) );
731
 
 
732
 
    tab->show();
733
 
}
734
 
 
735
 
QPixmap* CellLayoutDlg::paintFormatPixmap( const char *_string1, const QColor & _color1,
736
 
                                             const char *_string2, const QColor & _color2 )
737
 
{
738
 
    QPixmap *pixmap = new QPixmap( 150, 14 );
739
 
 
740
 
    QPainter painter;
741
 
    painter.begin( pixmap );
742
 
    painter.fillRect( 0, 0, 150, 14, QApplication::palette().active().base() );
743
 
    painter.setPen( _color1 );
744
 
    painter.drawText( 2, 11, _string1 );
745
 
    painter.setPen( _color2 );
746
 
    painter.drawText( 75, 11, _string2 );
747
 
    painter.end();
748
 
 
749
 
    return pixmap;
750
 
}
751
 
 
752
 
int CellLayoutDlg::exec()
753
 
{
754
 
    return ( tab->exec() );
755
 
}
756
 
 
757
 
void CellLayoutDlg::slotApply()
758
 
{
759
 
    KSpreadMacroUndoAction *macroUndo=new KSpreadMacroUndoAction( table->doc(),i18n("Change Layout") );
760
 
 
761
 
    if( isMerged!= positionPage->getMergedCellState())
762
 
    {
763
 
        if(positionPage->getMergedCellState())
764
 
        {
765
 
            KSpreadCell *obj = table->nonDefaultCell( left,top );
766
 
 
767
 
            KSpreadUndoMergedCell *undo = new KSpreadUndoMergedCell( table->doc(), table, left ,top ,obj->extraXCells() ,obj->extraYCells());
768
 
            macroUndo->addCommand(undo);
769
 
 
770
 
            //merge cell doesn't create undo
771
 
            table->mergeCell(QPoint(left,top),false);
772
 
            right=left;
773
 
            bottom=top;
774
 
        }
775
 
        else
776
 
        {
777
 
            //dissociate cells
778
 
            KSpreadCell *obj = table->nonDefaultCell( left,top );
779
 
            right=obj->extraXCells()+left;
780
 
            bottom=obj->extraYCells()+top;
781
 
 
782
 
            KSpreadUndoMergedCell *undo = new KSpreadUndoMergedCell( table->doc(), table, left ,top,obj->extraXCells() ,obj->extraYCells());
783
 
            macroUndo->addCommand(undo);
784
 
 
785
 
            table->dissociateCell(QPoint(left,top),false);
786
 
        }
787
 
 
788
 
    }
789
 
 
790
 
    // Prepare the undo buffer
791
 
    if ( !table->doc()->undoBuffer()->isLocked() )
792
 
    {
793
 
        QRect rect;
794
 
        // Since the right/bottom border is stored in objects right + 1 ( or: bottom + 1 )
795
 
        // So we have to save these layouts, too
796
 
        if(right!=0x7FFF && bottom!=0x7FFF)
797
 
            rect.setCoords( left, top, right + 1, bottom + 1 );
798
 
        else if( right==0x7FFF)
799
 
            rect.setCoords( left, top, right , bottom+1  );
800
 
        else if( bottom==0x7FFF)
801
 
        {
802
 
            //create cell before to apply
803
 
            RowLayout* rw =table->firstRow();
804
 
            for( ; rw; rw = rw->next() )
805
 
            {
806
 
                if ( !rw->isDefault() )
807
 
                {
808
 
                    for(int i=left;i<=right;i++)
809
 
                    {
810
 
                        KSpreadCell *cell = table->cellAt( i,  rw->row());
811
 
                        if ( cell->isDefault() )
812
 
                        {
813
 
                            cell = new KSpreadCell( table, i,  rw->row() );
814
 
                            table->insertCell( cell);
815
 
                        }
816
 
                    }
817
 
                }
818
 
            }
819
 
            rect.setCoords( left, top, right+1 , bottom  );
820
 
        }
821
 
 
822
 
        QString title=i18n("Change layout");
823
 
        KSpreadUndoCellLayout *undo = new KSpreadUndoCellLayout( table->doc(), table, rect,title );
824
 
//        table->doc()->undoBuffer()->appendUndo( undo );
825
 
        macroUndo->addCommand(undo);
826
 
 
827
 
        if( miscPage->getStyle()!=eStyle)
828
 
        {
829
 
            //make undo for style of cell
830
 
            KSpreadUndoStyleCell *undo3 = new KSpreadUndoStyleCell( table->doc(), table, rect);
831
 
            //table->doc()->undoBuffer()->appendUndo( undo3 );
832
 
            macroUndo->addCommand(undo3);
833
 
        }
834
 
    }
835
 
    borderPage->applyOutline( left, top, right, bottom );
836
 
 
837
 
 
838
 
 
839
 
    if(right!=0x7FFF && bottom!=0x7FFF)
840
 
    {
841
 
        for ( int x = left; x <= right; x++ )
842
 
            for ( int y = top; y <= bottom; y++ )
843
 
            {
844
 
                KSpreadCell *obj = table->nonDefaultCell( x, y );
845
 
                if(!obj->isObscuringForced())
846
 
                {
847
 
                    floatPage->apply( obj );
848
 
                    miscPage->apply( obj );
849
 
                    fontPage->apply( obj );
850
 
                    positionPage->apply( obj );
851
 
                    patternPage->apply(obj);
852
 
                }
853
 
            }
854
 
 
855
 
 
856
 
        if(positionPage->getSizeHeight()!=heigthSize
857
 
           || positionPage->getSizeWidth()!=widthSize)
858
 
        {
859
 
            if ( !table->doc()->undoBuffer()->isLocked())
860
 
            {
861
 
                QRect rect;
862
 
                rect.setCoords( left, top, right , bottom  );
863
 
                KSpreadUndoResizeColRow *undo2 = new KSpreadUndoResizeColRow( table->doc(),table , rect );
864
 
                //table->doc()->undoBuffer()->appendUndo( undo2 );
865
 
                macroUndo->addCommand(undo2);
866
 
            }
867
 
        }
868
 
        if(positionPage->getSizeHeight()!=heigthSize)
869
 
        {
870
 
            for ( int x = top; x <= bottom; x++ )
871
 
                m_pView->vBorderWidget()->resizeRow(positionPage->getSizeHeight(),x,false );
872
 
 
873
 
        }
874
 
        if(positionPage->getSizeWidth()!=widthSize)
875
 
        {
876
 
            for ( int x = left; x <= right; x++ )
877
 
                m_pView->hBorderWidget()->resizeColumn(positionPage->getSizeWidth(),x,false );
878
 
        }
879
 
 
880
 
    }
881
 
    else if( right==0x7FFF )
882
 
    {
883
 
        for(int i=top;i<=bottom;i++)
884
 
        {
885
 
            RowLayout *rw=table->nonDefaultRowLayout(i);
886
 
            floatPage->apply(rw );
887
 
            fontPage->apply( rw );
888
 
            positionPage->apply( rw );
889
 
            patternPage->apply(rw);
890
 
        }
891
 
        miscPage->applyRow( );
892
 
        if(positionPage->getSizeHeight()!=heigthSize)
893
 
        {
894
 
            if ( !table->doc()->undoBuffer()->isLocked())
895
 
            {
896
 
                QRect rect;
897
 
                rect.setCoords( left, top, right , bottom  );
898
 
                KSpreadUndoResizeColRow *undo2 = new KSpreadUndoResizeColRow( table->doc(),table , rect );
899
 
                //table->doc()->undoBuffer()->appendUndo( undo2 );
900
 
                macroUndo->addCommand(undo2);
901
 
            }
902
 
            for ( int x = top; x <= bottom; x++ )
903
 
                m_pView->vBorderWidget()->resizeRow(positionPage->getSizeHeight(),x,false );
904
 
        }
905
 
    }
906
 
    else if( bottom==0x7FFF)
907
 
    {
908
 
        for(int i=left;i<=right;i++)
909
 
        {
910
 
            ColumnLayout *cl=table->nonDefaultColumnLayout(i);
911
 
            floatPage->apply(cl );
912
 
            fontPage->apply( cl );
913
 
            positionPage->apply( cl );
914
 
            patternPage->apply(cl);
915
 
        }
916
 
        miscPage->applyColumn( );
917
 
 
918
 
        if( positionPage->getSizeWidth()!=widthSize)
919
 
        {
920
 
            if ( !table->doc()->undoBuffer()->isLocked())
921
 
            {
922
 
                QRect rect;
923
 
                rect.setCoords( left, top, right , bottom  );
924
 
                KSpreadUndoResizeColRow *undo2 = new KSpreadUndoResizeColRow( table->doc(),table , rect );
925
 
                //table->doc()->undoBuffer()->appendUndo( undo2 );
926
 
                macroUndo->addCommand(undo2);
927
 
            }
928
 
            for ( int x = left; x <= right; x++ )
929
 
                m_pView->hBorderWidget()->resizeColumn(positionPage->getSizeWidth(),x,false );
930
 
        }
931
 
    }
932
 
 
933
 
    if ( !table->doc()->undoBuffer()->isLocked())
934
 
    {
935
 
        table->doc()->undoBuffer()->appendUndo( macroUndo );
936
 
    }
937
 
    // m_pView->drawVisibleCells();
938
 
    QRect r;
939
 
    r.setCoords( left, top, right, bottom );
940
 
    m_pView->slotUpdateView( table, r );
941
 
    m_pView->doc()->setModified( true );
942
 
    // Update the toolbar (bold/italic/font...)
943
 
    m_pView->updateEditWidget();
944
 
}
945
 
 
946
 
 
947
 
CellLayoutPageFloat::CellLayoutPageFloat( QWidget* parent, CellLayoutDlg *_dlg ) : QWidget ( parent )
948
 
{
949
 
    dlg = _dlg;
950
 
 
 
711
void CellFormatDlg::initMembers()
 
712
{
 
713
  formatOnlyNegSignedPixmap    = 0L;
 
714
  formatRedOnlyNegSignedPixmap = 0L;
 
715
  formatRedNeverSignedPixmap   = 0L;
 
716
  formatAlwaysSignedPixmap     = 0L;
 
717
  formatRedAlwaysSignedPixmap  = 0L;
 
718
 
 
719
  m_bValue = false;
 
720
  m_bDate  = false;
 
721
  m_bTime  = false;
 
722
 
 
723
  // We assume, that all other objects have the same values
 
724
  for ( int i = 0; i < BorderType_END; ++i )
 
725
  {
 
726
    borders[i].bStyle = true;
 
727
    borders[i].bColor = true;
 
728
  }
 
729
  bFloatFormat    = true;
 
730
  bFloatColor     = true;
 
731
  bTextColor      = true;
 
732
  bBgColor        = true;
 
733
  bTextFontFamily = true;
 
734
  bTextFontSize   = true;
 
735
  bTextFontBold   = true;
 
736
  bTextFontItalic = true;
 
737
  bStrike         = true;
 
738
  bUnderline      = true;
 
739
  bTextRotation   = true;
 
740
  bFormatType     = true;
 
741
  bCurrency       = true;
 
742
  bDontPrintText  = false;
 
743
  bHideFormula    = false;
 
744
  bHideAll        = false;
 
745
  bIsProtected    = true;
 
746
  
 
747
  cCurrency.symbol = locale()->currencySymbol();
 
748
  cCurrency.type   = 0;
 
749
}
 
750
 
 
751
bool CellFormatDlg::checkCircle( QString const & name, QString const & parent )
 
752
{
 
753
  return m_styleManager->checkCircle( name, parent );
 
754
}
 
755
 
 
756
void CellFormatDlg::checkBorderRight(KSpreadFormat *obj,int x,int y)
 
757
{
 
758
  if ( borders[BorderType_Right].style != obj->rightBorderStyle( x, y ) ||
 
759
       borders[BorderType_Right].width != obj->rightBorderWidth( x, y ) )
 
760
    borders[BorderType_Right].bStyle = false;
 
761
  if ( borders[BorderType_Right].color != obj->rightBorderColor( x, y ) )
 
762
    borders[BorderType_Right].bColor = false;
 
763
}
 
764
 
 
765
void CellFormatDlg::checkBorderLeft(KSpreadFormat *obj,int x,int y)
 
766
{
 
767
  if ( borders[BorderType_Left].style != obj->leftBorderStyle( x, y ) ||
 
768
       borders[BorderType_Left].width != obj->leftBorderWidth( x, y ) )
 
769
    borders[BorderType_Left].bStyle = false;
 
770
  if ( borders[BorderType_Left].color != obj->leftBorderColor( x, y ) )
 
771
    borders[BorderType_Left].bColor = false;
 
772
}
 
773
 
 
774
void CellFormatDlg::checkBorderTop(KSpreadFormat *obj,int x,int y)
 
775
{
 
776
  if ( borders[BorderType_Top].style != obj->topBorderStyle( x, y ) ||
 
777
       borders[BorderType_Top].width != obj->topBorderWidth( x, y ) )
 
778
    borders[BorderType_Top].bStyle = false;
 
779
  if ( borders[BorderType_Top].color != obj->topBorderColor( x, y ) )
 
780
    borders[BorderType_Top].bColor = false;
 
781
}
 
782
 
 
783
void CellFormatDlg::checkBorderBottom(KSpreadFormat *obj,int x,int y)
 
784
{
 
785
  if ( borders[BorderType_Bottom].style != obj->bottomBorderStyle( x, y ) ||
 
786
       borders[BorderType_Bottom].width != obj->bottomBorderWidth( x, y ) )
 
787
    borders[BorderType_Bottom].bStyle = false;
 
788
  if ( borders[BorderType_Bottom].color != obj->bottomBorderColor( x, y ) )
 
789
    borders[BorderType_Bottom].bColor = false;
 
790
}
 
791
 
 
792
void CellFormatDlg::checkBorderVertical(KSpreadFormat *obj,int x,int y)
 
793
{
 
794
  if (borders[BorderType_Vertical].style != obj->leftBorderStyle( x, y ) ||
 
795
      borders[BorderType_Vertical].width != obj->leftBorderWidth( x, y ))
 
796
    borders[BorderType_Vertical].bStyle = false;
 
797
  if ( borders[BorderType_Vertical].color != obj->leftBorderColor( x, y ) )
 
798
    borders[BorderType_Vertical].bColor = false;
 
799
}
 
800
 
 
801
void CellFormatDlg::checkBorderHorizontal(KSpreadFormat *obj,int x,int y)
 
802
{
 
803
  if ( borders[BorderType_Horizontal].style != obj->topBorderStyle( x, y ) ||
 
804
       borders[BorderType_Horizontal].width != obj->topBorderWidth( x, y ) )
 
805
    borders[BorderType_Horizontal].bStyle = false;
 
806
  if ( borders[BorderType_Horizontal].color != obj->topBorderColor( x, y ) )
 
807
    borders[BorderType_Horizontal].bColor = false;
 
808
}
 
809
 
 
810
 
 
811
void CellFormatDlg::initParameters(KSpreadFormat *obj,int x,int y)
 
812
{
 
813
  if (borders[BorderType_FallingDiagonal].style != obj->fallDiagonalStyle( x, y ))
 
814
    borders[BorderType_FallingDiagonal].bStyle = false;
 
815
  if (borders[BorderType_FallingDiagonal].width != obj->fallDiagonalWidth( x, y ))
 
816
    borders[BorderType_FallingDiagonal].bStyle = false;
 
817
  if (borders[BorderType_FallingDiagonal].color != obj->fallDiagonalColor( x, y ))
 
818
    borders[BorderType_FallingDiagonal].bColor = false;
 
819
 
 
820
  if (borders[BorderType_RisingDiagonal].style != obj->goUpDiagonalStyle( x, y ))
 
821
    borders[BorderType_RisingDiagonal].bStyle = false;
 
822
  if (borders[BorderType_RisingDiagonal].width != obj->goUpDiagonalWidth( x, y ))
 
823
    borders[BorderType_RisingDiagonal].bStyle = false;
 
824
  if (borders[BorderType_RisingDiagonal].color != obj->goUpDiagonalColor( x, y ))
 
825
    borders[BorderType_RisingDiagonal].bColor = false;
 
826
  if ( strike != obj->textFontStrike( x, y ) )
 
827
    bStrike = false;
 
828
  if ( underline != obj->textFontUnderline( x, y ) )
 
829
    bUnderline = false;
 
830
  if ( prefix != obj->prefix( x, y ) )
 
831
    prefix = QString::null;
 
832
  if ( postfix != obj->postfix( x, y ) )
 
833
    postfix = QString::null;
 
834
  if ( floatFormat != obj->floatFormat( x, y ) )
 
835
    bFloatFormat = false;
 
836
  if ( floatColor != obj->floatColor( x, y ) )
 
837
    bFloatColor = false;
 
838
  if ( textColor != obj->textColor( x, y ) )
 
839
    bTextColor = false;
 
840
  if ( textFontFamily != obj->textFontFamily( x, y ) )
 
841
    bTextFontFamily = false;
 
842
  if ( textFontSize != obj->textFontSize( x, y ) )
 
843
    bTextFontSize = false;
 
844
  if ( textFontBold != obj->textFontBold( x, y ) )
 
845
    bTextFontBold = false;
 
846
  if ( textFontItalic != obj->textFontItalic( x, y ) )
 
847
    bTextFontItalic = false;
 
848
  if ( bgColor != obj->bgColor( x, y ) )
 
849
    bBgColor = false;
 
850
  if ( textRotation != obj->getAngle(left, top) )
 
851
    bTextRotation = false;
 
852
  if ( formatType != obj->getFormatType(left, top) )
 
853
    bFormatType = false;
 
854
  if ( bMultiRow != obj->multiRow( left, top ) )
 
855
    bMultiRow = false;
 
856
  if ( bVerticalText!=obj->verticalText( left, top ) )
 
857
    bVerticalText = false;
 
858
  if (  bDontPrintText!=obj->getDontprintText( left, top ) )
 
859
    bDontPrintText= false;
 
860
 
 
861
  KSpreadCell::Currency cur;
 
862
  if (!obj->currencyInfo(cur))
 
863
    bCurrency = false;
 
864
  else
 
865
    if (cur.symbol != cCurrency.symbol)
 
866
      bCurrency = false;
 
867
}
 
868
 
 
869
void CellFormatDlg::init()
 
870
{
 
871
  QColorGroup colorGroup = QApplication::palette().active();
 
872
  
 
873
  // Did we initialize the bitmaps ?
 
874
  if ( formatOnlyNegSignedPixmap == 0L )
 
875
  {
 
876
    QColor black = colorGroup.text(); // not necessarily black :)
 
877
    formatOnlyNegSignedPixmap    = paintFormatPixmap( "123.456", black, "-123.456", black );
 
878
    formatRedOnlyNegSignedPixmap = paintFormatPixmap( "123.456", black, "-123.456", Qt::red );
 
879
    formatRedNeverSignedPixmap   = paintFormatPixmap( "123.456", black, "123.456", Qt::red );
 
880
    formatAlwaysSignedPixmap     = paintFormatPixmap( "+123.456", black, "-123.456", black );
 
881
    formatRedAlwaysSignedPixmap  = paintFormatPixmap( "+123.456", black, "-123.456", Qt::red );
 
882
  }
 
883
 
 
884
  tab = new QTabDialog( (QWidget*)m_pView, 0L, true );
 
885
  tab->setGeometry( tab->x(), tab->y(), 420, 400 );
 
886
 
 
887
  if ( m_style )
 
888
  {
 
889
    generalPage = new GeneralTab( tab, this );
 
890
    tab->addTab( generalPage, i18n( "&General" ) );    
 
891
  }
 
892
 
 
893
  floatPage = new CellFormatPageFloat( tab, this );
 
894
  tab->addTab( floatPage, i18n("&Data Format") );
 
895
  
 
896
  fontPage = new CellFormatPageFont( tab, this );
 
897
  tab->addTab( fontPage, i18n("&Text") );
 
898
  
 
899
  //  miscPage = new CellFormatPageMisc( tab, this );
 
900
  //  tab->addTab( miscPage, i18n("&Misc") );
 
901
 
 
902
  positionPage = new CellFormatPagePosition( tab, this);
 
903
  tab->addTab( positionPage, i18n("&Position") );
 
904
  
 
905
  borderPage = new CellFormatPageBorder( tab, this );
 
906
  tab->addTab( borderPage, i18n("&Border") );
 
907
 
 
908
  patternPage=new CellFormatPagePattern(tab,this);
 
909
  tab->addTab( patternPage,i18n("Back&ground"));
 
910
  
 
911
  protectPage = new CellFormatPageProtection( tab, this );
 
912
  tab->addTab( protectPage, i18n("&Cell Protection") );
 
913
 
 
914
  tab->setCancelButton( i18n( "&Cancel" ) );
 
915
  tab->setOkButton( i18n( "&OK" ) );
 
916
  
 
917
  tab->setCaption( i18n( "Cell Format" ) );
 
918
  
 
919
  connect( tab, SIGNAL( applyButtonPressed() ), this, SLOT( slotApply() ) );
 
920
 
 
921
  tab->exec();
 
922
}
 
923
 
 
924
QPixmap * CellFormatDlg::paintFormatPixmap( const char * _string1, const QColor & _color1,
 
925
                                            const char *_string2, const QColor & _color2 )
 
926
{
 
927
  QPixmap * pixmap = new QPixmap( 150, 14 );
 
928
 
 
929
  QPainter painter;
 
930
  painter.begin( pixmap );
 
931
  painter.fillRect( 0, 0, 150, 14, QApplication::palette().active().base() );
 
932
  painter.setPen( _color1 );
 
933
  painter.drawText( 2, 11, _string1 );
 
934
  painter.setPen( _color2 );
 
935
  painter.drawText( 75, 11, _string2 );
 
936
  painter.end();
 
937
 
 
938
  QBitmap bm( pixmap->size() );
 
939
  bm.fill( color0 );
 
940
  painter.begin( &bm );
 
941
  painter.setPen( color1 );
 
942
  painter.drawText( 2, 11, _string1 );
 
943
  painter.drawText( 75, 11, _string2 );
 
944
  painter.end();
 
945
  pixmap->setMask( bm );
 
946
 
 
947
  return pixmap;
 
948
}
 
949
 
 
950
int CellFormatDlg::exec()
 
951
{
 
952
  return ( tab->exec() );
 
953
}
 
954
 
 
955
void CellFormatDlg::applyStyle()
 
956
{
 
957
  generalPage->apply( m_style );
 
958
 
 
959
  borderPage->applyOutline();
 
960
  floatPage->apply( m_style );
 
961
  // miscPage->apply( m_style );
 
962
  fontPage->apply( m_style );
 
963
  positionPage->apply( m_style );
 
964
  patternPage->apply( m_style );
 
965
  protectPage->apply( m_style );
 
966
}
 
967
 
 
968
void CellFormatDlg::slotApply()
 
969
{
 
970
  if ( m_style )
 
971
  {
 
972
    applyStyle();
 
973
    return;
 
974
  }
 
975
 
 
976
  m_pView->doc()->emitBeginOperation( false );
 
977
  KSpreadCell * cell = 0;
 
978
 
 
979
  KSpreadMacroUndoAction * macroUndo = new KSpreadMacroUndoAction( m_doc, i18n("Change Format") );
 
980
 
 
981
  if ( isMerged != positionPage->getMergedCellState() )
 
982
  {
 
983
    if ( positionPage->getMergedCellState() )
 
984
    {
 
985
      KSpreadCell * obj = m_table->nonDefaultCell( left, top );
 
986
 
 
987
      KSpreadUndoMergedCell * undo = new KSpreadUndoMergedCell( m_doc, m_table, left,
 
988
                                                                top, obj->extraXCells(), obj->extraYCells() );
 
989
      macroUndo->addCommand( undo );
 
990
 
 
991
      //merge cell doesn't create undo
 
992
      m_table->mergeCells( m_pView->selection(), false );
 
993
      right  = left;
 
994
      bottom = top;
 
995
    }
 
996
    else
 
997
    {
 
998
      //dissociate cells
 
999
      KSpreadCell * obj = m_table->nonDefaultCell( left, top );
 
1000
      right  = obj->extraXCells() + left;
 
1001
      bottom = obj->extraYCells() + top;
 
1002
      
 
1003
      KSpreadUndoMergedCell * undo = new KSpreadUndoMergedCell( m_doc, m_table, left,
 
1004
                                                                top, obj->extraXCells(), obj->extraYCells() );
 
1005
      macroUndo->addCommand(undo);
 
1006
      
 
1007
      m_table->dissociateCell(QPoint(left,top),false);
 
1008
    }    
 
1009
  }
 
1010
 
 
1011
  // Prepare the undo buffer
 
1012
  if ( !m_doc->undoBuffer()->isLocked() )
 
1013
  {
 
1014
    QRect rect;
 
1015
 
 
1016
    // Since the right/bottom border is stored in objects right + 1 ( or: bottom + 1 )
 
1017
    // So we have to save these formats, too
 
1018
    if ( (!isRowSelected ) && ( !isColumnSelected ) )
 
1019
      rect.setCoords( left, top, right + 1, bottom + 1 );
 
1020
    else if ( isRowSelected )
 
1021
      rect.setCoords( left, top, right, bottom + 1  );
 
1022
    else if ( isColumnSelected )
 
1023
    {
 
1024
      //create cell before to apply
 
1025
      RowFormat * rw = m_table->firstRow();
 
1026
      for ( ; rw; rw = rw->next() )
 
1027
      {
 
1028
        if ( !rw->isDefault() )
 
1029
        {
 
1030
          for ( int i = left; i <= right; ++i )
 
1031
          {
 
1032
            cell = m_table->nonDefaultCell( i, rw->row() );
 
1033
          }
 
1034
        }
 
1035
      }
 
1036
      rect.setCoords( left, top, right + 1, bottom  );
 
1037
    }
 
1038
    
 
1039
    QString title = i18n( "Change Format" );
 
1040
    KSpreadUndoCellFormat * undo = new KSpreadUndoCellFormat( m_doc, m_table, rect, title );
 
1041
    // m_doc->undoBuffer()->appendUndo( undo );
 
1042
    macroUndo->addCommand( undo );
 
1043
 
 
1044
    /*  if ( miscPage->getStyle()!=eStyle)
 
1045
        {
 
1046
        //make undo for style of cell
 
1047
        KSpreadUndoStyleCell *undo3 = new KSpreadUndoStyleCell( m_doc, m_table, rect );
 
1048
        //m_doc->undoBuffer()->appendUndo( undo3 );
 
1049
        macroUndo->addCommand( undo3 );
 
1050
        }*/
 
1051
  }
 
1052
  borderPage->applyOutline();
 
1053
  
 
1054
  if ( ( !isRowSelected ) && ( !isColumnSelected ) )
 
1055
  {
 
1056
    for ( int x = left; x <= right; x++ )
 
1057
      for ( int y = top; y <= bottom; y++ )
 
1058
      {
 
1059
        KSpreadCell *obj = m_table->nonDefaultCell( x, y );
 
1060
        if ( !obj->isObscuringForced() )
 
1061
        {
 
1062
          floatPage->apply( obj );
 
1063
          //                    miscPage->apply( obj );
 
1064
          fontPage->apply( obj );
 
1065
          positionPage->apply( obj );
 
1066
          patternPage->apply(obj);
 
1067
          protectPage->apply( obj );
 
1068
        }
 
1069
      }
 
1070
    
 
1071
    // Check for a change in the height and width of the cells
 
1072
    if ( int( positionPage->getSizeHeight() ) != int( heightSize )
 
1073
         || int( positionPage->getSizeWidth() ) != int( widthSize ) )
 
1074
    {
 
1075
      if ( !m_doc->undoBuffer()->isLocked() )
 
1076
      {
 
1077
        QRect rect;
 
1078
        rect.setCoords( left, top, right , bottom  );
 
1079
        KSpreadUndoResizeColRow *undo2 = new KSpreadUndoResizeColRow( m_doc, m_table , rect );
 
1080
        //m_doc->undoBuffer()->appendUndo( undo2 );
 
1081
        macroUndo->addCommand( undo2 );
 
1082
      }
 
1083
    }
 
1084
    if ( int( positionPage->getSizeHeight() ) != int( heightSize ) )
 
1085
    {
 
1086
      for ( int x = top; x <= bottom; x++ ) // The loop seems to be doubled, already done in resizeRow: Philipp -> fixme
 
1087
        m_pView->vBorderWidget()->resizeRow( positionPage->getSizeHeight(), x, false );
 
1088
      
 
1089
    }
 
1090
    if ( int( positionPage->getSizeWidth() ) != int( widthSize ) ) 
 
1091
      // The loop seems to be doubled, already done in resizeColumn: Philipp -> fixme
 
1092
    {
 
1093
      for ( int x = left; x <= right; x++ )
 
1094
        m_pView->hBorderWidget()->resizeColumn( positionPage->getSizeWidth(), x, false );
 
1095
    }
 
1096
  }
 
1097
  else if ( isRowSelected )
 
1098
  {
 
1099
    for ( int i = top; i <= bottom; i++ )
 
1100
    {
 
1101
      RowFormat * rw = m_table->nonDefaultRowFormat( i );
 
1102
      floatPage->apply( rw );
 
1103
      fontPage->apply( rw );
 
1104
      positionPage->apply( rw );
 
1105
      patternPage->apply( rw );
 
1106
      protectPage->apply( rw );
 
1107
    }
 
1108
    //        miscPage->applyRow( );
 
1109
    if ( int( positionPage->getSizeHeight() ) != int( heightSize ) )
 
1110
    {
 
1111
      if ( !m_doc->undoBuffer()->isLocked())
 
1112
      {
 
1113
        QRect rect;
 
1114
        rect.setCoords( left, top, right, bottom  );
 
1115
        KSpreadUndoResizeColRow * undo2 = new KSpreadUndoResizeColRow( m_doc, m_table , rect );
 
1116
        //m_doc->undoBuffer()->appendUndo( undo2 );
 
1117
        macroUndo->addCommand(undo2);
 
1118
      }
 
1119
      for ( int x = top; x <= bottom; x++ ) // The loop seems to be doubled, already done in resizeRow: Philipp -> fixme
 
1120
        m_pView->vBorderWidget()->resizeRow( positionPage->getSizeHeight(), x, false );
 
1121
    }
 
1122
  }
 
1123
  else if ( isColumnSelected )
 
1124
  {
 
1125
    for ( int i = left; i <= right; ++i )
 
1126
    {
 
1127
      ColumnFormat * cl = m_table->nonDefaultColumnFormat( i );
 
1128
      floatPage->apply( cl );
 
1129
      fontPage->apply( cl );
 
1130
      positionPage->apply( cl );
 
1131
      patternPage->apply( cl );
 
1132
      protectPage->apply( cl );
 
1133
    }
 
1134
    //        miscPage->applyColumn( );
 
1135
 
 
1136
    if ( int( positionPage->getSizeWidth() ) != int( widthSize ) )
 
1137
    {
 
1138
      if ( !m_doc->undoBuffer()->isLocked())
 
1139
      {
 
1140
        QRect rect;
 
1141
        rect.setCoords( left, top, right , bottom  );
 
1142
        KSpreadUndoResizeColRow * undo2 = new KSpreadUndoResizeColRow( m_doc, m_table , rect );
 
1143
        // m_doc->undoBuffer()->appendUndo( undo2 );
 
1144
        macroUndo->addCommand(undo2);
 
1145
      }
 
1146
      for ( int x = left; x <= right; x++ ) // The loop seems to be doubled, already done in resizeColumn: Philipp -> fixme
 
1147
        m_pView->hBorderWidget()->resizeColumn(positionPage->getSizeWidth(), x, false );
 
1148
    }
 
1149
  }
 
1150
 
 
1151
  if ( !m_doc->undoBuffer()->isLocked())
 
1152
    m_doc->undoBuffer()->appendUndo( macroUndo );
 
1153
 
 
1154
  // m_pView->drawVisibleCells();
 
1155
  QRect r;
 
1156
  r.setCoords( left, top, right, bottom );
 
1157
  m_pView->doc()->setModified( true );
 
1158
  // Update the toolbar (bold/italic/font...)
 
1159
  m_pView->updateEditWidget();
 
1160
  m_pView->slotUpdateView( m_table, r );
 
1161
}
 
1162
 
 
1163
 
 
1164
CellFormatPageFloat::CellFormatPageFloat( QWidget* parent, CellFormatDlg *_dlg ) 
 
1165
  : QWidget ( parent ),
 
1166
    dlg( _dlg )
 
1167
{
951
1168
    QVBoxLayout* layout = new QVBoxLayout( this, 6,10 );
 
1169
 
 
1170
    QButtonGroup *grp = new QButtonGroup( i18n("Format"),this);
 
1171
    QGridLayout *grid = new QGridLayout(grp,10,2,KDialog::marginHint(), KDialog::spacingHint());
 
1172
 
 
1173
    int fHeight = grp->fontMetrics().height();
 
1174
    grid->addRowSpacing( 0, fHeight/2 ); // groupbox title
 
1175
 
 
1176
    grp->setRadioButtonExclusive( true );
 
1177
    number=new QRadioButton(i18n("Number"),grp);
 
1178
    grid->addWidget(number,1,0);
 
1179
 
 
1180
    percent=new QRadioButton(i18n("Percent"),grp);
 
1181
    grid->addWidget(percent,2,0);
 
1182
 
 
1183
    money=new QRadioButton(i18n("Money"),grp);
 
1184
    grid->addWidget(money,3,0);
 
1185
 
 
1186
    scientific=new QRadioButton(i18n("Scientific"),grp);
 
1187
    grid->addWidget(scientific,4,0);
 
1188
 
 
1189
    fraction=new QRadioButton(i18n("Fraction"),grp);
 
1190
    grid->addWidget(fraction,5,0);
 
1191
 
 
1192
    date=new QRadioButton(i18n("Date format"),grp);
 
1193
    grid->addWidget(date,6,0);
 
1194
 
 
1195
    time=new QRadioButton(i18n("Time format"),grp);
 
1196
    grid->addWidget(time,7,0);
 
1197
 
 
1198
    textFormat=new QRadioButton(i18n("Text"),grp);
 
1199
    grid->addWidget(textFormat,8,0);
 
1200
 
 
1201
    customFormat=new QRadioButton(i18n("Custom"),grp);
 
1202
    grid->addWidget(customFormat,9,0);
 
1203
    customFormat->setEnabled( false );
 
1204
 
 
1205
    QGroupBox *box2 = new QGroupBox( grp, "Box");
 
1206
    box2->setTitle(i18n("Preview"));
 
1207
    QGridLayout *grid3 = new QGridLayout(box2,1,3,KDialog::marginHint(), KDialog::spacingHint());
 
1208
 
 
1209
    exampleLabel=new QLabel(box2);
 
1210
    grid3->addWidget(exampleLabel,0,1);
 
1211
 
 
1212
    grid->addMultiCellWidget(box2,8,9,1,1);
 
1213
 
 
1214
    customFormatEdit = new QLineEdit( grp );
 
1215
    grid->addMultiCellWidget( customFormatEdit, 1, 1, 1, 1 );
 
1216
    customFormatEdit->setHidden( true );
 
1217
 
 
1218
    listFormat=new QListBox(grp);
 
1219
    grid->addMultiCellWidget(listFormat,2,7,1,1);
 
1220
    layout->addWidget(grp);
 
1221
 
 
1222
    /* *** */
 
1223
 
952
1224
    QGroupBox *box = new QGroupBox( this, "Box");
953
1225
 
954
 
    QGridLayout *grid = new QGridLayout(box,3,4,7,7);
955
 
 
 
1226
    grid = new QGridLayout(box,3,4,KDialog::marginHint(), KDialog::spacingHint());
956
1227
 
957
1228
    postfix = new QLineEdit( box, "LineEdit_1" );
958
1229
    grid->addWidget(postfix,2,1);
971
1242
    QLabel* tmpQLabel;
972
1243
    tmpQLabel = new QLabel( box, "Label_1" );
973
1244
    grid->addWidget(tmpQLabel,2,0);
974
 
    tmpQLabel->setText( i18n("Postfix") );
 
1245
    tmpQLabel->setText( i18n("Postfix:") );
975
1246
 
976
1247
    if ( dlg->postfix.isNull() )
977
1248
        postfix->setText( "########" );
980
1251
 
981
1252
    tmpQLabel = new QLabel( box, "Label_2" );
982
1253
    grid->addWidget(tmpQLabel,0,0);
983
 
    tmpQLabel->setText( i18n("Prefix") );
 
1254
    tmpQLabel->setText( i18n("Prefix:") );
984
1255
 
985
1256
    tmpQLabel = new QLabel( box, "Label_3" );
986
1257
    grid->addWidget(tmpQLabel,1,0);
987
 
    tmpQLabel->setText( i18n("Precision") );
 
1258
    tmpQLabel->setText( i18n("Precision:") );
988
1259
 
989
1260
    if ( dlg->prefix.isNull() )
990
1261
        prefix->setText( "########" );
997
1268
    format->insertItem( *_dlg->formatRedNeverSignedPixmap, 2 );
998
1269
    format->insertItem( *_dlg->formatAlwaysSignedPixmap, 3 );
999
1270
    format->insertItem( *_dlg->formatRedAlwaysSignedPixmap, 4 );
1000
 
    format->insertItem( *_dlg->undefinedPixmap, 5 );
1001
1271
 
1002
1272
    tmpQLabel = new QLabel( box, "Label_4" );
1003
 
    grid->addWidget(tmpQLabel,0,2);
1004
 
    tmpQLabel->setText( i18n("Format") );
1005
 
 
 
1273
    grid->addWidget(tmpQLabel, 0, 2);
 
1274
    tmpQLabel->setText( i18n("Format:") );
 
1275
 
 
1276
    currencyLabel = new QLabel( box, "LabelCurrency" );
 
1277
    grid->addWidget(currencyLabel, 1, 2);
 
1278
    currencyLabel->setText( i18n("Currency:") );
 
1279
 
 
1280
    currency = new QComboBox( box, "ComboCurrency" );
 
1281
    grid->addWidget(currency, 1, 3);
 
1282
 
 
1283
    currency->insertItem( i18n("Automatic") );
 
1284
 
 
1285
    int index = 2; //ignore first two in the list
 
1286
    bool ok = true;
 
1287
    QString text;
 
1288
 
 
1289
    while ( ok )
 
1290
    {
 
1291
      text = KSpreadCurrency::getChooseString( index, ok );
 
1292
      if ( ok )
 
1293
      {
 
1294
        currency->insertItem( text );
 
1295
      }
 
1296
      else
 
1297
      {
 
1298
        break;
 
1299
      }
 
1300
 
 
1301
      ++index;
 
1302
    }
 
1303
 
 
1304
    currency->setCurrentItem( 0 );
 
1305
    currency->hide();
 
1306
    currencyLabel->hide();
1006
1307
 
1007
1308
    if ( !dlg->bFloatFormat || !dlg->bFloatColor )
1008
1309
        format->setCurrentItem( 5 );
1018
1319
        format->setCurrentItem( 4 );
1019
1320
    layout->addWidget(box);
1020
1321
 
1021
 
 
1022
 
    QButtonGroup *grp = new QButtonGroup( i18n("Format"),this);
1023
 
    grid = new QGridLayout(grp,7,2,15,7);
1024
 
    grp->setRadioButtonExclusive( TRUE );
1025
 
    number=new QRadioButton(i18n("Number"),grp);
1026
 
    grid->addWidget(number,0,0);
1027
 
 
1028
 
    percent=new QRadioButton(i18n("Percent"),grp);
1029
 
    grid->addWidget(percent,1,0);
1030
 
 
1031
 
    money=new QRadioButton(i18n("Money"),grp);
1032
 
    grid->addWidget(money,2,0);
1033
 
 
1034
 
    scientific=new QRadioButton(i18n("Scientific"),grp);
1035
 
    grid->addWidget(scientific,3,0);
1036
 
 
1037
 
    fraction=new QRadioButton(i18n("Fraction"),grp);
1038
 
    grid->addWidget(fraction,4,0);
1039
 
 
1040
 
    date=new QRadioButton(i18n("Date Format"),grp);
1041
 
    grid->addWidget(date,5,0);
1042
 
 
1043
 
    time=new QRadioButton(i18n("Time Format"),grp);
1044
 
    grid->addWidget(time,6,0);
1045
 
 
1046
 
    QGroupBox *box2 = new QGroupBox( grp, "Box");
1047
 
    box2->setTitle(i18n("Preview"));
1048
 
    QGridLayout *grid3 = new QGridLayout(box2,1,3,14,7);
1049
 
 
1050
 
    exampleLabel=new QLabel(box2);
1051
 
    grid3->addWidget(exampleLabel,0,1);
1052
 
 
1053
 
    grid->addMultiCellWidget(box2,0,1,1,1);
1054
 
 
1055
 
    listFormat=new QListBox(grp);
1056
 
    grid->addMultiCellWidget(listFormat,2,6,1,1);
1057
 
    layout->addWidget(grp);
1058
 
 
1059
 
    cellFormatNumber=dlg->formatNumber;
1060
 
 
1061
 
    if(!cellFormatNumber)
 
1322
    cellFormatType=dlg->formatType;
 
1323
 
 
1324
    if (!cellFormatType)
1062
1325
          number->setChecked(true);
1063
1326
    else
1064
 
        {
1065
 
        if(cellFormatNumber==KSpreadCell::Number)
 
1327
    {
 
1328
        if (cellFormatType==KSpreadCell::Number)
1066
1329
                number->setChecked(true);
1067
 
        else if(cellFormatNumber==KSpreadCell::Percentage)
 
1330
        else if (cellFormatType==KSpreadCell::Percentage)
1068
1331
                percent->setChecked(true);
1069
 
        else if(cellFormatNumber==KSpreadCell::Money)
 
1332
        else if (cellFormatType==KSpreadCell::Money)
 
1333
        {
1070
1334
                money->setChecked(true);
1071
 
        else if(cellFormatNumber==KSpreadCell::Scientific)
1072
 
                scientific->setChecked(true);
1073
 
        else if(cellFormatNumber==KSpreadCell::TextDate ||
1074
 
        cellFormatNumber==KSpreadCell::ShortDate
1075
 
        ||((int)(cellFormatNumber)>=200 && (int)(cellFormatNumber)<=217))
 
1335
                currencyLabel->show();
 
1336
                currency->show();
 
1337
                if (dlg->bCurrency)
 
1338
                {
 
1339
                  QString tmp;
 
1340
                  if (dlg->cCurrency.type != 1)
 
1341
                  {
 
1342
                    KSpreadCurrency curr(dlg->cCurrency.type);
 
1343
                    bool ok = true;
 
1344
                    tmp = KSpreadCurrency::getChooseString(dlg->cCurrency.type, ok);
 
1345
                    if ( !ok )
 
1346
                      tmp = dlg->cCurrency.symbol;
 
1347
                  }
 
1348
                  else
 
1349
                    tmp = dlg->cCurrency.symbol;
 
1350
                  currency->setCurrentText( tmp );
 
1351
                }
 
1352
        }
 
1353
        else if ( cellFormatType == KSpreadCell::Scientific )
 
1354
          scientific->setChecked(true);
 
1355
        else if ( cellFormatType == KSpreadCell::TextDate 
 
1356
                  || cellFormatType == KSpreadCell::ShortDate
 
1357
                  || ( ( (int)( cellFormatType ) >= 200 ) && ( (int)(cellFormatType) <= 217 ) ) )
1076
1358
                date->setChecked(true);
1077
 
        else if(cellFormatNumber==KSpreadCell::Time ||
1078
 
        cellFormatNumber==KSpreadCell::SecondeTime
1079
 
        ||cellFormatNumber==KSpreadCell::Time_format1
1080
 
        ||cellFormatNumber==KSpreadCell::Time_format2
1081
 
        ||cellFormatNumber==KSpreadCell::Time_format3)
1082
 
                time->setChecked(true);
1083
 
        else if(cellFormatNumber==KSpreadCell::fraction_half ||
1084
 
        cellFormatNumber==KSpreadCell::fraction_quarter ||
1085
 
        cellFormatNumber==KSpreadCell::fraction_eighth ||
1086
 
        cellFormatNumber==KSpreadCell::fraction_sixteenth ||
1087
 
        cellFormatNumber==KSpreadCell::fraction_tenth ||
1088
 
        cellFormatNumber==KSpreadCell::fraction_hundredth ||
1089
 
        cellFormatNumber==KSpreadCell::fraction_one_digit ||
1090
 
        cellFormatNumber==KSpreadCell::fraction_two_digits ||
1091
 
        cellFormatNumber==KSpreadCell::fraction_three_digits)
1092
 
                fraction->setChecked(true);
 
1359
        else if ( cellFormatType == KSpreadCell::Time 
 
1360
                  || cellFormatType == KSpreadCell::SecondeTime
 
1361
                  || cellFormatType == KSpreadCell::Time_format1
 
1362
                  || cellFormatType == KSpreadCell::Time_format2
 
1363
                  || cellFormatType == KSpreadCell::Time_format3
 
1364
                  || cellFormatType == KSpreadCell::Time_format4
 
1365
                  || cellFormatType == KSpreadCell::Time_format5
 
1366
                  || cellFormatType == KSpreadCell::Time_format6
 
1367
                  || cellFormatType == KSpreadCell::Time_format7
 
1368
                  || cellFormatType == KSpreadCell::Time_format8)
 
1369
          time->setChecked(true);
 
1370
        else if ( cellFormatType == KSpreadCell::fraction_half 
 
1371
                  || cellFormatType == KSpreadCell::fraction_quarter ||
 
1372
                  cellFormatType == KSpreadCell::fraction_eighth ||
 
1373
                  cellFormatType == KSpreadCell::fraction_sixteenth ||
 
1374
                  cellFormatType == KSpreadCell::fraction_tenth ||
 
1375
                  cellFormatType == KSpreadCell::fraction_hundredth ||
 
1376
                  cellFormatType == KSpreadCell::fraction_one_digit ||
 
1377
                  cellFormatType == KSpreadCell::fraction_two_digits ||
 
1378
                  cellFormatType == KSpreadCell::fraction_three_digits)
 
1379
          fraction->setChecked(true);
 
1380
        else if (cellFormatType == KSpreadCell::Text_format)
 
1381
          textFormat->setChecked(true);
 
1382
        else if (cellFormatType == KSpreadCell::Custom)
 
1383
          customFormat->setChecked(true);
1093
1384
        }
 
1385
 
1094
1386
    connect(fraction,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
1095
1387
    connect(money,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
1096
1388
    connect(date,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
1098
1390
    connect(number,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
1099
1391
    connect(percent,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
1100
1392
    connect(time,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
 
1393
    connect(textFormat,SIGNAL(clicked()),this,SLOT(slotChangeState()));
 
1394
    connect(customFormat,SIGNAL(clicked()),this,SLOT(slotChangeState()));
 
1395
 
1101
1396
    connect(listFormat,SIGNAL(selectionChanged ()),this,SLOT(makeformat()));
1102
1397
    connect(precision,SIGNAL(valueChanged(int)),this,SLOT(slotChangeValue(int)));
1103
1398
    connect(prefix,SIGNAL(textChanged ( const QString & ) ),this,SLOT(makeformat()));
1104
1399
    connect(postfix,SIGNAL(textChanged ( const QString & ) ),this,SLOT(makeformat()));
 
1400
    connect(currency,SIGNAL(activated ( const QString & ) ),this, SLOT(currencyChanged(const QString &)));
1105
1401
    connect(format,SIGNAL(activated ( int ) ),this,SLOT(formatChanged(int)));
1106
1402
    slotChangeState();
1107
1403
    m_bFormatColorChanged=false;
1108
 
    m_bFormatNumberChanged=false;
 
1404
    m_bFormatTypeChanged=false;
1109
1405
    this->resize( 400, 400 );
1110
1406
}
1111
1407
 
1112
 
void CellLayoutPageFloat::formatChanged(int)
 
1408
void CellFormatPageFloat::formatChanged(int)
1113
1409
{
1114
1410
    m_bFormatColorChanged=true;
1115
1411
}
1116
1412
 
1117
 
void CellLayoutPageFloat::slotChangeValue(int)
 
1413
void CellFormatPageFloat::slotChangeValue(int)
1118
1414
{
1119
1415
    makeformat();
1120
1416
}
1121
 
void CellLayoutPageFloat::slotChangeState()
 
1417
void CellFormatPageFloat::slotChangeState()
1122
1418
{
1123
1419
    QStringList list;
1124
1420
    listFormat->clear();
1125
 
    if(dlg->cellText.isEmpty() || dlg->m_bValue)
 
1421
    currency->hide();
 
1422
    currencyLabel->hide();
 
1423
    if (dlg->cellText.isEmpty() || dlg->m_bValue || !dlg->isSingleCell())
1126
1424
        {
1127
1425
            precision->setEnabled(true);
1128
1426
            prefix->setEnabled(true);
1136
1434
            postfix->setEnabled(false);
1137
1435
            format->setEnabled(false);
1138
1436
        }
1139
 
    if(number->isChecked())
1140
 
        listFormat->setEnabled(false);
1141
 
    else if(percent->isChecked())
1142
 
        listFormat->setEnabled(false);
1143
 
    else if(money->isChecked())
1144
 
        listFormat->setEnabled(false);
1145
 
    else if(scientific->isChecked())
1146
 
        listFormat->setEnabled(false);
1147
 
    else if(date->isChecked())
 
1437
    if (number->isChecked())
 
1438
        listFormat->setEnabled(false);
 
1439
    else if (percent->isChecked())
 
1440
        listFormat->setEnabled(false);
 
1441
    else if (money->isChecked())
 
1442
    {
 
1443
        listFormat->setEnabled(false);
 
1444
        precision->setValue(2);
 
1445
        currency->show();
 
1446
        currencyLabel->show();
 
1447
    }
 
1448
    else if (scientific->isChecked())
 
1449
        listFormat->setEnabled(false);
 
1450
    else if (date->isChecked())
1148
1451
        {
1149
1452
            format->setEnabled(false);
1150
1453
            precision->setEnabled(false);
1153
1456
            listFormat->setEnabled(true);
1154
1457
            init();
1155
1458
        }
1156
 
    else if(fraction->isChecked())
 
1459
    else if (fraction->isChecked())
1157
1460
        {
1158
1461
            precision->setEnabled(false);
1159
1462
            listFormat->setEnabled(true);
1160
1463
            list+=i18n("Halves 1/2");
1161
1464
            list+=i18n("Quarters 1/4");
1162
 
            list+=i18n("Eighth's 1/8");
1163
 
            list+=i18n("Sixteenth's 1/16");
1164
 
            list+=i18n("Tenth's 1/10");
1165
 
            list+=i18n("Hundredth's 1/100");
 
1465
            list+=i18n("Eighths 1/8");
 
1466
            list+=i18n("Sixteenths 1/16");
 
1467
            list+=i18n("Tenths 1/10");
 
1468
            list+=i18n("Hundredths 1/100");
1166
1469
            list+=i18n("One digit 5/9");
1167
1470
            list+=i18n("Two digits 15/22");
1168
1471
            list+=i18n("Three digits 153/652");
1169
1472
            listFormat->insertStringList(list);
1170
 
            if(cellFormatNumber==KSpreadCell::fraction_half)
 
1473
            if (cellFormatType == KSpreadCell::fraction_half)
1171
1474
                listFormat->setCurrentItem(0);
1172
 
            else if(cellFormatNumber==KSpreadCell::fraction_quarter)
 
1475
            else if (cellFormatType == KSpreadCell::fraction_quarter)
1173
1476
                listFormat->setCurrentItem(1);
1174
 
            else if(cellFormatNumber==KSpreadCell::fraction_eighth )
 
1477
            else if (cellFormatType == KSpreadCell::fraction_eighth )
1175
1478
                listFormat->setCurrentItem(2);
1176
 
            else if(cellFormatNumber==KSpreadCell::fraction_sixteenth )
 
1479
            else if (cellFormatType == KSpreadCell::fraction_sixteenth )
1177
1480
                listFormat->setCurrentItem(3);
1178
 
            else if(cellFormatNumber==KSpreadCell::fraction_tenth )
 
1481
            else if (cellFormatType == KSpreadCell::fraction_tenth )
1179
1482
                listFormat->setCurrentItem(4);
1180
 
            else if(cellFormatNumber==KSpreadCell::fraction_hundredth )
 
1483
            else if (cellFormatType == KSpreadCell::fraction_hundredth )
1181
1484
                listFormat->setCurrentItem(5);
1182
 
            else if(cellFormatNumber==KSpreadCell::fraction_one_digit )
 
1485
            else if (cellFormatType == KSpreadCell::fraction_one_digit )
1183
1486
                listFormat->setCurrentItem(6);
1184
 
            else if(cellFormatNumber==KSpreadCell::fraction_two_digits )
 
1487
            else if (cellFormatType == KSpreadCell::fraction_two_digits )
1185
1488
                listFormat->setCurrentItem(7);
1186
 
            else if(cellFormatNumber==KSpreadCell::fraction_three_digits )
 
1489
            else if (cellFormatType == KSpreadCell::fraction_three_digits )
1187
1490
                listFormat->setCurrentItem(8);
1188
1491
            else
1189
1492
                listFormat->setCurrentItem(0);
1190
1493
        }
1191
 
    else if(time->isChecked())
 
1494
    else if (time->isChecked())
1192
1495
        {
1193
1496
            precision->setEnabled(false);
1194
1497
            prefix->setEnabled(false);
1199
1502
 
1200
1503
            list+=i18n("System: ")+dlg->locale()->formatTime(QTime::currentTime(),false);
1201
1504
            list+=i18n("System: ")+dlg->locale()->formatTime(QTime::currentTime(),true);
1202
 
            QTime tmpTime(10,35,25);
 
1505
            QDateTime tmpTime(QDate(1900, 1, 2), QTime(10, 35, 25));
1203
1506
            list+= util_timeFormat(dlg->locale(), tmpTime, KSpreadCell::Time_format1);
1204
1507
            list+= util_timeFormat(dlg->locale(), tmpTime, KSpreadCell::Time_format2);
1205
1508
            list+= util_timeFormat(dlg->locale(), tmpTime, KSpreadCell::Time_format3);
 
1509
            list+= util_timeFormat(dlg->locale(), tmpTime, KSpreadCell::Time_format4);
 
1510
            list+= util_timeFormat(dlg->locale(), tmpTime, KSpreadCell::Time_format5);
 
1511
            list+= ( util_timeFormat(dlg->locale(), tmpTime, KSpreadCell::Time_format6) + i18n(" (=[mm]::ss)") );
 
1512
            list+= ( util_timeFormat(dlg->locale(), tmpTime, KSpreadCell::Time_format7) + i18n(" (=[hh]::mm::ss)") );
 
1513
            list+= ( util_timeFormat(dlg->locale(), tmpTime, KSpreadCell::Time_format8) + i18n(" (=[hh]::mm)") );
1206
1514
            listFormat->insertStringList(list);
1207
1515
 
1208
 
            if( cellFormatNumber==KSpreadCell::Time )
 
1516
            if ( cellFormatType == KSpreadCell::Time )
1209
1517
                listFormat->setCurrentItem(0);
1210
 
            else if(cellFormatNumber==KSpreadCell::SecondeTime)
 
1518
            else if (cellFormatType == KSpreadCell::SecondeTime)
1211
1519
                listFormat->setCurrentItem(1);
1212
 
            else if(cellFormatNumber==KSpreadCell::Time_format1)
 
1520
            else if (cellFormatType == KSpreadCell::Time_format1)
1213
1521
                listFormat->setCurrentItem(2);
1214
 
            else if(cellFormatNumber==KSpreadCell::Time_format2)
 
1522
            else if (cellFormatType == KSpreadCell::Time_format2)
1215
1523
                listFormat->setCurrentItem(3);
1216
 
            else if(cellFormatNumber==KSpreadCell::Time_format3)
 
1524
            else if (cellFormatType == KSpreadCell::Time_format3)
1217
1525
                listFormat->setCurrentItem(4);
 
1526
            else if (cellFormatType == KSpreadCell::Time_format4)
 
1527
                listFormat->setCurrentItem(5);
 
1528
            else if (cellFormatType == KSpreadCell::Time_format5)
 
1529
                listFormat->setCurrentItem(6);
 
1530
            else if (cellFormatType == KSpreadCell::Time_format6)
 
1531
                listFormat->setCurrentItem(7);
 
1532
            else if (cellFormatType == KSpreadCell::Time_format7)
 
1533
                listFormat->setCurrentItem(8);
 
1534
            else if (cellFormatType == KSpreadCell::Time_format8)
 
1535
                listFormat->setCurrentItem(9);
1218
1536
            else
1219
1537
                listFormat->setCurrentItem(0);
1220
1538
        }
1221
 
    m_bFormatNumberChanged=true;
1222
 
    if( date->isChecked() && dlg->m_bDate)
 
1539
    else if (textFormat->isChecked())
 
1540
      {
 
1541
        listFormat->setEnabled(false);
 
1542
      }
 
1543
 
 
1544
    if (customFormat->isChecked())
 
1545
    {
 
1546
      customFormatEdit->setHidden( false );
 
1547
      precision->setEnabled(false);
 
1548
      prefix->setEnabled(false);
 
1549
      postfix->setEnabled(false);
 
1550
      format->setEnabled(false);
 
1551
      listFormat->setEnabled(true);
 
1552
    }
 
1553
    else
 
1554
      customFormatEdit->setHidden( true );
 
1555
 
 
1556
    m_bFormatTypeChanged=true;
 
1557
    if ( date->isChecked() && dlg->m_bDate)
1223
1558
        makeDateFormat();
1224
1559
    else
1225
1560
        makeformat();
1226
1561
}
1227
1562
 
1228
 
void CellLayoutPageFloat::makeDateFormat()
 
1563
void CellFormatPageFloat::makeDateFormat()
1229
1564
{
1230
 
    KSpreadCell::formatNumber tmpFormat=KSpreadCell::ShortDate;
 
1565
    KSpreadCell::FormatType tmpFormat=KSpreadCell::ShortDate;
1231
1566
    QString tmp;
1232
 
    if( listFormat->currentItem()==0)
 
1567
    if ( listFormat->currentItem() == 0)
1233
1568
        tmpFormat=KSpreadCell::ShortDate;
1234
 
    else if(listFormat->currentItem()==1)
 
1569
    else if (listFormat->currentItem() == 1)
1235
1570
        tmpFormat=KSpreadCell::TextDate;
1236
 
    else if(listFormat->currentItem()==2)/*18-Feb-99*/
 
1571
    else if (listFormat->currentItem() == 2)/*18-Feb-99*/
1237
1572
        tmpFormat=KSpreadCell::date_format1;
1238
 
    else if(listFormat->currentItem()==3) /*18-Feb-1999*/
 
1573
    else if (listFormat->currentItem() == 3) /*18-Feb-1999*/
1239
1574
        tmpFormat=KSpreadCell::date_format2;
1240
 
    else if(listFormat->currentItem()==4) /*18-Feb*/
 
1575
    else if (listFormat->currentItem() == 4) /*18-Feb*/
1241
1576
        tmpFormat=KSpreadCell::date_format3;
1242
 
    else if(listFormat->currentItem()==5) /*18-05*/
 
1577
    else if (listFormat->currentItem() == 5) /*18-05*/
1243
1578
        tmpFormat=KSpreadCell::date_format4;
1244
 
    else if(listFormat->currentItem()==6) /*18/05/00*/
 
1579
    else if (listFormat->currentItem() == 6) /*18/05/00*/
1245
1580
        tmpFormat=KSpreadCell::date_format5;
1246
 
    else if(listFormat->currentItem()==7) /*18/05/1999*/
 
1581
    else if (listFormat->currentItem() == 7) /*18/05/1999*/
1247
1582
        tmpFormat=KSpreadCell::date_format6;
1248
 
    else if(listFormat->currentItem()==8) /*Feb-99*/
 
1583
    else if (listFormat->currentItem() == 8) /*Feb-99*/
1249
1584
        tmpFormat=KSpreadCell::date_format7;
1250
 
    else if(listFormat->currentItem()==9) /*February-99*/
 
1585
    else if (listFormat->currentItem() == 9) /*February-99*/
1251
1586
        tmpFormat=KSpreadCell::date_format8;
1252
 
    else if(listFormat->currentItem()==10) /*February-1999*/
 
1587
    else if (listFormat->currentItem() == 10) /*February-1999*/
1253
1588
        tmpFormat=KSpreadCell::date_format9;
1254
 
    else if(listFormat->currentItem()==11) /*F-99*/
 
1589
    else if (listFormat->currentItem() == 11) /*F-99*/
1255
1590
        tmpFormat=KSpreadCell::date_format10;
1256
 
    else if(listFormat->currentItem()==12) /*18/Feb*/
 
1591
    else if (listFormat->currentItem() == 12) /*18/Feb*/
1257
1592
        tmpFormat=KSpreadCell::date_format11;
1258
 
    else if(listFormat->currentItem()==13) /*18/02*/
 
1593
    else if (listFormat->currentItem() == 13) /*18/02*/
1259
1594
        tmpFormat=KSpreadCell::date_format12;
1260
 
    else if(listFormat->currentItem()==14) /*18/Feb/1999*/
 
1595
    else if (listFormat->currentItem() == 14) /*18/Feb/1999*/
1261
1596
        tmpFormat=KSpreadCell::date_format13;
1262
 
    else if(listFormat->currentItem()==15) /*2000/Feb/18*/
 
1597
    else if (listFormat->currentItem() == 15) /*2000/Feb/18*/
1263
1598
        tmpFormat=KSpreadCell::date_format14;
1264
 
    else if(listFormat->currentItem()==16) /*2000-Feb-18*/
 
1599
    else if (listFormat->currentItem() == 16) /*2000-Feb-18*/
1265
1600
        tmpFormat=KSpreadCell::date_format15;
1266
 
    else if(listFormat->currentItem()==17) /*2000-02-18*/
 
1601
    else if (listFormat->currentItem() == 17) /*2000-02-18*/
1267
1602
        tmpFormat=KSpreadCell::date_format16;
1268
 
    else if( listFormat->currentItem()==18) /*2000-02-18*/
 
1603
    else if ( listFormat->currentItem() == 18) /*2000-02-18*/
1269
1604
        tmpFormat=KSpreadCell::date_format17;
1270
 
    tmp= util_dateFormat( dlg->locale(), dlg->m_date, tmpFormat);
 
1605
    else if ( listFormat->currentItem() == 19)
 
1606
        tmpFormat=KSpreadCell::date_format18;
 
1607
    else if ( listFormat->currentItem() == 20)
 
1608
        tmpFormat=KSpreadCell::date_format19;
 
1609
    else if ( listFormat->currentItem() == 21)
 
1610
        tmpFormat=KSpreadCell::date_format20;
 
1611
    else if ( listFormat->currentItem() == 22)
 
1612
        tmpFormat=KSpreadCell::date_format21;
 
1613
    else if ( listFormat->currentItem() == 23)
 
1614
        tmpFormat=KSpreadCell::date_format22;
 
1615
    else if ( listFormat->currentItem() == 24)
 
1616
        tmpFormat=KSpreadCell::date_format23;
 
1617
    else if ( listFormat->currentItem() == 25)
 
1618
        tmpFormat=KSpreadCell::date_format24;
 
1619
    else if ( listFormat->currentItem() == 26)
 
1620
        tmpFormat=KSpreadCell::date_format25;
 
1621
    else if ( listFormat->currentItem() == 27)
 
1622
        tmpFormat=KSpreadCell::date_format26;
 
1623
    tmp= util_dateFormat( dlg->locale(), dlg->m_time.date(), tmpFormat);
1271
1624
    exampleLabel->setText(tmp);
1272
1625
}
1273
1626
 
1274
1627
 
1275
 
void CellLayoutPageFloat::init()
 
1628
void CellFormatPageFloat::init()
1276
1629
{
1277
1630
    QStringList list;
1278
1631
    QString tmp;
1314
1667
    list+=util_dateFormat( dlg->locale(), tmpDate, KSpreadCell::date_format16);
1315
1668
    /*2 february 2000*/
1316
1669
    list+=util_dateFormat( dlg->locale(), tmpDate, KSpreadCell::date_format17);
 
1670
    list+=util_dateFormat( dlg->locale(), tmpDate, KSpreadCell::date_format18);
 
1671
    list+=util_dateFormat( dlg->locale(), tmpDate, KSpreadCell::date_format19);
 
1672
    list+=util_dateFormat( dlg->locale(), tmpDate, KSpreadCell::date_format20);
 
1673
    list+=util_dateFormat( dlg->locale(), tmpDate, KSpreadCell::date_format21);
 
1674
    list+=util_dateFormat( dlg->locale(), tmpDate, KSpreadCell::date_format22);
 
1675
    list+=util_dateFormat( dlg->locale(), tmpDate, KSpreadCell::date_format23);
 
1676
    list+=util_dateFormat( dlg->locale(), tmpDate, KSpreadCell::date_format24);
 
1677
    list+=util_dateFormat( dlg->locale(), tmpDate, KSpreadCell::date_format25);
 
1678
    list+=util_dateFormat( dlg->locale(), tmpDate, KSpreadCell::date_format26);
1317
1679
 
1318
1680
    listFormat->insertStringList(list);
1319
 
    if( cellFormatNumber==KSpreadCell::ShortDate )
 
1681
    if ( cellFormatType == KSpreadCell::ShortDate )
1320
1682
        listFormat->setCurrentItem(0);
1321
 
    else if(cellFormatNumber==KSpreadCell::TextDate)
 
1683
    else if (cellFormatType == KSpreadCell::TextDate)
1322
1684
        listFormat->setCurrentItem(1);
1323
 
    else if(cellFormatNumber==KSpreadCell::date_format1)
 
1685
    else if (cellFormatType == KSpreadCell::date_format1)
1324
1686
        listFormat->setCurrentItem(2);
1325
 
    else if(cellFormatNumber==KSpreadCell::date_format2)
 
1687
    else if (cellFormatType == KSpreadCell::date_format2)
1326
1688
        listFormat->setCurrentItem(3);
1327
 
    else if(cellFormatNumber==KSpreadCell::date_format3)
 
1689
    else if (cellFormatType == KSpreadCell::date_format3)
1328
1690
        listFormat->setCurrentItem(4);
1329
 
    else if(cellFormatNumber==KSpreadCell::date_format4)
 
1691
    else if (cellFormatType == KSpreadCell::date_format4)
1330
1692
        listFormat->setCurrentItem(5);
1331
 
    else if(cellFormatNumber==KSpreadCell::date_format5)
 
1693
    else if (cellFormatType == KSpreadCell::date_format5)
1332
1694
        listFormat->setCurrentItem(6);
1333
 
    else if(cellFormatNumber==KSpreadCell::date_format6)
 
1695
    else if (cellFormatType == KSpreadCell::date_format6)
1334
1696
        listFormat->setCurrentItem(7);
1335
 
    else if(cellFormatNumber==KSpreadCell::date_format7)
 
1697
    else if (cellFormatType == KSpreadCell::date_format7)
1336
1698
        listFormat->setCurrentItem(8);
1337
 
    else if(cellFormatNumber==KSpreadCell::date_format8)
 
1699
    else if (cellFormatType == KSpreadCell::date_format8)
1338
1700
        listFormat->setCurrentItem(9);
1339
 
    else if(cellFormatNumber==KSpreadCell::date_format9)
 
1701
    else if (cellFormatType == KSpreadCell::date_format9)
1340
1702
        listFormat->setCurrentItem(10);
1341
 
    else if(cellFormatNumber==KSpreadCell::date_format10)
 
1703
    else if (cellFormatType == KSpreadCell::date_format10)
1342
1704
        listFormat->setCurrentItem(11);
1343
 
    else if(cellFormatNumber==KSpreadCell::date_format11)
 
1705
    else if (cellFormatType == KSpreadCell::date_format11)
1344
1706
        listFormat->setCurrentItem(12);
1345
 
    else if(cellFormatNumber==KSpreadCell::date_format12)
 
1707
    else if (cellFormatType == KSpreadCell::date_format12)
1346
1708
        listFormat->setCurrentItem(13);
1347
 
    else if(cellFormatNumber==KSpreadCell::date_format13)
 
1709
    else if (cellFormatType == KSpreadCell::date_format13)
1348
1710
        listFormat->setCurrentItem(14);
1349
 
    else if(cellFormatNumber==KSpreadCell::date_format14)
 
1711
    else if (cellFormatType == KSpreadCell::date_format14)
1350
1712
        listFormat->setCurrentItem(15);
1351
 
    else if(cellFormatNumber==KSpreadCell::date_format15)
 
1713
    else if (cellFormatType == KSpreadCell::date_format15)
1352
1714
        listFormat->setCurrentItem(16);
1353
 
    else if(cellFormatNumber==KSpreadCell::date_format16)
 
1715
    else if (cellFormatType == KSpreadCell::date_format16)
1354
1716
        listFormat->setCurrentItem(17);
1355
 
    else if(cellFormatNumber==KSpreadCell::date_format17)
 
1717
    else if (cellFormatType == KSpreadCell::date_format17)
1356
1718
        listFormat->setCurrentItem(18);
 
1719
    else if (cellFormatType == KSpreadCell::date_format18)
 
1720
        listFormat->setCurrentItem(19);
 
1721
    else if (cellFormatType == KSpreadCell::date_format19)
 
1722
        listFormat->setCurrentItem(20);
 
1723
    else if (cellFormatType == KSpreadCell::date_format20)
 
1724
        listFormat->setCurrentItem(21);
 
1725
    else if (cellFormatType == KSpreadCell::date_format21)
 
1726
        listFormat->setCurrentItem(22);
 
1727
    else if (cellFormatType == KSpreadCell::date_format22)
 
1728
        listFormat->setCurrentItem(23);
 
1729
    else if (cellFormatType == KSpreadCell::date_format23)
 
1730
        listFormat->setCurrentItem(24);
 
1731
    else if (cellFormatType == KSpreadCell::date_format24)
 
1732
        listFormat->setCurrentItem(25);
 
1733
    else if (cellFormatType == KSpreadCell::date_format25)
 
1734
        listFormat->setCurrentItem(26);
 
1735
    else if (cellFormatType == KSpreadCell::date_format26)
 
1736
        listFormat->setCurrentItem(27);
1357
1737
    else
1358
1738
        listFormat->setCurrentItem(0);
1359
1739
 
1360
1740
}
1361
1741
 
1362
 
void CellLayoutPageFloat::makeTimeFormat()
 
1742
void CellFormatPageFloat::makeTimeFormat()
1363
1743
{
1364
1744
    QString tmp;
1365
 
    QString tmpTime;
1366
 
    KSpreadCell::formatNumber tmpFormat=KSpreadCell::Time;
1367
 
    if( listFormat->currentItem()==0)
 
1745
    int current = listFormat->currentItem();
 
1746
    KSpreadCell::FormatType tmpFormat=KSpreadCell::Time;
 
1747
    if ( current == 0)
1368
1748
        tmpFormat=KSpreadCell::Time;
1369
 
    else if(listFormat->currentItem()==1)
 
1749
    else if (current == 1)
1370
1750
        tmpFormat=KSpreadCell::SecondeTime;
1371
 
    else if(listFormat->currentItem()==2)
 
1751
    else if (current == 2)
1372
1752
        tmpFormat=KSpreadCell::Time_format1;
1373
 
    else if(listFormat->currentItem()==3)
 
1753
    else if (current == 3)
1374
1754
        tmpFormat=KSpreadCell::Time_format2;
1375
 
    else if(listFormat->currentItem()==4)
 
1755
    else if (current == 4)
1376
1756
        tmpFormat=KSpreadCell::Time_format3;
1377
 
    tmp= util_timeFormat( dlg->locale(), dlg->m_time, tmpFormat);
 
1757
    else if (current == 5)
 
1758
        tmpFormat=KSpreadCell::Time_format4;
 
1759
    else if (current == 6)
 
1760
        tmpFormat=KSpreadCell::Time_format5;
 
1761
    else if (current == 7)
 
1762
        tmpFormat=KSpreadCell::Time_format6;
 
1763
    else if (current == 8)
 
1764
        tmpFormat=KSpreadCell::Time_format7;
 
1765
    else if (current == 9)
 
1766
        tmpFormat=KSpreadCell::Time_format8;
 
1767
 
 
1768
    tmp = util_timeFormat( dlg->locale(), dlg->m_time, tmpFormat);
1378
1769
    exampleLabel->setText(tmp);
1379
1770
}
1380
1771
 
1381
 
QString CellLayoutPageFloat::makeFractionFormat()
 
1772
QString CellFormatPageFloat::makeFractionFormat()
1382
1773
{
1383
1774
    double result = (dlg->m_value)-floor(dlg->m_value);
1384
1775
    QString tmp;
1385
 
    if(result == 0 )
 
1776
    if (result  ==  0 )
1386
1777
    {
1387
1778
        return tmp.setNum( dlg->m_value );
1388
1779
    }
1389
1780
    else
1390
1781
    {
1391
 
        KSpreadCell::formatNumber tmpFormat=KSpreadCell::fraction_half;
 
1782
        KSpreadCell::FormatType tmpFormat=KSpreadCell::fraction_half;
1392
1783
        switch( listFormat->currentItem())
1393
1784
        {
1394
1785
            case 0:
1423
1814
    }
1424
1815
}
1425
1816
 
1426
 
void CellLayoutPageFloat::makeformat()
1427
 
{
1428
 
    m_bFormatNumberChanged=true;
 
1817
void CellFormatPageFloat::currencyChanged(const QString &)
 
1818
{
 
1819
  int index = currency->currentItem();
 
1820
  if (index > 0)
 
1821
    ++index;
 
1822
  dlg->cCurrency.symbol = KSpreadCurrency::getDisplaySymbol(index);
 
1823
  dlg->cCurrency.type   = index;
 
1824
 
 
1825
  makeformat();
 
1826
}
 
1827
 
 
1828
void CellFormatPageFloat::makeformat()
 
1829
{
 
1830
    m_bFormatTypeChanged=true;
1429
1831
    QString tmp;
1430
1832
    int p;
1431
1833
    p = (precision->value() == -1) ? 8 : precision->value();
1432
1834
    QChar decimal_point= dlg->locale()->decimalSymbol()[0];
1433
 
    if(!dlg->m_bValue&&!dlg->m_bDate&&!dlg->m_bTime)
 
1835
    if ( !dlg->m_bValue && !dlg->m_bDate && !dlg->m_bTime )
1434
1836
        {
1435
1837
            QString tmpText;
1436
 
            if( dlg->cellText.length()>50)
 
1838
            if ( dlg->cellText.length()>50)
1437
1839
                tmpText=dlg->cellText.left(50);
1438
1840
            exampleLabel->setText(tmpText);
1439
1841
        }
1440
 
    else if(dlg->m_bDate)
 
1842
    else if (dlg->m_bDate)
1441
1843
        {
1442
 
            if(date->isChecked())
 
1844
            if (date->isChecked())
1443
1845
                {
1444
1846
                    makeDateFormat();
1445
1847
                }
1446
1848
            else
1447
1849
                exampleLabel->setText(dlg->cellText);
1448
1850
        }
1449
 
    else if(dlg->m_bTime)
 
1851
    else if (dlg->m_bTime)
1450
1852
        {
1451
 
            if(time->isChecked())
 
1853
            if (time->isChecked())
1452
1854
                {
1453
1855
                    makeTimeFormat();
1454
1856
                }
1455
1857
            else
1456
1858
                exampleLabel->setText(dlg->cellText);
1457
1859
        }
1458
 
    else if(dlg->m_bValue)
 
1860
    else if (dlg->m_bValue)
1459
1861
        {
1460
 
            if(number->isChecked())
 
1862
            if (number->isChecked())
1461
1863
                tmp=dlg->locale()->formatNumber(dlg->m_value,p );
1462
 
            else if(money->isChecked())
1463
 
                tmp=dlg->locale()->formatMoney(dlg->m_value,dlg->locale()->currencySymbol(),p );
1464
 
            else if(percent->isChecked())
 
1864
            else if (money->isChecked())
 
1865
                tmp=dlg->locale()->formatMoney(dlg->m_value, dlg->cCurrency.symbol, p );
 
1866
            else if (percent->isChecked())
1465
1867
                tmp=dlg->locale()->formatNumber(dlg->m_value*100.0, p)+ " %";
1466
 
            else if(scientific->isChecked())
 
1868
            else if (scientific->isChecked())
1467
1869
                {
1468
1870
                    tmp=QString::number(dlg->m_value, 'E', p);
1469
1871
                    int pos;
1470
 
                    if((pos=tmp.find('.'))!=-1)
 
1872
                    if ((pos=tmp.find('.'))!=-1)
1471
1873
                        tmp=tmp.replace(pos,1,decimal_point);
1472
1874
                }
1473
 
            else if(fraction->isChecked())
 
1875
            else if (fraction->isChecked())
1474
1876
                {
1475
1877
                    tmp=makeFractionFormat();
1476
1878
                }
1477
 
            if ( precision->value() == -1 && tmp.find(decimal_point) >= 0 )
 
1879
            else if (textFormat->isChecked())
 
1880
              {
 
1881
                tmp=QString::number(dlg->m_value);
 
1882
              }
 
1883
            else if (customFormat->isChecked())
 
1884
              {
 
1885
                // TODO!
 
1886
              }
 
1887
            if ( precision->value() == -1 && tmp.find(decimal_point) >= 0 && !textFormat->isChecked())
1478
1888
                {
1479
1889
                    int start=0;
1480
 
                    if(tmp.find('%')!=-1)
 
1890
                    if (tmp.find('%')!=-1)
1481
1891
                        start=2;
1482
 
                    else if(tmp.find(dlg->locale()->currencySymbol())==((int)(tmp.length()-dlg->locale()->currencySymbol().length())))
1483
 
                        start=dlg->locale()->currencySymbol().length()+1;
1484
 
                    else if((start=tmp.find('E'))!=-1)
 
1892
                    else if (tmp.find(dlg->cCurrency.symbol) == ((int)(tmp.length() - dlg->cCurrency.symbol.length())))
 
1893
                        start=dlg->cCurrency.symbol.length()+1;
 
1894
                    else if ((start=tmp.find('E'))!=-1)
1485
1895
                        start=tmp.length()-start;
1486
1896
                    else
1487
1897
                        start=0;
1488
1898
                    int i = tmp.length()-start;
1489
 
                    bool bFinished = FALSE;
 
1899
                    bool bFinished = false;
1490
1900
 
1491
1901
 
1492
1902
                    while ( !bFinished && i > 0 )
1496
1906
                                tmp.remove(--i,1);
1497
1907
                            else
1498
1908
                                {
1499
 
                                    bFinished = TRUE;
 
1909
                                    bFinished = true;
1500
1910
                                    if ( ch == decimal_point )
1501
1911
                                        tmp.remove(--i,1);
1502
1912
                                }
1503
1913
                        }
1504
1914
 
1505
1915
                }
1506
 
            if(dlg->m_bValue && !time->isChecked() && !date->isChecked())
 
1916
            if (dlg->m_bValue && !time->isChecked() && !date->isChecked())
1507
1917
                {
1508
1918
                    if ( prefix->text() != "########" )
1509
1919
                        tmp=prefix->text()+" "+tmp;
1516
1926
        exampleLabel->setText(i18n("Error"));
1517
1927
}
1518
1928
 
1519
 
 
1520
 
void CellLayoutPageFloat::applyLayout( KSpreadLayout *_obj )
 
1929
void CellFormatPageFloat::apply( KSpreadCustomStyle * style )
 
1930
{
 
1931
  if ( postfix->text() != dlg->postfix )
 
1932
  {
 
1933
    if ( postfix->text() != "########" )
 
1934
    {
 
1935
      if ( postfix->isEnabled())
 
1936
        style->changePostfix( postfix->text() );
 
1937
      else
 
1938
        style->changePostfix( "" );
 
1939
    }
 
1940
  }
 
1941
  if ( prefix->text() != dlg->prefix )
 
1942
  {
 
1943
    if ( prefix->text() != "########" )
 
1944
    {
 
1945
      if (prefix->isEnabled())
 
1946
        style->changePrefix( prefix->text() );
 
1947
      else
 
1948
        style->changePrefix( "" );
 
1949
    }
 
1950
  }
 
1951
 
 
1952
  if ( dlg->precision != precision->value() )
 
1953
    style->changePrecision( precision->value() );
 
1954
 
 
1955
  if ( m_bFormatColorChanged )
 
1956
  {
 
1957
    switch( format->currentItem() )
 
1958
    {
 
1959
     case 0:
 
1960
      style->changeFloatFormat( KSpreadCell::OnlyNegSigned );
 
1961
      style->changeFloatColor( KSpreadCell::AllBlack );
 
1962
      break;
 
1963
     case 1:
 
1964
      style->changeFloatFormat( KSpreadCell::OnlyNegSigned );
 
1965
      style->changeFloatColor( KSpreadCell::NegRed );
 
1966
      break;
 
1967
     case 2:
 
1968
      style->changeFloatFormat( KSpreadCell::AlwaysUnsigned );
 
1969
      style->changeFloatColor( KSpreadCell::NegRed );
 
1970
      break;
 
1971
     case 3:
 
1972
      style->changeFloatFormat( KSpreadCell::AlwaysSigned );
 
1973
      style->changeFloatColor( KSpreadCell::AllBlack );
 
1974
      break;
 
1975
     case 4:
 
1976
      style->changeFloatFormat( KSpreadCell::AlwaysSigned );
 
1977
      style->changeFloatColor( KSpreadCell::NegRed );
 
1978
      break;
 
1979
    }
 
1980
  }
 
1981
  if ( m_bFormatTypeChanged )
 
1982
  {
 
1983
    style->changeFactor( 1.0 );
 
1984
    if ( number->isChecked() )
 
1985
      style->changeFormatType(KSpreadCell::Number);
 
1986
    else if ( percent->isChecked() )
 
1987
    {
 
1988
      style->changeFormatType(KSpreadCell::Percentage);
 
1989
      style->changeFactor(100.0);
 
1990
    }
 
1991
    else if ( fraction->isChecked() )
 
1992
    {
 
1993
      if ( listFormat->currentItem() == 0 )
 
1994
        style->changeFormatType(KSpreadCell::fraction_half);
 
1995
      else if ( listFormat->currentItem() == 1)
 
1996
        style->changeFormatType(KSpreadCell::fraction_quarter);
 
1997
      else if ( listFormat->currentItem() == 2)
 
1998
        style->changeFormatType(KSpreadCell::fraction_eighth);
 
1999
      else if ( listFormat->currentItem() == 3)
 
2000
        style->changeFormatType(KSpreadCell::fraction_sixteenth);
 
2001
      else if ( listFormat->currentItem() == 4)
 
2002
        style->changeFormatType(KSpreadCell::fraction_tenth);
 
2003
      else if ( listFormat->currentItem() == 5)
 
2004
        style->changeFormatType(KSpreadCell::fraction_hundredth);
 
2005
      else if ( listFormat->currentItem() == 6)
 
2006
        style->changeFormatType(KSpreadCell::fraction_one_digit);
 
2007
      else if ( listFormat->currentItem() == 7)
 
2008
        style->changeFormatType(KSpreadCell::fraction_two_digits);
 
2009
      else if ( listFormat->currentItem() == 8)
 
2010
        style->changeFormatType(KSpreadCell::fraction_three_digits);
 
2011
    }
 
2012
    else if (date->isChecked())
 
2013
    {
 
2014
      if ( listFormat->currentItem() == 0)
 
2015
        style->changeFormatType(KSpreadCell::ShortDate );
 
2016
      else if (listFormat->currentItem() == 1)
 
2017
        style->changeFormatType(KSpreadCell::TextDate );
 
2018
      else if (listFormat->currentItem() == 2)
 
2019
        style->changeFormatType(KSpreadCell::date_format1 );
 
2020
      else if (listFormat->currentItem() == 3)
 
2021
        style->changeFormatType(KSpreadCell::date_format2 );
 
2022
      else if (listFormat->currentItem() == 4)
 
2023
        style->changeFormatType(KSpreadCell::date_format3 );
 
2024
      else if (listFormat->currentItem() == 5)
 
2025
        style->changeFormatType(KSpreadCell::date_format4 );
 
2026
      else if (listFormat->currentItem() == 6)
 
2027
        style->changeFormatType(KSpreadCell::date_format5 );
 
2028
      else if (listFormat->currentItem() == 7)
 
2029
        style->changeFormatType(KSpreadCell::date_format6 );
 
2030
      else if (listFormat->currentItem() == 8)
 
2031
        style->changeFormatType(KSpreadCell::date_format7 );
 
2032
      else if (listFormat->currentItem() == 9)
 
2033
        style->changeFormatType(KSpreadCell::date_format8 );
 
2034
      else if (listFormat->currentItem() == 10)
 
2035
        style->changeFormatType(KSpreadCell::date_format9 );
 
2036
      else if (listFormat->currentItem() == 11)
 
2037
        style->changeFormatType(KSpreadCell::date_format10 );
 
2038
      else if (listFormat->currentItem() == 12)
 
2039
        style->changeFormatType(KSpreadCell::date_format11 );
 
2040
      else if (listFormat->currentItem() == 13)
 
2041
        style->changeFormatType(KSpreadCell::date_format12 );
 
2042
      else if (listFormat->currentItem() == 14)
 
2043
        style->changeFormatType(KSpreadCell::date_format13 );
 
2044
      else if (listFormat->currentItem() == 15)
 
2045
        style->changeFormatType(KSpreadCell::date_format14 );
 
2046
      else if (listFormat->currentItem() == 16)
 
2047
        style->changeFormatType(KSpreadCell::date_format15 );
 
2048
      else if (listFormat->currentItem() == 17)
 
2049
        style->changeFormatType(KSpreadCell::date_format16 );
 
2050
      else if (listFormat->currentItem() == 18)
 
2051
        style->changeFormatType(KSpreadCell::date_format17 );
 
2052
      else if (listFormat->currentItem() == 19)
 
2053
        style->changeFormatType(KSpreadCell::date_format18 );
 
2054
      else if (listFormat->currentItem() == 20)
 
2055
        style->changeFormatType(KSpreadCell::date_format19 );
 
2056
      else if (listFormat->currentItem() == 21)
 
2057
        style->changeFormatType(KSpreadCell::date_format20 );
 
2058
      else if (listFormat->currentItem() == 22)
 
2059
        style->changeFormatType(KSpreadCell::date_format21 );
 
2060
      else if (listFormat->currentItem() == 23)
 
2061
        style->changeFormatType(KSpreadCell::date_format22 );
 
2062
      else if (listFormat->currentItem() == 24)
 
2063
        style->changeFormatType(KSpreadCell::date_format23 );
 
2064
      else if (listFormat->currentItem() == 25)
 
2065
        style->changeFormatType(KSpreadCell::date_format24 );
 
2066
      else if (listFormat->currentItem() == 26)
 
2067
        style->changeFormatType(KSpreadCell::date_format25 );
 
2068
      else if (listFormat->currentItem() == 27)
 
2069
        style->changeFormatType(KSpreadCell::date_format26 );
 
2070
    }
 
2071
    else if ( time->isChecked() )
 
2072
    {
 
2073
      int current = listFormat->currentItem();
 
2074
      if ( current == 0 )
 
2075
        style->changeFormatType(KSpreadCell::Time );
 
2076
      else if (current == 1)
 
2077
        style->changeFormatType(KSpreadCell::SecondeTime );
 
2078
      else if (current == 2)
 
2079
        style->changeFormatType(KSpreadCell::Time_format1 );
 
2080
      else if (current == 3)
 
2081
        style->changeFormatType(KSpreadCell::Time_format2 );
 
2082
      else if (current == 4)
 
2083
        style->changeFormatType(KSpreadCell::Time_format3 );
 
2084
      else if (current == 5)
 
2085
        style->changeFormatType(KSpreadCell::Time_format4 );
 
2086
      else if (current == 6)
 
2087
        style->changeFormatType(KSpreadCell::Time_format5 );
 
2088
      else if (current == 7)
 
2089
        style->changeFormatType(KSpreadCell::Time_format6 );
 
2090
      else if (current == 8)
 
2091
        style->changeFormatType(KSpreadCell::Time_format7 );
 
2092
      else if (current == 9)
 
2093
        style->changeFormatType(KSpreadCell::Time_format8 );
 
2094
    }
 
2095
    else if ( money->isChecked() )
 
2096
    {
 
2097
      style->changeFormatType(KSpreadCell::Money);
 
2098
      KSpreadCell::Currency cur;
 
2099
      int index = currency->currentItem();
 
2100
      if (index == 0)
 
2101
      {
 
2102
        if ( currency->currentText() == i18n( "Automatic" ) )
 
2103
        {
 
2104
          cur.symbol = dlg->locale()->currencySymbol();
 
2105
          cur.type   = 0;
 
2106
        }
 
2107
        else
 
2108
        {
 
2109
          cur.type   = 1;
 
2110
          cur.symbol = currency->currentText();
 
2111
        }
 
2112
      }
 
2113
      else
 
2114
      {
 
2115
        cur.type   = ++index;
 
2116
        cur.symbol = KSpreadCurrency::getDisplaySymbol( index );
 
2117
      }
 
2118
 
 
2119
      style->changeCurrency( cur );
 
2120
    }
 
2121
    else if ( scientific->isChecked() )
 
2122
      style->changeFormatType( KSpreadCell::Scientific );
 
2123
    else if ( textFormat->isChecked() )
 
2124
      style->changeFormatType( KSpreadCell::Text_format );
 
2125
    else if ( customFormat->isChecked() )
 
2126
      style->changeFormatType( KSpreadCell::Custom );
 
2127
  }  
 
2128
}
 
2129
 
 
2130
void CellFormatPageFloat::applyFormat( KSpreadFormat *_obj )
1521
2131
{
1522
2132
    if ( postfix->text() != dlg->postfix )
1523
2133
        if ( postfix->text() != "########" && postfix->isEnabled())
1524
2134
            {
1525
2135
                // If we are in here it *never* can be disabled - FIXME (Werner)!
1526
 
                if( postfix->isEnabled())
 
2136
                if ( postfix->isEnabled())
1527
2137
                    _obj->setPostfix( postfix->text() );
1528
2138
                else
1529
2139
                    _obj->setPostfix( "" );
1531
2141
    if ( prefix->text() != dlg->prefix )
1532
2142
        if ( prefix->text() != "########" )
1533
2143
            {
1534
 
                if(prefix->isEnabled())
 
2144
                if (prefix->isEnabled())
1535
2145
                    _obj->setPrefix( prefix->text() );
1536
2146
                else
1537
2147
                    _obj->setPrefix( "" );
1541
2151
    if ( dlg->precision != precision->value() )
1542
2152
        _obj->setPrecision( precision->value() );
1543
2153
 
1544
 
    if(m_bFormatColorChanged)
 
2154
    if (m_bFormatColorChanged)
1545
2155
        {
1546
2156
            switch( format->currentItem() )
1547
2157
                {
1567
2177
                    break;
1568
2178
                }
1569
2179
        }
1570
 
    if(m_bFormatNumberChanged)
1571
 
        {
1572
 
            _obj->setFaktor(1.0);
1573
 
            if(number->isChecked())
1574
 
                _obj->setFormatNumber(KSpreadCell::Number);
1575
 
            else if(percent->isChecked())
1576
 
                {
1577
 
                    _obj->setFormatNumber(KSpreadCell::Percentage);
1578
 
                    _obj->setFaktor(100.0);
1579
 
                }
1580
 
            else if(fraction->isChecked())
1581
 
                {
1582
 
                    if( listFormat->currentItem()==0)
1583
 
                        _obj->setFormatNumber(KSpreadCell::fraction_half);
1584
 
                    else if( listFormat->currentItem()==1)
1585
 
                        _obj->setFormatNumber(KSpreadCell::fraction_quarter);
1586
 
                    else if( listFormat->currentItem()==2)
1587
 
                        _obj->setFormatNumber(KSpreadCell::fraction_eighth);
1588
 
                    else if( listFormat->currentItem()==3)
1589
 
                        _obj->setFormatNumber(KSpreadCell::fraction_sixteenth);
1590
 
                    else if( listFormat->currentItem()==4)
1591
 
                        _obj->setFormatNumber(KSpreadCell::fraction_tenth);
1592
 
                    else if( listFormat->currentItem()==5)
1593
 
                        _obj->setFormatNumber(KSpreadCell::fraction_hundredth);
1594
 
                    else if( listFormat->currentItem()==6)
1595
 
                        _obj->setFormatNumber(KSpreadCell::fraction_one_digit);
1596
 
                    else if( listFormat->currentItem()==7)
1597
 
                        _obj->setFormatNumber(KSpreadCell::fraction_two_digits);
1598
 
                    else if( listFormat->currentItem()==8)
1599
 
                        _obj->setFormatNumber(KSpreadCell::fraction_three_digits);
1600
 
                }
1601
 
            else if(date->isChecked())
1602
 
                {
1603
 
                    if( listFormat->currentItem()==0)
1604
 
                        _obj->setFormatNumber(KSpreadCell::ShortDate );
1605
 
                    else if(listFormat->currentItem()==1)
1606
 
                        _obj->setFormatNumber(KSpreadCell::TextDate );
1607
 
                    else if(listFormat->currentItem()==2)
1608
 
                        _obj->setFormatNumber(KSpreadCell::date_format1 );
1609
 
                    else if(listFormat->currentItem()==3)
1610
 
                        _obj->setFormatNumber(KSpreadCell::date_format2 );
1611
 
                    else if(listFormat->currentItem()==4)
1612
 
                        _obj->setFormatNumber(KSpreadCell::date_format3 );
1613
 
                    else if(listFormat->currentItem()==5)
1614
 
                        _obj->setFormatNumber(KSpreadCell::date_format4 );
1615
 
                    else if(listFormat->currentItem()==6)
1616
 
                        _obj->setFormatNumber(KSpreadCell::date_format5 );
1617
 
                    else if(listFormat->currentItem()==7)
1618
 
                        _obj->setFormatNumber(KSpreadCell::date_format6 );
1619
 
                    else if(listFormat->currentItem()==8)
1620
 
                        _obj->setFormatNumber(KSpreadCell::date_format7 );
1621
 
                    else if(listFormat->currentItem()==9)
1622
 
                        _obj->setFormatNumber(KSpreadCell::date_format8 );
1623
 
                    else if(listFormat->currentItem()==10)
1624
 
                        _obj->setFormatNumber(KSpreadCell::date_format9 );
1625
 
                    else if(listFormat->currentItem()==11)
1626
 
                        _obj->setFormatNumber(KSpreadCell::date_format10 );
1627
 
                    else if(listFormat->currentItem()==12)
1628
 
                        _obj->setFormatNumber(KSpreadCell::date_format11 );
1629
 
                    else if(listFormat->currentItem()==13)
1630
 
                        _obj->setFormatNumber(KSpreadCell::date_format12 );
1631
 
                    else if(listFormat->currentItem()==14)
1632
 
                        _obj->setFormatNumber(KSpreadCell::date_format13 );
1633
 
                    else if(listFormat->currentItem()==15)
1634
 
                        _obj->setFormatNumber(KSpreadCell::date_format14 );
1635
 
                    else if(listFormat->currentItem()==16)
1636
 
                        _obj->setFormatNumber(KSpreadCell::date_format15 );
1637
 
                    else if(listFormat->currentItem()==17)
1638
 
                        _obj->setFormatNumber(KSpreadCell::date_format16 );
1639
 
                    else if(listFormat->currentItem()==18)
1640
 
                        _obj->setFormatNumber(KSpreadCell::date_format17 );
1641
 
                }
1642
 
            else if(time->isChecked())
1643
 
                {
1644
 
                    if( listFormat->currentItem()==0)
1645
 
                        _obj->setFormatNumber(KSpreadCell::Time );
1646
 
                    else if(listFormat->currentItem()==1)
1647
 
                        _obj->setFormatNumber(KSpreadCell::SecondeTime );
1648
 
                    else if(listFormat->currentItem()==2)
1649
 
                        _obj->setFormatNumber(KSpreadCell::Time_format1 );
1650
 
                    else if(listFormat->currentItem()==3)
1651
 
                        _obj->setFormatNumber(KSpreadCell::Time_format2 );
1652
 
                    else if(listFormat->currentItem()==4)
1653
 
                        _obj->setFormatNumber(KSpreadCell::Time_format3 );
1654
 
                }
1655
 
            else if(money->isChecked())
1656
 
                _obj->setFormatNumber(KSpreadCell::Money);
1657
 
            else if(scientific->isChecked())
1658
 
                _obj->setFormatNumber(KSpreadCell::Scientific);
1659
 
        }
1660
 
}
1661
 
 
1662
 
void CellLayoutPageFloat::apply( KSpreadCell *_obj )
1663
 
{
1664
 
applyLayout(_obj);
1665
 
}
1666
 
 
1667
 
void CellLayoutPageFloat::apply( RowLayout *_obj )
1668
 
{
1669
 
    KSpreadCell*c= dlg->getTable()->firstCell();
1670
 
    for( ;c; c = c->nextCell() )
1671
 
        {
1672
 
            int row = c->row();
1673
 
            if ( dlg->top <= row && dlg->bottom >= row
1674
 
                 &&!c->isObscuringForced())
1675
 
                {
1676
 
                    if ( dlg->precision != precision->value() )
1677
 
                        {
1678
 
                            c->clearProperty(KSpreadCell::PPrecision);
1679
 
                            c->clearNoFallBackProperties( KSpreadCell::PPrecision );
1680
 
                        }
1681
 
                    if ( postfix->text() != dlg->postfix )
1682
 
                        {
1683
 
                            if ( postfix->text() != "########" )
1684
 
                                {
1685
 
                                    c->clearProperty(KSpreadCell::PPostfix);
1686
 
                                    c->clearNoFallBackProperties( KSpreadCell::PPostfix );
1687
 
                                }
1688
 
                        }
1689
 
                    if ( prefix->text() != dlg->prefix )
1690
 
                        {
1691
 
                            if ( postfix->text() != "########" )
1692
 
                                {
1693
 
                                    c->clearProperty(KSpreadCell::PPrefix);
1694
 
                                    c->clearNoFallBackProperties( KSpreadCell::PPrefix );
1695
 
                                }
1696
 
                        }
1697
 
                    if(m_bFormatColorChanged)
1698
 
                        {
1699
 
                            c->clearProperty(KSpreadCell::PFloatFormat);
1700
 
                            c->clearNoFallBackProperties( KSpreadCell::PFloatFormat );
1701
 
                            c->clearProperty(KSpreadCell::PFloatColor);
1702
 
                            c->clearNoFallBackProperties( KSpreadCell::PFloatColor );
1703
 
                        }
1704
 
                    if(m_bFormatNumberChanged)
1705
 
                        {
1706
 
                            c->clearProperty(KSpreadCell::PFormatNumber);
1707
 
                            c->clearNoFallBackProperties( KSpreadCell::PFormatNumber );
1708
 
                            c->clearProperty(KSpreadCell::PFaktor);
1709
 
                            c->clearNoFallBackProperties( KSpreadCell::PFaktor );
1710
 
                        }
1711
 
                }
1712
 
        }
1713
 
    applyLayout(_obj);
1714
 
}
1715
 
 
1716
 
void CellLayoutPageFloat::apply( ColumnLayout *_obj )
1717
 
{
1718
 
  KSpreadCell*c= dlg->getTable()->firstCell();
1719
 
  for( ;c; c = c->nextCell() )
1720
 
      {
1721
 
        int col = c->column();
1722
 
        if ( dlg->left <= col && dlg->right >= col
1723
 
        &&!c->isObscuringForced())
1724
 
        {
1725
 
        if ( dlg->precision != precision->value() )
1726
 
                {
1727
 
                c->clearProperty(KSpreadCell::PPrecision);
1728
 
                c->clearNoFallBackProperties( KSpreadCell::PPrecision );
1729
 
                }
1730
 
        if ( postfix->text() != dlg->postfix )
1731
 
                {
1732
 
                if ( postfix->text() != "########" )
1733
 
                        {
1734
 
                        c->clearProperty(KSpreadCell::PPostfix);
1735
 
                        c->clearNoFallBackProperties( KSpreadCell::PPostfix );
1736
 
                        }
1737
 
                }
1738
 
        if ( prefix->text() != dlg->prefix )
1739
 
                {
1740
 
                if ( prefix->text() != "########" )
1741
 
                        {
1742
 
                        c->clearProperty(KSpreadCell::PPrefix);
1743
 
                        c->clearNoFallBackProperties( KSpreadCell::PPrefix );
1744
 
                        }
1745
 
                }
1746
 
        if(m_bFormatColorChanged)
1747
 
                {
1748
 
                c->clearProperty(KSpreadCell::PFloatFormat);
1749
 
                c->clearNoFallBackProperties( KSpreadCell::PFloatFormat );
1750
 
                c->clearProperty(KSpreadCell::PFloatColor);
1751
 
                c->clearNoFallBackProperties( KSpreadCell::PFloatColor );
1752
 
                }
1753
 
           if(m_bFormatNumberChanged)
1754
 
                {
1755
 
                c->clearProperty(KSpreadCell::PFormatNumber);
1756
 
                c->clearNoFallBackProperties( KSpreadCell::PFormatNumber );
1757
 
                c->clearProperty(KSpreadCell::PFaktor);
1758
 
                c->clearNoFallBackProperties( KSpreadCell::PFaktor );
1759
 
                }
1760
 
        }
1761
 
      }
1762
 
      applyLayout(_obj);
1763
 
 
1764
 
      RowLayout* rw =dlg->getTable()->firstRow();
1765
 
      for( ; rw; rw = rw->next() )
1766
 
        {
1767
 
        if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PPrecision) || rw->hasProperty(KSpreadCell::PPostfix)
1768
 
        || rw->hasProperty(KSpreadCell::PPrefix) || rw->hasProperty(KSpreadCell::PFloatFormat)
1769
 
        || rw->hasProperty(KSpreadCell::PFloatColor) || rw->hasProperty(KSpreadCell::PFormatNumber)
1770
 
        || rw->hasProperty(KSpreadCell::PFaktor) ))
1771
 
                {
1772
 
                for(int i=dlg->left;i<=dlg->right;i++)
1773
 
                        {
1774
 
                        KSpreadCell *cell = dlg->getTable()->cellAt( i,  rw->row());
1775
 
                        if ( cell->isDefault() )
1776
 
                                {
1777
 
                                cell = new KSpreadCell( dlg->getTable(), i,  rw->row() );
1778
 
                                dlg->getTable()->insertCell( cell);
1779
 
                                }
1780
 
                        applyLayout(cell );
1781
 
                        }
1782
 
                }
1783
 
        }
1784
 
 
1785
 
}
1786
 
 
1787
 
 
1788
 
CellLayoutPageMisc::CellLayoutPageMisc( QWidget* parent, CellLayoutDlg *_dlg ) : QWidget( parent )
 
2180
    if (m_bFormatTypeChanged)
 
2181
        {
 
2182
            _obj->setFactor(1.0);
 
2183
            if (number->isChecked())
 
2184
                _obj->setFormatType(KSpreadCell::Number);
 
2185
            else if (percent->isChecked())
 
2186
                {
 
2187
                    _obj->setFormatType(KSpreadCell::Percentage);
 
2188
                    _obj->setFactor(100.0);
 
2189
                }
 
2190
            else if (fraction->isChecked())
 
2191
                {
 
2192
                    if ( listFormat->currentItem() == 0)
 
2193
                        _obj->setFormatType(KSpreadCell::fraction_half);
 
2194
                    else if ( listFormat->currentItem() == 1)
 
2195
                        _obj->setFormatType(KSpreadCell::fraction_quarter);
 
2196
                    else if ( listFormat->currentItem() == 2)
 
2197
                        _obj->setFormatType(KSpreadCell::fraction_eighth);
 
2198
                    else if ( listFormat->currentItem() == 3)
 
2199
                        _obj->setFormatType(KSpreadCell::fraction_sixteenth);
 
2200
                    else if ( listFormat->currentItem() == 4)
 
2201
                        _obj->setFormatType(KSpreadCell::fraction_tenth);
 
2202
                    else if ( listFormat->currentItem() == 5)
 
2203
                        _obj->setFormatType(KSpreadCell::fraction_hundredth);
 
2204
                    else if ( listFormat->currentItem() == 6)
 
2205
                        _obj->setFormatType(KSpreadCell::fraction_one_digit);
 
2206
                    else if ( listFormat->currentItem() == 7)
 
2207
                        _obj->setFormatType(KSpreadCell::fraction_two_digits);
 
2208
                    else if ( listFormat->currentItem() == 8)
 
2209
                        _obj->setFormatType(KSpreadCell::fraction_three_digits);
 
2210
                }
 
2211
            else if (date->isChecked())
 
2212
                {
 
2213
                    if ( listFormat->currentItem() == 0)
 
2214
                        _obj->setFormatType(KSpreadCell::ShortDate );
 
2215
                    else if (listFormat->currentItem() == 1)
 
2216
                        _obj->setFormatType(KSpreadCell::TextDate );
 
2217
                    else if (listFormat->currentItem() == 2)
 
2218
                        _obj->setFormatType(KSpreadCell::date_format1 );
 
2219
                    else if (listFormat->currentItem() == 3)
 
2220
                        _obj->setFormatType(KSpreadCell::date_format2 );
 
2221
                    else if (listFormat->currentItem() == 4)
 
2222
                        _obj->setFormatType(KSpreadCell::date_format3 );
 
2223
                    else if (listFormat->currentItem() == 5)
 
2224
                        _obj->setFormatType(KSpreadCell::date_format4 );
 
2225
                    else if (listFormat->currentItem() == 6)
 
2226
                        _obj->setFormatType(KSpreadCell::date_format5 );
 
2227
                    else if (listFormat->currentItem() == 7)
 
2228
                        _obj->setFormatType(KSpreadCell::date_format6 );
 
2229
                    else if (listFormat->currentItem() == 8)
 
2230
                        _obj->setFormatType(KSpreadCell::date_format7 );
 
2231
                    else if (listFormat->currentItem() == 9)
 
2232
                        _obj->setFormatType(KSpreadCell::date_format8 );
 
2233
                    else if (listFormat->currentItem() == 10)
 
2234
                        _obj->setFormatType(KSpreadCell::date_format9 );
 
2235
                    else if (listFormat->currentItem() == 11)
 
2236
                        _obj->setFormatType(KSpreadCell::date_format10 );
 
2237
                    else if (listFormat->currentItem() == 12)
 
2238
                        _obj->setFormatType(KSpreadCell::date_format11 );
 
2239
                    else if (listFormat->currentItem() == 13)
 
2240
                        _obj->setFormatType(KSpreadCell::date_format12 );
 
2241
                    else if (listFormat->currentItem() == 14)
 
2242
                        _obj->setFormatType(KSpreadCell::date_format13 );
 
2243
                    else if (listFormat->currentItem() == 15)
 
2244
                        _obj->setFormatType(KSpreadCell::date_format14 );
 
2245
                    else if (listFormat->currentItem() == 16)
 
2246
                        _obj->setFormatType(KSpreadCell::date_format15 );
 
2247
                    else if (listFormat->currentItem() == 17)
 
2248
                        _obj->setFormatType(KSpreadCell::date_format16 );
 
2249
                    else if (listFormat->currentItem() == 18)
 
2250
                        _obj->setFormatType(KSpreadCell::date_format17 );
 
2251
                    else if (listFormat->currentItem() == 19)
 
2252
                        _obj->setFormatType(KSpreadCell::date_format18 );
 
2253
                    else if (listFormat->currentItem() == 20)
 
2254
                        _obj->setFormatType(KSpreadCell::date_format19 );
 
2255
                    else if (listFormat->currentItem() == 21)
 
2256
                        _obj->setFormatType(KSpreadCell::date_format20 );
 
2257
                    else if (listFormat->currentItem() == 22)
 
2258
                        _obj->setFormatType(KSpreadCell::date_format21 );
 
2259
                    else if (listFormat->currentItem() == 23)
 
2260
                        _obj->setFormatType(KSpreadCell::date_format22 );
 
2261
                    else if (listFormat->currentItem() == 24)
 
2262
                        _obj->setFormatType(KSpreadCell::date_format23 );
 
2263
                    else if (listFormat->currentItem() == 25)
 
2264
                        _obj->setFormatType(KSpreadCell::date_format24 );
 
2265
                    else if (listFormat->currentItem() == 26)
 
2266
                        _obj->setFormatType(KSpreadCell::date_format25 );
 
2267
                    else if (listFormat->currentItem() == 27)
 
2268
                        _obj->setFormatType(KSpreadCell::date_format26 );
 
2269
                }
 
2270
            else if (time->isChecked())
 
2271
                {
 
2272
                  int current = listFormat->currentItem();
 
2273
                    if ( current  == 0)
 
2274
                        _obj->setFormatType(KSpreadCell::Time );
 
2275
                    else if (current == 1)
 
2276
                        _obj->setFormatType(KSpreadCell::SecondeTime );
 
2277
                    else if (current == 2)
 
2278
                        _obj->setFormatType(KSpreadCell::Time_format1 );
 
2279
                    else if (current == 3)
 
2280
                        _obj->setFormatType(KSpreadCell::Time_format2 );
 
2281
                    else if (current == 4)
 
2282
                        _obj->setFormatType(KSpreadCell::Time_format3 );
 
2283
                    else if (current == 5)
 
2284
                        _obj->setFormatType(KSpreadCell::Time_format4 );
 
2285
                    else if (current == 6)
 
2286
                        _obj->setFormatType(KSpreadCell::Time_format5 );
 
2287
                    else if (current == 7)
 
2288
                        _obj->setFormatType(KSpreadCell::Time_format6 );
 
2289
                    else if (current == 8)
 
2290
                        _obj->setFormatType(KSpreadCell::Time_format7 );
 
2291
                    else if (current == 9)
 
2292
                        _obj->setFormatType(KSpreadCell::Time_format8 );
 
2293
                }
 
2294
            else if (money->isChecked())
 
2295
            {
 
2296
                _obj->setFormatType(KSpreadCell::Money);
 
2297
                KSpreadCell::Currency cur;
 
2298
                int index = currency->currentItem();
 
2299
                if (index == 0)
 
2300
                {
 
2301
                  if ( currency->currentText() == i18n( "Automatic" ) )
 
2302
                  {
 
2303
                    cur.symbol = dlg->locale()->currencySymbol();
 
2304
                    cur.type   = 0;
 
2305
                  }
 
2306
                  else
 
2307
                  {
 
2308
                    cur.type   = 1;
 
2309
                    cur.symbol = currency->currentText();
 
2310
                  }
 
2311
                }
 
2312
                else
 
2313
                {
 
2314
                  cur.type   = ++index;
 
2315
                  cur.symbol = KSpreadCurrency::getDisplaySymbol( index );
 
2316
                }
 
2317
 
 
2318
                _obj->setCurrency( cur.type, cur.symbol );
 
2319
            }
 
2320
            else if (scientific->isChecked())
 
2321
                _obj->setFormatType(KSpreadCell::Scientific);
 
2322
            else if (textFormat->isChecked())
 
2323
              _obj->setFormatType(KSpreadCell::Text_format);
 
2324
            else if (customFormat->isChecked())
 
2325
              _obj->setFormatType(KSpreadCell::Custom);
 
2326
        }
 
2327
}
 
2328
 
 
2329
void CellFormatPageFloat::apply( KSpreadCell *_obj )
 
2330
{
 
2331
    applyFormat(_obj);
 
2332
}
 
2333
 
 
2334
void CellFormatPageFloat::apply( RowFormat *_obj )
 
2335
{
 
2336
  KSpreadSheet* table = dlg->getTable();
 
2337
  KSpreadCell* c = NULL;
 
2338
  for (int row = dlg->top; row <= dlg->bottom; row++)
 
2339
  {
 
2340
    for ( c = table->getFirstCellRow(row); c != NULL;
 
2341
         c = table->getNextCellRight(c->column(), c->row()) )
 
2342
    {
 
2343
      if ( dlg->precision != precision->value() )
 
2344
      {
 
2345
        c->clearProperty(KSpreadCell::PPrecision);
 
2346
        c->clearNoFallBackProperties( KSpreadCell::PPrecision );
 
2347
      }
 
2348
      if ( postfix->text() != dlg->postfix )
 
2349
      {
 
2350
        if ( postfix->text() != "########" )
 
2351
        {
 
2352
          c->clearProperty(KSpreadCell::PPostfix);
 
2353
          c->clearNoFallBackProperties( KSpreadCell::PPostfix );
 
2354
        }
 
2355
      }
 
2356
      if ( prefix->text() != dlg->prefix )
 
2357
      {
 
2358
        if ( postfix->text() != "########" )
 
2359
        {
 
2360
          c->clearProperty(KSpreadCell::PPrefix);
 
2361
          c->clearNoFallBackProperties( KSpreadCell::PPrefix );
 
2362
        }
 
2363
      }
 
2364
      if (m_bFormatColorChanged)
 
2365
      {
 
2366
        c->clearProperty(KSpreadCell::PFloatFormat);
 
2367
        c->clearNoFallBackProperties( KSpreadCell::PFloatFormat );
 
2368
        c->clearProperty(KSpreadCell::PFloatColor);
 
2369
        c->clearNoFallBackProperties( KSpreadCell::PFloatColor );
 
2370
      }
 
2371
      if (m_bFormatTypeChanged)
 
2372
      {
 
2373
        c->clearProperty(KSpreadCell::PFormatType);
 
2374
        c->clearNoFallBackProperties( KSpreadCell::PFormatType );
 
2375
        c->clearProperty(KSpreadCell::PFactor);
 
2376
        c->clearNoFallBackProperties( KSpreadCell::PFactor );
 
2377
      }
 
2378
    }
 
2379
  }
 
2380
  applyFormat(_obj);
 
2381
}
 
2382
 
 
2383
void CellFormatPageFloat::apply( ColumnFormat *_obj )
 
2384
{
 
2385
  KSpreadSheet *table = dlg->getTable();
 
2386
  KSpreadCell* c = NULL;
 
2387
  for (int col = dlg->left; col <= dlg->right; col++)
 
2388
  {
 
2389
    for ( c = table->getFirstCellColumn(col); c != NULL;
 
2390
         c = table->getNextCellDown(c->column(), c->row()) )
 
2391
    {
 
2392
      if ( dlg->precision != precision->value() )
 
2393
      {
 
2394
        c->clearProperty(KSpreadCell::PPrecision);
 
2395
        c->clearNoFallBackProperties( KSpreadCell::PPrecision );
 
2396
      }
 
2397
      if ( postfix->text() != dlg->postfix )
 
2398
      {
 
2399
        if ( postfix->text() != "########" )
 
2400
        {
 
2401
          c->clearProperty(KSpreadCell::PPostfix);
 
2402
          c->clearNoFallBackProperties( KSpreadCell::PPostfix );
 
2403
        }
 
2404
      }
 
2405
      if ( prefix->text() != dlg->prefix )
 
2406
      {
 
2407
        if ( prefix->text() != "########" )
 
2408
        {
 
2409
          c->clearProperty(KSpreadCell::PPrefix);
 
2410
          c->clearNoFallBackProperties( KSpreadCell::PPrefix );
 
2411
        }
 
2412
      }
 
2413
      if (m_bFormatColorChanged)
 
2414
      {
 
2415
        c->clearProperty(KSpreadCell::PFloatFormat);
 
2416
        c->clearNoFallBackProperties( KSpreadCell::PFloatFormat );
 
2417
        c->clearProperty(KSpreadCell::PFloatColor);
 
2418
        c->clearNoFallBackProperties( KSpreadCell::PFloatColor );
 
2419
      }
 
2420
      if (m_bFormatTypeChanged)
 
2421
      {
 
2422
        c->clearProperty(KSpreadCell::PFormatType);
 
2423
        c->clearNoFallBackProperties( KSpreadCell::PFormatType );
 
2424
        c->clearProperty(KSpreadCell::PFactor);
 
2425
        c->clearNoFallBackProperties( KSpreadCell::PFactor );
 
2426
      }
 
2427
    }
 
2428
  }
 
2429
  applyFormat(_obj);
 
2430
 
 
2431
  RowFormat* rw =dlg->getTable()->firstRow();
 
2432
  for ( ; rw; rw = rw->next() )
 
2433
  {
 
2434
    if ( !rw->isDefault() &&
 
2435
         (rw->hasProperty(KSpreadCell::PPrecision) ||
 
2436
          rw->hasProperty(KSpreadCell::PPostfix) ||
 
2437
          rw->hasProperty(KSpreadCell::PPrefix) ||
 
2438
          rw->hasProperty(KSpreadCell::PFloatFormat) ||
 
2439
          rw->hasProperty(KSpreadCell::PFloatColor) ||
 
2440
          rw->hasProperty(KSpreadCell::PFormatType) ||
 
2441
          rw->hasProperty(KSpreadCell::PFactor) ))
 
2442
    {
 
2443
      for ( int i=dlg->left;i<=dlg->right;i++)
 
2444
      {
 
2445
        KSpreadCell *cell = dlg->getTable()->nonDefaultCell( i, rw->row() );
 
2446
        applyFormat(cell );
 
2447
      }
 
2448
    }
 
2449
  }
 
2450
}
 
2451
 
 
2452
CellFormatPageProtection::CellFormatPageProtection( QWidget* parent, CellFormatDlg * _dlg )
 
2453
  : QWidget( parent ),
 
2454
    m_dlg( _dlg )
 
2455
{
 
2456
  QVBoxLayout * Form1Layout     = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint(), "Form1Layout");
 
2457
 
 
2458
  QGroupBox   * groupBox1       = new QGroupBox( 0, Qt::Vertical, i18n( "Protection" ), this, "groupBox1" );
 
2459
  groupBox1->layout()->setSpacing( KDialog::spacingHint() );
 
2460
  groupBox1->layout()->setMargin( KDialog::marginHint() );
 
2461
  QVBoxLayout * groupBox1Layout = new QVBoxLayout( groupBox1->layout() );
 
2462
 
 
2463
  m_bIsProtected = new QCheckBox( i18n( "&Protected" ), groupBox1, "m_bIsProtected" );
 
2464
  m_bIsProtected->setChecked( true );
 
2465
  groupBox1Layout->addWidget( m_bIsProtected );
 
2466
 
 
2467
  m_bHideFormula = new QCheckBox( i18n( "&Hide formula" ), groupBox1, "m_bHideFormula" );
 
2468
  groupBox1Layout->addWidget( m_bHideFormula );
 
2469
 
 
2470
  m_bHideAll = new QCheckBox( i18n( "Hide &all" ), groupBox1, "m_bHideAll" );
 
2471
  groupBox1Layout->addWidget( m_bHideAll );
 
2472
  Form1Layout->addWidget( groupBox1 );
 
2473
 
 
2474
  QGroupBox   * groupBox2       = new QGroupBox( 0, Qt::Vertical, i18n( "Printing" ), this, "groupBox2" );
 
2475
  groupBox2->layout()->setSpacing( KDialog::spacingHint() );
 
2476
  groupBox2->layout()->setMargin( KDialog::marginHint() );
 
2477
  QVBoxLayout * groupBox2Layout = new QVBoxLayout( groupBox2->layout() );
 
2478
 
 
2479
  m_bDontPrint = new QCheckBox( i18n( "&Don't print text" ), groupBox2, "m_bDontPrint" );
 
2480
  groupBox2Layout->addWidget( m_bDontPrint );
 
2481
  Form1Layout->addWidget( groupBox2 );
 
2482
  QSpacerItem * spacer_4 = new QSpacerItem( 20, 90, QSizePolicy::Minimum, QSizePolicy::Expanding );
 
2483
  Form1Layout->addItem( spacer_4 );
 
2484
 
 
2485
  m_bDontPrint->setChecked( m_dlg->bDontPrintText );
 
2486
  m_bHideAll->setChecked( m_dlg->bHideAll );
 
2487
  m_bHideFormula->setChecked( m_dlg->bHideFormula );
 
2488
  m_bIsProtected->setChecked( m_dlg->bIsProtected );
 
2489
}
 
2490
 
 
2491
CellFormatPageProtection::~CellFormatPageProtection()
 
2492
{
 
2493
}
 
2494
 
 
2495
void CellFormatPageProtection::apply( KSpreadCustomStyle * style )
 
2496
{
 
2497
  if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked() )
 
2498
  {
 
2499
    if ( m_bDontPrint->isChecked() )
 
2500
      style->addProperty( KSpreadStyle::PDontPrintText );
 
2501
    else
 
2502
      style->removeProperty( KSpreadStyle::PDontPrintText );
 
2503
  }
 
2504
 
 
2505
  if ( m_dlg->bIsProtected != m_bIsProtected->isChecked() )
 
2506
  {
 
2507
    if ( !m_bIsProtected->isChecked() )
 
2508
      style->addProperty( KSpreadStyle::PNotProtected );
 
2509
    else
 
2510
      style->removeProperty( KSpreadStyle::PNotProtected );
 
2511
  }
 
2512
 
 
2513
  if ( m_dlg->bHideAll != m_bHideAll->isChecked() )
 
2514
  {
 
2515
    if ( m_bHideAll->isChecked() )
 
2516
      style->addProperty( KSpreadStyle::PHideAll );
 
2517
    else
 
2518
      style->removeProperty( KSpreadStyle::PHideAll );
 
2519
  }
 
2520
 
 
2521
  if ( m_dlg->bHideFormula != m_bHideFormula->isChecked() )
 
2522
  {
 
2523
    if ( m_bHideFormula->isChecked() )
 
2524
      style->addProperty( KSpreadStyle::PHideFormula );
 
2525
    else
 
2526
      style->removeProperty( KSpreadStyle::PHideFormula );
 
2527
  }
 
2528
}
 
2529
 
 
2530
void CellFormatPageProtection::apply( KSpreadCell * _cell )
 
2531
{
 
2532
  applyFormat( _cell );
 
2533
}
 
2534
 
 
2535
void CellFormatPageProtection::apply( ColumnFormat * _col )
 
2536
{
 
2537
  KSpreadSheet * table = m_dlg->getTable();
 
2538
  KSpreadCell  * c     = 0;
 
2539
  for (int col = m_dlg->left; col <= m_dlg->right; col++)
 
2540
  {
 
2541
    for ( c = table->getFirstCellColumn( col ); c != 0;
 
2542
         c = table->getNextCellDown( c->column(), c->row() ) )
 
2543
    {
 
2544
      if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked() )
 
2545
      {
 
2546
        c->clearProperty( KSpreadCell::PDontPrintText );
 
2547
        c->clearNoFallBackProperties( KSpreadCell::PDontPrintText );
 
2548
      }
 
2549
      if ( m_dlg->bIsProtected != m_bIsProtected->isChecked() )
 
2550
      {
 
2551
        c->clearProperty( KSpreadCell::PNotProtected );
 
2552
        c->clearNoFallBackProperties( KSpreadCell::PNotProtected );
 
2553
      }
 
2554
      if ( m_dlg->bHideFormula != m_bHideFormula->isChecked() )
 
2555
      {
 
2556
        c->clearProperty( KSpreadCell::PHideFormula );
 
2557
        c->clearNoFallBackProperties( KSpreadCell::PHideFormula );
 
2558
      }
 
2559
      if ( m_dlg->bHideAll != m_bHideAll->isChecked() )
 
2560
      {
 
2561
        c->clearProperty( KSpreadCell::PHideAll );
 
2562
        c->clearNoFallBackProperties( KSpreadCell::PHideAll );
 
2563
      }
 
2564
    }
 
2565
  }
 
2566
 
 
2567
  applyFormat( _col );
 
2568
}
 
2569
 
 
2570
void CellFormatPageProtection::apply( RowFormat * _row )
 
2571
{
 
2572
  KSpreadSheet * table = m_dlg->getTable();
 
2573
  KSpreadCell  * c = 0;
 
2574
  for ( int row = m_dlg->top; row <= m_dlg->bottom; ++row)
 
2575
  {
 
2576
    for ( c = table->getFirstCellRow( row ); c != 0;
 
2577
         c = table->getNextCellRight( c->column(), c->row() ) )
 
2578
    {
 
2579
      if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked() )
 
2580
      {
 
2581
        c->clearProperty( KSpreadCell::PDontPrintText );
 
2582
        c->clearNoFallBackProperties( KSpreadCell::PDontPrintText );
 
2583
      }
 
2584
      if ( m_dlg->bIsProtected != m_bIsProtected->isChecked() )
 
2585
      {
 
2586
        c->clearProperty( KSpreadCell::PNotProtected );
 
2587
        c->clearNoFallBackProperties( KSpreadCell::PNotProtected );
 
2588
      }
 
2589
      if ( m_dlg->bHideFormula != m_bHideFormula->isChecked() )
 
2590
      {
 
2591
        c->clearProperty( KSpreadCell::PHideFormula );
 
2592
        c->clearNoFallBackProperties( KSpreadCell::PHideFormula );
 
2593
      }
 
2594
      if ( m_dlg->bHideAll != m_bHideAll->isChecked() )
 
2595
      {
 
2596
        c->clearProperty( KSpreadCell::PHideAll );
 
2597
        c->clearNoFallBackProperties( KSpreadCell::PHideAll );
 
2598
      }
 
2599
    }
 
2600
  }
 
2601
 
 
2602
  applyFormat( _row );
 
2603
}
 
2604
 
 
2605
void CellFormatPageProtection::applyFormat( KSpreadFormat * _obj )
 
2606
{
 
2607
  if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked())
 
2608
    _obj->setDontPrintText( m_bDontPrint->isChecked() );
 
2609
 
 
2610
  if ( m_dlg->bIsProtected != m_bIsProtected->isChecked())
 
2611
    _obj->setNotProtected( !m_bIsProtected->isChecked() );
 
2612
 
 
2613
  if ( m_dlg->bHideAll != m_bHideAll->isChecked())
 
2614
    _obj->setHideAll( m_bHideAll->isChecked() );
 
2615
 
 
2616
  if ( m_dlg->bHideFormula != m_bHideFormula->isChecked())
 
2617
    _obj->setHideFormula( m_bHideFormula->isChecked() );
 
2618
}
 
2619
 
 
2620
 
 
2621
CellFormatPageMisc::CellFormatPageMisc( QWidget* parent, CellFormatDlg *_dlg ) : QWidget( parent )
1789
2622
{
1790
2623
    dlg = _dlg;
1791
2624
 
1792
2625
 
1793
 
    QGridLayout* layout = new QGridLayout( this, 2,2,7,7 );
 
2626
    QGridLayout* layout = new QGridLayout( this, 2,2,KDialog::marginHint(), KDialog::spacingHint() );
1794
2627
    QGroupBox *box = new QGroupBox( this, "Box");
1795
2628
 
1796
 
    QGridLayout *grid = new QGridLayout(box,2,4,7,7);
 
2629
    QGridLayout *grid = new QGridLayout(box,2,4,KDialog::marginHint(), KDialog::spacingHint());
1797
2630
    QLabel *tmpQLabel;
1798
2631
 
1799
2632
    tmpQLabel = new QLabel( box, "Label_3" );
1844
2677
    layout->addWidget(box,0,0);
1845
2678
 
1846
2679
    box = new QGroupBox( this, "Box1");
1847
 
    grid = new QGridLayout(box,4,1,7,7);
 
2680
    grid = new QGridLayout(box,4,1,KDialog::marginHint(), KDialog::spacingHint());
1848
2681
    dontPrintText= new QCheckBox(i18n("Don't print text"),box);
1849
 
    dontPrintText->setChecked(dlg->bDontprintText);
 
2682
    dontPrintText->setChecked(dlg->bDontPrintText);
1850
2683
 
1851
2684
    grid->addWidget(dontPrintText,0,0);
1852
2685
    layout->addWidget(box,1,0);
1855
2688
    this->resize( 400, 400 );
1856
2689
}
1857
2690
 
1858
 
void CellLayoutPageMisc::apply( KSpreadCell *_obj )
1859
 
{
1860
 
 applyLayout(_obj);
1861
 
}
1862
 
 
1863
 
void CellLayoutPageMisc::applyColumn( )
1864
 
{
1865
 
  KSpreadCell*c= dlg->getTable()->firstCell();
1866
 
  for( ;c; c = c->nextCell() )
1867
 
      {
1868
 
        int col = c->column();
1869
 
        if ( dlg->left <= col && dlg->right >= col
1870
 
        &&!c->isObscuringForced())
1871
 
                applyLayout(c);
1872
 
      }
1873
 
}
1874
 
 
1875
 
void CellLayoutPageMisc::applyRow(  )
1876
 
{
1877
 
  KSpreadCell*c= dlg->getTable()->firstCell();
1878
 
  for( ;c; c = c->nextCell() )
1879
 
      {
1880
 
        int row = c->row();
1881
 
        if ( dlg->top <= row && dlg->bottom >= row
1882
 
        &&!c->isObscuringForced())
1883
 
                applyLayout(c);
1884
 
      }
1885
 
}
1886
 
 
1887
 
KSpreadCell::Style CellLayoutPageMisc::getStyle()
 
2691
void CellFormatPageMisc::apply( KSpreadCustomStyle * /* style */ )
 
2692
{
 
2693
  // TODO
 
2694
}
 
2695
 
 
2696
void CellFormatPageMisc::apply( KSpreadCell *_obj )
 
2697
{
 
2698
  applyFormat( _obj );
 
2699
}
 
2700
 
 
2701
void CellFormatPageMisc::applyColumn( )
 
2702
{
 
2703
  KSpreadSheet* table = dlg->getTable();
 
2704
  KSpreadCell* c = NULL;
 
2705
  for (int col = dlg->left; col <= dlg->right; col++)
 
2706
  {
 
2707
    for ( c = table->getFirstCellColumn(col); c != NULL;
 
2708
         c = table->getNextCellDown(c->column(), c->row()) )
 
2709
      {
 
2710
        applyFormat(c);
 
2711
      }
 
2712
  }
 
2713
}
 
2714
 
 
2715
void CellFormatPageMisc::applyRow( )
 
2716
{
 
2717
  KSpreadSheet* table = dlg->getTable();
 
2718
  KSpreadCell* c= NULL;
 
2719
  for (int row = dlg->top; row <= dlg->bottom; row++)
 
2720
  {
 
2721
    for ( c = table->getFirstCellRow(row); c != NULL;
 
2722
         c = table->getNextCellRight(c->column(), c->row()) )
 
2723
    {
 
2724
      applyFormat(c);
 
2725
    }
 
2726
  }
 
2727
}
 
2728
 
 
2729
KSpreadCell::Style CellFormatPageMisc::getStyle()
1888
2730
{
1889
2731
  switch(styleButton->currentItem())
1890
2732
    {
1901
2743
    }
1902
2744
}
1903
2745
 
1904
 
void CellLayoutPageMisc::applyLayout( KSpreadCell *_obj )
 
2746
void CellFormatPageMisc::applyFormat( KSpreadCell *_obj )
1905
2747
{
1906
2748
    if ( styleButton->currentItem() == idStyleNormal )
1907
2749
      _obj->setStyle( KSpreadCell::ST_Normal );
1911
2753
      _obj->setStyle( KSpreadCell::ST_Select );
1912
2754
    if ( actionText->isEnabled() )
1913
2755
      _obj->setAction( actionText->text() );
1914
 
    if( dlg->bDontprintText!=dontPrintText->isChecked())
 
2756
    if ( dlg->bDontPrintText!=dontPrintText->isChecked())
1915
2757
      _obj->setDontPrintText(dontPrintText->isChecked());
1916
2758
}
1917
2759
 
1918
 
void CellLayoutPageMisc::slotStyle( int _i )
 
2760
void CellFormatPageMisc::slotStyle( int _i )
1919
2761
{
1920
2762
  if ( dlg->isSingleCell() && _i != idStyleNormal && _i != idStyleUndef )
1921
2763
    actionText->setEnabled( true );
1924
2766
}
1925
2767
 
1926
2768
 
1927
 
CellLayoutPageFont::CellLayoutPageFont( QWidget* parent, CellLayoutDlg *_dlg ) : QWidget ( parent )
 
2769
CellFormatPageFont::CellFormatPageFont( QWidget* parent, CellFormatDlg *_dlg ) : QWidget ( parent )
1928
2770
{
1929
2771
  dlg = _dlg;
1930
2772
 
1934
2776
 
1935
2777
  box1 = new QGroupBox( this, "Box1");
1936
2778
  box1->setTitle(i18n("Requested Font"));
1937
 
  QGridLayout *grid2 = new QGridLayout(box1,6,3,15,7);
 
2779
  QGridLayout *grid2 = new QGridLayout(box1,7,3,KDialog::marginHint(), KDialog::spacingHint());
 
2780
  int fHeight = box1->fontMetrics().height();
 
2781
  grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
 
2782
 
1938
2783
  family_label = new QLabel(box1,"family");
1939
2784
  family_label->setText(i18n("Family:"));
1940
 
  grid2->addWidget(family_label,0,0);
 
2785
  grid2->addWidget(family_label,1,0);
1941
2786
 
1942
2787
  size_label = new QLabel(box1,"size");
1943
2788
  size_label->setText(i18n("Size:"));
1944
 
  grid2->addWidget(size_label,0,2);
 
2789
  grid2->addWidget(size_label,1,2);
1945
2790
 
1946
2791
  weight_label = new QLabel(box1,"weight");
1947
2792
  weight_label->setText(i18n("Weight:"));
1948
 
  grid2->addWidget(weight_label,2,1);
 
2793
  grid2->addWidget(weight_label,3,1);
1949
2794
 
1950
2795
  QLabel *tmpQLabel = new QLabel( box1, "Label_1" );
1951
 
  tmpQLabel->setText( i18n("Text Color") );
1952
 
  grid2->addWidget(tmpQLabel,4,1);
 
2796
  tmpQLabel->setText( i18n("Text color:") );
 
2797
  grid2->addWidget(tmpQLabel,5,1);
1953
2798
 
1954
2799
  textColorButton = new KColorButton( box1, "textColor" );
1955
 
  grid2->addWidget(textColorButton,5,1);
 
2800
  grid2->addWidget(textColorButton,6,1);
1956
2801
 
1957
2802
  connect( textColorButton, SIGNAL( changed( const QColor & ) ),
1958
2803
             this, SLOT( slotSetTextColor( const QColor & ) ) );
1961
2806
 
1962
2807
  style_label = new QLabel(box1,"style");
1963
2808
  style_label->setText(i18n("Style:"));
1964
 
  grid2->addWidget(style_label,0,1);
 
2809
  grid2->addWidget(style_label,1,1);
1965
2810
 
1966
2811
  family_combo = new QListBox( box1, "Family" );
1967
2812
 
1968
2813
  QStringList tmpListFont;
1969
2814
  QFontDatabase *fontDataBase = new QFontDatabase();
1970
2815
  tmpListFont = fontDataBase->families();
 
2816
  delete fontDataBase;
1971
2817
 
1972
2818
  listFont.setItems(tmpListFont);
1973
2819
 
1979
2825
        selFont.setFamily( dlg->textFontFamily );
1980
2826
        kdDebug(36001) << "Family = " << dlg->textFontFamily << endl;
1981
2827
 
1982
 
        if( !family_combo->findItem(dlg->textFontFamily))
 
2828
        if ( !family_combo->findItem(dlg->textFontFamily))
1983
2829
                {
1984
2830
                family_combo->insertItem("",0);
1985
2831
                family_combo->setCurrentItem(0);
1993
2839
        family_combo->setCurrentItem(0);
1994
2840
   }
1995
2841
 
1996
 
  grid2->addMultiCellWidget(family_combo,2,5,0,0);
 
2842
  grid2->addMultiCellWidget(family_combo,3,6,0,0);
1997
2843
 
1998
2844
  connect( family_combo, SIGNAL(highlighted(const QString &)),
1999
2845
           SLOT(family_chosen_slot(const QString &)) );
2000
2846
 
2001
2847
  searchFont=new KLineEdit(box1);
2002
 
  grid2->addWidget(searchFont,1,0);
 
2848
  grid2->addWidget(searchFont,2,0);
2003
2849
  searchFont->setCompletionMode(KGlobalSettings::CompletionAuto  );
2004
2850
  searchFont->setCompletionObject( &listFont,true );
2005
2851
 
2016
2862
 
2017
2863
 
2018
2864
  size_combo->setInsertionPolicy(QComboBox::NoInsertion);
2019
 
  grid2->addWidget(size_combo,1,2);
 
2865
  grid2->addWidget(size_combo,2,2);
2020
2866
  connect( size_combo, SIGNAL(activated(const QString &)),
2021
2867
           SLOT(size_chosen_slot(const QString &)) );
2022
2868
  connect( size_combo ,SIGNAL( textChanged(const QString &)),
2024
2870
 
2025
2871
  weight_combo = new QComboBox( box1, "Weight" );
2026
2872
  weight_combo->insertItem( "", 0 );
2027
 
  weight_combo->insertItem( i18n("normal") );
2028
 
  weight_combo->insertItem( i18n("bold") );
 
2873
  weight_combo->insertItem( i18n("Normal") );
 
2874
  weight_combo->insertItem( i18n("Bold") );
2029
2875
 
2030
2876
  weight_combo->setInsertionPolicy(QComboBox::NoInsertion);
2031
 
  grid2->addWidget(weight_combo,3,1);
 
2877
  grid2->addWidget(weight_combo,4,1);
2032
2878
  connect( weight_combo, SIGNAL(activated(const QString &)),
2033
2879
           SLOT(weight_chosen_slot(const QString &)) );
2034
2880
 
2035
2881
  style_combo = new QComboBox( box1, "Style" );
2036
2882
  style_combo->insertItem( "", 0 );
2037
 
  style_combo->insertItem( i18n("roman") );
2038
 
  style_combo->insertItem( i18n("italic"), 2 );
2039
 
  grid2->addWidget(style_combo,1,1);
 
2883
  style_combo->insertItem( i18n("Roman") );
 
2884
  style_combo->insertItem( i18n("Italic"), 2 );
 
2885
  grid2->addWidget(style_combo,2,1);
2040
2886
  style_combo->setInsertionPolicy(QComboBox::NoInsertion);
2041
2887
  connect( style_combo, SIGNAL(activated(const QString &)),
2042
2888
           SLOT(style_chosen_slot(const QString &)) );
2043
2889
 
2044
2890
  strike = new QCheckBox(i18n("Strike out"),box1);
2045
 
  grid2->addWidget(strike,5,2);
 
2891
  grid2->addWidget(strike,6,2);
2046
2892
  strike->setChecked(dlg->strike);
2047
2893
  connect( strike, SIGNAL( clicked()),
2048
2894
           SLOT(strike_chosen_slot()) );
2049
2895
 
2050
2896
  underline = new QCheckBox(i18n("Underline"),box1);
2051
 
  grid2->addWidget(underline,3,2);
 
2897
  grid2->addWidget(underline,4,2);
2052
2898
  underline->setChecked(dlg->underline);
2053
2899
  connect( underline, SIGNAL( clicked()),
2054
2900
           SLOT(underline_chosen_slot()) );
2058
2904
 
2059
2905
  box1 = new QGroupBox(this, "Box2");
2060
2906
  box1->setTitle(i18n("Actual Font"));
2061
 
  grid2 = new QGridLayout(box1,2,4,15,7);
 
2907
  grid2 = new QGridLayout(box1,4,5,KDialog::marginHint(), KDialog::spacingHint());
 
2908
  grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
2062
2909
 
2063
2910
  actual_family_label = new QLabel(box1,"afamily");
2064
2911
  actual_family_label->setText(i18n("Family:"));
2065
 
  grid2->addWidget(actual_family_label,0,0);
 
2912
  grid2->addWidget(actual_family_label,1,0);
2066
2913
 
2067
2914
  actual_family_label_data = new QLabel(box1,"afamilyd");
2068
 
  grid2->addWidget(actual_family_label_data,0,1);
 
2915
  grid2->addWidget(actual_family_label_data,1,1);
2069
2916
 
2070
2917
  actual_size_label = new QLabel(box1,"asize");
2071
2918
  actual_size_label->setText(i18n("Size:"));
2072
 
  grid2->addWidget(actual_size_label,1,0);
 
2919
  grid2->addWidget(actual_size_label,2,0);
2073
2920
 
2074
2921
  actual_size_label_data = new QLabel(box1,"asized");
2075
 
  grid2->addWidget(actual_size_label_data,1,1);
 
2922
  grid2->addWidget(actual_size_label_data,2,1);
2076
2923
 
2077
2924
  actual_weight_label = new QLabel(box1,"aweight");
2078
2925
  actual_weight_label->setText(i18n("Weight:"));
2079
 
  grid2->addWidget(actual_weight_label,2,0);
 
2926
  grid2->addWidget(actual_weight_label,3,0);
2080
2927
 
2081
2928
  actual_weight_label_data = new QLabel(box1,"aweightd");
2082
 
  grid2->addWidget(actual_weight_label_data,2,1);
 
2929
  grid2->addWidget(actual_weight_label_data,3,1);
2083
2930
 
2084
2931
  actual_style_label = new QLabel(box1,"astyle");
2085
2932
  actual_style_label->setText(i18n("Style:"));
2086
 
  grid2->addWidget(actual_style_label,3,0);
 
2933
  grid2->addWidget(actual_style_label,4,0);
2087
2934
 
2088
2935
  actual_style_label_data = new QLabel(box1,"astyled");
2089
 
  grid2->addWidget(actual_style_label_data,3,1);
 
2936
  grid2->addWidget(actual_style_label_data,4,1);
2090
2937
 
2091
2938
 
2092
2939
  example_label = new QLabel(box1,"examples");
2097
2944
  example_label->setLineWidth( 1 );
2098
2945
  example_label->setText(i18n("Dolor Ipse"));
2099
2946
  //  example_label->setAutoResize(true);
2100
 
  grid2->addMultiCellWidget(example_label,0,3,2,3);
 
2947
  grid2->addMultiCellWidget(example_label,1,4,2,3);
2101
2948
  connect(this,SIGNAL(fontSelected( const QFont&  )),
2102
2949
          this,SLOT(display_example( const QFont&)));
2103
2950
 
2109
2956
  this->resize( 400, 400 );
2110
2957
}
2111
2958
 
2112
 
void CellLayoutPageFont::slotSearchFont(const QString &_text)
2113
 
{
2114
 
QString result;
2115
 
result=listFont.makeCompletion( _text );
2116
 
if(!result.isNull())
2117
 
        family_combo->setCurrentItem(family_combo->index(family_combo->findItem(result)));
2118
 
}
2119
 
 
2120
 
 
2121
 
void CellLayoutPageFont::slotSetTextColor( const QColor &_color )
2122
 
{
2123
 
textColor=_color;
2124
 
bTextColorUndefined=false;
2125
 
}
2126
 
 
2127
 
void CellLayoutPageFont::apply( ColumnLayout *_obj)
2128
 
{
2129
 
  KSpreadCell*c= dlg->getTable()->firstCell();
2130
 
  for( ;c; c = c->nextCell() )
2131
 
      {
2132
 
        int col = c->column();
2133
 
        if ( dlg->left <= col && dlg->right >= col
2134
 
        &&!c->isObscuringForced())
2135
 
        {
2136
 
            if ( !bTextColorUndefined )
2137
 
                {
2138
 
                c->clearProperty(KSpreadCell::PTextPen);
2139
 
                c->clearNoFallBackProperties( KSpreadCell::PTextPen );
2140
 
                }
2141
 
           if(fontChanged)
2142
 
                {
2143
 
                c->clearProperty(KSpreadCell::PFont);
2144
 
                c->clearNoFallBackProperties( KSpreadCell::PFont );
2145
 
                }
2146
 
        }
2147
 
      }
2148
 
 
2149
 
      applyLayout(_obj);
2150
 
      RowLayout* rw =dlg->getTable()->firstRow();
2151
 
      for( ; rw; rw = rw->next() )
2152
 
        {
2153
 
        if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PFont) ))
2154
 
                {
2155
 
                for(int i=dlg->left;i<=dlg->right;i++)
2156
 
                        {
2157
 
                        KSpreadCell *cell = dlg->getTable()->cellAt( i,  rw->row());
2158
 
                        if ( cell->isDefault() )
2159
 
                                {
2160
 
                                cell = new KSpreadCell( dlg->getTable(), i,  rw->row() );
2161
 
                                dlg->getTable()->insertCell( cell );
2162
 
                                }
2163
 
                        applyLayout(cell );
2164
 
                        }
2165
 
                }
2166
 
        }
2167
 
 
2168
 
 
2169
 
}
2170
 
 
2171
 
void CellLayoutPageFont::apply( RowLayout *_obj)
2172
 
{
2173
 
  KSpreadCell*c= dlg->getTable()->firstCell();
2174
 
  for( ;c; c = c->nextCell() )
2175
 
      {
2176
 
        int row = c->row();
2177
 
        if ( dlg->top <= row && dlg->bottom >= row
2178
 
        &&!c->isObscuringForced())
2179
 
        {
2180
 
           if ( !bTextColorUndefined )
2181
 
                {
2182
 
                c->clearProperty(KSpreadCell::PTextPen);
2183
 
                c->clearNoFallBackProperties( KSpreadCell::PTextPen );
2184
 
                }
2185
 
           if(fontChanged)
2186
 
                {
2187
 
                c->clearProperty(KSpreadCell::PFont);
2188
 
                c->clearNoFallBackProperties( KSpreadCell::PFont );
2189
 
                }
2190
 
        }
2191
 
      }
2192
 
applyLayout(_obj);
2193
 
}
2194
 
 
2195
 
 
2196
 
void CellLayoutPageFont::apply( KSpreadCell *_obj )
2197
 
{
2198
 
applyLayout(_obj);
2199
 
}
2200
 
 
2201
 
void CellLayoutPageFont::applyLayout( KSpreadLayout *_obj )
2202
 
{
2203
 
    if ( !bTextColorUndefined )
2204
 
        _obj->setTextColor( textColor );
2205
 
    if(fontChanged)
2206
 
        {
2207
 
        if ( size_combo->currentItem() != 0 )
2208
 
                _obj->setTextFontSize( selFont.pointSize() );
2209
 
        if ( !family_combo->currentText().isEmpty() )
2210
 
                _obj->setTextFontFamily( selFont.family() );
2211
 
        if ( weight_combo->currentItem() != 0 )
2212
 
                _obj->setTextFontBold( selFont.bold() );
2213
 
        if ( style_combo->currentItem() != 0 )
2214
 
                _obj->setTextFontItalic( selFont.italic() );
2215
 
        _obj->setTextFontStrike( strike->isChecked() );
2216
 
        _obj->setTextFontUnderline(underline->isChecked() );
2217
 
        }
2218
 
}
2219
 
 
2220
 
void CellLayoutPageFont::underline_chosen_slot()
 
2959
void CellFormatPageFont::slotSearchFont(const QString &_text)
 
2960
{
 
2961
  QString result;
 
2962
  result = listFont.makeCompletion( _text );
 
2963
  if ( !result.isNull() )
 
2964
    family_combo->setCurrentItem( family_combo->index( family_combo->findItem( result ) ) );
 
2965
}
 
2966
 
 
2967
void CellFormatPageFont::slotSetTextColor( const QColor &_color )
 
2968
{
 
2969
  textColor = _color;
 
2970
  bTextColorUndefined = false;
 
2971
}
 
2972
 
 
2973
void CellFormatPageFont::apply( KSpreadCustomStyle * style )
 
2974
{
 
2975
  if ( !bTextColorUndefined && textColor != dlg->textColor )
 
2976
    style->changeTextColor( textColor );
 
2977
 
 
2978
  if ( ( size_combo->currentItem() != 0 )
 
2979
       && ( dlg->textFontSize != selFont.pointSize() ) )
 
2980
    style->changeFontSize( selFont.pointSize() );
 
2981
 
 
2982
  if ( ( selFont.family() != dlg->textFontFamily )
 
2983
       && !family_combo->currentText().isEmpty() )
 
2984
    style->changeFontFamily( selFont.family() );
 
2985
  
 
2986
  uint flags = 0;
 
2987
  
 
2988
  if ( weight_combo->currentItem() != 0 && selFont.bold() )
 
2989
    flags |= KSpreadStyle::FBold;
 
2990
  else
 
2991
    flags &= ~(uint) KSpreadStyle::FBold;
 
2992
  
 
2993
  if ( style_combo->currentItem() != 0 && selFont.italic() )
 
2994
    flags |= KSpreadStyle::FItalic;
 
2995
  else
 
2996
    flags &= ~(uint) KSpreadStyle::FItalic;
 
2997
  
 
2998
  if ( strike->isChecked() )
 
2999
    flags |= KSpreadStyle::FStrike;
 
3000
  else
 
3001
    flags &= ~(uint) KSpreadStyle::FStrike;
 
3002
  
 
3003
  if ( underline->isChecked() )
 
3004
    flags |= KSpreadStyle::FUnderline;
 
3005
  else
 
3006
    flags &= ~(uint) KSpreadStyle::FUnderline;
 
3007
 
 
3008
  style->changeFontFlags( flags );
 
3009
}
 
3010
 
 
3011
void CellFormatPageFont::apply( ColumnFormat *_obj)
 
3012
{
 
3013
  KSpreadSheet* table = dlg->getTable();
 
3014
  KSpreadCell* c= NULL;
 
3015
  for (int col = dlg->left; col <= dlg->right; col++)
 
3016
  {
 
3017
    for ( c = table->getFirstCellColumn(col); c != NULL;
 
3018
         c = table->getNextCellDown(c->column(), c->row()) )
 
3019
    {
 
3020
      if ( !bTextColorUndefined )
 
3021
      {
 
3022
        c->clearProperty(KSpreadCell::PTextPen);
 
3023
        c->clearNoFallBackProperties( KSpreadCell::PTextPen );
 
3024
      }
 
3025
      if (fontChanged)
 
3026
      {
 
3027
        c->clearProperty(KSpreadCell::PFont);
 
3028
        c->clearNoFallBackProperties( KSpreadCell::PFont );
 
3029
      }
 
3030
    }
 
3031
  }
 
3032
 
 
3033
  applyFormat(_obj);
 
3034
  RowFormat* rw =dlg->getTable()->firstRow();
 
3035
  for ( ; rw; rw = rw->next() )
 
3036
  {
 
3037
    if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PFont) ))
 
3038
    {
 
3039
      for ( int i=dlg->left;i<=dlg->right;i++)
 
3040
      {
 
3041
        KSpreadCell *cell = dlg->getTable()->nonDefaultCell( i, rw->row() );
 
3042
        applyFormat(cell );
 
3043
      }
 
3044
    }
 
3045
  }
 
3046
}
 
3047
 
 
3048
void CellFormatPageFont::apply( RowFormat *_obj)
 
3049
{
 
3050
  KSpreadSheet* table = dlg->getTable();
 
3051
  KSpreadCell* c= NULL;
 
3052
  for (int row = dlg->top; row <= dlg->bottom; row++)
 
3053
  {
 
3054
    for ( c = table->getFirstCellRow(row); c != NULL;
 
3055
         c = table->getNextCellRight(c->column(), c->row()) )
 
3056
    {
 
3057
      if ( !bTextColorUndefined )
 
3058
      {
 
3059
        c->clearProperty(KSpreadCell::PTextPen);
 
3060
        c->clearNoFallBackProperties( KSpreadCell::PTextPen );
 
3061
      }
 
3062
      if (fontChanged)
 
3063
      {
 
3064
        c->clearProperty(KSpreadCell::PFont);
 
3065
        c->clearNoFallBackProperties( KSpreadCell::PFont );
 
3066
      }
 
3067
    }
 
3068
  }
 
3069
  applyFormat(_obj);
 
3070
}
 
3071
 
 
3072
 
 
3073
void CellFormatPageFont::apply( KSpreadCell *_obj )
 
3074
{
 
3075
  applyFormat(_obj);
 
3076
}
 
3077
 
 
3078
void CellFormatPageFont::applyFormat( KSpreadFormat *_obj )
 
3079
{
 
3080
  if ( !bTextColorUndefined && textColor != dlg->textColor )
 
3081
    _obj->setTextColor( textColor );
 
3082
  if (fontChanged)
 
3083
  {
 
3084
    if ( ( size_combo->currentItem() != 0 )
 
3085
         && ( dlg->textFontSize != selFont.pointSize() ) )
 
3086
      _obj->setTextFontSize( selFont.pointSize() );
 
3087
    if ( ( selFont.family() != dlg->textFontFamily ) && ( !family_combo->currentText().isEmpty() ) )
 
3088
      _obj->setTextFontFamily( selFont.family() );
 
3089
    if ( weight_combo->currentItem() != 0 )
 
3090
      _obj->setTextFontBold( selFont.bold() );
 
3091
    if ( style_combo->currentItem() != 0 )
 
3092
      _obj->setTextFontItalic( selFont.italic() );
 
3093
    _obj->setTextFontStrike( strike->isChecked() );
 
3094
    _obj->setTextFontUnderline(underline->isChecked() );
 
3095
  }
 
3096
}
 
3097
 
 
3098
void CellFormatPageFont::underline_chosen_slot()
2221
3099
{
2222
3100
   selFont.setUnderline( underline->isChecked() );
2223
3101
   emit fontSelected(selFont);
2224
3102
}
2225
3103
 
2226
 
void CellLayoutPageFont::strike_chosen_slot()
 
3104
void CellFormatPageFont::strike_chosen_slot()
2227
3105
{
2228
3106
   selFont.setStrikeOut( strike->isChecked() );
2229
3107
   emit fontSelected(selFont);
2230
3108
}
2231
3109
 
2232
 
void CellLayoutPageFont::family_chosen_slot(const QString & family)
 
3110
void CellFormatPageFont::family_chosen_slot(const QString & family)
2233
3111
{
2234
3112
  selFont.setFamily(family);
2235
3113
  emit fontSelected(selFont);
2236
3114
}
2237
3115
 
2238
 
void CellLayoutPageFont::size_chosen_slot(const QString & size)
 
3116
void CellFormatPageFont::size_chosen_slot(const QString & size)
2239
3117
{
2240
3118
  QString size_string = size;
2241
3119
 
2243
3121
  emit fontSelected(selFont);
2244
3122
}
2245
3123
 
2246
 
void CellLayoutPageFont::weight_chosen_slot(const QString & weight)
 
3124
void CellFormatPageFont::weight_chosen_slot(const QString & weight)
2247
3125
{
2248
3126
  QString weight_string = weight;
2249
3127
 
2250
 
  if ( weight_string == QString(i18n("normal")))
 
3128
  if ( weight_string == QString(i18n("Normal")))
2251
3129
    selFont.setBold(false);
2252
 
  if ( weight_string == QString(i18n("bold")))
2253
 
       selFont.setBold(true);
 
3130
  if ( weight_string == QString(i18n("Bold")))
 
3131
    selFont.setBold(true);
2254
3132
  emit fontSelected(selFont);
2255
3133
}
2256
3134
 
2257
 
void CellLayoutPageFont::style_chosen_slot(const QString & style)
 
3135
void CellFormatPageFont::style_chosen_slot(const QString & style)
2258
3136
{
2259
3137
  QString style_string = style;
2260
3138
 
2261
 
  if ( style_string == QString(i18n("roman")))
 
3139
  if ( style_string == QString(i18n("Roman")))
2262
3140
    selFont.setItalic(false);
2263
 
  if ( style_string == QString(i18n("italic")))
 
3141
  if ( style_string == QString(i18n("Italic")))
2264
3142
    selFont.setItalic(true);
2265
3143
  emit fontSelected(selFont);
2266
3144
}
2267
3145
 
2268
3146
 
2269
 
void CellLayoutPageFont::display_example(const QFont& font)
 
3147
void CellFormatPageFont::display_example(const QFont& font)
2270
3148
{
2271
3149
  QString string;
2272
3150
  fontChanged=true;
2289
3167
    actual_weight_label_data->setText(i18n("Normal"));
2290
3168
 
2291
3169
  if (info.italic())
2292
 
    actual_style_label_data->setText(i18n("italic"));
 
3170
    actual_style_label_data->setText(i18n("Italic"));
2293
3171
  else
2294
 
    actual_style_label_data->setText(i18n("roman"));
 
3172
    actual_style_label_data->setText(i18n("Roman"));
2295
3173
}
2296
3174
 
2297
 
void CellLayoutPageFont::setCombos()
 
3175
void CellFormatPageFont::setCombos()
2298
3176
{
2299
3177
 QString string;
2300
3178
 QComboBox* combo;
2302
3180
 bool found;
2303
3181
 
2304
3182
 if ( dlg->bTextColor )
2305
 
        textColor = dlg->textColor;
 
3183
   textColor = dlg->textColor;
2306
3184
 else
2307
 
        textColor = colorGroup().text();
2308
 
 
2309
 
 if(!textColor.isValid())
2310
 
     textColor =colorGroup().text();
2311
 
 
 
3185
   textColor = colorGroup().text();
 
3186
 
 
3187
 if ( !textColor.isValid() )
 
3188
   textColor =colorGroup().text();
 
3189
 
2312
3190
 textColorButton->setColor( textColor );
2313
3191
 
2314
3192
 
2360
3238
 }
2361
3239
}
2362
3240
 
2363
 
CellLayoutPagePosition::CellLayoutPagePosition( QWidget* parent, CellLayoutDlg *_dlg ) : QWidget( parent )
 
3241
CellFormatPagePosition::CellFormatPagePosition( QWidget* parent, CellFormatDlg *_dlg ) 
 
3242
  : QWidget( parent ),
 
3243
    dlg( _dlg )
2364
3244
{
2365
 
    dlg = _dlg;
2366
 
 
2367
 
    QGridLayout *grid3 = new QGridLayout(this,4,2,15,7);
2368
 
    QButtonGroup *grp = new QButtonGroup( i18n("Horizontal"),this);
2369
 
    grp->setRadioButtonExclusive( TRUE );
2370
 
 
2371
 
    QGridLayout *grid2 = new QGridLayout(grp,3,2,15,7);
 
3245
    QGridLayout *grid3 = new QGridLayout(this, 4, 2, KDialog::marginHint(), KDialog::spacingHint());
 
3246
    QButtonGroup *grp = new QButtonGroup( i18n("Horizontal"), this);
 
3247
    grp->setRadioButtonExclusive( true );
 
3248
 
 
3249
    QGridLayout *grid2 = new QGridLayout(grp, 4, 2, KDialog::marginHint(), KDialog::spacingHint());
 
3250
    int fHeight = grp->fontMetrics().height();
 
3251
    grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
2372
3252
    standard = new QRadioButton( i18n("Standard"), grp );
2373
 
    grid2->addWidget(standard,1,0);
 
3253
    grid2->addWidget(standard, 2, 0);
2374
3254
    left = new QRadioButton( i18n("Left"), grp );
2375
 
    grid2->addWidget(left,0,1);
 
3255
    grid2->addWidget(left, 1, 1);
2376
3256
    center = new QRadioButton( i18n("Center"), grp );
2377
 
    grid2->addWidget(center,1,1);
 
3257
    grid2->addWidget(center, 2, 1);
2378
3258
    right = new QRadioButton( i18n("Right"), grp );
2379
 
    grid2->addWidget(right,2,1);
2380
 
    grid3->addWidget(grp,0,0);
2381
 
 
2382
 
    if(dlg->alignX==KSpreadCell::Left)
2383
 
        left->setChecked(true);
2384
 
    else if(dlg->alignX==KSpreadCell::Center)
2385
 
        center->setChecked(true);
2386
 
    else if(dlg->alignX==KSpreadCell::Right)
2387
 
        right->setChecked(true);
2388
 
    else if( dlg->alignX==KSpreadCell::Undefined)
2389
 
        standard->setChecked(true);
2390
 
 
2391
 
    connect(grp, SIGNAL(clicked(int)),this,SLOT(slotStateChanged(int)));
2392
 
 
2393
 
    grp = new QButtonGroup( i18n("Vertical"),this);
2394
 
    grp->setRadioButtonExclusive( TRUE );
2395
 
 
2396
 
    grid2 = new QGridLayout(grp,3,1,15,7);
 
3259
    grid2->addWidget(right, 3, 1);
 
3260
    grid3->addWidget(grp, 0, 0);
 
3261
 
 
3262
    if ( dlg->alignX == KSpreadCell::Left )
 
3263
        left->setChecked( true );
 
3264
    else if ( dlg->alignX == KSpreadCell::Center )
 
3265
        center->setChecked( true );
 
3266
    else if ( dlg->alignX == KSpreadCell::Right )
 
3267
        right->setChecked( true );
 
3268
    else if ( dlg->alignX == KSpreadCell::Undefined )
 
3269
        standard->setChecked( true );
 
3270
 
 
3271
    connect(grp,  SIGNAL(clicked(int)), this, SLOT(slotStateChanged(int)));
 
3272
 
 
3273
    grp = new QButtonGroup( i18n("Vertical"), this);
 
3274
    grp->setRadioButtonExclusive( true );
 
3275
 
 
3276
    grid2 = new QGridLayout(grp, 4, 1, KDialog::marginHint(), KDialog::spacingHint());
 
3277
    fHeight = grp->fontMetrics().height();
 
3278
    grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
2397
3279
    top = new QRadioButton( i18n("Top"), grp );
2398
 
    grid2->addWidget(top,0,0);
 
3280
    grid2->addWidget(top, 1, 0);
2399
3281
    middle = new QRadioButton( i18n("Middle"), grp );
2400
 
    grid2->addWidget(middle,1,0);
 
3282
    grid2->addWidget(middle, 2, 0);
2401
3283
    bottom = new QRadioButton( i18n("Bottom"), grp );
2402
 
    grid2->addWidget(bottom,2,0);
2403
 
    grid3->addWidget(grp,0,1);
2404
 
 
2405
 
    if(dlg->alignY==KSpreadCell::Top)
2406
 
        top->setChecked(true);
2407
 
    else if(dlg->alignY==KSpreadCell::Middle)
2408
 
        middle->setChecked(true);
2409
 
    else if(dlg->alignY==KSpreadCell::Bottom)
2410
 
        bottom->setChecked(true);
2411
 
 
2412
 
    grp = new QButtonGroup( i18n("Text option"),this);
 
3284
    grid2->addWidget(bottom, 3, 0);
 
3285
    grid3->addWidget(grp, 0, 1);
 
3286
 
 
3287
    if ( dlg->alignY ==KSpreadCell::Top )
 
3288
        top->setChecked( true );
 
3289
    else if ( dlg->alignY ==KSpreadCell::Middle )
 
3290
        middle->setChecked(true );
 
3291
    else if ( dlg->alignY ==KSpreadCell::Bottom )
 
3292
        bottom->setChecked( true );
 
3293
 
 
3294
    grp = new QButtonGroup( i18n("Text Option"), this);
2413
3295
    //grp->setRadioButtonExclusive( false );
2414
 
    grid2 = new QGridLayout(grp,2,1,15,7);
2415
 
    multi = new QCheckBox( i18n("Go to line automatically"),grp);
 
3296
    grid2 = new QGridLayout(grp, 3, 1, KDialog::marginHint(), KDialog::spacingHint());
 
3297
    fHeight = grp->fontMetrics().height();
 
3298
    grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
 
3299
    multi = new QCheckBox( i18n("Wrap text"), grp);
2416
3300
 
2417
 
    grid2->addWidget(multi,0,0);
 
3301
    grid2->addWidget(multi, 1, 0);
2418
3302
    multi->setChecked(dlg->bMultiRow);
2419
3303
 
2420
 
    vertical = new QCheckBox( i18n("Vertical text"),grp);
2421
 
    grid2->addWidget(vertical,1,0);
 
3304
    vertical = new QCheckBox( i18n("Vertical text"), grp);
 
3305
    grid2->addWidget(vertical, 2, 0);
2422
3306
    vertical->setChecked(dlg->bVerticalText);
2423
3307
 
2424
 
    grid3->addWidget(grp,1,0);
2425
 
 
2426
 
    grp = new QButtonGroup( i18n("Rotation"),this);
2427
 
 
2428
 
    grid2 = new QGridLayout(grp,1,1,15,7);
 
3308
    grid3->addWidget(grp, 1, 0);
 
3309
 
 
3310
    grp = new QButtonGroup(i18n("Rotation"), this);
 
3311
 
 
3312
    grid2 = new QGridLayout(grp, 2, 1, KDialog::marginHint(), KDialog::spacingHint());
 
3313
    fHeight = grp->fontMetrics().height();
 
3314
    grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
2429
3315
    angleRotation=new KIntNumInput((-dlg->textRotation), grp, 10);
2430
3316
    angleRotation->setLabel(i18n("Angle:"));
2431
3317
    angleRotation->setRange(-90, 90, 1);
2432
3318
    angleRotation->setSuffix(" �");
2433
3319
 
2434
 
    grid2->addWidget(angleRotation,0,0);
2435
 
    grid3->addWidget(grp,1,1);
2436
 
    if(dlg->textRotation!=0)
2437
 
      {
2438
 
        multi->setEnabled(false);
 
3320
    grid2->addWidget(angleRotation, 1, 0);
 
3321
    grid3->addWidget(grp, 1, 1);
 
3322
    if ( dlg->textRotation != 0 )
 
3323
    {
 
3324
        multi->setEnabled(false );
2439
3325
        vertical->setEnabled(false);
2440
 
      }
2441
 
 
2442
 
    grp = new QButtonGroup( i18n("Merge cells"),this);
2443
 
    grid2 = new QGridLayout(grp,1,1,15,7);
2444
 
    mergeCell=new QCheckBox(i18n("Merge cells"),grp);
 
3326
    }
 
3327
 
 
3328
    grp = new QButtonGroup( i18n("Merge Cells"), this);
 
3329
    grid2 = new QGridLayout(grp, 2, 1, KDialog::marginHint(), KDialog::spacingHint());
 
3330
 
 
3331
    fHeight = grp->fontMetrics().height();
 
3332
    grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
 
3333
 
 
3334
    mergeCell=new QCheckBox(i18n("Merge cells"), grp);
2445
3335
    mergeCell->setChecked(dlg->isMerged);
2446
 
    mergeCell->setEnabled(!dlg->oneCell &&  (dlg->right!=0x7FFF&& dlg->bottom!=0x7FFF));
2447
 
    grid2->addWidget(mergeCell,0,0);
2448
 
    grid3->addWidget(grp,2,0);
2449
 
 
2450
 
    grp = new QButtonGroup( i18n("Indent"),this);
2451
 
    grid2 = new QGridLayout(grp,1,1,15,7);
2452
 
    indent=new KIntNumInput(dlg->indent, grp, 10);
2453
 
    indent->setRange(0, 400, 10);
2454
 
    indent->setSuffix(i18n(" pt"));
2455
 
    grid2->addWidget(indent,0,0);
2456
 
    grid3->addWidget(grp,2,1);
2457
 
 
2458
 
    grp = new QButtonGroup( i18n("Size of cell"),this);
2459
 
    grid2 = new QGridLayout(grp,2,4,15,7);
2460
 
 
2461
 
    QLabel *tmpLabel=new QLabel(grp,"label");
 
3336
    mergeCell->setEnabled(!dlg->oneCell && ((!dlg->isRowSelected) && (!dlg->isColumnSelected)));
 
3337
    grid2->addWidget(mergeCell, 1, 0);
 
3338
    grid3->addWidget(grp, 2, 0);
 
3339
 
 
3340
    grp = new QButtonGroup( i18n("Indent"), this);
 
3341
    grid2 = new QGridLayout(grp, 2, 1, KDialog::marginHint(), KDialog::spacingHint());
 
3342
    fHeight = grp->fontMetrics().height();
 
3343
    grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
 
3344
 
 
3345
    indent = new KDoubleNumInput( grp );
 
3346
    indent->setRange( KoUnit::ptToUnit( 0.0, dlg->getDoc()->getUnit() ),
 
3347
                      KoUnit::ptToUnit( 400.0, dlg->getDoc()->getUnit() ),
 
3348
                      KoUnit::ptToUnit( 10.0, dlg->getDoc()->getUnit()) );
 
3349
    indent->setValue ( KoUnit::ptToUnit( dlg->indent, dlg->getDoc()->getUnit() ) );
 
3350
    grid2->addWidget(indent, 1, 0);
 
3351
    grid3->addWidget(grp, 2, 1);
 
3352
 
 
3353
    grp = new QButtonGroup( i18n("Size of Cell"), this);
 
3354
    grid2 = new QGridLayout(grp, 3, 4, KDialog::marginHint(), KDialog::spacingHint());
 
3355
    fHeight = grp->fontMetrics().height();
 
3356
    grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
 
3357
 
 
3358
    QLabel *tmpLabel=new QLabel(grp, "label");
2462
3359
    tmpLabel->setText(i18n("Width:"));
2463
 
    grid2->addWidget(tmpLabel,0,0);
2464
 
 
2465
 
    width=new KIntNumInput(dlg->widthSize, grp, 10);
2466
 
    if(dlg->right==0x7FFF && (dlg->right!=dlg->left))
 
3360
    grid2->addWidget(tmpLabel, 1, 0);
 
3361
 
 
3362
    width = new KDoubleNumInput( grp );
 
3363
    width->setPrecision ( 2 );
 
3364
    width->setValue ( KoUnit::ptToUnit( dlg->widthSize, dlg->getDoc()->getUnit() ) );
 
3365
    //to ensure, that we don't get rounding problems, we store the displayed value (for later check for changes)
 
3366
    dlg->widthSize = KoUnit::ptFromUnit( width->value(), dlg->getDoc()->getUnit() );
 
3367
 
 
3368
    if ( dlg->isRowSelected )
2467
3369
        width->setEnabled(false);
2468
 
    width->setRange(2, 400, 1);
2469
3370
 
2470
 
    grid2->addWidget(width,0,1);
2471
 
    defaultWidth=new QCheckBox(i18n("Default width (60)"),grp);
2472
 
    if(dlg->right==0x7FFF && (dlg->right!=dlg->left))
 
3371
    grid2->addWidget(width, 1, 1);
 
3372
    defaultWidth=new QCheckBox(i18n("Default width (%1 %2)").arg(KoUnit::ptToUnit( 60, dlg->getDoc()->getUnit())).arg(dlg->getDoc()->getUnitName()), grp);
 
3373
    if ( dlg->isRowSelected )
2473
3374
        defaultWidth->setEnabled(false);
2474
3375
 
2475
 
    grid2->addMultiCellWidget(defaultWidth,1,1,0,1);
 
3376
    grid2->addMultiCellWidget(defaultWidth, 2, 2, 0, 1);
2476
3377
 
2477
 
    tmpLabel=new QLabel(grp,"label1");
 
3378
    tmpLabel=new QLabel(grp, "label1");
2478
3379
    tmpLabel->setText(i18n("Height:"));
2479
 
    grid2->addWidget(tmpLabel,0,2);
2480
 
 
2481
 
    height=new KIntNumInput(dlg->heigthSize, grp, 10);
2482
 
    if(dlg->bottom==0x7FFF && (dlg->bottom!=dlg->top))
 
3380
    grid2->addWidget(tmpLabel, 1, 2);
 
3381
 
 
3382
    height=new KDoubleNumInput( grp );
 
3383
    height->setPrecision( 2 );
 
3384
    height->setValue( KoUnit::ptToUnit( dlg->heightSize, dlg->getDoc()->getUnit() ) );
 
3385
    //to ensure, that we don't get rounding problems, we store the displayed value (for later check for changes)
 
3386
    dlg->heightSize = KoUnit::ptFromUnit( height->value(), dlg->getDoc()->getUnit() );
 
3387
 
 
3388
    if ( dlg->isColumnSelected )
2483
3389
        height->setEnabled(false);
2484
3390
 
2485
 
    height->setRange(2, 400, 1);
2486
 
    grid2->addWidget(height,0,3);
 
3391
    grid2->addWidget(height, 1, 3);
2487
3392
 
2488
 
    defaultHeight=new QCheckBox(i18n("Default height (20)"),grp);
2489
 
    if(dlg->bottom==0x7FFF && (dlg->bottom!=dlg->top))
 
3393
    defaultHeight=new QCheckBox(i18n("Default height (%1 %2)").arg(KoUnit::ptToUnit(  20 , dlg->getDoc()->getUnit())).arg(dlg->getDoc()->getUnitName()), grp);
 
3394
    if ( dlg->isColumnSelected )
2490
3395
        defaultHeight->setEnabled(false);
2491
3396
 
2492
 
    grid2->addMultiCellWidget(defaultHeight,1,1,2,3);
 
3397
    grid2->addMultiCellWidget(defaultHeight, 2, 2, 2, 3);
2493
3398
 
2494
 
    grid3->addMultiCellWidget(grp,3,3,0,1);
 
3399
    grid3->addMultiCellWidget(grp, 3, 3, 0, 1);
2495
3400
 
2496
3401
    connect(defaultWidth , SIGNAL(clicked() ),this, SLOT(slotChangeWidthState()));
2497
3402
    connect(defaultHeight , SIGNAL(clicked() ),this, SLOT(slotChangeHeightState()));
2498
3403
    connect(vertical , SIGNAL(clicked() ),this, SLOT(slotChangeVerticalState()));
2499
 
    connect(multi , SIGNAL(clicked() ),this, SLOT(slotChangeMultiState()));
2500
 
    connect(angleRotation, SIGNAL(valueChanged(int)),this,SLOT(slotChangeAngle(int)));
2501
 
    slotStateChanged(0);
2502
 
    m_bOptionText=false;
 
3404
    connect(multi , SIGNAL(clicked() ), this, SLOT(slotChangeMultiState()));
 
3405
    connect(angleRotation, SIGNAL(valueChanged(int)), this, SLOT(slotChangeAngle(int)));
 
3406
 
 
3407
    slotStateChanged( 0 );
 
3408
    m_bOptionText = false;
2503
3409
    this->resize( 400, 400 );
2504
3410
}
2505
3411
 
2506
 
void CellLayoutPagePosition::slotChangeMultiState()
 
3412
void CellFormatPagePosition::slotChangeMultiState()
2507
3413
{
2508
 
m_bOptionText=true;
2509
 
if(vertical->isChecked())
2510
 
        {
 
3414
    m_bOptionText = true;
 
3415
    if (vertical->isChecked())
 
3416
    {
2511
3417
        vertical->setChecked(false);
2512
 
        }
 
3418
    }
2513
3419
}
2514
3420
 
2515
 
void CellLayoutPagePosition::slotChangeVerticalState()
 
3421
void CellFormatPagePosition::slotChangeVerticalState()
2516
3422
{
2517
 
m_bOptionText=true;
2518
 
if(multi->isChecked())
2519
 
        {
 
3423
    m_bOptionText=true;
 
3424
    if (multi->isChecked())
 
3425
    {
2520
3426
        multi->setChecked(false);
2521
 
        }
 
3427
    }
2522
3428
 
2523
3429
}
2524
3430
 
2525
 
void CellLayoutPagePosition::slotStateChanged(int)
 
3431
void CellFormatPagePosition::slotStateChanged(int)
2526
3432
{
2527
 
if(right->isChecked() || center->isChecked())
 
3433
    if (right->isChecked() || center->isChecked())
2528
3434
        indent->setEnabled(false);
2529
 
else
 
3435
    else
2530
3436
        indent->setEnabled(true);
2531
3437
 
2532
3438
}
2533
 
bool CellLayoutPagePosition::getMergedCellState()
 
3439
bool CellFormatPagePosition::getMergedCellState()
2534
3440
{
2535
3441
    return  mergeCell->isChecked();
2536
3442
}
2537
3443
 
2538
 
void CellLayoutPagePosition::slotChangeWidthState()
 
3444
void CellFormatPagePosition::slotChangeWidthState()
2539
3445
{
2540
 
    if( defaultWidth->isChecked())
 
3446
    if ( defaultWidth->isChecked())
2541
3447
        width->setEnabled(false);
2542
3448
    else
2543
3449
        width->setEnabled(true);
2544
3450
}
2545
3451
 
2546
 
void CellLayoutPagePosition::slotChangeHeightState()
 
3452
void CellFormatPagePosition::slotChangeHeightState()
2547
3453
{
2548
 
    if( defaultHeight->isChecked())
 
3454
    if ( defaultHeight->isChecked())
2549
3455
        height->setEnabled(false);
2550
3456
    else
2551
3457
        height->setEnabled(true);
2552
3458
}
2553
3459
 
2554
 
void CellLayoutPagePosition::slotChangeAngle(int _angle)
2555
 
{
2556
 
if(_angle==0)
2557
 
    {
2558
 
    multi->setEnabled(true);
2559
 
    vertical->setEnabled(true);
2560
 
    }
2561
 
else
2562
 
    {
2563
 
    multi->setEnabled(false);
2564
 
    vertical->setEnabled(false);
2565
 
    }
2566
 
}
2567
 
 
2568
 
void CellLayoutPagePosition::apply( ColumnLayout *_obj )
2569
 
{
2570
 
  KSpreadCell*c= dlg->getTable()->firstCell();
2571
 
  for( ;c; c = c->nextCell() )
2572
 
      {
2573
 
        int col = c->column();
2574
 
        if ( dlg->left <= col && dlg->right >= col
2575
 
        &&!c->isObscuringForced())
2576
 
        {
2577
 
           if(dlg->indent!=indent->value() && indent->isEnabled())
2578
 
                {
2579
 
                c->clearProperty(KSpreadCell::PIndent);
2580
 
                c->clearNoFallBackProperties( KSpreadCell::PIndent );
2581
 
                }
2582
 
           c->clearProperty(KSpreadCell::PAlign);
2583
 
           c->clearNoFallBackProperties( KSpreadCell::PAlign );
2584
 
           c->clearProperty(KSpreadCell::PAlignY);
2585
 
           c->clearNoFallBackProperties( KSpreadCell::PAlignY );
2586
 
           if( m_bOptionText)
2587
 
                {
2588
 
                c->clearProperty(KSpreadCell::PMultiRow);
2589
 
                c->clearNoFallBackProperties( KSpreadCell::PMultiRow );
2590
 
                }
2591
 
 
2592
 
           if( m_bOptionText)
2593
 
                {
2594
 
                c->clearProperty(KSpreadCell::PVerticalText);
2595
 
                c->clearNoFallBackProperties( KSpreadCell::PVerticalText );
2596
 
                }
2597
 
 
2598
 
           if(dlg->textRotation!=angleRotation->value())
2599
 
                {
2600
 
                c->clearProperty(KSpreadCell::PAngle);
2601
 
                c->clearNoFallBackProperties( KSpreadCell::PAngle );
2602
 
                }
2603
 
        }
2604
 
      }
2605
 
      applyLayout(_obj);
2606
 
 
2607
 
      RowLayout* rw =dlg->getTable()->firstRow();
2608
 
      for( ; rw; rw = rw->next() )
2609
 
        {
2610
 
        if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PAngle) || rw->hasProperty(KSpreadCell::PVerticalText)
2611
 
        || rw->hasProperty(KSpreadCell::PMultiRow) || rw->hasProperty(KSpreadCell::PAlignY)
2612
 
        || rw->hasProperty(KSpreadCell::PAlign) || rw->hasProperty(KSpreadCell::PIndent) ))
2613
 
                {
2614
 
                for(int i=dlg->left;i<=dlg->right;i++)
2615
 
                        {
2616
 
                        KSpreadCell *cell = dlg->getTable()->cellAt( i,  rw->row());
2617
 
                        if ( cell->isDefault() )
2618
 
                                {
2619
 
                                cell = new KSpreadCell( dlg->getTable(), i,  rw->row() );
2620
 
                                dlg->getTable()->insertCell( cell);
2621
 
                                }
2622
 
                        applyLayout(cell );
2623
 
                        }
2624
 
                }
2625
 
        }
2626
 
 
2627
 
}
2628
 
 
2629
 
void CellLayoutPagePosition::apply( RowLayout *_obj )
2630
 
{
2631
 
  KSpreadCell*c= dlg->getTable()->firstCell();
2632
 
  for( ;c; c = c->nextCell() )
2633
 
      {
2634
 
        int row = c->row();
2635
 
        if ( dlg->top <= row && dlg->bottom >= row
2636
 
        &&!c->isObscuringForced())
2637
 
        {
2638
 
           if(dlg->indent!=indent->value() && indent->isEnabled())
2639
 
                {
2640
 
                c->clearProperty(KSpreadCell::PIndent);
2641
 
                c->clearNoFallBackProperties( KSpreadCell::PIndent );
2642
 
                }
2643
 
           c->clearProperty(KSpreadCell::PAlign);
2644
 
           c->clearNoFallBackProperties( KSpreadCell::PAlign );
2645
 
           c->clearProperty(KSpreadCell::PAlignY);
2646
 
           c->clearNoFallBackProperties( KSpreadCell::PAlignY );
2647
 
 
2648
 
           if( m_bOptionText)
2649
 
                {
2650
 
                c->clearProperty(KSpreadCell::PMultiRow);
2651
 
                c->clearNoFallBackProperties( KSpreadCell::PMultiRow );
2652
 
                }
2653
 
           if( m_bOptionText)
2654
 
                {
2655
 
                c->clearProperty(KSpreadCell::PVerticalText);
2656
 
                c->clearNoFallBackProperties( KSpreadCell::PVerticalText );
2657
 
                }
2658
 
           if(dlg->textRotation!=angleRotation->value())
2659
 
                {
2660
 
                c->clearProperty(KSpreadCell::PAngle);
2661
 
                c->clearNoFallBackProperties( KSpreadCell::PAngle );
2662
 
                }
2663
 
        }
2664
 
      }
2665
 
      applyLayout(_obj);
2666
 
}
2667
 
 
2668
 
 
2669
 
void CellLayoutPagePosition::apply( KSpreadCell *_obj )
2670
 
{
2671
 
applyLayout(_obj);
2672
 
}
2673
 
 
2674
 
void CellLayoutPagePosition::applyLayout( KSpreadLayout *_obj )
2675
 
{
2676
 
  if(top->isChecked())
2677
 
    _obj->setAlignY(KSpreadCell::Top);
2678
 
  else if(bottom->isChecked())
2679
 
    _obj->setAlignY(KSpreadCell::Bottom);
2680
 
  else if(middle->isChecked())
2681
 
    _obj->setAlignY(KSpreadCell::Middle);
2682
 
 
2683
 
  if(left->isChecked())
2684
 
    _obj->setAlign(KSpreadCell::Left);
2685
 
  else if(right->isChecked())
2686
 
    _obj->setAlign(KSpreadCell::Right);
2687
 
  else if(center->isChecked())
2688
 
    _obj->setAlign(KSpreadCell::Center);
2689
 
  else if( standard->isChecked())
2690
 
    _obj->setAlign(KSpreadCell::Undefined);
2691
 
 
2692
 
  if( m_bOptionText )
2693
 
        {
2694
 
        if(multi->isEnabled())
2695
 
                _obj->setMultiRow(multi->isChecked());
2696
 
        else
2697
 
                _obj->setMultiRow(false);
2698
 
        }
2699
 
 
2700
 
  if(m_bOptionText )
2701
 
        {
2702
 
        if(vertical->isEnabled())
2703
 
                _obj->setVerticalText(vertical->isChecked());
2704
 
        else
2705
 
                _obj->setVerticalText(false);
2706
 
        }
2707
 
 
2708
 
  if(dlg->textRotation!=angleRotation->value())
2709
 
        _obj->setAngle((-angleRotation->value()));
2710
 
  if(dlg->indent!=indent->value() && indent->isEnabled())
2711
 
        _obj->setIndent(indent->value());
2712
 
}
2713
 
 
2714
 
int CellLayoutPagePosition::getSizeHeight()
2715
 
{
2716
 
  if(defaultHeight->isChecked())
2717
 
        return 20;
2718
 
  else
2719
 
        return height->value();
2720
 
}
2721
 
 
2722
 
int CellLayoutPagePosition::getSizeWidth()
2723
 
{
2724
 
  if(defaultWidth->isChecked())
2725
 
        return 60;
2726
 
  else
2727
 
        return width->value();
 
3460
void CellFormatPagePosition::slotChangeAngle(int _angle)
 
3461
{
 
3462
  if ( _angle == 0 )
 
3463
  {
 
3464
    multi->setEnabled( true );
 
3465
    vertical->setEnabled( true );
 
3466
  }
 
3467
  else
 
3468
  {
 
3469
    multi->setEnabled( false );
 
3470
    vertical->setEnabled( false );
 
3471
  }
 
3472
}
 
3473
 
 
3474
void CellFormatPagePosition::apply( KSpreadCustomStyle * style )
 
3475
{
 
3476
  if ( top->isChecked() && dlg->alignY != KSpreadCell::Top )
 
3477
    style->changeAlignY( KSpreadCell::Top );
 
3478
  else if ( bottom->isChecked() && dlg->alignY != KSpreadCell::Bottom )
 
3479
    style->changeAlignY( KSpreadCell::Bottom );
 
3480
  else if ( middle->isChecked() && dlg->alignY != KSpreadCell::Middle )
 
3481
    style->changeAlignY( KSpreadCell::Middle );
 
3482
 
 
3483
  if ( left->isChecked() && dlg->alignX != KSpreadCell::Left )
 
3484
    style->changeAlignX( KSpreadCell::Left );
 
3485
  else if ( right->isChecked() && dlg->alignX != KSpreadCell::Right )
 
3486
    style->changeAlignX( KSpreadCell::Right );
 
3487
  else if ( center->isChecked() && dlg->alignX != KSpreadCell::Center )
 
3488
    style->changeAlignX( KSpreadCell::Center );
 
3489
  else if ( standard->isChecked() && dlg->alignX != KSpreadCell::Undefined )
 
3490
    style->changeAlignX( KSpreadCell::Undefined );
 
3491
 
 
3492
  if ( m_bOptionText )
 
3493
  {
 
3494
    if ( multi->isEnabled() )
 
3495
    { 
 
3496
      if ( multi->isChecked() )
 
3497
        style->addProperty( KSpreadStyle::PMultiRow );
 
3498
      else
 
3499
        style->removeProperty( KSpreadStyle::PMultiRow );
 
3500
    }
 
3501
  }
 
3502
 
 
3503
  if ( m_bOptionText )
 
3504
  {
 
3505
    if ( vertical->isEnabled() )
 
3506
    {
 
3507
      if ( vertical->isChecked() )
 
3508
        style->addProperty( KSpreadStyle::PVerticalText );
 
3509
      else
 
3510
        style->removeProperty( KSpreadStyle::PVerticalText );
 
3511
    }
 
3512
  }
 
3513
 
 
3514
  if ( dlg->textRotation != angleRotation->value() )
 
3515
    style->changeRotateAngle( (-angleRotation->value()) );
 
3516
 
 
3517
  if ( dlg->indent != indent->value() && indent->isEnabled() )
 
3518
    style->changeIndent( indent->value() );
 
3519
}
 
3520
 
 
3521
void CellFormatPagePosition::apply( ColumnFormat *_obj )
 
3522
{
 
3523
  KSpreadFormat::Align  ax;
 
3524
  KSpreadFormat::AlignY ay;
 
3525
 
 
3526
  if ( top->isChecked() )
 
3527
    ay = KSpreadCell::Top;
 
3528
  else if ( bottom->isChecked() )
 
3529
    ay = KSpreadCell::Bottom;
 
3530
  else if ( middle->isChecked() )
 
3531
    ay = KSpreadCell::Middle;
 
3532
  else
 
3533
    ay = KSpreadCell::Middle; //Default, just in case
 
3534
 
 
3535
  if ( left->isChecked() )
 
3536
    ax = KSpreadCell::Left;
 
3537
  else if ( right->isChecked() )
 
3538
    ax = KSpreadCell::Right;
 
3539
  else if ( center->isChecked() )
 
3540
    ax = KSpreadCell::Center;
 
3541
  else if ( standard->isChecked() )
 
3542
    ax = KSpreadCell::Undefined;
 
3543
  else
 
3544
    ax = KSpreadCell::Undefined; //Default, just in case
 
3545
 
 
3546
 
 
3547
  KSpreadSheet * table = dlg->getTable();
 
3548
  KSpreadCell * c = NULL;
 
3549
  for ( int col = dlg->left; col <= dlg->right; ++col)
 
3550
  {
 
3551
    for ( c = table->getFirstCellColumn(col); c != NULL;
 
3552
         c = table->getNextCellDown(c->column(), c->row()) )
 
3553
    {
 
3554
      if ( dlg->indent != indent->value() && indent->isEnabled() )
 
3555
      {
 
3556
        c->clearProperty( KSpreadCell::PIndent );
 
3557
        c->clearNoFallBackProperties( KSpreadCell::PIndent );
 
3558
      }
 
3559
      if ( ax != dlg->alignX )
 
3560
      {
 
3561
        c->clearProperty(KSpreadCell::PAlign);
 
3562
        c->clearNoFallBackProperties( KSpreadCell::PAlign );
 
3563
      }
 
3564
      if ( ay != dlg->alignY )
 
3565
      {
 
3566
        c->clearProperty(KSpreadCell::PAlignY);
 
3567
        c->clearNoFallBackProperties( KSpreadCell::PAlignY );
 
3568
      }
 
3569
      if ( m_bOptionText)
 
3570
      {
 
3571
        c->clearProperty(KSpreadCell::PMultiRow);
 
3572
        c->clearNoFallBackProperties( KSpreadCell::PMultiRow );
 
3573
      }
 
3574
      if ( m_bOptionText)
 
3575
      {
 
3576
        c->clearProperty(KSpreadCell::PVerticalText);
 
3577
        c->clearNoFallBackProperties( KSpreadCell::PVerticalText );
 
3578
      }
 
3579
 
 
3580
      if (dlg->textRotation != angleRotation->value())
 
3581
      {
 
3582
        c->clearProperty(KSpreadCell::PAngle);
 
3583
        c->clearNoFallBackProperties( KSpreadCell::PAngle );
 
3584
      }
 
3585
    }
 
3586
  }
 
3587
 
 
3588
  applyFormat( _obj );
 
3589
 
 
3590
  RowFormat* rw =dlg->getTable()->firstRow();
 
3591
  for ( ; rw; rw = rw->next() )
 
3592
  {
 
3593
    if ( !rw->isDefault() && ( rw->hasProperty(KSpreadCell::PAngle) ||
 
3594
                               rw->hasProperty(KSpreadCell::PVerticalText) ||
 
3595
                               rw->hasProperty(KSpreadCell::PMultiRow) ||
 
3596
                               rw->hasProperty(KSpreadCell::PAlignY) ||
 
3597
                               rw->hasProperty(KSpreadCell::PAlign) ||
 
3598
                               rw->hasProperty(KSpreadCell::PIndent) ) )
 
3599
    {
 
3600
      for ( int i = dlg->left; i <= dlg->right; ++i )
 
3601
      {
 
3602
        KSpreadCell * cell = dlg->getTable()->nonDefaultCell( i, rw->row() );
 
3603
        applyFormat( cell );
 
3604
      }
 
3605
    }
 
3606
  }
 
3607
}
 
3608
 
 
3609
void CellFormatPagePosition::apply( RowFormat *_obj )
 
3610
{
 
3611
  KSpreadFormat::Align  ax;
 
3612
  KSpreadFormat::AlignY ay;
 
3613
 
 
3614
  if ( top->isChecked() )
 
3615
    ay = KSpreadCell::Top;
 
3616
  else if ( bottom->isChecked() )
 
3617
    ay = KSpreadCell::Bottom;
 
3618
  else if ( middle->isChecked() )
 
3619
    ay = KSpreadCell::Middle;
 
3620
  else
 
3621
    ay = KSpreadCell::Middle; //Default, just in case
 
3622
 
 
3623
  if ( left->isChecked() )
 
3624
    ax = KSpreadCell::Left;
 
3625
  else if ( right->isChecked() )
 
3626
    ax = KSpreadCell::Right;
 
3627
  else if ( center->isChecked() )
 
3628
    ax = KSpreadCell::Center;
 
3629
  else if ( standard->isChecked() )
 
3630
    ax = KSpreadCell::Undefined;
 
3631
  else
 
3632
    ax = KSpreadCell::Undefined; //Default, just in case
 
3633
 
 
3634
  KSpreadSheet* table = dlg->getTable();
 
3635
  KSpreadCell* c= NULL;
 
3636
  for (int row = dlg->top; row <= dlg->bottom; row++)
 
3637
  {
 
3638
    for ( c = table->getFirstCellRow(row); c != NULL;
 
3639
         c = table->getNextCellRight(c->column(), c->row()) )
 
3640
    {
 
3641
      if (dlg->indent!=indent->value() && indent->isEnabled())
 
3642
      {
 
3643
        c->clearProperty(KSpreadCell::PIndent);
 
3644
        c->clearNoFallBackProperties( KSpreadCell::PIndent );
 
3645
      }
 
3646
      if ( ax != dlg->alignX )
 
3647
      {
 
3648
        c->clearProperty(KSpreadCell::PAlign);
 
3649
        c->clearNoFallBackProperties( KSpreadCell::PAlign );
 
3650
      }
 
3651
      if ( ay != dlg->alignY )
 
3652
      {
 
3653
        c->clearProperty(KSpreadCell::PAlignY);
 
3654
        c->clearNoFallBackProperties( KSpreadCell::PAlignY );
 
3655
      }
 
3656
      if ( m_bOptionText)
 
3657
      {
 
3658
        c->clearProperty(KSpreadCell::PMultiRow);
 
3659
        c->clearNoFallBackProperties( KSpreadCell::PMultiRow );
 
3660
      }
 
3661
      if ( m_bOptionText)
 
3662
      {
 
3663
        c->clearProperty(KSpreadCell::PVerticalText);
 
3664
        c->clearNoFallBackProperties( KSpreadCell::PVerticalText );
 
3665
      }
 
3666
      if (dlg->textRotation!=angleRotation->value())
 
3667
      {
 
3668
        c->clearProperty(KSpreadCell::PAngle);
 
3669
        c->clearNoFallBackProperties( KSpreadCell::PAngle );
 
3670
      }
 
3671
    }
 
3672
  }
 
3673
 
 
3674
  applyFormat( _obj );
 
3675
}
 
3676
 
 
3677
 
 
3678
void CellFormatPagePosition::apply( KSpreadCell *_obj )
 
3679
{
 
3680
  applyFormat( _obj );
 
3681
}
 
3682
 
 
3683
void CellFormatPagePosition::applyFormat( KSpreadFormat * _obj )
 
3684
{
 
3685
  KSpreadFormat::Align  ax;
 
3686
  KSpreadFormat::AlignY ay;
 
3687
 
 
3688
  if ( top->isChecked() )
 
3689
    ay = KSpreadCell::Top;
 
3690
  else if ( bottom->isChecked() )
 
3691
    ay = KSpreadCell::Bottom;
 
3692
  else if ( middle->isChecked() )
 
3693
    ay = KSpreadCell::Middle;
 
3694
  else
 
3695
    ay = KSpreadCell::Middle; // Default, just in case
 
3696
 
 
3697
  if ( left->isChecked() )
 
3698
    ax = KSpreadCell::Left;
 
3699
  else if ( right->isChecked() )
 
3700
    ax = KSpreadCell::Right;
 
3701
  else if ( center->isChecked() )
 
3702
    ax = KSpreadCell::Center;
 
3703
  else if ( standard->isChecked() )
 
3704
    ax = KSpreadCell::Undefined;
 
3705
  else
 
3706
    ax = KSpreadCell::Undefined; //Default, just in case
 
3707
 
 
3708
  if ( top->isChecked() && ay != dlg->alignY )
 
3709
    _obj->setAlignY( KSpreadCell::Top );
 
3710
  else if ( bottom->isChecked() && ay != dlg->alignY )
 
3711
    _obj->setAlignY( KSpreadCell::Bottom );
 
3712
  else if ( middle->isChecked() && ay != dlg->alignY )
 
3713
    _obj->setAlignY( KSpreadCell::Middle );
 
3714
 
 
3715
  if ( left->isChecked() && ax != dlg->alignX )
 
3716
    _obj->setAlign( KSpreadCell::Left );
 
3717
  else if ( right->isChecked() && ax != dlg->alignX )
 
3718
    _obj->setAlign( KSpreadCell::Right );
 
3719
  else if ( center->isChecked() && ax != dlg->alignX )
 
3720
    _obj->setAlign( KSpreadCell::Center );
 
3721
  else if ( standard->isChecked() && ax != dlg->alignX )
 
3722
    _obj->setAlign( KSpreadCell::Undefined );
 
3723
 
 
3724
  if ( m_bOptionText )
 
3725
  {
 
3726
    if ( multi->isEnabled() )
 
3727
      _obj->setMultiRow( multi->isChecked() );
 
3728
    else
 
3729
      _obj->setMultiRow( false );
 
3730
  }
 
3731
 
 
3732
  if ( m_bOptionText )
 
3733
  {
 
3734
    if ( vertical->isEnabled() )
 
3735
      _obj->setVerticalText( vertical->isChecked() );
 
3736
    else
 
3737
      _obj->setVerticalText( false );
 
3738
  }
 
3739
 
 
3740
  if ( dlg->textRotation!=angleRotation->value() )
 
3741
    _obj->setAngle( (-angleRotation->value() ) );
 
3742
  if ( dlg->indent != indent->value() && indent->isEnabled() )
 
3743
    _obj->setIndent( indent->value() );
 
3744
}
 
3745
 
 
3746
double CellFormatPagePosition::getSizeHeight()
 
3747
{
 
3748
  if ( defaultHeight->isChecked() )
 
3749
      return 20.0;
 
3750
  else
 
3751
      return KoUnit::ptFromUnit( height->value(), dlg->getDoc()->getUnit() );
 
3752
}
 
3753
 
 
3754
double CellFormatPagePosition::getSizeWidth()
 
3755
{
 
3756
  if ( defaultWidth->isChecked() )
 
3757
        return 60.0;
 
3758
  else
 
3759
        return KoUnit::ptFromUnit( width->value(), dlg->getDoc()->getUnit() );
2728
3760
}
2729
3761
 
2730
3762
KSpreadBorderButton::KSpreadBorderButton( QWidget *parent, const char *_name ) : QPushButton(parent,_name)
2732
3764
  penStyle = Qt::NoPen;
2733
3765
  penWidth = 1;
2734
3766
  penColor = colorGroup().text();
2735
 
  setToggleButton( TRUE );
 
3767
  setToggleButton( true );
2736
3768
  setOn( false);
2737
3769
  setChanged(false);
2738
3770
}
2789
3821
 
2790
3822
  painter.drawLine( width()-OFFSETX, height()-OFFSETY, width() , height()-OFFSETY );
2791
3823
  painter.drawLine( width()-OFFSETX, height()-OFFSETY, width()-OFFSETX , height() );
2792
 
  if(oneCol==false)
 
3824
  if (oneCol==false)
2793
3825
  {
2794
3826
        painter.drawLine( width()/2, OFFSETY-5, width()/2 , OFFSETY );
2795
3827
        painter.drawLine( width()/2-5, OFFSETY, width()/2+5 , OFFSETY );
2796
3828
        painter.drawLine( width()/2, height()-OFFSETY, width()/2 , height() );
2797
3829
        painter.drawLine( width()/2-5, height()-OFFSETY, width()/2+5 , height()-OFFSETY );
2798
3830
  }
2799
 
  if(oneRow==false)
 
3831
  if (oneRow==false)
2800
3832
  {
2801
3833
        painter.drawLine( OFFSETX-5, height()/2, OFFSETX , height()/2 );
2802
3834
        painter.drawLine( OFFSETX, height()/2-5, OFFSETX , height()/2+5 );
2812
3844
  emit choosearea(_ev);
2813
3845
}
2814
3846
 
2815
 
CellLayoutPageBorder::CellLayoutPageBorder( QWidget* parent, CellLayoutDlg *_dlg ) : QWidget( parent )
2816
 
{
2817
 
  dlg = _dlg;
2818
 
 
2819
 
  QGridLayout *grid = new QGridLayout(this,5,2,15,15);
2820
 
 
2821
 
  QGroupBox* tmpQGroupBox;
 
3847
CellFormatPageBorder::CellFormatPageBorder( QWidget* parent, CellFormatDlg *_dlg )
 
3848
  : QWidget( parent ),
 
3849
    dlg( _dlg )
 
3850
{
 
3851
  table = dlg->getTable();
 
3852
 
 
3853
  InitializeGrids();
 
3854
  InitializeBorderButtons();
 
3855
  InitializePatterns();
 
3856
  SetConnections();
 
3857
 
 
3858
  preview->slotSelect();
 
3859
  pattern[2]->slotSelect();
 
3860
 
 
3861
  style->setEnabled(false);
 
3862
  size->setEnabled(false);
 
3863
  preview->setPattern( black , 1, SolidLine );
 
3864
  this->resize( 400, 400 );
 
3865
}
 
3866
 
 
3867
void CellFormatPageBorder::InitializeGrids()
 
3868
{
 
3869
  QGridLayout *grid = new QGridLayout(this,5,2,KDialog::marginHint(), KDialog::spacingHint());
 
3870
  QGridLayout *grid2 = NULL;
 
3871
  QGroupBox* tmpQGroupBox = NULL;
 
3872
 
 
3873
  /***********************/
 
3874
  /* here is the data to initialize all the border buttons with */
 
3875
  const char borderButtonNames[BorderType_END][20] =
 
3876
    {"top", "bottom", "left", "right", "vertical", "fall", "go", "horizontal"};
 
3877
 
 
3878
  const char shortcutButtonNames[BorderShortcutType_END][20] =
 
3879
    {"remove", "all", "outline"};
 
3880
 
 
3881
  QString borderButtonIconNames[BorderType_END] =
 
3882
    {"border_top", "border_bottom", "border_left", "border_right",
 
3883
     "border_vertical", "border_horizontal", "border_fall", "border_up"};
 
3884
 
 
3885
  QString shortcutButtonIconNames[BorderShortcutType_END] =
 
3886
    { "border_remove", "", "border_outline"};
 
3887
 
 
3888
  int borderButtonPositions[BorderType_END][2] =
 
3889
    {{0,2}, {4,2}, {2,0}, {2,4}, {4,4}, {4,0}, {0,0}, {0,4}};
 
3890
 
 
3891
  int shortcutButtonPositions[BorderShortcutType_END][2] =
 
3892
    { {0,0}, {0,1},{0,2} };
 
3893
  /***********************/
 
3894
 
 
3895
  /* set up a layout box for most of the border setting buttons */
2822
3896
  tmpQGroupBox = new QGroupBox( this, "GroupBox_1" );
2823
 
  tmpQGroupBox->setFrameStyle( 49 );
 
3897
  tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
2824
3898
  tmpQGroupBox->setTitle( i18n("Border") );
2825
 
  tmpQGroupBox->setAlignment( 1 );
2826
 
 
2827
 
  QGridLayout *grid2 = new QGridLayout(tmpQGroupBox,5,5,15,7);
 
3899
  tmpQGroupBox->setAlignment( AlignLeft );
 
3900
  grid2 = new QGridLayout(tmpQGroupBox,6,5,KDialog::marginHint(), KDialog::spacingHint());
 
3901
  int fHeight = tmpQGroupBox->fontMetrics().height();
 
3902
  grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
2828
3903
 
2829
3904
  area=new KSpreadBorder(tmpQGroupBox,"area",dlg->oneCol,dlg->oneRow);
2830
 
  grid2->addMultiCellWidget(area,1,3,1,3);
 
3905
  grid2->addMultiCellWidget(area,2,4,1,3);
2831
3906
  area->setBackgroundColor( colorGroup().base() );
2832
3907
 
2833
 
  top=new KSpreadBorderButton(tmpQGroupBox,"top");
2834
 
  loadIcon("border_top",top);
2835
 
  grid2->addWidget(top,0,2);
2836
 
 
2837
 
  bottom=new KSpreadBorderButton(tmpQGroupBox,"bottom");
2838
 
  loadIcon("border_bottom",bottom);
2839
 
  grid2->addWidget(bottom,4,2);
2840
 
 
2841
 
  left=new KSpreadBorderButton(tmpQGroupBox,"left");
2842
 
  loadIcon("border_left",left);
2843
 
  grid2->addWidget(left,2,0);
2844
 
 
2845
 
  right=new KSpreadBorderButton(tmpQGroupBox,"right");
2846
 
  loadIcon("border_right",right);
2847
 
  grid2->addWidget(right,2,4);
2848
 
 
2849
 
  fallDiagonal=new KSpreadBorderButton(tmpQGroupBox,"fall");
2850
 
  loadIcon("border_fall",fallDiagonal);
2851
 
  grid2->addWidget(fallDiagonal,0,0);
2852
 
 
2853
 
  goUpDiagonal=new KSpreadBorderButton(tmpQGroupBox,"go");
2854
 
  loadIcon("border_up",goUpDiagonal);
2855
 
  grid2->addWidget(goUpDiagonal,0,4);
2856
 
 
2857
 
  vertical=new KSpreadBorderButton(tmpQGroupBox,"vertical");
2858
 
  loadIcon("border_vertical",vertical);
2859
 
  grid2->addWidget(vertical,4,4);
2860
 
 
2861
 
  horizontal=new KSpreadBorderButton(tmpQGroupBox,"horizontal");
2862
 
  loadIcon("border_horizontal",horizontal);
2863
 
  grid2->addWidget(horizontal,4,0);
 
3908
  /* initailize the buttons that are in this box */
 
3909
  for (int i=BorderType_Top; i < BorderType_END; i++)
 
3910
  {
 
3911
    borderButtons[i] = new KSpreadBorderButton(tmpQGroupBox,
 
3912
                                               borderButtonNames[i]);
 
3913
    loadIcon(borderButtonIconNames[i], borderButtons[i]);
 
3914
    grid2->addWidget(borderButtons[i], borderButtonPositions[i][0] + 1,
 
3915
                     borderButtonPositions[i][1]);
 
3916
  }
2864
3917
 
2865
3918
  grid->addMultiCellWidget(tmpQGroupBox,0,2,0,0);
2866
3919
 
 
3920
  /* the remove, all, and outline border buttons are in a second box down
 
3921
     below.*/
2867
3922
 
2868
3923
  tmpQGroupBox = new QGroupBox( this, "GroupBox_3" );
2869
 
  tmpQGroupBox->setFrameStyle( 49 );
 
3924
  tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
2870
3925
  tmpQGroupBox->setTitle( i18n("Preselect") );
2871
 
  tmpQGroupBox->setAlignment( 1 );
2872
 
 
2873
 
  grid2 = new QGridLayout(tmpQGroupBox,1,3,15,7);
2874
 
 
2875
 
  outline=new KSpreadBorderButton(tmpQGroupBox,"outline");
2876
 
  loadIcon("border_outline",outline);
2877
 
  grid2->addWidget(outline,0,2);
2878
 
 
2879
 
  remove=new KSpreadBorderButton(tmpQGroupBox,"remove");
2880
 
  loadIcon("border_remove",remove);
2881
 
  grid2->addWidget(remove,0,0);
2882
 
 
2883
 
  all=new KSpreadBorderButton(tmpQGroupBox,"all");
2884
 
  grid2->addWidget(all,0,1);
2885
 
 
2886
 
  if((dlg->oneRow==true)&&(dlg->oneCol==false))
2887
 
        {
2888
 
        loadIcon("border_vertical",all);
2889
 
        }
2890
 
  else if((dlg->oneRow==false)&&(dlg->oneCol==true))
2891
 
        {
2892
 
        loadIcon("border_horizontal",all);
2893
 
        }
2894
 
  else if((dlg->oneRow==false)&&(dlg->oneCol==false))
2895
 
        {
2896
 
         loadIcon("border_inside",all);
2897
 
        }
 
3926
  tmpQGroupBox->setAlignment( AlignLeft );
 
3927
 
 
3928
  grid2 = new QGridLayout(tmpQGroupBox,1,3,KDialog::marginHint(), KDialog::spacingHint());
 
3929
 
 
3930
  /* the "all" button is different depending on what kind of region is currently
 
3931
     selected */
 
3932
  if ((dlg->oneRow==true)&&(dlg->oneCol==false))
 
3933
  {
 
3934
    shortcutButtonIconNames[BorderShortcutType_All] = "border_vertical";
 
3935
  }
 
3936
  else if ((dlg->oneRow==false)&&(dlg->oneCol==true))
 
3937
  {
 
3938
    shortcutButtonIconNames[BorderShortcutType_All] = "border_horizontal";
 
3939
  }
2898
3940
  else
2899
 
        {
2900
 
        loadIcon("border_inside",all);
2901
 
        all->setEnabled(false);
2902
 
        }
 
3941
  {
 
3942
    shortcutButtonIconNames[BorderShortcutType_All] = "border_inside";
 
3943
  }
 
3944
 
 
3945
  for (int i=BorderShortcutType_Remove; i < BorderShortcutType_END; i++)
 
3946
  {
 
3947
    shortcutButtons[i] = new KSpreadBorderButton(tmpQGroupBox,
 
3948
                                                 shortcutButtonNames[i]);
 
3949
    loadIcon(shortcutButtonIconNames[i], shortcutButtons[i]);
 
3950
    grid2->addWidget(shortcutButtons[i], shortcutButtonPositions[i][0],
 
3951
                     shortcutButtonPositions[i][1]);
 
3952
  }
 
3953
 
 
3954
  if (dlg->oneRow && dlg->oneCol)
 
3955
  {
 
3956
    shortcutButtons[BorderShortcutType_All]->setEnabled(false);
 
3957
  }
 
3958
 
2903
3959
  grid->addMultiCellWidget(tmpQGroupBox,3,4,0,0);
2904
3960
 
 
3961
  /* now set up the group box with the pattern selector */
2905
3962
  tmpQGroupBox = new QGroupBox( this, "GroupBox_10" );
2906
 
  tmpQGroupBox->setFrameStyle( 49 );
 
3963
  tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
2907
3964
  tmpQGroupBox->setTitle( i18n("Pattern") );
2908
 
  tmpQGroupBox->setAlignment( 1 );
2909
 
 
2910
 
  grid2 = new QGridLayout(tmpQGroupBox,6,2,15,7);
2911
 
 
2912
 
  pattern1 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_1" );
2913
 
  pattern1->setFrameStyle( 50 );
2914
 
  grid2->addWidget(pattern1,0,0);
2915
 
 
2916
 
  pattern2 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_2" );
2917
 
  pattern2->setFrameStyle( 50 );
2918
 
  grid2->addWidget(pattern2,1,0);
2919
 
 
2920
 
  pattern3 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_3" );
2921
 
  pattern3->setFrameStyle( 50 );
2922
 
  grid2->addWidget(pattern3,2,0);
2923
 
 
2924
 
  pattern4 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_4" );
2925
 
  pattern4->setFrameStyle( 50 );
2926
 
  grid2->addWidget(pattern4,0,1);
2927
 
 
2928
 
  pattern5 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_5" );
2929
 
  pattern5->setFrameStyle( 50 );
2930
 
  grid2->addWidget(pattern5,1,1);
2931
 
 
2932
 
  pattern6 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_6" );
2933
 
  pattern6->setFrameStyle( 50 );
2934
 
  grid2->addWidget(pattern6,2,1);
2935
 
 
2936
 
  pattern7 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_7" );
2937
 
  pattern7->setFrameStyle( 50 );
2938
 
  grid2->addWidget(pattern7,3,1);
2939
 
 
2940
 
  pattern8 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_8" );
2941
 
  pattern8->setFrameStyle( 50 );
2942
 
  grid2->addWidget(pattern8,4,1);
2943
 
 
2944
 
  pattern9 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_9" );
2945
 
  pattern9->setFrameStyle( 50 );
2946
 
  grid2->addWidget(pattern9,3,0);
2947
 
 
2948
 
  pattern10 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_10" );
2949
 
  pattern10->setFrameStyle( 50 );
2950
 
  grid2->addWidget(pattern10,4,0);
2951
 
 
2952
 
 
2953
 
 
2954
 
    color = new KColorButton (tmpQGroupBox, "PushButton_1" );
2955
 
    grid2->addWidget(color,6,1);
2956
 
 
2957
 
    QLabel *tmpQLabel = new QLabel( tmpQGroupBox, "Label_6" );
2958
 
    tmpQLabel->setText( i18n("Color") );
2959
 
    grid2->addWidget(tmpQLabel,6,0);
2960
 
 
2961
 
 
2962
 
    QGridLayout *grid3 = new QGridLayout(tmpQGroupBox,2,2,0,7);
2963
 
    customize  = new QCheckBox(i18n("Customize"),tmpQGroupBox);
2964
 
    grid3->addWidget(customize,0,0);
2965
 
    connect( customize, SIGNAL( clicked()),
2966
 
           SLOT(cutomize_chosen_slot()) );
2967
 
 
2968
 
    size=new QComboBox(true,tmpQGroupBox);
2969
 
    grid3->addWidget(size,1,1);
2970
 
    size->setValidator(new KIntValidator( size ));
2971
 
    QString tmp;
2972
 
    for(int i=0;i<10;i++)
2973
 
        {
2974
 
        tmp=tmp.setNum(i);
2975
 
        size->insertItem(tmp);
2976
 
        }
2977
 
    size->setCurrentItem(1);
2978
 
 
2979
 
    style=new QComboBox(tmpQGroupBox);
2980
 
    grid3->addWidget(style,1,0);
2981
 
    style->insertItem(paintFormatPixmap(DotLine),0 );
2982
 
    style->insertItem(paintFormatPixmap(DashLine) ,1);
2983
 
    style->insertItem(paintFormatPixmap(DashDotLine),2 );
2984
 
    style->insertItem(paintFormatPixmap(DashDotDotLine),3  );
2985
 
    style->insertItem(paintFormatPixmap(SolidLine),4);
2986
 
    style->setBackgroundColor( colorGroup().background() );
2987
 
 
2988
 
    grid2->addMultiCell(grid3,5,5,0,1);
2989
 
    grid->addMultiCellWidget(tmpQGroupBox,0,3,1,1);
2990
 
 
2991
 
 
2992
 
    tmpQGroupBox = new QGroupBox(this, "GroupBox_4" );
2993
 
    tmpQGroupBox->setFrameStyle( 49 );
2994
 
    tmpQGroupBox->setTitle( i18n("Preview") );
2995
 
    tmpQGroupBox->setAlignment( 1 );
2996
 
 
2997
 
    grid2 = new QGridLayout(tmpQGroupBox,1,1,14,7);
2998
 
 
2999
 
 
3000
 
 
3001
 
    preview = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_preview" );
3002
 
    preview->setFrameStyle( 50 );
3003
 
    grid2->addWidget(preview,0,0);
3004
 
 
3005
 
    grid->addWidget(tmpQGroupBox,4,1);
3006
 
 
3007
 
 if(dlg->leftBorderStyle != Qt::NoPen || !dlg->bLeftBorderStyle )
3008
 
    {
3009
 
    if ( dlg->bLeftBorderColor && dlg->bLeftBorderStyle  )
3010
 
      {
3011
 
        left->setPenStyle(dlg->leftBorderStyle );
3012
 
        left->setPenWidth(dlg->leftBorderWidth);
3013
 
        left->setColor(dlg->leftBorderColor);
3014
 
        left->setOn(true);
3015
 
      }
3016
 
    else
3017
 
      {
3018
 
 
3019
 
        left->setUndefined();
3020
 
      }
3021
 
 }
3022
 
 if(dlg->rightBorderStyle!=Qt::NoPen|| !dlg->bRightBorderStyle)
3023
 
    {
3024
 
    if ( dlg->bRightBorderColor && dlg->bRightBorderStyle && dlg->rightBorderStyle!=NoPen)
3025
 
      {
3026
 
        right->setPenStyle(dlg->rightBorderStyle );
3027
 
        right->setPenWidth(dlg->rightBorderWidth);
3028
 
        right->setColor(dlg->rightBorderColor);
3029
 
        right->setOn(true);
3030
 
      }
3031
 
    else
3032
 
      {
3033
 
 
3034
 
        right->setUndefined();
3035
 
      }
3036
 
     }
3037
 
 
3038
 
   if(  dlg->topBorderStyle!=Qt::NoPen || !dlg->bTopBorderStyle)
3039
 
    {
3040
 
    if ( dlg->bTopBorderColor && dlg->bTopBorderStyle)
3041
 
      {
3042
 
        top->setPenStyle(dlg->topBorderStyle );
3043
 
        top->setPenWidth(dlg->topBorderWidth);
3044
 
        top->setColor(dlg->topBorderColor);
3045
 
        top->setOn(true);
3046
 
      }
3047
 
    else
3048
 
      {
3049
 
 
3050
 
        top->setUndefined();
3051
 
      }
3052
 
     }
3053
 
 
3054
 
 if(dlg->bottomBorderStyle != Qt::NoPen || !dlg->bBottomBorderStyle)
3055
 
 {
3056
 
    if ( dlg->bBottomBorderColor && dlg->bBottomBorderStyle )
3057
 
 
3058
 
      {
3059
 
        bottom->setPenStyle(dlg->bottomBorderStyle );
3060
 
        bottom->setPenWidth(dlg->bottomBorderWidth);
3061
 
        bottom->setColor(dlg->bottomBorderColor);
3062
 
        bottom->setOn(true);
3063
 
      }
3064
 
    else
3065
 
      {
3066
 
 
3067
 
        bottom->setUndefined();
3068
 
      }
3069
 
 }
3070
 
 
3071
 
  if(dlg->oneRow==FALSE)
3072
 
  {
3073
 
   if(dlg->horizontalBorderStyle!=Qt::NoPen ||!dlg->bHorizontalBorderStyle)
3074
 
   {
3075
 
    if ( dlg->bHorizontalBorderColor && dlg->bHorizontalBorderStyle )
3076
 
      {
3077
 
        horizontal->setPenStyle(dlg->horizontalBorderStyle );
3078
 
        horizontal->setPenWidth(dlg->horizontalBorderWidth);
3079
 
        horizontal->setColor(dlg->horizontalBorderColor);
3080
 
        horizontal->setOn(true);
3081
 
       }
3082
 
    else
3083
 
       {
3084
 
         horizontal->setUndefined();
3085
 
       }
3086
 
    }
3087
 
  }
3088
 
  else
3089
 
        horizontal->setEnabled(false);
3090
 
 
3091
 
  if(dlg->oneCol==FALSE)
3092
 
  {
3093
 
        if(dlg->verticalBorderStyle!=Qt::NoPen || !dlg->bVerticalBorderStyle)
3094
 
        {
3095
 
                if ( dlg->bVerticalBorderColor && dlg->bVerticalBorderStyle )
3096
 
                {
3097
 
                vertical->setPenStyle(dlg->verticalBorderStyle );
3098
 
                vertical->setPenWidth(dlg->verticalBorderWidth);
3099
 
                vertical->setColor(dlg->verticalBorderColor);
3100
 
                vertical->setOn(true);
3101
 
                }
3102
 
        else
3103
 
                {
3104
 
                vertical->setUndefined();
3105
 
                }
3106
 
         }
3107
 
   }
3108
 
   else
3109
 
        {
3110
 
        vertical->setEnabled(false);
3111
 
        }
3112
 
 
3113
 
  if(dlg->fallDiagonalStyle!=Qt::NoPen || !dlg->bFallDiagonalStyle)
3114
 
  {
3115
 
    if ( dlg->bfallDiagonalColor && dlg->bFallDiagonalStyle  )
3116
 
      {
3117
 
        fallDiagonal->setPenStyle(dlg->fallDiagonalStyle );
3118
 
        fallDiagonal->setPenWidth(dlg->fallDiagonalWidth);
3119
 
        fallDiagonal->setColor(dlg->fallDiagonalColor);
3120
 
        fallDiagonal->setOn(true);
3121
 
      }
3122
 
    else
3123
 
      {
3124
 
        fallDiagonal->setUndefined();
3125
 
      }
3126
 
   }
3127
 
 
3128
 
 if(dlg->goUpDiagonalStyle!=Qt::NoPen || !dlg->bGoUpDiagonalStyle)
3129
 
    {
3130
 
    if ( dlg->bGoUpDiagonalColor && dlg->bGoUpDiagonalStyle )
3131
 
      {
3132
 
        goUpDiagonal->setPenStyle(dlg->goUpDiagonalStyle );
3133
 
        goUpDiagonal->setPenWidth(dlg->goUpDiagonalWidth);
3134
 
        goUpDiagonal->setColor(dlg->goUpDiagonalColor);
3135
 
        goUpDiagonal->setOn(true);
3136
 
      }
3137
 
    else
3138
 
      {
3139
 
        goUpDiagonal->setUndefined();
3140
 
      }
3141
 
    }
3142
 
 
3143
 
 
3144
 
    pattern1->setPattern( black, 1, DotLine );
3145
 
    pattern2->setPattern( black, 1, DashLine );
3146
 
    pattern3->setPattern( black, 1, SolidLine );
3147
 
    pattern4->setPattern( black, 2, SolidLine );
3148
 
    pattern5->setPattern( black, 3, SolidLine );
3149
 
    pattern6->setPattern( black, 4, SolidLine );
3150
 
    pattern7->setPattern( black, 5, SolidLine );
3151
 
    pattern8->setPattern( black, 1, NoPen );
3152
 
    pattern9->setPattern( black, 1, DashDotLine );
3153
 
    pattern10->setPattern( black, 1, DashDotDotLine );
3154
 
 
3155
 
 
3156
 
 
3157
 
    slotSetColorButton( black );
3158
 
 
3159
 
    connect( color, SIGNAL( changed( const QColor & ) ),
3160
 
             this, SLOT( slotSetColorButton( const QColor & ) ) );
3161
 
 
3162
 
 
3163
 
    connect( pattern1, SIGNAL( clicked( KSpreadPatternSelect* ) ),
3164
 
             this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
3165
 
    connect( pattern2, SIGNAL( clicked( KSpreadPatternSelect* ) ),
3166
 
             this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
3167
 
    connect( pattern3, SIGNAL( clicked( KSpreadPatternSelect* ) ),
3168
 
             this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
3169
 
    connect( pattern4, SIGNAL( clicked( KSpreadPatternSelect* ) ),
3170
 
             this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
3171
 
    connect( pattern5, SIGNAL( clicked( KSpreadPatternSelect* ) ),
3172
 
             this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
3173
 
    connect( pattern6, SIGNAL( clicked( KSpreadPatternSelect* ) ),
3174
 
             this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
3175
 
    connect( pattern7, SIGNAL( clicked( KSpreadPatternSelect* ) ),
3176
 
             this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
3177
 
    connect( pattern8, SIGNAL( clicked( KSpreadPatternSelect* ) ),
3178
 
             this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
3179
 
    connect( pattern9, SIGNAL( clicked( KSpreadPatternSelect* ) ),
3180
 
             this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
3181
 
    connect( pattern10, SIGNAL( clicked( KSpreadPatternSelect* ) ),
3182
 
             this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
3183
 
 
3184
 
  connect( goUpDiagonal, SIGNAL( clicked (KSpreadBorderButton *) ),
3185
 
           this, SLOT( changeState( KSpreadBorderButton *) ) );
3186
 
  connect( top, SIGNAL( clicked(KSpreadBorderButton *) ),
3187
 
           this, SLOT( changeState(KSpreadBorderButton *) ) );
3188
 
  connect( right, SIGNAL( clicked(KSpreadBorderButton *) ),
3189
 
           this, SLOT( changeState(KSpreadBorderButton *) ) );
3190
 
 
3191
 
  connect( fallDiagonal, SIGNAL( clicked(KSpreadBorderButton *) ),
3192
 
           this, SLOT( changeState(KSpreadBorderButton *) ) );
3193
 
 
3194
 
  connect( bottom, SIGNAL( clicked(KSpreadBorderButton *) ),
3195
 
           this, SLOT( changeState(KSpreadBorderButton *) ) );
3196
 
  connect( left, SIGNAL( clicked(KSpreadBorderButton *) ),
3197
 
           this, SLOT( changeState(KSpreadBorderButton *) ) );
3198
 
  connect( horizontal, SIGNAL( clicked(KSpreadBorderButton *) ),
3199
 
           this, SLOT( changeState(KSpreadBorderButton *) ) );
3200
 
  connect( vertical, SIGNAL( clicked(KSpreadBorderButton *) ),
3201
 
           this, SLOT( changeState(KSpreadBorderButton *) ) );
3202
 
 
3203
 
  connect( all, SIGNAL( clicked(KSpreadBorderButton *) ),
3204
 
           this, SLOT( preselect(KSpreadBorderButton *) ) );
3205
 
  connect( remove, SIGNAL( clicked(KSpreadBorderButton *) ),
3206
 
           this, SLOT( preselect(KSpreadBorderButton *) ) );
3207
 
  connect( outline, SIGNAL( clicked(KSpreadBorderButton *) ),
3208
 
           this, SLOT( preselect(KSpreadBorderButton *) ) );
 
3965
  tmpQGroupBox->setAlignment( AlignLeft );
 
3966
 
 
3967
  grid2 = new QGridLayout(tmpQGroupBox,7,2,KDialog::marginHint(), KDialog::spacingHint());
 
3968
  fHeight = tmpQGroupBox->fontMetrics().height();
 
3969
  grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
 
3970
 
 
3971
  char name[] = "PatternXX";
 
3972
  Q_ASSERT(NUM_BORDER_PATTERNS < 100);
 
3973
 
 
3974
  for (int i=0; i < NUM_BORDER_PATTERNS; i++)
 
3975
  {
 
3976
    name[7] = '0' + (i+1) / 10;
 
3977
    name[8] = '0' + (i+1) % 10;
 
3978
    pattern[i] = new KSpreadPatternSelect( tmpQGroupBox, name );
 
3979
    pattern[i]->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
3980
    grid2->addWidget(pattern[i], i % 5 + 1, i / 5);
 
3981
    /* this puts them in the pattern:
 
3982
       1  6
 
3983
       2  7
 
3984
       3  8
 
3985
       4  9
 
3986
       5  10
 
3987
    */
 
3988
  }
 
3989
 
 
3990
  color = new KColorButton (tmpQGroupBox, "PushButton_1" );
 
3991
  grid2->addWidget(color,7,1);
 
3992
 
 
3993
  QLabel *tmpQLabel = new QLabel( tmpQGroupBox, "Label_6" );
 
3994
  tmpQLabel->setText( i18n("Color:") );
 
3995
  grid2->addWidget(tmpQLabel,7,0);
 
3996
 
 
3997
  /* tack on the 'customize' border pattern selector */
 
3998
  QGridLayout *grid3 = new QGridLayout( this, 2, 2, KDialog::marginHint(), KDialog::spacingHint() );
 
3999
  customize  = new QCheckBox(i18n("Customize"),tmpQGroupBox);
 
4000
  grid3->addWidget(customize,0,0);
 
4001
  connect( customize, SIGNAL( clicked()), SLOT(cutomize_chosen_slot()) );
 
4002
 
 
4003
  size=new QComboBox(true,tmpQGroupBox);
 
4004
  grid3->addWidget(size,1,1);
 
4005
  size->setValidator(new KIntValidator( size ));
 
4006
  QString tmp;
 
4007
  for ( int i=0;i<10;i++)
 
4008
  {
 
4009
    tmp=tmp.setNum(i);
 
4010
    size->insertItem(tmp);
 
4011
  }
 
4012
  size->setCurrentItem(1);
 
4013
 
 
4014
  style=new QComboBox(tmpQGroupBox);
 
4015
  grid3->addWidget(style,1,0);
 
4016
  style->insertItem(paintFormatPixmap(DotLine),0 );
 
4017
  style->insertItem(paintFormatPixmap(DashLine) ,1);
 
4018
  style->insertItem(paintFormatPixmap(DashDotLine),2 );
 
4019
  style->insertItem(paintFormatPixmap(DashDotDotLine),3  );
 
4020
  style->insertItem(paintFormatPixmap(SolidLine),4);
 
4021
  style->setBackgroundColor( colorGroup().background() );
 
4022
 
 
4023
  grid2->addMultiCell(grid3,6,6,0,1);
 
4024
  grid->addMultiCellWidget(tmpQGroupBox,0,3,1,1);
 
4025
 
 
4026
  /* Now the preview box is put together */
 
4027
  tmpQGroupBox = new QGroupBox(this, "GroupBox_4" );
 
4028
  tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
 
4029
  tmpQGroupBox->setTitle( i18n("Preview") );
 
4030
  tmpQGroupBox->setAlignment( AlignLeft );
 
4031
 
 
4032
  grid2 = new QGridLayout(tmpQGroupBox,1,1,KDialog::marginHint(), KDialog::spacingHint());
 
4033
  fHeight = tmpQGroupBox->fontMetrics().height();
 
4034
  grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
 
4035
 
 
4036
  preview = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_preview" );
 
4037
  preview->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
4038
  grid2->addWidget(preview,1,0);
 
4039
 
 
4040
  grid->addWidget(tmpQGroupBox,4,1);
 
4041
}
 
4042
 
 
4043
void CellFormatPageBorder::InitializeBorderButtons()
 
4044
{
 
4045
  for (int i=BorderType_Top; i < BorderType_END; i++)
 
4046
  {
 
4047
    if (dlg->borders[i].style != Qt::NoPen ||
 
4048
       !dlg->borders[i].bStyle )
 
4049
    {
 
4050
      /* the horozontil and vertical buttons might be disabled depending on what
 
4051
         kind of area is selected so check that first. */
 
4052
      if ((dlg->oneRow == true && i == BorderType_Horizontal) ||
 
4053
          (dlg->oneCol == true && i == BorderType_Vertical))
 
4054
      {
 
4055
        borderButtons[i]->setEnabled(false);
 
4056
      }
 
4057
      else if ( dlg->borders[i].bColor && dlg->borders[i].bStyle  )
 
4058
      {
 
4059
        borderButtons[i]->setPenStyle(dlg->borders[i].style );
 
4060
        borderButtons[i]->setPenWidth(dlg->borders[i].width);
 
4061
        borderButtons[i]->setColor(dlg->borders[i].color);
 
4062
        borderButtons[i]->setOn(true);
 
4063
      }
 
4064
      else
 
4065
      {
 
4066
        borderButtons[i]->setUndefined();
 
4067
      }
 
4068
    }
 
4069
  }
 
4070
 
 
4071
 
 
4072
}
 
4073
 
 
4074
void CellFormatPageBorder::InitializePatterns()
 
4075
{
 
4076
  pattern[0]->setPattern( black, 1, DotLine );
 
4077
  pattern[1]->setPattern( black, 1, DashLine );
 
4078
  pattern[2]->setPattern( black, 1, SolidLine );
 
4079
  pattern[3]->setPattern( black, 1, DashDotLine );
 
4080
  pattern[4]->setPattern( black, 1, DashDotDotLine );
 
4081
  pattern[5]->setPattern( black, 2, SolidLine );
 
4082
  pattern[6]->setPattern( black, 3, SolidLine );
 
4083
  pattern[7]->setPattern( black, 4, SolidLine );
 
4084
  pattern[8]->setPattern( black, 5, SolidLine );
 
4085
  pattern[9]->setPattern( black, 1, NoPen );
 
4086
 
 
4087
  slotSetColorButton( black );
 
4088
}
 
4089
 
 
4090
void CellFormatPageBorder::SetConnections()
 
4091
{
 
4092
  connect( color, SIGNAL( changed( const QColor & ) ),
 
4093
           this, SLOT( slotSetColorButton( const QColor & ) ) );
 
4094
 
 
4095
  for (int i=0; i < NUM_BORDER_PATTERNS; i++)
 
4096
  {
 
4097
    connect( pattern[i], SIGNAL( clicked( KSpreadPatternSelect* ) ),
 
4098
             this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
 
4099
  }
 
4100
 
 
4101
  for (int i = BorderType_Top; i < BorderType_END; i++)
 
4102
  {
 
4103
    connect( borderButtons[i], SIGNAL( clicked (KSpreadBorderButton *) ),
 
4104
             this, SLOT( changeState( KSpreadBorderButton *) ) );
 
4105
  }
 
4106
 
 
4107
  for (int i = BorderShortcutType_Remove; i < BorderShortcutType_END; i++)
 
4108
  {
 
4109
    connect( shortcutButtons[i], SIGNAL( clicked(KSpreadBorderButton *) ),
 
4110
             this, SLOT( preselect(KSpreadBorderButton *) ) );
 
4111
  }
3209
4112
 
3210
4113
  connect( area ,SIGNAL( redraw()),this,SLOT(draw()));
3211
4114
  connect( area ,SIGNAL( choosearea(QMouseEvent * )),
3212
4115
           this,SLOT( slotPressEvent(QMouseEvent *)));
3213
4116
 
3214
 
  connect( style ,SIGNAL( activated(int)),this,SLOT(slotChangeStyle(int)));
3215
 
  connect( size ,SIGNAL( textChanged(const QString &)),this,SLOT(slotChangeStyle(const QString &)));
3216
 
  connect( size ,SIGNAL( activated(int)),this,SLOT(slotChangeStyle(int)));
3217
 
  preview->slotSelect();
3218
 
  pattern3->slotSelect();
3219
 
  style->setEnabled(false);
3220
 
  size->setEnabled(false);
3221
 
  preview->setPattern( black , 1, SolidLine );
3222
 
  this->resize( 400, 400 );
3223
 
}
3224
 
 
3225
 
 
3226
 
void CellLayoutPageBorder::cutomize_chosen_slot()
3227
 
{
3228
 
        if(customize->isChecked())
3229
 
                {
3230
 
                style->setEnabled(true);
3231
 
                size->setEnabled(true);
3232
 
                slotUnselect2( preview );
3233
 
                }
3234
 
        else
3235
 
                {
3236
 
                style->setEnabled(false);
3237
 
                size->setEnabled(false);
3238
 
                pattern3->slotSelect();
3239
 
                preview->setPattern( black , 1, SolidLine );
3240
 
                }
3241
 
}
3242
 
 
3243
 
void CellLayoutPageBorder::slotChangeStyle(const QString &)
3244
 
{
3245
 
slotChangeStyle(0);
3246
 
}
3247
 
 
3248
 
void CellLayoutPageBorder::slotChangeStyle(int)
3249
 
{
3250
 
  int index =style->currentItem();
 
4117
  connect( style, SIGNAL( activated(int)), this, SLOT(slotChangeStyle(int)));
 
4118
  connect( size, SIGNAL( textChanged(const QString &)),
 
4119
           this, SLOT(slotChangeStyle(const QString &)));
 
4120
  connect( size ,SIGNAL( activated(int)), this, SLOT(slotChangeStyle(int)));
 
4121
}
 
4122
 
 
4123
void CellFormatPageBorder::cutomize_chosen_slot()
 
4124
{
 
4125
  if ( customize->isChecked() )
 
4126
  {
 
4127
    style->setEnabled( true );
 
4128
    size->setEnabled( true );
 
4129
    slotUnselect2( preview );
 
4130
  }
 
4131
  else
 
4132
  {
 
4133
    style->setEnabled( false );
 
4134
    size->setEnabled( false );
 
4135
    pattern[2]->slotSelect();
 
4136
    preview->setPattern( black , 1, SolidLine );
 
4137
  }
 
4138
}
 
4139
 
 
4140
void CellFormatPageBorder::slotChangeStyle(const QString &)
 
4141
{
 
4142
  /* if they try putting text in the size box, then erase the line */
 
4143
  slotChangeStyle(0);
 
4144
}
 
4145
 
 
4146
void CellFormatPageBorder::slotChangeStyle(int)
 
4147
{
 
4148
  int index = style->currentItem();
3251
4149
  QString tmp;
3252
 
  int penSize=size->currentText().toInt();
3253
 
  if( !penSize)
3254
 
       preview->setPattern( preview->getColor(), penSize, NoPen );
3255
 
  else
3256
 
  {
3257
 
  switch(index)
3258
 
        {
3259
 
        case 0:
3260
 
                preview->setPattern( preview->getColor(), penSize, DotLine );
3261
 
                break;
3262
 
        case 1:
3263
 
                preview->setPattern( preview->getColor(), penSize, DashLine );
3264
 
                break;
3265
 
        case 2:
3266
 
                preview->setPattern( preview->getColor(), penSize, DashDotLine );
3267
 
                break;
3268
 
        case 3:
3269
 
                preview->setPattern( preview->getColor(), penSize, DashDotDotLine );
3270
 
                break;
3271
 
        case 4:
3272
 
                preview->setPattern( preview->getColor(), penSize, SolidLine );
3273
 
                break;
3274
 
        default:
3275
 
                kdDebug(36001)<<"Error in combobox\n";
3276
 
                break;
3277
 
        }
3278
 
 }
3279
 
 slotUnselect2(preview);
3280
 
}
3281
 
 
3282
 
QPixmap CellLayoutPageBorder::paintFormatPixmap(PenStyle _style)
3283
 
{
3284
 
    QPixmap pixmap( style->width(), 14 );
3285
 
    QPainter painter;
3286
 
    QPen pen;
3287
 
    pen=QPen( colorGroup().text(),1,_style);
3288
 
    painter.begin( &pixmap );
3289
 
    painter.fillRect( 0, 0, style->width(), 14, colorGroup().background() );
3290
 
    painter.setPen( pen );
3291
 
    painter.drawLine( 0, 7, style->width(), 7 );
3292
 
    painter.end();
3293
 
    return pixmap;
3294
 
}
3295
 
 
3296
 
void CellLayoutPageBorder::loadIcon( QString _pix,KSpreadBorderButton *_button)
3297
 
{
3298
 
    _button->setPixmap( QPixmap( KSBarIcon(_pix) ) );
3299
 
}
3300
 
 
3301
 
void CellLayoutPageBorder::applyOutline( int _left, int _top, int _right, int _bottom )
3302
 
{
3303
 
 
3304
 
    if( horizontal->isChanged())
3305
 
    {
3306
 
        QPen tmpPen( horizontal->getColor(),horizontal->getPenWidth(),horizontal->getPenStyle());
3307
 
        if( _bottom!=0x7FFF && _right!=0x7FFF)
3308
 
        {
3309
 
        for ( int x = _left; x <= _right; x++ )
3310
 
                {
3311
 
                for ( int y = _top+1; y <= _bottom; y++ )
3312
 
                        {
3313
 
                        KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x, y );
3314
 
                        if(!obj->isObscuringForced())
3315
 
                                obj->setTopBorderPen(tmpPen);
3316
 
                        }
3317
 
                }
3318
 
         }
3319
 
         else if( _bottom==0x7FFF )
3320
 
         {
3321
 
                KSpreadCell*c= dlg->getTable()->firstCell();
3322
 
                for( ;c; c = c->nextCell() )
3323
 
                {
3324
 
                        int col = c->column();
3325
 
                        if ( dlg->left <= col && dlg->right >= col
3326
 
                        &&!c->isObscuringForced())
3327
 
                        {
3328
 
                        c->clearProperty(KSpreadCell::PTopBorder);
3329
 
                        c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
3330
 
                        }
3331
 
                }
3332
 
 
3333
 
                for(int x=_left;x<=_right;x++)
3334
 
                {
3335
 
                        ColumnLayout *obj=dlg->getTable()->nonDefaultColumnLayout(x);
3336
 
                        obj->setTopBorderPen(tmpPen);
3337
 
                }
3338
 
 
3339
 
                RowLayout* rw =dlg->getTable()->firstRow();
3340
 
                for( ; rw; rw = rw->next() )
3341
 
                {
3342
 
                if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PTopBorder)  ))
3343
 
                        {
3344
 
                        for(int i=dlg->left;i<=dlg->right;i++)
3345
 
                                {
3346
 
                                KSpreadCell *cell = dlg->getTable()->cellAt( i,  rw->row());
3347
 
                                if ( cell->isDefault() )
3348
 
                                        {
3349
 
                                        cell = new KSpreadCell( dlg->getTable(), i,  rw->row() );
3350
 
                                        dlg->getTable()->insertCell( cell);
3351
 
                                        }
3352
 
                                cell->setTopBorderPen(tmpPen);
3353
 
                                }
3354
 
                        }
3355
 
                }
3356
 
         }
3357
 
         else if( _right==0x7FFF)
3358
 
         {
3359
 
                KSpreadCell*c= dlg->getTable()->firstCell();
3360
 
                for( ;c; c = c->nextCell() )
3361
 
                        {
3362
 
                        int row = c->row();
3363
 
                        if ( (dlg->top+1) <= row && dlg->bottom >= row
3364
 
                                &&!c->isObscuringForced())
3365
 
                                {
3366
 
                                 c->clearProperty(KSpreadCell::PTopBorder);
3367
 
                                 c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
3368
 
                                }
3369
 
                        }
3370
 
 
3371
 
                for(int y=_top+1;y<=_bottom;y++)
3372
 
                        {
3373
 
                        RowLayout *obj=dlg->getTable()->nonDefaultRowLayout(y);
3374
 
                        obj->setTopBorderPen(tmpPen);
3375
 
                        }
3376
 
        }
3377
 
    }
3378
 
    if( vertical->isChanged())
3379
 
    {
3380
 
    QPen tmpPen( vertical->getColor(),vertical->getPenWidth(),vertical->getPenStyle());
3381
 
    if( _bottom!=0x7FFF && _right!=0x7FFF)
3382
 
        {
3383
 
        for ( int x = _left+1; x <= _right; x++ )
3384
 
                {
3385
 
                for ( int y = _top; y <= _bottom; y++ )
3386
 
                        {
3387
 
                        KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x,y );
3388
 
                        if(!obj->isObscuringForced())
3389
 
                                obj->setLeftBorderPen( tmpPen );
3390
 
                        }
3391
 
                }
3392
 
        }
3393
 
        else if( _bottom==0x7FFF )
3394
 
        {
3395
 
                KSpreadCell*c= dlg->getTable()->firstCell();
3396
 
                for( ;c; c = c->nextCell() )
3397
 
                {
3398
 
                        int col = c->column();
3399
 
                        if ( dlg->left <= col && dlg->right >= col
3400
 
                        &&!c->isObscuringForced())
3401
 
                        {
3402
 
                        c->clearProperty(KSpreadCell::PLeftBorder);
3403
 
                        c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
3404
 
                        }
3405
 
                }
3406
 
 
3407
 
                for(int x=_left+1;x<=_right;x++)
3408
 
                        {
3409
 
                        ColumnLayout *obj=dlg->getTable()->nonDefaultColumnLayout(x);
3410
 
                        obj->setLeftBorderPen( tmpPen );
3411
 
                        }
3412
 
                RowLayout* rw =dlg->getTable()->firstRow();
3413
 
                for( ; rw; rw = rw->next() )
3414
 
                {
3415
 
                if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PLeftBorder)  ))
3416
 
                        {
3417
 
                        for(int i=dlg->left;i<=dlg->right;i++)
3418
 
                                {
3419
 
                                KSpreadCell *cell = dlg->getTable()->cellAt( i,  rw->row());
3420
 
                                if ( cell->isDefault() )
3421
 
                                        {
3422
 
                                        cell = new KSpreadCell( dlg->getTable(), i,  rw->row() );
3423
 
                                        dlg->getTable()->insertCell( cell);
3424
 
                                        }
3425
 
                                cell->setLeftBorderPen( tmpPen );
3426
 
                                }
3427
 
                        }
3428
 
                }
3429
 
        }
3430
 
         else if( _right==0x7FFF)
3431
 
         {
3432
 
                KSpreadCell*c= dlg->getTable()->firstCell();
3433
 
                for( ;c; c = c->nextCell() )
3434
 
                        {
3435
 
                        int row = c->row();
3436
 
                        if ( dlg->top <= row && dlg->bottom >= row
3437
 
                                &&!c->isObscuringForced())
3438
 
                                {
3439
 
                                c->clearProperty(KSpreadCell::PLeftBorder);
3440
 
                                c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
3441
 
                                }
3442
 
                        }
3443
 
 
3444
 
                for(int y=_top;y<=_bottom;y++)
3445
 
                        {
3446
 
                        RowLayout *obj=dlg->getTable()->nonDefaultRowLayout(y);
3447
 
                        obj->setLeftBorderPen( tmpPen );
3448
 
                        }
3449
 
 
3450
 
         }
3451
 
  }
3452
 
 if ( left->isChanged() )
3453
 
    {
3454
 
    QPen tmpPen( left->getColor(),left->getPenWidth(),left->getPenStyle());
3455
 
    if( _bottom!=0x7FFF && _right!=0x7FFF)
3456
 
        {
3457
 
        for ( int y = _top; y <= _bottom; y++ )
3458
 
                {
3459
 
                KSpreadCell *obj = dlg->getTable()->nonDefaultCell( _left,y );
3460
 
                if(!obj->isObscuringForced())
3461
 
                        obj->setLeftBorderPen( tmpPen );
3462
 
                }
3463
 
        }
3464
 
    else if( _bottom==0x7FFF )
3465
 
        {
3466
 
                KSpreadCell*c= dlg->getTable()->firstCell();
3467
 
                for( ;c; c = c->nextCell() )
3468
 
                {
3469
 
                        int col = c->column();
3470
 
                        if ( dlg->left == col && !c->isObscuringForced())
3471
 
                        {
3472
 
                        c->clearProperty(KSpreadCell::PLeftBorder);
3473
 
                        c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
3474
 
                        }
3475
 
                }
3476
 
                ColumnLayout *obj=dlg->getTable()->nonDefaultColumnLayout(_left);
3477
 
                obj->setLeftBorderPen( tmpPen );
3478
 
 
3479
 
                RowLayout* rw =dlg->getTable()->firstRow();
3480
 
                for( ; rw; rw = rw->next() )
3481
 
                {
3482
 
                        if (rw->row()==_left&& !rw->isDefault() && (rw->hasProperty(KSpreadCell::PLeftBorder)  ))
3483
 
                        {
3484
 
                        for(int i=dlg->left;i<=dlg->right;i++)
3485
 
                                {
3486
 
                                KSpreadCell *cell = dlg->getTable()->cellAt( i,  rw->row());
3487
 
                                if ( cell->isDefault() )
3488
 
                                        {
3489
 
                                        cell = new KSpreadCell( dlg->getTable(), i,  rw->row() );
3490
 
                                        dlg->getTable()->insertCell( cell);
3491
 
                                        }
3492
 
                                cell->setLeftBorderPen( tmpPen );
3493
 
                                }
3494
 
                        }
3495
 
                }
3496
 
        }
3497
 
    else if( _right==0x7FFF)
3498
 
        {
3499
 
        KSpreadCell*c= dlg->getTable()->firstCell();
3500
 
        for( ;c; c = c->nextCell() )
3501
 
                {
3502
 
                int row = c->row();
3503
 
                if ( dlg->top <= row && dlg->bottom >= row
3504
 
                                &&!c->isObscuringForced() && c->column()==1)
3505
 
                        {
3506
 
                        c->clearProperty(KSpreadCell::PLeftBorder);
3507
 
                        c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
3508
 
                        }
3509
 
                }
3510
 
        for ( int y = _top; y <= _bottom; y++ )
3511
 
                {
3512
 
                KSpreadCell *obj = dlg->getTable()->nonDefaultCell( 1,y );
3513
 
                if(!obj->isObscuringForced())
3514
 
                        obj->setLeftBorderPen( tmpPen );
3515
 
                }
3516
 
        }
3517
 
    }
3518
 
 if ( right->isChanged() )
3519
 
    {
3520
 
    bool once=false;
3521
 
    QPen tmpPen( right->getColor(),right->getPenWidth(),right->getPenStyle());
3522
 
    if( _bottom!=0x7FFF && _right!=0x7FFF)
3523
 
        {
3524
 
        for ( int y = _top; y <= _bottom; y++ )
3525
 
                {
3526
 
                KSpreadCell *obj = dlg->getTable()->nonDefaultCell( _right,y );
3527
 
                if(!obj->isObscuringForced())
3528
 
                        obj->setRightBorderPen(tmpPen);
3529
 
                else if(obj->isObscuringForced() && !once )
3530
 
                        {
3531
 
                        once=true;
3532
 
                        int moveX=obj->obscuringCellsColumn();
3533
 
                        int moveY=obj->obscuringCellsRow();
3534
 
                        obj = dlg->getTable()->nonDefaultCell( moveX,  moveY );
3535
 
                        obj->setRightBorderPen(tmpPen);
3536
 
                        }
3537
 
                }
3538
 
        }
3539
 
    else if(  _bottom==0x7FFF)
3540
 
        {
3541
 
                KSpreadCell*c= dlg->getTable()->firstCell();
3542
 
                for( ;c; c = c->nextCell() )
3543
 
                {
3544
 
                        int col = c->column();
3545
 
                        if ( dlg->right == col && !c->isObscuringForced())
3546
 
                        {
3547
 
                        c->clearProperty(KSpreadCell::PRightBorder);
3548
 
                        c->clearNoFallBackProperties( KSpreadCell::PRightBorder );
3549
 
                        }
3550
 
                }
3551
 
 
3552
 
        ColumnLayout *obj=dlg->getTable()->nonDefaultColumnLayout(_right);
3553
 
        obj->setRightBorderPen(tmpPen);
3554
 
 
3555
 
        RowLayout* rw =dlg->getTable()->firstRow();
3556
 
                for( ; rw; rw = rw->next() )
3557
 
                {
3558
 
                if (rw->row()==dlg->right&& !rw->isDefault() && (rw->hasProperty(KSpreadCell::PRightBorder)  ))
3559
 
                        {
3560
 
                        for(int i=dlg->left;i<=dlg->right;i++)
3561
 
                                {
3562
 
                                KSpreadCell *cell = dlg->getTable()->cellAt( i,  rw->row());
3563
 
                                if ( cell->isDefault() )
3564
 
                                        {
3565
 
                                        cell = new KSpreadCell( dlg->getTable(), i,  rw->row() );
3566
 
                                        dlg->getTable()->insertCell( cell);
3567
 
                                        }
3568
 
                                cell->setRightBorderPen(tmpPen);
3569
 
                                }
3570
 
                        }
3571
 
                }
3572
 
        }
3573
 
    else if(  _right==0x7FFF)
3574
 
        {
3575
 
        KSpreadCell*c= dlg->getTable()->firstCell();
3576
 
        for( ;c; c = c->nextCell() )
3577
 
                {
3578
 
                int row = c->row();
3579
 
                if ( dlg->top <= row && dlg->bottom >= row
3580
 
                                &&!c->isObscuringForced() && c->column()==0x7FFF)
3581
 
                        {
3582
 
                        c->clearProperty(KSpreadCell::PRightBorder);
3583
 
                        c->clearNoFallBackProperties( KSpreadCell::PRightBorder );
3584
 
                        }
3585
 
                }
3586
 
 
3587
 
        for ( int y = _top; y <= _bottom; y++ )
3588
 
                {
3589
 
                KSpreadCell *obj = dlg->getTable()->nonDefaultCell( _right,y );
3590
 
                if(!obj->isObscuringForced())
3591
 
                        obj->setRightBorderPen(tmpPen);
3592
 
                else if(obj->isObscuringForced() && !once )
3593
 
                        {
3594
 
                        once=true;
3595
 
                        int moveX=obj->obscuringCellsColumn();
3596
 
                        int moveY=obj->obscuringCellsRow();
3597
 
                        obj = dlg->getTable()->nonDefaultCell( moveX,  moveY );
3598
 
                        obj->setRightBorderPen(tmpPen);
3599
 
                        }
3600
 
                }
3601
 
        }
3602
 
    }
3603
 
 
3604
 
 if ( top->isChanged() )
3605
 
    {
3606
 
    QPen tmpPen( top->getColor(),top->getPenWidth(),top->getPenStyle());
3607
 
    if( _bottom!=0x7FFF && _right!=0x7FFF)
3608
 
        {
3609
 
        for ( int x = _left; x <= _right; x++ )
3610
 
                {
3611
 
                KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x,_top );
3612
 
                if(!obj->isObscuringForced())
3613
 
                        obj->setTopBorderPen( tmpPen );
3614
 
                }
3615
 
        }
3616
 
    else if( _bottom==0x7FFF)
3617
 
        {
3618
 
         for ( int x = _left; x <= _right; x++ )
3619
 
                {
3620
 
                KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x,_top );
3621
 
                if(!obj->isObscuringForced())
3622
 
                        obj->setTopBorderPen( tmpPen );
3623
 
                }
3624
 
        }
3625
 
    else if(  _right==0x7FFF)
3626
 
        {
3627
 
        KSpreadCell*c= dlg->getTable()->firstCell();
3628
 
        for( ;c; c = c->nextCell() )
3629
 
                {
3630
 
                int row = c->row();
3631
 
                if ( dlg->top <= row && dlg->bottom >= row
3632
 
                                &&!c->isObscuringForced())
3633
 
                        {
3634
 
                        c->clearProperty(KSpreadCell::PTopBorder);
3635
 
                        c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
3636
 
                        }
3637
 
                }
3638
 
 
3639
 
        RowLayout *obj=dlg->getTable()->nonDefaultRowLayout(_top-1);
3640
 
        obj->setBottomBorderPen( tmpPen );
3641
 
        }
3642
 
    }
3643
 
 
3644
 
 if ( bottom->isChanged() )
3645
 
    {
3646
 
    bool once = false;
3647
 
    QPen tmpPen( bottom->getColor(),bottom->getPenWidth(),bottom->getPenStyle());
3648
 
    if( _bottom!=0x7FFF && _right!=0x7FFF)
3649
 
        {
3650
 
        for ( int x = _left; x <= _right; x++ )
3651
 
                {
3652
 
                KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x,_bottom );
3653
 
                if(!obj->isObscuringForced())
3654
 
                        obj->setBottomBorderPen( tmpPen );
3655
 
                else if(obj->isObscuringForced() && !once )
3656
 
                        {
3657
 
                        once = true;
3658
 
                        int moveX=obj->obscuringCellsColumn();
3659
 
                        int moveY=obj->obscuringCellsRow();
3660
 
                        obj = dlg->getTable()->nonDefaultCell( moveX,  moveY );
3661
 
                        obj->setBottomBorderPen( tmpPen );
3662
 
                        }
3663
 
                }
3664
 
        }
3665
 
    else if( _bottom==0x7FFF)
3666
 
        {
3667
 
        for ( int x = _left; x <= _right; x++ )
3668
 
                {
3669
 
                KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x,_bottom );
3670
 
                if(!obj->isObscuringForced())
3671
 
                        obj->setBottomBorderPen( tmpPen );
3672
 
                else if(obj->isObscuringForced() && !once )
3673
 
                        {
3674
 
                        once = true;
3675
 
                        int moveX=obj->obscuringCellsColumn();
3676
 
                        int moveY=obj->obscuringCellsRow();
3677
 
                        obj = dlg->getTable()->nonDefaultCell( moveX,  moveY );
3678
 
                        obj->setBottomBorderPen( tmpPen );
3679
 
                        }
3680
 
                }
3681
 
        }
3682
 
    else if(  _right==0x7FFF)
3683
 
        {
3684
 
        KSpreadCell*c= dlg->getTable()->firstCell();
3685
 
        for( ;c; c = c->nextCell() )
3686
 
                {
3687
 
                int row = c->row();
3688
 
                if ( dlg->top <= row && dlg->bottom >= row
3689
 
                                &&!c->isObscuringForced())
3690
 
                        {
3691
 
                        c->clearProperty(KSpreadCell::PBottomBorder);
3692
 
                        c->clearNoFallBackProperties( KSpreadCell::PBottomBorder );
3693
 
                        }
3694
 
                }
3695
 
 
3696
 
        RowLayout *obj=dlg->getTable()->nonDefaultRowLayout(_bottom);
3697
 
        obj->setBottomBorderPen( tmpPen );
3698
 
        }
3699
 
    }
3700
 
 
3701
 
 QPen tmpPenFall( fallDiagonal->getColor(),fallDiagonal->getPenWidth(),fallDiagonal->getPenStyle());
3702
 
 QPen tmpPenGoUp( goUpDiagonal->getColor(),goUpDiagonal->getPenWidth(),goUpDiagonal->getPenStyle());
3703
 
 if( _bottom!=0x7FFF && _right!=0x7FFF)
3704
 
 {
3705
 
        for ( int x = _left; x <= _right; x++ )
3706
 
        {
3707
 
        for ( int y = _top; y <= _bottom; y++ )
3708
 
                {
3709
 
                KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x,y );
3710
 
                if(!obj->isObscuringForced())
3711
 
                        {
3712
 
                        if ( fallDiagonal->isChanged() )
3713
 
                                obj->setFallDiagonalPen( tmpPenFall );
3714
 
                        if ( goUpDiagonal->isChanged() )
3715
 
                                obj->setGoUpDiagonalPen( tmpPenGoUp );
3716
 
                        }
3717
 
                }
3718
 
        }
3719
 
 }
3720
 
 else if(  _bottom==0x7FFF)
3721
 
 {
3722
 
        KSpreadCell*c= dlg->getTable()->firstCell();
3723
 
        for( ;c; c = c->nextCell() )
3724
 
                {
3725
 
                int col = c->column();
3726
 
                if ( dlg->left <= col && dlg->right >= col
3727
 
                        &&!c->isObscuringForced())
3728
 
                        {
3729
 
                        if ( fallDiagonal->isChanged() )
3730
 
                                {
3731
 
                                c->clearProperty(KSpreadCell::PFallDiagonal);
3732
 
                                c->clearNoFallBackProperties( KSpreadCell::PFallDiagonal );
3733
 
                                }
3734
 
                        if ( goUpDiagonal->isChanged() )
3735
 
                                {
3736
 
                                c->clearProperty(KSpreadCell::PGoUpDiagonal);
3737
 
                                c->clearNoFallBackProperties( KSpreadCell::PGoUpDiagonal);
3738
 
                                }
3739
 
                        }
3740
 
                }
3741
 
 
3742
 
 for ( int x = _left; x <= _right; x++ )
3743
 
        {
3744
 
        ColumnLayout *obj=dlg->getTable()->nonDefaultColumnLayout(x);
3745
 
        if ( fallDiagonal->isChanged() )
3746
 
                obj->setFallDiagonalPen( tmpPenFall );
3747
 
        if ( goUpDiagonal->isChanged() )
3748
 
                obj->setGoUpDiagonalPen( tmpPenGoUp );
3749
 
        }
3750
 
 
3751
 
        RowLayout* rw =dlg->getTable()->firstRow();
3752
 
        for( ; rw; rw = rw->next() )
3753
 
        {
3754
 
                if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PFallDiagonal)
3755
 
                ||rw->hasProperty(KSpreadCell::PGoUpDiagonal) ))
3756
 
                {
3757
 
                for(int i=dlg->left;i<=dlg->right;i++)
3758
 
                        {
3759
 
                        KSpreadCell *cell = dlg->getTable()->cellAt( i,  rw->row());
3760
 
                        if ( cell->isDefault() )
3761
 
                                {
3762
 
                                cell = new KSpreadCell( dlg->getTable(), i,  rw->row() );
3763
 
                                dlg->getTable()->insertCell( cell);
3764
 
                                }
3765
 
                        cell->setFallDiagonalPen( tmpPenFall );
3766
 
                        cell->setGoUpDiagonalPen( tmpPenGoUp );
3767
 
                        }
3768
 
                }
3769
 
        }
3770
 
 }
3771
 
 else if(  _right==0x7FFF)
3772
 
 {
3773
 
        KSpreadCell*c= dlg->getTable()->firstCell();
3774
 
        for( ;c; c = c->nextCell() )
3775
 
                {
3776
 
                int row = c->row();
3777
 
                if ( dlg->top <= row && dlg->bottom >= row
3778
 
                                &&!c->isObscuringForced())
3779
 
                        {
3780
 
                        if ( fallDiagonal->isChanged() )
3781
 
                                {
3782
 
                                c->clearProperty(KSpreadCell::PFallDiagonal);
3783
 
                                c->clearNoFallBackProperties( KSpreadCell::PFallDiagonal );
3784
 
                                }
3785
 
                        if ( goUpDiagonal->isChanged() )
3786
 
                                {
3787
 
                                c->clearProperty(KSpreadCell::PGoUpDiagonal);
3788
 
                                c->clearNoFallBackProperties( KSpreadCell::PGoUpDiagonal);
3789
 
                                }
3790
 
                        }
3791
 
                }
3792
 
 
3793
 
   for ( int y = _top; y <= _bottom; y++ )
3794
 
        {
3795
 
        RowLayout *obj=dlg->getTable()->nonDefaultRowLayout(y);
3796
 
        if ( fallDiagonal->isChanged() )
3797
 
                obj->setFallDiagonalPen( tmpPenFall );
3798
 
        if ( goUpDiagonal->isChanged() )
3799
 
                obj->setGoUpDiagonalPen( tmpPenGoUp );
3800
 
        }
3801
 
 }
3802
 
}
3803
 
 
3804
 
void CellLayoutPageBorder::slotSetColorButton( const QColor &_color )
 
4150
  int penSize = size->currentText().toInt();
 
4151
  if ( !penSize)
 
4152
  {
 
4153
    preview->setPattern( preview->getColor(), penSize, NoPen );
 
4154
  }
 
4155
  else
 
4156
  {
 
4157
    switch(index)
 
4158
    {
 
4159
    case 0:
 
4160
      preview->setPattern( preview->getColor(), penSize, DotLine );
 
4161
      break;
 
4162
    case 1:
 
4163
      preview->setPattern( preview->getColor(), penSize, DashLine );
 
4164
      break;
 
4165
    case 2:
 
4166
      preview->setPattern( preview->getColor(), penSize, DashDotLine );
 
4167
      break;
 
4168
    case 3:
 
4169
      preview->setPattern( preview->getColor(), penSize, DashDotDotLine );
 
4170
      break;
 
4171
    case 4:
 
4172
      preview->setPattern( preview->getColor(), penSize, SolidLine );
 
4173
      break;
 
4174
    default:
 
4175
      kdDebug(36001)<<"Error in combobox\n";
 
4176
      break;
 
4177
    }
 
4178
  }
 
4179
  slotUnselect2(preview);
 
4180
}
 
4181
 
 
4182
QPixmap CellFormatPageBorder::paintFormatPixmap(PenStyle _style)
 
4183
{
 
4184
  QPixmap pixmap( style->width(), 14 );
 
4185
  QPainter painter;
 
4186
  QPen pen;
 
4187
  pen=QPen( colorGroup().text(),1,_style);
 
4188
  painter.begin( &pixmap );
 
4189
  painter.fillRect( 0, 0, style->width(), 14, colorGroup().background() );
 
4190
  painter.setPen( pen );
 
4191
  painter.drawLine( 0, 7, style->width(), 7 );
 
4192
  painter.end();
 
4193
  return pixmap;
 
4194
}
 
4195
 
 
4196
void CellFormatPageBorder::loadIcon( QString _pix, KSpreadBorderButton *_button)
 
4197
{
 
4198
  _button->setPixmap( QPixmap( KSBarIcon(_pix) ) );
 
4199
}
 
4200
 
 
4201
void CellFormatPageBorder::applyOutline()
 
4202
{
 
4203
  if (borderButtons[BorderType_Horizontal]->isChanged())
 
4204
    applyHorizontalOutline();
 
4205
 
 
4206
  if (borderButtons[BorderType_Vertical]->isChanged())
 
4207
    applyVerticalOutline();
 
4208
 
 
4209
  if ( borderButtons[BorderType_Left]->isChanged() )
 
4210
    applyLeftOutline();
 
4211
 
 
4212
  if ( borderButtons[BorderType_Right]->isChanged() )
 
4213
    applyRightOutline();
 
4214
 
 
4215
  if ( borderButtons[BorderType_Top]->isChanged() )
 
4216
    applyTopOutline();
 
4217
 
 
4218
  if ( borderButtons[BorderType_Bottom]->isChanged() )
 
4219
    applyBottomOutline();
 
4220
 
 
4221
  if ( borderButtons[BorderType_RisingDiagonal]->isChanged() ||
 
4222
       borderButtons[BorderType_FallingDiagonal]->isChanged() )
 
4223
    applyDiagonalOutline();
 
4224
}
 
4225
 
 
4226
void CellFormatPageBorder::applyTopOutline()
 
4227
{
 
4228
  KSpreadBorderButton * top = borderButtons[BorderType_Top];
 
4229
 
 
4230
  QPen tmpPen( top->getColor(), top->getPenWidth(), top->getPenStyle());
 
4231
 
 
4232
  if ( dlg->getStyle() )
 
4233
  {
 
4234
    dlg->getStyle()->changeTopBorderPen( tmpPen );
 
4235
  }
 
4236
  else if ( !dlg->isRowSelected )
 
4237
  {
 
4238
    /* if a column is selected then _top will just be row 1 so there's no special
 
4239
       handling */
 
4240
 
 
4241
    for ( int x = dlg->left; x <= dlg->right; x++ )
 
4242
    {
 
4243
      KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x, dlg->top );
 
4244
      if ( obj->isObscuringForced() /* && dlg->isSingleCell() */ )
 
4245
        obj = obj->obscuringCells().first();
 
4246
      obj->setTopBorderPen( tmpPen );
 
4247
    }
 
4248
  }
 
4249
  else if ( dlg->isRowSelected )
 
4250
  {
 
4251
    KSpreadCell* c = NULL;
 
4252
    for ( c = table->getFirstCellRow(dlg->top); c != NULL;
 
4253
         c = table->getNextCellRight(c->column(), c->row()) )
 
4254
    {
 
4255
      c->clearProperty(KSpreadCell::PTopBorder);
 
4256
      c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
 
4257
    }
 
4258
 
 
4259
    RowFormat *obj=dlg->getTable()->nonDefaultRowFormat(dlg->top-1);
 
4260
    obj->setBottomBorderPen( tmpPen );
 
4261
  }
 
4262
}
 
4263
 
 
4264
void CellFormatPageBorder::applyBottomOutline()
 
4265
{
 
4266
  KSpreadSheet * table = dlg->getTable();
 
4267
  KSpreadBorderButton * bottom = borderButtons[BorderType_Bottom];
 
4268
 
 
4269
  QPen tmpPen( bottom->getColor(), bottom->getPenWidth(), bottom->getPenStyle() );
 
4270
 
 
4271
  if ( dlg->getStyle() )
 
4272
    dlg->getStyle()->changeBottomBorderPen( tmpPen );
 
4273
  else if ( !dlg->isRowSelected && !dlg->isColumnSelected )
 
4274
  {
 
4275
    for ( int x = dlg->left; x <= dlg->right; x++ )
 
4276
    {
 
4277
      KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x, dlg->bottom );
 
4278
      if ( obj->isObscuringForced() /* && dlg->isSingleCell() */ )
 
4279
        obj = obj->obscuringCells().first();
 
4280
      obj->setBottomBorderPen( tmpPen );
 
4281
    }
 
4282
  }
 
4283
  else if ( dlg->isRowSelected )
 
4284
  {
 
4285
    KSpreadCell* c = NULL;
 
4286
    for ( c = table->getFirstCellRow(dlg->bottom); c != NULL;
 
4287
         c = table->getNextCellRight(c->column(), c->row()) )
 
4288
    {
 
4289
      c->clearProperty(KSpreadCell::PBottomBorder);
 
4290
      c->clearNoFallBackProperties( KSpreadCell::PBottomBorder );
 
4291
    }
 
4292
 
 
4293
    RowFormat *obj=dlg->getTable()->nonDefaultRowFormat(dlg->bottom);
 
4294
    obj->setBottomBorderPen( tmpPen );
 
4295
  }
 
4296
}
 
4297
 
 
4298
void CellFormatPageBorder::applyLeftOutline()
 
4299
{
 
4300
  KSpreadBorderButton * left = borderButtons[BorderType_Left];
 
4301
  QPen tmpPen( left->getColor(), left->getPenWidth(), left->getPenStyle() );
 
4302
 
 
4303
  if ( dlg->getStyle() )
 
4304
    dlg->getStyle()->changeLeftBorderPen( tmpPen );  
 
4305
  else if ( !dlg->isColumnSelected )
 
4306
  {
 
4307
    for ( int y = dlg->top; y <= dlg->bottom; y++ )
 
4308
    {
 
4309
      KSpreadCell *obj = dlg->getTable()->nonDefaultCell( dlg->left, y );
 
4310
      if ( obj->isObscuringForced() /* && dlg->isSingleCell() */ )
 
4311
        continue;
 
4312
      obj->setLeftBorderPen( tmpPen );
 
4313
    }
 
4314
  }
 
4315
  else
 
4316
  {
 
4317
    KSpreadCell* c = NULL;
 
4318
    for ( c = table->getFirstCellColumn(dlg->left); c != NULL;
 
4319
         c = table->getNextCellDown(c->column(), c->row()) )
 
4320
    {
 
4321
      c->clearProperty(KSpreadCell::PLeftBorder);
 
4322
      c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
 
4323
    }
 
4324
    ColumnFormat *obj=dlg->getTable()->nonDefaultColumnFormat(dlg->left);
 
4325
    obj->setLeftBorderPen( tmpPen );
 
4326
 
 
4327
    RowFormat* rw =dlg->getTable()->firstRow();
 
4328
    for ( ; rw; rw = rw->next() )
 
4329
    {
 
4330
      if (rw->row()==dlg->left&& !rw->isDefault() &&
 
4331
          (rw->hasProperty(KSpreadCell::PLeftBorder)  ))
 
4332
      {
 
4333
        for ( int i=dlg->left;i<=dlg->right;i++)
 
4334
        {
 
4335
          KSpreadCell *cell =
 
4336
            dlg->getTable()->nonDefaultCell( i, rw->row() );
 
4337
          if ( cell->isObscuringForced() && dlg->isSingleCell() )
 
4338
            continue;
 
4339
          cell->setLeftBorderPen( tmpPen );
 
4340
        }
 
4341
      }
 
4342
    }
 
4343
  }
 
4344
}
 
4345
 
 
4346
void CellFormatPageBorder::applyRightOutline()
 
4347
{
 
4348
  KSpreadBorderButton* right = borderButtons[BorderType_Right];
 
4349
  QPen tmpPen( right->getColor(), right->getPenWidth(), right->getPenStyle() );
 
4350
 
 
4351
  if ( dlg->getStyle() )
 
4352
    dlg->getStyle()->changeRightBorderPen( tmpPen );
 
4353
  else if ( (!dlg->isRowSelected) && (!dlg->isColumnSelected) )
 
4354
  {
 
4355
    for ( int y = dlg->top; y <= dlg->bottom; y++ )
 
4356
    {
 
4357
      KSpreadCell * obj = dlg->getTable()->nonDefaultCell( dlg->right, y );
 
4358
      if ( obj->isObscuringForced() /* && dlg->isSingleCell() */ )
 
4359
        obj = obj->obscuringCells().first();
 
4360
      obj->setRightBorderPen( tmpPen );
 
4361
    }
 
4362
  }
 
4363
  else if (  dlg->isColumnSelected )
 
4364
  {
 
4365
    KSpreadCell* c = NULL;
 
4366
    for ( c = table->getFirstCellColumn(dlg->right); c != NULL;
 
4367
         c = table->getNextCellDown(c->column(), c->row()) )
 
4368
    {
 
4369
      c->clearProperty(KSpreadCell::PRightBorder);
 
4370
      c->clearNoFallBackProperties( KSpreadCell::PRightBorder );
 
4371
    }
 
4372
 
 
4373
    ColumnFormat *obj=dlg->getTable()->nonDefaultColumnFormat(dlg->right);
 
4374
    obj->setRightBorderPen(tmpPen);
 
4375
 
 
4376
    RowFormat* rw =dlg->getTable()->firstRow();
 
4377
    for ( ; rw; rw = rw->next() )
 
4378
    {
 
4379
      if (rw->row()==dlg->right&& !rw->isDefault() &&
 
4380
          (rw->hasProperty(KSpreadCell::PRightBorder)  ))
 
4381
      {
 
4382
        for ( int i=dlg->left;i<=dlg->right;i++)
 
4383
        {
 
4384
          KSpreadCell *cell =
 
4385
            dlg->getTable()->nonDefaultCell( i, rw->row() );
 
4386
          if ( cell->isObscuringForced() /* && dlg->isSingleCell() */ )
 
4387
            cell = cell->obscuringCells().first();
 
4388
          cell->setRightBorderPen( tmpPen );
 
4389
        }
 
4390
      }
 
4391
    }
 
4392
  }
 
4393
}
 
4394
 
 
4395
void CellFormatPageBorder::applyDiagonalOutline()
 
4396
{
 
4397
  KSpreadBorderButton * fallDiagonal = borderButtons[BorderType_FallingDiagonal];
 
4398
  KSpreadBorderButton * goUpDiagonal = borderButtons[BorderType_RisingDiagonal];
 
4399
  QPen tmpPenFall( fallDiagonal->getColor(), fallDiagonal->getPenWidth(),
 
4400
                   fallDiagonal->getPenStyle());
 
4401
  QPen tmpPenGoUp( goUpDiagonal->getColor(), goUpDiagonal->getPenWidth(),
 
4402
                   goUpDiagonal->getPenStyle());
 
4403
  
 
4404
  if ( dlg->getStyle() )
 
4405
  {
 
4406
    if ( fallDiagonal->isChanged() )
 
4407
      dlg->getStyle()->changeFallBorderPen( tmpPenFall );
 
4408
    if ( goUpDiagonal->isChanged() )
 
4409
      dlg->getStyle()->changeGoUpBorderPen( tmpPenGoUp );
 
4410
  }
 
4411
  else if ( (!dlg->isRowSelected) && (!dlg->isColumnSelected) )
 
4412
  {
 
4413
    for ( int x = dlg->left; x <= dlg->right; x++ )
 
4414
    {
 
4415
      for ( int y = dlg->top; y <= dlg->bottom; y++ )
 
4416
      {
 
4417
        KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x, y );
 
4418
        if ( fallDiagonal->isChanged() )
 
4419
          obj->setFallDiagonalPen( tmpPenFall );
 
4420
        if ( goUpDiagonal->isChanged() )
 
4421
          obj->setGoUpDiagonalPen( tmpPenGoUp );
 
4422
      }
 
4423
    }
 
4424
  }
 
4425
  else if ( dlg->isColumnSelected )
 
4426
  {
 
4427
    KSpreadCell* c = NULL;
 
4428
    for (int col = dlg->left; col <= dlg->right; col++)
 
4429
    {
 
4430
      for (c = table->getFirstCellColumn(col); c != NULL;
 
4431
           c = table->getNextCellDown(c->column(), c->row()))
 
4432
      {
 
4433
        if ( fallDiagonal->isChanged() )
 
4434
        {
 
4435
          c->clearProperty(KSpreadCell::PFallDiagonal);
 
4436
          c->clearNoFallBackProperties( KSpreadCell::PFallDiagonal );
 
4437
        }
 
4438
        if ( goUpDiagonal->isChanged() )
 
4439
        {
 
4440
          c->clearProperty(KSpreadCell::PGoUpDiagonal);
 
4441
          c->clearNoFallBackProperties( KSpreadCell::PGoUpDiagonal);
 
4442
        }
 
4443
      }
 
4444
 
 
4445
      ColumnFormat *obj=dlg->getTable()->nonDefaultColumnFormat(col);
 
4446
      if ( fallDiagonal->isChanged() )
 
4447
        obj->setFallDiagonalPen( tmpPenFall );
 
4448
      if ( goUpDiagonal->isChanged() )
 
4449
        obj->setGoUpDiagonalPen( tmpPenGoUp );
 
4450
    }
 
4451
 
 
4452
 
 
4453
    RowFormat* rw =dlg->getTable()->firstRow();
 
4454
    for ( ; rw; rw = rw->next() )
 
4455
    {
 
4456
      if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PFallDiagonal)
 
4457
                                ||rw->hasProperty(KSpreadCell::PGoUpDiagonal) ))
 
4458
      {
 
4459
        for ( int i=dlg->left;i<=dlg->right;i++)
 
4460
        {
 
4461
          KSpreadCell *cell =
 
4462
            dlg->getTable()->nonDefaultCell( i, rw->row() );
 
4463
          if ( cell->isObscuringForced() && dlg->isSingleCell() )
 
4464
            continue;
 
4465
          cell->setFallDiagonalPen( tmpPenFall );
 
4466
          cell->setGoUpDiagonalPen( tmpPenGoUp );
 
4467
        }
 
4468
      }
 
4469
    }
 
4470
  }
 
4471
  else if ( dlg->isRowSelected )
 
4472
  {
 
4473
    KSpreadCell* c = NULL;
 
4474
    for (int row = dlg->top; row <= dlg->bottom; row++)
 
4475
    {
 
4476
      for (c = table->getFirstCellRow(row); c != NULL;
 
4477
           c = table->getNextCellRight(c->column(), c->row()))
 
4478
      {
 
4479
        if ( fallDiagonal->isChanged() )
 
4480
        {
 
4481
          c->clearProperty(KSpreadCell::PFallDiagonal);
 
4482
          c->clearNoFallBackProperties( KSpreadCell::PFallDiagonal );
 
4483
        }
 
4484
        if ( goUpDiagonal->isChanged() )
 
4485
        {
 
4486
          c->clearProperty(KSpreadCell::PGoUpDiagonal);
 
4487
          c->clearNoFallBackProperties( KSpreadCell::PGoUpDiagonal);
 
4488
        }
 
4489
      }
 
4490
 
 
4491
      RowFormat *obj=dlg->getTable()->nonDefaultRowFormat(row);
 
4492
      if ( fallDiagonal->isChanged() )
 
4493
        obj->setFallDiagonalPen( tmpPenFall );
 
4494
      if ( goUpDiagonal->isChanged() )
 
4495
        obj->setGoUpDiagonalPen( tmpPenGoUp );
 
4496
    }
 
4497
  }
 
4498
}
 
4499
 
 
4500
void CellFormatPageBorder::applyHorizontalOutline()
 
4501
{
 
4502
  QPen tmpPen( borderButtons[BorderType_Horizontal]->getColor(),
 
4503
               borderButtons[BorderType_Horizontal]->getPenWidth(),
 
4504
               borderButtons[BorderType_Horizontal]->getPenStyle());
 
4505
 
 
4506
  if ( dlg->getStyle() )
 
4507
  {
 
4508
    dlg->getStyle()->changeTopBorderPen( tmpPen );
 
4509
  }
 
4510
  else if ( (!dlg->isRowSelected) && (!dlg->isColumnSelected) )
 
4511
  {
 
4512
    for ( int x = dlg->left; x <= dlg->right; x++ )
 
4513
    {
 
4514
      for ( int y = dlg->top + 1; y <= dlg->bottom; y++ )
 
4515
      {
 
4516
        KSpreadCell * obj = dlg->getTable()->nonDefaultCell( x, y );
 
4517
        obj->setTopBorderPen( tmpPen );
 
4518
      }
 
4519
    }
 
4520
  }
 
4521
  else if ( dlg->isColumnSelected )
 
4522
  {
 
4523
    KSpreadCell* c = NULL;
 
4524
    for (int col = dlg->left; col <= dlg->right; col++)
 
4525
    {
 
4526
      for (c = table->getFirstCellColumn(col); c != NULL;
 
4527
           c = table->getNextCellDown(c->column(), c->row()))
 
4528
      {
 
4529
        c->clearProperty(KSpreadCell::PTopBorder);
 
4530
        c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
 
4531
      }
 
4532
 
 
4533
      ColumnFormat *obj=dlg->getTable()->nonDefaultColumnFormat(col);
 
4534
      obj->setTopBorderPen(tmpPen);
 
4535
    }
 
4536
 
 
4537
    RowFormat* rw =dlg->getTable()->firstRow();
 
4538
    for ( ; rw; rw = rw->next() )
 
4539
    {
 
4540
      if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PTopBorder)  ))
 
4541
      {
 
4542
        for ( int i=dlg->left;i<=dlg->right;i++)
 
4543
        {
 
4544
          KSpreadCell *cell =
 
4545
            dlg->getTable()->nonDefaultCell( i, rw->row() );
 
4546
          cell->setTopBorderPen(tmpPen);
 
4547
        }
 
4548
      }
 
4549
    }
 
4550
  }
 
4551
  else if ( dlg->isRowSelected )
 
4552
  {
 
4553
    KSpreadCell* c = NULL;
 
4554
    for (int row = dlg->top + 1; row <= dlg->bottom; row++)
 
4555
    {
 
4556
      for (c = table->getFirstCellRow(row); c != NULL;
 
4557
           c = table->getNextCellRight(c->column(), c->row()))
 
4558
      {
 
4559
        c->clearProperty(KSpreadCell::PTopBorder);
 
4560
        c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
 
4561
      }
 
4562
 
 
4563
      RowFormat *obj = dlg->getTable()->nonDefaultRowFormat(row);
 
4564
      obj->setTopBorderPen(tmpPen);
 
4565
    }
 
4566
  }
 
4567
}
 
4568
 
 
4569
void CellFormatPageBorder::applyVerticalOutline()
 
4570
{
 
4571
  KSpreadBorderButton* vertical = borderButtons[BorderType_Vertical];
 
4572
  QPen tmpPen( vertical->getColor(), vertical->getPenWidth(),
 
4573
               vertical->getPenStyle());
 
4574
 
 
4575
  if ( dlg->getStyle() )
 
4576
    dlg->getStyle()->changeLeftBorderPen( tmpPen );  
 
4577
  else if ( (!dlg->isRowSelected) && (!dlg->isColumnSelected) )
 
4578
  {
 
4579
    for ( int x = dlg->left+1; x <= dlg->right; x++ )
 
4580
    {
 
4581
      for ( int y = dlg->top; y <= dlg->bottom; y++ )
 
4582
      {
 
4583
        KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x, y );
 
4584
        obj->setLeftBorderPen( tmpPen );
 
4585
      }
 
4586
    }
 
4587
  }
 
4588
  else if ( dlg->isColumnSelected )
 
4589
  {
 
4590
    KSpreadCell* c = NULL;
 
4591
    for (int col = dlg->left + 1; col <= dlg->right; ++col)
 
4592
    {
 
4593
      for (c = table->getFirstCellColumn(col); c != NULL;
 
4594
           c = table->getNextCellDown(c->column(), c->row()))
 
4595
      {
 
4596
        c->clearProperty(KSpreadCell::PLeftBorder);
 
4597
        c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
 
4598
      }
 
4599
      ColumnFormat *obj=dlg->getTable()->nonDefaultColumnFormat(col);
 
4600
      obj->setLeftBorderPen( tmpPen );
 
4601
    }
 
4602
 
 
4603
    RowFormat * rw = dlg->getTable()->firstRow();
 
4604
    for ( ; rw; rw = rw->next() )
 
4605
    {
 
4606
      if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PLeftBorder)  ))
 
4607
      {
 
4608
        for ( int i = dlg->left + 1; i <= dlg->right; ++i )
 
4609
        {
 
4610
          KSpreadCell * cell =
 
4611
            dlg->getTable()->nonDefaultCell( i, rw->row() );
 
4612
          cell->setLeftBorderPen( tmpPen );
 
4613
        }
 
4614
      }
 
4615
    }
 
4616
  }
 
4617
  else if ( dlg->isRowSelected )
 
4618
  {
 
4619
    KSpreadCell* c = NULL;
 
4620
    for (int row = dlg->top; row <= dlg->bottom; row++)
 
4621
    {
 
4622
      for (c = table->getFirstCellRow(row); c != NULL;
 
4623
           c = table->getNextCellRight(c->column(), c->row()))
 
4624
      {
 
4625
        c->clearProperty(KSpreadCell::PLeftBorder);
 
4626
        c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
 
4627
      }
 
4628
      RowFormat *obj=dlg->getTable()->nonDefaultRowFormat(row);
 
4629
      obj->setLeftBorderPen( tmpPen );
 
4630
    }
 
4631
  }
 
4632
}
 
4633
 
 
4634
 
 
4635
void CellFormatPageBorder::slotSetColorButton( const QColor &_color )
3805
4636
{
3806
4637
    currentColor = _color;
3807
4638
 
3808
 
    pattern1->setColor( currentColor );
3809
 
    pattern2->setColor( currentColor );
3810
 
    pattern3->setColor( currentColor );
3811
 
    pattern4->setColor( currentColor );
3812
 
    pattern5->setColor( currentColor );
3813
 
    pattern6->setColor( currentColor );
3814
 
    pattern7->setColor( currentColor );
3815
 
    pattern8->setColor( currentColor );
3816
 
    pattern9->setColor( currentColor );
3817
 
    pattern10->setColor( currentColor );
 
4639
    for ( int i = 0; i < NUM_BORDER_PATTERNS; ++i )
 
4640
    {
 
4641
      pattern[i]->setColor( currentColor );
 
4642
    }
3818
4643
    preview->setColor( currentColor );
3819
 
 
3820
4644
}
3821
4645
 
3822
 
void CellLayoutPageBorder::slotUnselect2( KSpreadPatternSelect *_p )
 
4646
void CellFormatPageBorder::slotUnselect2( KSpreadPatternSelect *_p )
3823
4647
{
3824
 
    if ( pattern1 != _p )
3825
 
        pattern1->slotUnselect();
3826
 
    if ( pattern2 != _p )
3827
 
        pattern2->slotUnselect();
3828
 
    if ( pattern3 != _p )
3829
 
        pattern3->slotUnselect();
3830
 
    if ( pattern4 != _p )
3831
 
        pattern4->slotUnselect();
3832
 
    if ( pattern5 != _p )
3833
 
        pattern5->slotUnselect();
3834
 
    if ( pattern6 != _p )
3835
 
        pattern6->slotUnselect();
3836
 
    if ( pattern7 != _p )
3837
 
        pattern7->slotUnselect();
3838
 
    if ( pattern8 != _p )
3839
 
        pattern8->slotUnselect();
3840
 
    if ( pattern9 != _p )
3841
 
        pattern9->slotUnselect();
3842
 
    if ( pattern10 != _p )
3843
 
        pattern10->slotUnselect();
 
4648
    for ( int i = 0; i < NUM_BORDER_PATTERNS; ++i )
 
4649
    {
 
4650
      if ( pattern[i] != _p )
 
4651
      {
 
4652
        pattern[i]->slotUnselect();
 
4653
      }
 
4654
    }
3844
4655
    preview->setPattern( _p->getColor(), _p->getPenWidth(), _p->getPenStyle() );
3845
4656
}
3846
4657
 
3847
 
void CellLayoutPageBorder::preselect( KSpreadBorderButton *_p)
 
4658
void CellFormatPageBorder::preselect( KSpreadBorderButton *_p )
3848
4659
{
 
4660
  KSpreadBorderButton* top = borderButtons[BorderType_Top];
 
4661
  KSpreadBorderButton* bottom = borderButtons[BorderType_Bottom];
 
4662
  KSpreadBorderButton* left = borderButtons[BorderType_Left];
 
4663
  KSpreadBorderButton* right = borderButtons[BorderType_Right];
 
4664
  KSpreadBorderButton* vertical = borderButtons[BorderType_Vertical];
 
4665
  KSpreadBorderButton* horizontal = borderButtons[BorderType_Horizontal];
 
4666
  KSpreadBorderButton* remove = shortcutButtons[BorderShortcutType_Remove];
 
4667
  KSpreadBorderButton* outline = shortcutButtons[BorderShortcutType_Outline];
 
4668
  KSpreadBorderButton* all = shortcutButtons[BorderShortcutType_All];
 
4669
 
3849
4670
  _p->setOn(false);
3850
 
  if(_p==remove)
3851
 
        {
3852
 
         if(left->isOn())
3853
 
                 left->unselect();
3854
 
 
3855
 
         if(right->isOn())
3856
 
                 right->unselect();
3857
 
 
3858
 
          if(top->isOn())
3859
 
                 top->unselect();
3860
 
 
3861
 
          if(bottom->isOn())
3862
 
                 bottom->unselect();
3863
 
 
3864
 
          if(fallDiagonal->isOn())
3865
 
                 fallDiagonal->unselect();
3866
 
 
3867
 
         if(goUpDiagonal->isOn())
3868
 
                 goUpDiagonal->unselect();
3869
 
 
3870
 
          if(vertical->isOn())
3871
 
                 vertical->unselect();
3872
 
 
3873
 
          if(horizontal->isOn())
3874
 
                 horizontal->unselect();
3875
 
        }
3876
 
  if(_p==outline)
3877
 
        {
3878
 
        top->setOn(true);
3879
 
        top->setPenWidth(preview->getPenWidth());
3880
 
        top->setPenStyle(preview->getPenStyle());
3881
 
        top->setColor( currentColor );
3882
 
        top->setChanged(true);
3883
 
        bottom->setOn(true);
3884
 
        bottom->setPenWidth(preview->getPenWidth());
3885
 
        bottom->setPenStyle(preview->getPenStyle());
3886
 
        bottom->setColor( currentColor );
3887
 
        bottom->setChanged(true);
3888
 
        left->setOn(true);
3889
 
        left->setPenWidth(preview->getPenWidth());
3890
 
        left->setPenStyle(preview->getPenStyle());
3891
 
        left->setColor( currentColor );
3892
 
        left->setChanged(true);
3893
 
        right->setOn(true);
3894
 
        right->setPenWidth(preview->getPenWidth());
3895
 
        right->setPenStyle(preview->getPenStyle());
3896
 
        right->setColor( currentColor );
3897
 
        right->setChanged(true);
3898
 
        }
3899
 
  if(_p==all)
3900
 
        {
3901
 
        if(dlg->oneRow==false)
3902
 
                {
3903
 
                horizontal->setOn(true);
3904
 
                horizontal->setPenWidth(preview->getPenWidth());
3905
 
                horizontal->setPenStyle(preview->getPenStyle());
3906
 
                horizontal->setColor( currentColor );
3907
 
                horizontal->setChanged(true);
3908
 
                }
3909
 
        if(dlg->oneCol==false)
3910
 
                {
3911
 
                vertical->setOn(true);
3912
 
                vertical->setPenWidth(preview->getPenWidth());
3913
 
                vertical->setPenStyle(preview->getPenStyle());
3914
 
                vertical->setColor( currentColor );
3915
 
                vertical->setChanged(true);
3916
 
                }
3917
 
        }
 
4671
  if (_p == remove)
 
4672
  {
 
4673
    for (int i=BorderType_Top; i < BorderType_END; i++)
 
4674
    {
 
4675
      if (borderButtons[i]->isOn())
 
4676
      {
 
4677
        borderButtons[i]->unselect();
 
4678
      }
 
4679
    }
 
4680
  }
 
4681
  if (_p==outline)
 
4682
  {
 
4683
    top->setOn(true);
 
4684
    top->setPenWidth(preview->getPenWidth());
 
4685
    top->setPenStyle(preview->getPenStyle());
 
4686
    top->setColor( currentColor );
 
4687
    top->setChanged(true);
 
4688
    bottom->setOn(true);
 
4689
    bottom->setPenWidth(preview->getPenWidth());
 
4690
    bottom->setPenStyle(preview->getPenStyle());
 
4691
    bottom->setColor( currentColor );
 
4692
    bottom->setChanged(true);
 
4693
    left->setOn(true);
 
4694
    left->setPenWidth(preview->getPenWidth());
 
4695
    left->setPenStyle(preview->getPenStyle());
 
4696
    left->setColor( currentColor );
 
4697
    left->setChanged(true);
 
4698
    right->setOn(true);
 
4699
    right->setPenWidth(preview->getPenWidth());
 
4700
    right->setPenStyle(preview->getPenStyle());
 
4701
    right->setColor( currentColor );
 
4702
    right->setChanged(true);
 
4703
  }
 
4704
  if (_p==all)
 
4705
  {
 
4706
    if (dlg->oneRow==false)
 
4707
    {
 
4708
      horizontal->setOn(true);
 
4709
      horizontal->setPenWidth(preview->getPenWidth());
 
4710
      horizontal->setPenStyle(preview->getPenStyle());
 
4711
      horizontal->setColor( currentColor );
 
4712
      horizontal->setChanged(true);
 
4713
    }
 
4714
    if (dlg->oneCol==false)
 
4715
    {
 
4716
      vertical->setOn(true);
 
4717
      vertical->setPenWidth(preview->getPenWidth());
 
4718
      vertical->setPenStyle(preview->getPenStyle());
 
4719
      vertical->setColor( currentColor );
 
4720
      vertical->setChanged(true);
 
4721
    }
 
4722
  }
3918
4723
  area->repaint();
3919
4724
}
3920
4725
 
3921
 
void CellLayoutPageBorder::changeState( KSpreadBorderButton *_p)
 
4726
void CellFormatPageBorder::changeState( KSpreadBorderButton *_p)
3922
4727
{
3923
4728
  _p->setChanged(true);
3924
4729
 
3925
 
      if(_p->isOn())
3926
 
        {
3927
 
          _p->setPenWidth(preview->getPenWidth());
3928
 
          _p->setPenStyle(preview->getPenStyle());
3929
 
          _p->setColor( currentColor );
3930
 
        }
3931
 
      else
3932
 
        {
3933
 
          _p->setPenWidth(1);
3934
 
          _p->setPenStyle(Qt::NoPen);
3935
 
          _p->setColor( colorGroup().text() );
3936
 
        }
 
4730
  if (_p->isOn())
 
4731
  {
 
4732
    _p->setPenWidth(preview->getPenWidth());
 
4733
    _p->setPenStyle(preview->getPenStyle());
 
4734
    _p->setColor( currentColor );
 
4735
  }
 
4736
  else
 
4737
  {
 
4738
    _p->setPenWidth(1);
 
4739
    _p->setPenStyle(Qt::NoPen);
 
4740
    _p->setColor( colorGroup().text() );
 
4741
  }
3937
4742
 
3938
4743
 area->repaint();
3939
4744
}
3940
4745
 
3941
 
void CellLayoutPageBorder::draw()
 
4746
void CellFormatPageBorder::draw()
3942
4747
{
 
4748
  KSpreadBorderButton* top = borderButtons[BorderType_Top];
 
4749
  KSpreadBorderButton* bottom = borderButtons[BorderType_Bottom];
 
4750
  KSpreadBorderButton* left = borderButtons[BorderType_Left];
 
4751
  KSpreadBorderButton* right = borderButtons[BorderType_Right];
 
4752
  KSpreadBorderButton* risingDiagonal = borderButtons[BorderType_RisingDiagonal];
 
4753
  KSpreadBorderButton* fallingDiagonal = borderButtons[BorderType_FallingDiagonal];
 
4754
  KSpreadBorderButton* vertical = borderButtons[BorderType_Vertical];
 
4755
  KSpreadBorderButton* horizontal = borderButtons[BorderType_Horizontal];
3943
4756
  QPen pen;
3944
4757
  QPainter painter;
3945
4758
  painter.begin( area );
3946
4759
 
3947
 
  if((bottom->getPenStyle())!=Qt::NoPen)
3948
 
    {
3949
 
      pen=QPen( bottom->getColor(), bottom->getPenWidth(),bottom->getPenStyle());
3950
 
      painter.setPen( pen );
3951
 
      painter.drawLine( OFFSETX, area->height()-OFFSETY, area->width()-OFFSETX , area->height()-OFFSETY );
3952
 
    }
3953
 
  if((top->getPenStyle())!=Qt::NoPen)
3954
 
    {
3955
 
      pen=QPen( top->getColor(), top->getPenWidth(),top->getPenStyle());
3956
 
      painter.setPen( pen );
3957
 
      painter.drawLine( OFFSETX, OFFSETY, area->width() -OFFSETX, OFFSETY );
3958
 
    }
3959
 
 if((left->getPenStyle())!=Qt::NoPen)
3960
 
    {
3961
 
      pen=QPen( left->getColor(), left->getPenWidth(),left->getPenStyle());
3962
 
      painter.setPen( pen );
3963
 
      painter.drawLine( OFFSETX, OFFSETY, OFFSETX , area->height()-OFFSETY );
3964
 
    }
3965
 
 if((right->getPenStyle())!=Qt::NoPen)
3966
 
    {
3967
 
      pen=QPen( right->getColor(), right->getPenWidth(),right->getPenStyle());
3968
 
      painter.setPen( pen );
3969
 
      painter.drawLine( area->width()-OFFSETX, OFFSETY, area->width()-OFFSETX, area->height()-OFFSETY );
3970
 
 
3971
 
    }
3972
 
 if((fallDiagonal->getPenStyle())!=Qt::NoPen)
3973
 
    {
3974
 
      pen=QPen( fallDiagonal->getColor(), fallDiagonal->getPenWidth(),fallDiagonal->getPenStyle());
3975
 
      painter.setPen( pen );
3976
 
      painter.drawLine( OFFSETX, OFFSETY, area->width()-OFFSETX, area->height()-OFFSETY );
3977
 
      if(dlg->oneCol==false&& dlg->oneRow==false)
3978
 
        {
3979
 
        painter.drawLine( area->width()/2, OFFSETY, area->width()-OFFSETX, area->height()/2 );
3980
 
        painter.drawLine( OFFSETX,area->height()/2 , area->width()/2, area->height()-OFFSETY );
3981
 
        }
3982
 
    }
3983
 
 if((goUpDiagonal->getPenStyle())!=Qt::NoPen)
3984
 
    {
3985
 
      pen=QPen( goUpDiagonal->getColor(), goUpDiagonal->getPenWidth(),goUpDiagonal->getPenStyle());
3986
 
      painter.setPen( pen );
3987
 
      painter.drawLine( OFFSETX, area->height()-OFFSETY , area->width()-OFFSETX , OFFSETY );
3988
 
      if(dlg->oneCol==false&& dlg->oneRow==false)
3989
 
        {
3990
 
        painter.drawLine( area->width()/2, OFFSETY, OFFSETX, area->height()/2 );
3991
 
        painter.drawLine( area->width()/2,area->height()-OFFSETY , area->width()-OFFSETX, area->height()/2 );
3992
 
        }
3993
 
 
3994
 
    }
3995
 
 if((vertical->getPenStyle())!=Qt::NoPen)
3996
 
    {
3997
 
      pen=QPen( vertical->getColor(), vertical->getPenWidth(),vertical->getPenStyle());
 
4760
  if ((bottom->getPenStyle())!=Qt::NoPen)
 
4761
  {
 
4762
    pen=QPen( bottom->getColor(), bottom->getPenWidth(),bottom->getPenStyle());
 
4763
    painter.setPen( pen );
 
4764
    painter.drawLine( OFFSETX, area->height()-OFFSETY, area->width()-OFFSETX , area->height()-OFFSETY );
 
4765
  }
 
4766
  if ((top->getPenStyle())!=Qt::NoPen)
 
4767
  {
 
4768
    pen=QPen( top->getColor(), top->getPenWidth(),top->getPenStyle());
 
4769
    painter.setPen( pen );
 
4770
    painter.drawLine( OFFSETX, OFFSETY, area->width() -OFFSETX, OFFSETY );
 
4771
  }
 
4772
 if ((left->getPenStyle())!=Qt::NoPen)
 
4773
 {
 
4774
   pen=QPen( left->getColor(), left->getPenWidth(),left->getPenStyle());
 
4775
   painter.setPen( pen );
 
4776
   painter.drawLine( OFFSETX, OFFSETY, OFFSETX , area->height()-OFFSETY );
 
4777
 }
 
4778
 if ((right->getPenStyle())!=Qt::NoPen)
 
4779
 {
 
4780
   pen=QPen( right->getColor(), right->getPenWidth(),right->getPenStyle());
 
4781
   painter.setPen( pen );
 
4782
   painter.drawLine( area->width()-OFFSETX, OFFSETY, area->width()-OFFSETX,
 
4783
                     area->height()-OFFSETY );
 
4784
 
 
4785
 }
 
4786
 if ((fallingDiagonal->getPenStyle())!=Qt::NoPen)
 
4787
 {
 
4788
   pen=QPen( fallingDiagonal->getColor(), fallingDiagonal->getPenWidth(),
 
4789
             fallingDiagonal->getPenStyle());
 
4790
   painter.setPen( pen );
 
4791
   painter.drawLine( OFFSETX, OFFSETY, area->width()-OFFSETX,
 
4792
                     area->height()-OFFSETY );
 
4793
   if (dlg->oneCol==false&& dlg->oneRow==false)
 
4794
   {
 
4795
     painter.drawLine( area->width()/2, OFFSETY, area->width()-OFFSETX,
 
4796
                       area->height()/2 );
 
4797
     painter.drawLine( OFFSETX,area->height()/2 , area->width()/2,
 
4798
                       area->height()-OFFSETY );
 
4799
   }
 
4800
 }
 
4801
 if ((risingDiagonal->getPenStyle())!=Qt::NoPen)
 
4802
 {
 
4803
   pen=QPen( risingDiagonal->getColor(), risingDiagonal->getPenWidth(),
 
4804
             risingDiagonal->getPenStyle());
 
4805
   painter.setPen( pen );
 
4806
   painter.drawLine( OFFSETX, area->height()-OFFSETY , area->width()-OFFSETX ,
 
4807
                     OFFSETY );
 
4808
   if (dlg->oneCol==false&& dlg->oneRow==false)
 
4809
   {
 
4810
     painter.drawLine( area->width()/2, OFFSETY, OFFSETX, area->height()/2 );
 
4811
     painter.drawLine( area->width()/2,area->height()-OFFSETY ,
 
4812
                       area->width()-OFFSETX, area->height()/2 );
 
4813
   }
 
4814
 
 
4815
 }
 
4816
 if ((vertical->getPenStyle())!=Qt::NoPen)
 
4817
    {
 
4818
      pen=QPen( vertical->getColor(), vertical->getPenWidth(),
 
4819
                vertical->getPenStyle());
3998
4820
      painter.setPen( pen );
3999
4821
      painter.drawLine( area->width()/2, 5 , area->width()/2 , area->height()-5 );
4000
4822
    }
4001
 
  if((horizontal->getPenStyle())!=Qt::NoPen)
4002
 
    {
4003
 
      pen=QPen( horizontal->getColor(), horizontal->getPenWidth(),horizontal->getPenStyle());
4004
 
      painter.setPen( pen );
4005
 
      painter.drawLine( OFFSETX,area->height()/2,area->width()-OFFSETX, area->height()/2 );
4006
 
    }
4007
 
  painter.end();
 
4823
 if ((horizontal->getPenStyle())!=Qt::NoPen)
 
4824
 {
 
4825
   pen=QPen( horizontal->getColor(), horizontal->getPenWidth(),
 
4826
             horizontal->getPenStyle());
 
4827
   painter.setPen( pen );
 
4828
   painter.drawLine( OFFSETX,area->height()/2,area->width()-OFFSETX,
 
4829
                     area->height()/2 );
 
4830
 }
 
4831
 painter.end();
4008
4832
}
4009
4833
 
4010
 
void CellLayoutPageBorder::invertState(KSpreadBorderButton *_p)
 
4834
void CellFormatPageBorder::invertState(KSpreadBorderButton *_p)
4011
4835
{
4012
 
  if(_p->isOn())
4013
 
        {
4014
 
        _p->unselect();
4015
 
        }
 
4836
  if (_p->isOn())
 
4837
  {
 
4838
    _p->unselect();
 
4839
  }
4016
4840
  else
4017
 
        {
4018
 
        _p->setOn(!_p->isOn());
4019
 
        _p->setPenWidth(preview->getPenWidth());
4020
 
        _p->setPenStyle(preview->getPenStyle());
4021
 
        _p->setColor( currentColor );
4022
 
        _p->setChanged(true);
4023
 
        }
 
4841
  {
 
4842
    _p->setOn(true);
 
4843
    _p->setPenWidth(preview->getPenWidth());
 
4844
    _p->setPenStyle(preview->getPenStyle());
 
4845
    _p->setColor( currentColor );
 
4846
    _p->setChanged(true);
 
4847
  }
4024
4848
}
4025
4849
 
4026
 
void CellLayoutPageBorder::slotPressEvent(QMouseEvent *_ev)
 
4850
void CellFormatPageBorder::slotPressEvent(QMouseEvent *_ev)
4027
4851
{
 
4852
  KSpreadBorderButton* top = borderButtons[BorderType_Top];
 
4853
  KSpreadBorderButton* bottom = borderButtons[BorderType_Bottom];
 
4854
  KSpreadBorderButton* left = borderButtons[BorderType_Left];
 
4855
  KSpreadBorderButton* right = borderButtons[BorderType_Right];
 
4856
  KSpreadBorderButton* vertical = borderButtons[BorderType_Vertical];
 
4857
  KSpreadBorderButton* horizontal = borderButtons[BorderType_Horizontal];
 
4858
 
 
4859
 
4028
4860
  QRect rect(OFFSETX,OFFSETY-8,area->width()-OFFSETX,OFFSETY+8);
4029
 
  if(rect.contains(QPoint(_ev->x(),_ev->y())))
4030
 
        {
4031
 
        if(((top->getPenWidth()!=preview->getPenWidth()) ||(top->getColor()!=currentColor)
4032
 
        ||(top->getPenStyle()!=preview->getPenStyle()))&& top->isOn())
4033
 
                {
4034
 
                top->setPenWidth(preview->getPenWidth());
4035
 
                top->setPenStyle(preview->getPenStyle());
4036
 
                top->setColor( currentColor );
4037
 
                top->setChanged(true);
4038
 
                }
4039
 
        else
4040
 
                invertState(top);
4041
 
        }
4042
 
  rect.setCoords(OFFSETX,area->height()-OFFSETY-8,area->width()-OFFSETX,area->height()-OFFSETY+8);
4043
 
  if(rect.contains(QPoint(_ev->x(),_ev->y())))
4044
 
        {
4045
 
         if(((bottom->getPenWidth()!=preview->getPenWidth()) ||(bottom->getColor()!=currentColor)
4046
 
        ||(bottom->getPenStyle()!=preview->getPenStyle()))&& bottom->isOn())
4047
 
                {
4048
 
                bottom->setPenWidth(preview->getPenWidth());
4049
 
                bottom->setPenStyle(preview->getPenStyle());
4050
 
                bottom->setColor( currentColor );
4051
 
                bottom->setChanged(true);
4052
 
                }
4053
 
        else
4054
 
                invertState(bottom);
4055
 
        }
 
4861
  if (rect.contains(QPoint(_ev->x(),_ev->y())))
 
4862
  {
 
4863
    if (((top->getPenWidth()!=preview->getPenWidth()) ||
 
4864
        (top->getColor()!=currentColor) ||
 
4865
        (top->getPenStyle()!=preview->getPenStyle()))
 
4866
       && top->isOn())
 
4867
    {
 
4868
      top->setPenWidth(preview->getPenWidth());
 
4869
      top->setPenStyle(preview->getPenStyle());
 
4870
      top->setColor( currentColor );
 
4871
      top->setChanged(true);
 
4872
    }
 
4873
    else
 
4874
      invertState(top);
 
4875
  }
 
4876
  rect.setCoords(OFFSETX,area->height()-OFFSETY-8,area->width()-OFFSETX,
 
4877
                 area->height()-OFFSETY+8);
 
4878
  if (rect.contains(QPoint(_ev->x(),_ev->y())))
 
4879
  {
 
4880
    if (((bottom->getPenWidth()!=preview->getPenWidth()) ||
 
4881
        (bottom->getColor()!=currentColor) ||
 
4882
        (bottom->getPenStyle()!=preview->getPenStyle()))
 
4883
       && bottom->isOn())
 
4884
    {
 
4885
      bottom->setPenWidth(preview->getPenWidth());
 
4886
      bottom->setPenStyle(preview->getPenStyle());
 
4887
      bottom->setColor( currentColor );
 
4888
      bottom->setChanged(true);
 
4889
    }
 
4890
    else
 
4891
      invertState(bottom);
 
4892
  }
4056
4893
 
4057
4894
  rect.setCoords(OFFSETX-8,OFFSETY,OFFSETX+8,area->height()-OFFSETY);
4058
 
  if(rect.contains(QPoint(_ev->x(),_ev->y())))
4059
 
        {
4060
 
        if(((left->getPenWidth()!=preview->getPenWidth()) ||(left->getColor()!=currentColor)
4061
 
        ||(left->getPenStyle()!=preview->getPenStyle()))&& left->isOn())
4062
 
                {
4063
 
                left->setPenWidth(preview->getPenWidth());
4064
 
                left->setPenStyle(preview->getPenStyle());
4065
 
                left->setColor( currentColor );
 
4895
  if (rect.contains(QPoint(_ev->x(),_ev->y())))
 
4896
  {
 
4897
    if (((left->getPenWidth()!=preview->getPenWidth()) ||
 
4898
        (left->getColor()!=currentColor) ||
 
4899
        (left->getPenStyle()!=preview->getPenStyle()))
 
4900
       && left->isOn())
 
4901
    {
 
4902
      left->setPenWidth(preview->getPenWidth());
 
4903
      left->setPenStyle(preview->getPenStyle());
 
4904
      left->setColor( currentColor );
4066
4905
                left->setChanged(true);
4067
 
                }
4068
 
        else
4069
 
                invertState(left);
4070
 
        }
4071
 
  rect.setCoords(area->width()-OFFSETX-8,OFFSETY,area->width()-OFFSETX+8,area->height()-OFFSETY);
4072
 
 if(rect.contains(QPoint(_ev->x(),_ev->y())))
4073
 
        {
4074
 
        if(((right->getPenWidth()!=preview->getPenWidth()) ||(right->getColor()!=currentColor)
4075
 
        ||(right->getPenStyle()!=preview->getPenStyle()))&& right->isOn())
4076
 
                {
4077
 
                right->setPenWidth(preview->getPenWidth());
4078
 
                right->setPenStyle(preview->getPenStyle());
4079
 
                right->setColor( currentColor );
4080
 
                right->setChanged(true);
4081
 
                }
4082
 
        else
4083
 
                invertState(right);
4084
 
        }
 
4906
    }
 
4907
    else
 
4908
      invertState(left);
 
4909
  }
 
4910
  rect.setCoords(area->width()-OFFSETX-8,OFFSETY,area->width()-OFFSETX+8,
 
4911
                 area->height()-OFFSETY);
 
4912
  if (rect.contains(QPoint(_ev->x(),_ev->y())))
 
4913
  {
 
4914
    if (((right->getPenWidth()!=preview->getPenWidth()) ||
 
4915
        (right->getColor()!=currentColor) ||
 
4916
        (right->getPenStyle()!=preview->getPenStyle()))
 
4917
       && right->isOn())
 
4918
    {
 
4919
      right->setPenWidth(preview->getPenWidth());
 
4920
      right->setPenStyle(preview->getPenStyle());
 
4921
      right->setColor( currentColor );
 
4922
      right->setChanged(true);
 
4923
    }
 
4924
    else
 
4925
      invertState(right);
 
4926
  }
4085
4927
 
4086
4928
//don't work because I don't know how create a rectangle
4087
4929
//for diagonal
4088
4930
/*rect.setCoords(OFFSETX,OFFSETY,XLEN-OFFSETX,YHEI-OFFSETY);
4089
 
if(rect.contains(QPoint(_ev->x(),_ev->y())))
 
4931
if (rect.contains(QPoint(_ev->x(),_ev->y())))
4090
4932
        {
4091
4933
         invertState(fallDiagonal);
4092
4934
        }
4093
4935
rect.setCoords(OFFSETX,YHEI-OFFSETY,XLEN-OFFSETX,OFFSETY);
4094
 
if(rect.contains(QPoint(_ev->x(),_ev->y())))
 
4936
if (rect.contains(QPoint(_ev->x(),_ev->y())))
4095
4937
        {
4096
4938
         invertState(goUpDiagonal);
4097
4939
        } */
4098
4940
 
4099
 
 if(dlg->oneCol==false)
4100
 
        {
4101
 
         rect.setCoords(area->width()/2-8,OFFSETY,area->width()/2+8,area->height()-OFFSETY);
4102
 
 
4103
 
        if(rect.contains(QPoint(_ev->x(),_ev->y())))
4104
 
                {
4105
 
                if(((vertical->getPenWidth()!=preview->getPenWidth()) ||(vertical->getColor()!=currentColor)
4106
 
                ||(vertical->getPenStyle()!=preview->getPenStyle()))&& vertical->isOn())
4107
 
                        {
4108
 
                        vertical->setPenWidth(preview->getPenWidth());
4109
 
                        vertical->setPenStyle(preview->getPenStyle());
4110
 
                        vertical->setColor( currentColor );
4111
 
                        vertical->setChanged(true);
4112
 
                        }
4113
 
                else
4114
 
                        invertState(vertical);
4115
 
                }
4116
 
        }
4117
 
 if(dlg->oneRow==false)
4118
 
        {
4119
 
        rect.setCoords(OFFSETX,area->height()/2-8,area->width()-OFFSETX,area->height()/2+8);
4120
 
        if(rect.contains(QPoint(_ev->x(),_ev->y())))
4121
 
                {
4122
 
                if(((horizontal->getPenWidth()!=preview->getPenWidth()) ||(horizontal->getColor()!=currentColor)
4123
 
                ||(horizontal->getPenStyle()!=preview->getPenStyle()))&& horizontal->isOn())
4124
 
                        {
4125
 
                        horizontal->setPenWidth(preview->getPenWidth());
4126
 
                        horizontal->setPenStyle(preview->getPenStyle());
4127
 
                        horizontal->setColor( currentColor );
4128
 
                        horizontal->setChanged(true);
4129
 
                        }
4130
 
                else
4131
 
                        invertState(horizontal);
4132
 
                }
4133
 
        }
4134
 
 
4135
 
 area->repaint();
 
4941
  if (dlg->oneCol==false)
 
4942
  {
 
4943
    rect.setCoords(area->width()/2-8,OFFSETY,area->width()/2+8,
 
4944
                   area->height()-OFFSETY);
 
4945
 
 
4946
    if (rect.contains(QPoint(_ev->x(),_ev->y())))
 
4947
    {
 
4948
      if (((vertical->getPenWidth()!=preview->getPenWidth()) ||
 
4949
          (vertical->getColor()!=currentColor) ||
 
4950
          (vertical->getPenStyle()!=preview->getPenStyle()))
 
4951
         && vertical->isOn())
 
4952
      {
 
4953
        vertical->setPenWidth(preview->getPenWidth());
 
4954
        vertical->setPenStyle(preview->getPenStyle());
 
4955
        vertical->setColor( currentColor );
 
4956
        vertical->setChanged(true);
 
4957
      }
 
4958
      else
 
4959
        invertState(vertical);
 
4960
    }
 
4961
  }
 
4962
  if (dlg->oneRow==false)
 
4963
  {
 
4964
    rect.setCoords(OFFSETX,area->height()/2-8,area->width()-OFFSETX,
 
4965
                   area->height()/2+8);
 
4966
    if (rect.contains(QPoint(_ev->x(),_ev->y())))
 
4967
    {
 
4968
      if (((horizontal->getPenWidth()!=preview->getPenWidth()) ||
 
4969
          (horizontal->getColor()!=currentColor) ||
 
4970
          (horizontal->getPenStyle()!=preview->getPenStyle()))
 
4971
         && horizontal->isOn())
 
4972
      {
 
4973
        horizontal->setPenWidth(preview->getPenWidth());
 
4974
        horizontal->setPenStyle(preview->getPenStyle());
 
4975
        horizontal->setColor( currentColor );
 
4976
        horizontal->setChanged(true);
 
4977
      }
 
4978
      else
 
4979
        invertState(horizontal);
 
4980
    }
 
4981
  }
 
4982
 
 
4983
  area->repaint();
4136
4984
}
4137
4985
 
4138
4986
KSpreadBrushSelect::KSpreadBrushSelect( QWidget *parent, const char * ) : QFrame( parent )
4139
4987
{
4140
4988
    brushStyle = Qt::NoBrush;
4141
4989
    brushColor = Qt::red;
4142
 
    selected = FALSE;
 
4990
    selected = false;
4143
4991
}
4144
4992
 
4145
4993
void KSpreadBrushSelect::setPattern( const QColor &_color,BrushStyle _style )
4172
5020
 
4173
5021
void KSpreadBrushSelect::slotUnselect()
4174
5022
{
4175
 
    selected = FALSE;
 
5023
    selected = false;
4176
5024
 
4177
5025
    setLineWidth( 1 );
4178
5026
    setFrameStyle( QFrame::Panel | QFrame::Sunken );
4181
5029
 
4182
5030
void KSpreadBrushSelect::slotSelect()
4183
5031
{
4184
 
    selected = TRUE;
 
5032
    selected = true;
4185
5033
 
4186
5034
    setLineWidth( 2 );
4187
5035
    setFrameStyle( QFrame::Panel | QFrame::Plain );
4189
5037
}
4190
5038
 
4191
5039
 
4192
 
CellLayoutPagePattern::CellLayoutPagePattern( QWidget* parent, CellLayoutDlg *_dlg ) : QWidget( parent )
 
5040
CellFormatPagePattern::CellFormatPagePattern( QWidget* parent, CellFormatDlg *_dlg ) : QWidget( parent )
4193
5041
{
4194
5042
    dlg = _dlg;
4195
5043
 
4196
5044
    bBgColorUndefined = !dlg->bBgColor;
4197
5045
 
4198
 
    QGridLayout *grid = new QGridLayout(this,5,2,15,15);
 
5046
    QGridLayout *grid = new QGridLayout(this,5,2,KDialog::marginHint(), KDialog::spacingHint());
4199
5047
 
4200
5048
    QGroupBox* tmpQGroupBox;
4201
5049
    tmpQGroupBox = new QGroupBox( this, "GroupBox_20" );
4202
 
    tmpQGroupBox->setFrameStyle( 49 );
 
5050
    tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
4203
5051
    tmpQGroupBox->setTitle( i18n("Pattern") );
4204
 
    tmpQGroupBox->setAlignment( 1 );
4205
 
 
4206
 
    QGridLayout *grid2 = new QGridLayout(tmpQGroupBox,7,3,15,7);
 
5052
    tmpQGroupBox->setAlignment( AlignLeft );
 
5053
 
 
5054
    QGridLayout *grid2 = new QGridLayout(tmpQGroupBox,8,3,KDialog::marginHint(), KDialog::spacingHint());
 
5055
    int fHeight = tmpQGroupBox->fontMetrics().height();
 
5056
    grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
 
5057
 
4207
5058
 
4208
5059
    brush1 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_1" );
4209
 
    brush1->setFrameStyle( 50 );
4210
 
    grid2->addWidget(brush1,0,0);
 
5060
    brush1->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5061
    grid2->addWidget(brush1,1,0);
4211
5062
 
4212
5063
    brush2 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_2" );
4213
 
    brush2->setFrameStyle( 50 );
4214
 
    grid2->addWidget(brush2,0,1);
 
5064
    brush2->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5065
    grid2->addWidget(brush2,1,1);
4215
5066
 
4216
5067
    brush3 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_3" );
4217
 
    brush3->setFrameStyle( 50 );
4218
 
    grid2->addWidget(brush3,0,2);
 
5068
    brush3->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5069
    grid2->addWidget(brush3,1,2);
4219
5070
 
4220
5071
    brush4 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_4" );
4221
 
    brush4->setFrameStyle( 50 );
4222
 
    grid2->addWidget(brush4,1,0);
 
5072
    brush4->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5073
    grid2->addWidget(brush4,2,0);
4223
5074
 
4224
5075
    brush5 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_5" );
4225
 
    brush5->setFrameStyle( 50 );
4226
 
    grid2->addWidget(brush5,1,1);
 
5076
    brush5->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5077
    grid2->addWidget(brush5,2,1);
4227
5078
 
4228
5079
    brush6 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_6" );
4229
 
    brush6->setFrameStyle( 50 );
4230
 
    grid2->addWidget(brush6,1,2);
 
5080
    brush6->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5081
    grid2->addWidget(brush6,2,2);
4231
5082
 
4232
5083
    brush7 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_7" );
4233
 
    brush7->setFrameStyle( 50 );
4234
 
    grid2->addWidget(brush7,2,0);
 
5084
    brush7->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5085
    grid2->addWidget(brush7,3,0);
4235
5086
 
4236
5087
    brush8 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_8" );
4237
 
    brush8->setFrameStyle( 50 );
4238
 
    grid2->addWidget(brush8,2,1);
 
5088
    brush8->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5089
    grid2->addWidget(brush8,3,1);
4239
5090
 
4240
5091
    brush9 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_9" );
4241
 
    brush9->setFrameStyle( 50 );
4242
 
    grid2->addWidget(brush9,2,2);
 
5092
    brush9->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5093
    grid2->addWidget(brush9,3,2);
4243
5094
 
4244
5095
    brush10 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_10" );
4245
 
    brush10->setFrameStyle( 50 );
4246
 
    grid2->addWidget(brush10,3,0);
 
5096
    brush10->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5097
    grid2->addWidget(brush10,4,0);
4247
5098
 
4248
5099
    brush11 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_11" );
4249
 
    brush11->setFrameStyle( 50 );
4250
 
    grid2->addWidget(brush11,3,1);
 
5100
    brush11->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5101
    grid2->addWidget(brush11,4,1);
4251
5102
 
4252
5103
    brush12 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_12" );
4253
 
    brush12->setFrameStyle( 50 );
4254
 
    grid2->addWidget(brush12,3,2);
 
5104
    brush12->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5105
    grid2->addWidget(brush12,4,2);
4255
5106
 
4256
5107
    brush13 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_13" );
4257
 
    brush13->setFrameStyle( 50 );
4258
 
    grid2->addWidget(brush13,4,0);
 
5108
    brush13->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5109
    grid2->addWidget(brush13,5,0);
4259
5110
 
4260
5111
    brush14 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_14" );
4261
 
    brush14->setFrameStyle( 50 );
4262
 
    grid2->addWidget(brush14,4,1);
 
5112
    brush14->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5113
    grid2->addWidget(brush14,5,1);
4263
5114
 
4264
5115
    brush15 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_15" );
4265
 
    brush15->setFrameStyle( 50 );
4266
 
    grid2->addWidget(brush15,4,2);
 
5116
    brush15->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5117
    grid2->addWidget(brush15,5,2);
4267
5118
 
4268
 
    QGridLayout *grid3=new QGridLayout(tmpQGroupBox,1,2);
 
5119
    QGridLayout *grid3 = new QGridLayout( 1, 2 );
4269
5120
    color = new KColorButton (tmpQGroupBox, "ColorButton_1" );
4270
5121
    grid3->addWidget(color,0,1);
4271
5122
 
4272
5123
    QLabel *tmpQLabel = new QLabel( tmpQGroupBox, "Label_1" );
4273
 
    tmpQLabel->setText( i18n("Color") );
 
5124
    tmpQLabel->setText( i18n("Color:") );
4274
5125
    grid3->addWidget(tmpQLabel,0,0);
4275
5126
 
4276
 
    grid2->addMultiCell(grid3,5,5,0,2);
 
5127
    grid2->addMultiCell(grid3,6,6,0,2);
4277
5128
 
4278
 
    grid3=new QGridLayout(tmpQGroupBox,1,3);
 
5129
    grid3 = new QGridLayout( 1, 3 );
4279
5130
 
4280
5131
    tmpQLabel = new QLabel( tmpQGroupBox, "Label_2" );
4281
5132
    grid3->addWidget(tmpQLabel,0,0);
4282
 
    tmpQLabel->setText( i18n("Background Color") );
 
5133
    tmpQLabel->setText( i18n("Background color:") );
4283
5134
 
4284
5135
    bgColorButton = new KColorButton( tmpQGroupBox, "ColorButton" );
4285
5136
    grid3->addWidget(bgColorButton,0,1);
4288
5139
    else
4289
5140
        bgColor = colorGroup().base();
4290
5141
 
4291
 
    if(!bgColor.isValid())
4292
 
        bgColor=colorGroup().base();
 
5142
    if (!bgColor.isValid())
 
5143
        bgColor = colorGroup().base();
4293
5144
 
4294
 
    bgColorButton->setColor(bgColor);
 
5145
    bgColorButton->setColor( bgColor );
4295
5146
    connect( bgColorButton, SIGNAL( changed( const QColor & ) ),
4296
5147
             this, SLOT( slotSetBackgroundColor( const QColor & ) ) );
4297
5148
 
4301
5152
             this, SLOT( slotNotAnyColor(  ) ) );
4302
5153
    b_notAnyColor=false;
4303
5154
 
4304
 
    grid2->addMultiCell(grid3,6,6,0,2);
 
5155
    grid2->addMultiCell(grid3,7,7,0,2);
4305
5156
 
4306
5157
    grid->addMultiCellWidget(tmpQGroupBox,0,3,0,0);
4307
5158
 
4308
5159
    tmpQGroupBox = new QGroupBox( this, "GroupBox1" );
4309
5160
    tmpQGroupBox->setTitle( i18n("Preview") );
4310
 
    tmpQGroupBox->setFrameStyle( 49 );
4311
 
    tmpQGroupBox->setAlignment( 1 );
 
5161
    tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
 
5162
    tmpQGroupBox->setAlignment( AlignLeft );
4312
5163
 
4313
 
    grid2 = new QGridLayout(tmpQGroupBox,1,1,14,4);
 
5164
    grid2 = new QGridLayout(tmpQGroupBox,2,1,KDialog::marginHint(), KDialog::spacingHint());
 
5165
    fHeight = tmpQGroupBox->fontMetrics().height();
 
5166
    grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
4314
5167
 
4315
5168
    current = new KSpreadBrushSelect( tmpQGroupBox, "Current" );
4316
 
    current->setFrameStyle( 50 );
4317
 
    grid2->addWidget(current,0,0);
 
5169
    current->setFrameStyle( QFrame::Panel | QFrame::Sunken );
 
5170
    grid2->addWidget(current,1,0);
4318
5171
    grid->addWidget( tmpQGroupBox,4,0);
4319
5172
 
4320
5173
    connect( brush1, SIGNAL( clicked( KSpreadBrushSelect* ) ),
4368
5221
    current->slotSelect();
4369
5222
    selectedBrush=current;
4370
5223
    color->setColor(dlg->brushColor);
4371
 
    current->setBackgroundColor(bgColor);
 
5224
    current->setBackgroundColor( bgColor );
4372
5225
 
4373
5226
    connect( color, SIGNAL( changed( const QColor & ) ),
4374
5227
             this, SLOT( slotSetColorButton( const QColor & ) ) );
4378
5231
    this->resize( 400, 400 );
4379
5232
}
4380
5233
 
4381
 
void CellLayoutPagePattern::slotNotAnyColor()
4382
 
{
4383
 
b_notAnyColor=true;
4384
 
bgColorButton->setColor(colorGroup().base());
4385
 
current->setBackgroundColor(colorGroup().base());
4386
 
}
4387
 
 
4388
 
void CellLayoutPagePattern::slotSetBackgroundColor( const QColor &_color )
4389
 
{
4390
 
bgColor =_color;
4391
 
current->setBackgroundColor(bgColor);
4392
 
bBgColorUndefined=false;
4393
 
b_notAnyColor=false;
4394
 
}
4395
 
 
4396
 
void CellLayoutPagePattern::init()
4397
 
{
4398
 
    if(dlg->brushStyle==Qt::VerPattern)
4399
 
        {
4400
 
        brush1->slotSelect();
4401
 
        }
4402
 
    else if(dlg->brushStyle==Qt::HorPattern)
4403
 
        {
4404
 
        brush2->slotSelect();
4405
 
        }
4406
 
    else if(dlg->brushStyle==Qt::Dense1Pattern)
4407
 
        {
4408
 
        brush3->slotSelect();
4409
 
        }
4410
 
    else if(dlg->brushStyle==Qt::Dense2Pattern)
4411
 
        {
4412
 
        brush4->slotSelect();
4413
 
        }
4414
 
    else if(dlg->brushStyle==Qt::Dense3Pattern)
4415
 
        {
4416
 
        brush5->slotSelect();
4417
 
        }
4418
 
    else if(dlg->brushStyle==Qt::Dense4Pattern)
4419
 
        {
4420
 
        brush6->slotSelect();
4421
 
        }
4422
 
    else if(dlg->brushStyle==Qt::Dense5Pattern)
4423
 
        {
4424
 
        brush7->slotSelect();
4425
 
        }
4426
 
    else if(dlg->brushStyle==Qt::Dense6Pattern)
4427
 
        {
4428
 
        brush8->slotSelect();
4429
 
        }
4430
 
    else if(dlg->brushStyle==Qt::Dense7Pattern)
4431
 
        {
4432
 
        brush9->slotSelect();
4433
 
        }
4434
 
    else if(dlg->brushStyle==Qt::CrossPattern)
4435
 
        {
4436
 
        brush10->slotSelect();
4437
 
        }
4438
 
    else if(dlg->brushStyle==Qt::BDiagPattern)
4439
 
        {
4440
 
        brush11->slotSelect();
4441
 
        }
4442
 
    else if(dlg->brushStyle==Qt::FDiagPattern)
4443
 
        {
4444
 
        brush12->slotSelect();
4445
 
        }
4446
 
    else if(dlg->brushStyle==Qt::VerPattern)
4447
 
        {
4448
 
        brush13->slotSelect();
4449
 
        }
4450
 
    else if(dlg->brushStyle==Qt::DiagCrossPattern)
4451
 
        {
4452
 
        brush14->slotSelect();
4453
 
        }
4454
 
    else if(dlg->brushStyle==Qt::NoBrush)
4455
 
        {
4456
 
        brush15->slotSelect();
4457
 
        }
4458
 
    else
4459
 
        kdDebug(36001) << "Error in brushStyle" << endl;
4460
 
}
4461
 
 
4462
 
void CellLayoutPagePattern::slotSetColorButton( const QColor &_color )
 
5234
void CellFormatPagePattern::slotNotAnyColor()
 
5235
{
 
5236
  b_notAnyColor = true;
 
5237
  bgColorButton->setColor( colorGroup().base() );
 
5238
  current->setBackgroundColor( colorGroup().base() );
 
5239
}
 
5240
 
 
5241
void CellFormatPagePattern::slotSetBackgroundColor( const QColor &_color )
 
5242
{
 
5243
  bgColor =_color;
 
5244
  current->setBackgroundColor( bgColor );
 
5245
  bBgColorUndefined = false;
 
5246
  b_notAnyColor = false;
 
5247
}
 
5248
 
 
5249
void CellFormatPagePattern::init()
 
5250
{
 
5251
  if (dlg->brushStyle == Qt::VerPattern)
 
5252
  {
 
5253
    brush1->slotSelect();
 
5254
  }
 
5255
  else if (dlg->brushStyle == Qt::HorPattern)
 
5256
  {
 
5257
    brush2->slotSelect();
 
5258
  }
 
5259
  else if (dlg->brushStyle == Qt::Dense1Pattern)
 
5260
  {
 
5261
    brush3->slotSelect();
 
5262
  }
 
5263
  else if (dlg->brushStyle == Qt::Dense2Pattern)
 
5264
  {
 
5265
    brush4->slotSelect();
 
5266
  }
 
5267
  else if (dlg->brushStyle == Qt::Dense3Pattern)
 
5268
  {
 
5269
    brush5->slotSelect();
 
5270
  }
 
5271
  else if (dlg->brushStyle == Qt::Dense4Pattern)
 
5272
  {
 
5273
    brush6->slotSelect();
 
5274
  }
 
5275
  else if (dlg->brushStyle == Qt::Dense5Pattern)
 
5276
  {
 
5277
    brush7->slotSelect();
 
5278
  }
 
5279
  else if (dlg->brushStyle == Qt::Dense6Pattern)
 
5280
  {
 
5281
    brush8->slotSelect();
 
5282
  }
 
5283
  else if (dlg->brushStyle == Qt::Dense7Pattern)
 
5284
  {
 
5285
    brush9->slotSelect();
 
5286
  }
 
5287
  else if (dlg->brushStyle == Qt::CrossPattern)
 
5288
  {
 
5289
    brush10->slotSelect();
 
5290
  }
 
5291
  else if (dlg->brushStyle == Qt::BDiagPattern)
 
5292
  {
 
5293
    brush11->slotSelect();
 
5294
  }
 
5295
  else if (dlg->brushStyle == Qt::FDiagPattern)
 
5296
  {
 
5297
    brush12->slotSelect();
 
5298
  }
 
5299
  else if (dlg->brushStyle == Qt::VerPattern)
 
5300
  {
 
5301
    brush13->slotSelect();
 
5302
  }
 
5303
  else if (dlg->brushStyle == Qt::DiagCrossPattern)
 
5304
  {
 
5305
    brush14->slotSelect();
 
5306
  }
 
5307
  else if (dlg->brushStyle == Qt::NoBrush)
 
5308
  {
 
5309
    brush15->slotSelect();
 
5310
  }
 
5311
  else
 
5312
    kdDebug(36001) << "Error in brushStyle" << endl;
 
5313
}
 
5314
 
 
5315
void CellFormatPagePattern::slotSetColorButton( const QColor &_color )
4463
5316
{
4464
5317
    currentColor = _color;
4465
5318
 
4481
5334
    current->setBrushColor( currentColor );
4482
5335
}
4483
5336
 
4484
 
void CellLayoutPagePattern::slotUnselect2( KSpreadBrushSelect *_p )
 
5337
void CellFormatPagePattern::slotUnselect2( KSpreadBrushSelect *_p )
4485
5338
{
4486
5339
    selectedBrush = _p;
4487
5340
 
4516
5369
    if ( brush15 != _p )
4517
5370
        brush15->slotUnselect();
4518
5371
 
4519
 
    current->setBrushStyle(selectedBrush->getBrushStyle());
4520
 
}
4521
 
 
4522
 
void CellLayoutPagePattern::apply( ColumnLayout *_obj )
4523
 
{
4524
 
  KSpreadCell*c= dlg->getTable()->firstCell();
4525
 
  for( ;c; c = c->nextCell() )
4526
 
      {
4527
 
        int col = c->column();
4528
 
        if ( dlg->left <= col && dlg->right >= col
4529
 
        &&!c->isObscuringForced())
4530
 
        {
4531
 
           if(selectedBrush!=0L)
4532
 
                {
4533
 
                c->clearProperty(KSpreadCell::PBackgroundBrush);
4534
 
                c->clearNoFallBackProperties( KSpreadCell::PBackgroundBrush );
4535
 
                }
4536
 
           if(!bBgColorUndefined || b_notAnyColor)
4537
 
                {
4538
 
                c->clearProperty(KSpreadCell::PBackgroundColor);
4539
 
                c->clearNoFallBackProperties( KSpreadCell::PBackgroundColor );
4540
 
                }
4541
 
        }
4542
 
      }
4543
 
      applyLayout(_obj);
4544
 
 
4545
 
      RowLayout* rw =dlg->getTable()->firstRow();
4546
 
      for( ; rw; rw = rw->next() )
4547
 
        {
4548
 
        if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PBackgroundColor) || rw->hasProperty(KSpreadCell::PBackgroundBrush)))
4549
 
                {
4550
 
                for(int i=dlg->left;i<=dlg->right;i++)
4551
 
                        {
4552
 
                        KSpreadCell *cell = dlg->getTable()->cellAt( i,  rw->row());
4553
 
                        if ( cell->isDefault() )
4554
 
                                {
4555
 
                                cell = new KSpreadCell( dlg->getTable(), i,  rw->row() );
4556
 
                                dlg->getTable()->insertCell( cell);
4557
 
                                }
4558
 
                        applyLayout(cell );
4559
 
                        }
4560
 
                }
4561
 
        }
4562
 
 
4563
 
}
4564
 
 
4565
 
void CellLayoutPagePattern::apply( RowLayout *_obj )
4566
 
{
4567
 
  KSpreadCell*c= dlg->getTable()->firstCell();
4568
 
  for( ;c; c = c->nextCell() )
4569
 
      {
4570
 
        int row = c->row();
4571
 
        if ( dlg->top <= row && dlg->bottom >= row
4572
 
        &&!c->isObscuringForced())
4573
 
        {
4574
 
           if(selectedBrush!=0L)
4575
 
                {
4576
 
                c->clearProperty(KSpreadCell::PBackgroundBrush);
4577
 
                c->clearNoFallBackProperties( KSpreadCell::PBackgroundBrush );
4578
 
                }
4579
 
           if(!bBgColorUndefined || b_notAnyColor)
4580
 
                {
4581
 
                c->clearProperty(KSpreadCell::PBackgroundColor);
4582
 
                c->clearNoFallBackProperties( KSpreadCell::PBackgroundColor );
4583
 
                }
4584
 
        }
4585
 
      }
4586
 
  applyLayout(_obj);
4587
 
}
4588
 
 
4589
 
 
4590
 
void CellLayoutPagePattern::apply( KSpreadCell *_obj )
4591
 
{
4592
 
applyLayout(_obj);
4593
 
}
4594
 
 
4595
 
void CellLayoutPagePattern::applyLayout( KSpreadLayout *_obj )
4596
 
{
4597
 
  if(selectedBrush!=0L)
4598
 
        _obj->setBackGroundBrush(QBrush( selectedBrush->getBrushColor(),selectedBrush->getBrushStyle()));
4599
 
  if( b_notAnyColor)
4600
 
        _obj->setBgColor( QColor() );
 
5372
    current->setBrushStyle( selectedBrush->getBrushStyle() );
 
5373
}
 
5374
 
 
5375
void CellFormatPagePattern::apply( KSpreadCustomStyle * style )
 
5376
{
 
5377
  if ( selectedBrush != 0L 
 
5378
    && ( dlg->brushStyle != selectedBrush->getBrushStyle() 
 
5379
         || dlg->brushColor != selectedBrush->getBrushColor() ) )
 
5380
    style->changeBackGroundBrush( QBrush( selectedBrush->getBrushColor(), selectedBrush->getBrushStyle() ) );
 
5381
 
 
5382
  /*
 
5383
    TODO: check...
 
5384
  if ( b_notAnyColor)
 
5385
    style->changeBgColor( QColor() );
 
5386
  else 
 
5387
  */
 
5388
  if ( bgColor != dlg->getStyle()->bgColor() )
 
5389
    style->changeBgColor( bgColor );
 
5390
}
 
5391
 
 
5392
void CellFormatPagePattern::apply( ColumnFormat *_obj )
 
5393
{
 
5394
  KSpreadSheet * table = dlg->getTable();
 
5395
  KSpreadCell  * c = NULL;
 
5396
  for ( int col = dlg->left; col <= dlg->right; ++col )
 
5397
  {
 
5398
    for (c = table->getFirstCellColumn(col); c != NULL;
 
5399
         c = table->getNextCellDown(c->column(), c->row()))
 
5400
    {
 
5401
      if ( selectedBrush != 0L 
 
5402
           && ( dlg->brushStyle != selectedBrush->getBrushStyle() 
 
5403
                || dlg->brushColor != selectedBrush->getBrushColor() ) )
 
5404
      {
 
5405
        c->clearProperty(KSpreadCell::PBackgroundBrush);
 
5406
        c->clearNoFallBackProperties( KSpreadCell::PBackgroundBrush );
 
5407
      }
 
5408
      if ( ( !bBgColorUndefined || b_notAnyColor )
 
5409
           && bgColor != dlg->bgColor )
 
5410
      {
 
5411
        c->clearProperty(KSpreadCell::PBackgroundColor);
 
5412
        c->clearNoFallBackProperties( KSpreadCell::PBackgroundColor );
 
5413
      }
 
5414
    }
 
5415
  }
 
5416
  applyFormat( _obj );
 
5417
 
 
5418
  RowFormat * rw = dlg->getTable()->firstRow();
 
5419
  for ( ; rw; rw = rw->next() )
 
5420
  {
 
5421
    if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PBackgroundColor) || rw->hasProperty(KSpreadCell::PBackgroundBrush)))
 
5422
    {
 
5423
      for ( int i = dlg->left; i <= dlg->right; ++i )
 
5424
      {
 
5425
        KSpreadCell * cell =
 
5426
          dlg->getTable()->nonDefaultCell( i, rw->row() );
 
5427
        applyFormat(cell );
 
5428
      }
 
5429
    }
 
5430
  }
 
5431
 
 
5432
}
 
5433
 
 
5434
void CellFormatPagePattern::apply( RowFormat *_obj )
 
5435
{
 
5436
  KSpreadSheet * table = dlg->getTable();
 
5437
  KSpreadCell * c = NULL;
 
5438
  for ( int row = dlg->top; row <= dlg->bottom; ++row)
 
5439
  {
 
5440
    for (c = table->getFirstCellRow(row); c != NULL;
 
5441
         c = table->getNextCellRight(c->column(), c->row()))
 
5442
    {
 
5443
      if ( selectedBrush != 0L
 
5444
           && ( dlg->brushStyle != selectedBrush->getBrushStyle() 
 
5445
                || dlg->brushColor != selectedBrush->getBrushColor() ) )
 
5446
      {
 
5447
        c->clearProperty(KSpreadCell::PBackgroundBrush);
 
5448
        c->clearNoFallBackProperties( KSpreadCell::PBackgroundBrush );
 
5449
      }
 
5450
      if ( ( !bBgColorUndefined || b_notAnyColor )
 
5451
           && bgColor != dlg->bgColor )
 
5452
      {
 
5453
        c->clearProperty(KSpreadCell::PBackgroundColor);
 
5454
        c->clearNoFallBackProperties( KSpreadCell::PBackgroundColor );
 
5455
      }
 
5456
    }
 
5457
  }
 
5458
  applyFormat( _obj );
 
5459
}
 
5460
 
 
5461
 
 
5462
void CellFormatPagePattern::apply( KSpreadCell *_obj )
 
5463
{
 
5464
  applyFormat( _obj );
 
5465
}
 
5466
 
 
5467
void CellFormatPagePattern::applyFormat( KSpreadFormat *_obj )
 
5468
{
 
5469
  if ( selectedBrush != 0L 
 
5470
       && ( dlg->brushStyle != selectedBrush->getBrushStyle() 
 
5471
            || dlg->brushColor != selectedBrush->getBrushColor() ) )
 
5472
    _obj->setBackGroundBrush( QBrush( selectedBrush->getBrushColor(), selectedBrush->getBrushStyle() ) );
 
5473
 
 
5474
  if ( bgColor == dlg->bgColor )
 
5475
    return;
 
5476
  
 
5477
  if ( b_notAnyColor)
 
5478
    _obj->setBgColor( QColor() );
4601
5479
  else if ( !bBgColorUndefined )
4602
 
        _obj->setBgColor( bgColor );
 
5480
    _obj->setBgColor( bgColor );
4603
5481
}
 
5482
 
4604
5483
#include "kspread_dlg_layout.moc"
 
5484