Subversion Repositories Scribus

Rev

Rev 23186 | Rev 23210 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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