~ubuntu-branches/ubuntu/maverick/scribus-ng/maverick-backports

« back to all changes in this revision

Viewing changes to scribus/smtextstyles.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Oleksandr Moskalenko
  • Date: 2007-08-11 17:41:51 UTC
  • mfrom: (0.1.1 upstream) (4.1.2 feisty)
  • Revision ID: james.westby@ubuntu.com-20070811174151-tmkgjvjuc0mtk8ul
Tags: 1.3.4.dfsg+svn20071115-1
* Upstream svn update (Closes: #447480, #448949).
* debian/NEWS: Added a note for users wanting stable Scribus to switch to
  the "scribus" package (Closes: #427638).
* debian/watch: Updated the watch regex to properly track sourceforge
  releases for this branch (Closes: #449700).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
 
3
to the COPYING file provided with the program. Following this notice may exist
 
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
 
5
for which a new license (GPL+exception) is in place.
 
6
*/
 
7
 
 
8
#include "smtextstyles.h"
 
9
#include "smtextstyles.moc"
 
10
#include "smtextstylewidgets.h"
 
11
#include "util.h"
 
12
#include "mspinbox.h"
 
13
#include "alignselect.h"
 
14
#include "tabruler.h"
 
15
#include "fontcombo.h"
 
16
#include "styleselect.h"
 
17
#include "sccombobox.h"
 
18
#include "shadebutton.h"
 
19
#include "commonstrings.h"
 
20
#include "style.h"
 
21
#include "scribusdoc.h"
 
22
#include "selection.h"
 
23
#include "scribus.h"
 
24
#include "prefsmanager.h"
 
25
#include "colorcombo.h"
 
26
#include "story.h"
 
27
#include "menumanager.h"
 
28
#include "fmitem.h"
 
29
#include "mpalette.h"
 
30
#include "smwidgets.h"
 
31
 
 
32
#include <qtabwidget.h>
 
33
 
 
34
SMParagraphStyle::SMParagraphStyle(StyleSet<CharStyle> *cstyles) : StyleItem(),
 
35
pwidget_(0), doc_(0), selectionIsDirty_(false), unitRatio_(1.0), cstyles_(cstyles)
 
36
{
 
37
        Q_ASSERT(cstyles_);
 
38
        pwidget_ = new SMPStyleWidget();
 
39
        Q_CHECK_PTR(pwidget_);
 
40
}
 
41
 
 
42
QTabWidget* SMParagraphStyle::widget()
 
43
{
 
44
        return pwidget_->tabWidget;
 
45
}
 
46
 
 
47
QString SMParagraphStyle::typeNamePlural()
 
48
{
 
49
        return tr("Paragraph Styles");
 
50
}
 
51
 
 
52
QString SMParagraphStyle::typeNameSingular()
 
53
{
 
54
        return tr("Paragraph Style");
 
55
}
 
56
 
 
57
void SMParagraphStyle::currentDoc(ScribusDoc *doc)
 
58
{
 
59
        doc_ = doc;
 
60
        if (doc_)
 
61
        {
 
62
                if (pwidget_)
 
63
                {
 
64
                        pwidget_->cpage->fillLangCombo(doc_->scMW()->LangTransl);
 
65
                        pwidget_->cpage->fillColorCombo(doc_->PageColors);
 
66
                        pwidget_->cpage->fontFace_->RebuildList(doc_);
 
67
                        if (unitRatio_ != doc_->unitRatio())
 
68
                                unitChange();
 
69
                }
 
70
        }
 
71
        else
 
72
        {
 
73
                removeConnections();
 
74
                selection_.clear();
 
75
                tmpStyles_.clear();
 
76
                deleted_.clear();
 
77
        }
 
78
}
 
79
 
 
80
StyleSet<ParagraphStyle>* SMParagraphStyle::tmpStyles()
 
81
{
 
82
        return &tmpStyles_;
 
83
}
 
84
 
 
85
QValueList<StyleName> SMParagraphStyle::styles(bool reloadFromDoc)
 
86
{
 
87
        QValueList<StyleName> tmpList;
 
88
 
 
89
        if (!doc_)
 
90
                return tmpList; // no doc available
 
91
 
 
92
        if (reloadFromDoc)
 
93
        {
 
94
                deleted_.clear();
 
95
                reloadTmpStyles();
 
96
        }
 
97
 
 
98
        for (uint i = 0; i < tmpStyles_.count(); ++i)
 
99
        {
 
100
                if (tmpStyles_[i].hasName())
 
101
                {
 
102
                        QString styleName(tmpStyles_[i].name());
 
103
                        QString parentName(QString::null);
 
104
 
 
105
                        if (tmpStyles_[i].hasParent() )
 
106
                                parentName = tmpStyles_[i].parent();
 
107
 
 
108
                        tmpList << StyleName(styleName, parentName);
 
109
                }
 
110
        }
 
111
 
 
112
        return tmpList;
 
113
}
 
114
 
 
115
void SMParagraphStyle::reload()
 
116
{
 
117
        reloadTmpStyles();
 
118
}
 
119
 
 
120
void SMParagraphStyle::selected(const QStringList &styleNames)
 
121
{
 
122
        if (!doc_)
 
123
                return;
 
124
 
 
125
        selection_.clear();
 
126
        selectionIsDirty_ = false;
 
127
        removeConnections(); // we don't want to record changes during style setup
 
128
 
 
129
        tmpStyles_.invalidate();
 
130
 
 
131
        QValueList<ParagraphStyle> pstyles; // get saved styles
 
132
        QValueList<CharStyle> cstyles;
 
133
        for (uint i = 0; i < tmpStyles_.count(); ++i)
 
134
                pstyles << tmpStyles_[i];
 
135
        for (uint i = 0; i < cstyles_->count(); ++i)
 
136
                cstyles << (*cstyles_)[i];
 
137
 
 
138
        int index;
 
139
        for (uint i = 0; i < styleNames.count(); ++i)
 
140
        {
 
141
                index = tmpStyles_.find(styleNames[i]);
 
142
                if (index > -1)
 
143
                        selection_.append(&tmpStyles_[index]);
 
144
        }
 
145
 
 
146
        pwidget_->show(selection_, pstyles, cstyles, doc_->unitIndex(), (*cstyles_)[""].language());
 
147
 
 
148
        setupConnections();
 
149
}
 
150
 
 
151
QValueList<CharStyle> SMParagraphStyle::getCharStyles()
 
152
{
 
153
        QValueList<CharStyle> charStyles;
 
154
        if (!doc_)
 
155
                return charStyles; // no doc available
 
156
 
 
157
        const StyleSet<CharStyle> &tmp(doc_->charStyles());
 
158
        for (uint i = 0; i < tmp.count(); ++i)
 
159
                charStyles.append(tmp[i]);
 
160
        return charStyles;
 
161
}
 
162
 
 
163
QString SMParagraphStyle::fromSelection() const
 
164
{
 
165
        QString lsName(QString::null);
 
166
        if (!doc_)
 
167
                return lsName; // no doc available
 
168
 
 
169
        for (uint i = 0; i < doc_->m_Selection->count(); ++i)
 
170
        {
 
171
                // wth is going on here
 
172
                PageItem *item = doc_->m_Selection->itemAt(i);
 
173
 
 
174
                QString tmpName = item->itemText.defaultStyle().parent();
 
175
 
 
176
                if (lsName.isNull() && !tmpName.isEmpty() && tmpName != "")
 
177
                {
 
178
                        lsName = tmpName;
 
179
                }
 
180
                else if (!lsName.isNull() && !tmpName.isEmpty() && tmpName != "" && lsName != tmpName)
 
181
                {
 
182
                        lsName = QString::null;
 
183
                        break;
 
184
                }
 
185
        }
 
186
        return lsName;
 
187
}
 
188
 
 
189
void SMParagraphStyle::toSelection(const QString &styleName) const
 
190
{
 
191
        if (!doc_)
 
192
                return; // nowhere to apply or no doc
 
193
 
 
194
        doc_->itemSelection_SetNamedParagraphStyle(styleName);
 
195
}
 
196
 
 
197
QString SMParagraphStyle::newStyle()
 
198
{
 
199
        if (!doc_)
 
200
                return QString::null;
 
201
 
 
202
        QString s(getUniqueName( tr("New Style")));
 
203
        ParagraphStyle p;
 
204
        p.setName(s);
 
205
        tmpStyles_.create(p);
 
206
        return s;
 
207
}
 
208
 
 
209
QString SMParagraphStyle::newStyle(const QString &fromStyle)
 
210
{
 
211
        Q_ASSERT(tmpStyles_.resolve(fromStyle));
 
212
        if (!tmpStyles_.resolve(fromStyle))
 
213
                return QString::null;
 
214
 
 
215
        QString s(getUniqueName( tr("Clone of %1").arg(fromStyle)));
 
216
        ParagraphStyle p(tmpStyles_[fromStyle]);
 
217
        p.setName(s);
 
218
        p.setShortcut(QString::null); // do not clone the sc
 
219
        tmpStyles_.create(p);
 
220
 
 
221
        return s;
 
222
}
 
223
 
 
224
// helper function to find a unique name to a new style or a clone
 
225
QString SMParagraphStyle::getUniqueName(const QString &name)
 
226
{
 
227
        int id = 0;
 
228
        bool done = false;
 
229
        QString s(name);
 
230
 
 
231
        while (!done)
 
232
        {
 
233
start:
 
234
                ++id;
 
235
                for (uint i = 0; i < tmpStyles_.count(); ++i)
 
236
                {
 
237
                        if (tmpStyles_[i].name() == s)
 
238
                        {
 
239
                                s = tr("%1 (%2)", "This for unique name when creating "
 
240
                                                "a new character style. %1 will be the name "
 
241
                                                                "of the style and %2 will be a number forming "
 
242
                                                                "a style name like: New Style (2)").arg(name).arg(id);
 
243
                                goto start;
 
244
                        }
 
245
                }
 
246
                done = true;
 
247
        }
 
248
 
 
249
        return s;
 
250
}
 
251
 
 
252
void SMParagraphStyle::apply()
 
253
{
 
254
        if (!doc_)
 
255
                return;
 
256
 
 
257
        QMap<QString, QString> replacement;
 
258
        for (uint i = 0; i < deleted_.count(); ++i)
 
259
                replacement[deleted_[i].first] = deleted_[i].second;
 
260
 
 
261
        doc_->redefineStyles(tmpStyles_, false);
 
262
        doc_->replaceStyles(replacement);
 
263
 
 
264
        deleted_.clear(); // deletion done at this point
 
265
 
 
266
        doc_->scMW()->propertiesPalette->paraStyleCombo->updateFormatList();
 
267
        doc_->scMW()->propertiesPalette->charStyleCombo->updateFormatList();
 
268
        doc_->scMW()->view->DrawNew();
 
269
        doc_->changed();
 
270
}
 
271
 
 
272
void SMParagraphStyle::editMode(bool isOn)
 
273
{
 
274
        if (isOn)
 
275
                reloadTmpStyles();
 
276
}
 
277
 
 
278
QString SMParagraphStyle::shortcut(const QString &stylename) const
 
279
{
 
280
        QString s(QString::null);
 
281
 
 
282
        int index = tmpStyles_.find(stylename);
 
283
        if (index > -1)
 
284
                s = tmpStyles_[index].shortcut();
 
285
 
 
286
        return s;
 
287
}
 
288
 
 
289
void SMParagraphStyle::setShortcut(const QString &shortcut)
 
290
{
 
291
        Q_ASSERT(selection_.count() == 1);
 
292
        if (selection_.count() != 1)
 
293
                return;
 
294
 
 
295
        selection_[0]->setShortcut(shortcut);
 
296
 
 
297
        if (!selectionIsDirty_)
 
298
        {
 
299
                selectionIsDirty_ = true;
 
300
                emit selectionDirty();
 
301
        }
 
302
}
 
303
 
 
304
void SMParagraphStyle::deleteStyles(const QValueList<RemoveItem> &removeList)
 
305
{
 
306
        for (uint i = 0; i < removeList.count(); ++i)
 
307
        {
 
308
                for (uint k = 0; k < selection_.count(); ++k)
 
309
                {
 
310
                        if (selection_[k]->name() == removeList[i].first)
 
311
                        {
 
312
                                selection_.erase(selection_.at(k));
 
313
                                break;
 
314
                        }
 
315
                }
 
316
 
 
317
                int index = tmpStyles_.find(removeList[i].first);
 
318
                if (index > -1)
 
319
                        tmpStyles_.remove(index);
 
320
 
 
321
                deleted_.append(removeList[i]);
 
322
        }
 
323
}
 
324
 
 
325
void SMParagraphStyle::nameChanged(const QString &newName)
 
326
{
 
327
        if (selection_.count() != 1)
 
328
                return;
 
329
 
 
330
        QString oldName(selection_[0]->name());
 
331
        ParagraphStyle p(*selection_[0]);
 
332
        p.setName(newName);
 
333
        tmpStyles_.create(p);
 
334
        selection_.clear();
 
335
        selection_.append(&tmpStyles_[tmpStyles_.find(newName)]);
 
336
        for (uint j = 0; j < tmpStyles_.count(); ++j)
 
337
        {
 
338
                int index = tmpStyles_.find(oldName);
 
339
                if (index > -1)
 
340
                {
 
341
                        tmpStyles_.remove(index);
 
342
                        break;
 
343
                }
 
344
        }
 
345
 
 
346
        for (uint j = 0; j < tmpStyles_.count(); ++j)
 
347
        {
 
348
                if (tmpStyles_[j].parent() == oldName)
 
349
                        tmpStyles_[j].setParent(newName);
 
350
        }
 
351
 
 
352
        QValueList<RemoveItem>::iterator it;
 
353
        for (it = deleted_.begin(); it != deleted_.end(); ++it)
 
354
        {
 
355
                if ((*it).second == oldName)
 
356
                {
 
357
                        oldName = (*it).first;
 
358
                        deleted_.remove(it);
 
359
                        break;
 
360
                }
 
361
        }
 
362
 
 
363
        deleted_.append(RemoveItem(oldName, newName));
 
364
 
 
365
        if (!selectionIsDirty_)
 
366
        {
 
367
                selectionIsDirty_ = true;
 
368
                emit selectionDirty();
 
369
        }
 
370
}
 
371
 
 
372
void SMParagraphStyle::languageChange()
 
373
{
 
374
        if (pwidget_)
 
375
        {
 
376
                pwidget_->languageChange();
 
377
                pwidget_->cpage->languageChange();
 
378
        }
 
379
}
 
380
 
 
381
void SMParagraphStyle::unitChange()
 
382
{
 
383
        double oldRatio = unitRatio_;
 
384
        unitRatio_ = doc_->unitRatio();
 
385
        pwidget_->unitChange(oldRatio, unitRatio_, doc_->unitIndex());
 
386
}
 
387
 
 
388
void SMParagraphStyle::reloadTmpStyles()
 
389
{
 
390
        if (!doc_)
 
391
                return;
 
392
 
 
393
        selection_.clear();
 
394
        tmpStyles_.clear();
 
395
        deleted_.clear();
 
396
        tmpStyles_.redefine(doc_->paragraphStyles(), true);
 
397
        Q_ASSERT(tmpStyles_.count() > 0);
 
398
        tmpStyles_[0].charStyle().setContext(cstyles_);
 
399
}
 
400
 
 
401
void SMParagraphStyle::setupConnections()
 
402
{
 
403
        if (!pwidget_)
 
404
                return;
 
405
 
 
406
        // paragraph attributes
 
407
        connect(pwidget_->lineSpacingMode_, SIGNAL(activated(int)), this, SLOT(slotLineSpacingMode(int)));
 
408
        connect(pwidget_->lineSpacing_, SIGNAL(valueChanged(int)), this, SLOT(slotLineSpacing()));
 
409
        connect(pwidget_->spaceAbove_, SIGNAL(valueChanged(int)), this, SLOT(slotSpaceAbove()));
 
410
        connect(pwidget_->spaceBelow_, SIGNAL(valueChanged(int)), this, SLOT(slotSpaceBelow()));
 
411
        connect(pwidget_->alignement_->TextL, SIGNAL(clicked()), this, SLOT(slotAlignment()));
 
412
        connect(pwidget_->alignement_->TextR, SIGNAL(clicked()), this, SLOT(slotAlignment()));
 
413
        connect(pwidget_->alignement_->TextC, SIGNAL(clicked()), this, SLOT(slotAlignment()));
 
414
        connect(pwidget_->alignement_->TextB, SIGNAL(clicked()), this, SLOT(slotAlignment()));
 
415
        connect(pwidget_->alignement_->TextF, SIGNAL(clicked()), this, SLOT(slotAlignment()));
 
416
        connect(pwidget_->alignement_->parentButton, SIGNAL(clicked()), this, SLOT(slotAlignment()));
 
417
 
 
418
        connect(pwidget_, SIGNAL(useParentDropCap()), this, SLOT(slotParentDropCap()));
 
419
        connect(pwidget_->dropCapsBox, SIGNAL(toggled(bool)), this, SLOT(slotDropCap(bool)));
 
420
        connect(pwidget_->dropCapLines_, SIGNAL(valueChanged(int)), this, SLOT(slotDropCapLines(int)));
 
421
        connect(pwidget_->dropCapOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotDropCapOffset()));
 
422
 
 
423
        connect(pwidget_->tabList_, SIGNAL(tabsChanged()), this, SLOT(slotTabRuler()));
 
424
        connect(pwidget_->tabList_, SIGNAL(mouseReleased()), this, SLOT(slotTabRuler()));
 
425
        connect(pwidget_->tabList_->left_, SIGNAL(valueChanged(int)), this, SLOT(slotLeftIndent()));
 
426
        connect(pwidget_->tabList_->right_, SIGNAL(valueChanged(int)), this, SLOT(slotRightIndent()));
 
427
        connect(pwidget_->tabList_->first_, SIGNAL(valueChanged(int)), this, SLOT(slotFirstLine()));
 
428
 
 
429
        connect(pwidget_->parentCombo, SIGNAL(activated(const QString&)),
 
430
                        this, SLOT(slotParentChanged(const QString&)));
 
431
 
 
432
        // character attributes
 
433
        connect(pwidget_->cpage->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
 
434
        connect(pwidget_->cpage->effects_, SIGNAL(State(int)), this, SLOT(slotEffects(int)));
 
435
        connect(pwidget_->cpage->effects_->ShadowVal->Xoffset, SIGNAL(valueChanged(int)),
 
436
                        this, SLOT(slotEffectProperties()));
 
437
        connect(pwidget_->cpage->effects_->ShadowVal->Yoffset, SIGNAL(valueChanged(int)),
 
438
                        this, SLOT(slotEffectProperties()));
 
439
        connect(pwidget_->cpage->effects_->OutlineVal->LWidth, SIGNAL(valueChanged(int)),
 
440
                        this, SLOT(slotEffectProperties()));
 
441
        connect(pwidget_->cpage->effects_->UnderlineVal->LPos, SIGNAL(valueChanged(int)),
 
442
                        this, SLOT(slotEffectProperties()));
 
443
        connect(pwidget_->cpage->effects_->UnderlineVal->LWidth, SIGNAL(valueChanged(int)),
 
444
                        this, SLOT(slotEffectProperties()));
 
445
        connect(pwidget_->cpage->effects_->StrikeVal->LPos, SIGNAL(valueChanged(int)),
 
446
                        this, SLOT(slotEffectProperties()));
 
447
        connect(pwidget_->cpage->effects_->StrikeVal->LWidth, SIGNAL(valueChanged(int)),
 
448
                        this, SLOT(slotEffectProperties()));
 
449
        connect(pwidget_->cpage->fillColor_, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
 
450
        connect(pwidget_->cpage->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
 
451
        connect(pwidget_->cpage->strokeColor_, SIGNAL(activated(const QString&)), this, SLOT(slotStrokeColor()));
 
452
        connect(pwidget_->cpage->strokeShade_, SIGNAL(clicked()), this, SLOT(slotStrokeShade()));
 
453
        connect(pwidget_->cpage->language_, SIGNAL(activated(int)), this, SLOT(slotLanguage()));
 
454
        connect(pwidget_->cpage->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(slotFontSize()));
 
455
        connect(pwidget_->cpage->fontHScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleH()));
 
456
        connect(pwidget_->cpage->fontVScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleV()));
 
457
        connect(pwidget_->cpage->tracking_, SIGNAL(valueChanged(int)), this, SLOT(slotTracking()));
 
458
        connect(pwidget_->cpage->baselineOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotBaselineOffset()));
 
459
        connect(pwidget_->cpage->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
 
460
        connect(pwidget_->cpage->parentCombo, SIGNAL(activated(const QString&)),
 
461
                        this, SLOT(slotCharParentChanged(const QString&)));
 
462
}
 
463
 
 
464
void SMParagraphStyle::removeConnections()
 
465
{
 
466
        if (!pwidget_)
 
467
                return;
 
468
 
 
469
        disconnect(pwidget_->lineSpacingMode_, SIGNAL(activated(int)), this, SLOT(slotLineSpacingMode(int)));
 
470
        disconnect(pwidget_->lineSpacing_, SIGNAL(valueChanged(int)), this, SLOT(slotLineSpacing()));
 
471
        disconnect(pwidget_->spaceAbove_, SIGNAL(valueChanged(int)), this, SLOT(slotSpaceAbove()));
 
472
        disconnect(pwidget_->spaceBelow_, SIGNAL(valueChanged(int)), this, SLOT(slotSpaceBelow()));
 
473
        disconnect(pwidget_->alignement_->TextL, SIGNAL(clicked()), this, SLOT(slotAlignment()));
 
474
        disconnect(pwidget_->alignement_->TextR, SIGNAL(clicked()), this, SLOT(slotAlignment()));
 
475
        disconnect(pwidget_->alignement_->TextC, SIGNAL(clicked()), this, SLOT(slotAlignment()));
 
476
        disconnect(pwidget_->alignement_->TextB, SIGNAL(clicked()), this, SLOT(slotAlignment()));
 
477
        disconnect(pwidget_->alignement_->TextF, SIGNAL(clicked()), this, SLOT(slotAlignment()));
 
478
        disconnect(pwidget_->alignement_->parentButton, SIGNAL(clicked()), this, SLOT(slotAlignment()));
 
479
 
 
480
        disconnect(pwidget_, SIGNAL(useParentDropCap()), this, SLOT(slotParentDropCap()));
 
481
        disconnect(pwidget_->dropCapsBox, SIGNAL(toggled(bool)), this, SLOT(slotDropCap(bool)));
 
482
        disconnect(pwidget_->dropCapLines_, SIGNAL(valueChanged(int)), this, SLOT(slotDropCapLines(int)));
 
483
        disconnect(pwidget_->dropCapOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotDropCapOffset()));
 
484
 
 
485
        disconnect(pwidget_->parentCombo, SIGNAL(activated(const QString&)),
 
486
                        this, SLOT(slotParentChanged(const QString&)));
 
487
 
 
488
        disconnect(pwidget_->tabList_, SIGNAL(tabsChanged()), this, SLOT(slotTabRuler()));
 
489
        disconnect(pwidget_->tabList_->left_, SIGNAL(valueChanged(int)), this, SLOT(slotLeftIndent()));
 
490
        disconnect(pwidget_->tabList_->right_, SIGNAL(valueChanged(int)), this, SLOT(slotRightIndent()));
 
491
        disconnect(pwidget_->tabList_->first_, SIGNAL(valueChanged(int)), this, SLOT(slotFirstLine()));
 
492
 
 
493
        disconnect(pwidget_->cpage->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
 
494
        disconnect(pwidget_->cpage->effects_, SIGNAL(State(int)), this, SLOT(slotEffects(int)));
 
495
        disconnect(pwidget_->cpage->effects_->ShadowVal->Xoffset, SIGNAL(valueChanged(int)),
 
496
                        this, SLOT(slotEffectProperties()));
 
497
        disconnect(pwidget_->cpage->effects_->ShadowVal->Yoffset, SIGNAL(valueChanged(int)),
 
498
                        this, SLOT(slotEffectProperties()));
 
499
        disconnect(pwidget_->cpage->effects_->OutlineVal->LWidth, SIGNAL(valueChanged(int)),
 
500
                        this, SLOT(slotEffectProperties()));
 
501
        disconnect(pwidget_->cpage->effects_->UnderlineVal->LPos, SIGNAL(valueChanged(int)),
 
502
                        this, SLOT(slotEffectProperties()));
 
503
        disconnect(pwidget_->cpage->effects_->UnderlineVal->LWidth, SIGNAL(valueChanged(int)),
 
504
                        this, SLOT(slotEffectProperties()));
 
505
        disconnect(pwidget_->cpage->effects_->StrikeVal->LPos, SIGNAL(valueChanged(int)),
 
506
                        this, SLOT(slotEffectProperties()));
 
507
        disconnect(pwidget_->cpage->effects_->StrikeVal->LWidth, SIGNAL(valueChanged(int)),
 
508
                        this, SLOT(slotEffectProperties()));
 
509
        disconnect(pwidget_->cpage->fillColor_, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
 
510
        disconnect(pwidget_->cpage->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
 
511
        disconnect(pwidget_->cpage->strokeColor_, SIGNAL(activated(const QString&)), this, SLOT(slotStrokeColor()));
 
512
        disconnect(pwidget_->cpage->strokeShade_, SIGNAL(clicked()), this, SLOT(slotStrokeShade()));
 
513
        disconnect(pwidget_->cpage->language_, SIGNAL(activated(int)), this, SLOT(slotLanguage()));
 
514
        disconnect(pwidget_->cpage->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(slotFontSize()));
 
515
        disconnect(pwidget_->cpage->fontHScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleH()));
 
516
        disconnect(pwidget_->cpage->fontVScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleV()));
 
517
        disconnect(pwidget_->cpage->tracking_, SIGNAL(valueChanged(int)), this, SLOT(slotTracking()));
 
518
        disconnect(pwidget_->cpage->baselineOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotBaselineOffset()));
 
519
        disconnect(pwidget_->cpage->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
 
520
        disconnect(pwidget_->cpage->parentCombo, SIGNAL(activated(const QString&)),
 
521
                        this, SLOT(slotCharParentChanged(const QString&)));
 
522
}
 
523
 
 
524
void SMParagraphStyle::slotLineSpacingMode(int mode)
 
525
{
 
526
        ParagraphStyle::LineSpacingMode lsm = static_cast<ParagraphStyle::LineSpacingMode>(mode);
 
527
 
 
528
        if (pwidget_->lineSpacingMode_->useParentValue())
 
529
                for (uint i = 0; i < selection_.count(); ++i)
 
530
                        selection_[i]->resetLineSpacingMode();
 
531
        else
 
532
                for (uint i = 0; i < selection_.count(); ++i)
 
533
                        selection_[i]->setLineSpacingMode(lsm);
 
534
 
 
535
        if (!selectionIsDirty_)
 
536
        {
 
537
                selectionIsDirty_ = true;
 
538
                emit selectionDirty();
 
539
        }
 
540
}
 
541
 
 
542
void SMParagraphStyle::slotLineSpacing()
 
543
{
 
544
        if (pwidget_->lineSpacing_->useParentValue())
 
545
                for (uint i = 0; i < selection_.count(); ++i)
 
546
                        selection_[i]->resetLineSpacing();
 
547
        else 
 
548
        {
 
549
                double a, b, value;
 
550
                int c;
 
551
 
 
552
                pwidget_->lineSpacing_->getValues(&a, &b, &c, &value);
 
553
                for (uint i = 0; i < selection_.count(); ++i)
 
554
                        selection_[i]->setLineSpacing(value);
 
555
        }
 
556
        
 
557
        if (!selectionIsDirty_)
 
558
        {
 
559
                selectionIsDirty_ = true;
 
560
                emit selectionDirty();
 
561
        }
 
562
}
 
563
 
 
564
void SMParagraphStyle::slotSpaceAbove()
 
565
{
 
566
        if (pwidget_->spaceAbove_->useParentValue())
 
567
                for (uint i = 0; i < selection_.count(); ++i)
 
568
                        selection_[i]->resetGapBefore();
 
569
        else 
 
570
        {
 
571
                double a, b, value;
 
572
                int c;
 
573
 
 
574
                pwidget_->spaceAbove_->getValues(&a, &b, &c, &value);
 
575
                value = value / unitRatio_;
 
576
                for (uint i = 0; i < selection_.count(); ++i)
 
577
                        selection_[i]->setGapBefore(value);
 
578
        }
 
579
        
 
580
        if (!selectionIsDirty_)
 
581
        {
 
582
                selectionIsDirty_ = true;
 
583
                emit selectionDirty();
 
584
        }
 
585
}
 
586
 
 
587
void SMParagraphStyle::slotSpaceBelow()
 
588
{
 
589
        if (pwidget_->spaceBelow_->useParentValue())
 
590
                for (uint i = 0; i < selection_.count(); ++i)
 
591
                        selection_[i]->resetGapAfter();
 
592
        else 
 
593
        {
 
594
                double a, b, value;
 
595
                int c;
 
596
                
 
597
                pwidget_->spaceBelow_->getValues(&a, &b, &c, &value);
 
598
                value = value / unitRatio_;
 
599
                for (uint i = 0; i < selection_.count(); ++i)
 
600
                        selection_[i]->setGapAfter(value);
 
601
        }
 
602
        
 
603
        if (!selectionIsDirty_)
 
604
        {
 
605
                selectionIsDirty_ = true;
 
606
                emit selectionDirty();
 
607
        }
 
608
}
 
609
 
 
610
void SMParagraphStyle::slotAlignment()
 
611
{
 
612
        ParagraphStyle::AlignmentType style = static_cast<ParagraphStyle::AlignmentType>(pwidget_->alignement_->getStyle());
 
613
        if (pwidget_->alignement_->useParentValue())
 
614
                for (uint i = 0; i < selection_.count(); ++i)
 
615
                        selection_[i]->resetAlignment();
 
616
        else 
 
617
                for (uint i = 0; i < selection_.count(); ++i)
 
618
                        selection_[i]->setAlignment(style);
 
619
 
 
620
        if (!selectionIsDirty_)
 
621
        {
 
622
                selectionIsDirty_ = true;
 
623
                emit selectionDirty();
 
624
        }
 
625
}
 
626
 
 
627
void SMParagraphStyle::slotDropCap(bool isOn)
 
628
{
 
629
        for (uint i = 0; i < selection_.count(); ++i)
 
630
                selection_[i]->setHasDropCap(isOn);
 
631
 
 
632
        if (!selectionIsDirty_)
 
633
        {
 
634
                selectionIsDirty_ = true;
 
635
                emit selectionDirty();
 
636
        }
 
637
}
 
638
 
 
639
void SMParagraphStyle::slotParentDropCap()
 
640
{
 
641
        for (uint i = 0; i < selection_.count(); ++i)
 
642
                selection_[i]->resetHasDropCap();
 
643
 
 
644
        if (!selectionIsDirty_)
 
645
        {
 
646
                selectionIsDirty_ = true;
 
647
                emit selectionDirty();
 
648
        }
 
649
}
 
650
 
 
651
void SMParagraphStyle::slotDropCapLines(int lines)
 
652
{
 
653
        if (pwidget_->dropCapLines_->useParentValue())
 
654
                for (uint i = 0; i < selection_.count(); ++i)
 
655
                        selection_[i]->resetDropCapLines();
 
656
        else            
 
657
                for (uint i = 0; i < selection_.count(); ++i)
 
658
                        selection_[i]->setDropCapLines(lines);
 
659
 
 
660
        if (!selectionIsDirty_)
 
661
        {
 
662
                selectionIsDirty_ = true;
 
663
                emit selectionDirty();
 
664
        }
 
665
}
 
666
 
 
667
void SMParagraphStyle::slotDropCapOffset()
 
668
{
 
669
        if (pwidget_->dropCapOffset_->useParentValue())
 
670
                for (uint i = 0; i < selection_.count(); ++i)
 
671
                        selection_[i]->resetDropCapOffset();
 
672
        else 
 
673
        {
 
674
                double a, b, value;
 
675
                int c;
 
676
 
 
677
                pwidget_->dropCapOffset_->getValues(&a, &b, &c, &value);
 
678
                value = value / unitRatio_;
 
679
                for (uint i = 0; i < selection_.count(); ++i)
 
680
                        selection_[i]->setDropCapOffset(value);
 
681
        }
 
682
        
 
683
        if (!selectionIsDirty_)
 
684
        {
 
685
                selectionIsDirty_ = true;
 
686
                emit selectionDirty();
 
687
        }
 
688
}
 
689
 
 
690
void SMParagraphStyle::slotTabRuler()
 
691
{
 
692
        if (pwidget_->tabList_->useParentTabs())
 
693
        {
 
694
                for (uint i = 0; i < selection_.count(); ++i)
 
695
                        selection_[i]->resetTabValues();
 
696
        }
 
697
        else
 
698
        {
 
699
                QValueList<ParagraphStyle::TabRecord> newTabs = pwidget_->tabList_->getTabVals();
 
700
                for (uint i = 0; i < selection_.count(); ++i)
 
701
                        selection_[i]->setTabValues(newTabs);
 
702
        }
 
703
 
 
704
        if (!selectionIsDirty_)
 
705
        {
 
706
                selectionIsDirty_ = true;
 
707
                emit selectionDirty();
 
708
        }
 
709
}
 
710
 
 
711
void SMParagraphStyle::slotLeftIndent()
 
712
{
 
713
        if (pwidget_->tabList_->useParentLeftIndent())
 
714
                for (uint i = 0; i < selection_.count(); ++i)
 
715
                        selection_[i]->resetLeftMargin();
 
716
        else 
 
717
        {
 
718
                double a, b, value;
 
719
                int c;
 
720
 
 
721
                pwidget_->tabList_->left_->getValues(&a, &b, &c, &value);
 
722
                value = value / unitRatio_;
 
723
                for (uint i = 0; i < selection_.count(); ++i)
 
724
                        selection_[i]->setLeftMargin(value);
 
725
        }
 
726
        
 
727
        if (!selectionIsDirty_)
 
728
        {
 
729
                selectionIsDirty_ = true;
 
730
                emit selectionDirty();
 
731
        }
 
732
}
 
733
 
 
734
void SMParagraphStyle::slotRightIndent()
 
735
{
 
736
        if (pwidget_->tabList_->useParentRightIndent())
 
737
                for (uint i = 0; i < selection_.count(); ++i)
 
738
                        selection_[i]->resetRightMargin();
 
739
        else 
 
740
        {
 
741
                double a, b, value;
 
742
                int c;
 
743
 
 
744
                pwidget_->tabList_->right_->getValues(&a, &b, &c, &value);
 
745
                value = value / unitRatio_;
 
746
                for (uint i = 0; i < selection_.count(); ++i)
 
747
                        selection_[i]->setRightMargin(value);
 
748
        }
 
749
        
 
750
        if (!selectionIsDirty_)
 
751
        {
 
752
                selectionIsDirty_ = true;
 
753
                emit selectionDirty();
 
754
        }
 
755
}
 
756
 
 
757
void SMParagraphStyle::slotFirstLine()
 
758
{
 
759
        if (pwidget_->tabList_->useParentFirstLine())
 
760
                for (uint i = 0; i < selection_.count(); ++i)
 
761
                        selection_[i]->resetFirstIndent();
 
762
        else 
 
763
        {
 
764
                double a, b, value;
 
765
                int c;
 
766
                
 
767
                pwidget_->tabList_->first_->getValues(&a, &b, &c, &value);
 
768
                value = value / unitRatio_;
 
769
                for (uint i = 0; i < selection_.count(); ++i)
 
770
                        selection_[i]->setFirstIndent(value);
 
771
        }
 
772
        
 
773
        if (!selectionIsDirty_)
 
774
        {
 
775
                selectionIsDirty_ = true;
 
776
                emit selectionDirty();
 
777
        }
 
778
}
 
779
 
 
780
void SMParagraphStyle::slotFontSize()
 
781
{
 
782
        if (pwidget_->cpage->fontSize_->useParentValue())
 
783
                for (uint i = 0; i < selection_.count(); ++i)
 
784
                        selection_[i]->charStyle().resetFontSize();
 
785
        else
 
786
        {
 
787
                double a, b, value;
 
788
                int c;
 
789
                
 
790
                pwidget_->cpage->fontSize_->getValues(&a, &b, &c, &value);
 
791
                value = value * 10;
 
792
                for (uint i = 0; i < selection_.count(); ++i)
 
793
                        selection_[i]->charStyle().setFontSize(qRound(value));
 
794
        }
 
795
 
 
796
 
 
797
        if (!selectionIsDirty_)
 
798
        {
 
799
                selectionIsDirty_ = true;
 
800
                emit selectionDirty();
 
801
        }
 
802
}
 
803
 
 
804
void SMParagraphStyle::slotEffects(int e)
 
805
{
 
806
        StyleFlag s = ScStyle_None;
 
807
        if (pwidget_->cpage->effects_->useParentValue())
 
808
        {
 
809
                for (uint i = 0; i < selection_.count(); ++i)
 
810
                {
 
811
                        selection_[i]->charStyle().resetFeatures();
 
812
                        selection_[i]->charStyle().resetShadowXOffset();
 
813
                        selection_[i]->charStyle().resetShadowYOffset();
 
814
                        selection_[i]->charStyle().resetOutlineWidth();
 
815
                        selection_[i]->charStyle().resetUnderlineOffset();
 
816
                        selection_[i]->charStyle().resetUnderlineWidth();
 
817
                        selection_[i]->charStyle().resetStrikethruOffset();
 
818
                        selection_[i]->charStyle().resetStrikethruWidth();
 
819
                }
 
820
        }
 
821
        else
 
822
        {
 
823
                double a, b, sxo, syo, olw, ulp, ulw, slp, slw;
 
824
                int c;
 
825
                
 
826
                s = static_cast<StyleFlag>(e);
 
827
                pwidget_->cpage->effects_->ShadowVal->Xoffset->getValues(&a, &b, &c, &sxo);
 
828
                sxo *= 10;
 
829
                pwidget_->cpage->effects_->ShadowVal->Yoffset->getValues(&a, &b, &c, &syo);
 
830
                syo *= 10;
 
831
 
 
832
                pwidget_->cpage->effects_->OutlineVal->LWidth->getValues(&a, &b, &c, &olw);
 
833
                olw *= 10;
 
834
 
 
835
                pwidget_->cpage->effects_->UnderlineVal->LPos->getValues(&a, &b, &c, &ulp);
 
836
                ulp *= 10;
 
837
                pwidget_->cpage->effects_->UnderlineVal->LWidth->getValues(&a, &b, &c, &ulw);
 
838
                ulw *= 10;
 
839
 
 
840
                pwidget_->cpage->effects_->StrikeVal->LPos->getValues(&a, &b, &c, &slp);
 
841
                slp *= 10;
 
842
                pwidget_->cpage->effects_->StrikeVal->LWidth->getValues(&a, &b, &c, &slw);
 
843
                slw *= 10;
 
844
 
 
845
                for (uint i = 0; i < selection_.count(); ++i)
 
846
                {
 
847
                        selection_[i]->charStyle().setFeatures(s.featureList());
 
848
                        selection_[i]->charStyle().setShadowXOffset(qRound(sxo));
 
849
                        selection_[i]->charStyle().setShadowYOffset(qRound(syo));
 
850
                        selection_[i]->charStyle().setOutlineWidth(qRound(olw));
 
851
                        selection_[i]->charStyle().setUnderlineOffset(qRound(ulp));
 
852
                        selection_[i]->charStyle().setUnderlineWidth(qRound(ulw));
 
853
                        selection_[i]->charStyle().setStrikethruOffset(qRound(slp));
 
854
                        selection_[i]->charStyle().setStrikethruWidth(qRound(slw));
 
855
                }
 
856
        }
 
857
 
 
858
 
 
859
        if (!selectionIsDirty_)
 
860
        {
 
861
                selectionIsDirty_ = true;
 
862
                emit selectionDirty();
 
863
        }
 
864
}
 
865
 
 
866
void SMParagraphStyle::slotEffectProperties()
 
867
{
 
868
        double a, b, sxo, syo, olw, ulp, ulw, slp, slw;
 
869
        int c;
 
870
 
 
871
        pwidget_->cpage->effects_->ShadowVal->Xoffset->getValues(&a, &b, &c, &sxo);
 
872
        sxo *= 10;
 
873
        pwidget_->cpage->effects_->ShadowVal->Yoffset->getValues(&a, &b, &c, &syo);
 
874
        syo *= 10;
 
875
 
 
876
        pwidget_->cpage->effects_->OutlineVal->LWidth->getValues(&a, &b, &c, &olw);
 
877
        olw *= 10;
 
878
 
 
879
        pwidget_->cpage->effects_->UnderlineVal->LPos->getValues(&a, &b, &c, &ulp);
 
880
        ulp *= 10;
 
881
        pwidget_->cpage->effects_->UnderlineVal->LWidth->getValues(&a, &b, &c, &ulw);
 
882
        ulw *= 10;
 
883
 
 
884
        pwidget_->cpage->effects_->StrikeVal->LPos->getValues(&a, &b, &c, &slp);
 
885
        slp *= 10;
 
886
        pwidget_->cpage->effects_->StrikeVal->LWidth->getValues(&a, &b, &c, &slw);
 
887
        slw *= 10;
 
888
        
 
889
        for (uint i = 0; i < selection_.count(); ++i)
 
890
        {
 
891
                selection_[i]->charStyle().setShadowXOffset(qRound(sxo));
 
892
                selection_[i]->charStyle().setShadowYOffset(qRound(syo));
 
893
                selection_[i]->charStyle().setOutlineWidth(qRound(olw));
 
894
                selection_[i]->charStyle().setUnderlineOffset(qRound(ulp));
 
895
                selection_[i]->charStyle().setUnderlineWidth(qRound(ulw));
 
896
                selection_[i]->charStyle().setStrikethruOffset(qRound(slp));
 
897
                selection_[i]->charStyle().setStrikethruWidth(qRound(slw));
 
898
        }
 
899
 
 
900
        if (!selectionIsDirty_)
 
901
        {
 
902
                selectionIsDirty_ = true;
 
903
                emit selectionDirty();
 
904
        }
 
905
}
 
906
 
 
907
void SMParagraphStyle::slotFillColor()
 
908
{
 
909
        if (pwidget_->cpage->fillColor_->useParentValue())
 
910
                for (uint i = 0; i < selection_.count(); ++i)
 
911
                        selection_[i]->charStyle().resetFillColor();
 
912
        else {
 
913
                QString c( pwidget_->cpage->fillColor_->currentText());
 
914
                for (uint i = 0; i < selection_.count(); ++i)
 
915
                        selection_[i]->charStyle().setFillColor(c);
 
916
        }
 
917
        
 
918
        if (!selectionIsDirty_)
 
919
        {
 
920
                selectionIsDirty_ = true;
 
921
                emit selectionDirty();
 
922
        }
 
923
}
 
924
 
 
925
void SMParagraphStyle::slotFillShade()
 
926
{
 
927
        if (pwidget_->cpage->fillShade_->useParentValue())
 
928
                for (uint i = 0; i < selection_.count(); ++i)
 
929
                        selection_[i]->charStyle().resetFillShade();
 
930
        else {
 
931
                int fs = pwidget_->cpage->fillShade_->getValue();
 
932
 
 
933
                for (uint i = 0; i < selection_.count(); ++i)
 
934
                        selection_[i]->charStyle().setFillShade(fs);
 
935
        }
 
936
        
 
937
        if (!selectionIsDirty_)
 
938
        {
 
939
                selectionIsDirty_ = true;
 
940
                emit selectionDirty();
 
941
        }
 
942
}
 
943
 
 
944
void SMParagraphStyle::slotStrokeColor()
 
945
{
 
946
        if (pwidget_->cpage->strokeColor_->useParentValue())
 
947
                for (uint i = 0; i < selection_.count(); ++i)
 
948
                        selection_[i]->charStyle().resetStrokeColor();
 
949
        else {
 
950
                QString c(pwidget_->cpage->strokeColor_->currentText());
 
951
 
 
952
                for (uint i = 0; i < selection_.count(); ++i)
 
953
                        selection_[i]->charStyle().setStrokeColor(c);
 
954
        }
 
955
        
 
956
        if (!selectionIsDirty_)
 
957
        {
 
958
                selectionIsDirty_ = true;
 
959
                emit selectionDirty();
 
960
        }
 
961
}
 
962
 
 
963
void SMParagraphStyle::slotStrokeShade()
 
964
{
 
965
        if (pwidget_->cpage->strokeShade_->useParentValue())
 
966
                for (uint i = 0; i < selection_.count(); ++i)
 
967
                        selection_[i]->charStyle().resetStrokeShade();
 
968
        else 
 
969
        {
 
970
                int ss = pwidget_->cpage->strokeShade_->getValue();
 
971
 
 
972
                for (uint i = 0; i < selection_.count(); ++i)
 
973
                        selection_[i]->charStyle().setStrokeShade(ss);
 
974
        }
 
975
        
 
976
        if (!selectionIsDirty_)
 
977
        {
 
978
                selectionIsDirty_ = true;
 
979
                emit selectionDirty();
 
980
        }
 
981
}
 
982
 
 
983
void SMParagraphStyle::slotLanguage()
 
984
{
 
985
        QMap<QString,QString>::Iterator it;
 
986
        QString language = doc_->paragraphStyle("").charStyle().language();
 
987
 
 
988
        if (pwidget_->cpage->language_->useParentValue())
 
989
                for (uint i = 0; i < selection_.count(); ++i)
 
990
                        selection_[i]->charStyle().resetLanguage();
 
991
        else
 
992
        {
 
993
                for (it = doc_->scMW()->LangTransl.begin(); it != doc_->scMW()->LangTransl.end(); ++it)
 
994
                {
 
995
                        if (it.data() == pwidget_->cpage->language_->currentText())
 
996
                        {
 
997
                                language = it.key();
 
998
                                break;
 
999
                        }
 
1000
                }
 
1001
                for (uint i = 0; i < selection_.count(); ++i)
 
1002
                        selection_[i]->charStyle().setLanguage(language);
 
1003
        }
 
1004
 
 
1005
        if (!selectionIsDirty_)
 
1006
        {
 
1007
                selectionIsDirty_ = true;
 
1008
                emit selectionDirty();
 
1009
        }
 
1010
}
 
1011
 
 
1012
void SMParagraphStyle::slotScaleH()
 
1013
{
 
1014
        if (pwidget_->cpage->fontHScale_->useParentValue())
 
1015
                for (uint i = 0; i < selection_.count(); ++i)
 
1016
                        selection_[i]->charStyle().resetScaleH();
 
1017
        else
 
1018
        {
 
1019
                double a, b, value;
 
1020
                int c;
 
1021
                pwidget_->cpage->fontHScale_->getValues(&a, &b, &c, &value);
 
1022
                value = value * 10;
 
1023
                for (uint i = 0; i < selection_.count(); ++i)
 
1024
                        selection_[i]->charStyle().setScaleH(qRound(value));
 
1025
        }
 
1026
 
 
1027
        if (!selectionIsDirty_)
 
1028
        {
 
1029
                selectionIsDirty_ = true;
 
1030
                emit selectionDirty();
 
1031
        }
 
1032
}
 
1033
 
 
1034
void SMParagraphStyle::slotScaleV()
 
1035
{
 
1036
        if (pwidget_->cpage->fontVScale_->useParentValue())
 
1037
                for (uint i = 0; i < selection_.count(); ++i)
 
1038
                        selection_[i]->charStyle().resetScaleV();
 
1039
        else
 
1040
        {
 
1041
                double a, b, value;
 
1042
                int c;
 
1043
                pwidget_->cpage->fontVScale_->getValues(&a, &b, &c, &value);
 
1044
                value = value * 10;
 
1045
                for (uint i = 0; i < selection_.count(); ++i)
 
1046
                        selection_[i]->charStyle().setScaleV(qRound(value));
 
1047
        }
 
1048
 
 
1049
        if (!selectionIsDirty_)
 
1050
        {
 
1051
                selectionIsDirty_ = true;
 
1052
                emit selectionDirty();
 
1053
        }
 
1054
}
 
1055
 
 
1056
void SMParagraphStyle::slotTracking()
 
1057
{
 
1058
        if (pwidget_->cpage->tracking_->useParentValue())
 
1059
                for (uint i = 0; i < selection_.count(); ++i)
 
1060
                        selection_[i]->charStyle().resetTracking();
 
1061
        else
 
1062
        {
 
1063
                double a, b, value;
 
1064
                int c;
 
1065
                pwidget_->cpage->tracking_->getValues(&a, &b, &c, &value);
 
1066
                value = value * 10;
 
1067
                for (uint i = 0; i < selection_.count(); ++i)
 
1068
                        selection_[i]->charStyle().setTracking(qRound(value));
 
1069
        }
 
1070
 
 
1071
        if (!selectionIsDirty_)
 
1072
        {
 
1073
                selectionIsDirty_ = true;
 
1074
                emit selectionDirty();
 
1075
        }
 
1076
}
 
1077
 
 
1078
void SMParagraphStyle::slotBaselineOffset()
 
1079
{
 
1080
        if (pwidget_->cpage->baselineOffset_->useParentValue())
 
1081
                for (uint i = 0; i < selection_.count(); ++i)
 
1082
                        selection_[i]->charStyle().resetBaselineOffset();
 
1083
        else
 
1084
        {
 
1085
                double a, b, value;
 
1086
                int c;  
 
1087
                pwidget_->cpage->baselineOffset_->getValues(&a, &b, &c, &value);
 
1088
                value = value * 10;
 
1089
                for (uint i = 0; i < selection_.count(); ++i)
 
1090
                        selection_[i]->charStyle().setBaselineOffset(qRound(value));
 
1091
        }
 
1092
 
 
1093
        if (!selectionIsDirty_)
 
1094
        {
 
1095
                selectionIsDirty_ = true;
 
1096
                emit selectionDirty();
 
1097
        }
 
1098
}
 
1099
 
 
1100
void SMParagraphStyle::slotFont(QString s)
 
1101
{
 
1102
        if (pwidget_->cpage->fontFace_->useParentFont())
 
1103
                for (uint i = 0; i < selection_.count(); ++i)
 
1104
                        selection_[i]->charStyle().resetFont();
 
1105
        else {
 
1106
                ScFace sf = PrefsManager::instance()->appPrefs.AvailFonts[s];
 
1107
                
 
1108
                for (uint i = 0; i < selection_.count(); ++i)
 
1109
                        selection_[i]->charStyle().setFont(sf);
 
1110
        }
 
1111
        
 
1112
        if (!selectionIsDirty_)
 
1113
        {
 
1114
                selectionIsDirty_ = true;
 
1115
                emit selectionDirty();
 
1116
        }
 
1117
}
 
1118
 
 
1119
void SMParagraphStyle::slotParentChanged(const QString &parent)
 
1120
{
 
1121
        Q_ASSERT(!parent.isNull());
 
1122
 
 
1123
        QStringList sel;
 
1124
 
 
1125
        for (uint i = 0; i < selection_.count(); ++i)
 
1126
        {
 
1127
//              const ParagraphStyle *style = & (doc_->paragraphStyle(parent));
 
1128
//              if (style)
 
1129
                {
 
1130
                        selection_[i]->erase(); // reset everything to NOVALUE
 
1131
                        selection_[i]->setParent(parent);
 
1132
                        selection_[i]->charStyle().setParent("");
 
1133
                        sel << selection_[i]->name();
 
1134
                }
 
1135
        }
 
1136
 
 
1137
        selected(sel);
 
1138
 
 
1139
        if (!selectionIsDirty_)
 
1140
        {
 
1141
                selectionIsDirty_ = true;
 
1142
                emit selectionDirty();
 
1143
        }
 
1144
}
 
1145
 
 
1146
void SMParagraphStyle::slotCharParentChanged(const QString &parent)
 
1147
{
 
1148
        Q_ASSERT(parent != QString::null);
 
1149
 
 
1150
        QStringList sel;
 
1151
 
 
1152
        for (uint i = 0; i < selection_.count(); ++i)
 
1153
        {
 
1154
                selection_[i]->charStyle().erase();
 
1155
                if (parent != QString::null)
 
1156
                        selection_[i]->charStyle().setParent(parent);
 
1157
 
 
1158
                sel << selection_[i]->name();
 
1159
        }
 
1160
 
 
1161
        selected(sel);
 
1162
 
 
1163
        if (!selectionIsDirty_)
 
1164
        {
 
1165
                selectionIsDirty_ = true;
 
1166
                emit selectionDirty();
 
1167
        }
 
1168
}
 
1169
 
 
1170
SMParagraphStyle::~SMParagraphStyle()
 
1171
{
 
1172
 
 
1173
}
 
1174
 
 
1175
/******************************************************************************/
 
1176
/******************************************************************************/
 
1177
 
 
1178
SMCharacterStyle::SMCharacterStyle() : StyleItem(), widget_(0), page_(0), doc_(0), selectionIsDirty_(false)
 
1179
{
 
1180
        widget_ = new QTabWidget();
 
1181
        Q_CHECK_PTR(widget_);
 
1182
        widget_->setMargin(5);//CB the SMCStylePage parent has a 0 value to fit properly onto the pstyle page, so add it here
 
1183
        page_ = new SMCStylePage();
 
1184
        Q_CHECK_PTR(page_);
 
1185
        widget_->addTab(page_, tr("Properties"));
 
1186
}
 
1187
 
 
1188
QTabWidget* SMCharacterStyle::widget()
 
1189
{
 
1190
        return widget_;
 
1191
}
 
1192
 
 
1193
QString SMCharacterStyle::typeNamePlural()
 
1194
{
 
1195
        return tr("Character Styles");
 
1196
}
 
1197
 
 
1198
QString SMCharacterStyle::typeNameSingular()
 
1199
{
 
1200
        return tr("Character Style");
 
1201
}
 
1202
 
 
1203
void SMCharacterStyle::currentDoc(ScribusDoc *doc)
 
1204
{
 
1205
        doc_ = doc;
 
1206
        if (doc_)
 
1207
        {
 
1208
                if (page_)
 
1209
                {
 
1210
                        page_->fillLangCombo(doc_->scMW()->LangTransl);
 
1211
                        page_->fillColorCombo(doc_->PageColors);
 
1212
                        page_->fontFace_->RebuildList(doc_);
 
1213
                }
 
1214
        }
 
1215
        else
 
1216
        {
 
1217
                removeConnections();
 
1218
                selection_.clear();
 
1219
                tmpStyles_.clear();
 
1220
        }
 
1221
 
 
1222
}
 
1223
 
 
1224
StyleSet<CharStyle>* SMCharacterStyle::tmpStyles()
 
1225
{
 
1226
        return &tmpStyles_;
 
1227
}
 
1228
 
 
1229
QValueList<StyleName> SMCharacterStyle::styles(bool reloadFromDoc)
 
1230
{
 
1231
        QValueList<StyleName> tmpList;
 
1232
 
 
1233
        if (!doc_)
 
1234
                return tmpList; // no doc available
 
1235
 
 
1236
        if (reloadFromDoc)
 
1237
                reloadTmpStyles();
 
1238
 
 
1239
        for (uint i = 0; i < tmpStyles_.count(); ++i)
 
1240
        {
 
1241
                if (tmpStyles_[i].hasName())
 
1242
                {
 
1243
                        QString styleName(tmpStyles_[i].name());
 
1244
                        QString parentName(QString::null);
 
1245
 
 
1246
                        if (tmpStyles_[i].hasParent())
 
1247
                                parentName = tmpStyles_[i].parent();
 
1248
 
 
1249
                        tmpList << StyleName(styleName, parentName);
 
1250
                }
 
1251
        }
 
1252
 
 
1253
        return tmpList;
 
1254
}
 
1255
 
 
1256
void SMCharacterStyle::reload()
 
1257
{
 
1258
        reloadTmpStyles();
 
1259
}
 
1260
 
 
1261
void SMCharacterStyle::selected(const QStringList &styleNames)
 
1262
{
 
1263
        selection_.clear();
 
1264
        selectionIsDirty_ = false;
 
1265
        removeConnections();
 
1266
        QValueList<CharStyle> cstyles;
 
1267
 
 
1268
        tmpStyles_.invalidate();
 
1269
 
 
1270
        for (uint i = 0; i < tmpStyles_.count(); ++i)
 
1271
                cstyles << tmpStyles_[i];
 
1272
 
 
1273
        for (uint i = 0; i < styleNames.count(); ++i)
 
1274
        {
 
1275
                int index = tmpStyles_.find(styleNames[i]);
 
1276
                if (index > -1)
 
1277
                        selection_.append(&tmpStyles_[index]);
 
1278
 
 
1279
        }
 
1280
 
 
1281
        page_->show(selection_, cstyles, doc_->paragraphStyle("").charStyle().language(), doc_->unitIndex());
 
1282
        setupConnections();
 
1283
}
 
1284
 
 
1285
QString SMCharacterStyle::fromSelection() const
 
1286
{
 
1287
        QString lsName(QString::null);
 
1288
        if (!doc_)
 
1289
                return lsName; // no doc available
 
1290
 
 
1291
        for (uint i = 0; i < doc_->m_Selection->count(); ++i)
 
1292
        {
 
1293
                // wth is going on here
 
1294
                PageItem *item = doc_->m_Selection->itemAt(i);
 
1295
 
 
1296
                QString tmpName = item->itemText.defaultStyle().charStyle().parent();
 
1297
 
 
1298
                if (lsName.isNull() && !tmpName.isEmpty() && tmpName != "")
 
1299
                {
 
1300
                        lsName = tmpName;
 
1301
                }
 
1302
                else if (!lsName.isNull() && !tmpName.isEmpty() && tmpName != "" && lsName != tmpName)
 
1303
                {
 
1304
                        lsName = QString::null;
 
1305
                        break;
 
1306
                }
 
1307
        }
 
1308
        return lsName;
 
1309
}
 
1310
 
 
1311
void SMCharacterStyle::toSelection(const QString &styleName) const
 
1312
{
 
1313
        if (!doc_)
 
1314
                return; // nowhere to apply or no doc
 
1315
 
 
1316
        doc_->itemSelection_SetNamedCharStyle(styleName);
 
1317
}
 
1318
 
 
1319
QString SMCharacterStyle::newStyle()
 
1320
{
 
1321
        Q_ASSERT(doc_ && doc_->paragraphStyles().count() > 0);
 
1322
 
 
1323
        QString s = getUniqueName( tr("New Style"));
 
1324
        CharStyle c;
 
1325
        c.setName(s);
 
1326
        tmpStyles_.create(c);
 
1327
        return s;
 
1328
}
 
1329
 
 
1330
QString SMCharacterStyle::newStyle(const QString &fromStyle)
 
1331
{
 
1332
        Q_ASSERT(tmpStyles_.resolve(fromStyle));
 
1333
        if (!tmpStyles_.resolve(fromStyle))
 
1334
                return QString::null;
 
1335
 
 
1336
        QString s = getUniqueName( tr("Clone of %1").arg(fromStyle));
 
1337
        CharStyle c(tmpStyles_[fromStyle]);
 
1338
        c.setName(s);
 
1339
        c.setShortcut(QString::null);
 
1340
        tmpStyles_.create(c);
 
1341
 
 
1342
        return s;
 
1343
}
 
1344
 
 
1345
QString SMCharacterStyle::getUniqueName(const QString &name)
 
1346
{
 
1347
        int id = 0;
 
1348
        bool done = false;
 
1349
        QString s(name);
 
1350
 
 
1351
        while (!done)
 
1352
        {
 
1353
start:
 
1354
                ++id;
 
1355
                for (uint i = 0; i < tmpStyles_.count(); ++i)
 
1356
                {
 
1357
                        if (tmpStyles_[i].name() == s)
 
1358
                        {
 
1359
                                s = tr("%1 (%2)", "This for unique name when creating "
 
1360
                                                "a new character style. %1 will be the name "
 
1361
                                                                "of the style and %2 will be a number forming "
 
1362
                                                                "a style name like: New Style (2)").arg(name).arg(id);
 
1363
                                goto start;
 
1364
                        }
 
1365
                }
 
1366
                done = true;
 
1367
        }
 
1368
 
 
1369
        return s;
 
1370
}
 
1371
 
 
1372
void SMCharacterStyle::apply()
 
1373
{
 
1374
        if (!doc_)
 
1375
                return;
 
1376
 
 
1377
        QMap<QString, QString> replacement;
 
1378
        for (uint i = 0; i < deleted_.count(); ++i)
 
1379
                replacement[deleted_[i].first] = deleted_[i].second;
 
1380
 
 
1381
        doc_->redefineCharStyles(tmpStyles_, false);
 
1382
        doc_->replaceCharStyles(replacement);
 
1383
 
 
1384
        deleted_.clear(); // deletion done at this point
 
1385
 
 
1386
        doc_->scMW()->propertiesPalette->paraStyleCombo->updateFormatList();
 
1387
        doc_->scMW()->propertiesPalette->charStyleCombo->updateFormatList();
 
1388
        doc_->scMW()->view->DrawNew();
 
1389
        doc_->changed();
 
1390
}
 
1391
 
 
1392
void SMCharacterStyle::editMode(bool isOn)
 
1393
{
 
1394
        if (isOn)
 
1395
                reloadTmpStyles();
 
1396
}
 
1397
 
 
1398
QString SMCharacterStyle::shortcut(const QString &stylename) const
 
1399
{
 
1400
        QString s = QString::null;
 
1401
        int index = tmpStyles_.find(stylename);
 
1402
        if (index > -1)
 
1403
                s = tmpStyles_[index].shortcut();
 
1404
 
 
1405
        return s;
 
1406
}
 
1407
 
 
1408
void SMCharacterStyle::setShortcut(const QString &shortcut)
 
1409
{
 
1410
        Q_ASSERT(selection_.count() == 1);
 
1411
        if (selection_.count() != 1)
 
1412
                return;
 
1413
 
 
1414
        selection_[0]->setShortcut(shortcut);
 
1415
 
 
1416
        if (!selectionIsDirty_)
 
1417
        {
 
1418
                selectionIsDirty_ = true;
 
1419
                emit selectionDirty();
 
1420
        }
 
1421
}
 
1422
 
 
1423
void SMCharacterStyle::deleteStyles(const QValueList<RemoveItem> &removeList)
 
1424
{
 
1425
        for (uint i = 0; i < removeList.count(); ++i)
 
1426
        {
 
1427
                for (uint k = 0; k < selection_.count(); ++k)
 
1428
                {
 
1429
                        if (selection_[k]->name() == removeList[i].first)
 
1430
                        {
 
1431
                                selection_.erase(selection_.at(k));
 
1432
                                break;
 
1433
                        }
 
1434
                }
 
1435
 
 
1436
                int index = tmpStyles_.find(removeList[i].first);
 
1437
                if (index > -1)
 
1438
                        tmpStyles_.remove(index);
 
1439
                deleted_ << removeList[i];
 
1440
        }
 
1441
}
 
1442
 
 
1443
void SMCharacterStyle::nameChanged(const QString &newName)
 
1444
{
 
1445
//      for (uint i = 0; i < selection_.count(); ++i)
 
1446
//              selection_[i]->setName(newName);
 
1447
 
 
1448
        QString oldName(selection_[0]->name());
 
1449
        CharStyle c(*selection_[0]);
 
1450
        c.setName(newName);
 
1451
        tmpStyles_.create(c);
 
1452
        selection_.clear();
 
1453
        selection_.append(&tmpStyles_[tmpStyles_.find(newName)]);
 
1454
        for (uint j = 0; j < tmpStyles_.count(); ++j)
 
1455
        {
 
1456
                int index = tmpStyles_.find(oldName);
 
1457
                if (index > -1)
 
1458
                {
 
1459
                        tmpStyles_.remove(index);
 
1460
                        break;
 
1461
                }
 
1462
        }
 
1463
 
 
1464
        for (uint j = 0; j < tmpStyles_.count(); ++j)
 
1465
        {
 
1466
                if (tmpStyles_[j].parent() == oldName)
 
1467
                        tmpStyles_[j].setParent(newName);
 
1468
        }
 
1469
 
 
1470
        QValueList<RemoveItem>::iterator it;
 
1471
        for (it = deleted_.begin(); it != deleted_.end(); ++it)
 
1472
        {
 
1473
                if ((*it).second == oldName)
 
1474
                {
 
1475
                        oldName = (*it).first;
 
1476
                        deleted_.remove(it);
 
1477
                        break;
 
1478
                }
 
1479
        }
 
1480
 
 
1481
        deleted_.append(RemoveItem(oldName, newName));
 
1482
 
 
1483
        if (!selectionIsDirty_)
 
1484
        {
 
1485
                selectionIsDirty_ = true;
 
1486
                emit selectionDirty();
 
1487
        }
 
1488
}
 
1489
 
 
1490
void SMCharacterStyle::languageChange()
 
1491
{
 
1492
        if (widget_ && page_)
 
1493
        {
 
1494
                widget_->setTabLabel(page_, tr("Properties"));
 
1495
                page_->languageChange();
 
1496
        }
 
1497
}
 
1498
 
 
1499
void SMCharacterStyle::unitChange()
 
1500
{
 
1501
 
 
1502
}
 
1503
 
 
1504
void SMCharacterStyle::reloadTmpStyles()
 
1505
{
 
1506
        if (!doc_)
 
1507
                return;
 
1508
 
 
1509
        selection_.clear();
 
1510
        tmpStyles_.clear();
 
1511
        tmpStyles_.redefine(doc_->charStyles(), true);
 
1512
}
 
1513
 
 
1514
void SMCharacterStyle::setupConnections()
 
1515
{
 
1516
        if (!page_)
 
1517
                return;
 
1518
 
 
1519
        connect(page_->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
 
1520
        connect(page_->effects_, SIGNAL(State(int)), this, SLOT(slotEffects(int)));
 
1521
        connect(page_->effects_->ShadowVal->Xoffset, SIGNAL(valueChanged(int)),
 
1522
                           this, SLOT(slotEffectProperties()));
 
1523
        connect(page_->effects_->ShadowVal->Yoffset, SIGNAL(valueChanged(int)),
 
1524
                           this, SLOT(slotEffectProperties()));
 
1525
        connect(page_->effects_->OutlineVal->LWidth, SIGNAL(valueChanged(int)),
 
1526
                           this, SLOT(slotEffectProperties()));
 
1527
        connect(page_->effects_->UnderlineVal->LPos, SIGNAL(valueChanged(int)),
 
1528
                           this, SLOT(slotEffectProperties()));
 
1529
        connect(page_->effects_->UnderlineVal->LWidth, SIGNAL(valueChanged(int)),
 
1530
                           this, SLOT(slotEffectProperties()));
 
1531
        connect(page_->effects_->StrikeVal->LPos, SIGNAL(valueChanged(int)),
 
1532
                           this, SLOT(slotEffectProperties()));
 
1533
        connect(page_->effects_->StrikeVal->LWidth, SIGNAL(valueChanged(int)),
 
1534
                           this, SLOT(slotEffectProperties()));
 
1535
        connect(page_->fillColor_, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
 
1536
        connect(page_->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
 
1537
        connect(page_->strokeColor_, SIGNAL(activated(const QString&)), this, SLOT(slotStrokeColor()));
 
1538
        connect(page_->strokeShade_, SIGNAL(clicked()), this, SLOT(slotStrokeShade()));
 
1539
        connect(page_->language_, SIGNAL(activated(int)), this, SLOT(slotLanguage()));
 
1540
        connect(page_->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(slotFontSize()));
 
1541
        connect(page_->fontHScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleH()));
 
1542
        connect(page_->fontVScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleV()));
 
1543
        connect(page_->tracking_, SIGNAL(valueChanged(int)), this, SLOT(slotTracking()));
 
1544
        connect(page_->baselineOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotBaselineOffset()));
 
1545
        connect(page_->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
 
1546
        connect(page_->parentCombo, SIGNAL(activated(const QString&)),
 
1547
                this, SLOT(slotParentChanged(const QString&)));
 
1548
}
 
1549
 
 
1550
void SMCharacterStyle::removeConnections()
 
1551
{
 
1552
        if (!page_)
 
1553
                return;
 
1554
 
 
1555
        disconnect(page_->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
 
1556
        disconnect(page_->effects_, SIGNAL(State(int)), this, SLOT(slotEffects(int)));
 
1557
        disconnect(page_->effects_->ShadowVal->Xoffset, SIGNAL(valueChanged(int)),
 
1558
                           this, SLOT(slotEffectProperties()));
 
1559
        disconnect(page_->effects_->ShadowVal->Yoffset, SIGNAL(valueChanged(int)),
 
1560
                           this, SLOT(slotEffectProperties()));
 
1561
        disconnect(page_->effects_->OutlineVal->LWidth, SIGNAL(valueChanged(int)),
 
1562
                           this, SLOT(slotEffectProperties()));
 
1563
        disconnect(page_->effects_->UnderlineVal->LPos, SIGNAL(valueChanged(int)),
 
1564
                           this, SLOT(slotEffectProperties()));
 
1565
        disconnect(page_->effects_->UnderlineVal->LWidth, SIGNAL(valueChanged(int)),
 
1566
                           this, SLOT(slotEffectProperties()));
 
1567
        disconnect(page_->effects_->StrikeVal->LPos, SIGNAL(valueChanged(int)),
 
1568
                           this, SLOT(slotEffectProperties()));
 
1569
        disconnect(page_->effects_->StrikeVal->LWidth, SIGNAL(valueChanged(int)),
 
1570
                           this, SLOT(slotEffectProperties()));
 
1571
        disconnect(page_->fillColor_, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
 
1572
        disconnect(page_->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
 
1573
        disconnect(page_->strokeColor_, SIGNAL(activated(const QString&)), this, SLOT(slotStrokeColor()));
 
1574
        disconnect(page_->strokeShade_, SIGNAL(clicked()), this, SLOT(slotStrokeShade()));
 
1575
        disconnect(page_->language_, SIGNAL(activated(int)), this, SLOT(slotLanguage()));
 
1576
        disconnect(page_->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(slotFontSize()));
 
1577
        disconnect(page_->fontHScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleH()));
 
1578
        disconnect(page_->fontVScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleV()));
 
1579
        disconnect(page_->tracking_, SIGNAL(valueChanged(int)), this, SLOT(slotTracking()));
 
1580
        disconnect(page_->baselineOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotBaselineOffset()));
 
1581
        disconnect(page_->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
 
1582
        disconnect(page_->parentCombo, SIGNAL(activated(const QString&)),
 
1583
                        this, SLOT(slotParentChanged(const QString&)));
 
1584
}
 
1585
 
 
1586
void SMCharacterStyle::slotFontSize()
 
1587
{
 
1588
        if (page_->fontSize_->useParentValue())
 
1589
                for (uint i = 0; i < selection_.count(); ++i)
 
1590
                        selection_[i]->resetFontSize();
 
1591
        else
 
1592
        {
 
1593
                double a, b, value;
 
1594
                int c;
 
1595
 
 
1596
                page_->fontSize_->getValues(&a, &b, &c, &value);
 
1597
                value = value * 10;
 
1598
                for (uint i = 0; i < selection_.count(); ++i)
 
1599
                        selection_[i]->setFontSize(qRound(value));
 
1600
        }
 
1601
 
 
1602
        if (!selectionIsDirty_)
 
1603
        {
 
1604
                selectionIsDirty_ = true;
 
1605
                emit selectionDirty();
 
1606
        }
 
1607
}
 
1608
 
 
1609
void SMCharacterStyle::slotEffects(int e)
 
1610
{
 
1611
        StyleFlag s = ScStyle_None;
 
1612
        if (page_->effects_->useParentValue())
 
1613
        {
 
1614
                for (uint i = 0; i < selection_.count(); ++i)
 
1615
                {
 
1616
                        selection_[i]->resetFeatures();
 
1617
                        selection_[i]->resetShadowXOffset();
 
1618
                        selection_[i]->resetShadowYOffset();
 
1619
                        selection_[i]->resetOutlineWidth();
 
1620
                        selection_[i]->resetUnderlineOffset();
 
1621
                        selection_[i]->resetUnderlineWidth();
 
1622
                        selection_[i]->resetStrikethruOffset();
 
1623
                        selection_[i]->resetStrikethruWidth();
 
1624
                }
 
1625
        }
 
1626
        else
 
1627
        {
 
1628
                s = static_cast<StyleFlag>(e);
 
1629
                double a, b, sxo, syo, olw, ulp, ulw, slp, slw;
 
1630
                int c;
 
1631
 
 
1632
                page_->effects_->ShadowVal->Xoffset->getValues(&a, &b, &c, &sxo);
 
1633
                sxo *= 10;
 
1634
                page_->effects_->ShadowVal->Yoffset->getValues(&a, &b, &c, &syo);
 
1635
                syo *= 10;
 
1636
 
 
1637
                page_->effects_->OutlineVal->LWidth->getValues(&a, &b, &c, &olw);
 
1638
                olw *= 10;
 
1639
 
 
1640
                page_->effects_->UnderlineVal->LPos->getValues(&a, &b, &c, &ulp);
 
1641
                ulp *= 10;
 
1642
                page_->effects_->UnderlineVal->LWidth->getValues(&a, &b, &c, &ulw);
 
1643
                ulw *= 10;
 
1644
 
 
1645
                page_->effects_->StrikeVal->LPos->getValues(&a, &b, &c, &slp);
 
1646
                slp *= 10;
 
1647
                page_->effects_->StrikeVal->LWidth->getValues(&a, &b, &c, &slw);
 
1648
                slw *= 10;
 
1649
 
 
1650
                for (uint i = 0; i < selection_.count(); ++i)
 
1651
                {
 
1652
                        selection_[i]->setFeatures(s.featureList());
 
1653
                        selection_[i]->setShadowXOffset(qRound(sxo));
 
1654
                        selection_[i]->setShadowYOffset(qRound(syo));
 
1655
                        selection_[i]->setOutlineWidth(qRound(olw));
 
1656
                        selection_[i]->setUnderlineOffset(qRound(ulp));
 
1657
                        selection_[i]->setUnderlineWidth(qRound(ulw));
 
1658
                        selection_[i]->setStrikethruOffset(qRound(slp));
 
1659
                        selection_[i]->setStrikethruWidth(qRound(slw));
 
1660
                }
 
1661
        }
 
1662
 
 
1663
 
 
1664
        if (!selectionIsDirty_)
 
1665
        {
 
1666
                selectionIsDirty_ = true;
 
1667
                emit selectionDirty();
 
1668
        }
 
1669
}
 
1670
 
 
1671
void SMCharacterStyle::slotEffectProperties()
 
1672
{
 
1673
        double a, b, sxo, syo, olw, ulp, ulw, slp, slw;
 
1674
        int c;
 
1675
 
 
1676
        page_->effects_->ShadowVal->Xoffset->getValues(&a, &b, &c, &sxo);
 
1677
        sxo *= 10;
 
1678
        page_->effects_->ShadowVal->Yoffset->getValues(&a, &b, &c, &syo);
 
1679
        syo *= 10;
 
1680
 
 
1681
        page_->effects_->OutlineVal->LWidth->getValues(&a, &b, &c, &olw);
 
1682
        olw *= 10;
 
1683
 
 
1684
        page_->effects_->UnderlineVal->LPos->getValues(&a, &b, &c, &ulp);
 
1685
        ulp *= 10;
 
1686
        page_->effects_->UnderlineVal->LWidth->getValues(&a, &b, &c, &ulw);
 
1687
        ulw *= 10;
 
1688
 
 
1689
        page_->effects_->StrikeVal->LPos->getValues(&a, &b, &c, &slp);
 
1690
        slp *= 10;
 
1691
        page_->effects_->StrikeVal->LWidth->getValues(&a, &b, &c, &slw);
 
1692
        slw *= 10;
 
1693
        
 
1694
        for (uint i = 0; i < selection_.count(); ++i)
 
1695
        {
 
1696
                selection_[i]->setShadowXOffset(qRound(sxo));
 
1697
                selection_[i]->setShadowYOffset(qRound(syo));
 
1698
                selection_[i]->setOutlineWidth(qRound(olw));
 
1699
                selection_[i]->setUnderlineOffset(qRound(ulp));
 
1700
                selection_[i]->setUnderlineWidth(qRound(ulw));
 
1701
                selection_[i]->setStrikethruOffset(qRound(slp));
 
1702
                selection_[i]->setStrikethruWidth(qRound(slw));
 
1703
        }
 
1704
 
 
1705
        if (!selectionIsDirty_)
 
1706
        {
 
1707
                selectionIsDirty_ = true;
 
1708
                emit selectionDirty();
 
1709
        }
 
1710
}
 
1711
 
 
1712
void SMCharacterStyle::slotFillColor()
 
1713
{
 
1714
        if (page_->fillColor_->useParentValue())
 
1715
                for (uint i = 0; i < selection_.count(); ++i)
 
1716
                        selection_[i]->resetFillColor();
 
1717
        else {          
 
1718
                QString col(page_->fillColor_->currentText());
 
1719
                
 
1720
                for (uint i = 0; i < selection_.count(); ++i)
 
1721
                        selection_[i]->setFillColor(col);
 
1722
        }
 
1723
        
 
1724
        if (!selectionIsDirty_)
 
1725
        {
 
1726
                selectionIsDirty_ = true;
 
1727
                emit selectionDirty();
 
1728
        }
 
1729
}
 
1730
 
 
1731
void SMCharacterStyle::slotFillShade()
 
1732
{
 
1733
        if (page_->fillShade_->useParentValue())
 
1734
                for (uint i = 0; i < selection_.count(); ++i)
 
1735
                        selection_[i]->resetFillShade();
 
1736
        else {
 
1737
                int fs = page_->fillShade_->getValue();
 
1738
 
 
1739
                for (uint i = 0; i < selection_.count(); ++i)
 
1740
                        selection_[i]->setFillShade(fs);
 
1741
        }
 
1742
        
 
1743
        if (!selectionIsDirty_)
 
1744
        {
 
1745
                selectionIsDirty_ = true;
 
1746
                emit selectionDirty();
 
1747
        }
 
1748
}
 
1749
 
 
1750
void SMCharacterStyle::slotStrokeColor()
 
1751
{
 
1752
        if (page_->strokeColor_->useParentValue())
 
1753
                for (uint i = 0; i < selection_.count(); ++i)
 
1754
                        selection_[i]->resetStrokeColor();
 
1755
        else {
 
1756
                QString c(page_->strokeColor_->currentText());
 
1757
 
 
1758
                for (uint i = 0; i < selection_.count(); ++i)
 
1759
                        selection_[i]->setStrokeColor(c);
 
1760
        }
 
1761
        
 
1762
        if (!selectionIsDirty_)
 
1763
        {
 
1764
                selectionIsDirty_ = true;
 
1765
                emit selectionDirty();
 
1766
        }
 
1767
}
 
1768
 
 
1769
void SMCharacterStyle::slotStrokeShade()
 
1770
{
 
1771
        if (page_->strokeShade_->useParentValue())
 
1772
                for (uint i = 0; i < selection_.count(); ++i)
 
1773
                        selection_[i]->resetStrokeShade();
 
1774
        else {
 
1775
                int ss = page_->strokeShade_->getValue();
 
1776
                
 
1777
                for (uint i = 0; i < selection_.count(); ++i)
 
1778
                        selection_[i]->setStrokeShade(ss);
 
1779
        }
 
1780
        
 
1781
        if (!selectionIsDirty_)
 
1782
        {
 
1783
                selectionIsDirty_ = true;
 
1784
                emit selectionDirty();
 
1785
        }
 
1786
}
 
1787
 
 
1788
void SMCharacterStyle::slotLanguage()
 
1789
{
 
1790
        QMap<QString,QString>::Iterator it;
 
1791
        QString language = doc_->paragraphStyle("").charStyle().language();
 
1792
 
 
1793
        if (page_->language_->useParentValue())
 
1794
                for (uint i = 0; i < selection_.count(); ++i)
 
1795
                        selection_[i]->resetLanguage();
 
1796
        else
 
1797
        {
 
1798
                for (it = doc_->scMW()->LangTransl.begin(); it != doc_->scMW()->LangTransl.end(); ++it)
 
1799
                {
 
1800
                        if (it.data() == page_->language_->currentText())
 
1801
                        {
 
1802
                                language = it.key();
 
1803
                                break;
 
1804
                        }
 
1805
                }
 
1806
                for (uint i = 0; i < selection_.count(); ++i)
 
1807
                        selection_[i]->setLanguage(language);
 
1808
        }
 
1809
 
 
1810
 
 
1811
        if (!selectionIsDirty_)
 
1812
        {
 
1813
                selectionIsDirty_ = true;
 
1814
                emit selectionDirty();
 
1815
        }
 
1816
}
 
1817
 
 
1818
void SMCharacterStyle::slotScaleH()
 
1819
{
 
1820
        if (page_->fontHScale_->useParentValue())
 
1821
                for (uint i = 0; i < selection_.count(); ++i)
 
1822
                        selection_[i]->resetScaleH();
 
1823
        else
 
1824
        {
 
1825
                double a, b, value;
 
1826
                int c;
 
1827
 
 
1828
                page_->fontHScale_->getValues(&a, &b, &c, &value);
 
1829
                value = value * 10;
 
1830
                for (uint i = 0; i < selection_.count(); ++i)
 
1831
                        selection_[i]->setScaleH(qRound(value));
 
1832
        }
 
1833
 
 
1834
 
 
1835
        if (!selectionIsDirty_)
 
1836
        {
 
1837
                selectionIsDirty_ = true;
 
1838
                emit selectionDirty();
 
1839
        }
 
1840
}
 
1841
 
 
1842
void SMCharacterStyle::slotScaleV()
 
1843
{
 
1844
        if (page_->fontVScale_->useParentValue())
 
1845
                for (uint i = 0; i < selection_.count(); ++i)
 
1846
                        selection_[i]->resetScaleV();
 
1847
        else
 
1848
        {
 
1849
                double a, b, value;
 
1850
                int c;
 
1851
 
 
1852
                page_->fontVScale_->getValues(&a, &b, &c, &value);
 
1853
                value = value * 10;
 
1854
                for (uint i = 0; i < selection_.count(); ++i)
 
1855
                        selection_[i]->setScaleV(qRound(value));
 
1856
        }
 
1857
 
 
1858
 
 
1859
        if (!selectionIsDirty_)
 
1860
        {
 
1861
                selectionIsDirty_ = true;
 
1862
                emit selectionDirty();
 
1863
        }
 
1864
}
 
1865
 
 
1866
void SMCharacterStyle::slotTracking()
 
1867
{
 
1868
        if (page_->tracking_->useParentValue())
 
1869
                for (uint i = 0; i < selection_.count(); ++i)
 
1870
                        selection_[i]->resetTracking();
 
1871
        else
 
1872
        {
 
1873
                double a, b, value;
 
1874
                int c;
 
1875
 
 
1876
                page_->tracking_->getValues(&a, &b, &c, &value);
 
1877
                value = value * 10;
 
1878
                for (uint i = 0; i < selection_.count(); ++i)
 
1879
                        selection_[i]->setTracking(qRound(value));
 
1880
        }
 
1881
 
 
1882
        if (!selectionIsDirty_)
 
1883
        {
 
1884
                selectionIsDirty_ = true;
 
1885
                emit selectionDirty();
 
1886
        }
 
1887
}
 
1888
 
 
1889
void SMCharacterStyle::slotBaselineOffset()
 
1890
{
 
1891
        if (page_->baselineOffset_->useParentValue())
 
1892
                for (uint i = 0; i < selection_.count(); ++i)
 
1893
                        selection_[i]->resetBaselineOffset();
 
1894
        else
 
1895
        {
 
1896
                double a, b, value;
 
1897
                int c;
 
1898
                
 
1899
                page_->baselineOffset_->getValues(&a, &b, &c, &value);
 
1900
                value = value * 10;
 
1901
                for (uint i = 0; i < selection_.count(); ++i)
 
1902
                        selection_[i]->setBaselineOffset(qRound(value));
 
1903
        }
 
1904
 
 
1905
        if (!selectionIsDirty_)
 
1906
        {
 
1907
                selectionIsDirty_ = true;
 
1908
                emit selectionDirty();
 
1909
        }
 
1910
}
 
1911
 
 
1912
void SMCharacterStyle::slotFont(QString s)
 
1913
{
 
1914
        ScFace sf;
 
1915
        if (page_->fontFace_->useParentFont())
 
1916
                for (uint i = 0; i < selection_.count(); ++i)
 
1917
                        selection_[i]->resetFont();
 
1918
        else {
 
1919
                sf = PrefsManager::instance()->appPrefs.AvailFonts[s];
 
1920
 
 
1921
                for (uint i = 0; i < selection_.count(); ++i)
 
1922
                        selection_[i]->setFont(sf);
 
1923
        }
 
1924
        
 
1925
        if (!selectionIsDirty_)
 
1926
        {
 
1927
                selectionIsDirty_ = true;
 
1928
                emit selectionDirty();
 
1929
        }
 
1930
}
 
1931
 
 
1932
void SMCharacterStyle::slotParentChanged(const QString &parent)
 
1933
{
 
1934
        Q_ASSERT(!parent.isNull());
 
1935
 
 
1936
        QStringList sel;
 
1937
 
 
1938
        for (uint i = 0; i < selection_.count(); ++i)
 
1939
        {
 
1940
                selection_[i]->erase();
 
1941
                selection_[i]->setParent(parent);
 
1942
                sel << selection_[i]->name();
 
1943
        }
 
1944
 
 
1945
        selected(sel);
 
1946
 
 
1947
        if (!selectionIsDirty_)
 
1948
        {
 
1949
                selectionIsDirty_ = true;
 
1950
                emit selectionDirty();
 
1951
        }
 
1952
}
 
1953
 
 
1954
SMCharacterStyle::~SMCharacterStyle()
 
1955
{
 
1956
        delete page_;
 
1957
        delete widget_;
 
1958
        page_ = 0;
 
1959
        widget_ = 0;
 
1960
}
 
1961