00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <stdlib.h>
00032 #include <math.h>
00033
00034 #include "kspread_canvas.h"
00035 #include "kspread_dlg_layout.h"
00036 #include "kspread_locale.h"
00037 #include "kspread_sheet.h"
00038 #include "kspread_style.h"
00039 #include "kspread_style_manager.h"
00040 #include "kspread_undo.h"
00041 #include "kspread_util.h"
00042 #include "valueformatter.h"
00043
00044 #include <qbitmap.h>
00045 #include <qlabel.h>
00046 #include <qlistbox.h>
00047 #include <qlayout.h>
00048 #include <qfontdatabase.h>
00049 #include <kdialog.h>
00050 #include <kdebug.h>
00051 #include <kmessagebox.h>
00052 #include <knumvalidator.h>
00053 #include <qradiobutton.h>
00054 #include <klineedit.h>
00055 #include <qcheckbox.h>
00056 #include <kcolorbutton.h>
00057 #include <kcombobox.h>
00058
00059
00060 KSpreadPatternSelect::KSpreadPatternSelect( QWidget *parent, const char * )
00061 : QFrame( parent )
00062 {
00063 penStyle = NoPen;
00064 penWidth = 1;
00065 penColor = colorGroup().text();
00066 selected = false;
00067 undefined = false;
00068 }
00069
00070 void KSpreadPatternSelect::setPattern( const QColor &_color, int _width, PenStyle _style )
00071 {
00072 penStyle = _style;
00073 penColor = _color;
00074 penWidth = _width;
00075 repaint();
00076 }
00077
00078 void KSpreadPatternSelect::setUndefined()
00079 {
00080 undefined = true;
00081 }
00082
00083 void KSpreadPatternSelect::paintEvent( QPaintEvent *_ev )
00084 {
00085 QFrame::paintEvent( _ev );
00086
00087 QPainter painter( this );
00088
00089 if ( !undefined )
00090 {
00091 QPen pen( penColor, penWidth, penStyle);
00092 painter.setPen( pen );
00093 painter.drawLine( 6, height()/2, width() - 6,height()/2 );
00094 }
00095 else
00096 {
00097 painter.fillRect( 2, 2, width() - 4, height() - 4, BDiagPattern );
00098 }
00099 }
00100
00101 void KSpreadPatternSelect::mousePressEvent( QMouseEvent * )
00102 {
00103 slotSelect();
00104
00105 emit clicked( this );
00106 }
00107
00108 void KSpreadPatternSelect::slotUnselect()
00109 {
00110 selected = false;
00111
00112 setLineWidth( 1 );
00113 setFrameStyle( QFrame::Panel | QFrame::Sunken );
00114 repaint();
00115 }
00116
00117 void KSpreadPatternSelect::slotSelect()
00118 {
00119 selected = true;
00120
00121 setLineWidth( 2 );
00122 setFrameStyle( QFrame::Panel | QFrame::Plain );
00123 repaint();
00124 }
00125
00126
00127
00128 GeneralTab::GeneralTab( QWidget* parent, CellFormatDlg * dlg )
00129 : QWidget( parent ),
00130 m_dlg( dlg )
00131 {
00132 QGridLayout * layout = new QGridLayout( this, 1, 1, KDialog::marginHint(), KDialog::spacingHint(), "layout");
00133
00134 QGroupBox * groupBox = new QGroupBox( this, "groupBox1" );
00135 groupBox->setColumnLayout(0, Qt::Vertical );
00136 groupBox->setTitle( i18n( "Style" ) );
00137 groupBox->layout()->setSpacing( KDialog::spacingHint() );
00138 groupBox->layout()->setMargin( KDialog::marginHint() );
00139
00140 QGridLayout * groupBoxLayout = new QGridLayout( groupBox->layout() );
00141 groupBoxLayout->setAlignment( Qt::AlignTop );
00142
00143 QLabel * label1 = new QLabel( groupBox, "label1" );
00144 label1->setText( i18n( "Name:" ) );
00145 groupBoxLayout->addWidget( label1, 0, 0 );
00146
00147 m_nameEdit = new KLineEdit( groupBox, "m_nameEdit" );
00148 m_nameEdit->setText( m_dlg->styleName );
00149 groupBoxLayout->addWidget( m_nameEdit, 0, 1 );
00150
00151 QLabel * label2 = new QLabel( groupBox, "label2" );
00152 label2->setText( i18n( "Inherit style:" ) );
00153 groupBoxLayout->addWidget( label2, 1, 0 );
00154
00155 m_parentBox = new KComboBox( false, groupBox, "m_parentBox" );
00156 m_parentBox->clear();
00157 m_parentBox->insertItem( i18n( "<None>" ) );
00158 QStringList tmp = m_dlg->getStyleManager()->styleNames();
00159 tmp.remove( m_dlg->styleName );
00160 m_parentBox->insertStringList( tmp );
00161
00162 if ( m_dlg->getStyle()->parent() )
00163 m_parentBox->setCurrentText( m_dlg->getStyle()->parentName() );
00164 else
00165 {
00166 m_parentBox->setCurrentText( i18n( "<None>" ) );
00167
00168 if ( m_dlg->getStyle()->definesAll() )
00169 m_parentBox->setEnabled( false );
00170 }
00171
00172 connect( m_parentBox, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotNewParent( const QString & ) ) );
00173 connect( m_nameEdit, SIGNAL( lostFocus() ), this, SLOT( slotNameChanged() ) );
00174
00175 groupBoxLayout->addWidget( m_parentBox, 1, 1 );
00176
00177 QSpacerItem * spacer = new QSpacerItem( 20, 260, QSizePolicy::Minimum, QSizePolicy::Expanding );
00178
00179 layout->addWidget( groupBox, 0, 0 );
00180 layout->addItem( spacer, 1, 0 );
00181
00182 if ( m_dlg->getStyle()->type() == KSpreadStyle::BUILTIN )
00183 {
00184 m_nameEdit->setEnabled( false );
00185 m_parentBox->setEnabled( false );
00186 }
00187
00188 resize( QSize( 534, 447 ).expandedTo(minimumSizeHint()) );
00189 }
00190
00191 GeneralTab::~GeneralTab()
00192 {
00193 }
00194
00195 void GeneralTab::slotNameChanged()
00196 {
00197 checkName();
00198 }
00199
00200 void GeneralTab::slotNewParent( const QString & parentName )
00201 {
00202 kdDebug() << "New Parent" << endl;
00203 if ( !checkParent( parentName ) )
00204 return;
00205
00206 if ( parentName.isEmpty() || parentName == i18n( "<None>" ) )
00207 m_dlg->getStyle()->setParent( 0 );
00208 else
00209 m_dlg->getStyle()->setParent( m_dlg->getStyleManager()->style( parentName ) );
00210
00211
00212
00213 }
00214
00215 bool GeneralTab::checkName()
00216 {
00217 if ( m_nameEdit->isEnabled() )
00218 {
00219 if ( !m_dlg->getStyleManager()->validateStyleName( m_nameEdit->text(), m_dlg->getStyle() ) )
00220 {
00221 KMessageBox::sorry( this, i18n( "A style with this name already exists." ) );
00222 return false;
00223 }
00224 }
00225
00226 return true;
00227 }
00228
00229 bool GeneralTab::checkParent( const QString & parentName )
00230 {
00231 if ( m_dlg->getStyle()->parentName() != parentName
00232 && m_parentBox->isEnabled() && parentName != i18n( "<None>" ) && !parentName.isEmpty() )
00233 {
00234 if ( m_nameEdit->text() == parentName )
00235 {
00236 KMessageBox::sorry( this, i18n( "A style cannot inherit from itself." ) );
00237 return false;
00238 }
00239 if ( !m_dlg->checkCircle( m_nameEdit->text(), parentName ) )
00240 {
00241 KMessageBox::sorry( this,
00242 i18n( "The style cannot inherit from '%1' because of recursive references." )
00243 .arg( m_parentBox->currentText() ) );
00244 return false;
00245 }
00246
00247 KSpreadCustomStyle * p = m_dlg->getStyleManager()->style( parentName );
00248
00249 if ( !p )
00250 {
00251 KMessageBox::sorry( this, i18n( "The parent style does not exist." ) );
00252 return false;
00253 }
00254 }
00255
00256 return true;
00257 }
00258
00259 bool GeneralTab::apply( KSpreadCustomStyle * style )
00260 {
00261 if ( !checkParent( m_parentBox->currentText() ) )
00262 return false;
00263
00264 if ( !checkName() )
00265 return false;
00266
00267 if ( m_nameEdit->isEnabled() )
00268 {
00269 if ( style->type() != KSpreadStyle::BUILTIN )
00270 {
00271 QString name( style->name() );
00272 style->setName( m_nameEdit->text() );
00273 if ( m_parentBox->isEnabled() )
00274 {
00275 if ( m_parentBox->currentText() == i18n( "None" ) || m_parentBox->currentText().isEmpty() )
00276 style->setParent( 0 );
00277 else
00278 style->setParent( m_dlg->getStyleManager()->style( m_parentBox->currentText() ) );
00279 }
00280 m_dlg->getStyleManager()->changeName( name, m_nameEdit->text() );
00281 }
00282 }
00283
00284 if ( style->type() == KSpreadStyle::TENTATIVE )
00285 style->setType( KSpreadStyle::CUSTOM );
00286
00287 return true;
00288 }
00289
00290
00291
00292 CellFormatDlg::CellFormatDlg( KSpreadView * _view, KSpreadSheet * _sheet,
00293 int _left, int _top, int _right, int _bottom )
00294 : QObject(),
00295 m_doc( _sheet->doc() ),
00296 m_sheet( _sheet ),
00297 m_pView( _view ),
00298 m_style( 0 )
00299 {
00300 initMembers();
00301
00302
00303 isRowSelected = util_isRowSelected(_view->selection());
00304 isColumnSelected = util_isColumnSelected(_view->selection());
00305
00306
00307 left = _left;
00308 top = _top;
00309 right = _right;
00310 bottom = _bottom;
00311
00312 if ( left == right )
00313 oneCol = true;
00314 else
00315 oneCol = false;
00316
00317 if ( top == bottom )
00318 oneRow = true;
00319 else
00320 oneRow = false;
00321
00322 KSpreadCell * obj = m_sheet->cellAt( _left, _top );
00323 oneCell = (left == right && top == bottom &&
00324 !obj->isForceExtraCells());
00325
00326 isMerged = ((obj->isForceExtraCells() &&
00327 left + obj->extraXCells() >= right &&
00328 top + obj->extraYCells() >= bottom));
00329
00330
00331 borders[BorderType_Left].style = obj->leftBorderStyle( _left, _top );
00332 borders[BorderType_Left].width = obj->leftBorderWidth( _left, _top );
00333 borders[BorderType_Left].color = obj->leftBorderColor( _left, _top );
00334 borders[BorderType_Top].style = obj->topBorderStyle( _left, _top );
00335 borders[BorderType_Top].width = obj->topBorderWidth( _left, _top );
00336 borders[BorderType_Top].color = obj->topBorderColor( _left, _top );
00337 borders[BorderType_FallingDiagonal].style =
00338 obj->fallDiagonalStyle( _left, _top );
00339 borders[BorderType_FallingDiagonal].width =
00340 obj->fallDiagonalWidth( _left, _top );
00341 borders[BorderType_FallingDiagonal].color =
00342 obj->fallDiagonalColor( _left, _top );
00343 borders[BorderType_RisingDiagonal].style =
00344 obj->goUpDiagonalStyle( _left, _top );
00345 borders[BorderType_RisingDiagonal].width =
00346 obj->goUpDiagonalWidth( _left, _top );
00347 borders[BorderType_RisingDiagonal].color =
00348 obj->goUpDiagonalColor( _left, _top );
00349
00350
00351 obj = m_sheet->cellAt( _right, _top );
00352 borders[BorderType_Right].style = obj->rightBorderStyle( _right, _top );
00353 borders[BorderType_Right].width = obj->rightBorderWidth( _right, _top );
00354 borders[BorderType_Right].color = obj->rightBorderColor( _right, _top );
00355
00356
00357 obj = m_sheet->cellAt( _left, _bottom );
00358 borders[BorderType_Bottom].style = obj->bottomBorderStyle( _left, _bottom );
00359 borders[BorderType_Bottom].width = obj->bottomBorderWidth( _left, _bottom );
00360 borders[BorderType_Bottom].color = obj->bottomBorderColor( _left, _bottom );
00361
00362
00363 obj = m_sheet->cellAt( _right, _top );
00364 if ( obj->isObscuringForced() )
00365 {
00366 obj = obj->obscuringCells().first();
00367 int moveX = obj->column();
00368 int moveY = _top;
00369 int moveX2 = _right;
00370 int moveY2 = obj->row();
00371 borders[BorderType_Vertical].style = obj->leftBorderStyle( moveX, moveY );
00372 borders[BorderType_Vertical].width = obj->leftBorderWidth( moveX, moveY );
00373 borders[BorderType_Vertical].color = obj->leftBorderColor( moveX, moveY );
00374
00375 obj = m_sheet->cellAt( moveX2, moveY2 );
00376 borders[BorderType_Horizontal].style = obj->topBorderStyle( moveX2, moveY2 );
00377 borders[BorderType_Horizontal].width = obj->topBorderWidth( moveX2, moveY2 );
00378 borders[BorderType_Horizontal].color = obj->topBorderColor( moveX2, moveY2 );
00379 }
00380 else
00381 {
00382 borders[BorderType_Vertical].style = obj->leftBorderStyle( _right, _top );
00383 borders[BorderType_Vertical].width = obj->leftBorderWidth( _right, _top );
00384 borders[BorderType_Vertical].color = obj->leftBorderColor( _right, _top );
00385 borders[BorderType_Horizontal].style = obj->topBorderStyle(_right, _bottom);
00386 borders[BorderType_Horizontal].width = obj->topBorderWidth(_right, _bottom);
00387 borders[BorderType_Horizontal].color = obj->topBorderColor(_right, _bottom);
00388 }
00389
00390 obj = m_sheet->cellAt( _left, _top );
00391 prefix = obj->prefix( _left, _top );
00392 postfix = obj->postfix( _left, _top );
00393 precision = obj->precision( _left, _top );
00394 floatFormat = obj->floatFormat( _left, _top );
00395 floatColor = obj->floatColor( _left, _top );
00396 alignX = obj->align( _left, _top );
00397 alignY = obj->alignY( _left, _top );
00398 textColor = obj->textColor( _left, _top );
00399 bgColor = obj->bgColor( _left, _top );
00400 textFontSize = obj->textFontSize( _left, _top );
00401 textFontFamily = obj->textFontFamily( _left, _top );
00402 textFontBold = obj->textFontBold( _left, _top );
00403 textFontItalic = obj->textFontItalic( _left, _top );
00404 strike=obj->textFontStrike( _left, _top );
00405 underline = obj->textFontUnderline( _left, _top );
00406
00407 textFont = obj->textFont( _left, _top );
00408 obj->currencyInfo( cCurrency );
00409
00410 brushColor = obj->backGroundBrushColor( _left, _top );
00411 brushStyle = obj->backGroundBrushStyle( _left,_top );
00412
00413 bMultiRow = obj->multiRow( _left, _top );
00414 bVerticalText = obj->verticalText( _left, _top );
00415 textRotation = obj->getAngle(_left, _top);
00416 formatType = obj->getFormatType(_left, _top);
00417
00418 bDontPrintText = obj->getDontprintText( _left, _top );
00419 bHideFormula = obj->isHideFormula( _left, _top );
00420 bHideAll = obj->isHideAll( _left, _top );
00421 bIsProtected = !obj->notProtected( _left, _top );
00422
00423 indent = obj->getIndent(_left, _top);
00424
00425 value = obj->value();
00426
00427 RowFormat *rl;
00428 ColumnFormat *cl;
00429 widthSize = 0.0;
00430 heightSize = 0.0;
00431
00432 if ( !isRowSelected )
00433 {
00434 for ( int x = _left; x <= _right; x++ )
00435 {
00436 cl = m_pView->activeSheet()->columnFormat( x );
00437 widthSize = QMAX( cl->dblWidth(), widthSize );
00438 }
00439 }
00440
00441 if ( !isColumnSelected )
00442 {
00443 for ( int y = _top; y <= _bottom; y++ )
00444 {
00445 rl = m_pView->activeSheet()->rowFormat(y);
00446 heightSize = QMAX( rl->dblHeight(), heightSize );
00447 }
00448 }
00449
00450
00451 if ( isColumnSelected )
00452 {
00453 int y = 1;
00454 KSpreadCell* c = NULL;
00455 for (int x = _left;x <= _right; x++)
00456 {
00457 ColumnFormat *obj = m_sheet->nonDefaultColumnFormat(x);
00458 initParameters( obj,x,y);
00459
00460 for (c = m_sheet->getFirstCellColumn(x); c != NULL;
00461 c = m_sheet->getNextCellDown(c->column(), c->row()))
00462 {
00463 initParameters( c, x, c->row());
00464 }
00465 }
00466
00467 }
00468 else if ( isRowSelected )
00469 {
00470 int x = 1;
00471 KSpreadCell* c = NULL;
00472 for ( int y = _top;y<=_bottom;y++)
00473 {
00474 RowFormat *obj = m_sheet->nonDefaultRowFormat(y);
00475 initParameters( obj,x,y);
00476
00477 for (c = m_sheet->getFirstCellRow(y); c != NULL;
00478 c = m_sheet->getNextCellRight(c->column(), c->row()) )
00479 {
00480 initParameters( c, c->column(), c->row());
00481 }
00482 }
00483 }
00484 else
00485 {
00486
00487 for ( int x = _left; x <= _right; x++ )
00488 {
00489 for ( int y = _top; y <= _bottom; y++ )
00490 {
00491 KSpreadCell *obj = m_sheet->cellAt( x, y );
00492
00493 if ( obj->isObscuringForced() )
00494 continue;
00495
00496 initParameters( obj,x,y);
00497 }
00498 }
00499 }
00500 if ( !bTextRotation )
00501 textRotation = 0;
00502
00503 if ( isColumnSelected )
00504 {
00505 int y=1;
00506 ColumnFormat *obj=m_sheet->nonDefaultColumnFormat(_left);
00507 checkBorderLeft( obj,_left, y);
00508
00509 KSpreadCell* c = NULL;
00510 for (c = m_sheet->getFirstCellColumn(_left); c != NULL;
00511 c = m_sheet->getNextCellDown(c->column(), c->row()) )
00512 {
00513 checkBorderLeft(c, c->column(), c->row());
00514 }
00515
00516
00517 obj=m_sheet->nonDefaultColumnFormat(_right);
00518 checkBorderRight(obj,_right,y);
00519 c = NULL;
00520 for (c = m_sheet->getFirstCellColumn(_right); c != NULL;
00521 c = m_sheet->getNextCellDown(c->column(), c->row()) )
00522 {
00523 checkBorderRight(c, c->column(), c->row());
00524 }
00525
00526 for ( int x = _left; x <= _right; x++ )
00527 {
00528 KSpreadCell *obj = m_sheet->cellAt( x, _top );
00529 checkBorderTop(obj,x, _top);
00530 obj = m_sheet->cellAt( x, _bottom );
00531 checkBorderBottom(obj,x, _bottom);
00532 if ( x > _left )
00533 {
00534 ColumnFormat *obj = m_sheet->nonDefaultColumnFormat(x);
00535 checkBorderHorizontal(obj,x, y);
00536 checkBorderVertical(obj,x, y);
00537 }
00538 }
00539 }
00540 else if ( isRowSelected )
00541 {
00542 int x=1;
00543 for ( int y = _top; y <= _bottom; y++ )
00544 {
00545 KSpreadCell *obj = m_sheet->cellAt( _right, y );
00546 checkBorderRight(obj,_right,y);
00547 obj = m_sheet->cellAt( _left, y );
00548 checkBorderLeft( obj,_left, y);
00549 if ( y > _top )
00550 {
00551 RowFormat* obj = m_sheet->nonDefaultRowFormat(y);
00552 checkBorderHorizontal(obj,x, y);
00553 checkBorderVertical(obj,x, y);
00554 }
00555 }
00556
00557 RowFormat *obj=m_sheet->nonDefaultRowFormat(_top);
00558 checkBorderTop(obj,x, _top);
00559 obj=m_sheet->nonDefaultRowFormat(_bottom);
00560 checkBorderBottom(obj,x, _bottom);
00561 }
00562 else
00563 {
00564 for ( int y = _top; y <= _bottom; y++ )
00565 {
00566 KSpreadCell *obj = m_sheet->cellAt( _left, y );
00567 checkBorderLeft( obj,_left, y);
00568 obj = m_sheet->cellAt( _right, y );
00569 checkBorderRight(obj,_right,y);
00570 }
00571
00572 for ( int x = _left; x <= _right; x++ )
00573 {
00574 KSpreadCell *obj = m_sheet->cellAt( x, _top );
00575 checkBorderTop( obj, x, _top );
00576 obj = m_sheet->cellAt( x, _bottom );
00577 checkBorderBottom( obj, x, _bottom );
00578 }
00579
00580
00581 for ( int x = _left; x <= _right; x++ )
00582 {
00583 for ( int y = _top+1; y <= _bottom; y++ )
00584 {
00585 KSpreadCell *obj = m_sheet->cellAt( x, y );
00586 checkBorderHorizontal(obj,x, y);
00587 }
00588 }
00589
00590 for ( int x = _left+1; x <= _right; x++ )
00591 {
00592 for ( int y = _top; y <= _bottom; y++ )
00593 {
00594 KSpreadCell *obj = m_sheet->cellAt( x, y );
00595 checkBorderVertical(obj,x,y);
00596 }
00597 }
00598 }
00599
00600 init();
00601 }
00602
00603 CellFormatDlg::CellFormatDlg( KSpreadView * _view, KSpreadCustomStyle * _style,
00604 KSpreadStyleManager * _manager, KSpreadDoc * doc )
00605 : QObject(),
00606 m_doc( doc ),
00607 m_sheet( 0 ),
00608 m_pView( _view ),
00609 m_style( _style ),
00610 m_styleManager( _manager )
00611 {
00612 initMembers();
00613 initGUI();
00614 init();
00615 }
00616
00617 void CellFormatDlg::initGUI()
00618 {
00619 isRowSelected = false;
00620 isColumnSelected = false;
00621 styleName = m_style->name();
00622
00623 borders[BorderType_Left].style = m_style->leftBorderPen().style();
00624 borders[BorderType_Left].width = m_style->leftBorderPen().width();
00625 borders[BorderType_Left].color = m_style->leftBorderPen().color();
00626
00627 borders[BorderType_Top].style = m_style->topBorderPen().style();
00628 borders[BorderType_Top].width = m_style->topBorderPen().width();
00629 borders[BorderType_Top].color = m_style->topBorderPen().color();
00630
00631 borders[BorderType_Right].style = m_style->rightBorderPen().style();
00632 borders[BorderType_Right].width = m_style->rightBorderPen().width();
00633 borders[BorderType_Right].color = m_style->rightBorderPen().color();
00634
00635 borders[BorderType_Bottom].style = m_style->bottomBorderPen().style();
00636 borders[BorderType_Bottom].width = m_style->bottomBorderPen().width();
00637 borders[BorderType_Bottom].color = m_style->bottomBorderPen().color();
00638
00639 borders[BorderType_FallingDiagonal].style = m_style->fallDiagonalPen().style();
00640 borders[BorderType_FallingDiagonal].width = m_style->fallDiagonalPen().width();
00641 borders[BorderType_FallingDiagonal].color = m_style->fallDiagonalPen().color();
00642
00643 borders[BorderType_RisingDiagonal].style = m_style->goUpDiagonalPen().style();
00644 borders[BorderType_RisingDiagonal].width = m_style->goUpDiagonalPen().width();
00645 borders[BorderType_RisingDiagonal].color = m_style->goUpDiagonalPen().color();
00646
00647 borders[BorderType_Vertical].style = m_style->leftBorderPen().style();
00648 borders[BorderType_Vertical].width = m_style->leftBorderPen().width();
00649 borders[BorderType_Vertical].color = m_style->leftBorderPen().color();
00650 borders[BorderType_Horizontal].style = m_style->topBorderPen().style();
00651 borders[BorderType_Horizontal].width = m_style->topBorderPen().width();
00652 borders[BorderType_Horizontal].color = m_style->topBorderPen().color();
00653
00654 prefix = m_style->prefix();
00655 postfix = m_style->postfix();
00656 precision = m_style->precision();
00657 floatFormat = m_style->floatFormat();
00658 floatColor = m_style->floatColor();
00659 alignX = m_style->alignX();
00660 alignY = m_style->alignY();
00661 textColor = m_style->pen().color();
00662 bgColor = m_style->bgColor();
00663 textFontSize = m_style->fontSize();
00664 textFontFamily = m_style->fontFamily();
00665
00666 uint flags = m_style->fontFlags();
00667 textFontBold = ( flags & (uint) KSpreadStyle::FBold );
00668 textFontItalic = ( flags & (uint) KSpreadStyle::FItalic );
00669 strike = ( flags & (uint) KSpreadStyle::FStrike );
00670 underline = ( flags & (uint) KSpreadStyle::FUnderline );
00671
00672
00673 textFont = m_style->font();
00674 cCurrency = m_style->currency();
00675 brushColor = m_style->backGroundBrush().color();
00676 brushStyle = m_style->backGroundBrush().style();
00677
00678 bMultiRow = m_style->hasProperty( KSpreadStyle::PMultiRow );
00679 bVerticalText = m_style->hasProperty( KSpreadStyle::PVerticalText );
00680 textRotation = m_style->rotateAngle();
00681 formatType = m_style->formatType();
00682 indent = m_style->indent();
00683
00684 bDontPrintText = m_style->hasProperty( KSpreadStyle::PDontPrintText );
00685 bHideFormula = m_style->hasProperty( KSpreadStyle::PHideFormula );
00686 bHideAll = m_style->hasProperty( KSpreadStyle::PHideAll );
00687 bIsProtected = !m_style->hasProperty( KSpreadStyle::PNotProtected );
00688 }
00689
00690 CellFormatDlg::~CellFormatDlg()
00691 {
00692 delete formatOnlyNegSignedPixmap;
00693 delete formatRedOnlyNegSignedPixmap;
00694 delete formatRedNeverSignedPixmap;
00695 delete formatAlwaysSignedPixmap;
00696 delete formatRedAlwaysSignedPixmap;
00697 }
00698
00699 void CellFormatDlg::initMembers()
00700 {
00701 formatOnlyNegSignedPixmap = 0L;
00702 formatRedOnlyNegSignedPixmap = 0L;
00703 formatRedNeverSignedPixmap = 0L;
00704 formatAlwaysSignedPixmap = 0L;
00705 formatRedAlwaysSignedPixmap = 0L;
00706
00707
00708 for ( int i = 0; i < BorderType_END; ++i )
00709 {
00710 borders[i].bStyle = true;
00711 borders[i].bColor = true;
00712 }
00713 bFloatFormat = true;
00714 bFloatColor = true;
00715 bTextColor = true;
00716 bBgColor = true;
00717 bTextFontFamily = true;
00718 bTextFontSize = true;
00719 bTextFontBold = true;
00720 bTextFontItalic = true;
00721 bStrike = true;
00722 bUnderline = true;
00723 bTextRotation = true;
00724 bFormatType = true;
00725 bCurrency = true;
00726 bDontPrintText = false;
00727 bHideFormula = false;
00728 bHideAll = false;
00729 bIsProtected = true;
00730
00731 cCurrency.symbol = locale()->currencySymbol();
00732 cCurrency.type = 0;
00733 }
00734
00735 bool CellFormatDlg::checkCircle( QString const & name, QString const & parent )
00736 {
00737 return m_styleManager->checkCircle( name, parent );
00738 }
00739
00740 void CellFormatDlg::checkBorderRight(KSpreadFormat *obj,int x,int y)
00741 {
00742 if ( borders[BorderType_Right].style != obj->rightBorderStyle( x, y ) ||
00743 borders[BorderType_Right].width != obj->rightBorderWidth( x, y ) )
00744 borders[BorderType_Right].bStyle = false;
00745 if ( borders[BorderType_Right].color != obj->rightBorderColor( x, y ) )
00746 borders[BorderType_Right].bColor = false;
00747 }
00748
00749 void CellFormatDlg::checkBorderLeft(KSpreadFormat *obj,int x,int y)
00750 {
00751 if ( borders[BorderType_Left].style != obj->leftBorderStyle( x, y ) ||
00752 borders[BorderType_Left].width != obj->leftBorderWidth( x, y ) )
00753 borders[BorderType_Left].bStyle = false;
00754 if ( borders[BorderType_Left].color != obj->leftBorderColor( x, y ) )
00755 borders[BorderType_Left].bColor = false;
00756 }
00757
00758 void CellFormatDlg::checkBorderTop(KSpreadFormat *obj,int x,int y)
00759 {
00760 if ( borders[BorderType_Top].style != obj->topBorderStyle( x, y ) ||
00761 borders[BorderType_Top].width != obj->topBorderWidth( x, y ) )
00762 borders[BorderType_Top].bStyle = false;
00763 if ( borders[BorderType_Top].color != obj->topBorderColor( x, y ) )
00764 borders[BorderType_Top].bColor = false;
00765 }
00766
00767 void CellFormatDlg::checkBorderBottom(KSpreadFormat *obj,int x,int y)
00768 {
00769 if ( borders[BorderType_Bottom].style != obj->bottomBorderStyle( x, y ) ||
00770 borders[BorderType_Bottom].width != obj->bottomBorderWidth( x, y ) )
00771 borders[BorderType_Bottom].bStyle = false;
00772 if ( borders[BorderType_Bottom].color != obj->bottomBorderColor( x, y ) )
00773 borders[BorderType_Bottom].bColor = false;
00774 }
00775
00776 void CellFormatDlg::checkBorderVertical(KSpreadFormat *obj,int x,int y)
00777 {
00778 if (borders[BorderType_Vertical].style != obj->leftBorderStyle( x, y ) ||
00779 borders[BorderType_Vertical].width != obj->leftBorderWidth( x, y ))
00780 borders[BorderType_Vertical].bStyle = false;
00781 if ( borders[BorderType_Vertical].color != obj->leftBorderColor( x, y ) )
00782 borders[BorderType_Vertical].bColor = false;
00783 }
00784
00785 void CellFormatDlg::checkBorderHorizontal(KSpreadFormat *obj,int x,int y)
00786 {
00787 if ( borders[BorderType_Horizontal].style != obj->topBorderStyle( x, y ) ||
00788 borders[BorderType_Horizontal].width != obj->topBorderWidth( x, y ) )
00789 borders[BorderType_Horizontal].bStyle = false;
00790 if ( borders[BorderType_Horizontal].color != obj->topBorderColor( x, y ) )
00791 borders[BorderType_Horizontal].bColor = false;
00792 }
00793
00794
00795 void CellFormatDlg::initParameters(KSpreadFormat *obj,int x,int y)
00796 {
00797 if (borders[BorderType_FallingDiagonal].style != obj->fallDiagonalStyle( x, y ))
00798 borders[BorderType_FallingDiagonal].bStyle = false;
00799 if (borders[BorderType_FallingDiagonal].width != obj->fallDiagonalWidth( x, y ))
00800 borders[BorderType_FallingDiagonal].bStyle = false;
00801 if (borders[BorderType_FallingDiagonal].color != obj->fallDiagonalColor( x, y ))
00802 borders[BorderType_FallingDiagonal].bColor = false;
00803
00804 if (borders[BorderType_RisingDiagonal].style != obj->goUpDiagonalStyle( x, y ))
00805 borders[BorderType_RisingDiagonal].bStyle = false;
00806 if (borders[BorderType_RisingDiagonal].width != obj->goUpDiagonalWidth( x, y ))
00807 borders[BorderType_RisingDiagonal].bStyle = false;
00808 if (borders[BorderType_RisingDiagonal].color != obj->goUpDiagonalColor( x, y ))
00809 borders[BorderType_RisingDiagonal].bColor = false;
00810 if ( strike != obj->textFontStrike( x, y ) )
00811 bStrike = false;
00812 if ( underline != obj->textFontUnderline( x, y ) )
00813 bUnderline = false;
00814 if ( prefix != obj->prefix( x, y ) )
00815 prefix = QString::null;
00816 if ( postfix != obj->postfix( x, y ) )
00817 postfix = QString::null;
00818 if ( floatFormat != obj->floatFormat( x, y ) )
00819 bFloatFormat = false;
00820 if ( floatColor != obj->floatColor( x, y ) )
00821 bFloatColor = false;
00822 if ( textColor != obj->textColor( x, y ) )
00823 bTextColor = false;
00824 if ( textFontFamily != obj->textFontFamily( x, y ) )
00825 bTextFontFamily = false;
00826 if ( textFontSize != obj->textFontSize( x, y ) )
00827 bTextFontSize = false;
00828 if ( textFontBold != obj->textFontBold( x, y ) )
00829 bTextFontBold = false;
00830 if ( textFontItalic != obj->textFontItalic( x, y ) )
00831 bTextFontItalic = false;
00832 if ( bgColor != obj->bgColor( x, y ) )
00833 bBgColor = false;
00834 if ( textRotation != obj->getAngle(left, top) )
00835 bTextRotation = false;
00836 if ( formatType != obj->getFormatType(left, top) )
00837 bFormatType = false;
00838 if ( bMultiRow != obj->multiRow( left, top ) )
00839 bMultiRow = false;
00840 if ( bVerticalText!=obj->verticalText( left, top ) )
00841 bVerticalText = false;
00842 if ( bDontPrintText!=obj->getDontprintText( left, top ) )
00843 bDontPrintText= false;
00844
00845 KSpreadCell::Currency cur;
00846 if (!obj->currencyInfo(cur))
00847 bCurrency = false;
00848 else
00849 if (cur.symbol != cCurrency.symbol)
00850 bCurrency = false;
00851 }
00852
00853 void CellFormatDlg::init()
00854 {
00855 QColorGroup colorGroup = QApplication::palette().active();
00856
00857
00858 if ( formatOnlyNegSignedPixmap == 0L )
00859 {
00860 QColor black = colorGroup.text();
00861 formatOnlyNegSignedPixmap = paintFormatPixmap( "123.456", black, "-123.456", black );
00862 formatRedOnlyNegSignedPixmap = paintFormatPixmap( "123.456", black, "-123.456", Qt::red );
00863 formatRedNeverSignedPixmap = paintFormatPixmap( "123.456", black, "123.456", Qt::red );
00864 formatAlwaysSignedPixmap = paintFormatPixmap( "+123.456", black, "-123.456", black );
00865 formatRedAlwaysSignedPixmap = paintFormatPixmap( "+123.456", black, "-123.456", Qt::red );
00866 }
00867
00868 tab = new QTabDialog( (QWidget*)m_pView, 0L, true );
00869 tab->setGeometry( tab->x(), tab->y(), 420, 400 );
00870
00871 if ( m_style )
00872 {
00873 generalPage = new GeneralTab( tab, this );
00874 tab->addTab( generalPage, i18n( "&General" ) );
00875 }
00876
00877 floatPage = new CellFormatPageFloat( tab, this );
00878 tab->addTab( floatPage, i18n("&Data Format") );
00879
00880 fontPage = new CellFormatPageFont( tab, this );
00881 tab->addTab( fontPage, i18n("&Text") );
00882
00883
00884
00885
00886 positionPage = new CellFormatPagePosition( tab, this);
00887 tab->addTab( positionPage, i18n("&Position") );
00888
00889 borderPage = new CellFormatPageBorder( tab, this );
00890 tab->addTab( borderPage, i18n("&Border") );
00891
00892 patternPage=new CellFormatPagePattern(tab,this);
00893 tab->addTab( patternPage,i18n("Back&ground"));
00894
00895 protectPage = new CellFormatPageProtection( tab, this );
00896 tab->addTab( protectPage, i18n("&Cell Protection") );
00897
00898 tab->setCancelButton( i18n( "&Cancel" ) );
00899 tab->setOkButton( i18n( "&OK" ) );
00900
00901 tab->setCaption( i18n( "Cell Format" ) );
00902
00903 connect( tab, SIGNAL( applyButtonPressed() ), this, SLOT( slotApply() ) );
00904
00905 tab->exec();
00906 }
00907
00908 QPixmap * CellFormatDlg::paintFormatPixmap( const char * _string1, const QColor & _color1,
00909 const char *_string2, const QColor & _color2 )
00910 {
00911 QPixmap * pixmap = new QPixmap( 150, 14 );
00912
00913 QPainter painter;
00914 painter.begin( pixmap );
00915 painter.fillRect( 0, 0, 150, 14, QApplication::palette().active().base() );
00916 painter.setPen( _color1 );
00917 painter.drawText( 2, 11, _string1 );
00918 painter.setPen( _color2 );
00919 painter.drawText( 75, 11, _string2 );
00920 painter.end();
00921
00922 QBitmap bm( pixmap->size() );
00923 bm.fill( color0 );
00924 painter.begin( &bm );
00925 painter.setPen( color1 );
00926 painter.drawText( 2, 11, _string1 );
00927 painter.drawText( 75, 11, _string2 );
00928 painter.end();
00929 pixmap->setMask( bm );
00930
00931 return pixmap;
00932 }
00933
00934 int CellFormatDlg::exec()
00935 {
00936 return ( tab->exec() );
00937 }
00938
00939 void CellFormatDlg::applyStyle()
00940 {
00941 generalPage->apply( m_style );
00942
00943 borderPage->applyOutline();
00944 floatPage->apply( m_style );
00945
00946 fontPage->apply( m_style );
00947 positionPage->apply( m_style );
00948 patternPage->apply( m_style );
00949 protectPage->apply( m_style );
00950 }
00951
00952 void CellFormatDlg::slotApply()
00953 {
00954 if ( m_style )
00955 {
00956 applyStyle();
00957 return;
00958 }
00959
00960 m_pView->doc()->emitBeginOperation( false );
00961 KSpreadCell * cell = 0;
00962
00963 KSpreadMacroUndoAction * macroUndo = new KSpreadMacroUndoAction( m_doc, i18n("Change Format") );
00964
00965 if ( isMerged != positionPage->getMergedCellState() )
00966 {
00967 if ( positionPage->getMergedCellState() )
00968 {
00969 KSpreadCell * obj = m_sheet->nonDefaultCell( left, top );
00970
00971 KSpreadUndoMergedCell * undo = new KSpreadUndoMergedCell( m_doc, m_sheet, left,
00972 top, obj->extraXCells(), obj->extraYCells() );
00973 macroUndo->addCommand( undo );
00974
00975
00976 m_sheet->mergeCells( m_pView->selection() );
00977 right = left;
00978 bottom = top;
00979 }
00980 else
00981 {
00982
00983 KSpreadCell * obj = m_sheet->nonDefaultCell( left, top );
00984 right = obj->extraXCells() + left;
00985 bottom = obj->extraYCells() + top;
00986
00987 KSpreadUndoMergedCell * undo = new KSpreadUndoMergedCell( m_doc, m_sheet, left,
00988 top, obj->extraXCells(), obj->extraYCells() );
00989 macroUndo->addCommand(undo);
00990
00991 m_sheet->dissociateCell(QPoint(left,top));
00992 }
00993 }
00994
00995
00996 if ( !m_doc->undoLocked() )
00997 {
00998 QRect rect;
00999
01000
01001
01002 if ( (!isRowSelected ) && ( !isColumnSelected ) )
01003 rect.setCoords( left, top, right + 1, bottom + 1 );
01004 else if ( isRowSelected )
01005 rect.setCoords( left, top, right, bottom + 1 );
01006 else if ( isColumnSelected )
01007 {
01008
01009 RowFormat * rw = m_sheet->firstRow();
01010 for ( ; rw; rw = rw->next() )
01011 {
01012 if ( !rw->isDefault() )
01013 {
01014 for ( int i = left; i <= right; ++i )
01015 {
01016 cell = m_sheet->nonDefaultCell( i, rw->row() );
01017 }
01018 }
01019 }
01020 rect.setCoords( left, top, right + 1, bottom );
01021 }
01022
01023 QString title = i18n( "Change Format" );
01024 KSpreadUndoCellFormat * undo = new KSpreadUndoCellFormat( m_doc, m_sheet, rect, title );
01025
01026 macroUndo->addCommand( undo );
01027
01028
01029
01030
01031
01032
01033
01034
01035 }
01036 borderPage->applyOutline();
01037
01038 if ( ( !isRowSelected ) && ( !isColumnSelected ) )
01039 {
01040 for ( int x = left; x <= right; x++ )
01041 for ( int y = top; y <= bottom; y++ )
01042 {
01043 KSpreadCell *obj = m_sheet->nonDefaultCell( x, y );
01044 if ( !obj->isObscuringForced() )
01045 {
01046 floatPage->apply( obj );
01047
01048 fontPage->apply( obj );
01049 positionPage->apply( obj );
01050 patternPage->apply(obj);
01051 protectPage->apply( obj );
01052 }
01053 }
01054
01055
01056 if ( int( positionPage->getSizeHeight() ) != int( heightSize )
01057 || int( positionPage->getSizeWidth() ) != int( widthSize ) )
01058 {
01059 if ( !m_doc->undoLocked() )
01060 {
01061 QRect rect;
01062 rect.setCoords( left, top, right , bottom );
01063 KSpreadUndoResizeColRow *undo2 = new KSpreadUndoResizeColRow( m_doc, m_sheet , rect );
01064
01065 macroUndo->addCommand( undo2 );
01066 }
01067 }
01068 if ( int( positionPage->getSizeHeight() ) != int( heightSize ) )
01069 {
01070 for ( int x = top; x <= bottom; x++ ) // The loop seems to be doubled, already done in resizeRow: Philipp -> fixme
01071 m_pView->vBorderWidget()->resizeRow( positionPage->getSizeHeight(), x, false );
01072
01073 }
01074 if ( int( positionPage->getSizeWidth() ) != int( widthSize ) )
01075
01076 {
01077 for ( int x = left; x <= right; x++ )
01078 m_pView->hBorderWidget()->resizeColumn( positionPage->getSizeWidth(), x, false );
01079 }
01080 }
01081 else if ( isRowSelected )
01082 {
01083 for ( int i = top; i <= bottom; i++ )
01084 {
01085 RowFormat * rw = m_sheet->nonDefaultRowFormat( i );
01086 floatPage->apply( rw );
01087 fontPage->apply( rw );
01088 positionPage->apply( rw );
01089 patternPage->apply( rw );
01090 protectPage->apply( rw );
01091 }
01092
01093 if ( int( positionPage->getSizeHeight() ) != int( heightSize ) )
01094 {
01095 if ( !m_doc->undoLocked())
01096 {
01097 QRect rect;
01098 rect.setCoords( left, top, right, bottom );
01099 KSpreadUndoResizeColRow * undo2 = new KSpreadUndoResizeColRow( m_doc, m_sheet , rect );
01100
01101 macroUndo->addCommand(undo2);
01102 }
01103 for ( int x = top; x <= bottom; x++ ) // The loop seems to be doubled, already done in resizeRow: Philipp -> fixme
01104 m_pView->vBorderWidget()->resizeRow( positionPage->getSizeHeight(), x, false );
01105 }
01106 }
01107 else if ( isColumnSelected )
01108 {
01109 for ( int i = left; i <= right; ++i )
01110 {
01111 ColumnFormat * cl = m_sheet->nonDefaultColumnFormat( i );
01112 floatPage->apply( cl );
01113 fontPage->apply( cl );
01114 positionPage->apply( cl );
01115 patternPage->apply( cl );
01116 protectPage->apply( cl );
01117 }
01118
01119
01120 if ( int( positionPage->getSizeWidth() ) != int( widthSize ) )
01121 {
01122 if ( !m_doc->undoLocked())
01123 {
01124 QRect rect;
01125 rect.setCoords( left, top, right , bottom );
01126 KSpreadUndoResizeColRow * undo2 = new KSpreadUndoResizeColRow( m_doc, m_sheet , rect );
01127
01128 macroUndo->addCommand(undo2);
01129 }
01130 for ( int x = left; x <= right; x++ ) // The loop seems to be doubled, already done in resizeColumn: Philipp -> fixme
01131 m_pView->hBorderWidget()->resizeColumn(positionPage->getSizeWidth(), x, false );
01132 }
01133 }
01134
01135 if ( !m_doc->undoLocked())
01136 m_doc->addCommand( macroUndo );
01137
01138
01139 QRect r;
01140 r.setCoords( left, top, right, bottom );
01141 m_pView->doc()->setModified( true );
01142
01143 m_pView->updateEditWidget();
01144 m_pView->slotUpdateView( m_sheet, r );
01145 }
01146
01147
01148 CellFormatPageFloat::CellFormatPageFloat( QWidget* parent, CellFormatDlg *_dlg )
01149 : QWidget ( parent ),
01150 dlg( _dlg )
01151 {
01152 QVBoxLayout* layout = new QVBoxLayout( this, 6,10 );
01153
01154 QButtonGroup *grp = new QButtonGroup( i18n("Format"),this);
01155 QGridLayout *grid = new QGridLayout(grp,11,2,KDialog::marginHint(), KDialog::spacingHint());
01156
01157 int fHeight = grp->fontMetrics().height();
01158 grid->addRowSpacing( 0, fHeight/2 );
01159
01160 grp->setRadioButtonExclusive( true );
01161 generic=new QRadioButton(i18n("Generic"),grp);
01162 grid->addWidget(generic,1,0);
01163
01164 number=new QRadioButton(i18n("Number"),grp);
01165 grid->addWidget(number,2,0);
01166
01167 percent=new QRadioButton(i18n("Percent"),grp);
01168 grid->addWidget(percent,3,0);
01169
01170 money=new QRadioButton(i18n("Money"),grp);
01171 grid->addWidget(money,4,0);
01172
01173 scientific=new QRadioButton(i18n("Scientific"),grp);
01174 grid->addWidget(scientific,5,0);
01175
01176 fraction=new QRadioButton(i18n("Fraction"),grp);
01177 grid->addWidget(fraction,6,0);
01178
01179 date=new QRadioButton(i18n("Date format"),grp);
01180 grid->addWidget(date,7,0);
01181
01182 time=new QRadioButton(i18n("Time format"),grp);
01183 grid->addWidget(time,8,0);
01184
01185 textFormat=new QRadioButton(i18n("Text"),grp);
01186 grid->addWidget(textFormat,9,0);
01187
01188 customFormat=new QRadioButton(i18n("Custom"),grp);
01189 grid->addWidget(customFormat,10,0);
01190 customFormat->setEnabled( false );
01191
01192 QGroupBox *box2 = new QGroupBox( grp, "Box");
01193 box2->setTitle(i18n("Preview"));
01194 QGridLayout *grid3 = new QGridLayout(box2,1,3,KDialog::marginHint(), KDialog::spacingHint());
01195
01196 exampleLabel=new QLabel(box2);
01197 grid3->addWidget(exampleLabel,0,1);
01198
01199 grid->addMultiCellWidget(box2,9,10,1,1);
01200
01201 customFormatEdit = new QLineEdit( grp );
01202 grid->addMultiCellWidget( customFormatEdit, 1, 1, 1, 1 );
01203 customFormatEdit->setHidden( true );
01204
01205 listFormat=new QListBox(grp);
01206 grid->addMultiCellWidget(listFormat,2,7,1,1);
01207 layout->addWidget(grp);
01208
01209
01210
01211 QGroupBox *box = new QGroupBox( this, "Box");
01212
01213 grid = new QGridLayout(box,3,4,KDialog::marginHint(), KDialog::spacingHint());
01214
01215 postfix = new QLineEdit( box, "LineEdit_1" );
01216 grid->addWidget(postfix,2,1);
01217 precision = new KIntNumInput( dlg->precision, box, 10 );
01218 precision->setSpecialValueText(i18n("variable"));
01219 precision->setRange(-1,10,1,false);
01220
01221 grid->addWidget(precision,1,1);
01222
01223 prefix = new QLineEdit( box, "LineEdit_3" );
01224 grid->addWidget(prefix,0,1);
01225
01226 format = new QComboBox( box, "ListBox_1" );
01227 grid->addWidget(format,0,3);
01228
01229 QLabel* tmpQLabel;
01230 tmpQLabel = new QLabel( box, "Label_1" );
01231 grid->addWidget(tmpQLabel,2,0);
01232 tmpQLabel->setText( i18n("Postfix:") );
01233
01234 if ( dlg->postfix.isNull() )
01235 postfix->setText( "########" );
01236 else
01237 postfix->setText( dlg->postfix );
01238
01239 tmpQLabel = new QLabel( box, "Label_2" );
01240 grid->addWidget(tmpQLabel,0,0);
01241 tmpQLabel->setText( i18n("Prefix:") );
01242
01243 tmpQLabel = new QLabel( box, "Label_3" );
01244 grid->addWidget(tmpQLabel,1,0);
01245 tmpQLabel->setText( i18n("Precision:") );
01246
01247 if ( dlg->prefix.isNull() )
01248 prefix->setText( "########" );
01249 else
01250 prefix->setText( dlg->prefix );
01251
01252
01253 format->insertItem( *_dlg->formatOnlyNegSignedPixmap, 0 );
01254 format->insertItem( *_dlg->formatRedOnlyNegSignedPixmap, 1 );
01255 format->insertItem( *_dlg->formatRedNeverSignedPixmap, 2 );
01256 format->insertItem( *_dlg->formatAlwaysSignedPixmap, 3 );
01257 format->insertItem( *_dlg->formatRedAlwaysSignedPixmap, 4 );
01258
01259 tmpQLabel = new QLabel( box, "Label_4" );
01260 grid->addWidget(tmpQLabel, 0, 2);
01261 tmpQLabel->setText( i18n("Format:") );
01262
01263 currencyLabel = new QLabel( box, "LabelCurrency" );
01264 grid->addWidget(currencyLabel, 1, 2);
01265 currencyLabel->setText( i18n("Currency:") );
01266
01267 currency = new QComboBox( box, "ComboCurrency" );
01268 grid->addWidget(currency, 1, 3);
01269
01270 currency->insertItem( i18n("Automatic") );
01271
01272 int index = 2;
01273 bool ok = true;
01274 QString text;
01275
01276 while ( ok )
01277 {
01278 text = KSpreadCurrency::getChooseString( index, ok );
01279 if ( ok )
01280 {
01281 currency->insertItem( text );
01282 }
01283 else
01284 {
01285 break;
01286 }
01287
01288 ++index;
01289 }
01290
01291 currency->setCurrentItem( 0 );
01292 currency->hide();
01293 currencyLabel->hide();
01294
01295 if ( !dlg->bFloatFormat || !dlg->bFloatColor )
01296 format->setCurrentItem( 5 );
01297 else if ( dlg->floatFormat == KSpreadCell::OnlyNegSigned && dlg->floatColor == KSpreadCell::AllBlack )
01298 format->setCurrentItem( 0 );
01299 else if ( dlg->floatFormat == KSpreadCell::OnlyNegSigned && dlg->floatColor == KSpreadCell::NegRed )
01300 format->setCurrentItem( 1 );
01301 else if ( dlg->floatFormat == KSpreadCell::AlwaysUnsigned && dlg->floatColor == KSpreadCell::NegRed )
01302 format->setCurrentItem( 2 );
01303 else if ( dlg->floatFormat == KSpreadCell::AlwaysSigned && dlg->floatColor == KSpreadCell::AllBlack )
01304 format->setCurrentItem( 3 );
01305 else if ( dlg->floatFormat == KSpreadCell::AlwaysSigned && dlg->floatColor == KSpreadCell::NegRed )
01306 format->setCurrentItem( 4 );
01307 layout->addWidget(box);
01308
01309 cellFormatType=dlg->formatType;
01310 newFormatType = cellFormatType;
01311
01312 if (!cellFormatType)
01313 generic->setChecked(true);
01314 else
01315 {
01316 if (cellFormatType==Number_format)
01317 number->setChecked(true);
01318 else if (cellFormatType==Percentage_format)
01319 percent->setChecked(true);
01320 else if (cellFormatType==Money_format)
01321 {
01322 money->setChecked(true);
01323 currencyLabel->show();
01324 currency->show();
01325 if (dlg->bCurrency)
01326 {
01327 QString tmp;
01328 if (dlg->cCurrency.type != 1)
01329 {
01330 KSpreadCurrency curr(dlg->cCurrency.type);
01331 bool ok = true;
01332 tmp = KSpreadCurrency::getChooseString(dlg->cCurrency.type, ok);
01333 if ( !ok )
01334 tmp = dlg->cCurrency.symbol;
01335 }
01336 else
01337 tmp = dlg->cCurrency.symbol;
01338 currency->setCurrentText( tmp );
01339 }
01340 }
01341 else if ( cellFormatType == Scientific_format )
01342 scientific->setChecked(true);
01343 else if ( formatIsDate (cellFormatType) )
01344 date->setChecked(true);
01345 else if ( formatIsTime (cellFormatType) )
01346 time->setChecked(true);
01347 else if ( formatIsFraction (cellFormatType) )
01348 fraction->setChecked(true);
01349 else if (cellFormatType == Text_format)
01350 textFormat->setChecked(true);
01351 else if (cellFormatType == Custom_format)
01352 customFormat->setChecked(true);
01353 }
01354
01355 connect(generic,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01356 connect(fraction,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01357 connect(money,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01358 connect(date,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01359 connect(scientific,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01360 connect(number,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01361 connect(percent,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01362 connect(time,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
01363 connect(textFormat,SIGNAL(clicked()),this,SLOT(slotChangeState()));
01364 connect(customFormat,SIGNAL(clicked()),this,SLOT(slotChangeState()));
01365
01366 connect(listFormat,SIGNAL(selectionChanged ()),this,SLOT(makeformat()));
01367 connect(precision,SIGNAL(valueChanged(int)),this,SLOT(slotChangeValue(int)));
01368 connect(prefix,SIGNAL(textChanged ( const QString & ) ),this,SLOT(makeformat()));
01369 connect(postfix,SIGNAL(textChanged ( const QString & ) ),this,SLOT(makeformat()));
01370 connect(currency,SIGNAL(activated ( const QString & ) ),this, SLOT(currencyChanged(const QString &)));
01371 connect(format,SIGNAL(activated ( int ) ),this,SLOT(formatChanged(int)));
01372 slotChangeState();
01373 m_bFormatColorChanged=false;
01374 m_bFormatTypeChanged=false;
01375 this->resize( 400, 400 );
01376 }
01377
01378 void CellFormatPageFloat::formatChanged(int)
01379 {
01380 m_bFormatColorChanged=true;
01381 }
01382
01383 void CellFormatPageFloat::slotChangeValue(int)
01384 {
01385 makeformat();
01386 }
01387 void CellFormatPageFloat::slotChangeState()
01388 {
01389 QStringList list;
01390 listFormat->clear();
01391 currency->hide();
01392 currencyLabel->hide();
01393
01394
01395 precision->setEnabled(true);
01396 prefix->setEnabled(true);
01397 postfix->setEnabled(true);
01398 format->setEnabled(true);
01399
01400 if (generic->isChecked() || number->isChecked() || percent->isChecked() ||
01401 scientific->isChecked() || textFormat->isChecked())
01402 listFormat->setEnabled(false);
01403 else if (money->isChecked())
01404 {
01405 listFormat->setEnabled(false);
01406 precision->setValue(2);
01407 currency->show();
01408 currencyLabel->show();
01409 }
01410 else if (date->isChecked())
01411 {
01412 format->setEnabled(false);
01413 precision->setEnabled(false);
01414 prefix->setEnabled(false);
01415 postfix->setEnabled(false);
01416 listFormat->setEnabled(true);
01417 init();
01418 }
01419 else if (fraction->isChecked())
01420 {
01421 precision->setEnabled(false);
01422 listFormat->setEnabled(true);
01423 list+=i18n("Halves 1/2");
01424 list+=i18n("Quarters 1/4");
01425 list+=i18n("Eighths 1/8");
01426 list+=i18n("Sixteenths 1/16");
01427 list+=i18n("Tenths 1/10");
01428 list+=i18n("Hundredths 1/100");
01429 list+=i18n("One digit 5/9");
01430 list+=i18n("Two digits 15/22");
01431 list+=i18n("Three digits 153/652");
01432 listFormat->insertStringList(list);
01433 if (cellFormatType == fraction_half)
01434 listFormat->setCurrentItem(0);
01435 else if (cellFormatType == fraction_quarter)
01436 listFormat->setCurrentItem(1);
01437 else if (cellFormatType == fraction_eighth )
01438 listFormat->setCurrentItem(2);
01439 else if (cellFormatType == fraction_sixteenth )
01440 listFormat->setCurrentItem(3);
01441 else if (cellFormatType == fraction_tenth )
01442 listFormat->setCurrentItem(4);
01443 else if (cellFormatType == fraction_hundredth )
01444 listFormat->setCurrentItem(5);
01445 else if (cellFormatType == fraction_one_digit )
01446 listFormat->setCurrentItem(6);
01447 else if (cellFormatType == fraction_two_digits )
01448 listFormat->setCurrentItem(7);
01449 else if (cellFormatType == fraction_three_digits )
01450 listFormat->setCurrentItem(8);
01451 else
01452 listFormat->setCurrentItem(0);
01453 }
01454 else if (time->isChecked())
01455 {
01456 precision->setEnabled(false);
01457 prefix->setEnabled(false);
01458 postfix->setEnabled(false);
01459 format->setEnabled(false);
01460 listFormat->setEnabled(true);
01461
01462
01463 list+=i18n("System: ")+dlg->locale()->formatTime(QTime::currentTime(),false);
01464 list+=i18n("System: ")+dlg->locale()->formatTime(QTime::currentTime(),true);
01465 QDateTime tmpTime (QDate (1, 1, 1900), QTime (10, 35, 25));
01466
01467
01468 KSpread::ValueFormatter *fmt = dlg->getDoc()->formatter();
01469 list+= fmt->timeFormat(tmpTime, Time_format1);
01470 list+= fmt->timeFormat(tmpTime, Time_format2);
01471 list+= fmt->timeFormat(tmpTime, Time_format3);
01472 list+= fmt->timeFormat(tmpTime, Time_format4);
01473 list+= fmt->timeFormat(tmpTime, Time_format5);
01474 list+= ( fmt->timeFormat(tmpTime, Time_format6) + i18n(" (=[mm]::ss)") );
01475 list+= ( fmt->timeFormat(tmpTime, Time_format7) + i18n(" (=[hh]::mm::ss)") );
01476 list+= ( fmt->timeFormat(tmpTime, Time_format8) + i18n(" (=[hh]::mm)") );
01477 listFormat->insertStringList(list);
01478
01479 if ( cellFormatType == Time_format )
01480 listFormat->setCurrentItem(0);
01481 else if (cellFormatType == SecondeTime_format)
01482 listFormat->setCurrentItem(1);
01483 else if (cellFormatType == Time_format1)
01484 listFormat->setCurrentItem(2);
01485 else if (cellFormatType == Time_format2)
01486 listFormat->setCurrentItem(3);
01487 else if (cellFormatType == Time_format3)
01488 listFormat->setCurrentItem(4);
01489 else if (cellFormatType == Time_format4)
01490 listFormat->setCurrentItem(5);
01491 else if (cellFormatType == Time_format5)
01492 listFormat->setCurrentItem(6);
01493 else if (cellFormatType == Time_format6)
01494 listFormat->setCurrentItem(7);
01495 else if (cellFormatType == Time_format7)
01496 listFormat->setCurrentItem(8);
01497 else if (cellFormatType == Time_format8)
01498 listFormat->setCurrentItem(9);
01499 else
01500 listFormat->setCurrentItem(0);
01501 }
01502
01503 if (customFormat->isChecked())
01504 {
01505 customFormatEdit->setHidden( false );
01506 precision->setEnabled(false);
01507 prefix->setEnabled(false);
01508 postfix->setEnabled(false);
01509 format->setEnabled(false);
01510 listFormat->setEnabled(true);
01511 }
01512 else
01513 customFormatEdit->setHidden( true );
01514
01515 m_bFormatTypeChanged=true;
01516
01517 makeformat();
01518 }
01519
01520 void CellFormatPageFloat::init()
01521 {
01522 QStringList list;
01523 QString tmp;
01524 QString tmp2;
01525 QDate tmpDate( 2000,2,18);
01526 list+=i18n("System: ")+dlg->locale()->formatDate (QDate::currentDate(), true);
01527 list+=i18n("System: ")+dlg->locale()->formatDate (QDate::currentDate(), false);
01528
01529 KSpread::ValueFormatter *fmt = dlg->getDoc()->formatter();
01530
01531
01532 list+=fmt->dateFormat( tmpDate, date_format1);
01533
01534 list+=fmt->dateFormat( tmpDate, date_format2);
01535
01536 list+=fmt->dateFormat( tmpDate, date_format3);
01537
01538 list+=fmt->dateFormat( tmpDate, date_format4);
01539
01540 list+=fmt->dateFormat( tmpDate, date_format5);
01541
01542 list+=fmt->dateFormat( tmpDate, date_format6);
01543
01544 list+=fmt->dateFormat( tmpDate, date_format7);
01545
01546 list+=fmt->dateFormat( tmpDate, date_format8);
01547
01548 list+=fmt->dateFormat( tmpDate, date_format9);
01549
01550 list+=fmt->dateFormat( tmpDate, date_format10);
01551
01552 list+=fmt->dateFormat( tmpDate, date_format11);
01553
01554 list+=fmt->dateFormat( tmpDate, date_format12);
01555
01556 list+=fmt->dateFormat( tmpDate, date_format13);
01557
01558 list+=fmt->dateFormat( tmpDate, date_format14);
01559
01560 list+=fmt->dateFormat( tmpDate, date_format15);
01561
01562 list+=fmt->dateFormat( tmpDate, date_format16);
01563
01564 list+=fmt->dateFormat( tmpDate, date_format17);
01565 list+=fmt->dateFormat( tmpDate, date_format18);
01566 list+=fmt->dateFormat( tmpDate, date_format19);
01567 list+=fmt->dateFormat( tmpDate, date_format20);
01568 list+=fmt->dateFormat( tmpDate, date_format21);
01569 list+=fmt->dateFormat( tmpDate, date_format22);
01570 list+=fmt->dateFormat( tmpDate, date_format23);
01571 list+=fmt->dateFormat( tmpDate, date_format24);
01572 list+=fmt->dateFormat( tmpDate, date_format25);
01573 list+=fmt->dateFormat( tmpDate, date_format26);
01574
01575 listFormat->insertStringList(list);
01576 if ( cellFormatType == ShortDate_format )
01577 listFormat->setCurrentItem(0);
01578 else if (cellFormatType == TextDate_format)
01579 listFormat->setCurrentItem(1);
01580 else if (cellFormatType == date_format1)
01581 listFormat->setCurrentItem(2);
01582 else if (cellFormatType == date_format2)
01583 listFormat->setCurrentItem(3);
01584 else if (cellFormatType == date_format3)
01585 listFormat->setCurrentItem(4);
01586 else if (cellFormatType == date_format4)
01587 listFormat->setCurrentItem(5);
01588 else if (cellFormatType == date_format5)
01589 listFormat->setCurrentItem(6);
01590 else if (cellFormatType == date_format6)
01591 listFormat->setCurrentItem(7);
01592 else if (cellFormatType == date_format7)
01593 listFormat->setCurrentItem(8);
01594 else if (cellFormatType == date_format8)
01595 listFormat->setCurrentItem(9);
01596 else if (cellFormatType == date_format9)
01597 listFormat->setCurrentItem(10);
01598 else if (cellFormatType == date_format10)
01599 listFormat->setCurrentItem(11);
01600 else if (cellFormatType == date_format11)
01601 listFormat->setCurrentItem(12);
01602 else if (cellFormatType == date_format12)
01603 listFormat->setCurrentItem(13);
01604 else if (cellFormatType == date_format13)
01605 listFormat->setCurrentItem(14);
01606 else if (cellFormatType == date_format14)
01607 listFormat->setCurrentItem(15);
01608 else if (cellFormatType == date_format15)
01609 listFormat->setCurrentItem(16);
01610 else if (cellFormatType == date_format16)
01611 listFormat->setCurrentItem(17);
01612 else if (cellFormatType == date_format17)
01613 listFormat->setCurrentItem(18);
01614 else if (cellFormatType == date_format18)
01615 listFormat->setCurrentItem(19);
01616 else if (cellFormatType == date_format19)
01617 listFormat->setCurrentItem(20);
01618 else if (cellFormatType == date_format20)
01619 listFormat->setCurrentItem(21);
01620 else if (cellFormatType == date_format21)
01621 listFormat->setCurrentItem(22);
01622 else if (cellFormatType == date_format22)
01623 listFormat->setCurrentItem(23);
01624 else if (cellFormatType == date_format23)
01625 listFormat->setCurrentItem(24);
01626 else if (cellFormatType == date_format24)
01627 listFormat->setCurrentItem(25);
01628 else if (cellFormatType == date_format25)
01629 listFormat->setCurrentItem(26);
01630 else if (cellFormatType == date_format26)
01631 listFormat->setCurrentItem(27);
01632 else
01633 listFormat->setCurrentItem(0);
01634
01635 }
01636
01637 void CellFormatPageFloat::currencyChanged(const QString &)
01638 {
01639 int index = currency->currentItem();
01640 if (index > 0)
01641 ++index;
01642 dlg->cCurrency.symbol = KSpreadCurrency::getDisplaySymbol(index);
01643 dlg->cCurrency.type = index;
01644
01645 makeformat();
01646 }
01647
01648 void CellFormatPageFloat::updateFormatType ()
01649 {
01650 if (generic->isChecked())
01651 newFormatType = Generic_format;
01652 else if (number->isChecked())
01653 newFormatType = Number_format;
01654 else if (percent->isChecked())
01655 newFormatType = Percentage_format;
01656 else if (date->isChecked())
01657 {
01658 newFormatType=ShortDate_format;
01659 switch (listFormat->currentItem())
01660 {
01661 case 0: newFormatType=ShortDate_format; break;
01662 case 1: newFormatType=TextDate_format; break;
01663 case 2: newFormatType=date_format1; break;
01664 case 3: newFormatType=date_format2; break;
01665 case 4: newFormatType=date_format3; break;
01666 case 5: newFormatType=date_format4; break;
01667 case 6: newFormatType=date_format5; break;
01668 case 7: newFormatType=date_format6; break;
01669 case 8: newFormatType=date_format7; break;
01670 case 9: newFormatType=date_format8; break;
01671 case 10: newFormatType=date_format9; break;
01672 case 11: newFormatType=date_format10; break;
01673 case 12: newFormatType=date_format11; break;
01674 case 13: newFormatType=date_format12; break;
01675 case 14: newFormatType=date_format13; break;
01676 case 15: newFormatType=date_format14; break;
01677 case 16: newFormatType=date_format15; break;
01678 case 17: newFormatType=date_format16; break;
01679 case 18: newFormatType=date_format17; break;
01680 case 19: newFormatType=date_format18; break;
01681 case 20: newFormatType=date_format19; break;
01682 case 21: newFormatType=date_format20; break;
01683 case 22: newFormatType=date_format21; break;
01684 case 23: newFormatType=date_format22; break;
01685 case 24: newFormatType=date_format23; break;
01686 case 25: newFormatType=date_format24; break;
01687 case 26: newFormatType=date_format25; break;
01688 case 27: newFormatType=date_format26; break;
01689 }
01690 }
01691 else if (money->isChecked())
01692 newFormatType = Money_format;
01693 else if (scientific->isChecked())
01694 newFormatType = Scientific_format;
01695 else if (fraction->isChecked())
01696 {
01697 newFormatType=fraction_half;
01698 switch (listFormat->currentItem())
01699 {
01700 case 0: newFormatType=fraction_half; break;
01701 case 1: newFormatType=fraction_quarter; break;
01702 case 2: newFormatType=fraction_eighth; break;
01703 case 3: newFormatType=fraction_sixteenth; break;
01704 case 4: newFormatType=fraction_tenth; break;
01705 case 5: newFormatType=fraction_hundredth; break;
01706 case 6: newFormatType=fraction_one_digit; break;
01707 case 7: newFormatType=fraction_two_digits; break;
01708 case 8: newFormatType=fraction_three_digits; break;
01709 }
01710 }
01711 else if (time->isChecked())
01712 {
01713 int current = listFormat->currentItem();
01714 newFormatType=Time_format;
01715 switch (listFormat->currentItem())
01716 {
01717 case 0: newFormatType=Time_format; break;
01718 case 1: newFormatType=SecondeTime_format; break;
01719 case 2: newFormatType=Time_format1; break;
01720 case 3: newFormatType=Time_format2; break;
01721 case 4: newFormatType=Time_format3; break;
01722 case 5: newFormatType=Time_format4; break;
01723 case 6: newFormatType=Time_format5; break;
01724 case 7: newFormatType=Time_format6; break;
01725 case 8: newFormatType=Time_format7; break;
01726 case 9: newFormatType=Time_format8; break;
01727 }
01728 }
01729 else if (textFormat->isChecked())
01730 newFormatType = Text_format;
01731 else if (customFormat->isChecked())
01732 newFormatType = Custom_format;
01733 }
01734
01735 void CellFormatPageFloat::makeformat()
01736 {
01737 m_bFormatTypeChanged=true;
01738 QString tmp;
01739
01740 updateFormatType();
01741 KSpread::ValueFormatter *fmt = dlg->getDoc()->formatter();
01742 tmp = fmt->formatText (dlg->value, newFormatType,
01743 precision->value());
01744 if (tmp.length() > 50)
01745 tmp = tmp.left (50);
01746 exampleLabel->setText (tmp);
01747 }
01748
01749 void CellFormatPageFloat::apply( KSpreadCustomStyle * style )
01750 {
01751 if ( postfix->text() != dlg->postfix )
01752 {
01753 if ( postfix->text() != "########" )
01754 {
01755 if ( postfix->isEnabled())
01756 style->changePostfix( postfix->text() );
01757 else
01758 style->changePostfix( "" );
01759 }
01760 }
01761 if ( prefix->text() != dlg->prefix )
01762 {
01763 if ( prefix->text() != "########" )
01764 {
01765 if (prefix->isEnabled())
01766 style->changePrefix( prefix->text() );
01767 else
01768 style->changePrefix( "" );
01769 }
01770 }
01771
01772 if ( dlg->precision != precision->value() )
01773 style->changePrecision( precision->value() );
01774
01775 if ( m_bFormatColorChanged )
01776 {
01777 switch( format->currentItem() )
01778 {
01779 case 0:
01780 style->changeFloatFormat( KSpreadCell::OnlyNegSigned );
01781 style->changeFloatColor( KSpreadCell::AllBlack );
01782 break;
01783 case 1:
01784 style->changeFloatFormat( KSpreadCell::OnlyNegSigned );
01785 style->changeFloatColor( KSpreadCell::NegRed );
01786 break;
01787 case 2:
01788 style->changeFloatFormat( KSpreadCell::AlwaysUnsigned );
01789 style->changeFloatColor( KSpreadCell::NegRed );
01790 break;
01791 case 3:
01792 style->changeFloatFormat( KSpreadCell::AlwaysSigned );
01793 style->changeFloatColor( KSpreadCell::AllBlack );
01794 break;
01795 case 4:
01796 style->changeFloatFormat( KSpreadCell::AlwaysSigned );
01797 style->changeFloatColor( KSpreadCell::NegRed );
01798 break;
01799 }
01800 }
01801 if ( m_bFormatTypeChanged )
01802 {
01803 style->changeFormatType (newFormatType);
01804 if ( money->isChecked() )
01805 {
01806 KSpreadCell::Currency cur;
01807 int index = currency->currentItem();
01808 if (index == 0)
01809 {
01810 if ( currency->currentText() == i18n( "Automatic" ) )
01811 {
01812 cur.symbol = dlg->locale()->currencySymbol();
01813 cur.type = 0;
01814 }
01815 else
01816 {
01817 cur.type = 1;
01818 cur.symbol = currency->currentText();
01819 }
01820 }
01821 else
01822 {
01823 cur.type = ++index;
01824 cur.symbol = KSpreadCurrency::getDisplaySymbol( index );
01825 }
01826
01827 style->changeCurrency( cur );
01828 }
01829 }
01830 }
01831
01832 void CellFormatPageFloat::applyFormat( KSpreadFormat *_obj )
01833 {
01834 if ( postfix->text() != dlg->postfix )
01835 if ( postfix->text() != "########" && postfix->isEnabled())
01836 {
01837
01838 if ( postfix->isEnabled())
01839 _obj->setPostfix( postfix->text() );
01840 else
01841 _obj->setPostfix( "" );
01842 }
01843 if ( prefix->text() != dlg->prefix )
01844 if ( prefix->text() != "########" )
01845 {
01846 if (prefix->isEnabled())
01847 _obj->setPrefix( prefix->text() );
01848 else
01849 _obj->setPrefix( "" );
01850
01851 }
01852
01853 if ( dlg->precision != precision->value() )
01854 _obj->setPrecision( precision->value() );
01855
01856 if (m_bFormatColorChanged)
01857 {
01858 switch( format->currentItem() )
01859 {
01860 case 0:
01861 _obj->setFloatFormat( KSpreadCell::OnlyNegSigned );
01862 _obj->setFloatColor( KSpreadCell::AllBlack );
01863 break;
01864 case 1:
01865 _obj->setFloatFormat( KSpreadCell::OnlyNegSigned );
01866 _obj->setFloatColor( KSpreadCell::NegRed );
01867 break;
01868 case 2:
01869 _obj->setFloatFormat( KSpreadCell::AlwaysUnsigned );
01870 _obj->setFloatColor( KSpreadCell::NegRed );
01871 break;
01872 case 3:
01873 _obj->setFloatFormat( KSpreadCell::AlwaysSigned );
01874 _obj->setFloatColor( KSpreadCell::AllBlack );
01875 break;
01876 case 4:
01877 _obj->setFloatFormat( KSpreadCell::AlwaysSigned );
01878 _obj->setFloatColor( KSpreadCell::NegRed );
01879 break;
01880 }
01881 }
01882 if (m_bFormatTypeChanged)
01883 {
01884 _obj->setFormatType (newFormatType);
01885 if (money->isChecked())
01886 {
01887 KSpreadCell::Currency cur;
01888 int index = currency->currentItem();
01889 if (index == 0)
01890 {
01891 if ( currency->currentText() == i18n( "Automatic" ) )
01892 {
01893 cur.symbol = dlg->locale()->currencySymbol();
01894 cur.type = 0;
01895 }
01896 else
01897 {
01898 cur.type = 1;
01899 cur.symbol = currency->currentText();
01900 }
01901 }
01902 else
01903 {
01904 cur.type = ++index;
01905 cur.symbol = KSpreadCurrency::getDisplaySymbol( index );
01906 }
01907
01908 _obj->setCurrency( cur.type, cur.symbol );
01909 }
01910 }
01911 }
01912
01913 void CellFormatPageFloat::apply( KSpreadCell *_obj )
01914 {
01915 applyFormat(_obj);
01916 }
01917
01918 void CellFormatPageFloat::apply( RowFormat *_obj )
01919 {
01920 KSpreadSheet* sheet = dlg->getSheet();
01921 KSpreadCell* c = NULL;
01922 for (int row = dlg->top; row <= dlg->bottom; row++)
01923 {
01924 for ( c = sheet->getFirstCellRow(row); c != NULL;
01925 c = sheet->getNextCellRight(c->column(), c->row()) )
01926 {
01927 if ( dlg->precision != precision->value() )
01928 {
01929 c->clearProperty(KSpreadCell::PPrecision);
01930 c->clearNoFallBackProperties( KSpreadCell::PPrecision );
01931 }
01932 if ( postfix->text() != dlg->postfix )
01933 {
01934 if ( postfix->text() != "########" )
01935 {
01936 c->clearProperty(KSpreadCell::PPostfix);
01937 c->clearNoFallBackProperties( KSpreadCell::PPostfix );
01938 }
01939 }
01940 if ( prefix->text() != dlg->prefix )
01941 {
01942 if ( postfix->text() != "########" )
01943 {
01944 c->clearProperty(KSpreadCell::PPrefix);
01945 c->clearNoFallBackProperties( KSpreadCell::PPrefix );
01946 }
01947 }
01948 if (m_bFormatColorChanged)
01949 {
01950 c->clearProperty(KSpreadCell::PFloatFormat);
01951 c->clearNoFallBackProperties( KSpreadCell::PFloatFormat );
01952 c->clearProperty(KSpreadCell::PFloatColor);
01953 c->clearNoFallBackProperties( KSpreadCell::PFloatColor );
01954 }
01955 if (m_bFormatTypeChanged)
01956 {
01957 c->clearProperty(KSpreadCell::PFormatType);
01958 c->clearNoFallBackProperties( KSpreadCell::PFormatType );
01959 }
01960 }
01961 }
01962 applyFormat(_obj);
01963 }
01964
01965 void CellFormatPageFloat::apply( ColumnFormat *_obj )
01966 {
01967 KSpreadSheet *sheet = dlg->getSheet();
01968 KSpreadCell* c = NULL;
01969 for (int col = dlg->left; col <= dlg->right; col++)
01970 {
01971 for ( c = sheet->getFirstCellColumn(col); c != NULL;
01972 c = sheet->getNextCellDown(c->column(), c->row()) )
01973 {
01974 if ( dlg->precision != precision->value() )
01975 {
01976 c->clearProperty(KSpreadCell::PPrecision);
01977 c->clearNoFallBackProperties( KSpreadCell::PPrecision );
01978 }
01979 if ( postfix->text() != dlg->postfix )
01980 {
01981 if ( postfix->text() != "########" )
01982 {
01983 c->clearProperty(KSpreadCell::PPostfix);
01984 c->clearNoFallBackProperties( KSpreadCell::PPostfix );
01985 }
01986 }
01987 if ( prefix->text() != dlg->prefix )
01988 {
01989 if ( prefix->text() != "########" )
01990 {
01991 c->clearProperty(KSpreadCell::PPrefix);
01992 c->clearNoFallBackProperties( KSpreadCell::PPrefix );
01993 }
01994 }
01995 if (m_bFormatColorChanged)
01996 {
01997 c->clearProperty(KSpreadCell::PFloatFormat);
01998 c->clearNoFallBackProperties( KSpreadCell::PFloatFormat );
01999 c->clearProperty(KSpreadCell::PFloatColor);
02000 c->clearNoFallBackProperties( KSpreadCell::PFloatColor );
02001 }
02002 if (m_bFormatTypeChanged)
02003 {
02004 c->clearProperty(KSpreadCell::PFormatType);
02005 c->clearNoFallBackProperties( KSpreadCell::PFormatType );
02006 }
02007 }
02008 }
02009 applyFormat(_obj);
02010
02011 RowFormat* rw =dlg->getSheet()->firstRow();
02012 for ( ; rw; rw = rw->next() )
02013 {
02014 if ( !rw->isDefault() &&
02015 (rw->hasProperty(KSpreadCell::PPrecision) ||
02016 rw->hasProperty(KSpreadCell::PPostfix) ||
02017 rw->hasProperty(KSpreadCell::PPrefix) ||
02018 rw->hasProperty(KSpreadCell::PFloatFormat) ||
02019 rw->hasProperty(KSpreadCell::PFloatColor) ||
02020 rw->hasProperty(KSpreadCell::PFormatType) ))
02021 {
02022 for ( int i=dlg->left;i<=dlg->right;i++)
02023 {
02024 KSpreadCell *cell = dlg->getSheet()->nonDefaultCell( i, rw->row() );
02025 applyFormat(cell );
02026 }
02027 }
02028 }
02029 }
02030
02031 CellFormatPageProtection::CellFormatPageProtection( QWidget* parent, CellFormatDlg * _dlg )
02032 : QWidget( parent ),
02033 m_dlg( _dlg )
02034 {
02035 QVBoxLayout * Form1Layout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint(), "Form1Layout");
02036
02037 QGroupBox * groupBox1 = new QGroupBox( 0, Qt::Vertical, i18n( "Protection" ), this, "groupBox1" );
02038 groupBox1->layout()->setSpacing( KDialog::spacingHint() );
02039 groupBox1->layout()->setMargin( KDialog::marginHint() );
02040 QVBoxLayout * groupBox1Layout = new QVBoxLayout( groupBox1->layout() );
02041
02042 m_bIsProtected = new QCheckBox( i18n( "&Protected" ), groupBox1, "m_bIsProtected" );
02043 m_bIsProtected->setChecked( true );
02044 groupBox1Layout->addWidget( m_bIsProtected );
02045
02046 m_bHideFormula = new QCheckBox( i18n( "&Hide formula" ), groupBox1, "m_bHideFormula" );
02047 groupBox1Layout->addWidget( m_bHideFormula );
02048
02049 m_bHideAll = new QCheckBox( i18n( "Hide &all" ), groupBox1, "m_bHideAll" );
02050 groupBox1Layout->addWidget( m_bHideAll );
02051 Form1Layout->addWidget( groupBox1 );
02052
02053 QGroupBox * groupBox2 = new QGroupBox( 0, Qt::Vertical, i18n( "Printing" ), this, "groupBox2" );
02054 groupBox2->layout()->setSpacing( KDialog::spacingHint() );
02055 groupBox2->layout()->setMargin( KDialog::marginHint() );
02056 QVBoxLayout * groupBox2Layout = new QVBoxLayout( groupBox2->layout() );
02057
02058 m_bDontPrint = new QCheckBox( i18n( "&Do not print text" ), groupBox2, "m_bDontPrint" );
02059 groupBox2Layout->addWidget( m_bDontPrint );
02060 Form1Layout->addWidget( groupBox2 );
02061 QSpacerItem * spacer_4 = new QSpacerItem( 20, 90, QSizePolicy::Minimum, QSizePolicy::Expanding );
02062 Form1Layout->addItem( spacer_4 );
02063
02064 m_bDontPrint->setChecked( m_dlg->bDontPrintText );
02065 m_bHideAll->setChecked( m_dlg->bHideAll );
02066 m_bHideFormula->setChecked( m_dlg->bHideFormula );
02067 m_bIsProtected->setChecked( m_dlg->bIsProtected );
02068 }
02069
02070 CellFormatPageProtection::~CellFormatPageProtection()
02071 {
02072 }
02073
02074 void CellFormatPageProtection::apply( KSpreadCustomStyle * style )
02075 {
02076 if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked() )
02077 {
02078 if ( m_bDontPrint->isChecked() )
02079 style->addProperty( KSpreadStyle::PDontPrintText );
02080 else
02081 style->removeProperty( KSpreadStyle::PDontPrintText );
02082 }
02083
02084 if ( m_dlg->bIsProtected != m_bIsProtected->isChecked() )
02085 {
02086 if ( !m_bIsProtected->isChecked() )
02087 style->addProperty( KSpreadStyle::PNotProtected );
02088 else
02089 style->removeProperty( KSpreadStyle::PNotProtected );
02090 }
02091
02092 if ( m_dlg->bHideAll != m_bHideAll->isChecked() )
02093 {
02094 if ( m_bHideAll->isChecked() )
02095 style->addProperty( KSpreadStyle::PHideAll );
02096 else
02097 style->removeProperty( KSpreadStyle::PHideAll );
02098 }
02099
02100 if ( m_dlg->bHideFormula != m_bHideFormula->isChecked() )
02101 {
02102 if ( m_bHideFormula->isChecked() )
02103 style->addProperty( KSpreadStyle::PHideFormula );
02104 else
02105 style->removeProperty( KSpreadStyle::PHideFormula );
02106 }
02107 }
02108
02109 void CellFormatPageProtection::apply( KSpreadCell * _cell )
02110 {
02111 applyFormat( _cell );
02112 }
02113
02114 void CellFormatPageProtection::apply( ColumnFormat * _col )
02115 {
02116 KSpreadSheet * sheet = m_dlg->getSheet();
02117 KSpreadCell * c = 0;
02118 for (int col = m_dlg->left; col <= m_dlg->right; col++)
02119 {
02120 for ( c = sheet->getFirstCellColumn( col ); c != 0;
02121 c = sheet->getNextCellDown( c->column(), c->row() ) )
02122 {
02123 if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked() )
02124 {
02125 c->clearProperty( KSpreadCell::PDontPrintText );
02126 c->clearNoFallBackProperties( KSpreadCell::PDontPrintText );
02127 }
02128 if ( m_dlg->bIsProtected != m_bIsProtected->isChecked() )
02129 {
02130 c->clearProperty( KSpreadCell::PNotProtected );
02131 c->clearNoFallBackProperties( KSpreadCell::PNotProtected );
02132 }
02133 if ( m_dlg->bHideFormula != m_bHideFormula->isChecked() )
02134 {
02135 c->clearProperty( KSpreadCell::PHideFormula );
02136 c->clearNoFallBackProperties( KSpreadCell::PHideFormula );
02137 }
02138 if ( m_dlg->bHideAll != m_bHideAll->isChecked() )
02139 {
02140 c->clearProperty( KSpreadCell::PHideAll );
02141 c->clearNoFallBackProperties( KSpreadCell::PHideAll );
02142 }
02143 }
02144 }
02145
02146 applyFormat( _col );
02147 }
02148
02149 void CellFormatPageProtection::apply( RowFormat * _row )
02150 {
02151 KSpreadSheet * sheet = m_dlg->getSheet();
02152 KSpreadCell * c = 0;
02153 for ( int row = m_dlg->top; row <= m_dlg->bottom; ++row)
02154 {
02155 for ( c = sheet->getFirstCellRow( row ); c != 0;
02156 c = sheet->getNextCellRight( c->column(), c->row() ) )
02157 {
02158 if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked() )
02159 {
02160 c->clearProperty( KSpreadCell::PDontPrintText );
02161 c->clearNoFallBackProperties( KSpreadCell::PDontPrintText );
02162 }
02163 if ( m_dlg->bIsProtected != m_bIsProtected->isChecked() )
02164 {
02165 c->clearProperty( KSpreadCell::PNotProtected );
02166 c->clearNoFallBackProperties( KSpreadCell::PNotProtected );
02167 }
02168 if ( m_dlg->bHideFormula != m_bHideFormula->isChecked() )
02169 {
02170 c->clearProperty( KSpreadCell::PHideFormula );
02171 c->clearNoFallBackProperties( KSpreadCell::PHideFormula );
02172 }
02173 if ( m_dlg->bHideAll != m_bHideAll->isChecked() )
02174 {
02175 c->clearProperty( KSpreadCell::PHideAll );
02176 c->clearNoFallBackProperties( KSpreadCell::PHideAll );
02177 }
02178 }
02179 }
02180
02181 applyFormat( _row );
02182 }
02183
02184 void CellFormatPageProtection::applyFormat( KSpreadFormat * _obj )
02185 {
02186 if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked())
02187 _obj->setDontPrintText( m_bDontPrint->isChecked() );
02188
02189 if ( m_dlg->bIsProtected != m_bIsProtected->isChecked())
02190 _obj->setNotProtected( !m_bIsProtected->isChecked() );
02191
02192 if ( m_dlg->bHideAll != m_bHideAll->isChecked())
02193 _obj->setHideAll( m_bHideAll->isChecked() );
02194
02195 if ( m_dlg->bHideFormula != m_bHideFormula->isChecked())
02196 _obj->setHideFormula( m_bHideFormula->isChecked() );
02197 }
02198
02199
02200 CellFormatPageMisc::CellFormatPageMisc( QWidget* parent, CellFormatDlg *_dlg ) : QWidget( parent )
02201 {
02202 dlg = _dlg;
02203
02204
02205 QGridLayout* layout = new QGridLayout( this, 2,2,KDialog::marginHint(), KDialog::spacingHint() );
02206 QGroupBox *box = new QGroupBox( this, "Box");
02207
02208 QGridLayout *grid = new QGridLayout(box,2,4,KDialog::marginHint(), KDialog::spacingHint());
02209 QLabel *tmpQLabel;
02210
02211 tmpQLabel = new QLabel( box, "Label_3" );
02212 grid->addWidget(tmpQLabel,0,0);
02213 tmpQLabel->setText( i18n("Functionality") );
02214
02215 styleButton = new QComboBox( box, "ComboBox_2" );
02216
02217 grid->addWidget(styleButton,1,0);
02218
02219 idStyleNormal = 0; styleButton->insertItem( i18n("Normal"), 0 );
02220 idStyleButton = 1; styleButton->insertItem( i18n("Button"), 1 );
02221 idStyleSelect = 2; styleButton->insertItem( i18n("Select"), 2 );
02222 idStyleUndef = -1;
02223 connect( styleButton, SIGNAL( activated( int ) ), this, SLOT( slotStyle( int ) ) );
02224
02225 tmpQLabel = new QLabel( box, "Label_3" );
02226 grid->addWidget(tmpQLabel,2,0);
02227 tmpQLabel->setText( i18n("Action") );
02228
02229 actionText = new QLineEdit( box );
02230 grid->addMultiCellWidget(actionText,3,3,0,1);
02231
02232 if ( dlg->isSingleCell() )
02233 {
02234 if ( !dlg->actionText.isEmpty() )
02235 actionText->setText( dlg->actionText );
02236 actionText->setEnabled( false );
02237 }
02238 else
02239 actionText->setEnabled( false );
02240
02241 styleButton->setCurrentItem( idStyleNormal );
02242
02243 layout->addWidget(box,0,0);
02244
02245 box = new QGroupBox( this, "Box1");
02246 grid = new QGridLayout(box,4,1,KDialog::marginHint(), KDialog::spacingHint());
02247 dontPrintText= new QCheckBox(i18n("Do not print text"),box);
02248 dontPrintText->setChecked(dlg->bDontPrintText);
02249
02250 grid->addWidget(dontPrintText,0,0);
02251 layout->addWidget(box,1,0);
02252
02253
02254 this->resize( 400, 400 );
02255 }
02256
02257 void CellFormatPageMisc::apply( KSpreadCustomStyle * )
02258 {
02259
02260 }
02261
02262 void CellFormatPageMisc::apply( KSpreadCell *_obj )
02263 {
02264 applyFormat( _obj );
02265 }
02266
02267 void CellFormatPageMisc::applyColumn( )
02268 {
02269 KSpreadSheet* sheet = dlg->getSheet();
02270 KSpreadCell* c = NULL;
02271 for (int col = dlg->left; col <= dlg->right; col++)
02272 {
02273 for ( c = sheet->getFirstCellColumn(col); c != NULL;
02274 c = sheet->getNextCellDown(c->column(), c->row()) )
02275 {
02276 applyFormat(c);
02277 }
02278 }
02279 }
02280
02281 void CellFormatPageMisc::applyRow( )
02282 {
02283 KSpreadSheet* sheet = dlg->getSheet();
02284 KSpreadCell* c= NULL;
02285 for (int row = dlg->top; row <= dlg->bottom; row++)
02286 {
02287 for ( c = sheet->getFirstCellRow(row); c != NULL;
02288 c = sheet->getNextCellRight(c->column(), c->row()) )
02289 {
02290 applyFormat(c);
02291 }
02292 }
02293 }
02294
02295 void CellFormatPageMisc::applyFormat( KSpreadCell *_obj )
02296 {
02297 if ( dlg->bDontPrintText!=dontPrintText->isChecked())
02298 _obj->setDontPrintText(dontPrintText->isChecked());
02299 }
02300
02301 void CellFormatPageMisc::slotStyle( int _i )
02302 {
02303 if ( dlg->isSingleCell() && _i != idStyleNormal && _i != idStyleUndef )
02304 actionText->setEnabled( true );
02305 else
02306 actionText->setEnabled( false );
02307 }
02308
02309
02310 CellFormatPageFont::CellFormatPageFont( QWidget* parent, CellFormatDlg *_dlg ) : QWidget ( parent )
02311 {
02312 dlg = _dlg;
02313
02314 bTextColorUndefined = !dlg->bTextColor;
02315
02316 QVBoxLayout* grid = new QVBoxLayout( this, 6 );
02317
02318 box1 = new QGroupBox( this, "Box1");
02319 box1->setTitle(i18n("Requested Font"));
02320 QGridLayout *grid2 = new QGridLayout(box1,7,3,KDialog::marginHint(), KDialog::spacingHint());
02321 int fHeight = box1->fontMetrics().height();
02322 grid2->addRowSpacing( 0, fHeight/2 );
02323
02324 family_label = new QLabel(box1,"family");
02325 family_label->setText(i18n("Family:"));
02326 grid2->addWidget(family_label,1,0);
02327
02328 size_label = new QLabel(box1,"size");
02329 size_label->setText(i18n("Size:"));
02330 grid2->addWidget(size_label,1,2);
02331
02332 weight_label = new QLabel(box1,"weight");
02333 weight_label->setText(i18n("Weight:"));
02334 grid2->addWidget(weight_label,3,1);
02335
02336 QLabel *tmpQLabel = new QLabel( box1, "Label_1" );
02337 tmpQLabel->setText( i18n("Text color:") );
02338 grid2->addWidget(tmpQLabel,5,1);
02339
02340 textColorButton = new KColorButton( box1, "textColor" );
02341 grid2->addWidget(textColorButton,6,1);
02342
02343 connect( textColorButton, SIGNAL( changed( const QColor & ) ),
02344 this, SLOT( slotSetTextColor( const QColor & ) ) );
02345
02346
02347
02348 style_label = new QLabel(box1,"style");
02349 style_label->setText(i18n("Style:"));
02350 grid2->addWidget(style_label,1,1);
02351
02352 family_combo = new QListBox( box1, "Family" );
02353
02354 QStringList tmpListFont;
02355 QFontDatabase *fontDataBase = new QFontDatabase();
02356 tmpListFont = fontDataBase->families();
02357 delete fontDataBase;
02358
02359 listFont.setItems(tmpListFont);
02360
02361 family_combo->insertStringList( tmpListFont);
02362 selFont = dlg->textFont;
02363
02364 if ( dlg->bTextFontFamily )
02365 {
02366 selFont.setFamily( dlg->textFontFamily );
02367 kdDebug(36001) << "Family = " << dlg->textFontFamily << endl;
02368
02369 if ( !family_combo->findItem(dlg->textFontFamily))
02370 {
02371 family_combo->insertItem("",0);
02372 family_combo->setCurrentItem(0);
02373 }
02374 else
02375 family_combo->setCurrentItem(family_combo->index(family_combo->findItem(dlg->textFontFamily)));
02376 }
02377 else
02378 {
02379 family_combo->insertItem("",0);
02380 family_combo->setCurrentItem(0);
02381 }
02382
02383 grid2->addMultiCellWidget(family_combo,3,6,0,0);
02384
02385 connect( family_combo, SIGNAL(highlighted(const QString &)),
02386 SLOT(family_chosen_slot(const QString &)) );
02387
02388 searchFont=new KLineEdit(box1);
02389 grid2->addWidget(searchFont,2,0);
02390 searchFont->setCompletionMode(KGlobalSettings::CompletionAuto );
02391 searchFont->setCompletionObject( &listFont,true );
02392
02393 connect(searchFont, SIGNAL( textChanged( const QString & )),
02394 this,SLOT(slotSearchFont(const QString &)));
02395
02396 size_combo = new QComboBox( true, box1, "Size" );
02397 QStringList lst;
02398 lst.append("");
02399 for ( unsigned int i = 1; i < 100; ++i )
02400 lst.append( QString( "%1" ).arg( i ) );
02401
02402 size_combo->insertStringList( lst );
02403
02404
02405 size_combo->setInsertionPolicy(QComboBox::NoInsertion);
02406 grid2->addWidget(size_combo,2,2);
02407 connect( size_combo, SIGNAL(activated(const QString &)),
02408 SLOT(size_chosen_slot(const QString &)) );
02409 connect( size_combo ,SIGNAL( textChanged(const QString &)),
02410 this,SLOT(size_chosen_slot(const QString &)));
02411
02412 weight_combo = new QComboBox( box1, "Weight" );
02413 weight_combo->insertItem( "", 0 );
02414 weight_combo->insertItem( i18n("Normal") );
02415 weight_combo->insertItem( i18n("Bold") );
02416
02417 weight_combo->setInsertionPolicy(QComboBox::NoInsertion);
02418 grid2->addWidget(weight_combo,4,1);
02419 connect( weight_combo, SIGNAL(activated(const QString &)),
02420 SLOT(weight_chosen_slot(const QString &)) );
02421
02422 style_combo = new QComboBox( box1, "Style" );
02423 style_combo->insertItem( "", 0 );
02424 style_combo->insertItem( i18n("Roman") );
02425 style_combo->insertItem( i18n("Italic"), 2 );
02426 grid2->addWidget(style_combo,2,1);
02427 style_combo->setInsertionPolicy(QComboBox::NoInsertion);
02428 connect( style_combo, SIGNAL(activated(const QString &)),
02429 SLOT(style_chosen_slot(const QString &)) );
02430
02431 strike = new QCheckBox(i18n("Strike out"),box1);
02432 grid2->addWidget(strike,6,2);
02433 strike->setChecked(dlg->strike);
02434 connect( strike, SIGNAL( clicked()),
02435 SLOT(strike_chosen_slot()) );
02436
02437 underline = new QCheckBox(i18n("Underline"),box1);
02438 grid2->addWidget(underline,4,2);
02439 underline->setChecked(dlg->underline);
02440 connect( underline, SIGNAL( clicked()),
02441 SLOT(underline_chosen_slot()) );
02442
02443
02444 grid->addWidget(box1);
02445
02446 box1 = new QGroupBox(this, "Box2");
02447 box1->setTitle(i18n("Actual Font"));
02448 grid2 = new QGridLayout(box1,4,5,KDialog::marginHint(), KDialog::spacingHint());
02449 grid2->addRowSpacing( 0, fHeight/2 );
02450
02451 actual_family_label = new QLabel(box1,"afamily");
02452 actual_family_label->setText(i18n("Family:"));
02453 grid2->addWidget(actual_family_label,1,0);
02454
02455 actual_family_label_data = new QLabel(box1,"afamilyd");
02456 grid2->addWidget(actual_family_label_data,1,1);
02457
02458 actual_size_label = new QLabel(box1,"asize");
02459 actual_size_label->setText(i18n("Size:"));
02460 grid2->addWidget(actual_size_label,2,0);
02461
02462 actual_size_label_data = new QLabel(box1,"asized");
02463 grid2->addWidget(actual_size_label_data,2,1);
02464
02465 actual_weight_label = new QLabel(box1,"aweight");
02466 actual_weight_label->setText(i18n("Weight:"));
02467 grid2->addWidget(actual_weight_label,3,0);
02468
02469 actual_weight_label_data = new QLabel(box1,"aweightd");
02470 grid2->addWidget(actual_weight_label_data,3,1);
02471
02472 actual_style_label = new QLabel(box1,"astyle");
02473 actual_style_label->setText(i18n("Style:"));
02474 grid2->addWidget(actual_style_label,4,0);
02475
02476 actual_style_label_data = new QLabel(box1,"astyled");
02477 grid2->addWidget(actual_style_label_data,4,1);
02478
02479
02480 example_label = new QLabel(box1,"examples");
02481 example_label->setFont(selFont);
02482 example_label->setAlignment(AlignCenter);
02483 example_label->setBackgroundColor(colorGroup().base());
02484 example_label->setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
02485 example_label->setLineWidth( 1 );
02486 example_label->setText(i18n("Dolor Ipse"));
02487
02488 grid2->addMultiCellWidget(example_label,1,4,2,3);
02489 connect(this,SIGNAL(fontSelected( const QFont& )),
02490 this,SLOT(display_example( const QFont&)));
02491
02492
02493 grid->addWidget(box1);
02494 setCombos();
02495 display_example( selFont );
02496 fontChanged=false;
02497 this->resize( 400, 400 );
02498 }
02499
02500 void CellFormatPageFont::slotSearchFont(const QString &_text)
02501 {
02502 QString result;
02503 result = listFont.makeCompletion( _text );
02504 if ( !result.isNull() )
02505 family_combo->setCurrentItem( family_combo->index( family_combo->findItem( result ) ) );
02506 }
02507
02508 void CellFormatPageFont::slotSetTextColor( const QColor &_color )
02509 {
02510 textColor = _color;
02511 bTextColorUndefined = false;
02512 }
02513
02514 void CellFormatPageFont::apply( KSpreadCustomStyle * style )
02515 {
02516 if ( !bTextColorUndefined && textColor != dlg->textColor )
02517 style->changeTextColor( textColor );
02518
02519 if ( ( size_combo->currentItem() != 0 )
02520 && ( dlg->textFontSize != selFont.pointSize() ) )
02521 style->changeFontSize( selFont.pointSize() );
02522
02523 if ( ( selFont.family() != dlg->textFontFamily )
02524 && !family_combo->currentText().isEmpty() )
02525 style->changeFontFamily( selFont.family() );
02526
02527 uint flags = 0;
02528
02529 if ( weight_combo->currentItem() != 0 && selFont.bold() )
02530 flags |= KSpreadStyle::FBold;
02531 else
02532 flags &= ~(uint) KSpreadStyle::FBold;
02533
02534 if ( style_combo->currentItem() != 0 && selFont.italic() )
02535 flags |= KSpreadStyle::FItalic;
02536 else
02537 flags &= ~(uint) KSpreadStyle::FItalic;
02538
02539 if ( strike->isChecked() )
02540 flags |= KSpreadStyle::FStrike;
02541 else
02542 flags &= ~(uint) KSpreadStyle::FStrike;
02543
02544 if ( underline->isChecked() )
02545 flags |= KSpreadStyle::FUnderline;
02546 else
02547 flags &= ~(uint) KSpreadStyle::FUnderline;
02548
02549 style->changeFontFlags( flags );
02550 }
02551
02552 void CellFormatPageFont::apply( ColumnFormat *_obj)
02553 {
02554 KSpreadSheet* sheet = dlg->getSheet();
02555 KSpreadCell* c= NULL;
02556 for (int col = dlg->left; col <= dlg->right; col++)
02557 {
02558 for ( c = sheet->getFirstCellColumn(col); c != NULL;
02559 c = sheet->getNextCellDown(c->column(), c->row()) )
02560 {
02561 if ( !bTextColorUndefined )
02562 {
02563 c->clearProperty(KSpreadCell::PTextPen);
02564 c->clearNoFallBackProperties( KSpreadCell::PTextPen );
02565 }
02566 if (fontChanged)
02567 {
02568 c->clearProperty(KSpreadCell::PFont);
02569 c->clearNoFallBackProperties( KSpreadCell::PFont );
02570 }
02571 }
02572 }
02573
02574 applyFormat(_obj);
02575 RowFormat* rw =dlg->getSheet()->firstRow();
02576 for ( ; rw; rw = rw->next() )
02577 {
02578 if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PFont) ))
02579 {
02580 for ( int i=dlg->left;i<=dlg->right;i++)
02581 {
02582 KSpreadCell *cell = dlg->getSheet()->nonDefaultCell( i, rw->row() );
02583 applyFormat(cell );
02584 }
02585 }
02586 }
02587 }
02588
02589 void CellFormatPageFont::apply( RowFormat *_obj)
02590 {
02591 KSpreadSheet* sheet = dlg->getSheet();
02592 KSpreadCell* c= NULL;
02593 for (int row = dlg->top; row <= dlg->bottom; row++)
02594 {
02595 for ( c = sheet->getFirstCellRow(row); c != NULL;
02596 c = sheet->getNextCellRight(c->column(), c->row()) )
02597 {
02598 if ( !bTextColorUndefined )
02599 {
02600 c->clearProperty(KSpreadCell::PTextPen);
02601 c->clearNoFallBackProperties( KSpreadCell::PTextPen );
02602 }
02603 if (fontChanged)
02604 {
02605 c->clearProperty(KSpreadCell::PFont);
02606 c->clearNoFallBackProperties( KSpreadCell::PFont );
02607 }
02608 }
02609 }
02610 applyFormat(_obj);
02611 }
02612
02613
02614 void CellFormatPageFont::apply( KSpreadCell *_obj )
02615 {
02616 applyFormat(_obj);
02617 }
02618
02619 void CellFormatPageFont::applyFormat( KSpreadFormat *_obj )
02620 {
02621 if ( !bTextColorUndefined && textColor != dlg->textColor )
02622 _obj->setTextColor( textColor );
02623 if (fontChanged)
02624 {
02625 if ( ( size_combo->currentItem() != 0 )
02626 && ( dlg->textFontSize != selFont.pointSize() ) )
02627 _obj->setTextFontSize( selFont.pointSize() );
02628 if ( ( selFont.family() != dlg->textFontFamily ) && ( !family_combo->currentText().isEmpty() ) )
02629 _obj->setTextFontFamily( selFont.family() );
02630 if ( weight_combo->currentItem() != 0 )
02631 _obj->setTextFontBold( selFont.bold() );
02632 if ( style_combo->currentItem() != 0 )
02633 _obj->setTextFontItalic( selFont.italic() );
02634 _obj->setTextFontStrike( strike->isChecked() );
02635 _obj->setTextFontUnderline(underline->isChecked() );
02636 }
02637 }
02638
02639 void CellFormatPageFont::underline_chosen_slot()
02640 {
02641 selFont.setUnderline( underline->isChecked() );
02642 emit fontSelected(selFont);
02643 }
02644
02645 void CellFormatPageFont::strike_chosen_slot()
02646 {
02647 selFont.setStrikeOut( strike->isChecked() );
02648 emit fontSelected(selFont);
02649 }
02650
02651 void CellFormatPageFont::family_chosen_slot(const QString & family)
02652 {
02653 selFont.setFamily(family);
02654 emit fontSelected(selFont);
02655 }
02656
02657 void CellFormatPageFont::size_chosen_slot(const QString & size)
02658 {
02659 QString size_string = size;
02660
02661 selFont.setPointSize(size_string.toInt());
02662 emit fontSelected(selFont);
02663 }
02664
02665 void CellFormatPageFont::weight_chosen_slot(const QString & weight)
02666 {
02667 QString weight_string = weight;
02668
02669 if ( weight_string == i18n("Normal"))
02670 selFont.setBold(false);
02671 if ( weight_string == i18n("Bold"))
02672 selFont.setBold(true);
02673 emit fontSelected(selFont);
02674 }
02675
02676 void CellFormatPageFont::style_chosen_slot(const QString & style)
02677 {
02678 QString style_string = style;
02679
02680 if ( style_string == i18n("Roman"))
02681 selFont.setItalic(false);
02682 if ( style_string == i18n("Italic"))
02683 selFont.setItalic(true);
02684 emit fontSelected(selFont);
02685 }
02686
02687
02688 void CellFormatPageFont::display_example(const QFont& font)
02689 {
02690 QString string;
02691 fontChanged=true;
02692 example_label->setFont(font);
02693 example_label->repaint();
02694
02695 kdDebug(36001) << "FAMILY 2 '" << font.family() << "' " << font.pointSize() << endl;
02696
02697 QFontInfo info = example_label->fontInfo();
02698 actual_family_label_data->setText(info.family());
02699
02700 kdDebug(36001) << "FAMILY 3 '" << info.family() << "' " << info.pointSize() << endl;
02701
02702 string.setNum(info.pointSize());
02703 actual_size_label_data->setText(string);
02704
02705 if (info.bold())
02706 actual_weight_label_data->setText(i18n("Bold"));
02707 else
02708 actual_weight_label_data->setText(i18n("Normal"));
02709
02710 if (info.italic())
02711 actual_style_label_data->setText(i18n("Italic"));
02712 else
02713 actual_style_label_data->setText(i18n("Roman"));
02714 }
02715
02716 void CellFormatPageFont::setCombos()
02717 {
02718 QString string;
02719 QComboBox* combo;
02720 int number_of_entries;
02721 bool found;
02722
02723 if ( dlg->bTextColor )
02724 textColor = dlg->textColor;
02725 else
02726 textColor = colorGroup().text();
02727
02728 if ( !textColor.isValid() )
02729 textColor =colorGroup().text();
02730
02731 textColorButton->setColor( textColor );
02732
02733
02734 combo = size_combo;
02735 if ( dlg->bTextFontSize )
02736 {
02737 kdDebug(36001) << "SIZE=" << dlg->textFontSize << endl;
02738 selFont.setPointSize( dlg->textFontSize );
02739 number_of_entries = size_combo->count();
02740 string.setNum( dlg->textFontSize );
02741 found = false;
02742
02743 for (int i = 0; i < number_of_entries ; i++){
02744 if ( string == (QString) combo->text(i)){
02745 combo->setCurrentItem(i);
02746 found = true;
02747
02748 break;
02749 }
02750 }
02751 }
02752 else
02753 combo->setCurrentItem( 0 );
02754
02755 if ( !dlg->bTextFontBold )
02756 weight_combo->setCurrentItem(0);
02757 else if ( dlg->textFontBold )
02758 {
02759 selFont.setBold( dlg->textFontBold );
02760 weight_combo->setCurrentItem(2);
02761 }
02762 else
02763 {
02764 selFont.setBold( dlg->textFontBold );
02765 weight_combo->setCurrentItem(1);
02766 }
02767
02768 if ( !dlg->bTextFontItalic )
02769 weight_combo->setCurrentItem(0);
02770 else if ( dlg->textFontItalic )
02771 {
02772 selFont.setItalic( dlg->textFontItalic );
02773 style_combo->setCurrentItem(2);
02774 }
02775 else
02776 {
02777 selFont.setItalic( dlg->textFontItalic );
02778 style_combo->setCurrentItem(1);
02779 }
02780 }
02781
02782 CellFormatPagePosition::CellFormatPagePosition( QWidget* parent, CellFormatDlg *_dlg )
02783 : QWidget( parent ),
02784 dlg( _dlg )
02785 {
02786 QGridLayout *grid3 = new QGridLayout(this, 4, 2, KDialog::marginHint(), KDialog::spacingHint());
02787 QButtonGroup *grp = new QButtonGroup( i18n("Horizontal"), this);
02788 grp->setRadioButtonExclusive( true );
02789
02790 QGridLayout *grid2 = new QGridLayout(grp, 4, 2, KDialog::marginHint(), KDialog::spacingHint());
02791 int fHeight = grp->fontMetrics().height();
02792 grid2->addRowSpacing( 0, fHeight/2 );
02793 standard = new QRadioButton( i18n("Standard"), grp );
02794 grid2->addWidget(standard, 2, 0);
02795 left = new QRadioButton( i18n("Left"), grp );
02796 grid2->addWidget(left, 1, 1);
02797 center = new QRadioButton( i18n("Center"), grp );
02798 grid2->addWidget(center, 2, 1);
02799 right = new QRadioButton( i18n("Right"), grp );
02800 grid2->addWidget(right, 3, 1);
02801 grid3->addWidget(grp, 0, 0);
02802
02803 if ( dlg->alignX == KSpreadCell::Left )
02804 left->setChecked( true );
02805 else if ( dlg->alignX == KSpreadCell::Center )
02806 center->setChecked( true );
02807 else if ( dlg->alignX == KSpreadCell::Right )
02808 right->setChecked( true );
02809 else if ( dlg->alignX == KSpreadCell::Undefined )
02810 standard->setChecked( true );
02811
02812 connect(grp, SIGNAL(clicked(int)), this, SLOT(slotStateChanged(int)));
02813
02814 grp = new QButtonGroup( i18n("Vertical"), this);
02815 grp->setRadioButtonExclusive( true );
02816
02817 grid2 = new QGridLayout(grp, 4, 1, KDialog::marginHint(), KDialog::spacingHint());
02818 fHeight = grp->fontMetrics().height();
02819 grid2->addRowSpacing( 0, fHeight/2 );
02820 top = new QRadioButton( i18n("Top"), grp );
02821 grid2->addWidget(top, 1, 0);
02822 middle = new QRadioButton( i18n("Middle"), grp );
02823 grid2->addWidget(middle, 2, 0);
02824 bottom = new QRadioButton( i18n("Bottom"), grp );
02825 grid2->addWidget(bottom, 3, 0);
02826 grid3->addWidget(grp, 0, 1);
02827
02828 if ( dlg->alignY ==KSpreadCell::Top )
02829 top->setChecked( true );
02830 else if ( dlg->alignY ==KSpreadCell::Middle )
02831 middle->setChecked(true );
02832 else if ( dlg->alignY ==KSpreadCell::Bottom )
02833 bottom->setChecked( true );
02834
02835 grp = new QButtonGroup( i18n("Text Option"), this);
02836
02837 grid2 = new QGridLayout(grp, 3, 1, KDialog::marginHint(), KDialog::spacingHint());
02838 fHeight = grp->fontMetrics().height();
02839 grid2->addRowSpacing( 0, fHeight/2 );
02840 multi = new QCheckBox( i18n("Wrap text"), grp);
02841
02842 grid2->addWidget(multi, 1, 0);
02843 multi->setChecked(dlg->bMultiRow);
02844
02845 vertical = new QCheckBox( i18n("Vertical text"), grp);
02846 grid2->addWidget(vertical, 2, 0);
02847 vertical->setChecked(dlg->bVerticalText);
02848
02849 grid3->addWidget(grp, 1, 0);
02850
02851 grp = new QButtonGroup(i18n("Rotation"), this);
02852
02853 grid2 = new QGridLayout(grp, 2, 1, KDialog::marginHint(), KDialog::spacingHint());
02854 fHeight = grp->fontMetrics().height();
02855 grid2->addRowSpacing( 0, fHeight/2 );
02856 angleRotation=new KIntNumInput((-dlg->textRotation), grp, 10);
02857 angleRotation->setLabel(i18n("Angle:"));
02858 angleRotation->setRange(-90, 90, 1);
02859 angleRotation->setSuffix(" °");
02860
02861 grid2->addWidget(angleRotation, 1, 0);
02862 grid3->addWidget(grp, 1, 1);
02863 if ( dlg->textRotation != 0 )
02864 {
02865 multi->setEnabled(false );
02866 vertical->setEnabled(false);
02867 }
02868
02869 grp = new QButtonGroup( i18n("Merge Cells"), this);
02870 grid2 = new QGridLayout(grp, 2, 1, KDialog::marginHint(), KDialog::spacingHint());
02871
02872 fHeight = grp->fontMetrics().height();
02873 grid2->addRowSpacing( 0, fHeight/2 );
02874
02875 mergeCell=new QCheckBox(i18n("Merge cells"), grp);
02876 mergeCell->setChecked(dlg->isMerged);
02877 mergeCell->setEnabled(!dlg->oneCell && ((!dlg->isRowSelected) && (!dlg->isColumnSelected)));
02878 grid2->addWidget(mergeCell, 1, 0);
02879 grid3->addWidget(grp, 2, 0);
02880
02881 grp = new QButtonGroup( i18n("Indent"), this);
02882 grid2 = new QGridLayout(grp, 2, 1, KDialog::marginHint(), KDialog::spacingHint());
02883 fHeight = grp->fontMetrics().height();
02884 grid2->addRowSpacing( 0, fHeight/2 );
02885
02886 m_indent = new KDoubleNumInput( grp );
02887 m_indent->setRange( KoUnit::toUserValue( 0.0, dlg->getDoc()->getUnit() ),
02888 KoUnit::toUserValue( 400.0, dlg->getDoc()->getUnit() ),
02889 KoUnit::toUserValue( 10.0, dlg->getDoc()->getUnit()));
02890 m_indent->setValue ( KoUnit::toUserValue( dlg->indent,
02891 dlg->getDoc()->getUnit() ) );
02892 grid2->addWidget(m_indent, 1, 0);
02893 grid3->addWidget(grp, 2, 1);
02894
02895 grp = new QButtonGroup( i18n("Size of Cell"), this);
02896 grid2 = new QGridLayout(grp, 3, 4, KDialog::marginHint(), KDialog::spacingHint());
02897 fHeight = grp->fontMetrics().height();
02898 grid2->addRowSpacing( 0, fHeight/2 );
02899
02900 QLabel *tmpLabel=new QLabel(grp, "label");
02901 tmpLabel->setText(i18n("Width:"));
02902 grid2->addWidget(tmpLabel, 1, 0);
02903
02904 width = new KDoubleNumInput( grp );
02905 width->setPrecision ( 2 );
02906 width->setValue ( KoUnit::toUserValue( dlg->widthSize, dlg->getDoc()->getUnit() ) );
02907
02908 dlg->widthSize = KoUnit::fromUserValue( width->value(), dlg->getDoc()->getUnit() );
02909
02910 if ( dlg->isRowSelected )
02911 width->setEnabled(false);
02912
02913 grid2->addWidget(width, 1, 1);
02914 defaultWidth=new QCheckBox(i18n("Default width (%1 %2)").arg(KoUnit::toUserValue( 60, dlg->getDoc()->getUnit())).arg(dlg->getDoc()->getUnitName()), grp);
02915 if ( dlg->isRowSelected )
02916 defaultWidth->setEnabled(false);
02917
02918 grid2->addMultiCellWidget(defaultWidth, 2, 2, 0, 1);
02919
02920 tmpLabel=new QLabel(grp, "label1");
02921 tmpLabel->setText(i18n("Height:"));
02922 grid2->addWidget(tmpLabel, 1, 2);
02923
02924 height=new KDoubleNumInput( grp );
02925 height->setPrecision( 2 );
02926 height->setValue( KoUnit::toUserValue( dlg->heightSize, dlg->getDoc()->getUnit() ) );
02927
02928 dlg->heightSize = KoUnit::fromUserValue( height->value(), dlg->getDoc()->getUnit() );
02929
02930 if ( dlg->isColumnSelected )
02931 height->setEnabled(false);
02932
02933 grid2->addWidget(height, 1, 3);
02934
02935 defaultHeight=new QCheckBox(i18n("Default height (%1 %2)").arg(KoUnit::toUserValue( 20 , dlg->getDoc()->getUnit())).arg(dlg->getDoc()->getUnitName()), grp);
02936 if ( dlg->isColumnSelected )
02937 defaultHeight->setEnabled(false);
02938
02939 grid2->addMultiCellWidget(defaultHeight, 2, 2, 2, 3);
02940
02941 grid3->addMultiCellWidget(grp, 3, 3, 0, 1);
02942
02943 connect(defaultWidth , SIGNAL(clicked() ),this, SLOT(slotChangeWidthState()));
02944 connect(defaultHeight , SIGNAL(clicked() ),this, SLOT(slotChangeHeightState()));
02945 connect(vertical , SIGNAL(clicked() ),this, SLOT(slotChangeVerticalState()));
02946 connect(multi , SIGNAL(clicked() ), this, SLOT(slotChangeMultiState()));
02947 connect(angleRotation, SIGNAL(valueChanged(int)), this, SLOT(slotChangeAngle(int)));
02948
02949 slotStateChanged( 0 );
02950 m_bOptionText = false;
02951 this->resize( 400, 400 );
02952 }
02953
02954 void CellFormatPagePosition::slotChangeMultiState()
02955 {
02956 m_bOptionText = true;
02957 if (vertical->isChecked())
02958 {
02959 vertical->setChecked(false);
02960 }
02961 }
02962
02963 void CellFormatPagePosition::slotChangeVerticalState()
02964 {
02965 m_bOptionText=true;
02966 if (multi->isChecked())
02967 {
02968 multi->setChecked(false);
02969 }
02970
02971 }
02972
02973 void CellFormatPagePosition::slotStateChanged(int)
02974 {
02975 if (right->isChecked() || center->isChecked())
02976 m_indent->setEnabled(false);
02977 else
02978 m_indent->setEnabled(true);
02979
02980 }
02981 bool CellFormatPagePosition::getMergedCellState()
02982 {
02983 return mergeCell->isChecked();
02984 }
02985
02986 void CellFormatPagePosition::slotChangeWidthState()
02987 {
02988 if ( defaultWidth->isChecked())
02989 width->setEnabled(false);
02990 else
02991 width->setEnabled(true);
02992 }
02993
02994 void CellFormatPagePosition::slotChangeHeightState()
02995 {
02996 if ( defaultHeight->isChecked())
02997 height->setEnabled(false);
02998 else
02999 height->setEnabled(true);
03000 }
03001
03002 void CellFormatPagePosition::slotChangeAngle(int _angle)
03003 {
03004 if ( _angle == 0 )
03005 {
03006 multi->setEnabled( true );
03007 vertical->setEnabled( true );
03008 }
03009 else
03010 {
03011 multi->setEnabled( false );
03012 vertical->setEnabled( false );
03013 }
03014 }
03015
03016 void CellFormatPagePosition::apply( KSpreadCustomStyle * style )
03017 {
03018 if ( top->isChecked() && dlg->alignY != KSpreadCell::Top )
03019 style->changeAlignY( KSpreadCell::Top );
03020 else if ( bottom->isChecked() && dlg->alignY != KSpreadCell::Bottom )
03021 style->changeAlignY( KSpreadCell::Bottom );
03022 else if ( middle->isChecked() && dlg->alignY != KSpreadCell::Middle )
03023 style->changeAlignY( KSpreadCell::Middle );
03024
03025 if ( left->isChecked() && dlg->alignX != KSpreadCell::Left )
03026 style->changeAlignX( KSpreadCell::Left );
03027 else if ( right->isChecked() && dlg->alignX != KSpreadCell::Right )
03028 style->changeAlignX( KSpreadCell::Right );
03029 else if ( center->isChecked() && dlg->alignX != KSpreadCell::Center )
03030 style->changeAlignX( KSpreadCell::Center );
03031 else if ( standard->isChecked() && dlg->alignX != KSpreadCell::Undefined )
03032 style->changeAlignX( KSpreadCell::Undefined );
03033
03034 if ( m_bOptionText )
03035 {
03036 if ( multi->isEnabled() )
03037 {
03038 if ( multi->isChecked() )
03039 style->addProperty( KSpreadStyle::PMultiRow );
03040 else
03041 style->removeProperty( KSpreadStyle::PMultiRow );
03042 }
03043 }
03044
03045 if ( m_bOptionText )
03046 {
03047 if ( vertical->isEnabled() )
03048 {
03049 if ( vertical->isChecked() )
03050 style->addProperty( KSpreadStyle::PVerticalText );
03051 else
03052 style->removeProperty( KSpreadStyle::PVerticalText );
03053 }
03054 }
03055
03056 if ( dlg->textRotation != angleRotation->value() )
03057 style->changeRotateAngle( (-angleRotation->value()) );
03058
03059 if ( m_indent->isEnabled()
03060 && dlg->indent != KoUnit::fromUserValue( m_indent->value(),
03061 dlg->getDoc()->getUnit() ) )
03062 style->changeIndent( KoUnit::fromUserValue( m_indent->value(),
03063 dlg->getDoc()->getUnit() ) );
03064 }
03065
03066 void CellFormatPagePosition::apply( ColumnFormat *_obj )
03067 {
03068 KSpreadFormat::Align ax;
03069 KSpreadFormat::AlignY ay;
03070
03071 if ( top->isChecked() )
03072 ay = KSpreadCell::Top;
03073 else if ( bottom->isChecked() )
03074 ay = KSpreadCell::Bottom;
03075 else if ( middle->isChecked() )
03076 ay = KSpreadCell::Middle;
03077 else
03078 ay = KSpreadCell::Middle;
03079
03080 if ( left->isChecked() )
03081 ax = KSpreadCell::Left;
03082 else if ( right->isChecked() )
03083 ax = KSpreadCell::Right;
03084 else if ( center->isChecked() )
03085 ax = KSpreadCell::Center;
03086 else if ( standard->isChecked() )
03087 ax = KSpreadCell::Undefined;
03088 else
03089 ax = KSpreadCell::Undefined;
03090
03091
03092 KSpreadSheet * sheet = dlg->getSheet();
03093 KSpreadCell * c = NULL;
03094 for ( int col = dlg->left; col <= dlg->right; ++col)
03095 {
03096 for ( c = sheet->getFirstCellColumn(col); c != NULL;
03097 c = sheet->getNextCellDown(c->column(), c->row()) )
03098 {
03099 if ( m_indent->isEnabled()
03100 && dlg->indent != KoUnit::fromUserValue( m_indent->value(),
03101 dlg->getDoc()->getUnit()) )
03102
03103 {
03104 c->clearProperty( KSpreadCell::PIndent );
03105 c->clearNoFallBackProperties( KSpreadCell::PIndent );
03106 }
03107 if ( ax != dlg->alignX )
03108 {
03109 c->clearProperty(KSpreadCell::PAlign);
03110 c->clearNoFallBackProperties( KSpreadCell::PAlign );
03111 }
03112 if ( ay != dlg->alignY )
03113 {
03114 c->clearProperty(KSpreadCell::PAlignY);
03115 c->clearNoFallBackProperties( KSpreadCell::PAlignY );
03116 }
03117 if ( m_bOptionText)
03118 {
03119 c->clearProperty(KSpreadCell::PMultiRow);
03120 c->clearNoFallBackProperties( KSpreadCell::PMultiRow );
03121 }
03122 if ( m_bOptionText)
03123 {
03124 c->clearProperty(KSpreadCell::PVerticalText);
03125 c->clearNoFallBackProperties( KSpreadCell::PVerticalText );
03126 }
03127
03128 if (dlg->textRotation != angleRotation->value())
03129 {
03130 c->clearProperty(KSpreadCell::PAngle);
03131 c->clearNoFallBackProperties( KSpreadCell::PAngle );
03132 }
03133 }
03134 }
03135
03136 applyFormat( _obj );
03137
03138 RowFormat* rw =dlg->getSheet()->firstRow();
03139 for ( ; rw; rw = rw->next() )
03140 {
03141 if ( !rw->isDefault() && ( rw->hasProperty(KSpreadCell::PAngle) ||
03142 rw->hasProperty(KSpreadCell::PVerticalText) ||
03143 rw->hasProperty(KSpreadCell::PMultiRow) ||
03144 rw->hasProperty(KSpreadCell::PAlignY) ||
03145 rw->hasProperty(KSpreadCell::PAlign) ||
03146 rw->hasProperty(KSpreadCell::PIndent) ) )
03147 {
03148 for ( int i = dlg->left; i <= dlg->right; ++i )
03149 {
03150 KSpreadCell * cell = dlg->getSheet()->nonDefaultCell( i, rw->row() );
03151 applyFormat( cell );
03152 }
03153 }
03154 }
03155 }
03156
03157 void CellFormatPagePosition::apply( RowFormat *_obj )
03158 {
03159 KSpreadFormat::Align ax;
03160 KSpreadFormat::AlignY ay;
03161
03162 if ( top->isChecked() )
03163 ay = KSpreadCell::Top;
03164 else if ( bottom->isChecked() )
03165 ay = KSpreadCell::Bottom;
03166 else if ( middle->isChecked() )
03167 ay = KSpreadCell::Middle;
03168 else
03169 ay = KSpreadCell::Middle;
03170
03171 if ( left->isChecked() )
03172 ax = KSpreadCell::Left;
03173 else if ( right->isChecked() )
03174 ax = KSpreadCell::Right;
03175 else if ( center->isChecked() )
03176 ax = KSpreadCell::Center;
03177 else if ( standard->isChecked() )
03178 ax = KSpreadCell::Undefined;
03179 else
03180 ax = KSpreadCell::Undefined;
03181
03182 KSpreadSheet* sheet = dlg->getSheet();
03183 KSpreadCell* c= NULL;
03184 for (int row = dlg->top; row <= dlg->bottom; row++)
03185 {
03186 for ( c = sheet->getFirstCellRow(row); c != NULL;
03187 c = sheet->getNextCellRight(c->column(), c->row()) )
03188 {
03189 if ( m_indent->isEnabled()
03190 && dlg->indent != KoUnit::fromUserValue( m_indent->value(),
03191 dlg->getDoc()->getUnit()) )
03192 {
03193 c->clearProperty(KSpreadCell::PIndent);
03194 c->clearNoFallBackProperties( KSpreadCell::PIndent );
03195 }
03196 if ( ax != dlg->alignX )
03197 {
03198 c->clearProperty(KSpreadCell::PAlign);
03199 c->clearNoFallBackProperties( KSpreadCell::PAlign );
03200 }
03201 if ( ay != dlg->alignY )
03202 {
03203 c->clearProperty(KSpreadCell::PAlignY);
03204 c->clearNoFallBackProperties( KSpreadCell::PAlignY );
03205 }
03206 if ( m_bOptionText)
03207 {
03208 c->clearProperty(KSpreadCell::PMultiRow);
03209 c->clearNoFallBackProperties( KSpreadCell::PMultiRow );
03210 }
03211 if ( m_bOptionText)
03212 {
03213 c->clearProperty(KSpreadCell::PVerticalText);
03214 c->clearNoFallBackProperties( KSpreadCell::PVerticalText );
03215 }
03216 if (dlg->textRotation!=angleRotation->value())
03217 {
03218 c->clearProperty(KSpreadCell::PAngle);
03219 c->clearNoFallBackProperties( KSpreadCell::PAngle );
03220 }
03221 }
03222 }
03223
03224 applyFormat( _obj );
03225 }
03226
03227
03228 void CellFormatPagePosition::apply( KSpreadCell *_obj )
03229 {
03230 applyFormat( _obj );
03231 }
03232
03233 void CellFormatPagePosition::applyFormat( KSpreadFormat * _obj )
03234 {
03235 KSpreadFormat::Align ax;
03236 KSpreadFormat::AlignY ay;
03237
03238 if ( top->isChecked() )
03239 ay = KSpreadCell::Top;
03240 else if ( bottom->isChecked() )
03241 ay = KSpreadCell::Bottom;
03242 else if ( middle->isChecked() )
03243 ay = KSpreadCell::Middle;
03244 else
03245 ay = KSpreadCell::Middle;
03246
03247 if ( left->isChecked() )
03248 ax = KSpreadCell::Left;
03249 else if ( right->isChecked() )
03250 ax = KSpreadCell::Right;
03251 else if ( center->isChecked() )
03252 ax = KSpreadCell::Center;
03253 else if ( standard->isChecked() )
03254 ax = KSpreadCell::Undefined;
03255 else
03256 ax = KSpreadCell::Undefined;
03257
03258 if ( top->isChecked() && ay != dlg->alignY )
03259 _obj->setAlignY( KSpreadCell::Top );
03260 else if ( bottom->isChecked() && ay != dlg->alignY )
03261 _obj->setAlignY( KSpreadCell::Bottom );
03262 else if ( middle->isChecked() && ay != dlg->alignY )
03263 _obj->setAlignY( KSpreadCell::Middle );
03264
03265 if ( left->isChecked() && ax != dlg->alignX )
03266 _obj->setAlign( KSpreadCell::Left );
03267 else if ( right->isChecked() && ax != dlg->alignX )
03268 _obj->setAlign( KSpreadCell::Right );
03269 else if ( center->isChecked() && ax != dlg->alignX )
03270 _obj->setAlign( KSpreadCell::Center );
03271 else if ( standard->isChecked() && ax != dlg->alignX )
03272 _obj->setAlign( KSpreadCell::Undefined );
03273
03274 if ( m_bOptionText )
03275 {
03276 if ( multi->isEnabled() )
03277 _obj->setMultiRow( multi->isChecked() );
03278 else
03279 _obj->setMultiRow( false );
03280 }
03281
03282 if ( m_bOptionText )
03283 {
03284 if ( vertical->isEnabled() )
03285 _obj->setVerticalText( vertical->isChecked() );
03286 else
03287 _obj->setVerticalText( false );
03288 }
03289
03290 if ( dlg->textRotation!=angleRotation->value() )
03291 _obj->setAngle( (-angleRotation->value() ) );
03292 if ( m_indent->isEnabled()
03293 && dlg->indent != KoUnit::fromUserValue( m_indent->value(),
03294 dlg->getDoc()->getUnit() ) )
03295 _obj->setIndent( KoUnit::fromUserValue( m_indent->value(),
03296 dlg->getDoc()->getUnit() ) );
03297 }
03298
03299 double CellFormatPagePosition::getSizeHeight()
03300 {
03301 if ( defaultHeight->isChecked() )
03302 return 20.0;
03303 else
03304 return KoUnit::fromUserValue( height->value(), dlg->getDoc()->getUnit() );
03305 }
03306
03307 double CellFormatPagePosition::getSizeWidth()
03308 {
03309 if ( defaultWidth->isChecked() )
03310 return 60.0;
03311 else
03312 return KoUnit::fromUserValue( width->value(), dlg->getDoc()->getUnit() );
03313 }
03314
03315 KSpreadBorderButton::KSpreadBorderButton( QWidget *parent, const char *_name ) : QPushButton(parent,_name)
03316 {
03317 penStyle = Qt::NoPen;
03318 penWidth = 1;
03319 penColor = colorGroup().text();
03320 setToggleButton( true );
03321 setOn( false);
03322 setChanged(false);
03323 }
03324 void KSpreadBorderButton::mousePressEvent( QMouseEvent * )
03325 {
03326
03327 this->setOn(!isOn());
03328 emit clicked( this );
03329 }
03330
03331 void KSpreadBorderButton::setUndefined()
03332 {
03333 setPenStyle(SolidLine );
03334 setPenWidth(1);
03335 setColor(colorGroup().midlight());
03336 }
03337
03338
03339 void KSpreadBorderButton::unselect()
03340 {
03341 setOn(false);
03342 setPenWidth(1);
03343 setPenStyle(Qt::NoPen);
03344 setColor( colorGroup().text() );
03345 setChanged(true);
03346 }
03347
03348 KSpreadBorder::KSpreadBorder( QWidget *parent, const char *_name,bool _oneCol, bool _oneRow )
03349 : QFrame( parent, _name )
03350 {
03351 oneCol=_oneCol;
03352 oneRow=_oneRow;
03353 }
03354
03355
03356 #define OFFSETX 5
03357 #define OFFSETY 5
03358 void KSpreadBorder::paintEvent( QPaintEvent *_ev )
03359 {
03360 QFrame::paintEvent( _ev );
03361 QPen pen;
03362 QPainter painter;
03363 painter.begin( this );
03364 pen=QPen( colorGroup().midlight(),2,SolidLine);
03365 painter.setPen( pen );
03366
03367 painter.drawLine( OFFSETX-5, OFFSETY, OFFSETX , OFFSETY );
03368 painter.drawLine( OFFSETX, OFFSETY-5, OFFSETX , OFFSETY );
03369 painter.drawLine( width()-OFFSETX, OFFSETY, width() , OFFSETY );
03370 painter.drawLine( width()-OFFSETX, OFFSETY-5, width()-OFFSETX , OFFSETY );
03371
03372 painter.drawLine( OFFSETX, height()-OFFSETY, OFFSETX , height() );
03373 painter.drawLine( OFFSETX-5, height()-OFFSETY, OFFSETX , height()-OFFSETY );
03374
03375 painter.drawLine( width()-OFFSETX, height()-OFFSETY, width() , height()-OFFSETY );
03376 painter.drawLine( width()-OFFSETX, height()-OFFSETY, width()-OFFSETX , height() );
03377 if (oneCol==false)
03378 {
03379 painter.drawLine( width()/2, OFFSETY-5, width()/2 , OFFSETY );
03380 painter.drawLine( width()/2-5, OFFSETY, width()/2+5 , OFFSETY );
03381 painter.drawLine( width()/2, height()-OFFSETY, width()/2 , height() );
03382 painter.drawLine( width()/2-5, height()-OFFSETY, width()/2+5 , height()-OFFSETY );
03383 }
03384 if (oneRow==false)
03385 {
03386 painter.drawLine( OFFSETX-5, height()/2, OFFSETX , height()/2 );
03387 painter.drawLine( OFFSETX, height()/2-5, OFFSETX , height()/2+5 );
03388 painter.drawLine( width()-OFFSETX, height()/2, width(), height()/2 );
03389 painter.drawLine( width()-OFFSETX, height()/2-5, width()-OFFSETX , height()/2+5 );
03390 }
03391 painter.end();
03392 emit redraw();
03393 }
03394
03395 void KSpreadBorder::mousePressEvent( QMouseEvent* _ev )
03396 {
03397 emit choosearea(_ev);
03398 }
03399
03400 CellFormatPageBorder::CellFormatPageBorder( QWidget* parent, CellFormatDlg *_dlg )
03401 : QWidget( parent ),
03402 dlg( _dlg )
03403 {
03404 sheet = dlg->getSheet();
03405
03406 InitializeGrids();
03407 InitializeBorderButtons();
03408 InitializePatterns();
03409 SetConnections();
03410
03411 preview->slotSelect();
03412 pattern[2]->slotSelect();
03413
03414 style->setEnabled(false);
03415 size->setEnabled(false);
03416 preview->setPattern( black , 1, SolidLine );
03417 this->resize( 400, 400 );
03418 }
03419
03420 void CellFormatPageBorder::InitializeGrids()
03421 {
03422 QGridLayout *grid = new QGridLayout(this,5,2,KDialog::marginHint(), KDialog::spacingHint());
03423 QGridLayout *grid2 = NULL;
03424 QGroupBox* tmpQGroupBox = NULL;
03425
03426
03427
03428 const char borderButtonNames[BorderType_END][20] =
03429 {"top", "bottom", "left", "right", "vertical", "fall", "go", "horizontal"};
03430
03431 const char shortcutButtonNames[BorderShortcutType_END][20] =
03432 {"remove", "all", "outline"};
03433
03434 QString borderButtonIconNames[BorderType_END] =
03435 {"border_top", "border_bottom", "border_left", "border_right",
03436 "border_vertical", "border_horizontal", "border_fall", "border_up"};
03437
03438 QString shortcutButtonIconNames[BorderShortcutType_END] =
03439 { "border_remove", "", "border_outline"};
03440
03441 int borderButtonPositions[BorderType_END][2] =
03442 {{0,2}, {4,2}, {2,0}, {2,4}, {4,4}, {4,0}, {0,0}, {0,4}};
03443
03444 int shortcutButtonPositions[BorderShortcutType_END][2] =
03445 { {0,0}, {0,1},{0,2} };
03446
03447
03448
03449 tmpQGroupBox = new QGroupBox( this, "GroupBox_1" );
03450 tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
03451 tmpQGroupBox->setTitle( i18n("Border") );
03452 tmpQGroupBox->setAlignment( AlignLeft );
03453 grid2 = new QGridLayout(tmpQGroupBox,6,5,KDialog::marginHint(), KDialog::spacingHint());
03454 int fHeight = tmpQGroupBox->fontMetrics().height();
03455 grid2->addRowSpacing( 0, fHeight/2 );
03456
03457 area=new KSpreadBorder(tmpQGroupBox,"area",dlg->oneCol,dlg->oneRow);
03458 grid2->addMultiCellWidget(area,2,4,1,3);
03459 area->setBackgroundColor( colorGroup().base() );
03460
03461
03462 for (int i=BorderType_Top; i < BorderType_END; i++)
03463 {
03464 borderButtons[i] = new KSpreadBorderButton(tmpQGroupBox,
03465 borderButtonNames[i]);
03466 loadIcon(borderButtonIconNames[i], borderButtons[i]);
03467 grid2->addWidget(borderButtons[i], borderButtonPositions[i][0] + 1,
03468 borderButtonPositions[i][1]);
03469 }
03470
03471 grid->addMultiCellWidget(tmpQGroupBox,0,2,0,0);
03472
03473
03474
03475
03476 tmpQGroupBox = new QGroupBox( this, "GroupBox_3" );
03477 tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
03478 tmpQGroupBox->setTitle( i18n("Preselect") );
03479 tmpQGroupBox->setAlignment( AlignLeft );
03480
03481 grid2 = new QGridLayout(tmpQGroupBox,1,3,KDialog::marginHint(), KDialog::spacingHint());
03482
03483
03484
03485 if ((dlg->oneRow==true)&&(dlg->oneCol==false))
03486 {
03487 shortcutButtonIconNames[BorderShortcutType_All] = "border_vertical";
03488 }
03489 else if ((dlg->oneRow==false)&&(dlg->oneCol==true))
03490 {
03491 shortcutButtonIconNames[BorderShortcutType_All] = "border_horizontal";
03492 }
03493 else
03494 {
03495 shortcutButtonIconNames[BorderShortcutType_All] = "border_inside";
03496 }
03497
03498 for (int i=BorderShortcutType_Remove; i < BorderShortcutType_END; i++)
03499 {
03500 shortcutButtons[i] = new KSpreadBorderButton(tmpQGroupBox,
03501 shortcutButtonNames[i]);
03502 loadIcon(shortcutButtonIconNames[i], shortcutButtons[i]);
03503 grid2->addWidget(shortcutButtons[i], shortcutButtonPositions[i][0],
03504 shortcutButtonPositions[i][1]);
03505 }
03506
03507 if (dlg->oneRow && dlg->oneCol)
03508 {
03509 shortcutButtons[BorderShortcutType_All]->setEnabled(false);
03510 }
03511
03512 grid->addMultiCellWidget(tmpQGroupBox,3,4,0,0);
03513
03514
03515 tmpQGroupBox = new QGroupBox( this, "GroupBox_10" );
03516 tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
03517 tmpQGroupBox->setTitle( i18n("Pattern") );
03518 tmpQGroupBox->setAlignment( AlignLeft );
03519
03520 grid2 = new QGridLayout(tmpQGroupBox,7,2,KDialog::marginHint(), KDialog::spacingHint());
03521 fHeight = tmpQGroupBox->fontMetrics().height();
03522 grid2->addRowSpacing( 0, fHeight/2 );
03523
03524 char name[] = "PatternXX";
03525 Q_ASSERT(NUM_BORDER_PATTERNS < 100);
03526
03527 for (int i=0; i < NUM_BORDER_PATTERNS; i++)
03528 {
03529 name[7] = '0' + (i+1) / 10;
03530 name[8] = '0' + (i+1) % 10;
03531 pattern[i] = new KSpreadPatternSelect( tmpQGroupBox, name );
03532 pattern[i]->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03533 grid2->addWidget(pattern[i], i % 5 + 1, i / 5);
03534
03535
03536
03537
03538
03539
03540
03541 }
03542
03543 color = new KColorButton (tmpQGroupBox, "PushButton_1" );
03544 grid2->addWidget(color,7,1);
03545
03546 QLabel *tmpQLabel = new QLabel( tmpQGroupBox, "Label_6" );
03547 tmpQLabel->setText( i18n("Color:") );
03548 grid2->addWidget(tmpQLabel,7,0);
03549
03550
03551 QGridLayout *grid3 = new QGridLayout( this, 2, 2, KDialog::marginHint(), KDialog::spacingHint() );
03552 customize = new QCheckBox(i18n("Customize"),tmpQGroupBox);
03553 grid3->addWidget(customize,0,0);
03554 connect( customize, SIGNAL( clicked()), SLOT(cutomize_chosen_slot()) );
03555
03556 size=new QComboBox(true,tmpQGroupBox);
03557 grid3->addWidget(size,1,1);
03558 size->setValidator(new KIntValidator( size ));
03559 QString tmp;
03560 for ( int i=0;i<10;i++)
03561 {
03562 tmp=tmp.setNum(i);
03563 size->insertItem(tmp);
03564 }
03565 size->setCurrentItem(1);
03566
03567 style=new QComboBox(tmpQGroupBox);
03568 grid3->addWidget(style,1,0);
03569 style->insertItem(paintFormatPixmap(DotLine),0 );
03570 style->insertItem(paintFormatPixmap(DashLine) ,1);
03571 style->insertItem(paintFormatPixmap(DashDotLine),2 );
03572 style->insertItem(paintFormatPixmap(DashDotDotLine),3 );
03573 style->insertItem(paintFormatPixmap(SolidLine),4);
03574 style->setBackgroundColor( colorGroup().background() );
03575
03576 grid2->addMultiCell(grid3,6,6,0,1);
03577 grid->addMultiCellWidget(tmpQGroupBox,0,3,1,1);
03578
03579
03580 tmpQGroupBox = new QGroupBox(this, "GroupBox_4" );
03581 tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
03582 tmpQGroupBox->setTitle( i18n("Preview") );
03583 tmpQGroupBox->setAlignment( AlignLeft );
03584
03585 grid2 = new QGridLayout(tmpQGroupBox,1,1,KDialog::marginHint(), KDialog::spacingHint());
03586 fHeight = tmpQGroupBox->fontMetrics().height();
03587 grid2->addRowSpacing( 0, fHeight/2 );
03588
03589 preview = new KSpreadPatternSelect( tmpQGroupBox, "Pattern_preview" );
03590 preview->setFrameStyle( QFrame::Panel | QFrame::Sunken );
03591 grid2->addWidget(preview,1,0);
03592
03593 grid->addWidget(tmpQGroupBox,4,1);
03594 }
03595
03596 void CellFormatPageBorder::InitializeBorderButtons()
03597 {
03598 for (int i=BorderType_Top; i < BorderType_END; i++)
03599 {
03600 if (dlg->borders[i].style != Qt::NoPen ||
03601 !dlg->borders[i].bStyle )
03602 {
03603
03604
03605 if ((dlg->oneRow == true && i == BorderType_Horizontal) ||
03606 (dlg->oneCol == true && i == BorderType_Vertical))
03607 {
03608 borderButtons[i]->setEnabled(false);
03609 }
03610 else if ( dlg->borders[i].bColor && dlg->borders[i].bStyle )
03611 {
03612 borderButtons[i]->setPenStyle(dlg->borders[i].style );
03613 borderButtons[i]->setPenWidth(dlg->borders[i].width);
03614 borderButtons[i]->setColor(dlg->borders[i].color);
03615 borderButtons[i]->setOn(true);
03616 }
03617 else
03618 {
03619 borderButtons[i]->setUndefined();
03620 }
03621 }
03622 }
03623
03624
03625 }
03626
03627 void CellFormatPageBorder::InitializePatterns()
03628 {
03629 pattern[0]->setPattern( black, 1, DotLine );
03630 pattern[1]->setPattern( black, 1, DashLine );
03631 pattern[2]->setPattern( black, 1, SolidLine );
03632 pattern[3]->setPattern( black, 1, DashDotLine );
03633 pattern[4]->setPattern( black, 1, DashDotDotLine );
03634 pattern[5]->setPattern( black, 2, SolidLine );
03635 pattern[6]->setPattern( black, 3, SolidLine );
03636 pattern[7]->setPattern( black, 4, SolidLine );
03637 pattern[8]->setPattern( black, 5, SolidLine );
03638 pattern[9]->setPattern( black, 1, NoPen );
03639
03640 slotSetColorButton( black );
03641 }
03642
03643 void CellFormatPageBorder::SetConnections()
03644 {
03645 connect( color, SIGNAL( changed( const QColor & ) ),
03646 this, SLOT( slotSetColorButton( const QColor & ) ) );
03647
03648 for (int i=0; i < NUM_BORDER_PATTERNS; i++)
03649 {
03650 connect( pattern[i], SIGNAL( clicked( KSpreadPatternSelect* ) ),
03651 this, SLOT( slotUnselect2( KSpreadPatternSelect* ) ) );
03652 }
03653
03654 for (int i = BorderType_Top; i < BorderType_END; i++)
03655 {
03656 connect( borderButtons[i], SIGNAL( clicked (KSpreadBorderButton *) ),
03657 this, SLOT( changeState( KSpreadBorderButton *) ) );
03658 }
03659
03660 for (int i = BorderShortcutType_Remove; i < BorderShortcutType_END; i++)
03661 {
03662 connect( shortcutButtons[i], SIGNAL( clicked(KSpreadBorderButton *) ),
03663 this, SLOT( preselect(KSpreadBorderButton *) ) );
03664 }
03665
03666 connect( area ,SIGNAL( redraw()),this,SLOT(draw()));
03667 connect( area ,SIGNAL( choosearea(QMouseEvent * )),
03668 this,SLOT( slotPressEvent(QMouseEvent *)));
03669
03670 connect( style, SIGNAL( activated(int)), this, SLOT(slotChangeStyle(int)));
03671 connect( size, SIGNAL( textChanged(const QString &)),
03672 this, SLOT(slotChangeStyle(const QString &)));
03673 connect( size ,SIGNAL( activated(int)), this, SLOT(slotChangeStyle(int)));
03674 }
03675
03676 void CellFormatPageBorder::cutomize_chosen_slot()
03677 {
03678 if ( customize->isChecked() )
03679 {
03680 style->setEnabled( true );
03681 size->setEnabled( true );
03682 slotUnselect2( preview );
03683 }
03684 else
03685 {
03686 style->setEnabled( false );
03687 size->setEnabled( false );
03688 pattern[2]->slotSelect();
03689 preview->setPattern( black , 1, SolidLine );
03690 }
03691 }
03692
03693 void CellFormatPageBorder::slotChangeStyle(const QString &)
03694 {
03695
03696 slotChangeStyle(0);
03697 }
03698
03699 void CellFormatPageBorder::slotChangeStyle(int)
03700 {
03701 int index = style->currentItem();
03702 QString tmp;
03703 int penSize = size->currentText().toInt();
03704 if ( !penSize)
03705 {
03706 preview->setPattern( preview->getColor(), penSize, NoPen );
03707 }
03708 else
03709 {
03710 switch(index)
03711 {
03712 case 0:
03713 preview->setPattern( preview->getColor(), penSize, DotLine );
03714 break;
03715 case 1:
03716 preview->setPattern( preview->getColor(), penSize, DashLine );
03717 break;
03718 case 2:
03719 preview->setPattern( preview->getColor(), penSize, DashDotLine );
03720 break;
03721 case 3:
03722 preview->setPattern( preview->getColor(), penSize, DashDotDotLine );
03723 break;
03724 case 4:
03725 preview->setPattern( preview->getColor(), penSize, SolidLine );
03726 break;
03727 default:
03728 kdDebug(36001)<<"Error in combobox\n";
03729 break;
03730 }
03731 }
03732 slotUnselect2(preview);
03733 }
03734
03735 QPixmap CellFormatPageBorder::paintFormatPixmap(PenStyle _style)
03736 {
03737 QPixmap pixmap( style->width(), 14 );
03738 QPainter painter;
03739 QPen pen;
03740 pen=QPen( colorGroup().text(),1,_style);
03741 painter.begin( &pixmap );
03742 painter.fillRect( 0, 0, style->width(), 14, colorGroup().background() );
03743 painter.setPen( pen );
03744 painter.drawLine( 0, 7, style->width(), 7 );
03745 painter.end();
03746 return pixmap;
03747 }
03748
03749 void CellFormatPageBorder::loadIcon( QString _pix, KSpreadBorderButton *_button)
03750 {
03751 _button->setPixmap( QPixmap( KSBarIcon(_pix) ) );
03752 }
03753
03754 void CellFormatPageBorder::applyOutline()
03755 {
03756 if (borderButtons[BorderType_Horizontal]->isChanged())
03757 applyHorizontalOutline();
03758
03759 if (borderButtons[BorderType_Vertical]->isChanged())
03760 applyVerticalOutline();
03761
03762 if ( borderButtons[BorderType_Left]->isChanged() )
03763 applyLeftOutline();
03764
03765 if ( borderButtons[BorderType_Right]->isChanged() )
03766 applyRightOutline();
03767
03768 if ( borderButtons[BorderType_Top]->isChanged() )
03769 applyTopOutline();
03770
03771 if ( borderButtons[BorderType_Bottom]->isChanged() )
03772 applyBottomOutline();
03773
03774 if ( borderButtons[BorderType_RisingDiagonal]->isChanged() ||
03775 borderButtons[BorderType_FallingDiagonal]->isChanged() )
03776 applyDiagonalOutline();
03777 }
03778
03779 void CellFormatPageBorder::applyTopOutline()
03780 {
03781 KSpreadBorderButton * top = borderButtons[BorderType_Top];
03782
03783 QPen tmpPen( top->getColor(), top->getPenWidth(), top->getPenStyle());
03784
03785 if ( dlg->getStyle() )
03786 {
03787 dlg->getStyle()->changeTopBorderPen( tmpPen );
03788 }
03789 else if ( !dlg->isRowSelected )
03790 {
03791
03792
03793
03794 for ( int x = dlg->left; x <= dlg->right; x++ )
03795 {
03796 KSpreadCell *obj = dlg->getSheet()->nonDefaultCell( x, dlg->top );
03797 if ( obj->isObscuringForced() )
03798 obj = obj->obscuringCells().first();
03799 obj->setTopBorderPen( tmpPen );
03800 }
03801 }
03802 else if ( dlg->isRowSelected )
03803 {
03804 KSpreadCell* c = NULL;
03805 for ( c = sheet->getFirstCellRow(dlg->top); c != NULL;
03806 c = sheet->getNextCellRight(c->column(), c->row()) )
03807 {
03808 c->clearProperty(KSpreadCell::PTopBorder);
03809 c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
03810 }
03811
03812 RowFormat *obj=dlg->getSheet()->nonDefaultRowFormat(dlg->top-1);
03813 obj->setBottomBorderPen( tmpPen );
03814 }
03815 }
03816
03817 void CellFormatPageBorder::applyBottomOutline()
03818 {
03819 KSpreadSheet * sheet = dlg->getSheet();
03820 KSpreadBorderButton * bottom = borderButtons[BorderType_Bottom];
03821
03822 QPen tmpPen( bottom->getColor(), bottom->getPenWidth(), bottom->getPenStyle() );
03823
03824 if ( dlg->getStyle() )
03825 dlg->getStyle()->changeBottomBorderPen( tmpPen );
03826 else if ( !dlg->isRowSelected && !dlg->isColumnSelected )
03827 {
03828 for ( int x = dlg->left; x <= dlg->right; x++ )
03829 {
03830 KSpreadCell *obj = dlg->getSheet()->nonDefaultCell( x, dlg->bottom );
03831 if ( obj->isObscuringForced() )
03832 obj = obj->obscuringCells().first();
03833 obj->setBottomBorderPen( tmpPen );
03834 }
03835 }
03836 else if ( dlg->isRowSelected )
03837 {
03838 KSpreadCell* c = NULL;
03839 for ( c = sheet->getFirstCellRow(dlg->bottom); c != NULL;
03840 c = sheet->getNextCellRight(c->column(), c->row()) )
03841 {
03842 c->clearProperty(KSpreadCell::PBottomBorder);
03843 c->clearNoFallBackProperties( KSpreadCell::PBottomBorder );
03844 }
03845
03846 RowFormat *obj=dlg->getSheet()->nonDefaultRowFormat(dlg->bottom);
03847 obj->setBottomBorderPen( tmpPen );
03848 }
03849 }
03850
03851 void CellFormatPageBorder::applyLeftOutline()
03852 {
03853 KSpreadBorderButton * left = borderButtons[BorderType_Left];
03854 QPen tmpPen( left->getColor(), left->getPenWidth(), left->getPenStyle() );
03855
03856 if ( dlg->getStyle() )
03857 dlg->getStyle()->changeLeftBorderPen( tmpPen );
03858 else if ( !dlg->isColumnSelected )
03859 {
03860 for ( int y = dlg->top; y <= dlg->bottom; y++ )
03861 {
03862 KSpreadCell *obj = dlg->getSheet()->nonDefaultCell( dlg->left, y );
03863 if ( obj->isObscuringForced() )
03864 continue;
03865 obj->setLeftBorderPen( tmpPen );
03866 }
03867 }
03868 else
03869 {
03870 KSpreadCell* c = NULL;
03871 for ( c = sheet->getFirstCellColumn(dlg->left); c != NULL;
03872 c = sheet->getNextCellDown(c->column(), c->row()) )
03873 {
03874 c->clearProperty(KSpreadCell::PLeftBorder);
03875 c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
03876 }
03877 ColumnFormat *obj=dlg->getSheet()->nonDefaultColumnFormat(dlg->left);
03878 obj->setLeftBorderPen( tmpPen );
03879
03880 RowFormat* rw =dlg->getSheet()->firstRow();
03881 for ( ; rw; rw = rw->next() )
03882 {
03883 if (rw->row()==dlg->left&& !rw->isDefault() &&
03884 (rw->hasProperty(KSpreadCell::PLeftBorder) ))
03885 {
03886 for ( int i=dlg->left;i<=dlg->right;i++)
03887 {
03888 KSpreadCell *cell =
03889 dlg->getSheet()->nonDefaultCell( i, rw->row() );
03890 if ( cell->isObscuringForced() && dlg->isSingleCell() )
03891 continue;
03892 cell->setLeftBorderPen( tmpPen );
03893 }
03894 }
03895 }
03896 }
03897 }
03898
03899 void CellFormatPageBorder::applyRightOutline()
03900 {
03901 KSpreadBorderButton* right = borderButtons[BorderType_Right];
03902 QPen tmpPen( right->getColor(), right->getPenWidth(), right->getPenStyle() );
03903
03904 if ( dlg->getStyle() )
03905 dlg->getStyle()->changeRightBorderPen( tmpPen );
03906 else if ( (!dlg->isRowSelected) && (!dlg->isColumnSelected) )
03907 {
03908 for ( int y = dlg->top; y <= dlg->bottom; y++ )
03909 {
03910 KSpreadCell * obj = dlg->getSheet()->nonDefaultCell( dlg->right, y );
03911 if ( obj->isObscuringForced() )
03912 obj = obj->obscuringCells().first();
03913 obj->setRightBorderPen( tmpPen );
03914 }
03915 }
03916 else if ( dlg->isColumnSelected )
03917 {
03918 KSpreadCell* c = NULL;
03919 for ( c = sheet->getFirstCellColumn(dlg->right); c != NULL;
03920 c = sheet->getNextCellDown(c->column(), c->row()) )
03921 {
03922 c->clearProperty(KSpreadCell::PRightBorder);
03923 c->clearNoFallBackProperties( KSpreadCell::PRightBorder );
03924 }
03925
03926 ColumnFormat *obj=dlg->getSheet()->nonDefaultColumnFormat(dlg->right);
03927 obj->setRightBorderPen(tmpPen);
03928
03929 RowFormat* rw =dlg->getSheet()->firstRow();
03930 for ( ; rw; rw = rw->next() )
03931 {
03932 if (rw->row()==dlg->right&& !rw->isDefault() &&
03933 (rw->hasProperty(KSpreadCell::PRightBorder) ))
03934 {
03935 for ( int i=dlg->left;i<=dlg->right;i++)
03936 {
03937 KSpreadCell *cell =
03938 dlg->getSheet()->nonDefaultCell( i, rw->row() );
03939 if ( cell->isObscuringForced() )
03940 cell = cell->obscuringCells().first();
03941 cell->setRightBorderPen( tmpPen );
03942 }
03943 }
03944 }
03945 }
03946 }
03947
03948 void CellFormatPageBorder::applyDiagonalOutline()
03949 {
03950 KSpreadBorderButton * fallDiagonal = borderButtons[BorderType_FallingDiagonal];
03951 KSpreadBorderButton * goUpDiagonal = borderButtons[BorderType_RisingDiagonal];
03952 QPen tmpPenFall( fallDiagonal->getColor(), fallDiagonal->getPenWidth(),
03953 fallDiagonal->getPenStyle());
03954 QPen tmpPenGoUp( goUpDiagonal->getColor(), goUpDiagonal->getPenWidth(),
03955 goUpDiagonal->getPenStyle());
03956
03957 if ( dlg->getStyle() )
03958 {
03959 if ( fallDiagonal->isChanged() )
03960 dlg->getStyle()->changeFallBorderPen( tmpPenFall );
03961 if ( goUpDiagonal->isChanged() )
03962 dlg->getStyle()->changeGoUpBorderPen( tmpPenGoUp );
03963 }
03964 else if ( (!dlg->isRowSelected) && (!dlg->isColumnSelected) )
03965 {
03966 for ( int x = dlg->left; x <= dlg->right; x++ )
03967 {
03968 for ( int y = dlg->top; y <= dlg->bottom; y++ )
03969 {
03970 KSpreadCell *obj = dlg->getSheet()->nonDefaultCell( x, y );
03971 if ( fallDiagonal->isChanged() )
03972 obj->setFallDiagonalPen( tmpPenFall );
03973 if ( goUpDiagonal->isChanged() )
03974 obj->setGoUpDiagonalPen( tmpPenGoUp );
03975 }
03976 }
03977 }
03978 else if ( dlg->isColumnSelected )
03979 {
03980 KSpreadCell* c = NULL;
03981 for (int col = dlg->left; col <= dlg->right; col++)
03982 {
03983 for (c = sheet->getFirstCellColumn(col); c != NULL;
03984 c = sheet->getNextCellDown(c->column(), c->row()))
03985 {
03986 if ( fallDiagonal->isChanged() )
03987 {
03988 c->clearProperty(KSpreadCell::PFallDiagonal);
03989 c->clearNoFallBackProperties( KSpreadCell::PFallDiagonal );
03990 }
03991 if ( goUpDiagonal->isChanged() )
03992 {
03993 c->clearProperty(KSpreadCell::PGoUpDiagonal);
03994 c->clearNoFallBackProperties( KSpreadCell::PGoUpDiagonal);
03995 }
03996 }
03997
03998 ColumnFormat *obj=dlg->getSheet()->nonDefaultColumnFormat(col);
03999 if ( fallDiagonal->isChanged() )
04000 obj->setFallDiagonalPen( tmpPenFall );
04001 if ( goUpDiagonal->isChanged() )
04002 obj->setGoUpDiagonalPen( tmpPenGoUp );
04003 }
04004
04005
04006 RowFormat* rw =dlg->getSheet()->firstRow();
04007 for ( ; rw; rw = rw->next() )
04008 {
04009 if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PFallDiagonal)
04010 ||rw->hasProperty(KSpreadCell::PGoUpDiagonal) ))
04011 {
04012 for ( int i=dlg->left;i<=dlg->right;i++)
04013 {
04014 KSpreadCell *cell =
04015 dlg->getSheet()->nonDefaultCell( i, rw->row() );
04016 if ( cell->isObscuringForced() && dlg->isSingleCell() )
04017 continue;
04018 cell->setFallDiagonalPen( tmpPenFall );
04019 cell->setGoUpDiagonalPen( tmpPenGoUp );
04020 }
04021 }
04022 }
04023 }
04024 else if ( dlg->isRowSelected )
04025 {
04026 KSpreadCell* c = NULL;
04027 for (int row = dlg->top; row <= dlg->bottom; row++)
04028 {
04029 for (c = sheet->getFirstCellRow(row); c != NULL;
04030 c = sheet->getNextCellRight(c->column(), c->row()))
04031 {
04032 if ( fallDiagonal->isChanged() )
04033 {
04034 c->clearProperty(KSpreadCell::PFallDiagonal);
04035 c->clearNoFallBackProperties( KSpreadCell::PFallDiagonal );
04036 }
04037 if ( goUpDiagonal->isChanged() )
04038 {
04039 c->clearProperty(KSpreadCell::PGoUpDiagonal);
04040 c->clearNoFallBackProperties( KSpreadCell::PGoUpDiagonal);
04041 }
04042 }
04043
04044 RowFormat *obj=dlg->getSheet()->nonDefaultRowFormat(row);
04045 if ( fallDiagonal->isChanged() )
04046 obj->setFallDiagonalPen( tmpPenFall );
04047 if ( goUpDiagonal->isChanged() )
04048 obj->setGoUpDiagonalPen( tmpPenGoUp );
04049 }
04050 }
04051 }
04052
04053 void CellFormatPageBorder::applyHorizontalOutline()
04054 {
04055 QPen tmpPen( borderButtons[BorderType_Horizontal]->getColor(),
04056 borderButtons[BorderType_Horizontal]->getPenWidth(),
04057 borderButtons[BorderType_Horizontal]->getPenStyle());
04058
04059 if ( dlg->getStyle() )
04060 {
04061 dlg->getStyle()->changeTopBorderPen( tmpPen );
04062 }
04063 else if ( (!dlg->isRowSelected) && (!dlg->isColumnSelected) )
04064 {
04065 for ( int x = dlg->left; x <= dlg->right; x++ )
04066 {
04067 for ( int y = dlg->top + 1; y <= dlg->bottom; y++ )
04068 {
04069 KSpreadCell * obj = dlg->getSheet()->nonDefaultCell( x, y );
04070 obj->setTopBorderPen( tmpPen );
04071 }
04072 }
04073 }
04074 else if ( dlg->isColumnSelected )
04075 {
04076 KSpreadCell* c = NULL;
04077 for (int col = dlg->left; col <= dlg->right; col++)
04078 {
04079 for (c = sheet->getFirstCellColumn(col); c != NULL;
04080 c = sheet->getNextCellDown(c->column(), c->row()))
04081 {
04082 c->clearProperty(KSpreadCell::PTopBorder);
04083 c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
04084 }
04085
04086 ColumnFormat *obj=dlg->getSheet()->nonDefaultColumnFormat(col);
04087 obj->setTopBorderPen(tmpPen);
04088 }
04089
04090 RowFormat* rw =dlg->getSheet()->firstRow();
04091 for ( ; rw; rw = rw->next() )
04092 {
04093 if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PTopBorder) ))
04094 {
04095 for ( int i=dlg->left;i<=dlg->right;i++)
04096 {
04097 KSpreadCell *cell =
04098 dlg->getSheet()->nonDefaultCell( i, rw->row() );
04099 cell->setTopBorderPen(tmpPen);
04100 }
04101 }
04102 }
04103 }
04104 else if ( dlg->isRowSelected )
04105 {
04106 KSpreadCell* c = NULL;
04107 for (int row = dlg->top + 1; row <= dlg->bottom; row++)
04108 {
04109 for (c = sheet->getFirstCellRow(row); c != NULL;
04110 c = sheet->getNextCellRight(c->column(), c->row()))
04111 {
04112 c->clearProperty(KSpreadCell::PTopBorder);
04113 c->clearNoFallBackProperties( KSpreadCell::PTopBorder );
04114 }
04115
04116 RowFormat *obj = dlg->getSheet()->nonDefaultRowFormat(row);
04117 obj->setTopBorderPen(tmpPen);
04118 }
04119 }
04120 }
04121
04122 void CellFormatPageBorder::applyVerticalOutline()
04123 {
04124 KSpreadBorderButton* vertical = borderButtons[BorderType_Vertical];
04125 QPen tmpPen( vertical->getColor(), vertical->getPenWidth(),
04126 vertical->getPenStyle());
04127
04128 if ( dlg->getStyle() )
04129 dlg->getStyle()->changeLeftBorderPen( tmpPen );
04130 else if ( (!dlg->isRowSelected) && (!dlg->isColumnSelected) )
04131 {
04132 for ( int x = dlg->left+1; x <= dlg->right; x++ )
04133 {
04134 for ( int y = dlg->top; y <= dlg->bottom; y++ )
04135 {
04136 KSpreadCell *obj = dlg->getSheet()->nonDefaultCell( x, y );
04137 obj->setLeftBorderPen( tmpPen );
04138 }
04139 }
04140 }
04141 else if ( dlg->isColumnSelected )
04142 {
04143 KSpreadCell* c = NULL;
04144 for (int col = dlg->left + 1; col <= dlg->right; ++col)
04145 {
04146 for (c = sheet->getFirstCellColumn(col); c != NULL;
04147 c = sheet->getNextCellDown(c->column(), c->row()))
04148 {
04149 c->clearProperty(KSpreadCell::PLeftBorder);
04150 c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
04151 }
04152 ColumnFormat *obj=dlg->getSheet()->nonDefaultColumnFormat(col);
04153 obj->setLeftBorderPen( tmpPen );
04154 }
04155
04156 RowFormat * rw = dlg->getSheet()->firstRow();
04157 for ( ; rw; rw = rw->next() )
04158 {
04159 if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PLeftBorder) ))
04160 {
04161 for ( int i = dlg->left + 1; i <= dlg->right; ++i )
04162 {
04163 KSpreadCell * cell =
04164 dlg->getSheet()->nonDefaultCell( i, rw->row() );
04165 cell->setLeftBorderPen( tmpPen );
04166 }
04167 }
04168 }
04169 }
04170 else if ( dlg->isRowSelected )
04171 {
04172 KSpreadCell* c = NULL;
04173 for (int row = dlg->top; row <= dlg->bottom; row++)
04174 {
04175 for (c = sheet->getFirstCellRow(row); c != NULL;
04176 c = sheet->getNextCellRight(c->column(), c->row()))
04177 {
04178 c->clearProperty(KSpreadCell::PLeftBorder);
04179 c->clearNoFallBackProperties( KSpreadCell::PLeftBorder );
04180 }
04181 RowFormat *obj=dlg->getSheet()->nonDefaultRowFormat(row);
04182 obj->setLeftBorderPen( tmpPen );
04183 }
04184 }
04185 }
04186
04187
04188 void CellFormatPageBorder::slotSetColorButton( const QColor &_color )
04189 {
04190 currentColor = _color;
04191
04192 for ( int i = 0; i < NUM_BORDER_PATTERNS; ++i )
04193 {
04194 pattern[i]->setColor( currentColor );
04195 }
04196 preview->setColor( currentColor );
04197 }
04198
04199 void CellFormatPageBorder::slotUnselect2( KSpreadPatternSelect *_p )
04200 {
04201 for ( int i = 0; i < NUM_BORDER_PATTERNS; ++i )
04202 {
04203 if ( pattern[i] != _p )
04204 {
04205 pattern[i]->slotUnselect();
04206 }
04207 }
04208 preview->setPattern( _p->getColor(), _p->getPenWidth(), _p->getPenStyle() );
04209 }
04210
04211 void CellFormatPageBorder::preselect( KSpreadBorderButton *_p )
04212 {
04213 KSpreadBorderButton* top = borderButtons[BorderType_Top];
04214 KSpreadBorderButton* bottom = borderButtons[BorderType_Bottom];
04215 KSpreadBorderButton* left = borderButtons[BorderType_Left];
04216 KSpreadBorderButton* right = borderButtons[BorderType_Right];
04217 KSpreadBorderButton* vertical = borderButtons[BorderType_Vertical];
04218 KSpreadBorderButton* horizontal = borderButtons[BorderType_Horizontal];
04219 KSpreadBorderButton* remove = shortcutButtons[BorderShortcutType_Remove];
04220 KSpreadBorderButton* outline = shortcutButtons[BorderShortcutType_Outline];
04221 KSpreadBorderButton* all = shortcutButtons[BorderShortcutType_All];
04222
04223 _p->setOn(false);
04224 if (_p == remove)
04225 {
04226 for (int i=BorderType_Top; i < BorderType_END; i++)
04227 {
04228 if (borderButtons[i]->isOn())
04229 {
04230 borderButtons[i]->unselect();
04231 }
04232 }
04233 }
04234 if (_p==outline)
04235 {
04236 top->setOn(true);
04237 top->setPenWidth(preview->getPenWidth());
04238 top->setPenStyle(preview->getPenStyle());
04239 top->setColor( currentColor );
04240 top->setChanged(true);
04241 bottom->setOn(true);
04242 bottom->setPenWidth(preview->getPenWidth());
04243 bottom->setPenStyle(preview->getPenStyle());
04244 bottom->setColor( currentColor );
04245 bottom->setChanged(true);
04246 left->setOn(true);
04247 left->setPenWidth(preview->getPenWidth());
04248 left->setPenStyle(preview->getPenStyle());
04249 left->setColor( currentColor );
04250 left->setChanged(true);
04251 right->setOn(true);
04252 right->setPenWidth(preview->getPenWidth());
04253 right->setPenStyle(preview->getPenStyle());
04254 right->setColor( currentColor );
04255 right->setChanged(true);
04256 }
04257 if (_p==all)
04258 {
04259 if (dlg->oneRow==false)
04260 {
04261 horizontal->setOn(true);
04262 horizontal->setPenWidth(preview->getPenWidth());
04263 horizontal->setPenStyle(preview->getPenStyle());
04264 horizontal->setColor( currentColor );
04265 horizontal->setChanged(true);
04266 }
04267 if (dlg->oneCol==false)
04268 {
04269 vertical->setOn(true);
04270 vertical->setPenWidth(preview->getPenWidth());
04271 vertical->setPenStyle(preview->getPenStyle());
04272 vertical->setColor( currentColor );
04273 vertical->setChanged(true);
04274 }
04275 }
04276 area->repaint();
04277 }
04278
04279 void CellFormatPageBorder::changeState( KSpreadBorderButton *_p)
04280 {
04281 _p->setChanged(true);
04282
04283 if (_p->isOn())
04284 {
04285 _p->setPenWidth(preview->getPenWidth());
04286 _p->setPenStyle(preview->getPenStyle());
04287 _p->setColor( currentColor );
04288 }
04289 else
04290 {
04291 _p->setPenWidth(1);
04292 _p->setPenStyle(Qt::NoPen);
04293 _p->setColor( colorGroup().text() );
04294 }
04295
04296 area->repaint();
04297 }
04298
04299 void CellFormatPageBorder::draw()
04300 {
04301 KSpreadBorderButton* top = borderButtons[BorderType_Top];
04302 KSpreadBorderButton* bottom = borderButtons[BorderType_Bottom];
04303 KSpreadBorderButton* left = borderButtons[BorderType_Left];
04304 KSpreadBorderButton* right = borderButtons[BorderType_Right];
04305 KSpreadBorderButton* risingDiagonal = borderButtons[BorderType_RisingDiagonal];
04306 KSpreadBorderButton* fallingDiagonal = borderButtons[BorderType_FallingDiagonal];
04307 KSpreadBorderButton* vertical = borderButtons[BorderType_Vertical];
04308 KSpreadBorderButton* horizontal = borderButtons[BorderType_Horizontal];
04309 QPen pen;
04310 QPainter painter;
04311 painter.begin( area );
04312
04313 if ((bottom->getPenStyle())!=Qt::NoPen)
04314 {
04315 pen=QPen( bottom->getColor(), bottom->getPenWidth(),bottom->getPenStyle());
04316 painter.setPen( pen );
04317 painter.drawLine( OFFSETX, area->height()-OFFSETY, area->width()-OFFSETX , area->height()-OFFSETY );
04318 }
04319 if ((top->getPenStyle())!=Qt::NoPen)
04320 {
04321 pen=QPen( top->getColor(), top->getPenWidth(),top->getPenStyle());
04322 painter.setPen( pen );
04323 painter.drawLine( OFFSETX, OFFSETY, area->width() -OFFSETX, OFFSETY );
04324 }
04325 if ((left->getPenStyle())!=Qt::NoPen)
04326 {
04327 pen=QPen( left->getColor(), left->getPenWidth(),left->getPenStyle());
04328 painter.setPen( pen );
04329 painter.drawLine( OFFSETX, OFFSETY, OFFSETX , area->height()-OFFSETY );
04330 }
04331 if ((right->getPenStyle())!=Qt::NoPen)
04332 {
04333 pen=QPen( right->getColor(), right->getPenWidth(),right->getPenStyle());
04334 painter.setPen( pen );
04335 painter.drawLine( area->width()-OFFSETX, OFFSETY, area->width()-OFFSETX,
04336 area->height()-OFFSETY );
04337
04338 }
04339 if ((fallingDiagonal->getPenStyle())!=Qt::NoPen)
04340 {
04341 pen=QPen( fallingDiagonal->getColor(), fallingDiagonal->getPenWidth(),
04342 fallingDiagonal->getPenStyle());
04343 painter.setPen( pen );
04344 painter.drawLine( OFFSETX, OFFSETY, area->width()-OFFSETX,
04345 area->height()-OFFSETY );
04346 if (dlg->oneCol==false&& dlg->oneRow==false)
04347 {
04348 painter.drawLine( area->width()/2, OFFSETY, area->width()-OFFSETX,
04349 area->height()/2 );
04350 painter.drawLine( OFFSETX,area->height()/2 , area->width()/2,
04351 area->height()-OFFSETY );
04352 }
04353 }
04354 if ((risingDiagonal->getPenStyle())!=Qt::NoPen)
04355 {
04356 pen=QPen( risingDiagonal->getColor(), risingDiagonal->getPenWidth(),
04357 risingDiagonal->getPenStyle());
04358 painter.setPen( pen );
04359 painter.drawLine( OFFSETX, area->height()-OFFSETY , area->width()-OFFSETX ,
04360 OFFSETY );
04361 if (dlg->oneCol==false&& dlg->oneRow==false)
04362 {
04363 painter.drawLine( area->width()/2, OFFSETY, OFFSETX, area->height()/2 );
04364 painter.drawLine( area->width()/2,area->height()-OFFSETY ,
04365 area->width()-OFFSETX, area->height()/2 );
04366 }
04367
04368 }
04369 if ((vertical->getPenStyle())!=Qt::NoPen)
04370 {
04371 pen=QPen( vertical->getColor(), vertical->getPenWidth(),
04372 vertical->getPenStyle());
04373 painter.setPen( pen );
04374 painter.drawLine( area->width()/2, 5 , area->width()/2 , area->height()-5 );
04375 }
04376 if ((horizontal->getPenStyle())!=Qt::NoPen)
04377 {
04378 pen=QPen( horizontal->getColor(), horizontal->getPenWidth(),
04379 horizontal->getPenStyle());
04380 painter.setPen( pen );
04381 painter.drawLine( OFFSETX,area->height()/2,area->width()-OFFSETX,
04382 area->height()/2 );
04383 }
04384 painter.end();
04385 }
04386
04387 void CellFormatPageBorder::invertState(KSpreadBorderButton *_p)
04388 {
04389 if (_p->isOn())
04390 {
04391 _p->unselect();
04392 }
04393 else
04394 {
04395 _p->setOn(true);
04396 _p->setPenWidth(preview->getPenWidth());
04397 _p->setPenStyle(preview->getPenStyle());
04398 _p->setColor( currentColor );
04399 _p->setChanged(true);
04400 }
04401 }
04402
04403 void CellFormatPageBorder::slotPressEvent(QMouseEvent *_ev)
04404 {
04405 KSpreadBorderButton* top = borderButtons[BorderType_Top];
04406 KSpreadBorderButton* bottom = borderButtons[BorderType_Bottom];
04407 KSpreadBorderButton* left = borderButtons[BorderType_Left];
04408 KSpreadBorderButton* right = borderButtons[BorderType_Right];
04409 KSpreadBorderButton* vertical = borderButtons[BorderType_Vertical];
04410 KSpreadBorderButton* horizontal = borderButtons[BorderType_Horizontal];
04411
04412
04413 QRect rect(OFFSETX,OFFSETY-8,area->width()-OFFSETX,OFFSETY+8);
04414 if (rect.contains(QPoint(_ev->x(),_ev->y())))
04415 {
04416 if (((top->getPenWidth()!=preview->getPenWidth()) ||
04417 (top->getColor()!=currentColor) ||
04418 (top->getPenStyle()!=preview->getPenStyle()))
04419 && top->isOn())
04420 {
04421 top->setPenWidth(preview->getPenWidth());
04422 top->setPenStyle(preview->getPenStyle());
04423 top->setColor( currentColor );
04424 top->setChanged(true);
04425 }
04426 else
04427 invertState(top);
04428 }
04429 rect.setCoords(OFFSETX,area->height()-OFFSETY-8,area->width()-OFFSETX,
04430 area->height()-OFFSETY+8);
04431 if (rect.contains(QPoint(_ev->x(),_ev->y())))
04432 {
04433 if (((bottom->getPenWidth()!=preview->getPenWidth()) ||
04434 (bottom->getColor()!=currentColor) ||
04435 (bottom->getPenStyle()!=preview->getPenStyle()))
04436 && bottom->isOn())
04437 {
04438 bottom->setPenWidth(preview->getPenWidth());
04439 bottom->setPenStyle(preview->getPenStyle());
04440 bottom->setColor( currentColor );
04441 bottom->setChanged(true);
04442 }
04443 else
04444 invertState(bottom);
04445 }
04446
04447 rect.setCoords(OFFSETX-8,OFFSETY,OFFSETX+8,area->height()-OFFSETY);
04448 if (rect.contains(QPoint(_ev->x(),_ev->y())))
04449 {
04450 if (((left->getPenWidth()!=preview->getPenWidth()) ||
04451 (left->getColor()!=currentColor) ||
04452 (left->getPenStyle()!=preview->getPenStyle()))
04453 && left->isOn())
04454 {
04455 left->setPenWidth(preview->getPenWidth());
04456 left->setPenStyle(preview->getPenStyle());
04457 left->setColor( currentColor );
04458 left->setChanged(true);
04459 }
04460 else
04461 invertState(left);
04462 }
04463 rect.setCoords(area->width()-OFFSETX-8,OFFSETY,area->width()-OFFSETX+8,
04464 area->height()-OFFSETY);
04465 if (rect.contains(QPoint(_ev->x(),_ev->y())))
04466 {
04467 if (((right->getPenWidth()!=preview->getPenWidth()) ||
04468 (right->getColor()!=currentColor) ||
04469 (right->getPenStyle()!=preview->getPenStyle()))
04470 && right->isOn())
04471 {
04472 right->setPenWidth(preview->getPenWidth());
04473 right->setPenStyle(preview->getPenStyle());
04474 right->setColor( currentColor );
04475 right->setChanged(true);
04476 }
04477 else
04478 invertState(right);
04479 }
04480
04481
04482
04483
04484
04485
04486
04487
04488
04489
04490
04491
04492
04493
04494 if (dlg->oneCol==false)
04495 {
04496 rect.setCoords(area->width()/2-8,OFFSETY,area->width()/2+8,
04497 area->height()-OFFSETY);
04498
04499 if (rect.contains(QPoint(_ev->x(),_ev->y())))
04500 {
04501 if (((vertical->getPenWidth()!=preview->getPenWidth()) ||
04502 (vertical->getColor()!=currentColor) ||
04503 (vertical->getPenStyle()!=preview->getPenStyle()))
04504 && vertical->isOn())
04505 {
04506 vertical->setPenWidth(preview->getPenWidth());
04507 vertical->setPenStyle(preview->getPenStyle());
04508 vertical->setColor( currentColor );
04509 vertical->setChanged(true);
04510 }
04511 else
04512 invertState(vertical);
04513 }
04514 }
04515 if (dlg->oneRow==false)
04516 {
04517 rect.setCoords(OFFSETX,area->height()/2-8,area->width()-OFFSETX,
04518 area->height()/2+8);
04519 if (rect.contains(QPoint(_ev->x(),_ev->y())))
04520 {
04521 if (((horizontal->getPenWidth()!=preview->getPenWidth()) ||
04522 (horizontal->getColor()!=currentColor) ||
04523 (horizontal->getPenStyle()!=preview->getPenStyle()))
04524 && horizontal->isOn())
04525 {
04526 horizontal->setPenWidth(preview->getPenWidth());
04527 horizontal->setPenStyle(preview->getPenStyle());
04528 horizontal->setColor( currentColor );
04529 horizontal->setChanged(true);
04530 }
04531 else
04532 invertState(horizontal);
04533 }
04534 }
04535
04536 area->repaint();
04537 }
04538
04539 KSpreadBrushSelect::KSpreadBrushSelect( QWidget *parent, const char * ) : QFrame( parent )
04540 {
04541 brushStyle = Qt::NoBrush;
04542 brushColor = Qt::red;
04543 selected = false;
04544 }
04545
04546 void KSpreadBrushSelect::setPattern( const QColor &_color,BrushStyle _style )
04547 {
04548 brushStyle = _style;
04549 brushColor = _color;
04550 repaint();
04551 }
04552
04553
04554 void KSpreadBrushSelect::paintEvent( QPaintEvent *_ev )
04555 {
04556 QFrame::paintEvent( _ev );
04557
04558 QPainter painter;
04559 QBrush brush(brushColor,brushStyle);
04560 painter.begin( this );
04561 painter.setPen( Qt::NoPen );
04562 painter.setBrush( brush);
04563 painter.drawRect( 2, 2, width()-4, height()-4);
04564 painter.end();
04565 }
04566
04567 void KSpreadBrushSelect::mousePressEvent( QMouseEvent * )
04568 {
04569 slotSelect();
04570
04571 emit clicked( this );
04572 }
04573
04574 void KSpreadBrushSelect::slotUnselect()
04575 {
04576 selected = false;
04577
04578 setLineWidth( 1 );
04579 setFrameStyle( QFrame::Panel | QFrame::Sunken );
04580 repaint();
04581 }
04582
04583 void KSpreadBrushSelect::slotSelect()
04584 {
04585 selected = true;
04586
04587 setLineWidth( 2 );
04588 setFrameStyle( QFrame::Panel | QFrame::Plain );
04589 repaint();
04590 }
04591
04592
04593 CellFormatPagePattern::CellFormatPagePattern( QWidget* parent, CellFormatDlg *_dlg ) : QWidget( parent )
04594 {
04595 dlg = _dlg;
04596
04597 bBgColorUndefined = !dlg->bBgColor;
04598
04599 QGridLayout *grid = new QGridLayout(this,5,2,KDialog::marginHint(), KDialog::spacingHint());
04600
04601 QGroupBox* tmpQGroupBox;
04602 tmpQGroupBox = new QGroupBox( this, "GroupBox_20" );
04603 tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
04604 tmpQGroupBox->setTitle( i18n("Pattern") );
04605 tmpQGroupBox->setAlignment( AlignLeft );
04606
04607 QGridLayout *grid2 = new QGridLayout(tmpQGroupBox,8,3,KDialog::marginHint(), KDialog::spacingHint());
04608 int fHeight = tmpQGroupBox->fontMetrics().height();
04609 grid2->addRowSpacing( 0, fHeight/2 );
04610
04611
04612 brush1 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_1" );
04613 brush1->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04614 grid2->addWidget(brush1,1,0);
04615
04616 brush2 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_2" );
04617 brush2->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04618 grid2->addWidget(brush2,1,1);
04619
04620 brush3 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_3" );
04621 brush3->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04622 grid2->addWidget(brush3,1,2);
04623
04624 brush4 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_4" );
04625 brush4->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04626 grid2->addWidget(brush4,2,0);
04627
04628 brush5 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_5" );
04629 brush5->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04630 grid2->addWidget(brush5,2,1);
04631
04632 brush6 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_6" );
04633 brush6->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04634 grid2->addWidget(brush6,2,2);
04635
04636 brush7 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_7" );
04637 brush7->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04638 grid2->addWidget(brush7,3,0);
04639
04640 brush8 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_8" );
04641 brush8->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04642 grid2->addWidget(brush8,3,1);
04643
04644 brush9 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_9" );
04645 brush9->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04646 grid2->addWidget(brush9,3,2);
04647
04648 brush10 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_10" );
04649 brush10->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04650 grid2->addWidget(brush10,4,0);
04651
04652 brush11 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_11" );
04653 brush11->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04654 grid2->addWidget(brush11,4,1);
04655
04656 brush12 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_12" );
04657 brush12->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04658 grid2->addWidget(brush12,4,2);
04659
04660 brush13 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_13" );
04661 brush13->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04662 grid2->addWidget(brush13,5,0);
04663
04664 brush14 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_14" );
04665 brush14->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04666 grid2->addWidget(brush14,5,1);
04667
04668 brush15 = new KSpreadBrushSelect( tmpQGroupBox, "Frame_15" );
04669 brush15->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04670 grid2->addWidget(brush15,5,2);
04671
04672 QGridLayout *grid3 = new QGridLayout( 1, 2 );
04673 color = new KColorButton (tmpQGroupBox, "ColorButton_1" );
04674 grid3->addWidget(color,0,1);
04675
04676 QLabel *tmpQLabel = new QLabel( tmpQGroupBox, "Label_1" );
04677 tmpQLabel->setText( i18n("Color:") );
04678 grid3->addWidget(tmpQLabel,0,0);
04679
04680 grid2->addMultiCell(grid3,6,6,0,2);
04681
04682 grid3 = new QGridLayout( 1, 3 );
04683 grid3->setSpacing(KDialog::spacingHint());
04684
04685 tmpQLabel = new QLabel( tmpQGroupBox, "Label_2" );
04686 grid3->addWidget(tmpQLabel,0,0);
04687 tmpQLabel->setText( i18n("Background color:") );
04688
04689 bgColorButton = new KColorButton( tmpQGroupBox, "ColorButton" );
04690 grid3->addWidget(bgColorButton,0,1);
04691 if ( dlg->bBgColor )
04692 bgColor = dlg->bgColor;
04693 else
04694 bgColor = colorGroup().base();
04695
04696 if (!bgColor.isValid())
04697 bgColor = colorGroup().base();
04698
04699 bgColorButton->setColor( bgColor );
04700 connect( bgColorButton, SIGNAL( changed( const QColor & ) ),
04701 this, SLOT( slotSetBackgroundColor( const QColor & ) ) );
04702
04703 notAnyColor=new QPushButton(i18n("No Color"),tmpQGroupBox);
04704 grid3->addWidget(notAnyColor,0,2);
04705 connect( notAnyColor, SIGNAL( clicked( ) ),
04706 this, SLOT( slotNotAnyColor( ) ) );
04707 b_notAnyColor=false;
04708
04709 grid2->addMultiCell(grid3,7,7,0,2);
04710
04711 grid->addMultiCellWidget(tmpQGroupBox,0,3,0,0);
04712
04713 tmpQGroupBox = new QGroupBox( this, "GroupBox1" );
04714 tmpQGroupBox->setTitle( i18n("Preview") );
04715 tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
04716 tmpQGroupBox->setAlignment( AlignLeft );
04717
04718 grid2 = new QGridLayout(tmpQGroupBox,2,1,KDialog::marginHint(), KDialog::spacingHint());
04719 fHeight = tmpQGroupBox->fontMetrics().height();
04720 grid2->addRowSpacing( 0, fHeight/2 );
04721
04722 current = new KSpreadBrushSelect( tmpQGroupBox, "Current" );
04723 current->setFrameStyle( QFrame::Panel | QFrame::Sunken );
04724 grid2->addWidget(current,1,0);
04725 grid->addWidget( tmpQGroupBox,4,0);
04726
04727 connect( brush1, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04728 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04729 connect( brush2, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04730 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04731 connect( brush3, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04732 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04733 connect( brush4, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04734 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04735 connect( brush5, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04736 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04737 connect( brush6, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04738 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04739 connect( brush7, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04740 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04741 connect( brush8, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04742 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04743 connect( brush9, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04744 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04745 connect( brush10, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04746 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04747 connect( brush11, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04748 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04749 connect( brush12, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04750 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04751 connect( brush13, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04752 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04753 connect( brush14, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04754 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04755 connect( brush15, SIGNAL( clicked( KSpreadBrushSelect* ) ),
04756 this, SLOT( slotUnselect2( KSpreadBrushSelect* ) ) );
04757
04758 brush1->setPattern( Qt::red, Qt::VerPattern );
04759 brush2->setPattern( Qt::red,Qt::HorPattern );
04760 brush3->setPattern( Qt::red,Qt::Dense1Pattern );
04761 brush4->setPattern( Qt::red,Qt::Dense2Pattern );
04762 brush5->setPattern( Qt::red,Qt::Dense3Pattern );
04763 brush6->setPattern( Qt::red,Qt::Dense4Pattern );
04764 brush7->setPattern( Qt::red,Qt::Dense5Pattern );
04765 brush8->setPattern( Qt::red,Qt::Dense6Pattern );
04766 brush9->setPattern( Qt::red,Qt::Dense7Pattern );
04767 brush10->setPattern( Qt::red,Qt::CrossPattern );
04768 brush11->setPattern( Qt::red,Qt::BDiagPattern );
04769 brush12->setPattern( Qt::red,Qt::FDiagPattern );
04770 brush13->setPattern( Qt::red,Qt::VerPattern );
04771 brush14->setPattern( Qt::red,Qt::DiagCrossPattern );
04772 brush15->setPattern( Qt::red,Qt::NoBrush );
04773
04774 current->setPattern(dlg->brushColor,dlg->brushStyle);
04775 current->slotSelect();
04776 selectedBrush=current;
04777 color->setColor(dlg->brushColor);
04778 current->setBackgroundColor( bgColor );
04779
04780 connect( color, SIGNAL( changed( const QColor & ) ),
04781 this, SLOT( slotSetColorButton( const QColor & ) ) );
04782
04783 slotSetColorButton( dlg->brushColor );
04784 init();
04785 this->resize( 400, 400 );
04786 }
04787
04788 void CellFormatPagePattern::slotNotAnyColor()
04789 {
04790 b_notAnyColor = true;
04791 bgColorButton->setColor( colorGroup().base() );
04792 current->setBackgroundColor( colorGroup().base() );
04793 }
04794
04795 void CellFormatPagePattern::slotSetBackgroundColor( const QColor &_color )
04796 {
04797 bgColor =_color;
04798 current->setBackgroundColor( bgColor );
04799 bBgColorUndefined = false;
04800 b_notAnyColor = false;
04801 }
04802
04803 void CellFormatPagePattern::init()
04804 {
04805 if (dlg->brushStyle == Qt::VerPattern)
04806 {
04807 brush1->slotSelect();
04808 }
04809 else if (dlg->brushStyle == Qt::HorPattern)
04810 {
04811 brush2->slotSelect();
04812 }
04813 else if (dlg->brushStyle == Qt::Dense1Pattern)
04814 {
04815 brush3->slotSelect();
04816 }
04817 else if (dlg->brushStyle == Qt::Dense2Pattern)
04818 {
04819 brush4->slotSelect();
04820 }
04821 else if (dlg->brushStyle == Qt::Dense3Pattern)
04822 {
04823 brush5->slotSelect();
04824 }
04825 else if (dlg->brushStyle == Qt::Dense4Pattern)
04826 {
04827 brush6->slotSelect();
04828 }
04829 else if (dlg->brushStyle == Qt::Dense5Pattern)
04830 {
04831 brush7->slotSelect();
04832 }
04833 else if (dlg->brushStyle == Qt::Dense6Pattern)
04834 {
04835 brush8->slotSelect();
04836 }
04837 else if (dlg->brushStyle == Qt::Dense7Pattern)
04838 {
04839 brush9->slotSelect();
04840 }
04841 else if (dlg->brushStyle == Qt::CrossPattern)
04842 {
04843 brush10->slotSelect();
04844 }
04845 else if (dlg->brushStyle == Qt::BDiagPattern)
04846 {
04847 brush11->slotSelect();
04848 }
04849 else if (dlg->brushStyle == Qt::FDiagPattern)
04850 {
04851 brush12->slotSelect();
04852 }
04853 else if (dlg->brushStyle == Qt::VerPattern)
04854 {
04855 brush13->slotSelect();
04856 }
04857 else if (dlg->brushStyle == Qt::DiagCrossPattern)
04858 {
04859 brush14->slotSelect();
04860 }
04861 else if (dlg->brushStyle == Qt::NoBrush)
04862 {
04863 brush15->slotSelect();
04864 }
04865 else
04866 kdDebug(36001) << "Error in brushStyle" << endl;
04867 }
04868
04869 void CellFormatPagePattern::slotSetColorButton( const QColor &_color )
04870 {
04871 currentColor = _color;
04872
04873 brush1->setBrushColor( currentColor );
04874 brush2->setBrushColor( currentColor );
04875 brush3->setBrushColor( currentColor );
04876 brush4->setBrushColor( currentColor );
04877 brush5->setBrushColor( currentColor );
04878 brush6->setBrushColor( currentColor );
04879 brush7->setBrushColor( currentColor );
04880 brush8->setBrushColor( currentColor );
04881 brush9->setBrushColor( currentColor );
04882 brush10->setBrushColor( currentColor );
04883 brush11->setBrushColor( currentColor );
04884 brush12->setBrushColor( currentColor );
04885 brush13->setBrushColor( currentColor );
04886 brush14->setBrushColor( currentColor );
04887 brush15->setBrushColor( currentColor );
04888 current->setBrushColor( currentColor );
04889 }
04890
04891 void CellFormatPagePattern::slotUnselect2( KSpreadBrushSelect *_p )
04892 {
04893 selectedBrush = _p;
04894
04895 if ( brush1 != _p )
04896 brush1->slotUnselect();
04897 if ( brush2 != _p )
04898 brush2->slotUnselect();
04899 if ( brush3 != _p )
04900 brush3->slotUnselect();
04901 if ( brush4 != _p )
04902 brush4->slotUnselect();
04903 if ( brush5 != _p )
04904 brush5->slotUnselect();
04905 if ( brush6 != _p )
04906 brush6->slotUnselect();
04907 if ( brush7 != _p )
04908 brush7->slotUnselect();
04909 if ( brush8 != _p )
04910 brush8->slotUnselect();
04911 if ( brush9 != _p )
04912 brush9->slotUnselect();
04913 if ( brush10 != _p )
04914 brush10->slotUnselect();
04915 if ( brush11 != _p )
04916 brush11->slotUnselect();
04917 if ( brush12 != _p )
04918 brush12->slotUnselect();
04919 if ( brush13 != _p )
04920 brush13->slotUnselect();
04921 if ( brush14 != _p )
04922 brush14->slotUnselect();
04923 if ( brush15 != _p )
04924 brush15->slotUnselect();
04925
04926 current->setBrushStyle( selectedBrush->getBrushStyle() );
04927 }
04928
04929 void CellFormatPagePattern::apply( KSpreadCustomStyle * style )
04930 {
04931 if ( selectedBrush != 0L
04932 && ( dlg->brushStyle != selectedBrush->getBrushStyle()
04933 || dlg->brushColor != selectedBrush->getBrushColor() ) )
04934 style->changeBackGroundBrush( QBrush( selectedBrush->getBrushColor(), selectedBrush->getBrushStyle() ) );
04935
04936
04937
04938
04939
04940
04941
04942 if ( bgColor != dlg->getStyle()->bgColor() )
04943 style->changeBgColor( bgColor );
04944 }
04945
04946 void CellFormatPagePattern::apply( ColumnFormat *_obj )
04947 {
04948 KSpreadSheet * sheet = dlg->getSheet();
04949 KSpreadCell * c = NULL;
04950 for ( int col = dlg->left; col <= dlg->right; ++col )
04951 {
04952 for (c = sheet->getFirstCellColumn(col); c != NULL;
04953 c = sheet->getNextCellDown(c->column(), c->row()))
04954 {
04955 if ( selectedBrush != 0L
04956 && ( dlg->brushStyle != selectedBrush->getBrushStyle()
04957 || dlg->brushColor != selectedBrush->getBrushColor() ) )
04958 {
04959 c->clearProperty(KSpreadCell::PBackgroundBrush);
04960 c->clearNoFallBackProperties( KSpreadCell::PBackgroundBrush );
04961 }
04962 if ( ( !bBgColorUndefined || b_notAnyColor )
04963 && bgColor != dlg->bgColor )
04964 {
04965 c->clearProperty(KSpreadCell::PBackgroundColor);
04966 c->clearNoFallBackProperties( KSpreadCell::PBackgroundColor );
04967 }
04968 }
04969 }
04970 applyFormat( _obj );
04971
04972 RowFormat * rw = dlg->getSheet()->firstRow();
04973 for ( ; rw; rw = rw->next() )
04974 {
04975 if ( !rw->isDefault() && (rw->hasProperty(KSpreadCell::PBackgroundColor) || rw->hasProperty(KSpreadCell::PBackgroundBrush)))
04976 {
04977 for ( int i = dlg->left; i <= dlg->right; ++i )
04978 {
04979 KSpreadCell * cell =
04980 dlg->getSheet()->nonDefaultCell( i, rw->row() );
04981 applyFormat(cell );
04982 }
04983 }
04984 }
04985
04986 }
04987
04988 void CellFormatPagePattern::apply( RowFormat *_obj )
04989 {
04990 KSpreadSheet * sheet = dlg->getSheet();
04991 KSpreadCell * c = NULL;
04992 for ( int row = dlg->top; row <= dlg->bottom; ++row)
04993 {
04994 for (c = sheet->getFirstCellRow(row); c != NULL;
04995 c = sheet->getNextCellRight(c->column(), c->row()))
04996 {
04997 if ( selectedBrush != 0L
04998 && ( dlg->brushStyle != selectedBrush->getBrushStyle()
04999 || dlg->brushColor != selectedBrush->getBrushColor() ) )
05000 {
05001 c->clearProperty(KSpreadCell::PBackgroundBrush);
05002 c->clearNoFallBackProperties( KSpreadCell::PBackgroundBrush );
05003 }
05004 if ( ( !bBgColorUndefined || b_notAnyColor )
05005 && bgColor != dlg->bgColor )
05006 {
05007 c->clearProperty(KSpreadCell::PBackgroundColor);
05008 c->clearNoFallBackProperties( KSpreadCell::PBackgroundColor );
05009 }
05010 }
05011 }
05012 applyFormat( _obj );
05013 }
05014
05015
05016 void CellFormatPagePattern::apply( KSpreadCell *_obj )
05017 {
05018 applyFormat( _obj );
05019 }
05020
05021 void CellFormatPagePattern::applyFormat( KSpreadFormat *_obj )
05022 {
05023 if ( selectedBrush != 0L
05024 && ( dlg->brushStyle != selectedBrush->getBrushStyle()
05025 || dlg->brushColor != selectedBrush->getBrushColor() ) )
05026 _obj->setBackGroundBrush( QBrush( selectedBrush->getBrushColor(), selectedBrush->getBrushStyle() ) );
05027
05028 if ( bgColor == dlg->bgColor )
05029 return;
05030
05031 if ( b_notAnyColor)
05032 _obj->setBgColor( QColor() );
05033 else if ( !bBgColorUndefined )
05034 _obj->setBgColor( bgColor );
05035 }
05036
05037 #include "kspread_dlg_layout.moc"
05038