F:/KPlato/koffice/libs/kotext/KoParagDia.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00003    Copyright (C) 2005 Martin Ellis <martin.ellis@kdemail.net>
00004    Copyright (C) 2006 Thomas Zander <zander@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "KoParagDia.h"
00023 #include "KoParagDia_p.h"
00024 #include "KoDocument.h"
00025 #include "KoTextFormat.h"
00026 #include "KoTextParag.h"
00027 #include "KoTextDocument.h"
00028 #include "KoTextZoomHandler.h"
00029 #include "KoBorderPreview.h"
00030 
00031 #include <KoCharSelectDia.h>
00032 #include <KoUnitWidgets.h>
00033 #include <kcolorbutton.h>
00034 #include <kdebug.h>
00035 #include <kiconloader.h>
00036 #include <klocale.h>
00037 #include <knumvalidator.h>
00038 #include <KoGlobal.h>
00039 #include <q3groupbox.h>
00040 //Added by qt3to4:
00041 #include <QMouseEvent>
00042 #include <Q3VBoxLayout>
00043 #include <QKeyEvent>
00044 #include <Q3GridLayout>
00045 #include <Q3PtrList>
00046 #include <Q3HBoxLayout>
00047 #include <knuminput.h>
00048 #include <kdeversion.h>
00049 #include <kpushbutton.h>
00050 #include <kcombobox.h>
00051 
00052 #include <QCheckBox>
00053 #include <QComboBox>
00054 #include <QLabel>
00055 #include <QRadioButton>
00056 #include <kvbox.h>
00057 #include <q3hbox.h>
00058 #include <QToolTip>
00059 #include <QLayout>
00060 #include <QApplication>
00061 #include <q3widgetstack.h>
00062 #include <q3tl.h>
00063 #include <QListWidget>
00064 #include <Q3ListBox>
00065 
00066 KoCounterStyleWidget::KoCounterStyleWidget( bool displayDepth, bool onlyStyleTypeLetter, bool disableAll, QWidget * parent  )
00067     :QWidget( parent ),
00068     stylesList()
00069 {
00070     noSignals = true;
00071     styleBuffer = 999;
00072     Q3VBoxLayout *vbox = new Q3VBoxLayout( this,0, 0/*KDialog::marginHint(), KDialog::spacingHint()*/ );
00073     gStyle = new Q3GroupBox( i18n( "St&yle" ), this, "styleLayout" );
00074     vbox->addWidget( gStyle);
00075     Q3GridLayout * grid = new Q3GridLayout(gStyle, 12, 5, KDialog::marginHint(), KDialog::spacingHint());
00076     grid->addItem( new QSpacerItem( 0, fontMetrics().height()/2), 0, 0 );
00077 
00078     makeCounterRepresenterList( stylesList, onlyStyleTypeLetter );
00079 
00080     lstStyle = new QListWidget( gStyle );
00081     grid->addMultiCellWidget( lstStyle, 1, 11, 0, 0);
00082     fillStyleCombo();
00083     connect( lstStyle, SIGNAL( itemSelectionChanged() ), this, SLOT( numStyleChanged() ) );
00084 
00085 
00086     QLabel *lPrefix = new QLabel( gStyle );
00087     lPrefix->setObjectName( "lPrefix" );
00088     lPrefix->setText( i18n( "Pre&fix text:" ) );
00089     grid->addWidget( lPrefix, 1, 1);
00090 
00091     sPrefix = new QLineEdit( gStyle, "sPrefix" );
00092     lPrefix->setBuddy( sPrefix );
00093     grid->addWidget( sPrefix, 1, 2);
00094 
00095     QLabel *lSuffix = new QLabel( gStyle );
00096     lSuffix->setObjectName( "lSuffix" );
00097     lSuffix->setText( i18n( "Suffi&x text:" ) );
00098     grid->addWidget( lSuffix, 1, 3);
00099 
00100     sSuffix = new QLineEdit( gStyle, "sSuffix" );
00101     lSuffix->setBuddy( sSuffix );
00102     grid->addWidget( sSuffix, 1, 4 );
00103 
00104     lStart = new QLabel( gStyle );
00105     lStart->setObjectName( "lStart" );
00106     lStart->setText( i18n( "&Start at:" ) );
00107     grid->addWidget( lStart, 2, 1 );
00108 
00109 
00110     spnDepth = new QSpinBox( 0, 15, 1, gStyle );
00111     if (  displayDepth )
00112         grid->addWidget( spnDepth, 3, 2 );
00113     else
00114         spnDepth->hide();
00115 
00116     spnDisplayLevels = new QSpinBox( 0, 15, 1, gStyle );
00117     spnDisplayLevels->setMinimum( 1 );
00118     if ( displayDepth )
00119         grid->addWidget( spnDisplayLevels, 3, 4 );
00120     else
00121         spnDisplayLevels->hide();
00122 
00123 
00124     Q3HBoxLayout *customCharBox = new Q3HBoxLayout(0, 0, 6);
00125     lCustom = new QLabel( i18n( "Custo&m character:" ), gStyle, "custom char label" );
00126     customCharBox->addWidget( lCustom );
00127 
00128     bCustom = new QPushButton( "", gStyle, "bCustom" );
00129     lCustom->setBuddy( bCustom );
00130     customCharBox->addWidget( bCustom );
00131     connect( bCustom, SIGNAL( clicked() ), this, SLOT( selectCustomBullet() ) );
00132 
00133     QSpacerItem* spacer_2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00134     customCharBox->addItem( spacer_2 );
00135 
00136     grid->addMultiCellLayout(customCharBox, 4, 4, 1, 4, Qt::AlignLeft);
00137 
00138     spnStart = new KoSpinBox( gStyle );
00139     spnStart->setMinimum ( 1);
00140     lStart->setBuddy( spnStart );
00141     grid->addWidget( spnStart, 2, 2);
00142 
00143     lAlignment = new QLabel( gStyle );
00144     lAlignment->setText( i18n( "Counter alignment:" ) );
00145     grid->addWidget( lAlignment, 2, 3 );
00146 
00147     cbAlignment = new KComboBox( gStyle );
00148     cbAlignment->addItem(i18n("Align Auto"));
00149     cbAlignment->addItem(i18n("Align Left"));
00150     cbAlignment->addItem(i18n("Align Right"));
00151     cbAlignment->setCurrentIndex(0);
00152     grid->addWidget( cbAlignment, 2, 4 );
00153 
00154     QLabel *lDepth = new QLabel( gStyle );
00155     lDepth->setObjectName( "lDepth" );
00156     lDepth->setText( i18n( "&Depth:" ) );
00157     lDepth->setBuddy( spnDepth );
00158     if ( displayDepth )
00159         grid->addWidget( lDepth, 3, 1 );
00160     else
00161         lDepth->hide();
00162 
00163     QLabel *lDisplayLevels = new QLabel( gStyle );
00164     lDisplayLevels->setText( i18n( "Display le&vels:" ) );
00165     lDisplayLevels->setBuddy( spnDisplayLevels );
00166     if ( displayDepth )
00167         grid->addWidget( lDisplayLevels, 3, 3 );
00168     else
00169         lDisplayLevels->hide();
00170 
00171     cbRestart = new QCheckBox( i18n( "&Restart numbering at this paragraph" ), gStyle );
00172     grid->addMultiCellWidget( cbRestart, 5, 5, 1, 3 );
00173 
00174     if ( onlyStyleTypeLetter )
00175     {
00176         lCustom->hide();
00177         bCustom->hide();
00178         cbRestart->hide();
00179     }
00180 
00181 
00182     connect( cbRestart, SIGNAL( toggled(bool) ), this, SLOT( restartChanged(bool) ) );
00183 
00184     connect( sSuffix, SIGNAL( textChanged (const QString &) ), this, SLOT( suffixChanged(const QString &) ) );
00185     connect( sPrefix, SIGNAL( textChanged (const QString &) ), this, SLOT( prefixChanged(const QString &) ) );
00186     connect( spnStart, SIGNAL( valueChanged (int) ), this, SLOT( startChanged(int) ) );
00187     connect( spnDepth, SIGNAL( valueChanged (int) ), this, SLOT( depthChanged(int) ) );
00188     connect( spnDisplayLevels, SIGNAL( valueChanged (int) ), this, SLOT( displayLevelsChanged(int) ) );
00189     connect( cbAlignment, SIGNAL( activated (const QString&) ), this, SLOT( alignmentChanged(const QString&) ) );
00190     noSignals = false;
00191     if ( disableAll )
00192     {
00193         gStyle->setEnabled( false );
00194         lstStyle->setEnabled( false );
00195         sSuffix->setEnabled( false );
00196         sPrefix->setEnabled( false );
00197         bCustom->setEnabled( false );
00198         spnStart->setEnabled( false );
00199         spnDepth->setEnabled( false );
00200         spnDisplayLevels->setEnabled( false );
00201         lStart->setEnabled( false );
00202         lCustom->setEnabled( false );
00203         cbRestart->setEnabled( false );
00204         cbAlignment->setEnabled( false );
00205     }
00206 }
00207 
00208 void KoCounterStyleWidget::alignmentChanged(const QString& s)
00209 {
00210     int a;
00211     if(s==i18n("Align Left"))
00212         a=Qt::AlignLeft;
00213     else if(s==i18n("Align Right"))
00214         a=Qt::AlignRight;
00215     else if(s==i18n("Align Auto"))
00216         a=Qt::AlignLeft;
00217     else {
00218         kError()<<"Not Implemented"<<endl;
00219         return;
00220     }
00221     m_counter.setAlignment(a);
00222     emit sig_alignmentChanged(a);
00223 }
00224 
00225 void KoCounterStyleWidget::setCounter( const KoParagCounter& counter )
00226 {
00227     noSignals = true;
00228     KoParagCounter::Style st = counter.style();
00229     m_counter = counter;
00230     // Huh? doesn't the line above do this already?
00231     //m_counter.setStyle( st );
00232     changeKWSpinboxType( st);
00233     displayStyle( st );
00234     noSignals = false;
00235 }
00236 
00237 void KoCounterStyleWidget::changeKWSpinboxType(KoParagCounter::Style st) {
00238     switch(st)
00239     {
00240         case KoParagCounter::STYLE_NONE:
00241             spnStart->setCounterType(KoSpinBox::NONE);
00242             break;
00243         case KoParagCounter::STYLE_NUM:
00244             spnStart->setCounterType(KoSpinBox::NUM);
00245             break;
00246         case KoParagCounter::STYLE_ALPHAB_L:
00247             spnStart->setCounterType(KoSpinBox::ALPHAB_L);
00248             break;
00249         case KoParagCounter::STYLE_ALPHAB_U:
00250             spnStart->setCounterType(KoSpinBox::ALPHAB_U);
00251             break;
00252         case KoParagCounter::STYLE_ROM_NUM_L:
00253             spnStart->setCounterType(KoSpinBox::ROM_NUM_L);
00254             break;
00255         case KoParagCounter::STYLE_ROM_NUM_U:
00256             spnStart->setCounterType(KoSpinBox::ROM_NUM_U);
00257             break;
00258         default:
00259             spnStart->setCounterType(KoSpinBox::NONE);
00260     }
00261 }
00262 
00263 
00264 void KoCounterStyleWidget::fillStyleCombo(KoParagCounter::Numbering type) {
00265     if(lstStyle==NULL) return;
00266     noSignals=true;
00267     unsigned int cur = lstStyle->currentRow();
00268     lstStyle->clear();
00269     Q3PtrListIterator<StyleRepresenter> style( stylesList );
00270     while ( style.current() ) {
00271         if(style.current()->style() == KoParagCounter::STYLE_NONE) {
00272             if(type == KoParagCounter::NUM_NONE)
00273                 lstStyle->addItem( style.current()->name() );
00274         }
00275         else if(type == KoParagCounter::NUM_LIST || !style.current()->isBullet())
00276             if(type != KoParagCounter::NUM_NONE)
00277                 lstStyle->addItem( style.current()->name() );
00278         ++style;
00279     }
00280 
00281     if(styleBuffer <= lstStyle->count())
00282         lstStyle->setCurrentRow(styleBuffer);
00283     else
00284         if(cur <= lstStyle->count())
00285             lstStyle->setCurrentRow(cur);
00286 
00287     if(cur > lstStyle->count()) {
00288         styleBuffer = cur;
00289     }
00290     noSignals=false;
00291 }
00292 
00293 void KoCounterStyleWidget::displayStyle( KoParagCounter::Style style )
00294 {
00295     unsigned int i = 0;
00296     while ( stylesList.count() > i && stylesList.at(i)->style() != style )
00297         ++i;
00298     lstStyle->setCurrentRow(i);
00299 
00300     bCustom->setText( m_counter.customBulletCharacter() );
00301     if ( !m_counter.customBulletFont().isEmpty() )
00302         bCustom->setFont( QFont( m_counter.customBulletFont() ) );
00303 
00304     sPrefix->setText( m_counter.prefix() );
00305     sSuffix->setText( m_counter.suffix() );
00306 
00307     spnDepth->setValue( m_counter.depth() );
00308     spnDisplayLevels->setValue( m_counter.displayLevels() );
00309     spnStart->setValue( m_counter.startNumber() );
00310 
00311     cbRestart->setChecked( m_counter.restartCounter() );
00312     if(m_counter.alignment()==Qt::AlignLeft)
00313         cbAlignment->setCurrentText(i18n("Align Left"));
00314     else if(m_counter.alignment()==Qt::AlignRight)
00315         cbAlignment->setCurrentText(i18n("Align Right"));
00316     else if(m_counter.alignment()==Qt::AlignLeft)
00317         cbAlignment->setCurrentText(i18n("Align Auto"));
00318     else
00319         kError()<<"Not Implemented"<<endl;
00320 }
00321 
00322 void KoCounterStyleWidget::display( const KoParagLayout & lay ) {
00323     KoParagCounter::Style style = KoParagCounter::STYLE_NONE;
00324     if ( lay.counter )
00325     {
00326         style=lay.counter->style();
00327         m_counter = *lay.counter;
00328     }
00329     else
00330     {
00331         m_counter = KoParagCounter();
00332     }
00333     styleBuffer = 999;
00334 
00335     numTypeChanged( m_counter.numbering() );
00336     emit sig_numTypeChanged( m_counter.numbering() );
00337 
00338     displayStyle( style );
00339 }
00340 
00341 
00342 void KoCounterStyleWidget::numTypeChanged( int nType ) {
00343     m_counter.setNumbering( static_cast<KoParagCounter::Numbering>( nType ) );
00344     gStyle->setEnabled( m_counter.numbering() != KoParagCounter::NUM_NONE );
00345     fillStyleCombo(m_counter.numbering());
00346     bool state=m_counter.numbering()==KoParagCounter::NUM_LIST;
00347     bCustom->setEnabled(state);
00348     lCustom->setEnabled(state);
00349 }
00350 
00351 
00352 void KoCounterStyleWidget::makeCounterRepresenterList( Q3PtrList<StyleRepresenter>& stylesList, bool onlyStyleTypeLetter )
00353 {
00354     stylesList.setAutoDelete( true );
00355     stylesList.append( new StyleRepresenter(i18n( "Arabic Numbers" )
00356             ,  KoParagCounter::STYLE_NUM));
00357     stylesList.append( new StyleRepresenter(i18n( "Lower Alphabetical" )
00358             ,  KoParagCounter::STYLE_ALPHAB_L ));
00359     stylesList.append( new StyleRepresenter(i18n( "Upper Alphabetical" )
00360             ,  KoParagCounter::STYLE_ALPHAB_U ));
00361     stylesList.append( new StyleRepresenter(i18n( "Lower Roman Numbers" )
00362             ,  KoParagCounter::STYLE_ROM_NUM_L ));
00363     stylesList.append( new StyleRepresenter(i18n( "Upper Roman Numbers" )
00364             ,  KoParagCounter::STYLE_ROM_NUM_U ));
00365     if ( !onlyStyleTypeLetter )
00366     {
00367         stylesList.append( new StyleRepresenter(i18n( "Disc Bullet" )
00368                                                 ,  KoParagCounter::STYLE_DISCBULLET , true));
00369         stylesList.append( new StyleRepresenter(i18n( "Square Bullet" )
00370                                                 ,  KoParagCounter::STYLE_SQUAREBULLET , true));
00371         stylesList.append( new StyleRepresenter(i18n( "Box Bullet" )
00372                                                 ,  KoParagCounter::STYLE_BOXBULLET , true));
00373         stylesList.append( new StyleRepresenter(i18n( "Circle Bullet" )
00374                                                 ,  KoParagCounter::STYLE_CIRCLEBULLET , true));
00375         stylesList.append( new StyleRepresenter(i18n( "Custom Bullet" )
00376                                                 ,  KoParagCounter::STYLE_CUSTOMBULLET , true));
00377     }
00378     stylesList.append( new StyleRepresenter(i18n( "None" ), KoParagCounter::STYLE_NONE));
00379 }
00380 
00381 
00382 void KoCounterStyleWidget::selectCustomBullet() {
00383     unsigned int i = 0;
00384     while ( stylesList.count() > i && stylesList.at(i)->style() != KoParagCounter::STYLE_CUSTOMBULLET )
00385         ++i;
00386     lstStyle->setCurrentRow(i);
00387 
00388     QString f = m_counter.customBulletFont();
00389     if ( f.isEmpty() )
00390         f = "symbol";
00391     QChar c = m_counter.customBulletCharacter();
00392 
00393     if ( KoCharSelectDia::selectChar( f, c ) ) {
00394         emit changeCustomBullet( f, c );
00395         m_counter.setCustomBulletFont( f );
00396         m_counter.setCustomBulletCharacter( c );
00397         if ( !f.isEmpty() )
00398             bCustom->setFont( QFont( f ) );
00399         bCustom->setText( c );
00400     }
00401 }
00402 
00403 void KoCounterStyleWidget::numStyleChanged() {
00404     if ( noSignals )
00405         return;
00406     // We selected another style from the list box.
00407     styleBuffer = 999;
00408     StyleRepresenter *sr = stylesList.at(lstStyle->currentRow());
00409     emit changeStyle( sr->style() );
00410     m_counter.setStyle( sr->style() );
00411     bool isNumbered = !sr->isBullet() && !sr->style() == KoParagCounter::STYLE_NONE;
00412     lStart->setEnabled( isNumbered );
00413     spnStart->setEnabled( isNumbered );
00414     cbRestart->setEnabled( isNumbered );
00415     spnDisplayLevels->setEnabled( isNumbered );
00416     changeKWSpinboxType(sr->style() );
00417 }
00418 
00419 
00420 
00421 KoSpinBox::KoSpinBox( QWidget * parent )
00422     : QSpinBox( parent )
00423 {
00424     m_Etype=NONE;
00425     //max value supported by roman number
00426     setMaximum ( 3999 );
00427 }
00428 KoSpinBox::~KoSpinBox( )
00429 {
00430 }
00431 
00432 KoSpinBox::KoSpinBox( int minValue, int maxValue, int step, QWidget * parent )
00433     : QSpinBox( minValue, maxValue, step, parent )
00434 {
00435     m_Etype = NONE;
00436 }
00437 
00438 void KoSpinBox::setCounterType(CounterType _type)
00439 {
00440     m_Etype = _type;
00441     lineEdit()->setText(mapValueToText(value()));
00442 }
00443 
00444 
00445 QString KoSpinBox::mapValueToText( int value )
00446 {
00447     if(value==0 && m_Etype==NUM)
00448         return QString("0");
00449     else if(value==0 && m_Etype!=NUM)
00450         return QString::null;
00451     switch(m_Etype)
00452     {
00453         case NUM:
00454             return QString::number(value);
00455         case ALPHAB_L:
00456             return KoParagCounter::makeAlphaLowerNumber( value );
00457         case ALPHAB_U:
00458             return KoParagCounter::makeAlphaUpperNumber( value );
00459         case ROM_NUM_L:
00460             return KoParagCounter::makeRomanNumber( value );
00461         case ROM_NUM_U:
00462             return KoParagCounter::makeRomanNumber( value ).toUpper();
00463         case NONE:
00464         default:
00465             return QString::null;
00466     }
00467     //never here
00468     return QString::null;
00469 }
00470 
00471 int KoSpinBox::mapTextToValue( bool * ok )
00472 {
00473     int ret;
00474     QString txt = text();
00475 
00476     *ok = true;
00477     switch(m_Etype)
00478     {
00479         case NUM:
00480             ret = txt.toInt ( ok );
00481             break;
00482         case ALPHAB_L:
00483             ret = KoParagCounter::fromAlphaLowerNumber( txt.toLower() );
00484             break;
00485         case ALPHAB_U:
00486             ret = KoParagCounter::fromAlphaUpperNumber( txt.toUpper() );
00487             break;
00488         case ROM_NUM_L:
00489             ret = KoParagCounter::fromRomanNumber( txt.toLower() );
00490             break;
00491         case ROM_NUM_U:
00492             ret = KoParagCounter::fromRomanNumber( txt.toLower() ); // _not_ toUpper()
00493             break;
00494         case NONE:
00495         default:
00496             ret = -1;
00497             break;
00498     }
00499 
00500     if (ret == -1)
00501         *ok = false;
00502 
00503     return ret;
00504 }
00505 
00506 
00507 /******************************************************************/
00508 /* class KPagePreview                                            */
00509 /******************************************************************/
00510 
00511 KPagePreview::KPagePreview( QWidget* parent )
00512     : Q3GroupBox( i18n( "Preview" ), parent )
00513 {
00514     left = 0;
00515     right = 0;
00516     first = 0;
00517     spacing = 0;
00518     before = 0;
00519     after = 0;
00520 }
00521 
00522 void KPagePreview::drawContents( QPainter* p )
00523 {
00524     int wid = 148;
00525     int hei = 210;
00526     int _x = ( width() - wid ) / 5;
00527     int _y = ( height() - hei ) / 5;
00528 
00529     int dl = convert(left);
00530     int dr = convert(right);
00531 
00532     //first+left because firstlineIndent is relative to leftIndent
00533     int df = convert(first + left);
00534 
00535     int spc = convert(spacing);
00536 
00537     // draw page
00538     p->setPen( QPen( Qt::black ) );
00539     p->setBrush( QBrush( Qt::black ) );
00540 
00541     p->drawRect( _x + 1, _y + 1, wid, hei );
00542 
00543     p->setBrush( QBrush( Qt::white ) );
00544     p->drawRect( _x, _y, wid, hei );
00545 
00546     // draw parags
00547     p->setPen( Qt::NoPen );
00548     p->setBrush( QBrush( Qt::lightGray ) );
00549 
00550     for ( int i = 1; i <= 4; i++ )
00551         p->drawRect( _x + 6, _y + 6 + ( i - 1 ) * 12 + 2, wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ), 6 );
00552 
00553     p->setBrush( QBrush( Qt::darkGray ) );
00554 
00555     for ( int i = 5; i <= 8; i++ )
00556       {
00557         QRect rect( ( i == 5 ? df : dl ) + _x + 6, _y + 6 + ( i - 1 ) * 12 + 2 + ( i - 5 ) * spc + static_cast<int>( before / 2 ),
00558                     wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ) - ( ( i == 12 ? 0 : dr ) + ( i == 5 ? df : dl ) ), 6);
00559 
00560         if(rect.width ()>=0)
00561           p->drawRect( rect );
00562       }
00563     p->setBrush( QBrush( Qt::lightGray ) );
00564 
00565     for ( int i = 9; i <= 12; i++ )
00566         p->drawRect( _x + 6, _y + 6 + ( i - 1 ) * 12 + 2 + 3 * spc +
00567                      static_cast<int>( before / 2 ) + static_cast<int>( after / 2 ),
00568                      wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ), 6 );
00569 
00570 }
00571 
00572 int KPagePreview::convert(double input) {
00573     if(input < 1) return 0;
00574     if(input <= 5) return 3;
00575     if(input <= 10) return 4 + static_cast<int>( (input-5) / 2.5 );
00576     if(input <= 20) return 6 + static_cast<int>( (input-10) / 4 );
00577     if(input <= 100) return 10 + static_cast<int>( (input-20) / 8 );
00578     return static_cast<int>( input / 5);
00579 }
00580 
00581 /******************************************************************/
00582 /* class KPagePreview2                                           */
00583 /******************************************************************/
00584 
00585 KPagePreview2::KPagePreview2( QWidget* parent )
00586     : Q3GroupBox( i18n( "Preview" ), parent )
00587 {
00588     align = Qt::AlignLeft;
00589 }
00590 
00591 void KPagePreview2::drawContents( QPainter* p )
00592 {
00593     int wid = 148;
00594     int hei = 210;
00595     int _x = ( width() - wid ) / 2;
00596     int _y = ( height() - hei ) / 2;
00597 
00598     // draw page
00599     p->setPen( QPen( Qt::black ) );
00600     p->setBrush( QBrush( Qt::black ) );
00601 
00602     p->drawRect( _x + 1, _y + 1, wid, hei );
00603 
00604     p->setBrush( QBrush( Qt::white ) );
00605     p->drawRect( _x, _y, wid, hei );
00606 
00607     // draw parags
00608     p->setPen( Qt::NoPen );
00609     p->setBrush( QBrush( Qt::lightGray ) );
00610 
00611     for ( int i = 1; i <= 4; i++ )
00612         p->drawRect( _x + 6, _y + 6 + ( i - 1 ) * 12 + 2, wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ), 6 );
00613 
00614     p->setBrush( QBrush( Qt::darkGray ) );
00615 
00616     int __x = 0, __w = 0;
00617     for ( int i = 5; i <= 8; i++ ) {
00618         switch ( i ) {
00619         case 5: __w = wid - 12;
00620             break;
00621         case 6: __w = wid - 52;
00622             break;
00623         case 7: __w = wid - 33;
00624             break;
00625         case 8: __w = wid - 62;
00626         default: break;
00627         }
00628 
00629         switch ( align ) {
00630             case Qt::AlignLeft:
00631                 __x = _x + 6;
00632                 break;
00633             case Qt::AlignHCenter:
00634                 __x = _x + ( wid - __w ) / 2;
00635                 break;
00636             case Qt::AlignRight:
00637                 __x = _x + ( wid - __w ) - 6;
00638                 break;
00639             case Qt::AlignJustify:
00640             {
00641                 if ( i < 8 ) __w = wid - 12;
00642                 __x = _x + 6;
00643             } break;
00644         }
00645 
00646         p->drawRect( __x, _y + 6 + ( i - 1 ) * 12 + 2 + ( i - 5 ), __w, 6 );
00647     }
00648 
00649     p->setBrush( QBrush( Qt::lightGray ) );
00650 
00651     for ( int i = 9; i <= 12; i++ )
00652         p->drawRect( _x + 6, _y + 6 + ( i - 1 ) * 12 + 2 + 3, wid - 12 - ( ( i / 4 ) * 4 == i ? 50 : 0 ), 6 );
00653 
00654 }
00655 
00656 
00657 /******************************************************************/
00658 /* Class: KoStylePreview. Previewing text with style ;)           */
00659 /******************************************************************/
00660 KoStylePreview::KoStylePreview( const QString& title, const QString& text, QWidget* parent )
00661     : Q3GroupBox( title, parent )
00662 {
00663     setMinimumHeight(80);
00664     m_zoomHandler = new KoTextZoomHandler;
00665     QFont font = KoGlobal::defaultFont();
00666     m_textdoc = new KoTextDocument( m_zoomHandler, new KoTextFormatCollection( font, QColor(), KGlobal::locale()->language(), false ) );
00667 
00668     class MyFlow : public KoTextFlow {
00669         public:
00670             MyFlow(QWidget *parent, KoTextZoomHandler *zoom) {
00671                 m_parent = parent;
00672                 m_zoomHandler = zoom;
00673             }
00674             int availableHeight() const {
00675                 return m_zoomHandler->pixelToLayoutUnitY(m_parent->height());
00676             }
00677         private:
00678             QWidget *m_parent;
00679             KoTextZoomHandler *m_zoomHandler;
00680     };
00681 
00682     m_textdoc->setFlow( new MyFlow(this, m_zoomHandler) );
00683     //m_textdoc->setWidth( KoTextZoomHandler::ptToLayoutUnitPt( 1000 ) );
00684     KoTextParag * parag = m_textdoc->firstParag();
00685     parag->insert( 0, text );
00686 }
00687 
00688 KoStylePreview::~KoStylePreview()
00689 {
00690     delete m_textdoc;
00691     delete m_zoomHandler;
00692 }
00693 
00694 void KoStylePreview::setCounter( const KoParagCounter & counter )
00695 {
00696     KoTextParag * parag = m_textdoc->firstParag();
00697     parag->setCounter( counter );
00698     update();
00699 }
00700 
00701 void KoStylePreview::setStyle( KoParagStyle * style )
00702 {
00703     KoTextParag * parag = m_textdoc->firstParag();
00704     parag->applyStyle( style );
00705     update();
00706 }
00707 
00708 void KoStylePreview::drawContents( QPainter *painter )
00709 {
00710     painter->save();
00711     QRect r = contentsRect();
00712     //kDebug(32500) << "KoStylePreview::drawContents contentsRect=" << DEBUGRECT(r) << endl;
00713 
00714     QRect whiteRect( r.x() + 10, r.y() + 10,
00715                      r.width() - 20, r.height() - 20 );
00716     QColorGroup cg = QApplication::palette().active();
00717     painter->fillRect( whiteRect, cg.brush( QColorGroup::Base ) );
00718 
00719     KoTextParag * parag = m_textdoc->firstParag();
00720     int widthLU = m_zoomHandler->pixelToLayoutUnitX( whiteRect.width() - 2 ); // keep one pixel border horizontally
00721     if ( m_textdoc->width() != widthLU )
00722     {
00723         // For centering to work, and to even get word wrapping when the thing is too big :)
00724         m_textdoc->setWidth( widthLU );
00725         parag->invalidate(0);
00726     }
00727 
00728     parag->format();
00729     QRect textRect = parag->pixelRect( m_zoomHandler );
00730 
00731     // Center vertically, but not horizontally, to keep the parag alignment working,
00732     textRect.moveTopLeft( QPoint( whiteRect.x(),
00733                                   whiteRect.y() + ( whiteRect.height() - textRect.height() ) / 2 ) );
00734     // Move it from the left border a little
00735     textRect.rLeft() += 4;
00736     textRect.rRight() += 4;
00737     //kDebug(32500) << "KoStylePreview::drawContents textRect=" << DEBUGRECT(textRect)
00738     //          << " textSize=" << textSize.width() << "," << textSize.height() << endl;
00739     painter->setClipRect( textRect.intersect( whiteRect ) );
00740     painter->translate( textRect.x(), textRect.y() );
00741 
00742     m_textdoc->drawWYSIWYG( painter, 0, 0, textRect.width(), textRect.height(), cg, m_zoomHandler );
00743     painter->restore();
00744 }
00745 
00746 KoIndentSpacingWidget::KoIndentSpacingWidget( KoUnit::Unit unit, double _frameWidth, QWidget * parent )
00747         : KoParagLayoutWidget( KoParagDia::PD_SPACING, parent ), m_unit( unit )
00748 {
00749     QString unitName = KoUnit::unitName( m_unit );
00750     Q3GridLayout *mainGrid = new Q3GridLayout( this, 3, 2, KDialog::marginHint(), KDialog::spacingHint() );
00751 
00752     // mainGrid gives equal space to each groupbox, apparently
00753     // I tried setRowStretch but the result is awful (much space between them and not equal!)
00754     // Any other way (in order to make the 2nd, the one with a single checkbox, a bit
00755     // smaller than the other 3) ? (DF)
00756 
00757 
00758     // --------------- indent ---------------
00759     double frameWidth=_frameWidth;
00760     QString length;
00761     if(frameWidth==-1) {
00762         frameWidth=9999;
00763     } else {
00764         length=i18n("Frame width: %1 %2"
00765                 ,KoUnit::toUserStringValue(frameWidth,m_unit)
00766                 ,KoUnit::unitName(m_unit));
00767         frameWidth=KoUnit::toUserValue(frameWidth,m_unit);
00768     }
00769 
00770     Q3GroupBox * indentFrame = new Q3GroupBox( i18n( "Indent" ), this );
00771     Q3GridLayout * indentGrid = new Q3GridLayout( indentFrame, 5, 2, KDialog::marginHint(), KDialog::spacingHint() );
00772 
00773     QLabel * lLimit = new QLabel(length , indentFrame );
00774     if(frameWidth!=-1)
00775     {
00776         lLimit->setAlignment( Qt::AlignRight );
00777         indentGrid->addWidget( lLimit, 1,0 );
00778     }
00779 
00780     QLabel * lLeft = new QLabel( i18n("&Left:"), indentFrame );
00781     lLeft->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
00782     indentGrid->addWidget( lLeft, 1, 0 );
00783 
00784     eLeft = new KoUnitDoubleSpinBox( indentFrame, 0, 9999, 1, 0.0, m_unit );
00785     lLeft->setBuddy( eLeft );
00786     indentGrid->addWidget( eLeft, 1, 1 );
00787     connect( eLeft, SIGNAL( valueChangedPt(double ) ), this, SLOT( leftChanged( double ) ) );
00788 
00789     QLabel * lRight = new QLabel( i18n("&Right:"), indentFrame );
00790     lRight->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
00791     indentGrid->addWidget( lRight, 2, 0 );
00792 
00793     eRight = new KoUnitDoubleSpinBox( indentFrame, 0, 9999, 1, 0.0, m_unit );
00794     lRight->setBuddy( eRight );
00795     indentGrid->addWidget( eRight, 2, 1 );
00796     connect( eRight, SIGNAL( valueChangedPt( double ) ), this, SLOT( rightChanged( double ) ) );
00797 
00798     QLabel * lFirstLine = new QLabel( i18n("&First line:"), indentFrame );
00799     lFirstLine->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
00800     indentGrid->addWidget( lFirstLine, 3, 0 );
00801 
00802     eFirstLine = new KoUnitDoubleSpinBox( indentFrame, -9999, 9999, 1, 0.0, m_unit );
00803     lFirstLine->setBuddy( eFirstLine );
00804     connect( eFirstLine, SIGNAL( valueChangedPt( double ) ), this, SLOT( firstChanged( double ) ) );
00805     indentGrid->addWidget( eFirstLine, 3, 1 );
00806 
00807     // grid row spacing
00808     indentGrid->addItem( new QSpacerItem( 0, fontMetrics().height() / 2 ), 0, 0 ); // groupbox title
00809     for ( int i = 1 ; i < indentGrid->rowCount() ; ++i )
00810         indentGrid->setRowStretch( i, 1 );
00811     mainGrid->addWidget( indentFrame, 0, 0 );
00812 
00813         // --------------- line spacing ---------------
00814     Q3GroupBox * spacingFrame = new Q3GroupBox( i18n( "Line &Spacing" ), this, "spacingFrame" );
00815     Q3GridLayout * spacingGrid = new Q3GridLayout( spacingFrame, 2, 1,
00816                                                  KDialog::marginHint(), KDialog::spacingHint() );
00817 
00818     cSpacing = new QComboBox(spacingFrame, "" );
00819     cSpacing->setEditable( false );
00820     // Keep order in sync with lineSpacingType() and display()
00821     cSpacing->addItem( i18nc( "Line spacing value", "Single" ) );
00822     cSpacing->addItem( i18nc( "Line spacing value", "1.5 Lines" ) );
00823     cSpacing->addItem( i18nc( "Line spacing value", "Double" ) );
00824     cSpacing->addItem( i18n( "Proportional") ); // LS_MULTIPLE, called Proportional like in OO
00825     cSpacing->addItem( i18n( "Line Distance (%1)" ,unitName) ); // LS_CUSTOM
00826     cSpacing->addItem( i18n( "At Least (%1)" ,unitName) );
00827     cSpacing->addItem( i18n( "Fixed (%1)" ,unitName) ); // LS_FIXED
00828 
00829     connect( cSpacing, SIGNAL( activated( int ) ), this, SLOT( spacingActivated( int ) ) );
00830     spacingGrid->addWidget( cSpacing, 1, 0 );
00831 
00832     sSpacingStack = new QStackedWidget( spacingFrame );
00833 
00834     eSpacing = new KoUnitDoubleSpinBox( spacingFrame, 0, 9999, CM_TO_POINT(1),
00835                                         0.0, m_unit );
00836     eSpacing->setRange( 0, 9999, 1, false);
00837     connect( eSpacing, SIGNAL( valueChanged( double ) ), this, SLOT( spacingChanged( double ) ) );
00838     eSpacingPercent = new KIntNumInput( 100, spacingFrame );
00839     eSpacingPercent->setRange( 0, 1000, 10, false );
00840     eSpacingPercent->setSuffix( " %" );
00841     connect( eSpacingPercent, SIGNAL( valueChanged( int ) ), this, SLOT( spacingChanged( int ) ) );
00842 
00843     sSpacingStack->addWidget( eSpacing );
00844     sSpacingStack->addWidget( eSpacingPercent );
00845     spacingGrid->addWidget( sSpacingStack, 1, 1 );
00846 
00847     // grid row spacing
00848     spacingGrid->addItem( new QSpacerItem( 0, fontMetrics().height() / 2 ), 0, 0 ); // groupbox title
00849     for ( int i = 1 ; i < spacingGrid->rowCount() ; ++i )
00850         spacingGrid->setRowStretch( i, 1 );
00851     mainGrid->addWidget( spacingFrame, 1, 0 );
00852 
00853     eSpacing->setEnabled( true );
00854 
00855     // --------------- paragraph spacing ---------------
00856     Q3GroupBox * pSpaceFrame = new Q3GroupBox( i18n( "Para&graph Space" ), this, "pSpaceFrame" );
00857     Q3GridLayout * pSpaceGrid = new Q3GridLayout( pSpaceFrame, 3, 2,
00858                                                 KDialog::marginHint(), KDialog::spacingHint() );
00859 
00860     QLabel * lBefore = new QLabel( i18n("Before:"), pSpaceFrame );
00861     lBefore->setAlignment( Qt::AlignRight );
00862     pSpaceGrid->addWidget( lBefore, 1, 0 );
00863 
00864     eBefore = new KoUnitDoubleSpinBox( pSpaceFrame, 0, 9999, CM_TO_POINT(1), 0.0, m_unit );
00865     eBefore->setRange( 0 , 9999, 1, false);
00866     connect( eBefore, SIGNAL( valueChanged( double ) ), this, SLOT( beforeChanged( double ) ) );
00867     pSpaceGrid->addWidget( eBefore, 1, 1 );
00868 
00869     QLabel * lAfter = new QLabel( i18n("After:"), pSpaceFrame );
00870     lAfter->setAlignment( Qt::AlignRight );
00871     pSpaceGrid->addWidget( lAfter, 2, 0 );
00872 
00873     eAfter = new KoUnitDoubleSpinBox( pSpaceFrame, 0, 9999, 1, 0.0, m_unit );
00874     eAfter->setRange( 0, 9999, 1, false);
00875     connect( eAfter, SIGNAL( valueChanged( double ) ), this, SLOT( afterChanged( double ) ) );
00876     pSpaceGrid->addWidget( eAfter, 2, 1 );
00877 
00878     // grid row spacing
00879     pSpaceGrid->addItem( new QSpacerItem( 0, fontMetrics().height() / 2 ), 0, 0 ); // groupbox title
00880     for ( int i = 1 ; i < pSpaceGrid->rowCount() ; ++i )
00881         pSpaceGrid->setRowStretch( i, 1 );
00882     mainGrid->addWidget( pSpaceFrame, 2, 0 );
00883 
00884     // --------------- preview --------------------
00885     prev1 = new KPagePreview( this );
00886     mainGrid->addMultiCellWidget( prev1, 0, mainGrid->rowCount()-1, 1, 1 );
00887 
00888     mainGrid->setColumnStretch( 1, 1 );
00889     //mainGrid->setRowStretch( 4, 1 );
00890 }
00891 
00892 double KoIndentSpacingWidget::leftIndent() const
00893 {
00894     return qMax(0.0, eLeft->value() );
00895 }
00896 
00897 double KoIndentSpacingWidget::rightIndent() const
00898 {
00899     return qMax(0.0,eRight->value() );
00900 }
00901 
00902 double KoIndentSpacingWidget::firstLineIndent() const
00903 {
00904     return eFirstLine->value();
00905 }
00906 
00907 double KoIndentSpacingWidget::spaceBeforeParag() const
00908 {
00909     return qMax(0.0, eBefore->value() );
00910 }
00911 
00912 double KoIndentSpacingWidget::spaceAfterParag() const
00913 {
00914     return qMax(0.0, eAfter->value() );
00915 }
00916 
00917 KoParagLayout::SpacingType KoIndentSpacingWidget::lineSpacingType() const
00918 {
00919     int index = cSpacing->currentIndex();
00920     switch ( index ) {
00921     case 0:
00922         return KoParagLayout::LS_SINGLE;
00923     case 1:
00924         return KoParagLayout::LS_ONEANDHALF;
00925     case 2:
00926         return KoParagLayout::LS_DOUBLE;
00927     case 3:
00928         return KoParagLayout::LS_MULTIPLE;
00929     case 4:
00930         return KoParagLayout::LS_CUSTOM;
00931     case 5:
00932         return KoParagLayout::LS_AT_LEAST;
00933     case 6:
00934         return KoParagLayout::LS_FIXED;
00935     default:
00936         kError(32500) << "Error in KoIndentSpacingWidget::lineSpacingType" << endl;
00937         return KoParagLayout::LS_SINGLE;
00938     }
00939 }
00940 
00941 double KoIndentSpacingWidget::lineSpacing() const
00942 {
00943     return (lineSpacingType() == KoParagLayout::LS_MULTIPLE)
00944                                ? qMax( 1, eSpacingPercent->value() ) / 100.0
00945                                : qMax( 0.0, eSpacing->value() );
00946 }
00947 
00948 
00949 void KoIndentSpacingWidget::display( const KoParagLayout & lay )
00950 {
00951     double _left = lay.margins[Q3StyleSheetItem::MarginLeft];
00952     eLeft->changeValue( _left );
00953     //prev1->setLeft( _left );  done by leftChanged() below
00954     leftChanged( _left ); // sets min value for eFirstLine
00955 
00956     double _right = lay.margins[Q3StyleSheetItem::MarginRight];
00957     eRight->changeValue( _right );
00958     prev1->setRight( _right );
00959 
00960     double _first = lay.margins[Q3StyleSheetItem::MarginFirstLine];
00961     eFirstLine->changeValue( _first );
00962     prev1->setFirst( _first );
00963 
00964     double _before = lay.margins[Q3StyleSheetItem::MarginTop];
00965     eBefore->changeValue( _before );
00966     prev1->setBefore( _before );
00967 
00968     double _after = lay.margins[Q3StyleSheetItem::MarginBottom];
00969     eAfter->changeValue( _after );
00970     prev1->setAfter( _after );
00971 
00972     double _spacing = lay.lineSpacingValue();
00973     KoParagLayout::SpacingType _type = lay.lineSpacingType;
00974     switch ( _type ) {
00975     case KoParagLayout::LS_SINGLE: // single
00976         cSpacing->setCurrentIndex( 0 );
00977         break;
00978     case KoParagLayout::LS_ONEANDHALF:
00979         cSpacing->setCurrentIndex( 1 );
00980         break;
00981     case KoParagLayout::LS_DOUBLE:
00982         cSpacing->setCurrentIndex( 2 );
00983         break;
00984     case KoParagLayout::LS_MULTIPLE:
00985         cSpacing->setCurrentIndex( 3 );
00986         break;
00987     case KoParagLayout::LS_CUSTOM:
00988         cSpacing->setCurrentIndex( 4 );
00989         break;
00990     case KoParagLayout::LS_AT_LEAST:
00991         cSpacing->setCurrentIndex( 5 );
00992         break;
00993     case KoParagLayout::LS_FIXED:
00994         cSpacing->setCurrentIndex( 6 );
00995         break;
00996     default:
00997         cSpacing->setCurrentIndex( 0 );
00998         break;
00999     }
01000 
01001     updateLineSpacing( _type );
01002     eSpacing->setValue( (_type == KoParagLayout::LS_MULTIPLE) ? qMax( 1.0, _spacing )
01003                         : KoUnit::toUserValue( _spacing, m_unit ) );
01004     eSpacingPercent->setValue( ( _type == KoParagLayout::LS_MULTIPLE ) ? qRound( _spacing * 100 ) : 100 );
01005 }
01006 
01007 void KoIndentSpacingWidget::save( KoParagLayout & lay )
01008 {
01009     lay.setLineSpacingValue(lineSpacing());
01010     lay.lineSpacingType = lineSpacingType();
01011     lay.margins[Q3StyleSheetItem::MarginLeft] = leftIndent();
01012     lay.margins[Q3StyleSheetItem::MarginRight] = rightIndent();
01013     lay.margins[Q3StyleSheetItem::MarginFirstLine] = firstLineIndent();
01014     lay.margins[Q3StyleSheetItem::MarginTop] = spaceBeforeParag();
01015     lay.margins[Q3StyleSheetItem::MarginBottom] = spaceAfterParag();
01016 }
01017 
01018 QString KoIndentSpacingWidget::tabName()
01019 {
01020     return i18n( "Indent && S&pacing" );
01021 }
01022 
01023 void KoIndentSpacingWidget::leftChanged( double val )
01024 {
01025     prev1->setLeft( val );
01026     // The minimum first-line margin is -leftMargin() (where leftMargin>=0)
01027     eFirstLine->setMinimum( -qMax( 0.0, val ) );
01028 }
01029 
01030 void KoIndentSpacingWidget::rightChanged( double val )
01031 {
01032     prev1->setRight( val );
01033 }
01034 
01035 void KoIndentSpacingWidget::firstChanged( double val )
01036 {
01037     prev1->setFirst( val );
01038 }
01039 
01040 void KoIndentSpacingWidget::updateLineSpacing( KoParagLayout::SpacingType _type )
01041 {
01042     bool needsValue = (_type != KoParagLayout::LS_SINGLE &&
01043                        _type != KoParagLayout::LS_ONEANDHALF &&
01044                        _type != KoParagLayout::LS_DOUBLE);
01045 
01046     if ( _type == KoParagLayout::LS_MULTIPLE )
01047     {
01048         sSpacingStack->setCurrentWidget( eSpacingPercent );
01049     }
01050     else
01051     {
01052         sSpacingStack->setCurrentWidget( eSpacing );
01053     }
01054     eSpacing->setEnabled( needsValue );
01055     if ( needsValue )
01056         prev1->setSpacing( eSpacing->value() );
01057     else
01058     {
01059         prev1->setSpacing( _type == KoParagLayout::LS_ONEANDHALF ? 8 :
01060                            _type == KoParagLayout::LS_DOUBLE ? 16 :0 );
01061     }
01062 }
01063 
01064 void KoIndentSpacingWidget::spacingActivated( int /*_index*/ )
01065 {
01066     updateLineSpacing( lineSpacingType() );
01067     if ( eSpacing->isEnabled() ) // i.e. needsValue = true
01068         eSpacing->setFocus();
01069 }
01070 
01071 void KoIndentSpacingWidget::spacingChanged( double _val )
01072 {
01073     prev1->setSpacing( _val );
01074 }
01075 
01076 void KoIndentSpacingWidget::spacingChanged( int _val )
01077 {
01078     prev1->setSpacing( _val / 100.0 );
01079 }
01080 
01081 void KoIndentSpacingWidget::beforeChanged( double _val )
01082 {
01083     prev1->setBefore( KoUnit::fromUserValue( _val, m_unit ) );
01084 }
01085 
01086 void KoIndentSpacingWidget::afterChanged( double _val )
01087 {
01088     prev1->setAfter( KoUnit::fromUserValue( _val, m_unit ) );
01089 }
01090 
01091 
01092 KoParagAlignWidget::KoParagAlignWidget( bool breakLine, QWidget * parent )
01093         : KoParagLayoutWidget( KoParagDia::PD_ALIGN, parent )
01094 {
01095     Q3GridLayout *grid = new Q3GridLayout( this, 3, 2, KDialog::marginHint(), KDialog::spacingHint() );
01096 
01097     QGroupBox * AlignGroup = new QGroupBox( i18n( "Alignment" ), this );
01098 
01099     rLeft = new QRadioButton( i18n( "&Left" ), AlignGroup );
01100     connect( rLeft, SIGNAL( clicked() ), this, SLOT( alignLeft() ) );
01101 
01102     rCenter = new QRadioButton( i18n( "C&enter" ), AlignGroup );
01103     connect( rCenter, SIGNAL( clicked() ), this, SLOT( alignCenter() ) );
01104 
01105     rRight = new QRadioButton( i18n( "&Right" ), AlignGroup );
01106     connect( rRight, SIGNAL( clicked() ), this, SLOT( alignRight() ) );
01107 
01108     rJustify = new QRadioButton( i18n( "&Justify" ), AlignGroup );
01109     connect( rJustify, SIGNAL( clicked() ), this, SLOT( alignJustify() ) );
01110 
01111     clearAligns();
01112     rLeft->setChecked( true );
01113 
01114     grid->addWidget(AlignGroup, 0, 0);
01115 
01116     // --------------- End of page /frame ---------------
01117     Q3GroupBox * endFramePage = new Q3GroupBox( i18n( "Behavior at &End of Frame/Page" ), this );
01118     Q3GridLayout * endFramePageGrid = new Q3GridLayout( endFramePage, 4, 1,
01119                                                       KDialog::marginHint(), KDialog::spacingHint() );
01120 
01121     cKeepLinesTogether = new QCheckBox( i18n("&Keep lines together"),endFramePage);
01122     endFramePageGrid->addWidget( cKeepLinesTogether, 1, 0 );
01123     cHardBreakBefore = new QCheckBox( i18n("Insert break before paragraph"),endFramePage);
01124     endFramePageGrid->addWidget( cHardBreakBefore, 2, 0 );
01125     cHardBreakAfter = new QCheckBox( i18n("Insert break after paragraph"),endFramePage);
01126     endFramePageGrid->addWidget( cHardBreakAfter, 3, 0 );
01127 
01128     endFramePageGrid->addItem( new QSpacerItem( 0, fontMetrics().height() / 2 ), 0, 0 ); // groupbox title
01129     for ( int i = 0 ; i < endFramePageGrid->rowCount()-1 ; ++i )
01130         endFramePageGrid->setRowStretch( 0, 0 );
01131     endFramePageGrid->setRowStretch( endFramePageGrid->rowCount()-1, 1 );
01132     grid->addWidget( endFramePage, 2, 0 );
01133 
01134     endFramePage->setEnabled(breakLine);
01135 
01136     // --------------- preview --------------------
01137     prev2 = new KPagePreview2( this );
01138     grid->addMultiCellWidget( prev2, 0, 2, 1, 1 );
01139 
01140     // --------------- main grid ------------------
01141     grid->setColumnStretch( 1, 1 );
01142     grid->setRowStretch( 1, 1 );
01143 }
01144 
01145 int KoParagAlignWidget::pageBreaking() const
01146 {
01147     int pb = 0;
01148     if ( cKeepLinesTogether->isChecked() )
01149         pb |= KoParagLayout::KeepLinesTogether;
01150     if ( cHardBreakBefore->isChecked() )
01151         pb |= KoParagLayout::HardFrameBreakBefore;
01152     if ( cHardBreakAfter->isChecked() )
01153         pb |= KoParagLayout::HardFrameBreakAfter;
01154     return pb;
01155 }
01156 
01157 
01158 void KoParagAlignWidget::display( const KoParagLayout & lay )
01159 {
01160     int align = lay.alignment;
01161     prev2->setAlign( align );
01162 
01163     clearAligns();
01164     switch ( align ) {
01165         case Qt::AlignLeft: // see KoView::setAlign
01166             rLeft->setChecked( true );
01167             break;
01168         case Qt::AlignHCenter:
01169             rCenter->setChecked( true );
01170             break;
01171         case Qt::AlignRight:
01172             rRight->setChecked( true );
01173             break;
01174         case Qt::AlignJustify:
01175             rJustify->setChecked( true );
01176     }
01177 
01178     cKeepLinesTogether->setChecked( lay.pageBreaking & KoParagLayout::KeepLinesTogether );
01179     cHardBreakBefore->setChecked( lay.pageBreaking & KoParagLayout::HardFrameBreakBefore );
01180     cHardBreakAfter->setChecked( lay.pageBreaking & KoParagLayout::HardFrameBreakAfter );
01181     // ## preview support for end-of-frame ?
01182 }
01183 
01184 void KoParagAlignWidget::save( KoParagLayout & lay )
01185 {
01186     lay.alignment = align();
01187     lay.pageBreaking = pageBreaking();
01188 }
01189 
01190 int KoParagAlignWidget::align() const
01191 {
01192     if ( rLeft->isChecked() ) return Qt::AlignLeft;
01193     else if ( rCenter->isChecked() ) return Qt::AlignHCenter;
01194     else if ( rRight->isChecked() ) return Qt::AlignRight;
01195     else if ( rJustify->isChecked() ) return Qt::AlignJustify;
01196 
01197     return Qt::AlignLeft;
01198 }
01199 
01200 QString KoParagAlignWidget::tabName()
01201 {
01202     return i18n( "General &Layout" );
01203 }
01204 
01205 void KoParagAlignWidget::alignLeft()
01206 {
01207     prev2->setAlign( Qt::AlignLeft );
01208     clearAligns();
01209     rLeft->setChecked( true );
01210 }
01211 
01212 void KoParagAlignWidget::alignCenter()
01213 {
01214     prev2->setAlign( Qt::AlignHCenter );
01215     clearAligns();
01216     rCenter->setChecked( true );
01217 }
01218 
01219 void KoParagAlignWidget::alignRight()
01220 {
01221     prev2->setAlign( Qt::AlignRight );
01222     clearAligns();
01223     rRight->setChecked( true );
01224 }
01225 
01226 void KoParagAlignWidget::alignJustify()
01227 {
01228     prev2->setAlign( Qt::AlignJustify );
01229     clearAligns();
01230     rJustify->setChecked( true );
01231 }
01232 
01233 void KoParagAlignWidget::clearAligns()
01234 {
01235     rLeft->setChecked( false );
01236     rCenter->setChecked( false );
01237     rRight->setChecked( false );
01238     rJustify->setChecked( false );
01239 }
01240 
01242 
01243 KoParagDecorationWidget::KoParagDecorationWidget( QWidget * parent )
01244     : KoParagLayoutWidget( KoParagDia::PD_DECORATION, parent )
01245 {
01246     Q3VBoxLayout *tabLayout = new Q3VBoxLayout( this );
01247     wDeco = new KoParagDecorationTab( this );
01248     tabLayout->addWidget( wDeco );
01249 
01250     // Set up Border Style combo box
01251     wDeco->cbBorderStyle->addItem( KoBorder::getStyle( KoBorder::SOLID ) );
01252     wDeco->cbBorderStyle->addItem( KoBorder::getStyle( KoBorder::DASH ) );
01253     wDeco->cbBorderStyle->addItem( KoBorder::getStyle( KoBorder::DOT ) );
01254     wDeco->cbBorderStyle->addItem( KoBorder::getStyle( KoBorder::DASH_DOT ) );
01255     wDeco->cbBorderStyle->addItem( KoBorder::getStyle( KoBorder::DASH_DOT_DOT ) );
01256     wDeco->cbBorderStyle->addItem( KoBorder::getStyle( KoBorder::DOUBLE_LINE  ) );
01257 
01258     // Set up Border Width combo box
01259     for( unsigned int i = 1; i <= 10; i++ )
01260         wDeco->cbBorderWidth->addItem(QString::number(i));
01261 
01262     // Setup the border toggle buttons, and merge checkbox
01263     connect( wDeco->bBorderLeft, SIGNAL( toggled( bool ) ),
01264              this, SLOT( brdLeftToggled( bool ) ) );
01265     connect( wDeco->bBorderRight, SIGNAL( toggled( bool ) ),
01266              this, SLOT( brdRightToggled( bool ) ) );
01267     connect( wDeco->bBorderTop, SIGNAL( toggled( bool ) ),
01268              this, SLOT( brdTopToggled( bool ) ) );
01269     connect( wDeco->bBorderBottom, SIGNAL( toggled( bool ) ),
01270              this, SLOT( brdBottomToggled( bool ) ) );
01271     connect( wDeco->cbJoinBorder, SIGNAL( toggled( bool ) ),
01272              this, SLOT( brdJoinToggled( bool ) ) );
01273 
01274     // Set up Border preview widget
01275     wPreview  = new KoBorderPreview( wDeco->borderPreview );
01276     Q3VBoxLayout *previewLayout = new Q3VBoxLayout( wDeco->borderPreview );
01277     previewLayout->addWidget( wPreview );
01278     connect( wPreview, SIGNAL( choosearea(QMouseEvent * ) ),
01279              this, SLOT( slotPressEvent(QMouseEvent *) ) );
01280 }
01281 
01283 // Current GUI selections
01284 KoBorder::BorderStyle KoParagDecorationWidget::curBorderStyle() const
01285 {
01286     QString selection = wDeco->cbBorderStyle->currentText();
01287     return KoBorder::getStyle( selection );
01288 }
01289 
01290 unsigned int KoParagDecorationWidget::curBorderWidth() const {
01291     return wDeco->cbBorderWidth->currentText().toUInt();
01292 }
01293 
01294 QColor KoParagDecorationWidget::curBorderColor() const {
01295     return wDeco->bBorderColor->color();
01296 }
01298 
01299 // Check whether a border is the same as that selected in the GUI
01300 bool KoParagDecorationWidget::borderChanged( const KoBorder& border ) {
01301     return (unsigned int)border.penWidth() != curBorderWidth() ||
01302            border.color != curBorderColor() ||
01303            border.getStyle() != curBorderStyle();
01304 }
01305 
01306 // Set a given border according to the values selected in the GUI
01307 void KoParagDecorationWidget::updateBorder( KoBorder& border )
01308 {
01309     border.setPenWidth( curBorderWidth() );
01310     border.color = curBorderColor();
01311     border.setStyle( curBorderStyle () );
01312 }
01313 
01314 void KoParagDecorationWidget::clickedBorderPreview( KoBorder& border,
01315                                                      KoBorder::BorderType position,
01316                                                      KPushButton *corresponding )
01317 {
01318     if ( borderChanged( border ) && corresponding->isOn() ) {
01319         updateBorder( border );
01320         wPreview->setBorder( position, border );
01321     }
01322     else
01323         corresponding->setOn( !corresponding->isOn() );
01324 }
01325 
01326 // Establish which border position was clicked in the border preview,
01327 // and update the appropriate border
01328 void KoParagDecorationWidget::slotPressEvent(QMouseEvent *_ev)
01329 {
01330     const int OFFSETX = 15;
01331     const int OFFSETY = 7;
01332     const int Ko_SPACE = 30;
01333 
01334     QRect r = wPreview->contentsRect();
01335     QRect rect(r.x() + OFFSETX, r.y() + OFFSETY,
01336                r.width() - OFFSETX, r.y() + OFFSETY + Ko_SPACE);
01337     if(rect.contains(QPoint(_ev->x(),_ev->y())))
01338     {
01339         clickedBorderPreview( m_topBorder, KoBorder::TopBorder,
01340                               wDeco->bBorderTop );
01341     }
01342 
01343     rect.setCoords(r.x() + OFFSETX, r.height() - OFFSETY - Ko_SPACE,
01344                    r.width() - OFFSETX, r.height() - OFFSETY);
01345     if(rect.contains(QPoint(_ev->x(),_ev->y())))
01346     {
01347         clickedBorderPreview( m_bottomBorder, KoBorder::BottomBorder,
01348                               wDeco->bBorderBottom );
01349     }
01350 
01351     rect.setCoords(r.x() + OFFSETX, r.y() + OFFSETY,
01352                    r.x() + Ko_SPACE + OFFSETX, r.height() - OFFSETY);
01353     if(rect.contains(QPoint(_ev->x(),_ev->y())))
01354     {
01355         clickedBorderPreview( m_leftBorder, KoBorder::LeftBorder,
01356                               wDeco->bBorderLeft );
01357     }
01358 
01359     rect.setCoords(r.width() - OFFSETX - Ko_SPACE, r.y() + OFFSETY,
01360                    r.width() - OFFSETX, r.height() - OFFSETY);
01361     if(rect.contains(QPoint(_ev->x(),_ev->y())))
01362     {
01363         clickedBorderPreview( m_rightBorder, KoBorder::RightBorder,
01364                               wDeco->bBorderRight );
01365     }
01366 }
01367 
01368 void KoParagDecorationWidget::display( const KoParagLayout & lay )
01369 {
01370     wDeco->bBackgroundColor->setColor( lay.backgroundColor );
01371 
01372     m_leftBorder = lay.leftBorder;
01373     m_rightBorder = lay.rightBorder;
01374     m_topBorder = lay.topBorder;
01375     m_bottomBorder = lay.bottomBorder;
01376     m_joinBorder = lay.joinBorder;
01377 
01378     wDeco->bBorderLeft->blockSignals( true );
01379     wDeco->bBorderRight->blockSignals( true );
01380     wDeco->bBorderTop->blockSignals( true );
01381     wDeco->bBorderBottom->blockSignals( true );
01382     updateBorders();
01383     wDeco->bBorderLeft->blockSignals( false );
01384     wDeco->bBorderRight->blockSignals( false );
01385     wDeco->bBorderTop->blockSignals( false );
01386     wDeco->bBorderBottom->blockSignals( false );
01387 }
01388 
01389 void KoParagDecorationWidget::updateBorders()
01390 {
01391     wDeco->bBorderLeft->setOn( m_leftBorder.penWidth() > 0 );
01392     wDeco->bBorderRight->setOn( m_rightBorder.penWidth() > 0 );
01393     wDeco->bBorderTop->setOn( m_topBorder.penWidth() > 0 );
01394     wDeco->bBorderBottom->setOn( m_bottomBorder.penWidth() > 0 );
01395     wDeco->cbJoinBorder->setChecked( m_joinBorder );
01396     wPreview->setLeftBorder( m_leftBorder );
01397     wPreview->setRightBorder( m_rightBorder );
01398     wPreview->setTopBorder( m_topBorder );
01399     wPreview->setBottomBorder( m_bottomBorder );
01400 }
01401 
01402 
01403 void KoParagDecorationWidget::save( KoParagLayout & lay )
01404 {
01405     lay.backgroundColor = wDeco->bBackgroundColor->color();
01406     lay.topBorder = m_topBorder;
01407     lay.bottomBorder = m_bottomBorder;
01408     lay.leftBorder = m_leftBorder;
01409     lay.rightBorder = m_rightBorder;
01410     lay.joinBorder = m_joinBorder;
01411 }
01412 
01413 QColor KoParagDecorationWidget::backgroundColor() const {
01414     return wDeco->bBackgroundColor->color();
01415 }
01416 
01417 QString KoParagDecorationWidget::tabName() {
01418     // Why D&e..?  Because &De.. conflicts with &Delete in
01419     // the style manager.
01420     return i18n( "D&ecorations" );
01421 }
01422 
01423 void KoParagDecorationWidget::brdLeftToggled( bool _on )
01424 {
01425     if ( !_on )
01426         m_leftBorder.setPenWidth(0);
01427     else {
01428         m_leftBorder.setPenWidth( curBorderWidth() );
01429         m_leftBorder.color = curBorderColor();
01430         m_leftBorder.setStyle( curBorderStyle() );
01431     }
01432     wPreview->setLeftBorder( m_leftBorder );
01433 }
01434 
01435 void KoParagDecorationWidget::brdRightToggled( bool _on )
01436 {
01437     if ( !_on )
01438         m_rightBorder.setPenWidth(0);
01439     else {
01440         m_rightBorder.setPenWidth( curBorderWidth() );
01441         m_rightBorder.color = curBorderColor();
01442         m_rightBorder.setStyle( curBorderStyle() );
01443     }
01444     wPreview->setRightBorder( m_rightBorder );
01445 }
01446 
01447 void KoParagDecorationWidget::brdTopToggled( bool _on )
01448 {
01449     if ( !_on )
01450         m_topBorder.setPenWidth(0);
01451     else {
01452         m_topBorder.setPenWidth( curBorderWidth() );
01453         m_topBorder.color = curBorderColor();
01454         m_topBorder.setStyle( curBorderStyle() );
01455     }
01456     wPreview->setTopBorder( m_topBorder );
01457 }
01458 
01459 void KoParagDecorationWidget::brdBottomToggled( bool _on )
01460 {
01461     if ( !_on )
01462         m_bottomBorder.setPenWidth ( 0 );
01463     else {
01464         m_bottomBorder.setPenWidth( curBorderWidth() );
01465         m_bottomBorder.color = curBorderColor();
01466         m_bottomBorder.setStyle( curBorderStyle() );
01467     }
01468     wPreview->setBottomBorder( m_bottomBorder );
01469 }
01470 
01471 void KoParagDecorationWidget::brdJoinToggled( bool _on ) {
01472     m_joinBorder = _on;
01473 }
01475 
01476 
01477 KoParagCounterWidget::KoParagCounterWidget( bool disableAll, QWidget * parent )
01478     : KoParagLayoutWidget( KoParagDia::PD_NUMBERING, parent )
01479 {
01480 
01481     Q3VBoxLayout *Form1Layout = new Q3VBoxLayout( this );
01482     Form1Layout->setSpacing( KDialog::spacingHint() );
01483     Form1Layout->setMargin( KDialog::marginHint() );
01484 
01485     gNumbering = new Q3ButtonGroup( this, "numberingGroup" );
01486     gNumbering->setTitle( i18n( "Numbering" ) );
01487     gNumbering->setColumnLayout(0, Qt::Vertical );
01488     gNumbering->layout()->setSpacing( 0 );
01489     gNumbering->layout()->setMargin( 0 );
01490     Q3HBoxLayout *numberingGroupLayout = new Q3HBoxLayout();
01491     gNumbering->layout()->addItem( numberingGroupLayout );
01492     numberingGroupLayout->setAlignment( Qt::AlignTop );
01493     numberingGroupLayout->setSpacing( KDialog::spacingHint() );
01494     numberingGroupLayout->setMargin( KDialog::marginHint() );
01495 
01496     // What type of numbering is required?
01497     QRadioButton *rNone = new QRadioButton( gNumbering );
01498     rNone->setText( i18n( "&None" ) );
01499     numberingGroupLayout->addWidget( rNone );
01500 
01501     gNumbering->insert( rNone , KoParagCounter::NUM_NONE);
01502 
01503     QRadioButton *rList = new QRadioButton( gNumbering );
01504     rList->setText( i18n( "&List" ) );
01505     gNumbering->insert( rList , KoParagCounter::NUM_LIST);
01506     numberingGroupLayout->addWidget( rList );
01507 
01508     QRadioButton *rChapter = new QRadioButton( gNumbering );
01509     rChapter->setText( i18n( "Chapt&er" ) );
01510     gNumbering->insert( rChapter , KoParagCounter::NUM_CHAPTER);
01511     numberingGroupLayout->addWidget( rChapter );
01512     Form1Layout->addWidget( gNumbering );
01513     connect( gNumbering, SIGNAL( clicked( int ) ), this, SLOT( numTypeChanged( int ) ) );
01514 
01515     m_styleWidget = new KoCounterStyleWidget( true, false, disableAll, this );
01516 
01517     connect( m_styleWidget, SIGNAL( sig_suffixChanged (const QString &) ), this, SLOT( suffixChanged(const QString &) ) );
01518     connect( m_styleWidget, SIGNAL( sig_prefixChanged (const QString &) ), this, SLOT( prefixChanged(const QString &) ) );
01519     connect( m_styleWidget, SIGNAL( sig_startChanged(int) ), this, SLOT( startChanged(int) ) );
01520     connect( m_styleWidget, SIGNAL( sig_restartChanged(bool) ), this, SLOT( restartChanged(bool) ) );
01521     connect( m_styleWidget, SIGNAL( sig_depthChanged (int) ), this, SLOT( depthChanged(int) ) );
01522     connect( m_styleWidget, SIGNAL( sig_displayLevelsChanged (int) ), this, SLOT( displayLevelsChanged(int) ) );
01523     connect( m_styleWidget, SIGNAL( sig_alignmentChanged (int) ), this, SLOT( alignmentChanged(int) ) );
01524     connect( m_styleWidget, SIGNAL( changeCustomBullet( const QString & , QChar ) ), this, SLOT( slotChangeCustomBullet( const QString & , QChar ) ) );
01525 
01526     connect( m_styleWidget, SIGNAL( sig_numTypeChanged( int ) ), this, SLOT( numTypeChanged(int ) ) );
01527     connect( m_styleWidget, SIGNAL( changeStyle( KoParagCounter::Style ) ), this, SLOT( styleChanged (KoParagCounter::Style ) ) );
01528 
01529     Form1Layout->addWidget( m_styleWidget );
01530 
01531 
01532     preview = new KoStylePreview( i18n( "Preview" ), i18n("Normal paragraph text"), this );
01533     preview->setObjectName( "counter preview" );
01534     Form1Layout->addWidget( preview );
01535     if ( disableAll)
01536     {
01537         gNumbering->setEnabled( false);
01538         preview->setEnabled( false );
01539     }
01540 
01541     QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
01542     Form1Layout->addItem( spacer );
01543 }
01544 
01545 void KoParagCounterWidget::styleChanged( KoParagCounter::Style st )
01546 {
01547     m_counter.setStyle( st );
01548     updatePreview();
01549 }
01550 
01551 void KoParagCounterWidget::slotChangeCustomBullet( const QString & f, QChar c)
01552 {
01553     m_counter.setCustomBulletFont( f );
01554     m_counter.setCustomBulletCharacter( c );
01555     preview->setCounter( m_counter );
01556 }
01557 
01558 QString KoParagCounterWidget::tabName() {
01559     return i18n( "B&ullets/Numbers" );
01560 }
01561 
01562 void KoParagCounterWidget::numTypeChanged( int nType ) {
01563     // radio buttons pressed to change numbering type
01564     m_counter.setNumbering( static_cast<KoParagCounter::Numbering>( nType ) );
01565     preview->setEnabled( m_counter.numbering() != KoParagCounter::NUM_NONE );
01566     m_styleWidget->numTypeChanged( nType );
01567 
01568     updatePreview();
01569 }
01570 
01571 void KoParagCounterWidget::display( const KoParagLayout & lay ) {
01572     KoParagCounter::Style style = KoParagCounter::STYLE_NONE;
01573     if ( lay.counter )
01574     {
01575         style=lay.counter->style();
01576         m_counter = *lay.counter;
01577     }
01578     else
01579     {
01580         m_counter = KoParagCounter();
01581     }
01582     gNumbering->setButton( m_counter.numbering() );
01583     preview->setStyle( lay.style );
01584     preview->setCounter( m_counter );
01585     m_styleWidget->display( lay );
01586 }
01587 
01588 void KoParagCounterWidget::updatePreview() {
01589     preview->setCounter(m_counter);
01590     preview->update();
01591 }
01592 
01593 void KoParagCounterWidget::save( KoParagLayout & lay ) {
01594 /*    m_counter.setDepth(spnDepth->value());
01595     m_counter.setStartNumber(spnStart->value());
01596     m_counter.setPrefix(sPrefix->text());
01597     m_counter.setSuffix(sSuffix->text()); */
01598 
01599     if ( lay.counter )
01600         *lay.counter = m_counter;
01601     else
01602         lay.counter = new KoParagCounter( m_counter );
01603 }
01604 
01605 KoTabulatorsLineEdit::KoTabulatorsLineEdit( QWidget *parent, double lower, double toUpper, double step, double value /*= 0.0*/, KoUnit::Unit unit /*= KoUnit::U_PT*/, unsigned int precision /*= 2*/ )
01606     : KoUnitDoubleSpinBox ( parent, lower, toUpper, step, value, unit, precision )
01607 {
01608     setRange( 0, 9999, 1, false);
01609 }
01610 
01611 void KoTabulatorsLineEdit::keyPressEvent ( QKeyEvent *ke )
01612 {
01613     if( ke->key()  == Qt::Key_Return ||
01614         ke->key()  == Qt::Key_Enter )
01615     {
01616         emit keyReturnPressed();
01617         return;
01618     }
01619     KoUnitDoubleSpinBox::keyPressEvent (ke);
01620 }
01621 
01622 KoParagTabulatorsWidget::KoParagTabulatorsWidget( KoUnit::Unit unit, double frameWidth, QWidget * parent )
01623     : KoParagLayoutWidget( KoParagDia::PD_TABS, parent ), m_unit(unit) {
01624     QString length;
01625     if(frameWidth==-1) {
01626         frameWidth=9999;
01627         m_toplimit=9999;
01628     } else {
01629         m_toplimit=frameWidth;
01630         length=i18n("Frame width: %1 %2",
01631                 KoUnit::toUserStringValue(frameWidth,m_unit),
01632                 KoUnit::unitName(m_unit));
01633         frameWidth=KoUnit::toUserValue(frameWidth,m_unit);
01634     }
01635     Q3VBoxLayout* Form1Layout = new Q3VBoxLayout( this );
01636     Form1Layout->setSpacing( KDialog::spacingHint() );
01637     Form1Layout->setMargin( KDialog::marginHint() );
01638 
01639     Q3HBoxLayout* Layout13 = new Q3HBoxLayout;
01640     Layout13->setSpacing( KDialog::spacingHint() );
01641     Layout13->setMargin( 0 ); //?
01642 
01643     lstTabs = new Q3ListBox( this);
01644     lstTabs->insertItem( "mytabvalue" );
01645     lstTabs->setMaximumSize( QSize( 300, 32767 ) );
01646     Layout13->addWidget( lstTabs );
01647 
01648     editLayout = new Q3VBoxLayout;
01649     editLayout->setSpacing( KDialog::spacingHint() );
01650     editLayout->setMargin( 0 ); //?
01651 
01652     gPosition = new Q3GroupBox( this, "gPosition" );
01653     gPosition->setTitle( i18n( "Po&sition" ) );
01654     gPosition->setColumnLayout(0, Qt::Vertical );
01655     gPosition->layout()->setSpacing( 0 );
01656     gPosition->layout()->setMargin( 0 );
01657     Q3VBoxLayout* GroupBox2Layout = new Q3VBoxLayout();
01658     gPosition->layout()->addItem( GroupBox2Layout );
01659     GroupBox2Layout->setAlignment( Qt::AlignTop );
01660     GroupBox2Layout->setSpacing( KDialog::spacingHint() );
01661     GroupBox2Layout->setMargin( KDialog::marginHint() );
01662 
01663     Q3HBoxLayout* Layout5 = new Q3HBoxLayout;
01664     Layout5->setSpacing( KDialog::spacingHint() );
01665     Layout5->setMargin( 0 ); //?
01666 
01667     sTabPos = new KoTabulatorsLineEdit( gPosition, 0, 9999, 1, 0.0, m_unit );
01668     sTabPos->setRange( 0, 9999, 1 );
01669     sTabPos->setMaximumSize( QSize( 100, 32767 ) );
01670     Layout5->addWidget( sTabPos );
01671     QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
01672     Layout5->addItem( spacer );
01673     GroupBox2Layout->addLayout( Layout5 );
01674     editLayout->addWidget( gPosition );
01675 
01676     QLabel* TextLabel1 = new QLabel( gPosition );
01677     QString unitDescription = KoUnit::unitDescription( m_unit );
01678     TextLabel1->setText( length );
01679     GroupBox2Layout->addWidget( TextLabel1 );
01680 
01681     bgAlign = new Q3ButtonGroup( this );
01682     bgAlign->setTitle( i18n( "Alignment" ) );
01683     bgAlign->setColumnLayout(0, Qt::Vertical );
01684     bgAlign->layout()->setSpacing( 0 );
01685     bgAlign->layout()->setMargin( 0 );
01686     Q3VBoxLayout* ButtonGroup1Layout = new Q3VBoxLayout();
01687     bgAlign->layout()->addItem( ButtonGroup1Layout );
01688     ButtonGroup1Layout->setAlignment( Qt::AlignTop );
01689     ButtonGroup1Layout->setSpacing( KDialog::spacingHint() );
01690     ButtonGroup1Layout->setMargin( KDialog::marginHint() );
01691 
01692     rAlignLeft = new QRadioButton( bgAlign );
01693     rAlignLeft->setText( i18n( "&Left" ) );
01694     ButtonGroup1Layout->addWidget( rAlignLeft );
01695 
01696     rAlignCenter = new QRadioButton( bgAlign );
01697     rAlignCenter->setText( i18n( "C&enter" ) );
01698     ButtonGroup1Layout->addWidget( rAlignCenter );
01699 
01700     rAlignRight = new QRadioButton( bgAlign );
01701     rAlignRight->setText( i18n( "&Right" ) );
01702     ButtonGroup1Layout->addWidget( rAlignRight );
01703 
01704     Q3HBoxLayout* Layout8 = new Q3HBoxLayout;
01705     Layout8->setSpacing( KDialog::spacingHint() );
01706     Layout8->setMargin( 0 );
01707 
01708     rAlignVar = new QRadioButton( bgAlign );
01709     rAlignVar->setText( i18n( "On followin&g character: " ) );
01710     Layout8->addWidget( rAlignVar );
01711 
01712     sAlignChar = new QLineEdit( bgAlign);
01713     sAlignChar->setMaximumSize( QSize( 60, 32767 ) );
01714     sAlignChar->setText(QString(KGlobal::locale()->decimalSymbol()[0]));
01715     Layout8->addWidget( sAlignChar );
01716     QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
01717     Layout8->addItem( spacer_2 );
01718     ButtonGroup1Layout->addLayout( Layout8 );
01719     editLayout->addWidget( bgAlign );
01720 
01721     gTabLeader = new Q3GroupBox( this, "gTabLeader" );
01722     gTabLeader->setTitle( i18n( "Tab Leader" ) );
01723     Q3VBoxLayout* GroupBox5Layout = new Q3VBoxLayout( gTabLeader );
01724     GroupBox5Layout->setAlignment( Qt::AlignTop );
01725     GroupBox5Layout->setSpacing( KDialog::spacingHint() );
01726     GroupBox5Layout->setMargin( KDialog::marginHint() );
01727     GroupBox5Layout->addSpacing( fontMetrics().height() / 2 ); // groupbox title
01728 
01729     QLabel* TextLabel1_2 = new QLabel( gTabLeader );
01730     TextLabel1_2->setText( i18n( "The space a tab uses can be filled with a pattern." ) );
01731     GroupBox5Layout->addWidget( TextLabel1_2 );
01732 
01733     Q3GridLayout *fillingGrid = new Q3GridLayout( 0L, 2, 2, 0, KDialog::spacingHint() );
01734 
01735     QLabel* TextLabel2 = new QLabel( gTabLeader);
01736     TextLabel2->setText( i18n( "&Filling:" ) );
01737     TextLabel2->setAlignment( Qt::AlignRight );
01738     fillingGrid->addWidget( TextLabel2, 0, 0 );
01739 
01740     cFilling = new QComboBox( gTabLeader);
01741     cFilling->setEditable( false );
01742     cFilling->addItem( i18n( "Blank" ) );
01743     cFilling->addItem( "_ _ _ _ _ _"); // DOT
01744     cFilling->addItem( "_________");   // SOLID
01745     cFilling->addItem( "___ ___ __");  // DASH
01746     cFilling->addItem( "___ _ ___ _"); // DASH_DOT
01747     cFilling->addItem( "___ _ _ ___"); // DASH_DOT_DOT
01748     TextLabel2->setBuddy( cFilling );
01749     fillingGrid->addWidget( cFilling, 0, 1 );
01750 
01751     QLabel * TextLabel3 = new QLabel( i18n("Size:"), gTabLeader );
01752     TextLabel3->setAlignment( Qt::AlignRight );
01753     fillingGrid->addWidget( TextLabel3, 1, 0 );
01754 
01755     eWidth = new KoUnitDoubleSpinBox( gTabLeader );
01756     eWidth->setUnit( m_unit );
01757     eWidth->setMinimum(0.0);
01758     TextLabel3->setBuddy( eWidth );
01759     fillingGrid->addWidget( eWidth, 1, 1 );
01760 
01761     GroupBox5Layout->addLayout( fillingGrid );
01762     editLayout->addWidget( gTabLeader );
01763     QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
01764     editLayout->addItem( spacer_4 );
01765     Layout13->addLayout( editLayout );
01766     Form1Layout->addLayout( Layout13 );
01767 
01768     Q3HBoxLayout* Layout4 = new Q3HBoxLayout;
01769     Layout4->setSpacing( KDialog::spacingHint() );
01770     Layout4->setMargin( 0 );
01771 
01772     bNew = new QPushButton( this);
01773     bNew->setText( i18n( "&New" ) );
01774     Layout4->addWidget( bNew );
01775 
01776     bDelete = new QPushButton( this);
01777     bDelete->setText( i18n( "&Delete" ) );
01778     Layout4->addWidget( bDelete );
01779 
01780     bDeleteAll = new QPushButton( this);
01781     bDeleteAll->setText( i18n( "Delete All" ) );
01782     Layout4->addWidget( bDeleteAll );
01783 
01784     QSpacerItem* spacer_5 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
01785     Layout4->addItem( spacer_5 );
01786     Form1Layout->addLayout( Layout4 );
01787 
01788     //signal valueChanged passes value which the user see (unlike the value() function)
01789     //so fromUserValue has to be used in slotTabValueChanged
01790     connect(sTabPos,SIGNAL(valueChanged(double)), this, SLOT(slotTabValueChanged(double )));
01791     connect(sTabPos,SIGNAL( keyReturnPressed()),this,SLOT(newClicked()));
01792     connect(sAlignChar,SIGNAL(textChanged( const QString & )), this, SLOT(slotAlignCharChanged( const QString & )));
01793     connect(bNew,SIGNAL(clicked ()),this,SLOT(newClicked()));
01794     connect(bDelete,SIGNAL(clicked ()),this,SLOT(deleteClicked()));
01795     connect(bDeleteAll,SIGNAL(clicked ()),this,SLOT(deleteAllClicked()));
01796     connect(bgAlign,SIGNAL(clicked (int)),this,SLOT(updateAlign(int)));
01797     connect(cFilling,SIGNAL(activated (int)),this,SLOT(updateFilling(int)));
01798     connect(eWidth,SIGNAL(valueChangedPt ( double ) ),this,SLOT(updateWidth()));
01799     connect(lstTabs,SIGNAL(highlighted (int)),this,SLOT(setActiveItem(int)));
01800     noSignals=false;
01801 }
01802 
01803 void KoParagTabulatorsWidget::slotTabValueChanged( double val ) {
01804     if(noSignals) return;
01805     noSignals=true;
01806     //see comment where this slot is connected
01807     m_tabList[lstTabs->currentItem()].ptPos = KoUnit::fromUserValue( val, m_unit );
01808 
01809     lstTabs->changeItem(tabToString(m_tabList[lstTabs->currentItem()]), lstTabs->currentItem());
01810 
01811     sortLists();
01812     noSignals=false;
01813 }
01814 
01815 void KoParagTabulatorsWidget::slotAlignCharChanged( const QString &/*_text*/ ) {
01816     // select align 3 and update data structures.
01817     bgAlign->setButton(3);
01818     m_tabList[lstTabs->currentItem()].alignChar=sAlignChar->text()[0];
01819     m_tabList[lstTabs->currentItem()].type=T_DEC_PNT;
01820 }
01821 
01822 void KoParagTabulatorsWidget::newClicked() {
01823     int selected=lstTabs->currentItem();
01824     KoTabulator newTab;
01825     if(selected < 0) {
01826         newTab.ptPos=0;
01827         newTab.type=T_LEFT;
01828         newTab.filling=TF_BLANK;
01829         newTab.ptWidth=0.5;
01830         m_tabList.append(newTab);
01831         lstTabs->insertItem(tabToString(newTab));
01832         lstTabs->setCurrentItem(0);
01833     } else {
01834         double pos = m_tabList[selected].ptPos;
01835         double add=1.0;
01836         if(m_unit==KoUnit::U_INCH) // inches are 25 times as big as mm, take it easy with adding..
01837             add=0.1;
01838 
01839         pos=pos + KoUnit::fromUserValue( add, m_unit );
01840         if(pos<m_toplimit)
01841         {
01842             newTab.ptPos=pos + KoUnit::fromUserValue( add, m_unit );
01843             newTab.type=m_tabList[selected].type;
01844             newTab.filling=m_tabList[selected].filling;
01845             newTab.ptWidth=m_tabList[selected].ptWidth;
01846             m_tabList.insert(selected, newTab);
01847             lstTabs->insertItem( tabToString(newTab), selected);
01848             lstTabs->setCurrentItem(lstTabs->findItem(tabToString(newTab)));
01849             sortLists();
01850         }
01851     }
01852 }
01853 
01854 void KoParagTabulatorsWidget::deleteClicked() {
01855     int selected = lstTabs->currentItem();
01856     if (selected < 0) return;
01857     noSignals=true;
01858     sTabPos->changeValue(0.0);
01859     noSignals=false;
01860     lstTabs->removeItem(selected);
01861     m_tabList.remove(m_tabList[selected]);
01862     if(lstTabs->count() >0) {
01863         lstTabs->setCurrentItem(qMin(static_cast<unsigned int>(selected), lstTabs->count()-1 ));
01864     } else {
01865         bDeleteAll->setEnabled(false);
01866         bDelete->setEnabled(false);
01867         gPosition->setEnabled(false);
01868         bgAlign->setEnabled(false);
01869         gTabLeader->setEnabled(false);
01870     }
01871 }
01872 
01873 void KoParagTabulatorsWidget::deleteAllClicked()
01874 {
01875     noSignals=true;
01876     sTabPos->changeValue(0.0);
01877     noSignals=false;
01878     lstTabs->clear();
01879     m_tabList.clear();
01880     bDeleteAll->setEnabled(false);
01881     bDelete->setEnabled(false);
01882     gPosition->setEnabled(false);
01883     bgAlign->setEnabled(false);
01884     gTabLeader->setEnabled(false);
01885 }
01886 
01887 void KoParagTabulatorsWidget::setActiveItem(int selected) {
01888     if(noSignals) return;
01889     if(selected < 0) return;
01890     noSignals=true;
01891     KoTabulator *selectedTab = &m_tabList[selected];
01892     switch( selectedTab->type) {
01893         case T_CENTER:
01894             bgAlign->setButton(1); break;
01895         case  T_RIGHT:
01896             bgAlign->setButton(2); break;
01897         case T_DEC_PNT:
01898             bgAlign->setButton(3);
01899             sAlignChar->setText(QString(selectedTab->alignChar));
01900             break;
01901         case T_LEFT:
01902         default:
01903             bgAlign->setButton(0);
01904     }
01905     switch( selectedTab->filling) {
01906         case TF_DOTS:
01907             cFilling->setCurrentIndex(1); break;
01908         case TF_LINE:
01909             cFilling->setCurrentIndex(2); break;
01910         case TF_DASH:
01911             cFilling->setCurrentIndex(3); break;
01912         case TF_DASH_DOT:
01913             cFilling->setCurrentIndex(4); break;
01914         case TF_DASH_DOT_DOT:
01915             cFilling->setCurrentIndex(5); break;
01916         case TF_BLANK:
01917         default:
01918             cFilling->setCurrentIndex(0);
01919     }
01920     eWidth->changeValue( selectedTab->ptWidth );
01921     sTabPos->setValue( KoUnit::toUserValue(selectedTab->ptPos, m_unit));
01922     bDelete->setEnabled(true);
01923     bDeleteAll->setEnabled(true);
01924     gPosition->setEnabled(true);
01925     bgAlign->setEnabled(true);
01926     gTabLeader->setEnabled(true);
01927     noSignals=false;
01928 }
01929 
01930 void KoParagTabulatorsWidget::setCurrentTab( double tabPos ) {
01931     KoTabulatorList::ConstIterator it = m_tabList.begin();
01932     for ( int i = 0; it != m_tabList.end(); ++it, ++i )
01933         if ( (*it).ptPos == tabPos ) {
01934             lstTabs->setCurrentItem(i);
01935             setActiveItem( i );
01936             return;
01937         }
01938     kWarning() << "KoParagTabulatorsWidget::setCurrentTab: no tab found at pos=" << tabPos << endl;
01939 }
01940 
01941 QString KoParagTabulatorsWidget::tabToString(const KoTabulator &tab) {
01942     return KoUnit::toUserStringValue( tab.ptPos, m_unit);
01943 }
01944 
01945 void KoParagTabulatorsWidget::updateAlign(int selected) {
01946     KoTabulator *selectedTab = &m_tabList[lstTabs->currentItem()];
01947 
01948     switch( selected) {
01949         case 1:
01950             selectedTab->type=T_CENTER; break;
01951         case  2:
01952             selectedTab->type=T_RIGHT; break;
01953         case 3:
01954             selectedTab->type=T_DEC_PNT;
01955             selectedTab->alignChar=sAlignChar->text()[0];
01956             break;
01957         case 0:
01958         default:
01959             selectedTab->type=T_LEFT;
01960     }
01961 }
01962 
01963 void KoParagTabulatorsWidget::updateFilling(int selected) {
01964     KoTabulator *selectedTab = &m_tabList[lstTabs->currentItem()];
01965 
01966     switch( selected) {
01967         case 1:
01968             selectedTab->filling=TF_DOTS; break;
01969         case 2:
01970             selectedTab->filling=TF_LINE; break;
01971         case 3:
01972             selectedTab->filling=TF_DASH; break;
01973         case 4:
01974             selectedTab->filling=TF_DASH_DOT; break;
01975         case 5:
01976             selectedTab->filling=TF_DASH_DOT_DOT; break;
01977     case 0:
01978         default:
01979             selectedTab->filling=TF_BLANK;
01980     }
01981 }
01982 
01983 void KoParagTabulatorsWidget::updateWidth() {
01984     KoTabulator *selectedTab = &m_tabList[lstTabs->currentItem()];
01985     selectedTab->ptWidth = qMax( 0.0, eWidth->value() );
01986 }
01987 
01988 void KoParagTabulatorsWidget::sortLists() {
01989 
01990     noSignals=true;
01991     qHeapSort( m_tabList );
01992 
01993     // we could just sort the listView, but to make sure we never have any problems with
01994     // inconsistent lists, just re-add..
01995     QString curValue=lstTabs->currentText();
01996     lstTabs->clear();
01997     KoTabulatorList::ConstIterator it = m_tabList.begin();
01998     for ( ; it != m_tabList.end(); ++it )
01999         lstTabs->insertItem( KoUnit::toUserStringValue( (*it).ptPos, m_unit ) );
02000 
02001     lstTabs->setCurrentItem(lstTabs->findItem(curValue));
02002     noSignals=false;
02003 }
02004 
02005 void KoParagTabulatorsWidget::display( const KoParagLayout &lay ) {
02006     m_tabList.clear();
02007     lstTabs->clear();
02008     m_tabList = lay.tabList();
02009     KoTabulatorList::ConstIterator it = m_tabList.begin();
02010     for ( ; it != m_tabList.end(); ++it )
02011         lstTabs->insertItem( KoUnit::toUserStringValue( (*it).ptPos, m_unit ) );
02012 
02013     if(lstTabs->count() > 0)
02014         lstTabs->setCurrentItem(0);
02015     else {
02016         bDelete->setEnabled(false);
02017         bDeleteAll->setEnabled(false);
02018         gPosition->setEnabled(false);
02019         bgAlign->setEnabled(false);
02020         gTabLeader->setEnabled(false);
02021     }
02022 }
02023 
02024 void KoParagTabulatorsWidget::save( KoParagLayout & lay ) {
02025     lay.setTabList( m_tabList );
02026 }
02027 
02028 QString KoParagTabulatorsWidget::tabName() {
02029     return i18n( "&Tabulators" );
02030 }
02031 
02032 /******************************************************************/
02033 /* Class: KoParagDia                                              */
02034 /******************************************************************/
02035 KoParagDia::KoParagDia( QWidget* parent,
02036                         int flags, KoUnit::Unit unit, double _frameWidth, bool breakLine, bool disableAll )
02037     : KPageDialog( parent )
02038 {
02039     setFaceType( Tabbed );
02040     setButtons(Ok | Cancel | User1 | Apply );
02041     setDefaultButton( Ok );
02042 
02043     m_decorationsWidget = 0;
02044     m_flags = flags;
02045     setButtonText( KDialog::User1, i18n("Reset") );
02046 
02047     if ( m_flags & PD_SPACING )
02048     {
02049         KVBox * page = new KVBox();
02050         m_p1 = addPage( page, i18n( "Indent && S&pacing" ) );
02051         m_indentSpacingWidget = new KoIndentSpacingWidget( unit, _frameWidth, page );
02052         m_indentSpacingWidget->layout()->setMargin(0);
02053     }
02054     if ( m_flags & PD_ALIGN )
02055     {
02056         KVBox * page = new KVBox();
02057         m_p2 = addPage( page, i18n( "General &Layout" ) );
02058         m_alignWidget = new KoParagAlignWidget( breakLine, page );
02059         m_alignWidget->layout()->setMargin(0);
02060     }
02061     if ( m_flags & PD_DECORATION )
02062     {
02063         KVBox * page = new KVBox();
02064         m_p3 = addPage( page, i18n( "D&ecorations" ) );
02065         m_decorationsWidget = new KoParagDecorationWidget( page);
02066         m_decorationsWidget->layout()->setMargin(0);
02067     }
02068     if ( m_flags & PD_NUMBERING )
02069     {
02070         KVBox * page = new KVBox();
02071         m_p4 = addPage( page,i18n( "B&ullets/Numbers" ) );
02072         m_counterWidget = new KoParagCounterWidget( disableAll, page );
02073         m_counterWidget->layout()->setMargin(0);
02074     }
02075     if ( m_flags & PD_TABS )
02076     {
02077         KVBox * page = new KVBox();
02078         m_p5 = addPage( page,i18n( "&Tabulators" ) );
02079         m_tabulatorsWidget = new KoParagTabulatorsWidget( unit, _frameWidth, page );
02080         m_tabulatorsWidget->layout()->setMargin(0);
02081     }
02082 
02083     connect( this, SIGNAL( user1Clicked() ), this, SLOT(slotReset()));
02084     setInitialSize( QSize(630, 500) );
02085 }
02086 
02087 KoParagDia::~KoParagDia()
02088 {
02089 }
02090 
02091 void KoParagDia::slotApply()
02092 {
02093     emit applyParagStyle();
02094 }
02095 
02096 void KoParagDia::slotOk()
02097 {
02098     slotApply();
02099     slotButtonClicked( Ok );
02100 }
02101 
02102 void KoParagDia::setCurrentPage( int page )
02103 {
02104     switch( page )
02105     {
02106     case PD_SPACING:
02107         KPageDialog::setCurrentPage( m_p1 );
02108         break;
02109     case PD_ALIGN:
02110         KPageDialog::setCurrentPage( m_p2 );
02111         break;
02112     case PD_DECORATION:
02113         KPageDialog::setCurrentPage( m_p3 );
02114         break;
02115     case PD_NUMBERING:
02116         KPageDialog::setCurrentPage( m_p4 );
02117         break;
02118     case PD_TABS:
02119         KPageDialog::setCurrentPage( m_p5 );
02120         break;
02121     default:
02122         break;
02123     }
02124 }
02125 
02126 void KoParagDia::setParagLayout( const KoParagLayout & lay )
02127 {
02128     m_indentSpacingWidget->display( lay );
02129     m_alignWidget->display( lay );
02130     m_decorationsWidget->display( lay );
02131     m_counterWidget->display( lay );
02132     m_tabulatorsWidget->display( lay );
02133     oldLayout = lay;
02134 }
02135 
02136 void KoParagDia::slotReset()
02137 {
02138     if( m_indentSpacingWidget )
02139         m_indentSpacingWidget->display( oldLayout );
02140     if( m_alignWidget )
02141         m_alignWidget->display( oldLayout );
02142     if ( m_decorationsWidget )
02143         m_decorationsWidget->display( oldLayout );
02144     if( m_counterWidget )
02145         m_counterWidget->display( oldLayout );
02146     if( m_tabulatorsWidget )
02147         m_tabulatorsWidget->display( oldLayout );
02148 }
02149 
02150 bool KoParagDia::isCounterChanged() const
02151 {
02152     if ( oldLayout.counter ) // We had a counter
02153         return ! ( *oldLayout.counter == counter() );
02154     else // We had no counter -> changed if we have one now
02155         return counter().numbering() != KoParagCounter::NUM_NONE;
02156 }
02157 
02158 int KoParagDia::changedFlags() const
02159 {
02160     return paragLayout().compare( oldLayout );
02161 }
02162 
02163 KoParagLayout KoParagDia::paragLayout() const
02164 {
02165     KoParagLayout newLayout;
02166     newLayout.setLineSpacingValue( lineSpacing() );
02167     newLayout.lineSpacingType = lineSpacingType();
02168     newLayout.setTabList( tabListTabulator() );
02169     newLayout.alignment = align();
02170     newLayout.margins[Q3StyleSheetItem::MarginFirstLine] = firstLineIndent();
02171     newLayout.margins[Q3StyleSheetItem::MarginLeft] = leftIndent();
02172     newLayout.margins[Q3StyleSheetItem::MarginRight] = rightIndent();
02173     newLayout.margins[Q3StyleSheetItem::MarginTop] = spaceBeforeParag();
02174     newLayout.margins[Q3StyleSheetItem::MarginBottom] = spaceAfterParag();
02175     newLayout.pageBreaking = pageBreaking();
02176     newLayout.leftBorder = leftBorder();
02177     newLayout.rightBorder = rightBorder();
02178     newLayout.topBorder = topBorder();
02179     newLayout.bottomBorder = bottomBorder();
02180     newLayout.joinBorder = joinBorder();
02181     newLayout.backgroundColor = backgroundColor();
02182     newLayout.counter = new KoParagCounter( counter() );
02183     return newLayout;
02184 }
02185 
02186 #include "KoParagDia.moc"
02187 #include "KoParagDia_p.moc"

Généré le Wed Nov 22 23:41:08 2006 pour KPlato par  doxygen 1.5.1-p1