107
105
void KSpreadPatternSelect::slotSelect()
111
109
setLineWidth( 2 );
112
110
setFrameStyle( QFrame::Panel | QFrame::Plain );
116
CellLayoutDlg::CellLayoutDlg( KSpreadView *_view, KSpreadTable *_table, int _left, int _top,
117
int _right, int _bottom ) : QObject()
119
undefinedPixmap = 0L;
120
formatOnlyNegSignedPixmap = 0L;
121
formatRedOnlyNegSignedPixmap = 0L;
122
formatRedNeverSignedPixmap = 0L;
123
formatAlwaysSignedPixmap = 0L;
124
formatRedAlwaysSignedPixmap = 0L;
125
undefinedPixmap = 0L;
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;
158
bTextFontFamily = TRUE;
159
bTextFontSize = TRUE;
160
bTextFontBold = TRUE;
161
bTextFontItalic = TRUE;
164
bTextRotation = TRUE;
165
bFormatNumber = TRUE;
166
bDontprintText = TRUE;
179
KSpreadCell *obj = table->cellAt( _left, _top );
181
if( left==right && top==bottom)
183
if(obj->extraXCells()!=0 ||obj->extraYCells()!=0)
116
GeneralTab::GeneralTab( QWidget* parent, CellFormatDlg * dlg )
120
QGridLayout * layout = new QGridLayout( this, 1, 1, KDialog::marginHint(), KDialog::spacingHint(), "layout");
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() );
128
QGridLayout * groupBoxLayout = new QGridLayout( groupBox->layout() );
129
groupBoxLayout->setAlignment( Qt::AlignTop );
131
QLabel * label1 = new QLabel( groupBox, "label1" );
132
label1->setText( i18n( "Name:" ) );
133
groupBoxLayout->addWidget( label1, 0, 0 );
135
m_nameEdit = new KLineEdit( groupBox, "m_nameEdit" );
136
m_nameEdit->setText( m_dlg->styleName );
137
groupBoxLayout->addWidget( m_nameEdit, 0, 1 );
139
QLabel * label2 = new QLabel( groupBox, "label2" );
140
label2->setText( i18n( "Inherit style:" ) );
141
groupBoxLayout->addWidget( label2, 1, 0 );
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() );
148
if ( m_dlg->getStyle()->parent() )
149
m_parentBox->setCurrentText( m_dlg->getStyle()->parentName() );
152
m_parentBox->setCurrentText( i18n( "<None>" ) );
154
if ( m_dlg->getStyle()->definesAll() )
155
m_parentBox->setEnabled( false );
158
connect( m_parentBox, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotNewParent( const QString & ) ) );
159
connect( m_nameEdit, SIGNAL( lostFocus() ), this, SLOT( slotNameChanged() ) );
161
groupBoxLayout->addWidget( m_parentBox, 1, 1 );
163
QSpacerItem * spacer = new QSpacerItem( 20, 260, QSizePolicy::Minimum, QSizePolicy::Expanding );
165
layout->addWidget( groupBox, 0, 0 );
166
layout->addItem( spacer, 1, 0 );
168
if ( m_dlg->getStyle()->type() == KSpreadStyle::BUILTIN )
170
m_nameEdit->setEnabled( false );
171
m_parentBox->setEnabled( false );
174
resize( QSize( 534, 447 ).expandedTo(minimumSizeHint()) );
177
GeneralTab::~GeneralTab()
181
void GeneralTab::slotNameChanged()
186
void GeneralTab::slotNewParent( const QString & parentName )
188
kdDebug() << "New Parent" << endl;
189
if ( !checkParent( parentName ) )
192
if ( parentName.isEmpty() || parentName == i18n( "<None>" ) )
193
m_dlg->getStyle()->setParent( 0 );
195
m_dlg->getStyle()->setParent( m_dlg->getStyleManager()->style( parentName ) );
197
// Set difference to new parent, set GUI to parent values, add changes made before
201
bool GeneralTab::checkName()
203
if ( m_nameEdit->isEnabled() )
205
if ( !m_dlg->getStyleManager()->validateStyleName( m_nameEdit->text(), m_dlg->getStyle() ) )
207
KMessageBox::sorry( this, i18n( "A style with this name already exists." ) );
215
bool GeneralTab::checkParent( const QString & parentName )
217
if ( m_dlg->getStyle()->parentName() != parentName
218
&& m_parentBox->isEnabled() && parentName != i18n( "<None>" ) && !parentName.isEmpty() )
220
if ( m_nameEdit->text() == parentName )
222
KMessageBox::sorry( this, i18n( "A style cannot inherit from itself." ) );
225
if ( !m_dlg->checkCircle( m_nameEdit->text(), parentName ) )
227
KMessageBox::sorry( this,
228
i18n( "The style cannot inherit from '%1' because of recursive references." )
229
.arg( m_parentBox->currentText() ) );
233
KSpreadCustomStyle * p = m_dlg->getStyleManager()->style( parentName );
237
KMessageBox::sorry( this, i18n( "The parent style doesn't exist." ) );
245
bool GeneralTab::apply( KSpreadCustomStyle * style )
247
if ( !checkParent( m_parentBox->currentText() ) )
253
if ( m_nameEdit->isEnabled() )
255
if ( style->type() != KSpreadStyle::BUILTIN )
257
QString name( style->name() );
258
style->setName( m_nameEdit->text() );
259
if ( m_parentBox->isEnabled() )
261
if ( m_parentBox->currentText() == i18n( "None" ) || m_parentBox->currentText().isEmpty() )
262
style->setParent( 0 );
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 );
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 );
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 );
219
// Just an assumption
220
obj = table->cellAt( _right, _top );
221
if(obj->isObscuringForced())
223
int moveX=obj->obscuringCellsColumn();
225
obj = table->cellAt( moveX, moveY );
226
verticalBorderStyle = obj->leftBorderStyle( moveX,moveY );
227
verticalBorderWidth = obj->leftBorderWidth( moveX, moveY);
228
verticalBorderColor = obj->leftBorderColor( moveX, moveY );
232
verticalBorderStyle = obj->leftBorderStyle( _right, _top );
233
verticalBorderWidth = obj->leftBorderWidth( _right, _top );
234
verticalBorderColor = obj->leftBorderColor( _right, _top );
237
if(obj->isObscuringForced())
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 );
248
horizontalBorderStyle = obj->topBorderStyle( _right, _bottom );
249
horizontalBorderWidth = obj->topBorderWidth( _right, _bottom );
250
horizontalBorderColor = obj->topBorderColor( _right, _bottom );
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();
274
brushColor = obj->backGroundBrushColor( _left, _top );
275
brushStyle = obj->backGroundBrushStyle( _left,_top );
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);
283
indent = obj->getIndent(_left, _top);
285
cellText=obj->text();
290
m_value=obj->valueDouble();
292
else if(obj->isDate())
295
m_date=obj->valueDate();
297
else if(obj->isTime())
300
m_time=obj->valueTime();
310
for ( int x = _left; x <= _right; x++ )
312
cl = m_pView->activeTable()->columnLayout( x );
313
widthSize = QMAX( cl->width( /* m_pView->canvasWidget() */ ), widthSize );
319
for ( int y = _top; y <= _bottom; y++ )
321
rl = m_pView->activeTable()->rowLayout(y);
322
heigthSize = QMAX( rl->height( /* m_pView->canvasWidget() */ ),heigthSize );
330
for(int x=_left;x<=_right;x++)
332
ColumnLayout *obj=table->nonDefaultColumnLayout(x);
333
initParameters( obj,x,y);
335
KSpreadCell* c = table->firstCell();
336
for( ;c; c = c->nextCell() )
338
int col = c->column();
339
if ( _left <= col && _right >= col
340
&&!c->isObscuringForced())
342
initParameters( c ,col,c->row());
343
if ( eStyle != c->style() )
344
eStyle = KSpreadCell::ST_Undef;
349
else if( _right==0x7FFF)
352
for(int y=_top;y<=_bottom;y++)
354
RowLayout *obj=table->nonDefaultRowLayout(y);
355
initParameters( obj,x,y);
359
KSpreadCell* c = table->firstCell();
360
for( ;c; c = c->nextCell() )
363
if ( _top <= row && _bottom >= row
364
&&!c->isObscuringForced())
366
initParameters( c ,c->column(),row);
367
if ( eStyle != c->style() )
368
eStyle = KSpreadCell::ST_Undef;
264
style->setParent( m_dlg->getStyleManager()->style( m_parentBox->currentText() ) );
266
m_dlg->getStyleManager()->changeName( name, m_nameEdit->text() );
270
if ( style->type() == KSpreadStyle::TENTATIVE )
271
style->setType( KSpreadStyle::CUSTOM );
278
CellFormatDlg::CellFormatDlg( KSpreadView * _view, KSpreadSheet * _table,
279
int _left, int _top, int _right, int _bottom )
281
m_doc( _table->doc() ),
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());
292
//Do we really need these as arguments? (_view->selection())
308
KSpreadCell * obj = m_table->cellAt( _left, _top );
309
oneCell = (left == right && top == bottom &&
310
!obj->isForceExtraCells());
312
isMerged = ((obj->isForceExtraCells() &&
313
left + obj->extraXCells() >= right &&
314
top + obj->extraYCells() >= bottom));
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 );
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 );
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 );
348
// Just an assumption
349
obj = m_table->cellAt( _right, _top );
350
if ( obj->isObscuringForced() )
352
obj = obj->obscuringCells().first();
353
int moveX = obj->column();
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 );
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 );
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);
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 );
398
brushColor = obj->backGroundBrushColor( _left, _top );
399
brushStyle = obj->backGroundBrushStyle( _left,_top );
401
bMultiRow = obj->multiRow( _left, _top );
402
bVerticalText = obj->verticalText( _left, _top );
403
textRotation = obj->getAngle(_left, _top);
404
formatType = obj->getFormatType(_left, _top);
406
bDontPrintText = obj->getDontprintText( _left, _top );
407
bHideFormula = obj->isHideFormula( _left, _top );
408
bHideAll = obj->isHideAll( _left, _top );
409
bIsProtected = !obj->notProtected( _left, _top );
411
indent = obj->getIndent(_left, _top);
413
cellText = obj->text();
415
if ( obj->value().isNumber() || obj->value().isBoolean() )
418
m_value = obj->value().asFloat();
420
else if (obj->isDate())
423
m_time = obj->value().asDateTime();
425
else if (obj->isTime())
428
m_time = obj->value().asDateTime();
436
if ( !isRowSelected )
438
for ( int x = _left; x <= _right; x++ )
440
cl = m_pView->activeTable()->columnFormat( x );
441
widthSize = QMAX( cl->dblWidth(), widthSize );
445
if ( !isColumnSelected )
447
for ( int y = _top; y <= _bottom; y++ )
449
rl = m_pView->activeTable()->rowFormat(y);
450
heightSize = QMAX( rl->dblHeight(), heightSize );
455
if ( isColumnSelected )
458
KSpreadCell* c = NULL;
459
for (int x = _left;x <= _right; x++)
461
ColumnFormat *obj = m_table->nonDefaultColumnFormat(x);
462
initParameters( obj,x,y);
464
for (c = m_table->getFirstCellColumn(x); c != NULL;
465
c = m_table->getNextCellDown(c->column(), c->row()))
467
initParameters( c, x, c->row());
468
if ( eStyle != c->style() )
469
eStyle = KSpreadCell::ST_Undef;
474
else if ( isRowSelected )
477
KSpreadCell* c = NULL;
478
for ( int y = _top;y<=_bottom;y++)
480
RowFormat *obj = m_table->nonDefaultRowFormat(y);
481
initParameters( obj,x,y);
483
for (c = m_table->getFirstCellRow(y); c != NULL;
484
c = m_table->getNextCellRight(c->column(), c->row()) )
486
initParameters( c, c->column(), c->row());
487
if ( eStyle != c->style() )
488
eStyle = KSpreadCell::ST_Undef;
374
494
// Do the other objects have the same values ?
375
495
for ( int x = _left; x <= _right; x++ )
377
for ( int y = _top; y <= _bottom; y++ )
379
KSpreadCell *obj = table->cellAt( x, y );
380
if(!obj->isObscuringForced())
382
initParameters( obj,x,y);
383
if ( eStyle != obj->style() )
384
eStyle = KSpreadCell::ST_Undef;
395
ColumnLayout *obj=table->nonDefaultColumnLayout(_left);
396
checkBorderLeft( obj,_left, y);
398
KSpreadCell* c = table->firstCell();
399
for( ;c; c = c->nextCell() )
401
int col = c->column();
402
if ( _left == col &&!c->isObscuringForced())
403
checkBorderLeft( c,col,c->row());
407
obj=table->nonDefaultColumnLayout(_right);
408
checkBorderRight(obj,_right,y);
409
c = table->firstCell();
410
for( ;c; c = c->nextCell() )
412
int col = c->column();
413
if ( _right == col &&!c->isObscuringForced())
414
checkBorderRight(c,col,c->row());
418
for ( int x = _left; x <= _right; x++ )
420
KSpreadCell *obj = table->cellAt( x, _top );
421
if(!obj->isObscuringForced())
422
checkBorderTop(obj,x, _top);
425
for ( int x = _left; x <= _right; x++ )
427
KSpreadCell *obj = table->cellAt( x, _bottom );
428
if(!obj->isObscuringForced())
429
checkBorderBottom(obj,x, _bottom);
430
else if( obj->isObscuringForced() && !once)
433
int moveX=obj->obscuringCellsColumn();
434
int moveY=obj->obscuringCellsRow();
435
obj = table->nonDefaultCell( moveX, moveY );
436
checkBorderBottom(obj,moveX, moveY );
440
for ( int x = _left+1; x <= _right; x++ )
442
obj=table->nonDefaultColumnLayout(x);
443
checkBorderHorizontal(obj,x, y);
444
checkBorderVertical(obj,x, y);
448
else if( _right==0x7FFF)
452
for ( int y = _top; y <= _bottom; y++ )
454
KSpreadCell *obj = table->cellAt( _right, y );
455
if(!obj->isObscuringForced())
456
checkBorderRight(obj,_right,y);
457
else if( obj->isObscuringForced() && !once)
460
int moveX=obj->obscuringCellsColumn();
461
int moveY=obj->obscuringCellsRow();
462
obj = table->nonDefaultCell( moveX, moveY );
463
checkBorderRight(obj,moveX, moveY);
467
for ( int y = _top; y <= _bottom; y++ )
469
KSpreadCell *obj = table->cellAt( _left, y );
470
if(!obj->isObscuringForced())
471
checkBorderLeft( obj,_left, y);
475
RowLayout *obj=table->nonDefaultRowLayout(_top);
476
checkBorderTop(obj,x, _top);
477
obj=table->nonDefaultRowLayout(_bottom);
478
checkBorderBottom(obj,x, _bottom);
480
for ( int y = _top+1; y <= _bottom; y++ )
482
obj=table->nonDefaultRowLayout(y);
483
checkBorderHorizontal(obj,x, y);
484
checkBorderVertical(obj,x, y);
490
for ( int y = _top; y <= _bottom; y++ )
492
KSpreadCell *obj = table->cellAt( _left, y );
493
if(!obj->isObscuringForced())
494
checkBorderLeft( obj,_left, y);
498
for ( int y = _top; y <= _bottom; y++ )
500
KSpreadCell *obj = table->cellAt( _right, y );
501
if(!obj->isObscuringForced())
502
checkBorderRight(obj,_right,y);
503
else if( obj->isObscuringForced() && !once)
506
int moveX=obj->obscuringCellsColumn();
507
int moveY=obj->obscuringCellsRow();
508
obj = table->nonDefaultCell( moveX, moveY );
509
checkBorderRight(obj,moveX, moveY);
513
for ( int x = _left; x <= _right; x++ )
515
KSpreadCell *obj = table->cellAt( x, _top );
516
if(!obj->isObscuringForced())
517
checkBorderTop(obj,x, _top);
521
for ( int x = _left; x <= _right; x++ )
523
KSpreadCell *obj = table->cellAt( x, _bottom );
524
if(!obj->isObscuringForced())
525
checkBorderBottom(obj,x, _bottom);
526
else if( obj->isObscuringForced() && !once)
529
int moveX=obj->obscuringCellsColumn();
530
int moveY=obj->obscuringCellsRow();
531
obj = table->nonDefaultCell( moveX, moveY );
532
checkBorderBottom(obj,moveX, moveY );
537
// Look for the Outline
538
for ( int x = _left; x <= _right; x++ )
540
for ( int y = _top+1; y <= _bottom; y++ )
542
KSpreadCell *obj = table->cellAt( x, y );
543
if(!obj->isObscuringForced())
544
checkBorderHorizontal(obj,x, y);
548
for ( int x = _left+1; x <= _right; x++ )
550
for ( int y = _top; y <= _bottom; y++ )
552
KSpreadCell *obj = table->cellAt( x, y );
553
if(!obj->isObscuringForced())
554
checkBorderVertical(obj,x,y);
561
CellLayoutDlg::~CellLayoutDlg()
563
delete undefinedPixmap;
497
for ( int y = _top; y <= _bottom; y++ )
499
KSpreadCell *obj = m_table->cellAt( x, y );
501
if ( obj->isObscuringForced() )
504
initParameters( obj,x,y);
505
if ( eStyle != obj->style() )
506
eStyle = KSpreadCell::ST_Undef;
510
if ( !bTextRotation )
513
if ( isColumnSelected )
516
ColumnFormat *obj=m_table->nonDefaultColumnFormat(_left);
517
checkBorderLeft( obj,_left, y);
519
KSpreadCell* c = NULL;
520
for (c = m_table->getFirstCellColumn(_left); c != NULL;
521
c = m_table->getNextCellDown(c->column(), c->row()) )
523
checkBorderLeft(c, c->column(), c->row());
527
obj=m_table->nonDefaultColumnFormat(_right);
528
checkBorderRight(obj,_right,y);
530
for (c = m_table->getFirstCellColumn(_right); c != NULL;
531
c = m_table->getNextCellDown(c->column(), c->row()) )
533
checkBorderRight(c, c->column(), c->row());
536
for ( int x = _left; x <= _right; x++ )
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);
544
ColumnFormat *obj = m_table->nonDefaultColumnFormat(x);
545
checkBorderHorizontal(obj,x, y);
546
checkBorderVertical(obj,x, y);
550
else if ( isRowSelected )
553
for ( int y = _top; y <= _bottom; y++ )
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);
561
RowFormat* obj = m_table->nonDefaultRowFormat(y);
562
checkBorderHorizontal(obj,x, y);
563
checkBorderVertical(obj,x, y);
567
RowFormat *obj=m_table->nonDefaultRowFormat(_top);
568
checkBorderTop(obj,x, _top);
569
obj=m_table->nonDefaultRowFormat(_bottom);
570
checkBorderBottom(obj,x, _bottom);
574
for ( int y = _top; y <= _bottom; y++ )
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);
582
for ( int x = _left; x <= _right; x++ )
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 );
590
// Look for the Outline
591
for ( int x = _left; x <= _right; x++ )
593
for ( int y = _top+1; y <= _bottom; y++ )
595
KSpreadCell *obj = m_table->cellAt( x, y );
596
checkBorderHorizontal(obj,x, y);
600
for ( int x = _left+1; x <= _right; x++ )
602
for ( int y = _top; y <= _bottom; y++ )
604
KSpreadCell *obj = m_table->cellAt( x, y );
605
checkBorderVertical(obj,x,y);
613
CellFormatDlg::CellFormatDlg( KSpreadView * _view, KSpreadCustomStyle * _style,
614
KSpreadStyleManager * _manager, KSpreadDoc * doc )
620
m_styleManager( _manager )
627
void CellFormatDlg::initGUI()
629
isRowSelected = false;
630
isColumnSelected = false;
631
styleName = m_style->name();
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();
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();
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();
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();
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();
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();
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();
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();
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 );
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();
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();
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 );
699
cellText = i18n( "The quick brown fox jumps over the lazy dog" );
702
CellFormatDlg::~CellFormatDlg()
564
704
delete formatOnlyNegSignedPixmap;
565
705
delete formatRedOnlyNegSignedPixmap;
566
706
delete formatRedNeverSignedPixmap;
568
708
delete formatRedAlwaysSignedPixmap;
571
void CellLayoutDlg::checkBorderRight(KSpreadLayout *obj,int x,int y)
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;
581
void CellLayoutDlg::checkBorderLeft(KSpreadLayout *obj,int x,int y)
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;
591
void CellLayoutDlg::checkBorderTop(KSpreadLayout *obj,int x,int y)
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;
601
void CellLayoutDlg::checkBorderBottom(KSpreadLayout *obj,int x,int y)
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;
611
void CellLayoutDlg::checkBorderVertical(KSpreadLayout *obj,int x,int y)
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;
621
void CellLayoutDlg::checkBorderHorizontal(KSpreadLayout *obj,int x,int y)
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;
632
void CellLayoutDlg::initParameters(KSpreadLayout *obj,int x,int y)
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 ) )
648
if ( underline != obj->textFontUnderline( x, y ) )
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 ) )
658
if ( textColor != obj->textColor( x, y ) )
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 ) )
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 ) )
676
if( bVerticalText!=obj->verticalText( left, top ) )
677
bVerticalText = FALSE;
678
if( bDontprintText!=obj->getDontprintText( left, top ) )
679
bDontprintText= FALSE;
682
void CellLayoutDlg::init()
684
QColorGroup colorGroup = QApplication::palette().active();
685
// Did we initialize the bitmaps ?
686
if ( formatOnlyNegSignedPixmap == 0L )
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 );
695
// Make the undefined pixmap
696
undefinedPixmap = new QPixmap( 100, 12 );
698
painter.begin( undefinedPixmap );
699
painter.setBackgroundColor( colorGroup.base() );
700
painter.setPen( colorGroup.text() );
701
painter.fillRect( 0, 0, 100, 12, BDiagPattern );
705
tab = new QTabDialog( (QWidget*)m_pView, 0L, TRUE );
706
tab->setGeometry( tab->x(), tab->y(), 420, 400 );
708
borderPage = new CellLayoutPageBorder( tab, this );
709
tab->addTab( borderPage, i18n("&Border") );
711
floatPage = new CellLayoutPageFloat( tab, this );
712
tab->addTab( floatPage, i18n("&Number Format") );
714
miscPage = new CellLayoutPageMisc( tab, this );
715
tab->addTab( miscPage, i18n("&Misc") );
717
fontPage = new CellLayoutPageFont( tab, this );
718
tab->addTab( fontPage, i18n("&Text") );
720
positionPage = new CellLayoutPagePosition( tab, this);
721
tab->addTab( positionPage, i18n("&Position") );
723
patternPage=new CellLayoutPagePattern(tab,this);
724
tab->addTab( patternPage,i18n("Back&ground"));
726
tab->setCancelButton();
728
tab->setCaption(i18n("Cell Layout"));
730
connect( tab, SIGNAL( applyButtonPressed() ), this, SLOT( slotApply() ) );
735
QPixmap* CellLayoutDlg::paintFormatPixmap( const char *_string1, const QColor & _color1,
736
const char *_string2, const QColor & _color2 )
738
QPixmap *pixmap = new QPixmap( 150, 14 );
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 );
752
int CellLayoutDlg::exec()
754
return ( tab->exec() );
757
void CellLayoutDlg::slotApply()
759
KSpreadMacroUndoAction *macroUndo=new KSpreadMacroUndoAction( table->doc(),i18n("Change Layout") );
761
if( isMerged!= positionPage->getMergedCellState())
763
if(positionPage->getMergedCellState())
765
KSpreadCell *obj = table->nonDefaultCell( left,top );
767
KSpreadUndoMergedCell *undo = new KSpreadUndoMergedCell( table->doc(), table, left ,top ,obj->extraXCells() ,obj->extraYCells());
768
macroUndo->addCommand(undo);
770
//merge cell doesn't create undo
771
table->mergeCell(QPoint(left,top),false);
778
KSpreadCell *obj = table->nonDefaultCell( left,top );
779
right=obj->extraXCells()+left;
780
bottom=obj->extraYCells()+top;
782
KSpreadUndoMergedCell *undo = new KSpreadUndoMergedCell( table->doc(), table, left ,top,obj->extraXCells() ,obj->extraYCells());
783
macroUndo->addCommand(undo);
785
table->dissociateCell(QPoint(left,top),false);
790
// Prepare the undo buffer
791
if ( !table->doc()->undoBuffer()->isLocked() )
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)
802
//create cell before to apply
803
RowLayout* rw =table->firstRow();
804
for( ; rw; rw = rw->next() )
806
if ( !rw->isDefault() )
808
for(int i=left;i<=right;i++)
810
KSpreadCell *cell = table->cellAt( i, rw->row());
811
if ( cell->isDefault() )
813
cell = new KSpreadCell( table, i, rw->row() );
814
table->insertCell( cell);
819
rect.setCoords( left, top, right+1 , bottom );
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);
827
if( miscPage->getStyle()!=eStyle)
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);
835
borderPage->applyOutline( left, top, right, bottom );
839
if(right!=0x7FFF && bottom!=0x7FFF)
841
for ( int x = left; x <= right; x++ )
842
for ( int y = top; y <= bottom; y++ )
844
KSpreadCell *obj = table->nonDefaultCell( x, y );
845
if(!obj->isObscuringForced())
847
floatPage->apply( obj );
848
miscPage->apply( obj );
849
fontPage->apply( obj );
850
positionPage->apply( obj );
851
patternPage->apply(obj);
856
if(positionPage->getSizeHeight()!=heigthSize
857
|| positionPage->getSizeWidth()!=widthSize)
859
if ( !table->doc()->undoBuffer()->isLocked())
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);
868
if(positionPage->getSizeHeight()!=heigthSize)
870
for ( int x = top; x <= bottom; x++ )
871
m_pView->vBorderWidget()->resizeRow(positionPage->getSizeHeight(),x,false );
874
if(positionPage->getSizeWidth()!=widthSize)
876
for ( int x = left; x <= right; x++ )
877
m_pView->hBorderWidget()->resizeColumn(positionPage->getSizeWidth(),x,false );
881
else if( right==0x7FFF )
883
for(int i=top;i<=bottom;i++)
885
RowLayout *rw=table->nonDefaultRowLayout(i);
886
floatPage->apply(rw );
887
fontPage->apply( rw );
888
positionPage->apply( rw );
889
patternPage->apply(rw);
891
miscPage->applyRow( );
892
if(positionPage->getSizeHeight()!=heigthSize)
894
if ( !table->doc()->undoBuffer()->isLocked())
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);
902
for ( int x = top; x <= bottom; x++ )
903
m_pView->vBorderWidget()->resizeRow(positionPage->getSizeHeight(),x,false );
906
else if( bottom==0x7FFF)
908
for(int i=left;i<=right;i++)
910
ColumnLayout *cl=table->nonDefaultColumnLayout(i);
911
floatPage->apply(cl );
912
fontPage->apply( cl );
913
positionPage->apply( cl );
914
patternPage->apply(cl);
916
miscPage->applyColumn( );
918
if( positionPage->getSizeWidth()!=widthSize)
920
if ( !table->doc()->undoBuffer()->isLocked())
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);
928
for ( int x = left; x <= right; x++ )
929
m_pView->hBorderWidget()->resizeColumn(positionPage->getSizeWidth(),x,false );
933
if ( !table->doc()->undoBuffer()->isLocked())
935
table->doc()->undoBuffer()->appendUndo( macroUndo );
937
// m_pView->drawVisibleCells();
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();
947
CellLayoutPageFloat::CellLayoutPageFloat( QWidget* parent, CellLayoutDlg *_dlg ) : QWidget ( parent )
711
void CellFormatDlg::initMembers()
713
formatOnlyNegSignedPixmap = 0L;
714
formatRedOnlyNegSignedPixmap = 0L;
715
formatRedNeverSignedPixmap = 0L;
716
formatAlwaysSignedPixmap = 0L;
717
formatRedAlwaysSignedPixmap = 0L;
723
// We assume, that all other objects have the same values
724
for ( int i = 0; i < BorderType_END; ++i )
726
borders[i].bStyle = true;
727
borders[i].bColor = true;
733
bTextFontFamily = true;
734
bTextFontSize = true;
735
bTextFontBold = true;
736
bTextFontItalic = true;
739
bTextRotation = true;
742
bDontPrintText = false;
743
bHideFormula = false;
747
cCurrency.symbol = locale()->currencySymbol();
751
bool CellFormatDlg::checkCircle( QString const & name, QString const & parent )
753
return m_styleManager->checkCircle( name, parent );
756
void CellFormatDlg::checkBorderRight(KSpreadFormat *obj,int x,int y)
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;
765
void CellFormatDlg::checkBorderLeft(KSpreadFormat *obj,int x,int y)
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;
774
void CellFormatDlg::checkBorderTop(KSpreadFormat *obj,int x,int y)
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;
783
void CellFormatDlg::checkBorderBottom(KSpreadFormat *obj,int x,int y)
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;
792
void CellFormatDlg::checkBorderVertical(KSpreadFormat *obj,int x,int y)
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;
801
void CellFormatDlg::checkBorderHorizontal(KSpreadFormat *obj,int x,int y)
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;
811
void CellFormatDlg::initParameters(KSpreadFormat *obj,int x,int y)
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;
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 ) )
828
if ( underline != obj->textFontUnderline( x, y ) )
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 ) )
838
if ( textColor != obj->textColor( x, y ) )
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 ) )
850
if ( textRotation != obj->getAngle(left, top) )
851
bTextRotation = false;
852
if ( formatType != obj->getFormatType(left, top) )
854
if ( bMultiRow != obj->multiRow( left, top ) )
856
if ( bVerticalText!=obj->verticalText( left, top ) )
857
bVerticalText = false;
858
if ( bDontPrintText!=obj->getDontprintText( left, top ) )
859
bDontPrintText= false;
861
KSpreadCell::Currency cur;
862
if (!obj->currencyInfo(cur))
865
if (cur.symbol != cCurrency.symbol)
869
void CellFormatDlg::init()
871
QColorGroup colorGroup = QApplication::palette().active();
873
// Did we initialize the bitmaps ?
874
if ( formatOnlyNegSignedPixmap == 0L )
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 );
884
tab = new QTabDialog( (QWidget*)m_pView, 0L, true );
885
tab->setGeometry( tab->x(), tab->y(), 420, 400 );
889
generalPage = new GeneralTab( tab, this );
890
tab->addTab( generalPage, i18n( "&General" ) );
893
floatPage = new CellFormatPageFloat( tab, this );
894
tab->addTab( floatPage, i18n("&Data Format") );
896
fontPage = new CellFormatPageFont( tab, this );
897
tab->addTab( fontPage, i18n("&Text") );
899
// miscPage = new CellFormatPageMisc( tab, this );
900
// tab->addTab( miscPage, i18n("&Misc") );
902
positionPage = new CellFormatPagePosition( tab, this);
903
tab->addTab( positionPage, i18n("&Position") );
905
borderPage = new CellFormatPageBorder( tab, this );
906
tab->addTab( borderPage, i18n("&Border") );
908
patternPage=new CellFormatPagePattern(tab,this);
909
tab->addTab( patternPage,i18n("Back&ground"));
911
protectPage = new CellFormatPageProtection( tab, this );
912
tab->addTab( protectPage, i18n("&Cell Protection") );
914
tab->setCancelButton( i18n( "&Cancel" ) );
915
tab->setOkButton( i18n( "&OK" ) );
917
tab->setCaption( i18n( "Cell Format" ) );
919
connect( tab, SIGNAL( applyButtonPressed() ), this, SLOT( slotApply() ) );
924
QPixmap * CellFormatDlg::paintFormatPixmap( const char * _string1, const QColor & _color1,
925
const char *_string2, const QColor & _color2 )
927
QPixmap * pixmap = new QPixmap( 150, 14 );
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 );
938
QBitmap bm( pixmap->size() );
940
painter.begin( &bm );
941
painter.setPen( color1 );
942
painter.drawText( 2, 11, _string1 );
943
painter.drawText( 75, 11, _string2 );
945
pixmap->setMask( bm );
950
int CellFormatDlg::exec()
952
return ( tab->exec() );
955
void CellFormatDlg::applyStyle()
957
generalPage->apply( m_style );
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 );
968
void CellFormatDlg::slotApply()
976
m_pView->doc()->emitBeginOperation( false );
977
KSpreadCell * cell = 0;
979
KSpreadMacroUndoAction * macroUndo = new KSpreadMacroUndoAction( m_doc, i18n("Change Format") );
981
if ( isMerged != positionPage->getMergedCellState() )
983
if ( positionPage->getMergedCellState() )
985
KSpreadCell * obj = m_table->nonDefaultCell( left, top );
987
KSpreadUndoMergedCell * undo = new KSpreadUndoMergedCell( m_doc, m_table, left,
988
top, obj->extraXCells(), obj->extraYCells() );
989
macroUndo->addCommand( undo );
991
//merge cell doesn't create undo
992
m_table->mergeCells( m_pView->selection(), false );
999
KSpreadCell * obj = m_table->nonDefaultCell( left, top );
1000
right = obj->extraXCells() + left;
1001
bottom = obj->extraYCells() + top;
1003
KSpreadUndoMergedCell * undo = new KSpreadUndoMergedCell( m_doc, m_table, left,
1004
top, obj->extraXCells(), obj->extraYCells() );
1005
macroUndo->addCommand(undo);
1007
m_table->dissociateCell(QPoint(left,top),false);
1011
// Prepare the undo buffer
1012
if ( !m_doc->undoBuffer()->isLocked() )
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 )
1024
//create cell before to apply
1025
RowFormat * rw = m_table->firstRow();
1026
for ( ; rw; rw = rw->next() )
1028
if ( !rw->isDefault() )
1030
for ( int i = left; i <= right; ++i )
1032
cell = m_table->nonDefaultCell( i, rw->row() );
1036
rect.setCoords( left, top, right + 1, bottom );
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 );
1044
/* if ( miscPage->getStyle()!=eStyle)
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 );
1052
borderPage->applyOutline();
1054
if ( ( !isRowSelected ) && ( !isColumnSelected ) )
1056
for ( int x = left; x <= right; x++ )
1057
for ( int y = top; y <= bottom; y++ )
1059
KSpreadCell *obj = m_table->nonDefaultCell( x, y );
1060
if ( !obj->isObscuringForced() )
1062
floatPage->apply( obj );
1063
// miscPage->apply( obj );
1064
fontPage->apply( obj );
1065
positionPage->apply( obj );
1066
patternPage->apply(obj);
1067
protectPage->apply( obj );
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 ) )
1075
if ( !m_doc->undoBuffer()->isLocked() )
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 );
1084
if ( int( positionPage->getSizeHeight() ) != int( heightSize ) )
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 );
1090
if ( int( positionPage->getSizeWidth() ) != int( widthSize ) )
1091
// The loop seems to be doubled, already done in resizeColumn: Philipp -> fixme
1093
for ( int x = left; x <= right; x++ )
1094
m_pView->hBorderWidget()->resizeColumn( positionPage->getSizeWidth(), x, false );
1097
else if ( isRowSelected )
1099
for ( int i = top; i <= bottom; i++ )
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 );
1108
// miscPage->applyRow( );
1109
if ( int( positionPage->getSizeHeight() ) != int( heightSize ) )
1111
if ( !m_doc->undoBuffer()->isLocked())
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);
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 );
1123
else if ( isColumnSelected )
1125
for ( int i = left; i <= right; ++i )
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 );
1134
// miscPage->applyColumn( );
1136
if ( int( positionPage->getSizeWidth() ) != int( widthSize ) )
1138
if ( !m_doc->undoBuffer()->isLocked())
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);
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 );
1151
if ( !m_doc->undoBuffer()->isLocked())
1152
m_doc->undoBuffer()->appendUndo( macroUndo );
1154
// m_pView->drawVisibleCells();
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 );
1164
CellFormatPageFloat::CellFormatPageFloat( QWidget* parent, CellFormatDlg *_dlg )
1165
: QWidget ( parent ),
951
1168
QVBoxLayout* layout = new QVBoxLayout( this, 6,10 );
1170
QButtonGroup *grp = new QButtonGroup( i18n("Format"),this);
1171
QGridLayout *grid = new QGridLayout(grp,10,2,KDialog::marginHint(), KDialog::spacingHint());
1173
int fHeight = grp->fontMetrics().height();
1174
grid->addRowSpacing( 0, fHeight/2 ); // groupbox title
1176
grp->setRadioButtonExclusive( true );
1177
number=new QRadioButton(i18n("Number"),grp);
1178
grid->addWidget(number,1,0);
1180
percent=new QRadioButton(i18n("Percent"),grp);
1181
grid->addWidget(percent,2,0);
1183
money=new QRadioButton(i18n("Money"),grp);
1184
grid->addWidget(money,3,0);
1186
scientific=new QRadioButton(i18n("Scientific"),grp);
1187
grid->addWidget(scientific,4,0);
1189
fraction=new QRadioButton(i18n("Fraction"),grp);
1190
grid->addWidget(fraction,5,0);
1192
date=new QRadioButton(i18n("Date format"),grp);
1193
grid->addWidget(date,6,0);
1195
time=new QRadioButton(i18n("Time format"),grp);
1196
grid->addWidget(time,7,0);
1198
textFormat=new QRadioButton(i18n("Text"),grp);
1199
grid->addWidget(textFormat,8,0);
1201
customFormat=new QRadioButton(i18n("Custom"),grp);
1202
grid->addWidget(customFormat,9,0);
1203
customFormat->setEnabled( false );
1205
QGroupBox *box2 = new QGroupBox( grp, "Box");
1206
box2->setTitle(i18n("Preview"));
1207
QGridLayout *grid3 = new QGridLayout(box2,1,3,KDialog::marginHint(), KDialog::spacingHint());
1209
exampleLabel=new QLabel(box2);
1210
grid3->addWidget(exampleLabel,0,1);
1212
grid->addMultiCellWidget(box2,8,9,1,1);
1214
customFormatEdit = new QLineEdit( grp );
1215
grid->addMultiCellWidget( customFormatEdit, 1, 1, 1, 1 );
1216
customFormatEdit->setHidden( true );
1218
listFormat=new QListBox(grp);
1219
grid->addMultiCellWidget(listFormat,2,7,1,1);
1220
layout->addWidget(grp);
952
1224
QGroupBox *box = new QGroupBox( this, "Box");
954
QGridLayout *grid = new QGridLayout(box,3,4,7,7);
1226
grid = new QGridLayout(box,3,4,KDialog::marginHint(), KDialog::spacingHint());
957
1228
postfix = new QLineEdit( box, "LineEdit_1" );
958
1229
grid->addWidget(postfix,2,1);
1570
if(m_bFormatNumberChanged)
1572
_obj->setFaktor(1.0);
1573
if(number->isChecked())
1574
_obj->setFormatNumber(KSpreadCell::Number);
1575
else if(percent->isChecked())
1577
_obj->setFormatNumber(KSpreadCell::Percentage);
1578
_obj->setFaktor(100.0);
1580
else if(fraction->isChecked())
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);
1601
else if(date->isChecked())
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 );
1642
else if(time->isChecked())
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 );
1655
else if(money->isChecked())
1656
_obj->setFormatNumber(KSpreadCell::Money);
1657
else if(scientific->isChecked())
1658
_obj->setFormatNumber(KSpreadCell::Scientific);
1662
void CellLayoutPageFloat::apply( KSpreadCell *_obj )
1667
void CellLayoutPageFloat::apply( RowLayout *_obj )
1669
KSpreadCell*c= dlg->getTable()->firstCell();
1670
for( ;c; c = c->nextCell() )
1673
if ( dlg->top <= row && dlg->bottom >= row
1674
&&!c->isObscuringForced())
1676
if ( dlg->precision != precision->value() )
1678
c->clearProperty(KSpreadCell::PPrecision);
1679
c->clearNoFallBackProperties( KSpreadCell::PPrecision );
1681
if ( postfix->text() != dlg->postfix )
1683
if ( postfix->text() != "########" )
1685
c->clearProperty(KSpreadCell::PPostfix);
1686
c->clearNoFallBackProperties( KSpreadCell::PPostfix );
1689
if ( prefix->text() != dlg->prefix )
1691
if ( postfix->text() != "########" )
1693
c->clearProperty(KSpreadCell::PPrefix);
1694
c->clearNoFallBackProperties( KSpreadCell::PPrefix );
1697
if(m_bFormatColorChanged)
1699
c->clearProperty(KSpreadCell::PFloatFormat);
1700
c->clearNoFallBackProperties( KSpreadCell::PFloatFormat );
1701
c->clearProperty(KSpreadCell::PFloatColor);
1702
c->clearNoFallBackProperties( KSpreadCell::PFloatColor );
1704
if(m_bFormatNumberChanged)
1706
c->clearProperty(KSpreadCell::PFormatNumber);
1707
c->clearNoFallBackProperties( KSpreadCell::PFormatNumber );
1708
c->clearProperty(KSpreadCell::PFaktor);
1709
c->clearNoFallBackProperties( KSpreadCell::PFaktor );
1716
void CellLayoutPageFloat::apply( ColumnLayout *_obj )
1718
KSpreadCell*c= dlg->getTable()->firstCell();
1719
for( ;c; c = c->nextCell() )
1721
int col = c->column();
1722
if ( dlg->left <= col && dlg->right >= col
1723
&&!c->isObscuringForced())
1725
if ( dlg->precision != precision->value() )
1727
c->clearProperty(KSpreadCell::PPrecision);
1728
c->clearNoFallBackProperties( KSpreadCell::PPrecision );
1730
if ( postfix->text() != dlg->postfix )
1732
if ( postfix->text() != "########" )
1734
c->clearProperty(KSpreadCell::PPostfix);
1735
c->clearNoFallBackProperties( KSpreadCell::PPostfix );
1738
if ( prefix->text() != dlg->prefix )
1740
if ( prefix->text() != "########" )
1742
c->clearProperty(KSpreadCell::PPrefix);
1743
c->clearNoFallBackProperties( KSpreadCell::PPrefix );
1746
if(m_bFormatColorChanged)
1748
c->clearProperty(KSpreadCell::PFloatFormat);
1749
c->clearNoFallBackProperties( KSpreadCell::PFloatFormat );
1750
c->clearProperty(KSpreadCell::PFloatColor);
1751
c->clearNoFallBackProperties( KSpreadCell::PFloatColor );
1753
if(m_bFormatNumberChanged)
1755
c->clearProperty(KSpreadCell::PFormatNumber);
1756
c->clearNoFallBackProperties( KSpreadCell::PFormatNumber );
1757
c->clearProperty(KSpreadCell::PFaktor);
1758
c->clearNoFallBackProperties( KSpreadCell::PFaktor );
1764
RowLayout* rw =dlg->getTable()->firstRow();
1765
for( ; rw; rw = rw->next() )
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) ))
1772
for(int i=dlg->left;i<=dlg->right;i++)
1774
KSpreadCell *cell = dlg->getTable()->cellAt( i, rw->row());
1775
if ( cell->isDefault() )
1777
cell = new KSpreadCell( dlg->getTable(), i, rw->row() );
1778
dlg->getTable()->insertCell( cell);
1788
CellLayoutPageMisc::CellLayoutPageMisc( QWidget* parent, CellLayoutDlg *_dlg ) : QWidget( parent )
2180
if (m_bFormatTypeChanged)
2182
_obj->setFactor(1.0);
2183
if (number->isChecked())
2184
_obj->setFormatType(KSpreadCell::Number);
2185
else if (percent->isChecked())
2187
_obj->setFormatType(KSpreadCell::Percentage);
2188
_obj->setFactor(100.0);
2190
else if (fraction->isChecked())
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);
2211
else if (date->isChecked())
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 );
2270
else if (time->isChecked())
2272
int current = listFormat->currentItem();
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 );
2294
else if (money->isChecked())
2296
_obj->setFormatType(KSpreadCell::Money);
2297
KSpreadCell::Currency cur;
2298
int index = currency->currentItem();
2301
if ( currency->currentText() == i18n( "Automatic" ) )
2303
cur.symbol = dlg->locale()->currencySymbol();
2309
cur.symbol = currency->currentText();
2315
cur.symbol = KSpreadCurrency::getDisplaySymbol( index );
2318
_obj->setCurrency( cur.type, cur.symbol );
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);
2329
void CellFormatPageFloat::apply( KSpreadCell *_obj )
2334
void CellFormatPageFloat::apply( RowFormat *_obj )
2336
KSpreadSheet* table = dlg->getTable();
2337
KSpreadCell* c = NULL;
2338
for (int row = dlg->top; row <= dlg->bottom; row++)
2340
for ( c = table->getFirstCellRow(row); c != NULL;
2341
c = table->getNextCellRight(c->column(), c->row()) )
2343
if ( dlg->precision != precision->value() )
2345
c->clearProperty(KSpreadCell::PPrecision);
2346
c->clearNoFallBackProperties( KSpreadCell::PPrecision );
2348
if ( postfix->text() != dlg->postfix )
2350
if ( postfix->text() != "########" )
2352
c->clearProperty(KSpreadCell::PPostfix);
2353
c->clearNoFallBackProperties( KSpreadCell::PPostfix );
2356
if ( prefix->text() != dlg->prefix )
2358
if ( postfix->text() != "########" )
2360
c->clearProperty(KSpreadCell::PPrefix);
2361
c->clearNoFallBackProperties( KSpreadCell::PPrefix );
2364
if (m_bFormatColorChanged)
2366
c->clearProperty(KSpreadCell::PFloatFormat);
2367
c->clearNoFallBackProperties( KSpreadCell::PFloatFormat );
2368
c->clearProperty(KSpreadCell::PFloatColor);
2369
c->clearNoFallBackProperties( KSpreadCell::PFloatColor );
2371
if (m_bFormatTypeChanged)
2373
c->clearProperty(KSpreadCell::PFormatType);
2374
c->clearNoFallBackProperties( KSpreadCell::PFormatType );
2375
c->clearProperty(KSpreadCell::PFactor);
2376
c->clearNoFallBackProperties( KSpreadCell::PFactor );
2383
void CellFormatPageFloat::apply( ColumnFormat *_obj )
2385
KSpreadSheet *table = dlg->getTable();
2386
KSpreadCell* c = NULL;
2387
for (int col = dlg->left; col <= dlg->right; col++)
2389
for ( c = table->getFirstCellColumn(col); c != NULL;
2390
c = table->getNextCellDown(c->column(), c->row()) )
2392
if ( dlg->precision != precision->value() )
2394
c->clearProperty(KSpreadCell::PPrecision);
2395
c->clearNoFallBackProperties( KSpreadCell::PPrecision );
2397
if ( postfix->text() != dlg->postfix )
2399
if ( postfix->text() != "########" )
2401
c->clearProperty(KSpreadCell::PPostfix);
2402
c->clearNoFallBackProperties( KSpreadCell::PPostfix );
2405
if ( prefix->text() != dlg->prefix )
2407
if ( prefix->text() != "########" )
2409
c->clearProperty(KSpreadCell::PPrefix);
2410
c->clearNoFallBackProperties( KSpreadCell::PPrefix );
2413
if (m_bFormatColorChanged)
2415
c->clearProperty(KSpreadCell::PFloatFormat);
2416
c->clearNoFallBackProperties( KSpreadCell::PFloatFormat );
2417
c->clearProperty(KSpreadCell::PFloatColor);
2418
c->clearNoFallBackProperties( KSpreadCell::PFloatColor );
2420
if (m_bFormatTypeChanged)
2422
c->clearProperty(KSpreadCell::PFormatType);
2423
c->clearNoFallBackProperties( KSpreadCell::PFormatType );
2424
c->clearProperty(KSpreadCell::PFactor);
2425
c->clearNoFallBackProperties( KSpreadCell::PFactor );
2431
RowFormat* rw =dlg->getTable()->firstRow();
2432
for ( ; rw; rw = rw->next() )
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) ))
2443
for ( int i=dlg->left;i<=dlg->right;i++)
2445
KSpreadCell *cell = dlg->getTable()->nonDefaultCell( i, rw->row() );
2452
CellFormatPageProtection::CellFormatPageProtection( QWidget* parent, CellFormatDlg * _dlg )
2453
: QWidget( parent ),
2456
QVBoxLayout * Form1Layout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint(), "Form1Layout");
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() );
2463
m_bIsProtected = new QCheckBox( i18n( "&Protected" ), groupBox1, "m_bIsProtected" );
2464
m_bIsProtected->setChecked( true );
2465
groupBox1Layout->addWidget( m_bIsProtected );
2467
m_bHideFormula = new QCheckBox( i18n( "&Hide formula" ), groupBox1, "m_bHideFormula" );
2468
groupBox1Layout->addWidget( m_bHideFormula );
2470
m_bHideAll = new QCheckBox( i18n( "Hide &all" ), groupBox1, "m_bHideAll" );
2471
groupBox1Layout->addWidget( m_bHideAll );
2472
Form1Layout->addWidget( groupBox1 );
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() );
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 );
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 );
2491
CellFormatPageProtection::~CellFormatPageProtection()
2495
void CellFormatPageProtection::apply( KSpreadCustomStyle * style )
2497
if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked() )
2499
if ( m_bDontPrint->isChecked() )
2500
style->addProperty( KSpreadStyle::PDontPrintText );
2502
style->removeProperty( KSpreadStyle::PDontPrintText );
2505
if ( m_dlg->bIsProtected != m_bIsProtected->isChecked() )
2507
if ( !m_bIsProtected->isChecked() )
2508
style->addProperty( KSpreadStyle::PNotProtected );
2510
style->removeProperty( KSpreadStyle::PNotProtected );
2513
if ( m_dlg->bHideAll != m_bHideAll->isChecked() )
2515
if ( m_bHideAll->isChecked() )
2516
style->addProperty( KSpreadStyle::PHideAll );
2518
style->removeProperty( KSpreadStyle::PHideAll );
2521
if ( m_dlg->bHideFormula != m_bHideFormula->isChecked() )
2523
if ( m_bHideFormula->isChecked() )
2524
style->addProperty( KSpreadStyle::PHideFormula );
2526
style->removeProperty( KSpreadStyle::PHideFormula );
2530
void CellFormatPageProtection::apply( KSpreadCell * _cell )
2532
applyFormat( _cell );
2535
void CellFormatPageProtection::apply( ColumnFormat * _col )
2537
KSpreadSheet * table = m_dlg->getTable();
2538
KSpreadCell * c = 0;
2539
for (int col = m_dlg->left; col <= m_dlg->right; col++)
2541
for ( c = table->getFirstCellColumn( col ); c != 0;
2542
c = table->getNextCellDown( c->column(), c->row() ) )
2544
if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked() )
2546
c->clearProperty( KSpreadCell::PDontPrintText );
2547
c->clearNoFallBackProperties( KSpreadCell::PDontPrintText );
2549
if ( m_dlg->bIsProtected != m_bIsProtected->isChecked() )
2551
c->clearProperty( KSpreadCell::PNotProtected );
2552
c->clearNoFallBackProperties( KSpreadCell::PNotProtected );
2554
if ( m_dlg->bHideFormula != m_bHideFormula->isChecked() )
2556
c->clearProperty( KSpreadCell::PHideFormula );
2557
c->clearNoFallBackProperties( KSpreadCell::PHideFormula );
2559
if ( m_dlg->bHideAll != m_bHideAll->isChecked() )
2561
c->clearProperty( KSpreadCell::PHideAll );
2562
c->clearNoFallBackProperties( KSpreadCell::PHideAll );
2567
applyFormat( _col );
2570
void CellFormatPageProtection::apply( RowFormat * _row )
2572
KSpreadSheet * table = m_dlg->getTable();
2573
KSpreadCell * c = 0;
2574
for ( int row = m_dlg->top; row <= m_dlg->bottom; ++row)
2576
for ( c = table->getFirstCellRow( row ); c != 0;
2577
c = table->getNextCellRight( c->column(), c->row() ) )
2579
if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked() )
2581
c->clearProperty( KSpreadCell::PDontPrintText );
2582
c->clearNoFallBackProperties( KSpreadCell::PDontPrintText );
2584
if ( m_dlg->bIsProtected != m_bIsProtected->isChecked() )
2586
c->clearProperty( KSpreadCell::PNotProtected );
2587
c->clearNoFallBackProperties( KSpreadCell::PNotProtected );
2589
if ( m_dlg->bHideFormula != m_bHideFormula->isChecked() )
2591
c->clearProperty( KSpreadCell::PHideFormula );
2592
c->clearNoFallBackProperties( KSpreadCell::PHideFormula );
2594
if ( m_dlg->bHideAll != m_bHideAll->isChecked() )
2596
c->clearProperty( KSpreadCell::PHideAll );
2597
c->clearNoFallBackProperties( KSpreadCell::PHideAll );
2602
applyFormat( _row );
2605
void CellFormatPageProtection::applyFormat( KSpreadFormat * _obj )
2607
if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked())
2608
_obj->setDontPrintText( m_bDontPrint->isChecked() );
2610
if ( m_dlg->bIsProtected != m_bIsProtected->isChecked())
2611
_obj->setNotProtected( !m_bIsProtected->isChecked() );
2613
if ( m_dlg->bHideAll != m_bHideAll->isChecked())
2614
_obj->setHideAll( m_bHideAll->isChecked() );
2616
if ( m_dlg->bHideFormula != m_bHideFormula->isChecked())
2617
_obj->setHideFormula( m_bHideFormula->isChecked() );
2621
CellFormatPageMisc::CellFormatPageMisc( QWidget* parent, CellFormatDlg *_dlg ) : QWidget( parent )
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");
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;
1799
2632
tmpQLabel = new QLabel( box, "Label_3" );
2363
CellLayoutPagePosition::CellLayoutPagePosition( QWidget* parent, CellLayoutDlg *_dlg ) : QWidget( parent )
3241
CellFormatPagePosition::CellFormatPagePosition( QWidget* parent, CellFormatDlg *_dlg )
3242
: QWidget( parent ),
2367
QGridLayout *grid3 = new QGridLayout(this,4,2,15,7);
2368
QButtonGroup *grp = new QButtonGroup( i18n("Horizontal"),this);
2369
grp->setRadioButtonExclusive( TRUE );
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 );
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);
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);
2391
connect(grp, SIGNAL(clicked(int)),this,SLOT(slotStateChanged(int)));
2393
grp = new QButtonGroup( i18n("Vertical"),this);
2394
grp->setRadioButtonExclusive( TRUE );
2396
grid2 = new QGridLayout(grp,3,1,15,7);
3259
grid2->addWidget(right, 3, 1);
3260
grid3->addWidget(grp, 0, 0);
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 );
3271
connect(grp, SIGNAL(clicked(int)), this, SLOT(slotStateChanged(int)));
3273
grp = new QButtonGroup( i18n("Vertical"), this);
3274
grp->setRadioButtonExclusive( true );
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);
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);
2412
grp = new QButtonGroup( i18n("Text option"),this);
3284
grid2->addWidget(bottom, 3, 0);
3285
grid3->addWidget(grp, 0, 1);
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 );
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);
2417
grid2->addWidget(multi,0,0);
3301
grid2->addWidget(multi, 1, 0);
2418
3302
multi->setChecked(dlg->bMultiRow);
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);
2424
grid3->addWidget(grp,1,0);
2426
grp = new QButtonGroup( i18n("Rotation"),this);
2428
grid2 = new QGridLayout(grp,1,1,15,7);
3308
grid3->addWidget(grp, 1, 0);
3310
grp = new QButtonGroup(i18n("Rotation"), this);
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(" �");
2434
grid2->addWidget(angleRotation,0,0);
2435
grid3->addWidget(grp,1,1);
2436
if(dlg->textRotation!=0)
2438
multi->setEnabled(false);
3320
grid2->addWidget(angleRotation, 1, 0);
3321
grid3->addWidget(grp, 1, 1);
3322
if ( dlg->textRotation != 0 )
3324
multi->setEnabled(false );
2439
3325
vertical->setEnabled(false);
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);
3328
grp = new QButtonGroup( i18n("Merge Cells"), this);
3329
grid2 = new QGridLayout(grp, 2, 1, KDialog::marginHint(), KDialog::spacingHint());
3331
fHeight = grp->fontMetrics().height();
3332
grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
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);
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);
2458
grp = new QButtonGroup( i18n("Size of cell"),this);
2459
grid2 = new QGridLayout(grp,2,4,15,7);
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);
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
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);
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
3358
QLabel *tmpLabel=new QLabel(grp, "label");
2462
3359
tmpLabel->setText(i18n("Width:"));
2463
grid2->addWidget(tmpLabel,0,0);
2465
width=new KIntNumInput(dlg->widthSize, grp, 10);
2466
if(dlg->right==0x7FFF && (dlg->right!=dlg->left))
3360
grid2->addWidget(tmpLabel, 1, 0);
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() );
3368
if ( dlg->isRowSelected )
2467
3369
width->setEnabled(false);
2468
width->setRange(2, 400, 1);
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);
2475
grid2->addMultiCellWidget(defaultWidth,1,1,0,1);
3376
grid2->addMultiCellWidget(defaultWidth, 2, 2, 0, 1);
2477
tmpLabel=new QLabel(grp,"label1");
3378
tmpLabel=new QLabel(grp, "label1");
2478
3379
tmpLabel->setText(i18n("Height:"));
2479
grid2->addWidget(tmpLabel,0,2);
2481
height=new KIntNumInput(dlg->heigthSize, grp, 10);
2482
if(dlg->bottom==0x7FFF && (dlg->bottom!=dlg->top))
3380
grid2->addWidget(tmpLabel, 1, 2);
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() );
3388
if ( dlg->isColumnSelected )
2483
3389
height->setEnabled(false);
2485
height->setRange(2, 400, 1);
2486
grid2->addWidget(height,0,3);
3391
grid2->addWidget(height, 1, 3);
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);
2492
grid2->addMultiCellWidget(defaultHeight,1,1,2,3);
3397
grid2->addMultiCellWidget(defaultHeight, 2, 2, 2, 3);
2494
grid3->addMultiCellWidget(grp,3,3,0,1);
3399
grid3->addMultiCellWidget(grp, 3, 3, 0, 1);
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)));
3407
slotStateChanged( 0 );
3408
m_bOptionText = false;
2503
3409
this->resize( 400, 400 );
2506
void CellLayoutPagePosition::slotChangeMultiState()
3412
void CellFormatPagePosition::slotChangeMultiState()
2509
if(vertical->isChecked())
3414
m_bOptionText = true;
3415
if (vertical->isChecked())
2511
3417
vertical->setChecked(false);
2515
void CellLayoutPagePosition::slotChangeVerticalState()
3421
void CellFormatPagePosition::slotChangeVerticalState()
2518
if(multi->isChecked())
3424
if (multi->isChecked())
2520
3426
multi->setChecked(false);
2525
void CellLayoutPagePosition::slotStateChanged(int)
3431
void CellFormatPagePosition::slotStateChanged(int)
2527
if(right->isChecked() || center->isChecked())
3433
if (right->isChecked() || center->isChecked())
2528
3434
indent->setEnabled(false);
2530
3436
indent->setEnabled(true);
2533
bool CellLayoutPagePosition::getMergedCellState()
3439
bool CellFormatPagePosition::getMergedCellState()
2535
3441
return mergeCell->isChecked();
2538
void CellLayoutPagePosition::slotChangeWidthState()
3444
void CellFormatPagePosition::slotChangeWidthState()
2540
if( defaultWidth->isChecked())
3446
if ( defaultWidth->isChecked())
2541
3447
width->setEnabled(false);
2543
3449
width->setEnabled(true);
2546
void CellLayoutPagePosition::slotChangeHeightState()
3452
void CellFormatPagePosition::slotChangeHeightState()
2548
if( defaultHeight->isChecked())
3454
if ( defaultHeight->isChecked())
2549
3455
height->setEnabled(false);
2551
3457
height->setEnabled(true);
2554
void CellLayoutPagePosition::slotChangeAngle(int _angle)
2558
multi->setEnabled(true);
2559
vertical->setEnabled(true);
2563
multi->setEnabled(false);
2564
vertical->setEnabled(false);
2568
void CellLayoutPagePosition::apply( ColumnLayout *_obj )
2570
KSpreadCell*c= dlg->getTable()->firstCell();
2571
for( ;c; c = c->nextCell() )
2573
int col = c->column();
2574
if ( dlg->left <= col && dlg->right >= col
2575
&&!c->isObscuringForced())
2577
if(dlg->indent!=indent->value() && indent->isEnabled())
2579
c->clearProperty(KSpreadCell::PIndent);
2580
c->clearNoFallBackProperties( KSpreadCell::PIndent );
2582
c->clearProperty(KSpreadCell::PAlign);
2583
c->clearNoFallBackProperties( KSpreadCell::PAlign );
2584
c->clearProperty(KSpreadCell::PAlignY);
2585
c->clearNoFallBackProperties( KSpreadCell::PAlignY );
2588
c->clearProperty(KSpreadCell::PMultiRow);
2589
c->clearNoFallBackProperties( KSpreadCell::PMultiRow );
2594
c->clearProperty(KSpreadCell::PVerticalText);
2595
c->clearNoFallBackProperties( KSpreadCell::PVerticalText );
2598
if(dlg->textRotation!=angleRotation->value())
2600
c->clearProperty(KSpreadCell::PAngle);
2601
c->clearNoFallBackProperties( KSpreadCell::PAngle );
2607
RowLayout* rw =dlg->getTable()->firstRow();
2608
for( ; rw; rw = rw->next() )
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) ))
2614
for(int i=dlg->left;i<=dlg->right;i++)
2616
KSpreadCell *cell = dlg->getTable()->cellAt( i, rw->row());
2617
if ( cell->isDefault() )
2619
cell = new KSpreadCell( dlg->getTable(), i, rw->row() );
2620
dlg->getTable()->insertCell( cell);
2629
void CellLayoutPagePosition::apply( RowLayout *_obj )
2631
KSpreadCell*c= dlg->getTable()->firstCell();
2632
for( ;c; c = c->nextCell() )
2635
if ( dlg->top <= row && dlg->bottom >= row
2636
&&!c->isObscuringForced())
2638
if(dlg->indent!=indent->value() && indent->isEnabled())
2640
c->clearProperty(KSpreadCell::PIndent);
2641
c->clearNoFallBackProperties( KSpreadCell::PIndent );
2643
c->clearProperty(KSpreadCell::PAlign);
2644
c->clearNoFallBackProperties( KSpreadCell::PAlign );
2645
c->clearProperty(KSpreadCell::PAlignY);
2646
c->clearNoFallBackProperties( KSpreadCell::PAlignY );
2650
c->clearProperty(KSpreadCell::PMultiRow);
2651
c->clearNoFallBackProperties( KSpreadCell::PMultiRow );
2655
c->clearProperty(KSpreadCell::PVerticalText);
2656
c->clearNoFallBackProperties( KSpreadCell::PVerticalText );
2658
if(dlg->textRotation!=angleRotation->value())
2660
c->clearProperty(KSpreadCell::PAngle);
2661
c->clearNoFallBackProperties( KSpreadCell::PAngle );
2669
void CellLayoutPagePosition::apply( KSpreadCell *_obj )
2674
void CellLayoutPagePosition::applyLayout( KSpreadLayout *_obj )
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);
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);
2694
if(multi->isEnabled())
2695
_obj->setMultiRow(multi->isChecked());
2697
_obj->setMultiRow(false);
2702
if(vertical->isEnabled())
2703
_obj->setVerticalText(vertical->isChecked());
2705
_obj->setVerticalText(false);
2708
if(dlg->textRotation!=angleRotation->value())
2709
_obj->setAngle((-angleRotation->value()));
2710
if(dlg->indent!=indent->value() && indent->isEnabled())
2711
_obj->setIndent(indent->value());
2714
int CellLayoutPagePosition::getSizeHeight()
2716
if(defaultHeight->isChecked())
2719
return height->value();
2722
int CellLayoutPagePosition::getSizeWidth()
2724
if(defaultWidth->isChecked())
2727
return width->value();
3460
void CellFormatPagePosition::slotChangeAngle(int _angle)
3464
multi->setEnabled( true );
3465
vertical->setEnabled( true );
3469
multi->setEnabled( false );
3470
vertical->setEnabled( false );
3474
void CellFormatPagePosition::apply( KSpreadCustomStyle * style )
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 );
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 );
3492
if ( m_bOptionText )
3494
if ( multi->isEnabled() )
3496
if ( multi->isChecked() )
3497
style->addProperty( KSpreadStyle::PMultiRow );
3499
style->removeProperty( KSpreadStyle::PMultiRow );
3503
if ( m_bOptionText )
3505
if ( vertical->isEnabled() )
3507
if ( vertical->isChecked() )
3508
style->addProperty( KSpreadStyle::PVerticalText );
3510
style->removeProperty( KSpreadStyle::PVerticalText );
3514
if ( dlg->textRotation != angleRotation->value() )
3515
style->changeRotateAngle( (-angleRotation->value()) );
3517
if ( dlg->indent != indent->value() && indent->isEnabled() )
3518
style->changeIndent( indent->value() );
3521
void CellFormatPagePosition::apply( ColumnFormat *_obj )
3523
KSpreadFormat::Align ax;
3524
KSpreadFormat::AlignY ay;
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;
3533
ay = KSpreadCell::Middle; //Default, just in case
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;
3544
ax = KSpreadCell::Undefined; //Default, just in case
3547
KSpreadSheet * table = dlg->getTable();
3548
KSpreadCell * c = NULL;
3549
for ( int col = dlg->left; col <= dlg->right; ++col)
3551
for ( c = table->getFirstCellColumn(col); c != NULL;
3552
c = table->getNextCellDown(c->column(), c->row()) )
3554
if ( dlg->indent != indent->value() && indent->isEnabled() )
3556
c->clearProperty( KSpreadCell::PIndent );
3557
c->clearNoFallBackProperties( KSpreadCell::PIndent );
3559
if ( ax != dlg->alignX )
3561
c->clearProperty(KSpreadCell::PAlign);
3562
c->clearNoFallBackProperties( KSpreadCell::PAlign );
3564
if ( ay != dlg->alignY )
3566
c->clearProperty(KSpreadCell::PAlignY);
3567
c->clearNoFallBackProperties( KSpreadCell::PAlignY );
3571
c->clearProperty(KSpreadCell::PMultiRow);
3572
c->clearNoFallBackProperties( KSpreadCell::PMultiRow );
3576
c->clearProperty(KSpreadCell::PVerticalText);
3577
c->clearNoFallBackProperties( KSpreadCell::PVerticalText );
3580
if (dlg->textRotation != angleRotation->value())
3582
c->clearProperty(KSpreadCell::PAngle);
3583
c->clearNoFallBackProperties( KSpreadCell::PAngle );
3588
applyFormat( _obj );
3590
RowFormat* rw =dlg->getTable()->firstRow();
3591
for ( ; rw; rw = rw->next() )
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) ) )
3600
for ( int i = dlg->left; i <= dlg->right; ++i )
3602
KSpreadCell * cell = dlg->getTable()->nonDefaultCell( i, rw->row() );
3603
applyFormat( cell );
3609
void CellFormatPagePosition::apply( RowFormat *_obj )
3611
KSpreadFormat::Align ax;
3612
KSpreadFormat::AlignY ay;
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;
3621
ay = KSpreadCell::Middle; //Default, just in case
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;
3632
ax = KSpreadCell::Undefined; //Default, just in case
3634
KSpreadSheet* table = dlg->getTable();
3635
KSpreadCell* c= NULL;
3636
for (int row = dlg->top; row <= dlg->bottom; row++)
3638
for ( c = table->getFirstCellRow(row); c != NULL;
3639
c = table->getNextCellRight(c->column(), c->row()) )
3641
if (dlg->indent!=indent->value() && indent->isEnabled())
3643
c->clearProperty(KSpreadCell::PIndent);
3644
c->clearNoFallBackProperties( KSpreadCell::PIndent );
3646
if ( ax != dlg->alignX )
3648
c->clearProperty(KSpreadCell::PAlign);
3649
c->clearNoFallBackProperties( KSpreadCell::PAlign );
3651
if ( ay != dlg->alignY )
3653
c->clearProperty(KSpreadCell::PAlignY);
3654
c->clearNoFallBackProperties( KSpreadCell::PAlignY );
3658
c->clearProperty(KSpreadCell::PMultiRow);
3659
c->clearNoFallBackProperties( KSpreadCell::PMultiRow );
3663
c->clearProperty(KSpreadCell::PVerticalText);
3664
c->clearNoFallBackProperties( KSpreadCell::PVerticalText );
3666
if (dlg->textRotation!=angleRotation->value())
3668
c->clearProperty(KSpreadCell::PAngle);
3669
c->clearNoFallBackProperties( KSpreadCell::PAngle );
3674
applyFormat( _obj );
3678
void CellFormatPagePosition::apply( KSpreadCell *_obj )
3680
applyFormat( _obj );
3683
void CellFormatPagePosition::applyFormat( KSpreadFormat * _obj )
3685
KSpreadFormat::Align ax;
3686
KSpreadFormat::AlignY ay;
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;
3695
ay = KSpreadCell::Middle; // Default, just in case
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;
3706
ax = KSpreadCell::Undefined; //Default, just in case
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 );
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 );
3724
if ( m_bOptionText )
3726
if ( multi->isEnabled() )
3727
_obj->setMultiRow( multi->isChecked() );
3729
_obj->setMultiRow( false );
3732
if ( m_bOptionText )
3734
if ( vertical->isEnabled() )
3735
_obj->setVerticalText( vertical->isChecked() );
3737
_obj->setVerticalText( false );
3740
if ( dlg->textRotation!=angleRotation->value() )
3741
_obj->setAngle( (-angleRotation->value() ) );
3742
if ( dlg->indent != indent->value() && indent->isEnabled() )
3743
_obj->setIndent( indent->value() );
3746
double CellFormatPagePosition::getSizeHeight()
3748
if ( defaultHeight->isChecked() )
3751
return KoUnit::ptFromUnit( height->value(), dlg->getDoc()->getUnit() );
3754
double CellFormatPagePosition::getSizeWidth()
3756
if ( defaultWidth->isChecked() )
3759
return KoUnit::ptFromUnit( width->value(), dlg->getDoc()->getUnit() );
2730
3762
KSpreadBorderButton::KSpreadBorderButton( QWidget *parent, const char *_name ) : QPushButton(parent,_name)
2812
3844
emit choosearea(_ev);
2815
CellLayoutPageBorder::CellLayoutPageBorder( QWidget* parent, CellLayoutDlg *_dlg ) : QWidget( parent )
2819
QGridLayout *grid = new QGridLayout(this,5,2,15,15);
2821
QGroupBox* tmpQGroupBox;
3847
CellFormatPageBorder::CellFormatPageBorder( QWidget* parent, CellFormatDlg *_dlg )
3848
: QWidget( parent ),
3851
table = dlg->getTable();
3854
InitializeBorderButtons();
3855
InitializePatterns();
3858
preview->slotSelect();
3859
pattern[2]->slotSelect();
3861
style->setEnabled(false);
3862
size->setEnabled(false);
3863
preview->setPattern( black , 1, SolidLine );
3864
this->resize( 400, 400 );
3867
void CellFormatPageBorder::InitializeGrids()
3869
QGridLayout *grid = new QGridLayout(this,5,2,KDialog::marginHint(), KDialog::spacingHint());
3870
QGridLayout *grid2 = NULL;
3871
QGroupBox* tmpQGroupBox = NULL;
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"};
3878
const char shortcutButtonNames[BorderShortcutType_END][20] =
3879
{"remove", "all", "outline"};
3881
QString borderButtonIconNames[BorderType_END] =
3882
{"border_top", "border_bottom", "border_left", "border_right",
3883
"border_vertical", "border_horizontal", "border_fall", "border_up"};
3885
QString shortcutButtonIconNames[BorderShortcutType_END] =
3886
{ "border_remove", "", "border_outline"};
3888
int borderButtonPositions[BorderType_END][2] =
3889
{{0,2}, {4,2}, {2,0}, {2,4}, {4,4}, {4,0}, {0,0}, {0,4}};
3891
int shortcutButtonPositions[BorderShortcutType_END][2] =
3892
{ {0,0}, {0,1},{0,2} };
3893
/***********************/
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 );
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
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() );
2833
top=new KSpreadBorderButton(tmpQGroupBox,"top");
2834
loadIcon("border_top",top);
2835
grid2->addWidget(top,0,2);
2837
bottom=new KSpreadBorderButton(tmpQGroupBox,"bottom");
2838
loadIcon("border_bottom",bottom);
2839
grid2->addWidget(bottom,4,2);
2841
left=new KSpreadBorderButton(tmpQGroupBox,"left");
2842
loadIcon("border_left",left);
2843
grid2->addWidget(left,2,0);
2845
right=new KSpreadBorderButton(tmpQGroupBox,"right");
2846
loadIcon("border_right",right);
2847
grid2->addWidget(right,2,4);
2849
fallDiagonal=new KSpreadBorderButton(tmpQGroupBox,"fall");
2850
loadIcon("border_fall",fallDiagonal);
2851
grid2->addWidget(fallDiagonal,0,0);
2853
goUpDiagonal=new KSpreadBorderButton(tmpQGroupBox,"go");
2854
loadIcon("border_up",goUpDiagonal);
2855
grid2->addWidget(goUpDiagonal,0,4);
2857
vertical=new KSpreadBorderButton(tmpQGroupBox,"vertical");
2858
loadIcon("border_vertical",vertical);
2859
grid2->addWidget(vertical,4,4);
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++)
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]);
2865
3918
grid->addMultiCellWidget(tmpQGroupBox,0,2,0,0);
3920
/* the remove, all, and outline border buttons are in a second box down
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 );
2873
grid2 = new QGridLayout(tmpQGroupBox,1,3,15,7);
2875
outline=new KSpreadBorderButton(tmpQGroupBox,"outline");
2876
loadIcon("border_outline",outline);
2877
grid2->addWidget(outline,0,2);
2879
remove=new KSpreadBorderButton(tmpQGroupBox,"remove");
2880
loadIcon("border_remove",remove);
2881
grid2->addWidget(remove,0,0);
2883
all=new KSpreadBorderButton(tmpQGroupBox,"all");
2884
grid2->addWidget(all,0,1);
2886
if((dlg->oneRow==true)&&(dlg->oneCol==false))
2888
loadIcon("border_vertical",all);
2890
else if((dlg->oneRow==false)&&(dlg->oneCol==true))
2892
loadIcon("border_horizontal",all);
2894
else if((dlg->oneRow==false)&&(dlg->oneCol==false))
2896
loadIcon("border_inside",all);
3926
tmpQGroupBox->setAlignment( AlignLeft );
3928
grid2 = new QGridLayout(tmpQGroupBox,1,3,KDialog::marginHint(), KDialog::spacingHint());
3930
/* the "all" button is different depending on what kind of region is currently
3932
if ((dlg->oneRow==true)&&(dlg->oneCol==false))
3934
shortcutButtonIconNames[BorderShortcutType_All] = "border_vertical";
3936
else if ((dlg->oneRow==false)&&(dlg->oneCol==true))
3938
shortcutButtonIconNames[BorderShortcutType_All] = "border_horizontal";
2900
loadIcon("border_inside",all);
2901
all->setEnabled(false);
3942
shortcutButtonIconNames[BorderShortcutType_All] = "border_inside";
3945
for (int i=BorderShortcutType_Remove; i < BorderShortcutType_END; i++)
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]);
3954
if (dlg->oneRow && dlg->oneCol)
3956
shortcutButtons[BorderShortcutType_All]->setEnabled(false);
2903
3959
grid->addMultiCellWidget(tmpQGroupBox,3,4,0,0);
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 );
2910
grid2 = new QGridLayout(tmpQGroupBox,6,2,15,7);
2912
pattern1 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_1" );
2913
pattern1->setFrameStyle( 50 );
2914
grid2->addWidget(pattern1,0,0);
2916
pattern2 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_2" );
2917
pattern2->setFrameStyle( 50 );
2918
grid2->addWidget(pattern2,1,0);
2920
pattern3 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_3" );
2921
pattern3->setFrameStyle( 50 );
2922
grid2->addWidget(pattern3,2,0);
2924
pattern4 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_4" );
2925
pattern4->setFrameStyle( 50 );
2926
grid2->addWidget(pattern4,0,1);
2928
pattern5 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_5" );
2929
pattern5->setFrameStyle( 50 );
2930
grid2->addWidget(pattern5,1,1);
2932
pattern6 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_6" );
2933
pattern6->setFrameStyle( 50 );
2934
grid2->addWidget(pattern6,2,1);
2936
pattern7 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_7" );
2937
pattern7->setFrameStyle( 50 );
2938
grid2->addWidget(pattern7,3,1);
2940
pattern8 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_8" );
2941
pattern8->setFrameStyle( 50 );
2942
grid2->addWidget(pattern8,4,1);
2944
pattern9 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_9" );
2945
pattern9->setFrameStyle( 50 );
2946
grid2->addWidget(pattern9,3,0);
2948
pattern10 = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_10" );
2949
pattern10->setFrameStyle( 50 );
2950
grid2->addWidget(pattern10,4,0);
2954
color = new KColorButton (tmpQGroupBox, "PushButton_1" );
2955
grid2->addWidget(color,6,1);
2957
QLabel *tmpQLabel = new QLabel( tmpQGroupBox, "Label_6" );
2958
tmpQLabel->setText( i18n("Color") );
2959
grid2->addWidget(tmpQLabel,6,0);
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()) );
2968
size=new QComboBox(true,tmpQGroupBox);
2969
grid3->addWidget(size,1,1);
2970
size->setValidator(new KIntValidator( size ));
2972
for(int i=0;i<10;i++)
2975
size->insertItem(tmp);
2977
size->setCurrentItem(1);
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() );
2988
grid2->addMultiCell(grid3,5,5,0,1);
2989
grid->addMultiCellWidget(tmpQGroupBox,0,3,1,1);
2992
tmpQGroupBox = new QGroupBox(this, "GroupBox_4" );
2993
tmpQGroupBox->setFrameStyle( 49 );
2994
tmpQGroupBox->setTitle( i18n("Preview") );
2995
tmpQGroupBox->setAlignment( 1 );
2997
grid2 = new QGridLayout(tmpQGroupBox,1,1,14,7);
3001
preview = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_preview" );
3002
preview->setFrameStyle( 50 );
3003
grid2->addWidget(preview,0,0);
3005
grid->addWidget(tmpQGroupBox,4,1);
3007
if(dlg->leftBorderStyle != Qt::NoPen || !dlg->bLeftBorderStyle )
3009
if ( dlg->bLeftBorderColor && dlg->bLeftBorderStyle )
3011
left->setPenStyle(dlg->leftBorderStyle );
3012
left->setPenWidth(dlg->leftBorderWidth);
3013
left->setColor(dlg->leftBorderColor);
3019
left->setUndefined();
3022
if(dlg->rightBorderStyle!=Qt::NoPen|| !dlg->bRightBorderStyle)
3024
if ( dlg->bRightBorderColor && dlg->bRightBorderStyle && dlg->rightBorderStyle!=NoPen)
3026
right->setPenStyle(dlg->rightBorderStyle );
3027
right->setPenWidth(dlg->rightBorderWidth);
3028
right->setColor(dlg->rightBorderColor);
3034
right->setUndefined();
3038
if( dlg->topBorderStyle!=Qt::NoPen || !dlg->bTopBorderStyle)
3040
if ( dlg->bTopBorderColor && dlg->bTopBorderStyle)
3042
top->setPenStyle(dlg->topBorderStyle );
3043
top->setPenWidth(dlg->topBorderWidth);
3044
top->setColor(dlg->topBorderColor);
3050
top->setUndefined();
3054
if(dlg->bottomBorderStyle != Qt::NoPen || !dlg->bBottomBorderStyle)
3056
if ( dlg->bBottomBorderColor && dlg->bBottomBorderStyle )
3059
bottom->setPenStyle(dlg->bottomBorderStyle );
3060
bottom->setPenWidth(dlg->bottomBorderWidth);
3061
bottom->setColor(dlg->bottomBorderColor);
3062
bottom->setOn(true);
3067
bottom->setUndefined();
3071
if(dlg->oneRow==FALSE)
3073
if(dlg->horizontalBorderStyle!=Qt::NoPen ||!dlg->bHorizontalBorderStyle)
3075
if ( dlg->bHorizontalBorderColor && dlg->bHorizontalBorderStyle )
3077
horizontal->setPenStyle(dlg->horizontalBorderStyle );
3078
horizontal->setPenWidth(dlg->horizontalBorderWidth);
3079
horizontal->setColor(dlg->horizontalBorderColor);
3080
horizontal->setOn(true);
3084
horizontal->setUndefined();
3089
horizontal->setEnabled(false);
3091
if(dlg->oneCol==FALSE)
3093
if(dlg->verticalBorderStyle!=Qt::NoPen || !dlg->bVerticalBorderStyle)
3095
if ( dlg->bVerticalBorderColor && dlg->bVerticalBorderStyle )
3097
vertical->setPenStyle(dlg->verticalBorderStyle );
3098
vertical->setPenWidth(dlg->verticalBorderWidth);
3099
vertical->setColor(dlg->verticalBorderColor);
3100
vertical->setOn(true);
3104
vertical->setUndefined();
3110
vertical->setEnabled(false);
3113
if(dlg->fallDiagonalStyle!=Qt::NoPen || !dlg->bFallDiagonalStyle)
3115
if ( dlg->bfallDiagonalColor && dlg->bFallDiagonalStyle )
3117
fallDiagonal->setPenStyle(dlg->fallDiagonalStyle );
3118
fallDiagonal->setPenWidth(dlg->fallDiagonalWidth);
3119
fallDiagonal->setColor(dlg->fallDiagonalColor);
3120
fallDiagonal->setOn(true);
3124
fallDiagonal->setUndefined();
3128
if(dlg->goUpDiagonalStyle!=Qt::NoPen || !dlg->bGoUpDiagonalStyle)
3130
if ( dlg->bGoUpDiagonalColor && dlg->bGoUpDiagonalStyle )
3132
goUpDiagonal->setPenStyle(dlg->goUpDiagonalStyle );
3133
goUpDiagonal->setPenWidth(dlg->goUpDiagonalWidth);
3134
goUpDiagonal->setColor(dlg->goUpDiagonalColor);
3135
goUpDiagonal->setOn(true);
3139
goUpDiagonal->setUndefined();
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 );
3157
slotSetColorButton( black );
3159
connect( color, SIGNAL( changed( const QColor & ) ),
3160
this, SLOT( slotSetColorButton( const QColor & ) ) );
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* ) ) );
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 *) ) );
3191
connect( fallDiagonal, SIGNAL( clicked(KSpreadBorderButton *) ),
3192
this, SLOT( changeState(KSpreadBorderButton *) ) );
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 *) ) );
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 );
3967
grid2 = new QGridLayout(tmpQGroupBox,7,2,KDialog::marginHint(), KDialog::spacingHint());
3968
fHeight = tmpQGroupBox->fontMetrics().height();
3969
grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
3971
char name[] = "PatternXX";
3972
Q_ASSERT(NUM_BORDER_PATTERNS < 100);
3974
for (int i=0; i < NUM_BORDER_PATTERNS; i++)
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:
3990
color = new KColorButton (tmpQGroupBox, "PushButton_1" );
3991
grid2->addWidget(color,7,1);
3993
QLabel *tmpQLabel = new QLabel( tmpQGroupBox, "Label_6" );
3994
tmpQLabel->setText( i18n("Color:") );
3995
grid2->addWidget(tmpQLabel,7,0);
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()) );
4003
size=new QComboBox(true,tmpQGroupBox);
4004
grid3->addWidget(size,1,1);
4005
size->setValidator(new KIntValidator( size ));
4007
for ( int i=0;i<10;i++)
4010
size->insertItem(tmp);
4012
size->setCurrentItem(1);
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() );
4023
grid2->addMultiCell(grid3,6,6,0,1);
4024
grid->addMultiCellWidget(tmpQGroupBox,0,3,1,1);
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 );
4032
grid2 = new QGridLayout(tmpQGroupBox,1,1,KDialog::marginHint(), KDialog::spacingHint());
4033
fHeight = tmpQGroupBox->fontMetrics().height();
4034
grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
4036
preview = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_preview" );
4037
preview->setFrameStyle( QFrame::Panel | QFrame::Sunken );
4038
grid2->addWidget(preview,1,0);
4040
grid->addWidget(tmpQGroupBox,4,1);
4043
void CellFormatPageBorder::InitializeBorderButtons()
4045
for (int i=BorderType_Top; i < BorderType_END; i++)
4047
if (dlg->borders[i].style != Qt::NoPen ||
4048
!dlg->borders[i].bStyle )
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))
4055
borderButtons[i]->setEnabled(false);
4057
else if ( dlg->borders[i].bColor && dlg->borders[i].bStyle )
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);
4066
borderButtons[i]->setUndefined();
4074
void CellFormatPageBorder::InitializePatterns()
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 );
4087
slotSetColorButton( black );
4090
void CellFormatPageBorder::SetConnections()
4092
connect( color, SIGNAL( changed( const QColor & ) ),
4093
this, SLOT( slotSetColorButton( const QColor & ) ) );
4095
for (int i=0; i < NUM_BORDER_PATTERNS; i++)
4097
connect( pattern[i], SIGNAL( clicked( KSpreadPatternSelect* ) ),
4098
this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
4101
for (int i = BorderType_Top; i < BorderType_END; i++)
4103
connect( borderButtons[i], SIGNAL( clicked (KSpreadBorderButton *) ),
4104
this, SLOT( changeState( KSpreadBorderButton *) ) );
4107
for (int i = BorderShortcutType_Remove; i < BorderShortcutType_END; i++)
4109
connect( shortcutButtons[i], SIGNAL( clicked(KSpreadBorderButton *) ),
4110
this, SLOT( preselect(KSpreadBorderButton *) ) );
3210
4113
connect( area ,SIGNAL( redraw()),this,SLOT(draw()));
3211
4114
connect( area ,SIGNAL( choosearea(QMouseEvent * )),
3212
4115
this,SLOT( slotPressEvent(QMouseEvent *)));
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 );
3226
void CellLayoutPageBorder::cutomize_chosen_slot()
3228
if(customize->isChecked())
3230
style->setEnabled(true);
3231
size->setEnabled(true);
3232
slotUnselect2( preview );
3236
style->setEnabled(false);
3237
size->setEnabled(false);
3238
pattern3->slotSelect();
3239
preview->setPattern( black , 1, SolidLine );
3243
void CellLayoutPageBorder::slotChangeStyle(const QString &)
3248
void CellLayoutPageBorder::slotChangeStyle(int)
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)));
4123
void CellFormatPageBorder::cutomize_chosen_slot()
4125
if ( customize->isChecked() )
4127
style->setEnabled( true );
4128
size->setEnabled( true );
4129
slotUnselect2( preview );
4133
style->setEnabled( false );
4134
size->setEnabled( false );
4135
pattern[2]->slotSelect();
4136
preview->setPattern( black , 1, SolidLine );
4140
void CellFormatPageBorder::slotChangeStyle(const QString &)
4142
/* if they try putting text in the size box, then erase the line */
4146
void CellFormatPageBorder::slotChangeStyle(int)
4148
int index = style->currentItem();
3252
int penSize=size->currentText().toInt();
3254
preview->setPattern( preview->getColor(), penSize, NoPen );
3260
preview->setPattern( preview->getColor(), penSize, DotLine );
3263
preview->setPattern( preview->getColor(), penSize, DashLine );
3266
preview->setPattern( preview->getColor(), penSize, DashDotLine );
3269
preview->setPattern( preview->getColor(), penSize, DashDotDotLine );
3272
preview->setPattern( preview->getColor(), penSize, SolidLine );
3275
kdDebug(36001)<<"Error in combobox\n";
3279
slotUnselect2(preview);
3282
QPixmap CellLayoutPageBorder::paintFormatPixmap(PenStyle _style)
3284
QPixmap pixmap( style->width(), 14 );
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 );
3296
void CellLayoutPageBorder::loadIcon( QString _pix,KSpreadBorderButton *_button)
3298
_button->setPixmap( QPixmap( KSBarIcon(_pix) ) );
3301
void CellLayoutPageBorder::applyOutline( int _left, int _top, int _right, int _bottom )
3304
if( horizontal->isChanged())
3306
QPen tmpPen( horizontal->getColor(),horizontal->getPenWidth(),horizontal->getPenStyle());
3307
if( _bottom!=0x7FFF && _right!=0x7FFF)
3309
for ( int x = _left; x <= _right; x++ )
3311
for ( int y = _top+1; y <= _bottom; y++ )
3313
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x, y );
3314
if(!obj->isObscuringForced())
3315
obj->setTopBorderPen(tmpPen);
3319
else if( _bottom==0x7FFF )
3321
KSpreadCell*c= dlg->getTable()->firstCell();
3322
for( ;c; c = c->nextCell() )
3324
int col = c->column();
3325
if ( dlg->left <= col && dlg->right >= col
3326
&&!c->isObscuringForced())
3328
c->clearProperty(KSpreadCell::PTopBorder);
3329
c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
3333
for(int x=_left;x<=_right;x++)
3335
ColumnLayout *obj=dlg->getTable()->nonDefaultColumnLayout(x);
3336
obj->setTopBorderPen(tmpPen);
3339
RowLayout* rw =dlg->getTable()->firstRow();
3340
for( ; rw; rw = rw->next() )
3342
if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PTopBorder) ))
3344
for(int i=dlg->left;i<=dlg->right;i++)
3346
KSpreadCell *cell = dlg->getTable()->cellAt( i, rw->row());
3347
if ( cell->isDefault() )
3349
cell = new KSpreadCell( dlg->getTable(), i, rw->row() );
3350
dlg->getTable()->insertCell( cell);
3352
cell->setTopBorderPen(tmpPen);
3357
else if( _right==0x7FFF)
3359
KSpreadCell*c= dlg->getTable()->firstCell();
3360
for( ;c; c = c->nextCell() )
3363
if ( (dlg->top+1) <= row && dlg->bottom >= row
3364
&&!c->isObscuringForced())
3366
c->clearProperty(KSpreadCell::PTopBorder);
3367
c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
3371
for(int y=_top+1;y<=_bottom;y++)
3373
RowLayout *obj=dlg->getTable()->nonDefaultRowLayout(y);
3374
obj->setTopBorderPen(tmpPen);
3378
if( vertical->isChanged())
3380
QPen tmpPen( vertical->getColor(),vertical->getPenWidth(),vertical->getPenStyle());
3381
if( _bottom!=0x7FFF && _right!=0x7FFF)
3383
for ( int x = _left+1; x <= _right; x++ )
3385
for ( int y = _top; y <= _bottom; y++ )
3387
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x,y );
3388
if(!obj->isObscuringForced())
3389
obj->setLeftBorderPen( tmpPen );
3393
else if( _bottom==0x7FFF )
3395
KSpreadCell*c= dlg->getTable()->firstCell();
3396
for( ;c; c = c->nextCell() )
3398
int col = c->column();
3399
if ( dlg->left <= col && dlg->right >= col
3400
&&!c->isObscuringForced())
3402
c->clearProperty(KSpreadCell::PLeftBorder);
3403
c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
3407
for(int x=_left+1;x<=_right;x++)
3409
ColumnLayout *obj=dlg->getTable()->nonDefaultColumnLayout(x);
3410
obj->setLeftBorderPen( tmpPen );
3412
RowLayout* rw =dlg->getTable()->firstRow();
3413
for( ; rw; rw = rw->next() )
3415
if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PLeftBorder) ))
3417
for(int i=dlg->left;i<=dlg->right;i++)
3419
KSpreadCell *cell = dlg->getTable()->cellAt( i, rw->row());
3420
if ( cell->isDefault() )
3422
cell = new KSpreadCell( dlg->getTable(), i, rw->row() );
3423
dlg->getTable()->insertCell( cell);
3425
cell->setLeftBorderPen( tmpPen );
3430
else if( _right==0x7FFF)
3432
KSpreadCell*c= dlg->getTable()->firstCell();
3433
for( ;c; c = c->nextCell() )
3436
if ( dlg->top <= row && dlg->bottom >= row
3437
&&!c->isObscuringForced())
3439
c->clearProperty(KSpreadCell::PLeftBorder);
3440
c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
3444
for(int y=_top;y<=_bottom;y++)
3446
RowLayout *obj=dlg->getTable()->nonDefaultRowLayout(y);
3447
obj->setLeftBorderPen( tmpPen );
3452
if ( left->isChanged() )
3454
QPen tmpPen( left->getColor(),left->getPenWidth(),left->getPenStyle());
3455
if( _bottom!=0x7FFF && _right!=0x7FFF)
3457
for ( int y = _top; y <= _bottom; y++ )
3459
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( _left,y );
3460
if(!obj->isObscuringForced())
3461
obj->setLeftBorderPen( tmpPen );
3464
else if( _bottom==0x7FFF )
3466
KSpreadCell*c= dlg->getTable()->firstCell();
3467
for( ;c; c = c->nextCell() )
3469
int col = c->column();
3470
if ( dlg->left == col && !c->isObscuringForced())
3472
c->clearProperty(KSpreadCell::PLeftBorder);
3473
c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
3476
ColumnLayout *obj=dlg->getTable()->nonDefaultColumnLayout(_left);
3477
obj->setLeftBorderPen( tmpPen );
3479
RowLayout* rw =dlg->getTable()->firstRow();
3480
for( ; rw; rw = rw->next() )
3482
if (rw->row()==_left&& !rw->isDefault() && (rw->hasProperty(KSpreadCell::PLeftBorder) ))
3484
for(int i=dlg->left;i<=dlg->right;i++)
3486
KSpreadCell *cell = dlg->getTable()->cellAt( i, rw->row());
3487
if ( cell->isDefault() )
3489
cell = new KSpreadCell( dlg->getTable(), i, rw->row() );
3490
dlg->getTable()->insertCell( cell);
3492
cell->setLeftBorderPen( tmpPen );
3497
else if( _right==0x7FFF)
3499
KSpreadCell*c= dlg->getTable()->firstCell();
3500
for( ;c; c = c->nextCell() )
3503
if ( dlg->top <= row && dlg->bottom >= row
3504
&&!c->isObscuringForced() && c->column()==1)
3506
c->clearProperty(KSpreadCell::PLeftBorder);
3507
c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
3510
for ( int y = _top; y <= _bottom; y++ )
3512
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( 1,y );
3513
if(!obj->isObscuringForced())
3514
obj->setLeftBorderPen( tmpPen );
3518
if ( right->isChanged() )
3521
QPen tmpPen( right->getColor(),right->getPenWidth(),right->getPenStyle());
3522
if( _bottom!=0x7FFF && _right!=0x7FFF)
3524
for ( int y = _top; y <= _bottom; y++ )
3526
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( _right,y );
3527
if(!obj->isObscuringForced())
3528
obj->setRightBorderPen(tmpPen);
3529
else if(obj->isObscuringForced() && !once )
3532
int moveX=obj->obscuringCellsColumn();
3533
int moveY=obj->obscuringCellsRow();
3534
obj = dlg->getTable()->nonDefaultCell( moveX, moveY );
3535
obj->setRightBorderPen(tmpPen);
3539
else if( _bottom==0x7FFF)
3541
KSpreadCell*c= dlg->getTable()->firstCell();
3542
for( ;c; c = c->nextCell() )
3544
int col = c->column();
3545
if ( dlg->right == col && !c->isObscuringForced())
3547
c->clearProperty(KSpreadCell::PRightBorder);
3548
c->clearNoFallBackProperties( KSpreadCell::PRightBorder );
3552
ColumnLayout *obj=dlg->getTable()->nonDefaultColumnLayout(_right);
3553
obj->setRightBorderPen(tmpPen);
3555
RowLayout* rw =dlg->getTable()->firstRow();
3556
for( ; rw; rw = rw->next() )
3558
if (rw->row()==dlg->right&& !rw->isDefault() && (rw->hasProperty(KSpreadCell::PRightBorder) ))
3560
for(int i=dlg->left;i<=dlg->right;i++)
3562
KSpreadCell *cell = dlg->getTable()->cellAt( i, rw->row());
3563
if ( cell->isDefault() )
3565
cell = new KSpreadCell( dlg->getTable(), i, rw->row() );
3566
dlg->getTable()->insertCell( cell);
3568
cell->setRightBorderPen(tmpPen);
3573
else if( _right==0x7FFF)
3575
KSpreadCell*c= dlg->getTable()->firstCell();
3576
for( ;c; c = c->nextCell() )
3579
if ( dlg->top <= row && dlg->bottom >= row
3580
&&!c->isObscuringForced() && c->column()==0x7FFF)
3582
c->clearProperty(KSpreadCell::PRightBorder);
3583
c->clearNoFallBackProperties( KSpreadCell::PRightBorder );
3587
for ( int y = _top; y <= _bottom; y++ )
3589
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( _right,y );
3590
if(!obj->isObscuringForced())
3591
obj->setRightBorderPen(tmpPen);
3592
else if(obj->isObscuringForced() && !once )
3595
int moveX=obj->obscuringCellsColumn();
3596
int moveY=obj->obscuringCellsRow();
3597
obj = dlg->getTable()->nonDefaultCell( moveX, moveY );
3598
obj->setRightBorderPen(tmpPen);
3604
if ( top->isChanged() )
3606
QPen tmpPen( top->getColor(),top->getPenWidth(),top->getPenStyle());
3607
if( _bottom!=0x7FFF && _right!=0x7FFF)
3609
for ( int x = _left; x <= _right; x++ )
3611
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x,_top );
3612
if(!obj->isObscuringForced())
3613
obj->setTopBorderPen( tmpPen );
3616
else if( _bottom==0x7FFF)
3618
for ( int x = _left; x <= _right; x++ )
3620
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x,_top );
3621
if(!obj->isObscuringForced())
3622
obj->setTopBorderPen( tmpPen );
3625
else if( _right==0x7FFF)
3627
KSpreadCell*c= dlg->getTable()->firstCell();
3628
for( ;c; c = c->nextCell() )
3631
if ( dlg->top <= row && dlg->bottom >= row
3632
&&!c->isObscuringForced())
3634
c->clearProperty(KSpreadCell::PTopBorder);
3635
c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
3639
RowLayout *obj=dlg->getTable()->nonDefaultRowLayout(_top-1);
3640
obj->setBottomBorderPen( tmpPen );
3644
if ( bottom->isChanged() )
3647
QPen tmpPen( bottom->getColor(),bottom->getPenWidth(),bottom->getPenStyle());
3648
if( _bottom!=0x7FFF && _right!=0x7FFF)
3650
for ( int x = _left; x <= _right; x++ )
3652
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x,_bottom );
3653
if(!obj->isObscuringForced())
3654
obj->setBottomBorderPen( tmpPen );
3655
else if(obj->isObscuringForced() && !once )
3658
int moveX=obj->obscuringCellsColumn();
3659
int moveY=obj->obscuringCellsRow();
3660
obj = dlg->getTable()->nonDefaultCell( moveX, moveY );
3661
obj->setBottomBorderPen( tmpPen );
3665
else if( _bottom==0x7FFF)
3667
for ( int x = _left; x <= _right; x++ )
3669
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x,_bottom );
3670
if(!obj->isObscuringForced())
3671
obj->setBottomBorderPen( tmpPen );
3672
else if(obj->isObscuringForced() && !once )
3675
int moveX=obj->obscuringCellsColumn();
3676
int moveY=obj->obscuringCellsRow();
3677
obj = dlg->getTable()->nonDefaultCell( moveX, moveY );
3678
obj->setBottomBorderPen( tmpPen );
3682
else if( _right==0x7FFF)
3684
KSpreadCell*c= dlg->getTable()->firstCell();
3685
for( ;c; c = c->nextCell() )
3688
if ( dlg->top <= row && dlg->bottom >= row
3689
&&!c->isObscuringForced())
3691
c->clearProperty(KSpreadCell::PBottomBorder);
3692
c->clearNoFallBackProperties( KSpreadCell::PBottomBorder );
3696
RowLayout *obj=dlg->getTable()->nonDefaultRowLayout(_bottom);
3697
obj->setBottomBorderPen( tmpPen );
3701
QPen tmpPenFall( fallDiagonal->getColor(),fallDiagonal->getPenWidth(),fallDiagonal->getPenStyle());
3702
QPen tmpPenGoUp( goUpDiagonal->getColor(),goUpDiagonal->getPenWidth(),goUpDiagonal->getPenStyle());
3703
if( _bottom!=0x7FFF && _right!=0x7FFF)
3705
for ( int x = _left; x <= _right; x++ )
3707
for ( int y = _top; y <= _bottom; y++ )
3709
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x,y );
3710
if(!obj->isObscuringForced())
3712
if ( fallDiagonal->isChanged() )
3713
obj->setFallDiagonalPen( tmpPenFall );
3714
if ( goUpDiagonal->isChanged() )
3715
obj->setGoUpDiagonalPen( tmpPenGoUp );
3720
else if( _bottom==0x7FFF)
3722
KSpreadCell*c= dlg->getTable()->firstCell();
3723
for( ;c; c = c->nextCell() )
3725
int col = c->column();
3726
if ( dlg->left <= col && dlg->right >= col
3727
&&!c->isObscuringForced())
3729
if ( fallDiagonal->isChanged() )
3731
c->clearProperty(KSpreadCell::PFallDiagonal);
3732
c->clearNoFallBackProperties( KSpreadCell::PFallDiagonal );
3734
if ( goUpDiagonal->isChanged() )
3736
c->clearProperty(KSpreadCell::PGoUpDiagonal);
3737
c->clearNoFallBackProperties( KSpreadCell::PGoUpDiagonal);
3742
for ( int x = _left; x <= _right; x++ )
3744
ColumnLayout *obj=dlg->getTable()->nonDefaultColumnLayout(x);
3745
if ( fallDiagonal->isChanged() )
3746
obj->setFallDiagonalPen( tmpPenFall );
3747
if ( goUpDiagonal->isChanged() )
3748
obj->setGoUpDiagonalPen( tmpPenGoUp );
3751
RowLayout* rw =dlg->getTable()->firstRow();
3752
for( ; rw; rw = rw->next() )
3754
if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PFallDiagonal)
3755
||rw->hasProperty(KSpreadCell::PGoUpDiagonal) ))
3757
for(int i=dlg->left;i<=dlg->right;i++)
3759
KSpreadCell *cell = dlg->getTable()->cellAt( i, rw->row());
3760
if ( cell->isDefault() )
3762
cell = new KSpreadCell( dlg->getTable(), i, rw->row() );
3763
dlg->getTable()->insertCell( cell);
3765
cell->setFallDiagonalPen( tmpPenFall );
3766
cell->setGoUpDiagonalPen( tmpPenGoUp );
3771
else if( _right==0x7FFF)
3773
KSpreadCell*c= dlg->getTable()->firstCell();
3774
for( ;c; c = c->nextCell() )
3777
if ( dlg->top <= row && dlg->bottom >= row
3778
&&!c->isObscuringForced())
3780
if ( fallDiagonal->isChanged() )
3782
c->clearProperty(KSpreadCell::PFallDiagonal);
3783
c->clearNoFallBackProperties( KSpreadCell::PFallDiagonal );
3785
if ( goUpDiagonal->isChanged() )
3787
c->clearProperty(KSpreadCell::PGoUpDiagonal);
3788
c->clearNoFallBackProperties( KSpreadCell::PGoUpDiagonal);
3793
for ( int y = _top; y <= _bottom; y++ )
3795
RowLayout *obj=dlg->getTable()->nonDefaultRowLayout(y);
3796
if ( fallDiagonal->isChanged() )
3797
obj->setFallDiagonalPen( tmpPenFall );
3798
if ( goUpDiagonal->isChanged() )
3799
obj->setGoUpDiagonalPen( tmpPenGoUp );
3804
void CellLayoutPageBorder::slotSetColorButton( const QColor &_color )
4150
int penSize = size->currentText().toInt();
4153
preview->setPattern( preview->getColor(), penSize, NoPen );
4160
preview->setPattern( preview->getColor(), penSize, DotLine );
4163
preview->setPattern( preview->getColor(), penSize, DashLine );
4166
preview->setPattern( preview->getColor(), penSize, DashDotLine );
4169
preview->setPattern( preview->getColor(), penSize, DashDotDotLine );
4172
preview->setPattern( preview->getColor(), penSize, SolidLine );
4175
kdDebug(36001)<<"Error in combobox\n";
4179
slotUnselect2(preview);
4182
QPixmap CellFormatPageBorder::paintFormatPixmap(PenStyle _style)
4184
QPixmap pixmap( style->width(), 14 );
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 );
4196
void CellFormatPageBorder::loadIcon( QString _pix, KSpreadBorderButton *_button)
4198
_button->setPixmap( QPixmap( KSBarIcon(_pix) ) );
4201
void CellFormatPageBorder::applyOutline()
4203
if (borderButtons[BorderType_Horizontal]->isChanged())
4204
applyHorizontalOutline();
4206
if (borderButtons[BorderType_Vertical]->isChanged())
4207
applyVerticalOutline();
4209
if ( borderButtons[BorderType_Left]->isChanged() )
4212
if ( borderButtons[BorderType_Right]->isChanged() )
4213
applyRightOutline();
4215
if ( borderButtons[BorderType_Top]->isChanged() )
4218
if ( borderButtons[BorderType_Bottom]->isChanged() )
4219
applyBottomOutline();
4221
if ( borderButtons[BorderType_RisingDiagonal]->isChanged() ||
4222
borderButtons[BorderType_FallingDiagonal]->isChanged() )
4223
applyDiagonalOutline();
4226
void CellFormatPageBorder::applyTopOutline()
4228
KSpreadBorderButton * top = borderButtons[BorderType_Top];
4230
QPen tmpPen( top->getColor(), top->getPenWidth(), top->getPenStyle());
4232
if ( dlg->getStyle() )
4234
dlg->getStyle()->changeTopBorderPen( tmpPen );
4236
else if ( !dlg->isRowSelected )
4238
/* if a column is selected then _top will just be row 1 so there's no special
4241
for ( int x = dlg->left; x <= dlg->right; x++ )
4243
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x, dlg->top );
4244
if ( obj->isObscuringForced() /* && dlg->isSingleCell() */ )
4245
obj = obj->obscuringCells().first();
4246
obj->setTopBorderPen( tmpPen );
4249
else if ( dlg->isRowSelected )
4251
KSpreadCell* c = NULL;
4252
for ( c = table->getFirstCellRow(dlg->top); c != NULL;
4253
c = table->getNextCellRight(c->column(), c->row()) )
4255
c->clearProperty(KSpreadCell::PTopBorder);
4256
c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
4259
RowFormat *obj=dlg->getTable()->nonDefaultRowFormat(dlg->top-1);
4260
obj->setBottomBorderPen( tmpPen );
4264
void CellFormatPageBorder::applyBottomOutline()
4266
KSpreadSheet * table = dlg->getTable();
4267
KSpreadBorderButton * bottom = borderButtons[BorderType_Bottom];
4269
QPen tmpPen( bottom->getColor(), bottom->getPenWidth(), bottom->getPenStyle() );
4271
if ( dlg->getStyle() )
4272
dlg->getStyle()->changeBottomBorderPen( tmpPen );
4273
else if ( !dlg->isRowSelected && !dlg->isColumnSelected )
4275
for ( int x = dlg->left; x <= dlg->right; x++ )
4277
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x, dlg->bottom );
4278
if ( obj->isObscuringForced() /* && dlg->isSingleCell() */ )
4279
obj = obj->obscuringCells().first();
4280
obj->setBottomBorderPen( tmpPen );
4283
else if ( dlg->isRowSelected )
4285
KSpreadCell* c = NULL;
4286
for ( c = table->getFirstCellRow(dlg->bottom); c != NULL;
4287
c = table->getNextCellRight(c->column(), c->row()) )
4289
c->clearProperty(KSpreadCell::PBottomBorder);
4290
c->clearNoFallBackProperties( KSpreadCell::PBottomBorder );
4293
RowFormat *obj=dlg->getTable()->nonDefaultRowFormat(dlg->bottom);
4294
obj->setBottomBorderPen( tmpPen );
4298
void CellFormatPageBorder::applyLeftOutline()
4300
KSpreadBorderButton * left = borderButtons[BorderType_Left];
4301
QPen tmpPen( left->getColor(), left->getPenWidth(), left->getPenStyle() );
4303
if ( dlg->getStyle() )
4304
dlg->getStyle()->changeLeftBorderPen( tmpPen );
4305
else if ( !dlg->isColumnSelected )
4307
for ( int y = dlg->top; y <= dlg->bottom; y++ )
4309
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( dlg->left, y );
4310
if ( obj->isObscuringForced() /* && dlg->isSingleCell() */ )
4312
obj->setLeftBorderPen( tmpPen );
4317
KSpreadCell* c = NULL;
4318
for ( c = table->getFirstCellColumn(dlg->left); c != NULL;
4319
c = table->getNextCellDown(c->column(), c->row()) )
4321
c->clearProperty(KSpreadCell::PLeftBorder);
4322
c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
4324
ColumnFormat *obj=dlg->getTable()->nonDefaultColumnFormat(dlg->left);
4325
obj->setLeftBorderPen( tmpPen );
4327
RowFormat* rw =dlg->getTable()->firstRow();
4328
for ( ; rw; rw = rw->next() )
4330
if (rw->row()==dlg->left&& !rw->isDefault() &&
4331
(rw->hasProperty(KSpreadCell::PLeftBorder) ))
4333
for ( int i=dlg->left;i<=dlg->right;i++)
4336
dlg->getTable()->nonDefaultCell( i, rw->row() );
4337
if ( cell->isObscuringForced() && dlg->isSingleCell() )
4339
cell->setLeftBorderPen( tmpPen );
4346
void CellFormatPageBorder::applyRightOutline()
4348
KSpreadBorderButton* right = borderButtons[BorderType_Right];
4349
QPen tmpPen( right->getColor(), right->getPenWidth(), right->getPenStyle() );
4351
if ( dlg->getStyle() )
4352
dlg->getStyle()->changeRightBorderPen( tmpPen );
4353
else if ( (!dlg->isRowSelected) && (!dlg->isColumnSelected) )
4355
for ( int y = dlg->top; y <= dlg->bottom; y++ )
4357
KSpreadCell * obj = dlg->getTable()->nonDefaultCell( dlg->right, y );
4358
if ( obj->isObscuringForced() /* && dlg->isSingleCell() */ )
4359
obj = obj->obscuringCells().first();
4360
obj->setRightBorderPen( tmpPen );
4363
else if ( dlg->isColumnSelected )
4365
KSpreadCell* c = NULL;
4366
for ( c = table->getFirstCellColumn(dlg->right); c != NULL;
4367
c = table->getNextCellDown(c->column(), c->row()) )
4369
c->clearProperty(KSpreadCell::PRightBorder);
4370
c->clearNoFallBackProperties( KSpreadCell::PRightBorder );
4373
ColumnFormat *obj=dlg->getTable()->nonDefaultColumnFormat(dlg->right);
4374
obj->setRightBorderPen(tmpPen);
4376
RowFormat* rw =dlg->getTable()->firstRow();
4377
for ( ; rw; rw = rw->next() )
4379
if (rw->row()==dlg->right&& !rw->isDefault() &&
4380
(rw->hasProperty(KSpreadCell::PRightBorder) ))
4382
for ( int i=dlg->left;i<=dlg->right;i++)
4385
dlg->getTable()->nonDefaultCell( i, rw->row() );
4386
if ( cell->isObscuringForced() /* && dlg->isSingleCell() */ )
4387
cell = cell->obscuringCells().first();
4388
cell->setRightBorderPen( tmpPen );
4395
void CellFormatPageBorder::applyDiagonalOutline()
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());
4404
if ( dlg->getStyle() )
4406
if ( fallDiagonal->isChanged() )
4407
dlg->getStyle()->changeFallBorderPen( tmpPenFall );
4408
if ( goUpDiagonal->isChanged() )
4409
dlg->getStyle()->changeGoUpBorderPen( tmpPenGoUp );
4411
else if ( (!dlg->isRowSelected) && (!dlg->isColumnSelected) )
4413
for ( int x = dlg->left; x <= dlg->right; x++ )
4415
for ( int y = dlg->top; y <= dlg->bottom; y++ )
4417
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x, y );
4418
if ( fallDiagonal->isChanged() )
4419
obj->setFallDiagonalPen( tmpPenFall );
4420
if ( goUpDiagonal->isChanged() )
4421
obj->setGoUpDiagonalPen( tmpPenGoUp );
4425
else if ( dlg->isColumnSelected )
4427
KSpreadCell* c = NULL;
4428
for (int col = dlg->left; col <= dlg->right; col++)
4430
for (c = table->getFirstCellColumn(col); c != NULL;
4431
c = table->getNextCellDown(c->column(), c->row()))
4433
if ( fallDiagonal->isChanged() )
4435
c->clearProperty(KSpreadCell::PFallDiagonal);
4436
c->clearNoFallBackProperties( KSpreadCell::PFallDiagonal );
4438
if ( goUpDiagonal->isChanged() )
4440
c->clearProperty(KSpreadCell::PGoUpDiagonal);
4441
c->clearNoFallBackProperties( KSpreadCell::PGoUpDiagonal);
4445
ColumnFormat *obj=dlg->getTable()->nonDefaultColumnFormat(col);
4446
if ( fallDiagonal->isChanged() )
4447
obj->setFallDiagonalPen( tmpPenFall );
4448
if ( goUpDiagonal->isChanged() )
4449
obj->setGoUpDiagonalPen( tmpPenGoUp );
4453
RowFormat* rw =dlg->getTable()->firstRow();
4454
for ( ; rw; rw = rw->next() )
4456
if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PFallDiagonal)
4457
||rw->hasProperty(KSpreadCell::PGoUpDiagonal) ))
4459
for ( int i=dlg->left;i<=dlg->right;i++)
4462
dlg->getTable()->nonDefaultCell( i, rw->row() );
4463
if ( cell->isObscuringForced() && dlg->isSingleCell() )
4465
cell->setFallDiagonalPen( tmpPenFall );
4466
cell->setGoUpDiagonalPen( tmpPenGoUp );
4471
else if ( dlg->isRowSelected )
4473
KSpreadCell* c = NULL;
4474
for (int row = dlg->top; row <= dlg->bottom; row++)
4476
for (c = table->getFirstCellRow(row); c != NULL;
4477
c = table->getNextCellRight(c->column(), c->row()))
4479
if ( fallDiagonal->isChanged() )
4481
c->clearProperty(KSpreadCell::PFallDiagonal);
4482
c->clearNoFallBackProperties( KSpreadCell::PFallDiagonal );
4484
if ( goUpDiagonal->isChanged() )
4486
c->clearProperty(KSpreadCell::PGoUpDiagonal);
4487
c->clearNoFallBackProperties( KSpreadCell::PGoUpDiagonal);
4491
RowFormat *obj=dlg->getTable()->nonDefaultRowFormat(row);
4492
if ( fallDiagonal->isChanged() )
4493
obj->setFallDiagonalPen( tmpPenFall );
4494
if ( goUpDiagonal->isChanged() )
4495
obj->setGoUpDiagonalPen( tmpPenGoUp );
4500
void CellFormatPageBorder::applyHorizontalOutline()
4502
QPen tmpPen( borderButtons[BorderType_Horizontal]->getColor(),
4503
borderButtons[BorderType_Horizontal]->getPenWidth(),
4504
borderButtons[BorderType_Horizontal]->getPenStyle());
4506
if ( dlg->getStyle() )
4508
dlg->getStyle()->changeTopBorderPen( tmpPen );
4510
else if ( (!dlg->isRowSelected) && (!dlg->isColumnSelected) )
4512
for ( int x = dlg->left; x <= dlg->right; x++ )
4514
for ( int y = dlg->top + 1; y <= dlg->bottom; y++ )
4516
KSpreadCell * obj = dlg->getTable()->nonDefaultCell( x, y );
4517
obj->setTopBorderPen( tmpPen );
4521
else if ( dlg->isColumnSelected )
4523
KSpreadCell* c = NULL;
4524
for (int col = dlg->left; col <= dlg->right; col++)
4526
for (c = table->getFirstCellColumn(col); c != NULL;
4527
c = table->getNextCellDown(c->column(), c->row()))
4529
c->clearProperty(KSpreadCell::PTopBorder);
4530
c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
4533
ColumnFormat *obj=dlg->getTable()->nonDefaultColumnFormat(col);
4534
obj->setTopBorderPen(tmpPen);
4537
RowFormat* rw =dlg->getTable()->firstRow();
4538
for ( ; rw; rw = rw->next() )
4540
if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PTopBorder) ))
4542
for ( int i=dlg->left;i<=dlg->right;i++)
4545
dlg->getTable()->nonDefaultCell( i, rw->row() );
4546
cell->setTopBorderPen(tmpPen);
4551
else if ( dlg->isRowSelected )
4553
KSpreadCell* c = NULL;
4554
for (int row = dlg->top + 1; row <= dlg->bottom; row++)
4556
for (c = table->getFirstCellRow(row); c != NULL;
4557
c = table->getNextCellRight(c->column(), c->row()))
4559
c->clearProperty(KSpreadCell::PTopBorder);
4560
c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
4563
RowFormat *obj = dlg->getTable()->nonDefaultRowFormat(row);
4564
obj->setTopBorderPen(tmpPen);
4569
void CellFormatPageBorder::applyVerticalOutline()
4571
KSpreadBorderButton* vertical = borderButtons[BorderType_Vertical];
4572
QPen tmpPen( vertical->getColor(), vertical->getPenWidth(),
4573
vertical->getPenStyle());
4575
if ( dlg->getStyle() )
4576
dlg->getStyle()->changeLeftBorderPen( tmpPen );
4577
else if ( (!dlg->isRowSelected) && (!dlg->isColumnSelected) )
4579
for ( int x = dlg->left+1; x <= dlg->right; x++ )
4581
for ( int y = dlg->top; y <= dlg->bottom; y++ )
4583
KSpreadCell *obj = dlg->getTable()->nonDefaultCell( x, y );
4584
obj->setLeftBorderPen( tmpPen );
4588
else if ( dlg->isColumnSelected )
4590
KSpreadCell* c = NULL;
4591
for (int col = dlg->left + 1; col <= dlg->right; ++col)
4593
for (c = table->getFirstCellColumn(col); c != NULL;
4594
c = table->getNextCellDown(c->column(), c->row()))
4596
c->clearProperty(KSpreadCell::PLeftBorder);
4597
c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
4599
ColumnFormat *obj=dlg->getTable()->nonDefaultColumnFormat(col);
4600
obj->setLeftBorderPen( tmpPen );
4603
RowFormat * rw = dlg->getTable()->firstRow();
4604
for ( ; rw; rw = rw->next() )
4606
if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PLeftBorder) ))
4608
for ( int i = dlg->left + 1; i <= dlg->right; ++i )
4610
KSpreadCell * cell =
4611
dlg->getTable()->nonDefaultCell( i, rw->row() );
4612
cell->setLeftBorderPen( tmpPen );
4617
else if ( dlg->isRowSelected )
4619
KSpreadCell* c = NULL;
4620
for (int row = dlg->top; row <= dlg->bottom; row++)
4622
for (c = table->getFirstCellRow(row); c != NULL;
4623
c = table->getNextCellRight(c->column(), c->row()))
4625
c->clearProperty(KSpreadCell::PLeftBorder);
4626
c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
4628
RowFormat *obj=dlg->getTable()->nonDefaultRowFormat(row);
4629
obj->setLeftBorderPen( tmpPen );
4635
void CellFormatPageBorder::slotSetColorButton( const QColor &_color )
3806
4637
currentColor = _color;
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 )
4641
pattern[i]->setColor( currentColor );
3818
4643
preview->setColor( currentColor );
3822
void CellLayoutPageBorder::slotUnselect2( KSpreadPatternSelect *_p )
4646
void CellFormatPageBorder::slotUnselect2( KSpreadPatternSelect *_p )
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 )
4650
if ( pattern[i] != _p )
4652
pattern[i]->slotUnselect();
3844
4655
preview->setPattern( _p->getColor(), _p->getPenWidth(), _p->getPenStyle() );
3847
void CellLayoutPageBorder::preselect( KSpreadBorderButton *_p)
4658
void CellFormatPageBorder::preselect( KSpreadBorderButton *_p )
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];
3849
4670
_p->setOn(false);
3864
if(fallDiagonal->isOn())
3865
fallDiagonal->unselect();
3867
if(goUpDiagonal->isOn())
3868
goUpDiagonal->unselect();
3870
if(vertical->isOn())
3871
vertical->unselect();
3873
if(horizontal->isOn())
3874
horizontal->unselect();
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);
3889
left->setPenWidth(preview->getPenWidth());
3890
left->setPenStyle(preview->getPenStyle());
3891
left->setColor( currentColor );
3892
left->setChanged(true);
3894
right->setPenWidth(preview->getPenWidth());
3895
right->setPenStyle(preview->getPenStyle());
3896
right->setColor( currentColor );
3897
right->setChanged(true);
3901
if(dlg->oneRow==false)
3903
horizontal->setOn(true);
3904
horizontal->setPenWidth(preview->getPenWidth());
3905
horizontal->setPenStyle(preview->getPenStyle());
3906
horizontal->setColor( currentColor );
3907
horizontal->setChanged(true);
3909
if(dlg->oneCol==false)
3911
vertical->setOn(true);
3912
vertical->setPenWidth(preview->getPenWidth());
3913
vertical->setPenStyle(preview->getPenStyle());
3914
vertical->setColor( currentColor );
3915
vertical->setChanged(true);
4673
for (int i=BorderType_Top; i < BorderType_END; i++)
4675
if (borderButtons[i]->isOn())
4677
borderButtons[i]->unselect();
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);
4694
left->setPenWidth(preview->getPenWidth());
4695
left->setPenStyle(preview->getPenStyle());
4696
left->setColor( currentColor );
4697
left->setChanged(true);
4699
right->setPenWidth(preview->getPenWidth());
4700
right->setPenStyle(preview->getPenStyle());
4701
right->setColor( currentColor );
4702
right->setChanged(true);
4706
if (dlg->oneRow==false)
4708
horizontal->setOn(true);
4709
horizontal->setPenWidth(preview->getPenWidth());
4710
horizontal->setPenStyle(preview->getPenStyle());
4711
horizontal->setColor( currentColor );
4712
horizontal->setChanged(true);
4714
if (dlg->oneCol==false)
4716
vertical->setOn(true);
4717
vertical->setPenWidth(preview->getPenWidth());
4718
vertical->setPenStyle(preview->getPenStyle());
4719
vertical->setColor( currentColor );
4720
vertical->setChanged(true);
3918
4723
area->repaint();
3921
void CellLayoutPageBorder::changeState( KSpreadBorderButton *_p)
4726
void CellFormatPageBorder::changeState( KSpreadBorderButton *_p)
3923
4728
_p->setChanged(true);
3927
_p->setPenWidth(preview->getPenWidth());
3928
_p->setPenStyle(preview->getPenStyle());
3929
_p->setColor( currentColor );
3934
_p->setPenStyle(Qt::NoPen);
3935
_p->setColor( colorGroup().text() );
4732
_p->setPenWidth(preview->getPenWidth());
4733
_p->setPenStyle(preview->getPenStyle());
4734
_p->setColor( currentColor );
4739
_p->setPenStyle(Qt::NoPen);
4740
_p->setColor( colorGroup().text() );
3938
4743
area->repaint();
3941
void CellLayoutPageBorder::draw()
4746
void CellFormatPageBorder::draw()
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];
3944
4757
QPainter painter;
3945
4758
painter.begin( area );
3947
if((bottom->getPenStyle())!=Qt::NoPen)
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 );
3953
if((top->getPenStyle())!=Qt::NoPen)
3955
pen=QPen( top->getColor(), top->getPenWidth(),top->getPenStyle());
3956
painter.setPen( pen );
3957
painter.drawLine( OFFSETX, OFFSETY, area->width() -OFFSETX, OFFSETY );
3959
if((left->getPenStyle())!=Qt::NoPen)
3961
pen=QPen( left->getColor(), left->getPenWidth(),left->getPenStyle());
3962
painter.setPen( pen );
3963
painter.drawLine( OFFSETX, OFFSETY, OFFSETX , area->height()-OFFSETY );
3965
if((right->getPenStyle())!=Qt::NoPen)
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 );
3972
if((fallDiagonal->getPenStyle())!=Qt::NoPen)
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)
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 );
3983
if((goUpDiagonal->getPenStyle())!=Qt::NoPen)
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)
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 );
3995
if((vertical->getPenStyle())!=Qt::NoPen)
3997
pen=QPen( vertical->getColor(), vertical->getPenWidth(),vertical->getPenStyle());
4760
if ((bottom->getPenStyle())!=Qt::NoPen)
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 );
4766
if ((top->getPenStyle())!=Qt::NoPen)
4768
pen=QPen( top->getColor(), top->getPenWidth(),top->getPenStyle());
4769
painter.setPen( pen );
4770
painter.drawLine( OFFSETX, OFFSETY, area->width() -OFFSETX, OFFSETY );
4772
if ((left->getPenStyle())!=Qt::NoPen)
4774
pen=QPen( left->getColor(), left->getPenWidth(),left->getPenStyle());
4775
painter.setPen( pen );
4776
painter.drawLine( OFFSETX, OFFSETY, OFFSETX , area->height()-OFFSETY );
4778
if ((right->getPenStyle())!=Qt::NoPen)
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 );
4786
if ((fallingDiagonal->getPenStyle())!=Qt::NoPen)
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)
4795
painter.drawLine( area->width()/2, OFFSETY, area->width()-OFFSETX,
4797
painter.drawLine( OFFSETX,area->height()/2 , area->width()/2,
4798
area->height()-OFFSETY );
4801
if ((risingDiagonal->getPenStyle())!=Qt::NoPen)
4803
pen=QPen( risingDiagonal->getColor(), risingDiagonal->getPenWidth(),
4804
risingDiagonal->getPenStyle());
4805
painter.setPen( pen );
4806
painter.drawLine( OFFSETX, area->height()-OFFSETY , area->width()-OFFSETX ,
4808
if (dlg->oneCol==false&& dlg->oneRow==false)
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 );
4816
if ((vertical->getPenStyle())!=Qt::NoPen)
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 );
4001
if((horizontal->getPenStyle())!=Qt::NoPen)
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 );
4823
if ((horizontal->getPenStyle())!=Qt::NoPen)
4825
pen=QPen( horizontal->getColor(), horizontal->getPenWidth(),
4826
horizontal->getPenStyle());
4827
painter.setPen( pen );
4828
painter.drawLine( OFFSETX,area->height()/2,area->width()-OFFSETX,
4010
void CellLayoutPageBorder::invertState(KSpreadBorderButton *_p)
4834
void CellFormatPageBorder::invertState(KSpreadBorderButton *_p)
4018
_p->setOn(!_p->isOn());
4019
_p->setPenWidth(preview->getPenWidth());
4020
_p->setPenStyle(preview->getPenStyle());
4021
_p->setColor( currentColor );
4022
_p->setChanged(true);
4843
_p->setPenWidth(preview->getPenWidth());
4844
_p->setPenStyle(preview->getPenStyle());
4845
_p->setColor( currentColor );
4846
_p->setChanged(true);
4026
void CellLayoutPageBorder::slotPressEvent(QMouseEvent *_ev)
4850
void CellFormatPageBorder::slotPressEvent(QMouseEvent *_ev)
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];
4028
4860
QRect rect(OFFSETX,OFFSETY-8,area->width()-OFFSETX,OFFSETY+8);
4029
if(rect.contains(QPoint(_ev->x(),_ev->y())))
4031
if(((top->getPenWidth()!=preview->getPenWidth()) ||(top->getColor()!=currentColor)
4032
||(top->getPenStyle()!=preview->getPenStyle()))&& top->isOn())
4034
top->setPenWidth(preview->getPenWidth());
4035
top->setPenStyle(preview->getPenStyle());
4036
top->setColor( currentColor );
4037
top->setChanged(true);
4042
rect.setCoords(OFFSETX,area->height()-OFFSETY-8,area->width()-OFFSETX,area->height()-OFFSETY+8);
4043
if(rect.contains(QPoint(_ev->x(),_ev->y())))
4045
if(((bottom->getPenWidth()!=preview->getPenWidth()) ||(bottom->getColor()!=currentColor)
4046
||(bottom->getPenStyle()!=preview->getPenStyle()))&& bottom->isOn())
4048
bottom->setPenWidth(preview->getPenWidth());
4049
bottom->setPenStyle(preview->getPenStyle());
4050
bottom->setColor( currentColor );
4051
bottom->setChanged(true);
4054
invertState(bottom);
4861
if (rect.contains(QPoint(_ev->x(),_ev->y())))
4863
if (((top->getPenWidth()!=preview->getPenWidth()) ||
4864
(top->getColor()!=currentColor) ||
4865
(top->getPenStyle()!=preview->getPenStyle()))
4868
top->setPenWidth(preview->getPenWidth());
4869
top->setPenStyle(preview->getPenStyle());
4870
top->setColor( currentColor );
4871
top->setChanged(true);
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())))
4880
if (((bottom->getPenWidth()!=preview->getPenWidth()) ||
4881
(bottom->getColor()!=currentColor) ||
4882
(bottom->getPenStyle()!=preview->getPenStyle()))
4885
bottom->setPenWidth(preview->getPenWidth());
4886
bottom->setPenStyle(preview->getPenStyle());
4887
bottom->setColor( currentColor );
4888
bottom->setChanged(true);
4891
invertState(bottom);
4057
4894
rect.setCoords(OFFSETX-8,OFFSETY,OFFSETX+8,area->height()-OFFSETY);
4058
if(rect.contains(QPoint(_ev->x(),_ev->y())))
4060
if(((left->getPenWidth()!=preview->getPenWidth()) ||(left->getColor()!=currentColor)
4061
||(left->getPenStyle()!=preview->getPenStyle()))&& left->isOn())
4063
left->setPenWidth(preview->getPenWidth());
4064
left->setPenStyle(preview->getPenStyle());
4065
left->setColor( currentColor );
4895
if (rect.contains(QPoint(_ev->x(),_ev->y())))
4897
if (((left->getPenWidth()!=preview->getPenWidth()) ||
4898
(left->getColor()!=currentColor) ||
4899
(left->getPenStyle()!=preview->getPenStyle()))
4902
left->setPenWidth(preview->getPenWidth());
4903
left->setPenStyle(preview->getPenStyle());
4904
left->setColor( currentColor );
4066
4905
left->setChanged(true);
4071
rect.setCoords(area->width()-OFFSETX-8,OFFSETY,area->width()-OFFSETX+8,area->height()-OFFSETY);
4072
if(rect.contains(QPoint(_ev->x(),_ev->y())))
4074
if(((right->getPenWidth()!=preview->getPenWidth()) ||(right->getColor()!=currentColor)
4075
||(right->getPenStyle()!=preview->getPenStyle()))&& right->isOn())
4077
right->setPenWidth(preview->getPenWidth());
4078
right->setPenStyle(preview->getPenStyle());
4079
right->setColor( currentColor );
4080
right->setChanged(true);
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())))
4914
if (((right->getPenWidth()!=preview->getPenWidth()) ||
4915
(right->getColor()!=currentColor) ||
4916
(right->getPenStyle()!=preview->getPenStyle()))
4919
right->setPenWidth(preview->getPenWidth());
4920
right->setPenStyle(preview->getPenStyle());
4921
right->setColor( currentColor );
4922
right->setChanged(true);
4086
4928
//don't work because I don't know how create a rectangle
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())))
4091
4933
invertState(fallDiagonal);
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())))
4096
4938
invertState(goUpDiagonal);
4099
if(dlg->oneCol==false)
4101
rect.setCoords(area->width()/2-8,OFFSETY,area->width()/2+8,area->height()-OFFSETY);
4103
if(rect.contains(QPoint(_ev->x(),_ev->y())))
4105
if(((vertical->getPenWidth()!=preview->getPenWidth()) ||(vertical->getColor()!=currentColor)
4106
||(vertical->getPenStyle()!=preview->getPenStyle()))&& vertical->isOn())
4108
vertical->setPenWidth(preview->getPenWidth());
4109
vertical->setPenStyle(preview->getPenStyle());
4110
vertical->setColor( currentColor );
4111
vertical->setChanged(true);
4114
invertState(vertical);
4117
if(dlg->oneRow==false)
4119
rect.setCoords(OFFSETX,area->height()/2-8,area->width()-OFFSETX,area->height()/2+8);
4120
if(rect.contains(QPoint(_ev->x(),_ev->y())))
4122
if(((horizontal->getPenWidth()!=preview->getPenWidth()) ||(horizontal->getColor()!=currentColor)
4123
||(horizontal->getPenStyle()!=preview->getPenStyle()))&& horizontal->isOn())
4125
horizontal->setPenWidth(preview->getPenWidth());
4126
horizontal->setPenStyle(preview->getPenStyle());
4127
horizontal->setColor( currentColor );
4128
horizontal->setChanged(true);
4131
invertState(horizontal);
4941
if (dlg->oneCol==false)
4943
rect.setCoords(area->width()/2-8,OFFSETY,area->width()/2+8,
4944
area->height()-OFFSETY);
4946
if (rect.contains(QPoint(_ev->x(),_ev->y())))
4948
if (((vertical->getPenWidth()!=preview->getPenWidth()) ||
4949
(vertical->getColor()!=currentColor) ||
4950
(vertical->getPenStyle()!=preview->getPenStyle()))
4951
&& vertical->isOn())
4953
vertical->setPenWidth(preview->getPenWidth());
4954
vertical->setPenStyle(preview->getPenStyle());
4955
vertical->setColor( currentColor );
4956
vertical->setChanged(true);
4959
invertState(vertical);
4962
if (dlg->oneRow==false)
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())))
4968
if (((horizontal->getPenWidth()!=preview->getPenWidth()) ||
4969
(horizontal->getColor()!=currentColor) ||
4970
(horizontal->getPenStyle()!=preview->getPenStyle()))
4971
&& horizontal->isOn())
4973
horizontal->setPenWidth(preview->getPenWidth());
4974
horizontal->setPenStyle(preview->getPenStyle());
4975
horizontal->setColor( currentColor );
4976
horizontal->setChanged(true);
4979
invertState(horizontal);
4138
4986
KSpreadBrushSelect::KSpreadBrushSelect( QWidget *parent, const char * ) : QFrame( parent )
4140
4988
brushStyle = Qt::NoBrush;
4141
4989
brushColor = Qt::red;
4145
4993
void KSpreadBrushSelect::setPattern( const QColor &_color,BrushStyle _style )