Back to index

scribus-ng  1.3.4.dfsg+svn20071115
smtextstyles.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 
00008 #include "smtextstyles.h"
00009 #include "smtextstyles.moc"
00010 #include "smtextstylewidgets.h"
00011 #include "util.h"
00012 #include "mspinbox.h"
00013 #include "alignselect.h"
00014 #include "tabruler.h"
00015 #include "fontcombo.h"
00016 #include "styleselect.h"
00017 #include "sccombobox.h"
00018 #include "shadebutton.h"
00019 #include "commonstrings.h"
00020 #include "style.h"
00021 #include "scribusdoc.h"
00022 #include "selection.h"
00023 #include "scribus.h"
00024 #include "prefsmanager.h"
00025 #include "colorcombo.h"
00026 #include "story.h"
00027 #include "menumanager.h"
00028 #include "fmitem.h"
00029 #include "mpalette.h"
00030 #include "smwidgets.h"
00031 
00032 #include <qtabwidget.h>
00033 
00034 SMParagraphStyle::SMParagraphStyle(StyleSet<CharStyle> *cstyles) : StyleItem(),
00035 pwidget_(0), doc_(0), selectionIsDirty_(false), unitRatio_(1.0), cstyles_(cstyles)
00036 {
00037        Q_ASSERT(cstyles_);
00038        pwidget_ = new SMPStyleWidget();
00039        Q_CHECK_PTR(pwidget_);
00040 }
00041 
00042 QTabWidget* SMParagraphStyle::widget()
00043 {
00044        return pwidget_->tabWidget;
00045 }
00046 
00047 QString SMParagraphStyle::typeNamePlural()
00048 {
00049        return tr("Paragraph Styles");
00050 }
00051 
00052 QString SMParagraphStyle::typeNameSingular()
00053 {
00054        return tr("Paragraph Style");
00055 }
00056 
00057 void SMParagraphStyle::currentDoc(ScribusDoc *doc)
00058 {
00059        doc_ = doc;
00060        if (doc_)
00061        {
00062               if (pwidget_)
00063               {
00064                      pwidget_->cpage->fillLangCombo(doc_->scMW()->LangTransl);
00065                      pwidget_->cpage->fillColorCombo(doc_->PageColors);
00066                      pwidget_->cpage->fontFace_->RebuildList(doc_);
00067                      if (unitRatio_ != doc_->unitRatio())
00068                             unitChange();
00069               }
00070        }
00071        else
00072        {
00073               removeConnections();
00074               selection_.clear();
00075               tmpStyles_.clear();
00076               deleted_.clear();
00077        }
00078 }
00079 
00080 StyleSet<ParagraphStyle>* SMParagraphStyle::tmpStyles()
00081 {
00082        return &tmpStyles_;
00083 }
00084 
00085 QValueList<StyleName> SMParagraphStyle::styles(bool reloadFromDoc)
00086 {
00087        QValueList<StyleName> tmpList;
00088 
00089        if (!doc_)
00090               return tmpList; // no doc available
00091 
00092        if (reloadFromDoc)
00093        {
00094               deleted_.clear();
00095               reloadTmpStyles();
00096        }
00097 
00098        for (uint i = 0; i < tmpStyles_.count(); ++i)
00099        {
00100               if (tmpStyles_[i].hasName())
00101               {
00102                      QString styleName(tmpStyles_[i].name());
00103                      QString parentName(QString::null);
00104 
00105                      if (tmpStyles_[i].hasParent() )
00106                             parentName = tmpStyles_[i].parent();
00107 
00108                      tmpList << StyleName(styleName, parentName);
00109               }
00110        }
00111 
00112        return tmpList;
00113 }
00114 
00115 void SMParagraphStyle::reload()
00116 {
00117        reloadTmpStyles();
00118 }
00119 
00120 void SMParagraphStyle::selected(const QStringList &styleNames)
00121 {
00122        if (!doc_)
00123               return;
00124 
00125        selection_.clear();
00126        selectionIsDirty_ = false;
00127        removeConnections(); // we don't want to record changes during style setup
00128 
00129        tmpStyles_.invalidate();
00130 
00131        QValueList<ParagraphStyle> pstyles; // get saved styles
00132        QValueList<CharStyle> cstyles;
00133        for (uint i = 0; i < tmpStyles_.count(); ++i)
00134               pstyles << tmpStyles_[i];
00135        for (uint i = 0; i < cstyles_->count(); ++i)
00136               cstyles << (*cstyles_)[i];
00137 
00138        int index;
00139        for (uint i = 0; i < styleNames.count(); ++i)
00140        {
00141               index = tmpStyles_.find(styleNames[i]);
00142               if (index > -1)
00143                      selection_.append(&tmpStyles_[index]);
00144        }
00145 
00146        pwidget_->show(selection_, pstyles, cstyles, doc_->unitIndex(), (*cstyles_)[""].language());
00147 
00148        setupConnections();
00149 }
00150 
00151 QValueList<CharStyle> SMParagraphStyle::getCharStyles()
00152 {
00153        QValueList<CharStyle> charStyles;
00154        if (!doc_)
00155               return charStyles; // no doc available
00156 
00157        const StyleSet<CharStyle> &tmp(doc_->charStyles());
00158        for (uint i = 0; i < tmp.count(); ++i)
00159               charStyles.append(tmp[i]);
00160        return charStyles;
00161 }
00162 
00163 QString SMParagraphStyle::fromSelection() const
00164 {
00165        QString lsName(QString::null);
00166        if (!doc_)
00167               return lsName; // no doc available
00168 
00169        for (uint i = 0; i < doc_->m_Selection->count(); ++i)
00170        {
00171               // wth is going on here
00172               PageItem *item = doc_->m_Selection->itemAt(i);
00173 
00174               QString tmpName = item->itemText.defaultStyle().parent();
00175 
00176               if (lsName.isNull() && !tmpName.isEmpty() && tmpName != "")
00177               {
00178                      lsName = tmpName;
00179               }
00180               else if (!lsName.isNull() && !tmpName.isEmpty() && tmpName != "" && lsName != tmpName)
00181               {
00182                      lsName = QString::null;
00183                      break;
00184               }
00185        }
00186        return lsName;
00187 }
00188 
00189 void SMParagraphStyle::toSelection(const QString &styleName) const
00190 {
00191        if (!doc_)
00192               return; // nowhere to apply or no doc
00193 
00194        doc_->itemSelection_SetNamedParagraphStyle(styleName);
00195 }
00196 
00197 QString SMParagraphStyle::newStyle()
00198 {
00199        if (!doc_)
00200               return QString::null;
00201 
00202        QString s(getUniqueName( tr("New Style")));
00203        ParagraphStyle p;
00204        p.setName(s);
00205        tmpStyles_.create(p);
00206        return s;
00207 }
00208 
00209 QString SMParagraphStyle::newStyle(const QString &fromStyle)
00210 {
00211        Q_ASSERT(tmpStyles_.resolve(fromStyle));
00212        if (!tmpStyles_.resolve(fromStyle))
00213               return QString::null;
00214 
00215        QString s(getUniqueName( tr("Clone of %1").arg(fromStyle)));
00216        ParagraphStyle p(tmpStyles_[fromStyle]);
00217        p.setName(s);
00218        p.setShortcut(QString::null); // do not clone the sc
00219        tmpStyles_.create(p);
00220 
00221        return s;
00222 }
00223 
00224 // helper function to find a unique name to a new style or a clone
00225 QString SMParagraphStyle::getUniqueName(const QString &name)
00226 {
00227        int id = 0;
00228        bool done = false;
00229        QString s(name);
00230 
00231        while (!done)
00232        {
00233 start:
00234               ++id;
00235               for (uint i = 0; i < tmpStyles_.count(); ++i)
00236               {
00237                      if (tmpStyles_[i].name() == s)
00238                      {
00239                             s = tr("%1 (%2)", "This for unique name when creating "
00240                                           "a new character style. %1 will be the name "
00241                                                         "of the style and %2 will be a number forming "
00242                                                         "a style name like: New Style (2)").arg(name).arg(id);
00243                             goto start;
00244                      }
00245               }
00246               done = true;
00247        }
00248 
00249        return s;
00250 }
00251 
00252 void SMParagraphStyle::apply()
00253 {
00254        if (!doc_)
00255               return;
00256 
00257        QMap<QString, QString> replacement;
00258        for (uint i = 0; i < deleted_.count(); ++i)
00259               replacement[deleted_[i].first] = deleted_[i].second;
00260 
00261        doc_->redefineStyles(tmpStyles_, false);
00262        doc_->replaceStyles(replacement);
00263 
00264        deleted_.clear(); // deletion done at this point
00265 
00266        doc_->scMW()->propertiesPalette->paraStyleCombo->updateFormatList();
00267        doc_->scMW()->propertiesPalette->charStyleCombo->updateFormatList();
00268        doc_->scMW()->view->DrawNew();
00269        doc_->changed();
00270 }
00271 
00272 void SMParagraphStyle::editMode(bool isOn)
00273 {
00274        if (isOn)
00275               reloadTmpStyles();
00276 }
00277 
00278 QString SMParagraphStyle::shortcut(const QString &stylename) const
00279 {
00280        QString s(QString::null);
00281 
00282        int index = tmpStyles_.find(stylename);
00283        if (index > -1)
00284               s = tmpStyles_[index].shortcut();
00285 
00286        return s;
00287 }
00288 
00289 void SMParagraphStyle::setShortcut(const QString &shortcut)
00290 {
00291        Q_ASSERT(selection_.count() == 1);
00292        if (selection_.count() != 1)
00293               return;
00294 
00295        selection_[0]->setShortcut(shortcut);
00296 
00297        if (!selectionIsDirty_)
00298        {
00299               selectionIsDirty_ = true;
00300               emit selectionDirty();
00301        }
00302 }
00303 
00304 void SMParagraphStyle::deleteStyles(const QValueList<RemoveItem> &removeList)
00305 {
00306        for (uint i = 0; i < removeList.count(); ++i)
00307        {
00308               for (uint k = 0; k < selection_.count(); ++k)
00309               {
00310                      if (selection_[k]->name() == removeList[i].first)
00311                      {
00312                             selection_.erase(selection_.at(k));
00313                             break;
00314                      }
00315               }
00316 
00317               int index = tmpStyles_.find(removeList[i].first);
00318               if (index > -1)
00319                      tmpStyles_.remove(index);
00320 
00321               deleted_.append(removeList[i]);
00322        }
00323 }
00324 
00325 void SMParagraphStyle::nameChanged(const QString &newName)
00326 {
00327        if (selection_.count() != 1)
00328               return;
00329 
00330        QString oldName(selection_[0]->name());
00331        ParagraphStyle p(*selection_[0]);
00332        p.setName(newName);
00333        tmpStyles_.create(p);
00334        selection_.clear();
00335        selection_.append(&tmpStyles_[tmpStyles_.find(newName)]);
00336        for (uint j = 0; j < tmpStyles_.count(); ++j)
00337        {
00338               int index = tmpStyles_.find(oldName);
00339               if (index > -1)
00340               {
00341                      tmpStyles_.remove(index);
00342                      break;
00343               }
00344        }
00345 
00346        for (uint j = 0; j < tmpStyles_.count(); ++j)
00347        {
00348               if (tmpStyles_[j].parent() == oldName)
00349                      tmpStyles_[j].setParent(newName);
00350        }
00351 
00352        QValueList<RemoveItem>::iterator it;
00353        for (it = deleted_.begin(); it != deleted_.end(); ++it)
00354        {
00355               if ((*it).second == oldName)
00356               {
00357                      oldName = (*it).first;
00358                      deleted_.remove(it);
00359                      break;
00360               }
00361        }
00362 
00363        deleted_.append(RemoveItem(oldName, newName));
00364 
00365        if (!selectionIsDirty_)
00366        {
00367               selectionIsDirty_ = true;
00368               emit selectionDirty();
00369        }
00370 }
00371 
00372 void SMParagraphStyle::languageChange()
00373 {
00374        if (pwidget_)
00375        {
00376               pwidget_->languageChange();
00377               pwidget_->cpage->languageChange();
00378        }
00379 }
00380 
00381 void SMParagraphStyle::unitChange()
00382 {
00383        double oldRatio = unitRatio_;
00384        unitRatio_ = doc_->unitRatio();
00385        pwidget_->unitChange(oldRatio, unitRatio_, doc_->unitIndex());
00386 }
00387 
00388 void SMParagraphStyle::reloadTmpStyles()
00389 {
00390        if (!doc_)
00391               return;
00392 
00393        selection_.clear();
00394        tmpStyles_.clear();
00395        deleted_.clear();
00396        tmpStyles_.redefine(doc_->paragraphStyles(), true);
00397        Q_ASSERT(tmpStyles_.count() > 0);
00398        tmpStyles_[0].charStyle().setContext(cstyles_);
00399 }
00400 
00401 void SMParagraphStyle::setupConnections()
00402 {
00403        if (!pwidget_)
00404               return;
00405 
00406        // paragraph attributes
00407        connect(pwidget_->lineSpacingMode_, SIGNAL(activated(int)), this, SLOT(slotLineSpacingMode(int)));
00408        connect(pwidget_->lineSpacing_, SIGNAL(valueChanged(int)), this, SLOT(slotLineSpacing()));
00409        connect(pwidget_->spaceAbove_, SIGNAL(valueChanged(int)), this, SLOT(slotSpaceAbove()));
00410        connect(pwidget_->spaceBelow_, SIGNAL(valueChanged(int)), this, SLOT(slotSpaceBelow()));
00411        connect(pwidget_->alignement_->TextL, SIGNAL(clicked()), this, SLOT(slotAlignment()));
00412        connect(pwidget_->alignement_->TextR, SIGNAL(clicked()), this, SLOT(slotAlignment()));
00413        connect(pwidget_->alignement_->TextC, SIGNAL(clicked()), this, SLOT(slotAlignment()));
00414        connect(pwidget_->alignement_->TextB, SIGNAL(clicked()), this, SLOT(slotAlignment()));
00415        connect(pwidget_->alignement_->TextF, SIGNAL(clicked()), this, SLOT(slotAlignment()));
00416        connect(pwidget_->alignement_->parentButton, SIGNAL(clicked()), this, SLOT(slotAlignment()));
00417 
00418        connect(pwidget_, SIGNAL(useParentDropCap()), this, SLOT(slotParentDropCap()));
00419        connect(pwidget_->dropCapsBox, SIGNAL(toggled(bool)), this, SLOT(slotDropCap(bool)));
00420        connect(pwidget_->dropCapLines_, SIGNAL(valueChanged(int)), this, SLOT(slotDropCapLines(int)));
00421        connect(pwidget_->dropCapOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotDropCapOffset()));
00422 
00423        connect(pwidget_->tabList_, SIGNAL(tabsChanged()), this, SLOT(slotTabRuler()));
00424        connect(pwidget_->tabList_, SIGNAL(mouseReleased()), this, SLOT(slotTabRuler()));
00425        connect(pwidget_->tabList_->left_, SIGNAL(valueChanged(int)), this, SLOT(slotLeftIndent()));
00426        connect(pwidget_->tabList_->right_, SIGNAL(valueChanged(int)), this, SLOT(slotRightIndent()));
00427        connect(pwidget_->tabList_->first_, SIGNAL(valueChanged(int)), this, SLOT(slotFirstLine()));
00428 
00429        connect(pwidget_->parentCombo, SIGNAL(activated(const QString&)),
00430                      this, SLOT(slotParentChanged(const QString&)));
00431 
00432        // character attributes
00433        connect(pwidget_->cpage->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
00434        connect(pwidget_->cpage->effects_, SIGNAL(State(int)), this, SLOT(slotEffects(int)));
00435        connect(pwidget_->cpage->effects_->ShadowVal->Xoffset, SIGNAL(valueChanged(int)),
00436                      this, SLOT(slotEffectProperties()));
00437        connect(pwidget_->cpage->effects_->ShadowVal->Yoffset, SIGNAL(valueChanged(int)),
00438                      this, SLOT(slotEffectProperties()));
00439        connect(pwidget_->cpage->effects_->OutlineVal->LWidth, SIGNAL(valueChanged(int)),
00440                      this, SLOT(slotEffectProperties()));
00441        connect(pwidget_->cpage->effects_->UnderlineVal->LPos, SIGNAL(valueChanged(int)),
00442                      this, SLOT(slotEffectProperties()));
00443        connect(pwidget_->cpage->effects_->UnderlineVal->LWidth, SIGNAL(valueChanged(int)),
00444                      this, SLOT(slotEffectProperties()));
00445        connect(pwidget_->cpage->effects_->StrikeVal->LPos, SIGNAL(valueChanged(int)),
00446                      this, SLOT(slotEffectProperties()));
00447        connect(pwidget_->cpage->effects_->StrikeVal->LWidth, SIGNAL(valueChanged(int)),
00448                      this, SLOT(slotEffectProperties()));
00449        connect(pwidget_->cpage->fillColor_, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
00450        connect(pwidget_->cpage->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
00451        connect(pwidget_->cpage->strokeColor_, SIGNAL(activated(const QString&)), this, SLOT(slotStrokeColor()));
00452        connect(pwidget_->cpage->strokeShade_, SIGNAL(clicked()), this, SLOT(slotStrokeShade()));
00453        connect(pwidget_->cpage->language_, SIGNAL(activated(int)), this, SLOT(slotLanguage()));
00454        connect(pwidget_->cpage->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(slotFontSize()));
00455        connect(pwidget_->cpage->fontHScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleH()));
00456        connect(pwidget_->cpage->fontVScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleV()));
00457        connect(pwidget_->cpage->tracking_, SIGNAL(valueChanged(int)), this, SLOT(slotTracking()));
00458        connect(pwidget_->cpage->baselineOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotBaselineOffset()));
00459        connect(pwidget_->cpage->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
00460        connect(pwidget_->cpage->parentCombo, SIGNAL(activated(const QString&)),
00461                      this, SLOT(slotCharParentChanged(const QString&)));
00462 }
00463 
00464 void SMParagraphStyle::removeConnections()
00465 {
00466        if (!pwidget_)
00467               return;
00468 
00469        disconnect(pwidget_->lineSpacingMode_, SIGNAL(activated(int)), this, SLOT(slotLineSpacingMode(int)));
00470        disconnect(pwidget_->lineSpacing_, SIGNAL(valueChanged(int)), this, SLOT(slotLineSpacing()));
00471        disconnect(pwidget_->spaceAbove_, SIGNAL(valueChanged(int)), this, SLOT(slotSpaceAbove()));
00472        disconnect(pwidget_->spaceBelow_, SIGNAL(valueChanged(int)), this, SLOT(slotSpaceBelow()));
00473        disconnect(pwidget_->alignement_->TextL, SIGNAL(clicked()), this, SLOT(slotAlignment()));
00474        disconnect(pwidget_->alignement_->TextR, SIGNAL(clicked()), this, SLOT(slotAlignment()));
00475        disconnect(pwidget_->alignement_->TextC, SIGNAL(clicked()), this, SLOT(slotAlignment()));
00476        disconnect(pwidget_->alignement_->TextB, SIGNAL(clicked()), this, SLOT(slotAlignment()));
00477        disconnect(pwidget_->alignement_->TextF, SIGNAL(clicked()), this, SLOT(slotAlignment()));
00478        disconnect(pwidget_->alignement_->parentButton, SIGNAL(clicked()), this, SLOT(slotAlignment()));
00479 
00480        disconnect(pwidget_, SIGNAL(useParentDropCap()), this, SLOT(slotParentDropCap()));
00481        disconnect(pwidget_->dropCapsBox, SIGNAL(toggled(bool)), this, SLOT(slotDropCap(bool)));
00482        disconnect(pwidget_->dropCapLines_, SIGNAL(valueChanged(int)), this, SLOT(slotDropCapLines(int)));
00483        disconnect(pwidget_->dropCapOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotDropCapOffset()));
00484 
00485        disconnect(pwidget_->parentCombo, SIGNAL(activated(const QString&)),
00486                      this, SLOT(slotParentChanged(const QString&)));
00487 
00488        disconnect(pwidget_->tabList_, SIGNAL(tabsChanged()), this, SLOT(slotTabRuler()));
00489        disconnect(pwidget_->tabList_->left_, SIGNAL(valueChanged(int)), this, SLOT(slotLeftIndent()));
00490        disconnect(pwidget_->tabList_->right_, SIGNAL(valueChanged(int)), this, SLOT(slotRightIndent()));
00491        disconnect(pwidget_->tabList_->first_, SIGNAL(valueChanged(int)), this, SLOT(slotFirstLine()));
00492 
00493        disconnect(pwidget_->cpage->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
00494        disconnect(pwidget_->cpage->effects_, SIGNAL(State(int)), this, SLOT(slotEffects(int)));
00495        disconnect(pwidget_->cpage->effects_->ShadowVal->Xoffset, SIGNAL(valueChanged(int)),
00496                      this, SLOT(slotEffectProperties()));
00497        disconnect(pwidget_->cpage->effects_->ShadowVal->Yoffset, SIGNAL(valueChanged(int)),
00498                      this, SLOT(slotEffectProperties()));
00499        disconnect(pwidget_->cpage->effects_->OutlineVal->LWidth, SIGNAL(valueChanged(int)),
00500                      this, SLOT(slotEffectProperties()));
00501        disconnect(pwidget_->cpage->effects_->UnderlineVal->LPos, SIGNAL(valueChanged(int)),
00502                      this, SLOT(slotEffectProperties()));
00503        disconnect(pwidget_->cpage->effects_->UnderlineVal->LWidth, SIGNAL(valueChanged(int)),
00504                      this, SLOT(slotEffectProperties()));
00505        disconnect(pwidget_->cpage->effects_->StrikeVal->LPos, SIGNAL(valueChanged(int)),
00506                      this, SLOT(slotEffectProperties()));
00507        disconnect(pwidget_->cpage->effects_->StrikeVal->LWidth, SIGNAL(valueChanged(int)),
00508                      this, SLOT(slotEffectProperties()));
00509        disconnect(pwidget_->cpage->fillColor_, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
00510        disconnect(pwidget_->cpage->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
00511        disconnect(pwidget_->cpage->strokeColor_, SIGNAL(activated(const QString&)), this, SLOT(slotStrokeColor()));
00512        disconnect(pwidget_->cpage->strokeShade_, SIGNAL(clicked()), this, SLOT(slotStrokeShade()));
00513        disconnect(pwidget_->cpage->language_, SIGNAL(activated(int)), this, SLOT(slotLanguage()));
00514        disconnect(pwidget_->cpage->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(slotFontSize()));
00515        disconnect(pwidget_->cpage->fontHScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleH()));
00516        disconnect(pwidget_->cpage->fontVScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleV()));
00517        disconnect(pwidget_->cpage->tracking_, SIGNAL(valueChanged(int)), this, SLOT(slotTracking()));
00518        disconnect(pwidget_->cpage->baselineOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotBaselineOffset()));
00519        disconnect(pwidget_->cpage->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
00520        disconnect(pwidget_->cpage->parentCombo, SIGNAL(activated(const QString&)),
00521                      this, SLOT(slotCharParentChanged(const QString&)));
00522 }
00523 
00524 void SMParagraphStyle::slotLineSpacingMode(int mode)
00525 {
00526        ParagraphStyle::LineSpacingMode lsm = static_cast<ParagraphStyle::LineSpacingMode>(mode);
00527 
00528        if (pwidget_->lineSpacingMode_->useParentValue())
00529               for (uint i = 0; i < selection_.count(); ++i)
00530                      selection_[i]->resetLineSpacingMode();
00531        else
00532               for (uint i = 0; i < selection_.count(); ++i)
00533                      selection_[i]->setLineSpacingMode(lsm);
00534 
00535        if (!selectionIsDirty_)
00536        {
00537               selectionIsDirty_ = true;
00538               emit selectionDirty();
00539        }
00540 }
00541 
00542 void SMParagraphStyle::slotLineSpacing()
00543 {
00544        if (pwidget_->lineSpacing_->useParentValue())
00545               for (uint i = 0; i < selection_.count(); ++i)
00546                      selection_[i]->resetLineSpacing();
00547        else 
00548        {
00549               double a, b, value;
00550               int c;
00551 
00552               pwidget_->lineSpacing_->getValues(&a, &b, &c, &value);
00553               for (uint i = 0; i < selection_.count(); ++i)
00554                      selection_[i]->setLineSpacing(value);
00555        }
00556        
00557        if (!selectionIsDirty_)
00558        {
00559               selectionIsDirty_ = true;
00560               emit selectionDirty();
00561        }
00562 }
00563 
00564 void SMParagraphStyle::slotSpaceAbove()
00565 {
00566        if (pwidget_->spaceAbove_->useParentValue())
00567               for (uint i = 0; i < selection_.count(); ++i)
00568                      selection_[i]->resetGapBefore();
00569        else 
00570        {
00571               double a, b, value;
00572               int c;
00573 
00574               pwidget_->spaceAbove_->getValues(&a, &b, &c, &value);
00575               value = value / unitRatio_;
00576               for (uint i = 0; i < selection_.count(); ++i)
00577                      selection_[i]->setGapBefore(value);
00578        }
00579        
00580        if (!selectionIsDirty_)
00581        {
00582               selectionIsDirty_ = true;
00583               emit selectionDirty();
00584        }
00585 }
00586 
00587 void SMParagraphStyle::slotSpaceBelow()
00588 {
00589        if (pwidget_->spaceBelow_->useParentValue())
00590               for (uint i = 0; i < selection_.count(); ++i)
00591                      selection_[i]->resetGapAfter();
00592        else 
00593        {
00594               double a, b, value;
00595               int c;
00596               
00597               pwidget_->spaceBelow_->getValues(&a, &b, &c, &value);
00598               value = value / unitRatio_;
00599               for (uint i = 0; i < selection_.count(); ++i)
00600                      selection_[i]->setGapAfter(value);
00601        }
00602        
00603        if (!selectionIsDirty_)
00604        {
00605               selectionIsDirty_ = true;
00606               emit selectionDirty();
00607        }
00608 }
00609 
00610 void SMParagraphStyle::slotAlignment()
00611 {
00612        ParagraphStyle::AlignmentType style = static_cast<ParagraphStyle::AlignmentType>(pwidget_->alignement_->getStyle());
00613        if (pwidget_->alignement_->useParentValue())
00614               for (uint i = 0; i < selection_.count(); ++i)
00615                      selection_[i]->resetAlignment();
00616        else 
00617               for (uint i = 0; i < selection_.count(); ++i)
00618                      selection_[i]->setAlignment(style);
00619 
00620        if (!selectionIsDirty_)
00621        {
00622               selectionIsDirty_ = true;
00623               emit selectionDirty();
00624        }
00625 }
00626 
00627 void SMParagraphStyle::slotDropCap(bool isOn)
00628 {
00629        for (uint i = 0; i < selection_.count(); ++i)
00630               selection_[i]->setHasDropCap(isOn);
00631 
00632        if (!selectionIsDirty_)
00633        {
00634               selectionIsDirty_ = true;
00635               emit selectionDirty();
00636        }
00637 }
00638 
00639 void SMParagraphStyle::slotParentDropCap()
00640 {
00641        for (uint i = 0; i < selection_.count(); ++i)
00642               selection_[i]->resetHasDropCap();
00643 
00644        if (!selectionIsDirty_)
00645        {
00646               selectionIsDirty_ = true;
00647               emit selectionDirty();
00648        }
00649 }
00650 
00651 void SMParagraphStyle::slotDropCapLines(int lines)
00652 {
00653        if (pwidget_->dropCapLines_->useParentValue())
00654               for (uint i = 0; i < selection_.count(); ++i)
00655                      selection_[i]->resetDropCapLines();
00656        else          
00657               for (uint i = 0; i < selection_.count(); ++i)
00658                      selection_[i]->setDropCapLines(lines);
00659 
00660        if (!selectionIsDirty_)
00661        {
00662               selectionIsDirty_ = true;
00663               emit selectionDirty();
00664        }
00665 }
00666 
00667 void SMParagraphStyle::slotDropCapOffset()
00668 {
00669        if (pwidget_->dropCapOffset_->useParentValue())
00670               for (uint i = 0; i < selection_.count(); ++i)
00671                      selection_[i]->resetDropCapOffset();
00672        else 
00673        {
00674               double a, b, value;
00675               int c;
00676 
00677               pwidget_->dropCapOffset_->getValues(&a, &b, &c, &value);
00678               value = value / unitRatio_;
00679               for (uint i = 0; i < selection_.count(); ++i)
00680                      selection_[i]->setDropCapOffset(value);
00681        }
00682        
00683        if (!selectionIsDirty_)
00684        {
00685               selectionIsDirty_ = true;
00686               emit selectionDirty();
00687        }
00688 }
00689 
00690 void SMParagraphStyle::slotTabRuler()
00691 {
00692        if (pwidget_->tabList_->useParentTabs())
00693        {
00694               for (uint i = 0; i < selection_.count(); ++i)
00695                      selection_[i]->resetTabValues();
00696        }
00697        else
00698        {
00699               QValueList<ParagraphStyle::TabRecord> newTabs = pwidget_->tabList_->getTabVals();
00700               for (uint i = 0; i < selection_.count(); ++i)
00701                      selection_[i]->setTabValues(newTabs);
00702        }
00703 
00704        if (!selectionIsDirty_)
00705        {
00706               selectionIsDirty_ = true;
00707               emit selectionDirty();
00708        }
00709 }
00710 
00711 void SMParagraphStyle::slotLeftIndent()
00712 {
00713        if (pwidget_->tabList_->useParentLeftIndent())
00714               for (uint i = 0; i < selection_.count(); ++i)
00715                      selection_[i]->resetLeftMargin();
00716        else 
00717        {
00718               double a, b, value;
00719               int c;
00720 
00721               pwidget_->tabList_->left_->getValues(&a, &b, &c, &value);
00722               value = value / unitRatio_;
00723               for (uint i = 0; i < selection_.count(); ++i)
00724                      selection_[i]->setLeftMargin(value);
00725        }
00726        
00727        if (!selectionIsDirty_)
00728        {
00729               selectionIsDirty_ = true;
00730               emit selectionDirty();
00731        }
00732 }
00733 
00734 void SMParagraphStyle::slotRightIndent()
00735 {
00736        if (pwidget_->tabList_->useParentRightIndent())
00737               for (uint i = 0; i < selection_.count(); ++i)
00738                      selection_[i]->resetRightMargin();
00739        else 
00740        {
00741               double a, b, value;
00742               int c;
00743 
00744               pwidget_->tabList_->right_->getValues(&a, &b, &c, &value);
00745               value = value / unitRatio_;
00746               for (uint i = 0; i < selection_.count(); ++i)
00747                      selection_[i]->setRightMargin(value);
00748        }
00749        
00750        if (!selectionIsDirty_)
00751        {
00752               selectionIsDirty_ = true;
00753               emit selectionDirty();
00754        }
00755 }
00756 
00757 void SMParagraphStyle::slotFirstLine()
00758 {
00759        if (pwidget_->tabList_->useParentFirstLine())
00760               for (uint i = 0; i < selection_.count(); ++i)
00761                      selection_[i]->resetFirstIndent();
00762        else 
00763        {
00764               double a, b, value;
00765               int c;
00766               
00767               pwidget_->tabList_->first_->getValues(&a, &b, &c, &value);
00768               value = value / unitRatio_;
00769               for (uint i = 0; i < selection_.count(); ++i)
00770                      selection_[i]->setFirstIndent(value);
00771        }
00772        
00773        if (!selectionIsDirty_)
00774        {
00775               selectionIsDirty_ = true;
00776               emit selectionDirty();
00777        }
00778 }
00779 
00780 void SMParagraphStyle::slotFontSize()
00781 {
00782        if (pwidget_->cpage->fontSize_->useParentValue())
00783               for (uint i = 0; i < selection_.count(); ++i)
00784                      selection_[i]->charStyle().resetFontSize();
00785        else
00786        {
00787               double a, b, value;
00788               int c;
00789               
00790               pwidget_->cpage->fontSize_->getValues(&a, &b, &c, &value);
00791               value = value * 10;
00792               for (uint i = 0; i < selection_.count(); ++i)
00793                      selection_[i]->charStyle().setFontSize(qRound(value));
00794        }
00795 
00796 
00797        if (!selectionIsDirty_)
00798        {
00799               selectionIsDirty_ = true;
00800               emit selectionDirty();
00801        }
00802 }
00803 
00804 void SMParagraphStyle::slotEffects(int e)
00805 {
00806        StyleFlag s = ScStyle_None;
00807        if (pwidget_->cpage->effects_->useParentValue())
00808        {
00809               for (uint i = 0; i < selection_.count(); ++i)
00810               {
00811                      selection_[i]->charStyle().resetFeatures();
00812                      selection_[i]->charStyle().resetShadowXOffset();
00813                      selection_[i]->charStyle().resetShadowYOffset();
00814                      selection_[i]->charStyle().resetOutlineWidth();
00815                      selection_[i]->charStyle().resetUnderlineOffset();
00816                      selection_[i]->charStyle().resetUnderlineWidth();
00817                      selection_[i]->charStyle().resetStrikethruOffset();
00818                      selection_[i]->charStyle().resetStrikethruWidth();
00819               }
00820        }
00821        else
00822        {
00823               double a, b, sxo, syo, olw, ulp, ulw, slp, slw;
00824               int c;
00825               
00826               s = static_cast<StyleFlag>(e);
00827               pwidget_->cpage->effects_->ShadowVal->Xoffset->getValues(&a, &b, &c, &sxo);
00828               sxo *= 10;
00829               pwidget_->cpage->effects_->ShadowVal->Yoffset->getValues(&a, &b, &c, &syo);
00830               syo *= 10;
00831 
00832               pwidget_->cpage->effects_->OutlineVal->LWidth->getValues(&a, &b, &c, &olw);
00833               olw *= 10;
00834 
00835               pwidget_->cpage->effects_->UnderlineVal->LPos->getValues(&a, &b, &c, &ulp);
00836               ulp *= 10;
00837               pwidget_->cpage->effects_->UnderlineVal->LWidth->getValues(&a, &b, &c, &ulw);
00838               ulw *= 10;
00839 
00840               pwidget_->cpage->effects_->StrikeVal->LPos->getValues(&a, &b, &c, &slp);
00841               slp *= 10;
00842               pwidget_->cpage->effects_->StrikeVal->LWidth->getValues(&a, &b, &c, &slw);
00843               slw *= 10;
00844 
00845               for (uint i = 0; i < selection_.count(); ++i)
00846               {
00847                      selection_[i]->charStyle().setFeatures(s.featureList());
00848                      selection_[i]->charStyle().setShadowXOffset(qRound(sxo));
00849                      selection_[i]->charStyle().setShadowYOffset(qRound(syo));
00850                      selection_[i]->charStyle().setOutlineWidth(qRound(olw));
00851                      selection_[i]->charStyle().setUnderlineOffset(qRound(ulp));
00852                      selection_[i]->charStyle().setUnderlineWidth(qRound(ulw));
00853                      selection_[i]->charStyle().setStrikethruOffset(qRound(slp));
00854                      selection_[i]->charStyle().setStrikethruWidth(qRound(slw));
00855               }
00856        }
00857 
00858 
00859        if (!selectionIsDirty_)
00860        {
00861               selectionIsDirty_ = true;
00862               emit selectionDirty();
00863        }
00864 }
00865 
00866 void SMParagraphStyle::slotEffectProperties()
00867 {
00868        double a, b, sxo, syo, olw, ulp, ulw, slp, slw;
00869        int c;
00870 
00871        pwidget_->cpage->effects_->ShadowVal->Xoffset->getValues(&a, &b, &c, &sxo);
00872        sxo *= 10;
00873        pwidget_->cpage->effects_->ShadowVal->Yoffset->getValues(&a, &b, &c, &syo);
00874        syo *= 10;
00875 
00876        pwidget_->cpage->effects_->OutlineVal->LWidth->getValues(&a, &b, &c, &olw);
00877        olw *= 10;
00878 
00879        pwidget_->cpage->effects_->UnderlineVal->LPos->getValues(&a, &b, &c, &ulp);
00880        ulp *= 10;
00881        pwidget_->cpage->effects_->UnderlineVal->LWidth->getValues(&a, &b, &c, &ulw);
00882        ulw *= 10;
00883 
00884        pwidget_->cpage->effects_->StrikeVal->LPos->getValues(&a, &b, &c, &slp);
00885        slp *= 10;
00886        pwidget_->cpage->effects_->StrikeVal->LWidth->getValues(&a, &b, &c, &slw);
00887        slw *= 10;
00888        
00889        for (uint i = 0; i < selection_.count(); ++i)
00890        {
00891               selection_[i]->charStyle().setShadowXOffset(qRound(sxo));
00892               selection_[i]->charStyle().setShadowYOffset(qRound(syo));
00893               selection_[i]->charStyle().setOutlineWidth(qRound(olw));
00894               selection_[i]->charStyle().setUnderlineOffset(qRound(ulp));
00895               selection_[i]->charStyle().setUnderlineWidth(qRound(ulw));
00896               selection_[i]->charStyle().setStrikethruOffset(qRound(slp));
00897               selection_[i]->charStyle().setStrikethruWidth(qRound(slw));
00898        }
00899 
00900        if (!selectionIsDirty_)
00901        {
00902               selectionIsDirty_ = true;
00903               emit selectionDirty();
00904        }
00905 }
00906 
00907 void SMParagraphStyle::slotFillColor()
00908 {
00909        if (pwidget_->cpage->fillColor_->useParentValue())
00910               for (uint i = 0; i < selection_.count(); ++i)
00911                      selection_[i]->charStyle().resetFillColor();
00912        else {
00913               QString c( pwidget_->cpage->fillColor_->currentText());
00914               for (uint i = 0; i < selection_.count(); ++i)
00915                      selection_[i]->charStyle().setFillColor(c);
00916        }
00917        
00918        if (!selectionIsDirty_)
00919        {
00920               selectionIsDirty_ = true;
00921               emit selectionDirty();
00922        }
00923 }
00924 
00925 void SMParagraphStyle::slotFillShade()
00926 {
00927        if (pwidget_->cpage->fillShade_->useParentValue())
00928               for (uint i = 0; i < selection_.count(); ++i)
00929                      selection_[i]->charStyle().resetFillShade();
00930        else {
00931               int fs = pwidget_->cpage->fillShade_->getValue();
00932 
00933               for (uint i = 0; i < selection_.count(); ++i)
00934                      selection_[i]->charStyle().setFillShade(fs);
00935        }
00936        
00937        if (!selectionIsDirty_)
00938        {
00939               selectionIsDirty_ = true;
00940               emit selectionDirty();
00941        }
00942 }
00943 
00944 void SMParagraphStyle::slotStrokeColor()
00945 {
00946        if (pwidget_->cpage->strokeColor_->useParentValue())
00947               for (uint i = 0; i < selection_.count(); ++i)
00948                      selection_[i]->charStyle().resetStrokeColor();
00949        else {
00950               QString c(pwidget_->cpage->strokeColor_->currentText());
00951 
00952               for (uint i = 0; i < selection_.count(); ++i)
00953                      selection_[i]->charStyle().setStrokeColor(c);
00954        }
00955        
00956        if (!selectionIsDirty_)
00957        {
00958               selectionIsDirty_ = true;
00959               emit selectionDirty();
00960        }
00961 }
00962 
00963 void SMParagraphStyle::slotStrokeShade()
00964 {
00965        if (pwidget_->cpage->strokeShade_->useParentValue())
00966               for (uint i = 0; i < selection_.count(); ++i)
00967                      selection_[i]->charStyle().resetStrokeShade();
00968        else 
00969        {
00970               int ss = pwidget_->cpage->strokeShade_->getValue();
00971 
00972               for (uint i = 0; i < selection_.count(); ++i)
00973                      selection_[i]->charStyle().setStrokeShade(ss);
00974        }
00975        
00976        if (!selectionIsDirty_)
00977        {
00978               selectionIsDirty_ = true;
00979               emit selectionDirty();
00980        }
00981 }
00982 
00983 void SMParagraphStyle::slotLanguage()
00984 {
00985        QMap<QString,QString>::Iterator it;
00986        QString language = doc_->paragraphStyle("").charStyle().language();
00987 
00988        if (pwidget_->cpage->language_->useParentValue())
00989               for (uint i = 0; i < selection_.count(); ++i)
00990                      selection_[i]->charStyle().resetLanguage();
00991        else
00992        {
00993               for (it = doc_->scMW()->LangTransl.begin(); it != doc_->scMW()->LangTransl.end(); ++it)
00994               {
00995                      if (it.data() == pwidget_->cpage->language_->currentText())
00996                      {
00997                             language = it.key();
00998                             break;
00999                      }
01000               }
01001               for (uint i = 0; i < selection_.count(); ++i)
01002                      selection_[i]->charStyle().setLanguage(language);
01003        }
01004 
01005        if (!selectionIsDirty_)
01006        {
01007               selectionIsDirty_ = true;
01008               emit selectionDirty();
01009        }
01010 }
01011 
01012 void SMParagraphStyle::slotScaleH()
01013 {
01014        if (pwidget_->cpage->fontHScale_->useParentValue())
01015               for (uint i = 0; i < selection_.count(); ++i)
01016                      selection_[i]->charStyle().resetScaleH();
01017        else
01018        {
01019               double a, b, value;
01020               int c;
01021               pwidget_->cpage->fontHScale_->getValues(&a, &b, &c, &value);
01022               value = value * 10;
01023               for (uint i = 0; i < selection_.count(); ++i)
01024                      selection_[i]->charStyle().setScaleH(qRound(value));
01025        }
01026 
01027        if (!selectionIsDirty_)
01028        {
01029               selectionIsDirty_ = true;
01030               emit selectionDirty();
01031        }
01032 }
01033 
01034 void SMParagraphStyle::slotScaleV()
01035 {
01036        if (pwidget_->cpage->fontVScale_->useParentValue())
01037               for (uint i = 0; i < selection_.count(); ++i)
01038                      selection_[i]->charStyle().resetScaleV();
01039        else
01040        {
01041               double a, b, value;
01042               int c;
01043               pwidget_->cpage->fontVScale_->getValues(&a, &b, &c, &value);
01044               value = value * 10;
01045               for (uint i = 0; i < selection_.count(); ++i)
01046                      selection_[i]->charStyle().setScaleV(qRound(value));
01047        }
01048 
01049        if (!selectionIsDirty_)
01050        {
01051               selectionIsDirty_ = true;
01052               emit selectionDirty();
01053        }
01054 }
01055 
01056 void SMParagraphStyle::slotTracking()
01057 {
01058        if (pwidget_->cpage->tracking_->useParentValue())
01059               for (uint i = 0; i < selection_.count(); ++i)
01060                      selection_[i]->charStyle().resetTracking();
01061        else
01062        {
01063               double a, b, value;
01064               int c;
01065               pwidget_->cpage->tracking_->getValues(&a, &b, &c, &value);
01066               value = value * 10;
01067               for (uint i = 0; i < selection_.count(); ++i)
01068                      selection_[i]->charStyle().setTracking(qRound(value));
01069        }
01070 
01071        if (!selectionIsDirty_)
01072        {
01073               selectionIsDirty_ = true;
01074               emit selectionDirty();
01075        }
01076 }
01077 
01078 void SMParagraphStyle::slotBaselineOffset()
01079 {
01080        if (pwidget_->cpage->baselineOffset_->useParentValue())
01081               for (uint i = 0; i < selection_.count(); ++i)
01082                      selection_[i]->charStyle().resetBaselineOffset();
01083        else
01084        {
01085               double a, b, value;
01086               int c; 
01087               pwidget_->cpage->baselineOffset_->getValues(&a, &b, &c, &value);
01088               value = value * 10;
01089               for (uint i = 0; i < selection_.count(); ++i)
01090                      selection_[i]->charStyle().setBaselineOffset(qRound(value));
01091        }
01092 
01093        if (!selectionIsDirty_)
01094        {
01095               selectionIsDirty_ = true;
01096               emit selectionDirty();
01097        }
01098 }
01099 
01100 void SMParagraphStyle::slotFont(QString s)
01101 {
01102        if (pwidget_->cpage->fontFace_->useParentFont())
01103               for (uint i = 0; i < selection_.count(); ++i)
01104                      selection_[i]->charStyle().resetFont();
01105        else {
01106               ScFace sf = PrefsManager::instance()->appPrefs.AvailFonts[s];
01107               
01108               for (uint i = 0; i < selection_.count(); ++i)
01109                      selection_[i]->charStyle().setFont(sf);
01110        }
01111        
01112        if (!selectionIsDirty_)
01113        {
01114               selectionIsDirty_ = true;
01115               emit selectionDirty();
01116        }
01117 }
01118 
01119 void SMParagraphStyle::slotParentChanged(const QString &parent)
01120 {
01121        Q_ASSERT(!parent.isNull());
01122 
01123        QStringList sel;
01124 
01125        for (uint i = 0; i < selection_.count(); ++i)
01126        {
01127 //            const ParagraphStyle *style = & (doc_->paragraphStyle(parent));
01128 //            if (style)
01129               {
01130                      selection_[i]->erase(); // reset everything to NOVALUE
01131                      selection_[i]->setParent(parent);
01132                      selection_[i]->charStyle().setParent("");
01133                      sel << selection_[i]->name();
01134               }
01135        }
01136 
01137        selected(sel);
01138 
01139        if (!selectionIsDirty_)
01140        {
01141               selectionIsDirty_ = true;
01142               emit selectionDirty();
01143        }
01144 }
01145 
01146 void SMParagraphStyle::slotCharParentChanged(const QString &parent)
01147 {
01148        Q_ASSERT(parent != QString::null);
01149 
01150        QStringList sel;
01151 
01152        for (uint i = 0; i < selection_.count(); ++i)
01153        {
01154               selection_[i]->charStyle().erase();
01155               if (parent != QString::null)
01156                      selection_[i]->charStyle().setParent(parent);
01157 
01158               sel << selection_[i]->name();
01159        }
01160 
01161        selected(sel);
01162 
01163        if (!selectionIsDirty_)
01164        {
01165               selectionIsDirty_ = true;
01166               emit selectionDirty();
01167        }
01168 }
01169 
01170 SMParagraphStyle::~SMParagraphStyle()
01171 {
01172 
01173 }
01174 
01175 /******************************************************************************/
01176 /******************************************************************************/
01177 
01178 SMCharacterStyle::SMCharacterStyle() : StyleItem(), widget_(0), page_(0), doc_(0), selectionIsDirty_(false)
01179 {
01180        widget_ = new QTabWidget();
01181        Q_CHECK_PTR(widget_);
01182        widget_->setMargin(5);//CB the SMCStylePage parent has a 0 value to fit properly onto the pstyle page, so add it here
01183        page_ = new SMCStylePage();
01184        Q_CHECK_PTR(page_);
01185        widget_->addTab(page_, tr("Properties"));
01186 }
01187 
01188 QTabWidget* SMCharacterStyle::widget()
01189 {
01190        return widget_;
01191 }
01192 
01193 QString SMCharacterStyle::typeNamePlural()
01194 {
01195        return tr("Character Styles");
01196 }
01197 
01198 QString SMCharacterStyle::typeNameSingular()
01199 {
01200        return tr("Character Style");
01201 }
01202 
01203 void SMCharacterStyle::currentDoc(ScribusDoc *doc)
01204 {
01205        doc_ = doc;
01206        if (doc_)
01207        {
01208               if (page_)
01209               {
01210                      page_->fillLangCombo(doc_->scMW()->LangTransl);
01211                      page_->fillColorCombo(doc_->PageColors);
01212                      page_->fontFace_->RebuildList(doc_);
01213               }
01214        }
01215        else
01216        {
01217               removeConnections();
01218               selection_.clear();
01219               tmpStyles_.clear();
01220        }
01221 
01222 }
01223 
01224 StyleSet<CharStyle>* SMCharacterStyle::tmpStyles()
01225 {
01226        return &tmpStyles_;
01227 }
01228 
01229 QValueList<StyleName> SMCharacterStyle::styles(bool reloadFromDoc)
01230 {
01231        QValueList<StyleName> tmpList;
01232 
01233        if (!doc_)
01234               return tmpList; // no doc available
01235 
01236        if (reloadFromDoc)
01237               reloadTmpStyles();
01238 
01239        for (uint i = 0; i < tmpStyles_.count(); ++i)
01240        {
01241               if (tmpStyles_[i].hasName())
01242               {
01243                      QString styleName(tmpStyles_[i].name());
01244                      QString parentName(QString::null);
01245 
01246                      if (tmpStyles_[i].hasParent())
01247                             parentName = tmpStyles_[i].parent();
01248 
01249                      tmpList << StyleName(styleName, parentName);
01250               }
01251        }
01252 
01253        return tmpList;
01254 }
01255 
01256 void SMCharacterStyle::reload()
01257 {
01258        reloadTmpStyles();
01259 }
01260 
01261 void SMCharacterStyle::selected(const QStringList &styleNames)
01262 {
01263        selection_.clear();
01264        selectionIsDirty_ = false;
01265        removeConnections();
01266        QValueList<CharStyle> cstyles;
01267 
01268        tmpStyles_.invalidate();
01269 
01270        for (uint i = 0; i < tmpStyles_.count(); ++i)
01271               cstyles << tmpStyles_[i];
01272 
01273        for (uint i = 0; i < styleNames.count(); ++i)
01274        {
01275               int index = tmpStyles_.find(styleNames[i]);
01276               if (index > -1)
01277                      selection_.append(&tmpStyles_[index]);
01278 
01279        }
01280 
01281        page_->show(selection_, cstyles, doc_->paragraphStyle("").charStyle().language(), doc_->unitIndex());
01282        setupConnections();
01283 }
01284 
01285 QString SMCharacterStyle::fromSelection() const
01286 {
01287        QString lsName(QString::null);
01288        if (!doc_)
01289               return lsName; // no doc available
01290 
01291        for (uint i = 0; i < doc_->m_Selection->count(); ++i)
01292        {
01293               // wth is going on here
01294               PageItem *item = doc_->m_Selection->itemAt(i);
01295 
01296               QString tmpName = item->itemText.defaultStyle().charStyle().parent();
01297 
01298               if (lsName.isNull() && !tmpName.isEmpty() && tmpName != "")
01299               {
01300                      lsName = tmpName;
01301               }
01302               else if (!lsName.isNull() && !tmpName.isEmpty() && tmpName != "" && lsName != tmpName)
01303               {
01304                      lsName = QString::null;
01305                      break;
01306               }
01307        }
01308        return lsName;
01309 }
01310 
01311 void SMCharacterStyle::toSelection(const QString &styleName) const
01312 {
01313        if (!doc_)
01314               return; // nowhere to apply or no doc
01315 
01316        doc_->itemSelection_SetNamedCharStyle(styleName);
01317 }
01318 
01319 QString SMCharacterStyle::newStyle()
01320 {
01321        Q_ASSERT(doc_ && doc_->paragraphStyles().count() > 0);
01322 
01323        QString s = getUniqueName( tr("New Style"));
01324        CharStyle c;
01325        c.setName(s);
01326        tmpStyles_.create(c);
01327        return s;
01328 }
01329 
01330 QString SMCharacterStyle::newStyle(const QString &fromStyle)
01331 {
01332        Q_ASSERT(tmpStyles_.resolve(fromStyle));
01333        if (!tmpStyles_.resolve(fromStyle))
01334               return QString::null;
01335 
01336        QString s = getUniqueName( tr("Clone of %1").arg(fromStyle));
01337        CharStyle c(tmpStyles_[fromStyle]);
01338        c.setName(s);
01339        c.setShortcut(QString::null);
01340        tmpStyles_.create(c);
01341 
01342        return s;
01343 }
01344 
01345 QString SMCharacterStyle::getUniqueName(const QString &name)
01346 {
01347        int id = 0;
01348        bool done = false;
01349        QString s(name);
01350 
01351        while (!done)
01352        {
01353 start:
01354               ++id;
01355               for (uint i = 0; i < tmpStyles_.count(); ++i)
01356               {
01357                      if (tmpStyles_[i].name() == s)
01358                      {
01359                             s = tr("%1 (%2)", "This for unique name when creating "
01360                                           "a new character style. %1 will be the name "
01361                                                         "of the style and %2 will be a number forming "
01362                                                         "a style name like: New Style (2)").arg(name).arg(id);
01363                             goto start;
01364                      }
01365               }
01366               done = true;
01367        }
01368 
01369        return s;
01370 }
01371 
01372 void SMCharacterStyle::apply()
01373 {
01374        if (!doc_)
01375               return;
01376 
01377        QMap<QString, QString> replacement;
01378        for (uint i = 0; i < deleted_.count(); ++i)
01379               replacement[deleted_[i].first] = deleted_[i].second;
01380 
01381        doc_->redefineCharStyles(tmpStyles_, false);
01382        doc_->replaceCharStyles(replacement);
01383 
01384        deleted_.clear(); // deletion done at this point
01385 
01386        doc_->scMW()->propertiesPalette->paraStyleCombo->updateFormatList();
01387        doc_->scMW()->propertiesPalette->charStyleCombo->updateFormatList();
01388        doc_->scMW()->view->DrawNew();
01389        doc_->changed();
01390 }
01391 
01392 void SMCharacterStyle::editMode(bool isOn)
01393 {
01394        if (isOn)
01395               reloadTmpStyles();
01396 }
01397 
01398 QString SMCharacterStyle::shortcut(const QString &stylename) const
01399 {
01400        QString s = QString::null;
01401        int index = tmpStyles_.find(stylename);
01402        if (index > -1)
01403               s = tmpStyles_[index].shortcut();
01404 
01405        return s;
01406 }
01407 
01408 void SMCharacterStyle::setShortcut(const QString &shortcut)
01409 {
01410        Q_ASSERT(selection_.count() == 1);
01411        if (selection_.count() != 1)
01412               return;
01413 
01414        selection_[0]->setShortcut(shortcut);
01415 
01416        if (!selectionIsDirty_)
01417        {
01418               selectionIsDirty_ = true;
01419               emit selectionDirty();
01420        }
01421 }
01422 
01423 void SMCharacterStyle::deleteStyles(const QValueList<RemoveItem> &removeList)
01424 {
01425        for (uint i = 0; i < removeList.count(); ++i)
01426        {
01427               for (uint k = 0; k < selection_.count(); ++k)
01428               {
01429                      if (selection_[k]->name() == removeList[i].first)
01430                      {
01431                             selection_.erase(selection_.at(k));
01432                             break;
01433                      }
01434               }
01435 
01436               int index = tmpStyles_.find(removeList[i].first);
01437               if (index > -1)
01438                      tmpStyles_.remove(index);
01439               deleted_ << removeList[i];
01440        }
01441 }
01442 
01443 void SMCharacterStyle::nameChanged(const QString &newName)
01444 {
01445 //     for (uint i = 0; i < selection_.count(); ++i)
01446 //            selection_[i]->setName(newName);
01447 
01448        QString oldName(selection_[0]->name());
01449        CharStyle c(*selection_[0]);
01450        c.setName(newName);
01451        tmpStyles_.create(c);
01452        selection_.clear();
01453        selection_.append(&tmpStyles_[tmpStyles_.find(newName)]);
01454        for (uint j = 0; j < tmpStyles_.count(); ++j)
01455        {
01456               int index = tmpStyles_.find(oldName);
01457               if (index > -1)
01458               {
01459                      tmpStyles_.remove(index);
01460                      break;
01461               }
01462        }
01463 
01464        for (uint j = 0; j < tmpStyles_.count(); ++j)
01465        {
01466               if (tmpStyles_[j].parent() == oldName)
01467                      tmpStyles_[j].setParent(newName);
01468        }
01469 
01470        QValueList<RemoveItem>::iterator it;
01471        for (it = deleted_.begin(); it != deleted_.end(); ++it)
01472        {
01473               if ((*it).second == oldName)
01474               {
01475                      oldName = (*it).first;
01476                      deleted_.remove(it);
01477                      break;
01478               }
01479        }
01480 
01481        deleted_.append(RemoveItem(oldName, newName));
01482 
01483        if (!selectionIsDirty_)
01484        {
01485               selectionIsDirty_ = true;
01486               emit selectionDirty();
01487        }
01488 }
01489 
01490 void SMCharacterStyle::languageChange()
01491 {
01492        if (widget_ && page_)
01493        {
01494               widget_->setTabLabel(page_, tr("Properties"));
01495               page_->languageChange();
01496        }
01497 }
01498 
01499 void SMCharacterStyle::unitChange()
01500 {
01501 
01502 }
01503 
01504 void SMCharacterStyle::reloadTmpStyles()
01505 {
01506        if (!doc_)
01507               return;
01508 
01509        selection_.clear();
01510        tmpStyles_.clear();
01511        tmpStyles_.redefine(doc_->charStyles(), true);
01512 }
01513 
01514 void SMCharacterStyle::setupConnections()
01515 {
01516        if (!page_)
01517               return;
01518 
01519        connect(page_->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
01520        connect(page_->effects_, SIGNAL(State(int)), this, SLOT(slotEffects(int)));
01521        connect(page_->effects_->ShadowVal->Xoffset, SIGNAL(valueChanged(int)),
01522                         this, SLOT(slotEffectProperties()));
01523        connect(page_->effects_->ShadowVal->Yoffset, SIGNAL(valueChanged(int)),
01524                         this, SLOT(slotEffectProperties()));
01525        connect(page_->effects_->OutlineVal->LWidth, SIGNAL(valueChanged(int)),
01526                         this, SLOT(slotEffectProperties()));
01527        connect(page_->effects_->UnderlineVal->LPos, SIGNAL(valueChanged(int)),
01528                         this, SLOT(slotEffectProperties()));
01529        connect(page_->effects_->UnderlineVal->LWidth, SIGNAL(valueChanged(int)),
01530                         this, SLOT(slotEffectProperties()));
01531        connect(page_->effects_->StrikeVal->LPos, SIGNAL(valueChanged(int)),
01532                         this, SLOT(slotEffectProperties()));
01533        connect(page_->effects_->StrikeVal->LWidth, SIGNAL(valueChanged(int)),
01534                         this, SLOT(slotEffectProperties()));
01535        connect(page_->fillColor_, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
01536        connect(page_->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
01537        connect(page_->strokeColor_, SIGNAL(activated(const QString&)), this, SLOT(slotStrokeColor()));
01538        connect(page_->strokeShade_, SIGNAL(clicked()), this, SLOT(slotStrokeShade()));
01539        connect(page_->language_, SIGNAL(activated(int)), this, SLOT(slotLanguage()));
01540        connect(page_->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(slotFontSize()));
01541        connect(page_->fontHScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleH()));
01542        connect(page_->fontVScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleV()));
01543        connect(page_->tracking_, SIGNAL(valueChanged(int)), this, SLOT(slotTracking()));
01544        connect(page_->baselineOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotBaselineOffset()));
01545        connect(page_->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
01546        connect(page_->parentCombo, SIGNAL(activated(const QString&)),
01547                this, SLOT(slotParentChanged(const QString&)));
01548 }
01549 
01550 void SMCharacterStyle::removeConnections()
01551 {
01552        if (!page_)
01553               return;
01554 
01555        disconnect(page_->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
01556        disconnect(page_->effects_, SIGNAL(State(int)), this, SLOT(slotEffects(int)));
01557        disconnect(page_->effects_->ShadowVal->Xoffset, SIGNAL(valueChanged(int)),
01558                         this, SLOT(slotEffectProperties()));
01559        disconnect(page_->effects_->ShadowVal->Yoffset, SIGNAL(valueChanged(int)),
01560                         this, SLOT(slotEffectProperties()));
01561        disconnect(page_->effects_->OutlineVal->LWidth, SIGNAL(valueChanged(int)),
01562                         this, SLOT(slotEffectProperties()));
01563        disconnect(page_->effects_->UnderlineVal->LPos, SIGNAL(valueChanged(int)),
01564                         this, SLOT(slotEffectProperties()));
01565        disconnect(page_->effects_->UnderlineVal->LWidth, SIGNAL(valueChanged(int)),
01566                         this, SLOT(slotEffectProperties()));
01567        disconnect(page_->effects_->StrikeVal->LPos, SIGNAL(valueChanged(int)),
01568                         this, SLOT(slotEffectProperties()));
01569        disconnect(page_->effects_->StrikeVal->LWidth, SIGNAL(valueChanged(int)),
01570                         this, SLOT(slotEffectProperties()));
01571        disconnect(page_->fillColor_, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
01572        disconnect(page_->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
01573        disconnect(page_->strokeColor_, SIGNAL(activated(const QString&)), this, SLOT(slotStrokeColor()));
01574        disconnect(page_->strokeShade_, SIGNAL(clicked()), this, SLOT(slotStrokeShade()));
01575        disconnect(page_->language_, SIGNAL(activated(int)), this, SLOT(slotLanguage()));
01576        disconnect(page_->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(slotFontSize()));
01577        disconnect(page_->fontHScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleH()));
01578        disconnect(page_->fontVScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleV()));
01579        disconnect(page_->tracking_, SIGNAL(valueChanged(int)), this, SLOT(slotTracking()));
01580        disconnect(page_->baselineOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotBaselineOffset()));
01581        disconnect(page_->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
01582        disconnect(page_->parentCombo, SIGNAL(activated(const QString&)),
01583                      this, SLOT(slotParentChanged(const QString&)));
01584 }
01585 
01586 void SMCharacterStyle::slotFontSize()
01587 {
01588        if (page_->fontSize_->useParentValue())
01589               for (uint i = 0; i < selection_.count(); ++i)
01590                      selection_[i]->resetFontSize();
01591        else
01592        {
01593               double a, b, value;
01594               int c;
01595 
01596               page_->fontSize_->getValues(&a, &b, &c, &value);
01597               value = value * 10;
01598               for (uint i = 0; i < selection_.count(); ++i)
01599                      selection_[i]->setFontSize(qRound(value));
01600        }
01601 
01602        if (!selectionIsDirty_)
01603        {
01604               selectionIsDirty_ = true;
01605               emit selectionDirty();
01606        }
01607 }
01608 
01609 void SMCharacterStyle::slotEffects(int e)
01610 {
01611        StyleFlag s = ScStyle_None;
01612        if (page_->effects_->useParentValue())
01613        {
01614               for (uint i = 0; i < selection_.count(); ++i)
01615               {
01616                      selection_[i]->resetFeatures();
01617                      selection_[i]->resetShadowXOffset();
01618                      selection_[i]->resetShadowYOffset();
01619                      selection_[i]->resetOutlineWidth();
01620                      selection_[i]->resetUnderlineOffset();
01621                      selection_[i]->resetUnderlineWidth();
01622                      selection_[i]->resetStrikethruOffset();
01623                      selection_[i]->resetStrikethruWidth();
01624               }
01625        }
01626        else
01627        {
01628               s = static_cast<StyleFlag>(e);
01629               double a, b, sxo, syo, olw, ulp, ulw, slp, slw;
01630               int c;
01631 
01632               page_->effects_->ShadowVal->Xoffset->getValues(&a, &b, &c, &sxo);
01633               sxo *= 10;
01634               page_->effects_->ShadowVal->Yoffset->getValues(&a, &b, &c, &syo);
01635               syo *= 10;
01636 
01637               page_->effects_->OutlineVal->LWidth->getValues(&a, &b, &c, &olw);
01638               olw *= 10;
01639 
01640               page_->effects_->UnderlineVal->LPos->getValues(&a, &b, &c, &ulp);
01641               ulp *= 10;
01642               page_->effects_->UnderlineVal->LWidth->getValues(&a, &b, &c, &ulw);
01643               ulw *= 10;
01644 
01645               page_->effects_->StrikeVal->LPos->getValues(&a, &b, &c, &slp);
01646               slp *= 10;
01647               page_->effects_->StrikeVal->LWidth->getValues(&a, &b, &c, &slw);
01648               slw *= 10;
01649 
01650               for (uint i = 0; i < selection_.count(); ++i)
01651               {
01652                      selection_[i]->setFeatures(s.featureList());
01653                      selection_[i]->setShadowXOffset(qRound(sxo));
01654                      selection_[i]->setShadowYOffset(qRound(syo));
01655                      selection_[i]->setOutlineWidth(qRound(olw));
01656                      selection_[i]->setUnderlineOffset(qRound(ulp));
01657                      selection_[i]->setUnderlineWidth(qRound(ulw));
01658                      selection_[i]->setStrikethruOffset(qRound(slp));
01659                      selection_[i]->setStrikethruWidth(qRound(slw));
01660               }
01661        }
01662 
01663 
01664        if (!selectionIsDirty_)
01665        {
01666               selectionIsDirty_ = true;
01667               emit selectionDirty();
01668        }
01669 }
01670 
01671 void SMCharacterStyle::slotEffectProperties()
01672 {
01673        double a, b, sxo, syo, olw, ulp, ulw, slp, slw;
01674        int c;
01675 
01676        page_->effects_->ShadowVal->Xoffset->getValues(&a, &b, &c, &sxo);
01677        sxo *= 10;
01678        page_->effects_->ShadowVal->Yoffset->getValues(&a, &b, &c, &syo);
01679        syo *= 10;
01680 
01681        page_->effects_->OutlineVal->LWidth->getValues(&a, &b, &c, &olw);
01682        olw *= 10;
01683 
01684        page_->effects_->UnderlineVal->LPos->getValues(&a, &b, &c, &ulp);
01685        ulp *= 10;
01686        page_->effects_->UnderlineVal->LWidth->getValues(&a, &b, &c, &ulw);
01687        ulw *= 10;
01688 
01689        page_->effects_->StrikeVal->LPos->getValues(&a, &b, &c, &slp);
01690        slp *= 10;
01691        page_->effects_->StrikeVal->LWidth->getValues(&a, &b, &c, &slw);
01692        slw *= 10;
01693        
01694        for (uint i = 0; i < selection_.count(); ++i)
01695        {
01696               selection_[i]->setShadowXOffset(qRound(sxo));
01697               selection_[i]->setShadowYOffset(qRound(syo));
01698               selection_[i]->setOutlineWidth(qRound(olw));
01699               selection_[i]->setUnderlineOffset(qRound(ulp));
01700               selection_[i]->setUnderlineWidth(qRound(ulw));
01701               selection_[i]->setStrikethruOffset(qRound(slp));
01702               selection_[i]->setStrikethruWidth(qRound(slw));
01703        }
01704 
01705        if (!selectionIsDirty_)
01706        {
01707               selectionIsDirty_ = true;
01708               emit selectionDirty();
01709        }
01710 }
01711 
01712 void SMCharacterStyle::slotFillColor()
01713 {
01714        if (page_->fillColor_->useParentValue())
01715               for (uint i = 0; i < selection_.count(); ++i)
01716                      selection_[i]->resetFillColor();
01717        else {        
01718               QString col(page_->fillColor_->currentText());
01719               
01720               for (uint i = 0; i < selection_.count(); ++i)
01721                      selection_[i]->setFillColor(col);
01722        }
01723        
01724        if (!selectionIsDirty_)
01725        {
01726               selectionIsDirty_ = true;
01727               emit selectionDirty();
01728        }
01729 }
01730 
01731 void SMCharacterStyle::slotFillShade()
01732 {
01733        if (page_->fillShade_->useParentValue())
01734               for (uint i = 0; i < selection_.count(); ++i)
01735                      selection_[i]->resetFillShade();
01736        else {
01737               int fs = page_->fillShade_->getValue();
01738 
01739               for (uint i = 0; i < selection_.count(); ++i)
01740                      selection_[i]->setFillShade(fs);
01741        }
01742        
01743        if (!selectionIsDirty_)
01744        {
01745               selectionIsDirty_ = true;
01746               emit selectionDirty();
01747        }
01748 }
01749 
01750 void SMCharacterStyle::slotStrokeColor()
01751 {
01752        if (page_->strokeColor_->useParentValue())
01753               for (uint i = 0; i < selection_.count(); ++i)
01754                      selection_[i]->resetStrokeColor();
01755        else {
01756               QString c(page_->strokeColor_->currentText());
01757 
01758               for (uint i = 0; i < selection_.count(); ++i)
01759                      selection_[i]->setStrokeColor(c);
01760        }
01761        
01762        if (!selectionIsDirty_)
01763        {
01764               selectionIsDirty_ = true;
01765               emit selectionDirty();
01766        }
01767 }
01768 
01769 void SMCharacterStyle::slotStrokeShade()
01770 {
01771        if (page_->strokeShade_->useParentValue())
01772               for (uint i = 0; i < selection_.count(); ++i)
01773                      selection_[i]->resetStrokeShade();
01774        else {
01775               int ss = page_->strokeShade_->getValue();
01776               
01777               for (uint i = 0; i < selection_.count(); ++i)
01778                      selection_[i]->setStrokeShade(ss);
01779        }
01780        
01781        if (!selectionIsDirty_)
01782        {
01783               selectionIsDirty_ = true;
01784               emit selectionDirty();
01785        }
01786 }
01787 
01788 void SMCharacterStyle::slotLanguage()
01789 {
01790        QMap<QString,QString>::Iterator it;
01791        QString language = doc_->paragraphStyle("").charStyle().language();
01792 
01793        if (page_->language_->useParentValue())
01794               for (uint i = 0; i < selection_.count(); ++i)
01795                      selection_[i]->resetLanguage();
01796        else
01797        {
01798               for (it = doc_->scMW()->LangTransl.begin(); it != doc_->scMW()->LangTransl.end(); ++it)
01799               {
01800                      if (it.data() == page_->language_->currentText())
01801                      {
01802                             language = it.key();
01803                             break;
01804                      }
01805               }
01806               for (uint i = 0; i < selection_.count(); ++i)
01807                      selection_[i]->setLanguage(language);
01808        }
01809 
01810 
01811        if (!selectionIsDirty_)
01812        {
01813               selectionIsDirty_ = true;
01814               emit selectionDirty();
01815        }
01816 }
01817 
01818 void SMCharacterStyle::slotScaleH()
01819 {
01820        if (page_->fontHScale_->useParentValue())
01821               for (uint i = 0; i < selection_.count(); ++i)
01822                      selection_[i]->resetScaleH();
01823        else
01824        {
01825               double a, b, value;
01826               int c;
01827 
01828               page_->fontHScale_->getValues(&a, &b, &c, &value);
01829               value = value * 10;
01830               for (uint i = 0; i < selection_.count(); ++i)
01831                      selection_[i]->setScaleH(qRound(value));
01832        }
01833 
01834 
01835        if (!selectionIsDirty_)
01836        {
01837               selectionIsDirty_ = true;
01838               emit selectionDirty();
01839        }
01840 }
01841 
01842 void SMCharacterStyle::slotScaleV()
01843 {
01844        if (page_->fontVScale_->useParentValue())
01845               for (uint i = 0; i < selection_.count(); ++i)
01846                      selection_[i]->resetScaleV();
01847        else
01848        {
01849               double a, b, value;
01850               int c;
01851 
01852               page_->fontVScale_->getValues(&a, &b, &c, &value);
01853               value = value * 10;
01854               for (uint i = 0; i < selection_.count(); ++i)
01855                      selection_[i]->setScaleV(qRound(value));
01856        }
01857 
01858 
01859        if (!selectionIsDirty_)
01860        {
01861               selectionIsDirty_ = true;
01862               emit selectionDirty();
01863        }
01864 }
01865 
01866 void SMCharacterStyle::slotTracking()
01867 {
01868        if (page_->tracking_->useParentValue())
01869               for (uint i = 0; i < selection_.count(); ++i)
01870                      selection_[i]->resetTracking();
01871        else
01872        {
01873               double a, b, value;
01874               int c;
01875 
01876               page_->tracking_->getValues(&a, &b, &c, &value);
01877               value = value * 10;
01878               for (uint i = 0; i < selection_.count(); ++i)
01879                      selection_[i]->setTracking(qRound(value));
01880        }
01881 
01882        if (!selectionIsDirty_)
01883        {
01884               selectionIsDirty_ = true;
01885               emit selectionDirty();
01886        }
01887 }
01888 
01889 void SMCharacterStyle::slotBaselineOffset()
01890 {
01891        if (page_->baselineOffset_->useParentValue())
01892               for (uint i = 0; i < selection_.count(); ++i)
01893                      selection_[i]->resetBaselineOffset();
01894        else
01895        {
01896               double a, b, value;
01897               int c;
01898               
01899               page_->baselineOffset_->getValues(&a, &b, &c, &value);
01900               value = value * 10;
01901               for (uint i = 0; i < selection_.count(); ++i)
01902                      selection_[i]->setBaselineOffset(qRound(value));
01903        }
01904 
01905        if (!selectionIsDirty_)
01906        {
01907               selectionIsDirty_ = true;
01908               emit selectionDirty();
01909        }
01910 }
01911 
01912 void SMCharacterStyle::slotFont(QString s)
01913 {
01914        ScFace sf;
01915        if (page_->fontFace_->useParentFont())
01916               for (uint i = 0; i < selection_.count(); ++i)
01917                      selection_[i]->resetFont();
01918        else {
01919               sf = PrefsManager::instance()->appPrefs.AvailFonts[s];
01920 
01921               for (uint i = 0; i < selection_.count(); ++i)
01922                      selection_[i]->setFont(sf);
01923        }
01924        
01925        if (!selectionIsDirty_)
01926        {
01927               selectionIsDirty_ = true;
01928               emit selectionDirty();
01929        }
01930 }
01931 
01932 void SMCharacterStyle::slotParentChanged(const QString &parent)
01933 {
01934        Q_ASSERT(!parent.isNull());
01935 
01936        QStringList sel;
01937 
01938        for (uint i = 0; i < selection_.count(); ++i)
01939        {
01940               selection_[i]->erase();
01941               selection_[i]->setParent(parent);
01942               sel << selection_[i]->name();
01943        }
01944 
01945        selected(sel);
01946 
01947        if (!selectionIsDirty_)
01948        {
01949               selectionIsDirty_ = true;
01950               emit selectionDirty();
01951        }
01952 }
01953 
01954 SMCharacterStyle::~SMCharacterStyle()
01955 {
01956        delete page_;
01957        delete widget_;
01958        page_ = 0;
01959        widget_ = 0;
01960 }
01961