~ubuntu-branches/ubuntu/wily/scribus/wily-proposed

« back to all changes in this revision

Viewing changes to .pc/0001-qreal-double-fixes.patch/scribus/pageitem.cpp

  • Committer: Package Import Robot
  • Author(s): Oleksandr Moskalenko
  • Date: 2012-02-09 21:50:56 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120209215056-2wrx1ara0jbm7fi5
Tags: 1.4.0.dfsg+r17287-1
* New upstream stable release upload into Debian (Closes: #654703).
* Applied the Ubuntu armel patch.
* Removed non-free color swatches from resources.
* debian/control:
  - Moved icc-profiles from Recommends to Suggests (Closes: #655885).
  - Updated Standards-Version to 3.9.2.
  - Updated extended description per lintian warning.
* debian/rules:
  - Update mailcap (Closes: #630751). A request for mime.types update has
    been sent to the mime-support maintainer.
  - Added build-arch and build-indep targets per lintian warning.
* debian/patches:
  - top_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't install the non-free "doc" dir.
  - profiles_cmakelists.patch - don't install non-free sRGB profile.
* debian/copyright: 
  - Converted to the DEP5 machine readable foramt.
  - Added licenses for free color swatches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
 
to the COPYING file provided with the program. Following this notice may exist
4
 
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
 
for which a new license (GPL+exception) is in place.
6
 
*/
7
 
/***************************************************************************
8
 
                          pageitem.cpp  -  description
9
 
                             -------------------
10
 
    begin                : Sat Apr 7 2001
11
 
    copyright            : (C) 2001 by Franz Schmid
12
 
    email                : Franz.Schmid@altmuehlnet.de
13
 
 ***************************************************************************/
14
 
 
15
 
/***************************************************************************
16
 
 *                                                                         *
17
 
 *   This program is free software; you can redistribute it and/or modify  *
18
 
 *   it under the terms of the GNU General Public License as published by  *
19
 
 *   the Free Software Foundation; either version 2 of the License, or     *
20
 
 *   (at your option) any later version.                                   *
21
 
 *                                                                         *
22
 
 ***************************************************************************/
23
 
 
24
 
#include "pageitem.h"
25
 
#include <QPainter>
26
 
#include <QPen>
27
 
#include <QFont>
28
 
#include <QRegion>
29
 
#include <QPoint>
30
 
#include <QFileInfo>
31
 
#include <qdrawutil.h>
32
 
#include <QRegExp>
33
 
#include <QMessageBox>
34
 
#include <QPolygon>
35
 
#include <cassert>
36
 
#include <QDebug>
37
 
#include <iostream>
38
 
#include <sstream>
39
 
#include <string>
40
 
 
41
 
#include "canvas.h"
42
 
#include "cmsettings.h"
43
 
#include "colorblind.h"
44
 
#include "commonstrings.h"
45
 
#include "cpalette.h"
46
 
#include "guidemanager.h"
47
 
#include "page.h"
48
 
#include "pageitem_latexframe.h"
49
 
#include "pageitem_textframe.h"
50
 
#include "prefsmanager.h"
51
 
#include "propertiespalette.h"
52
 
#include "resourcecollection.h"
53
 
#include "scclocale.h"
54
 
#include "sccolorengine.h"
55
 
#include "scconfig.h"
56
 
#include "scpainter.h"
57
 
#include "scpaths.h"
58
 
#include "scpattern.h"
59
 
#include "scribus.h"
60
 
#include "scribusapp.h"
61
 
#include "scribuscore.h"
62
 
#include "scribusdoc.h"
63
 
#include "scribusstructs.h"
64
 
#include "scribuswin.h"
65
 
#include "sctextstream.h"
66
 
#include "serializer.h"
67
 
#include "selection.h"
68
 
#include "sclimits.h"
69
 
#include "text/nlsconfig.h"
70
 
#include "desaxe/saxXML.h"
71
 
#include "undomanager.h"
72
 
#include "undostate.h"
73
 
#include "util.h"
74
 
#include "util_formats.h"
75
 
#include "util_math.h"
76
 
#include "util_text.h"
77
 
#include "util_file.h"
78
 
#ifdef HAVE_CAIRO
79
 
        #include <cairo.h>
80
 
#endif
81
 
 
82
 
using namespace std;
83
 
 
84
 
PageItem::PageItem(const PageItem & other)
85
 
        : QObject(other.parent()),
86
 
         UndoObject(other), SingleObservable<PageItem>(other.m_Doc->itemsChanged()),
87
 
 
88
 
// 200 attributes! That is madness, or to quote some famous people from Kriquet:
89
 
// "THAT ALL HAS TO GO!"
90
 
        gXpos(other.gXpos),
91
 
        gYpos(other.gYpos),
92
 
        gWidth(other.gWidth),
93
 
        gHeight(other.gHeight),
94
 
        GrType(other.GrType),
95
 
        GrStartX(other.GrStartX),
96
 
        GrStartY(other.GrStartY),
97
 
        GrEndX(other.GrEndX),
98
 
        GrEndY(other.GrEndY),
99
 
        Cols(other.Cols),
100
 
        ColGap(other.ColGap),
101
 
        PLineArt(other.PLineArt),
102
 
        PLineEnd(other.PLineEnd),
103
 
        PLineJoin(other.PLineJoin),
104
 
        NamedLStyle(other.NamedLStyle),
105
 
        Clip(other.Clip),
106
 
        PoLine(other.PoLine),
107
 
        ContourLine(other.ContourLine),
108
 
        imageClip(other.imageClip),
109
 
        Segments(other.Segments),
110
 
        effectsInUse(other.effectsInUse),
111
 
        PoShow(other.PoShow),
112
 
        BaseOffs(other.BaseOffs),
113
 
        textPathType(other.textPathType),
114
 
        textPathFlipped(other.textPathFlipped),
115
 
        ClipEdited(other.ClipEdited),
116
 
        FrameType(other.FrameType),
117
 
        ItemNr(other.ItemNr),
118
 
        Frame(other.Frame),
119
 
        OwnPage(other.OwnPage),
120
 
        oldOwnPage(other.oldOwnPage),
121
 
        pixm(other.pixm),
122
 
        Pfile(other.Pfile),
123
 
        Pfile2(other.Pfile2),
124
 
        Pfile3(other.Pfile3),
125
 
        IProfile(other.IProfile),
126
 
        UseEmbedded(other.UseEmbedded),
127
 
        EmProfile(other.EmProfile),
128
 
        IRender(other.IRender),
129
 
 
130
 
        PictureIsAvailable(other.PictureIsAvailable),
131
 
        OrigW(other.OrigW),
132
 
        OrigH(other.OrigH),
133
 
        BBoxX(other.BBoxX),
134
 
        BBoxH(other.BBoxH),
135
 
        CurX(other.CurX),
136
 
        CurY(other.CurY),
137
 
        CPos(other.CPos),
138
 
        itemText(other.itemText),
139
 
        isBookmark(other.isBookmark),
140
 
        HasSel(other.HasSel),
141
 
//      Tinput(other.Tinput),
142
 
        isAutoText(other.isAutoText),
143
 
        BackBox(NULL),  // otherwise other.BackBox->NextBox would be inconsistent
144
 
        NextBox(NULL),  // otherwise other.NextBox->BackBox would be inconsistent
145
 
        firstChar(0),   // since this box is unlinked now
146
 
        MaxChars(0),   // since the layout is invalid now
147
 
        inPdfArticle(other.inPdfArticle),
148
 
        isRaster(other.isRaster),
149
 
        OldB(other.OldB),
150
 
        OldH(other.OldH),
151
 
        OldB2(other.OldB2),
152
 
        OldH2(other.OldH2),
153
 
        Sizing(other.Sizing),
154
 
        toPixmap(other.toPixmap),
155
 
        LayerNr(other.LayerNr),
156
 
        ScaleType(other.ScaleType),
157
 
        AspectRatio(other.AspectRatio),
158
 
        Groups(other.Groups),
159
 
        DashValues(other.DashValues),
160
 
        DashOffset(other.DashOffset),
161
 
        fill_gradient(other.fill_gradient),
162
 
        fillRule(other.fillRule),
163
 
        doOverprint(other.doOverprint),
164
 
        LeftLink(other.LeftLink),
165
 
        RightLink(other.RightLink),
166
 
        TopLink(other.TopLink),
167
 
        BottomLink(other.BottomLink),
168
 
        LeftLinkID(other.LeftLinkID),
169
 
        RightLinkID(other.RightLinkID),
170
 
        TopLinkID(other.TopLinkID),
171
 
        BottomLinkID(other.BottomLinkID),
172
 
        LeftLine(other.LeftLine),
173
 
        RightLine(other.RightLine),
174
 
        TopLine(other.TopLine),
175
 
        BottomLine(other.BottomLine),
176
 
        isTableItem(other.isTableItem),
177
 
        isSingleSel(other.isSingleSel),
178
 
        isGroupControl(other.isGroupControl),
179
 
        groupsLastItem(other.groupsLastItem),
180
 
        BoundingX(other.BoundingX),
181
 
        BoundingY(other.BoundingY),
182
 
        BoundingW(other.BoundingW),
183
 
        BoundingH(other.BoundingH),
184
 
        ChangedMasterItem(other.ChangedMasterItem),
185
 
        OnMasterPage(other.OnMasterPage),
186
 
        isEmbedded(other.isEmbedded),
187
 
 
188
 
        // protected
189
 
        undoManager(other.undoManager),
190
 
        m_ItemType(other.m_ItemType),
191
 
        AnName(other.AnName),
192
 
        patternVal(other.patternVal),
193
 
        patternScaleX(other.patternScaleX),
194
 
        patternScaleY(other.patternScaleY),
195
 
        patternOffsetX(other.patternOffsetX),
196
 
        patternOffsetY(other.patternOffsetY),
197
 
        patternRotation(other.patternRotation),
198
 
        fillColorVal(other.fillColorVal),
199
 
        lineColorVal(other.lineColorVal),
200
 
        lineShadeVal(other.lineShadeVal),
201
 
        fillShadeVal(other.fillShadeVal),
202
 
        fillTransparencyVal(other.fillTransparencyVal),
203
 
        lineTransparencyVal(other.lineTransparencyVal),
204
 
        fillBlendmodeVal(other.fillBlendmodeVal),
205
 
        lineBlendmodeVal(other.lineBlendmodeVal),
206
 
        m_ImageIsFlippedH(other.m_ImageIsFlippedH),
207
 
        m_ImageIsFlippedV(other.m_ImageIsFlippedV),
208
 
        m_Locked(other.m_Locked),
209
 
        m_SizeLocked(other.m_SizeLocked),
210
 
        textFlowModeVal(other.textFlowModeVal),
211
 
        pageItemAttributes(other.pageItemAttributes),
212
 
        m_PrintEnabled(other.m_PrintEnabled),
213
 
        tagged(other.tagged),
214
 
        fillQColor(other.fillQColor),
215
 
        strokeQColor(other.strokeQColor),
216
 
        Xpos(other.Xpos),
217
 
        Ypos(other.Ypos),
218
 
        Width(other.Width),
219
 
        Height(other.Height),
220
 
        Rot(other.Rot),
221
 
        Select(other.Select),
222
 
        LocalScX(other.LocalScX),
223
 
        LocalScY(other.LocalScY),
224
 
        LocalX(other.LocalX),
225
 
        LocalY(other.LocalY),
226
 
        Reverse(other.Reverse),
227
 
        m_startArrowIndex(other.m_startArrowIndex),
228
 
        m_endArrowIndex(other.m_endArrowIndex),
229
 
        Extra(other.Extra),
230
 
        TExtra(other.TExtra),
231
 
        BExtra(other.BExtra),
232
 
        RExtra(other.RExtra),
233
 
        firstLineOffsetP(other.firstLineOffsetP),
234
 
        RadRect(other.RadRect),
235
 
        oldXpos(other.oldXpos),
236
 
        oldYpos(other.oldYpos),
237
 
        oldWidth(other.oldWidth),
238
 
        oldHeight(other.oldHeight),
239
 
        oldRot(other.oldRot),
240
 
        oldLocalScX(other.oldLocalScX),
241
 
        oldLocalScY(other.oldLocalScY),
242
 
        oldLocalX(other.oldLocalX),
243
 
        oldLocalY(other.oldLocalY),
244
 
        m_Doc(other.m_Doc),
245
 
        m_isAnnotation(other.m_isAnnotation),
246
 
        m_annotation(other.m_annotation),
247
 
        PicArt(other.PicArt),
248
 
        m_lineWidth(other.m_lineWidth),
249
 
        Oldm_lineWidth(other.Oldm_lineWidth)
250
 
{
251
 
        QString tmp;
252
 
        m_Doc->TotalItems++;
253
 
        AnName += tmp.setNum(m_Doc->TotalItems);
254
 
        uniqueNr = m_Doc->TotalItems;
255
 
        invalid = true;
256
 
        if (other.isInlineImage)
257
 
        {
258
 
                QFileInfo inlFi(Pfile);
259
 
                QString ext = inlFi.suffix();
260
 
                tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + ext);
261
 
                tempImageFile->open();
262
 
                QString fileName = getLongPathName(tempImageFile->fileName());
263
 
                tempImageFile->close();
264
 
                copyFile(Pfile, fileName);
265
 
                Pfile = fileName;
266
 
                isInlineImage = true;
267
 
        }
268
 
        else
269
 
        {
270
 
                tempImageFile = NULL;
271
 
                isInlineImage = false;
272
 
        }
273
 
}
274
 
 
275
 
 
276
 
PageItem::PageItem(ScribusDoc *pa, ItemType newType, double x, double y, double w, double h, double w2, QString fill, QString outline)
277
 
        // Initialize superclass(es)
278
 
        : QObject(pa), SingleObservable<PageItem>(pa->itemsChanged()),
279
 
        // Initialize member variables
280
 
        itemText(pa),
281
 
        undoManager(UndoManager::instance()),
282
 
        lineShadeVal(100),
283
 
        fillShadeVal(100),
284
 
        fillTransparencyVal(0.0),
285
 
        lineTransparencyVal(0.0),
286
 
        fillBlendmodeVal(0),
287
 
        lineBlendmodeVal(0),
288
 
        m_ImageIsFlippedH(0),
289
 
        m_ImageIsFlippedV(0),
290
 
        m_Locked(false),
291
 
        m_SizeLocked(false),
292
 
        textFlowModeVal(TextFlowDisabled)
293
 
{
294
 
        m_Doc = pa;
295
 
        QString tmp;
296
 
        BackBox = 0;
297
 
        NextBox = 0;
298
 
        oldXpos = Xpos = x;
299
 
        oldYpos = Ypos = y;
300
 
        //CB Surely we can remove some of these?
301
 
        OldB2 = OldB = oldWidth = Width = w;
302
 
        OldH2 = OldH = oldHeight = Height = h;
303
 
        BoundingX = x;
304
 
        BoundingY = y;
305
 
        BoundingW = w;
306
 
        BoundingH = h;
307
 
        m_ItemType = newType;
308
 
        oldRot = Rot = 0;
309
 
        fillColorVal = fill;
310
 
        lineColorVal = m_ItemType == PageItem::TextFrame ? fill : outline;
311
 
        gXpos = gYpos = 0;
312
 
        gWidth = gHeight = 0;
313
 
        GrType = 0;
314
 
        GrStartX = 0;
315
 
        GrStartY = 0;
316
 
        GrEndX = w;
317
 
        GrEndY = 0;
318
 
        patternVal = "";
319
 
        patternScaleX = 100;
320
 
        patternScaleY = 100;
321
 
        patternOffsetX = 0;
322
 
        patternOffsetY = 0;
323
 
        patternRotation = 0;
324
 
        m_lineWidth = w2;
325
 
        Oldm_lineWidth = w2;
326
 
        PLineArt = Qt::PenStyle(m_Doc->toolSettings.dLineArt);
327
 
        PLineEnd = Qt::FlatCap;
328
 
        PLineJoin = Qt::MiterJoin;
329
 
        Select = false;
330
 
        ClipEdited = false;
331
 
        FrameType = 0;
332
 
        CurX = 0;
333
 
        CurY = 0;
334
 
        CPos = 0;
335
 
        oldCPos = 0;
336
 
        Extra = 0;
337
 
        TExtra = 0;
338
 
        BExtra = 0;
339
 
        RExtra = 0;
340
 
        firstChar = 0;
341
 
        MaxChars = 0;
342
 
        Pfile = "";
343
 
        pixm = ScImage();
344
 
        pixm.imgInfo.lowResType = m_Doc->toolSettings.lowResType;
345
 
        Pfile2 = "";
346
 
        Pfile3 = "";
347
 
        oldLocalScX = LocalScX = 1;
348
 
        oldLocalScY = LocalScY = 1;
349
 
        OrigW = 0;
350
 
        OrigH = 0;
351
 
        oldLocalX = LocalX = 0;
352
 
        oldLocalY = LocalY = 0;
353
 
        BBoxX = 0;
354
 
        BBoxH = 0;
355
 
        RadRect = 0;
356
 
        if ((m_ItemType == TextFrame) || (m_ItemType == ImageFrame) || (m_ItemType == PathText))
357
 
                // TODO: Frame should become a read-only calculated property
358
 
                Frame = true;
359
 
        else
360
 
                Frame = false;
361
 
        switch (m_ItemType)
362
 
        {
363
 
                case Polygon:
364
 
                        Clip.setPoints(4, static_cast<int>(w/2), 0, static_cast<int>(w), static_cast<int>(h/2),
365
 
                                                                static_cast<int>(w/2), static_cast<int>(h), 0,static_cast<int>(h/2));
366
 
                        break;
367
 
                default:
368
 
                        Clip.setPoints(4, 0,0, static_cast<int>(w),0, static_cast<int>(w), static_cast<int>(h), 0,static_cast<int>(h));
369
 
                        break;
370
 
        }
371
 
        PoLine.resize(0);
372
 
        ContourLine.resize(0);
373
 
        imageClip.resize(0);
374
 
        Segments.clear();
375
 
        PoShow = false;
376
 
        BaseOffs = 0;
377
 
        textPathType = 0;
378
 
        textPathFlipped = false;
379
 
        OwnPage = m_Doc->currentPage()->pageNr();
380
 
        oldOwnPage = OwnPage;
381
 
        savedOwnPage = OwnPage;
382
 
        PicArt = true;
383
 
        PictureIsAvailable = false;
384
 
        m_PrintEnabled = true;
385
 
        isBookmark = false;
386
 
        m_isAnnotation = false;
387
 
        
388
 
        switch (m_ItemType)
389
 
        {
390
 
        case ImageFrame:
391
 
        case LatexFrame:
392
 
                //We can't determine if this is a latex frame here
393
 
                // because c++'s typeinfos are still saying it's 
394
 
                // a plain pageitem
395
 
                // This is fixed in the PageItem_LatexFrame constructor
396
 
                AnName = tr("Image");
397
 
                setUPixmap(Um::IImageFrame);
398
 
                break;
399
 
        case TextFrame:
400
 
                AnName = tr("Text");
401
 
                setUPixmap(Um::ITextFrame);
402
 
                break;
403
 
        case Line:
404
 
                AnName = tr("Line");
405
 
                setUPixmap(Um::ILine);
406
 
                break;
407
 
        case Polygon:
408
 
                AnName = tr("Polygon");
409
 
                setUPixmap(Um::IPolygon);
410
 
                break;
411
 
        case PolyLine:
412
 
                AnName = tr("Polyline");
413
 
                setUPixmap(Um::IPolyline);
414
 
                break;
415
 
        case PathText:
416
 
                AnName = tr("PathText");
417
 
                setUPixmap(Um::IPathText);
418
 
                break;
419
 
        default:
420
 
                AnName = "Item";
421
 
                break;
422
 
        }
423
 
        m_Doc->TotalItems++;
424
 
        AnName += tmp.setNum(m_Doc->TotalItems); // +" "+QDateTime::currentDateTime().toString();
425
 
        uniqueNr = m_Doc->TotalItems;
426
 
        AutoName = true;
427
 
        setUName(AnName);
428
 
        m_annotation.setBorderColor(outline);
429
 
        HasSel = false;
430
 
//      Tinput = false;
431
 
        isAutoText = false;
432
 
        inPdfArticle = false;
433
 
        isRaster = false;
434
 
        Sizing = false;
435
 
        toPixmap = false;
436
 
        UseEmbedded = true;
437
 
        IRender = Intent_Relative_Colorimetric;
438
 
        EmProfile = "";
439
 
        Groups.clear();
440
 
        LayerNr = m_Doc->activeLayer();
441
 
        ScaleType = true;
442
 
        AspectRatio = true;
443
 
        Reverse = false;
444
 
        NamedLStyle = "";
445
 
        DashValues.clear();
446
 
        DashOffset = 0;
447
 
        fillRule = true;
448
 
        doOverprint = false;
449
 
        fill_gradient = VGradient(VGradient::linear);
450
 
        fill_gradient.clearStops();
451
 
        if (fillColorVal != CommonStrings::None)
452
 
        {
453
 
                const ScColor& col = m_Doc->PageColors[fillColorVal];
454
 
                QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
455
 
                fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, fillColorVal, 100);
456
 
                fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, fillColorVal, 100);
457
 
        }
458
 
        else
459
 
        {
460
 
                if (m_Doc->toolSettings.dBrush != CommonStrings::None)
461
 
                {
462
 
                        const ScColor& col = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
463
 
                        QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
464
 
                        fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
465
 
                        fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
466
 
                }
467
 
                else
468
 
                {
469
 
                        if (lineColorVal != CommonStrings::None)
470
 
                        {
471
 
                                const ScColor& col = m_Doc->PageColors[lineColorVal];
472
 
                                QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
473
 
                                fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, lineColorVal, 100);
474
 
                                fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, lineColorVal, 100);
475
 
                        }
476
 
                        else
477
 
                        {
478
 
                                if (m_Doc->toolSettings.dPen != CommonStrings::None)
479
 
                                {
480
 
                                        const ScColor& col = m_Doc->PageColors[m_Doc->toolSettings.dPen];
481
 
                                        QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
482
 
                                        fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
483
 
                                        fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
484
 
                                }
485
 
                                else if (m_Doc->PageColors.contains("Black"))
486
 
                                {
487
 
                                        const ScColor& col = m_Doc->PageColors["Black"];
488
 
                                        QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
489
 
                                        fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100);
490
 
                                        fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100);
491
 
                                }
492
 
                        }
493
 
                }
494
 
        }
495
 
        firstLineOffsetP = FLOPRealGlyphHeight;
496
 
        Cols = m_Doc->toolSettings.dCols;
497
 
        ColGap = m_Doc->toolSettings.dGap;
498
 
        LeftLink = 0;
499
 
        RightLink = 0;
500
 
        TopLink = 0;
501
 
        BottomLink = 0;
502
 
        LeftLinkID = 0;
503
 
        RightLinkID = 0;
504
 
        TopLinkID = 0;
505
 
        BottomLinkID = 0;
506
 
        LeftLine = 0;
507
 
        RightLine = false;
508
 
        TopLine = false;
509
 
        BottomLine = false;
510
 
        isTableItem = false;
511
 
        isSingleSel = false;
512
 
        Dirty = false;
513
 
        invalid = true;
514
 
        isGroupControl = false;
515
 
        groupsLastItem = 0;
516
 
        ChangedMasterItem = false;
517
 
        isEmbedded = false;
518
 
        OnMasterPage = m_Doc->currentPage()->pageName();
519
 
        m_startArrowIndex = m_Doc->toolSettings.dStartArrow;
520
 
        m_endArrowIndex = m_Doc->toolSettings.dEndArrow;
521
 
        effectsInUse.clear();
522
 
        //Page Item Attributes
523
 
        pageItemAttributes.clear();
524
 
        for(ObjAttrVector::Iterator objAttrIt = m_Doc->docItemAttributes.begin() ; objAttrIt != m_Doc->docItemAttributes.end(); ++objAttrIt )
525
 
        {
526
 
                if (((*objAttrIt).autoaddto=="textframes" && m_ItemType==TextFrame) ||
527
 
                        ((*objAttrIt).autoaddto=="imageframes" && m_ItemType==ImageFrame)
528
 
                        )
529
 
                        pageItemAttributes.append(*objAttrIt);
530
 
        }
531
 
        tempImageFile = NULL;
532
 
        isInlineImage = false;
533
 
}
534
 
 
535
 
void PageItem::setXPos(const double newXPos, bool drawingOnly)
536
 
{
537
 
        Xpos = newXPos;
538
 
        if (drawingOnly || m_Doc->isLoading())
539
 
                return;
540
 
        checkChanges();
541
 
        emit position(Xpos, Ypos);
542
 
}
543
 
 
544
 
void PageItem::setYPos(const double newYPos, bool drawingOnly)
545
 
{
546
 
        Ypos = newYPos;
547
 
        if (drawingOnly || m_Doc->isLoading())
548
 
                return;
549
 
        checkChanges();
550
 
        emit position(Xpos, Ypos);
551
 
}
552
 
 
553
 
void PageItem::setXYPos(const double newXPos, const double newYPos, bool drawingOnly)
554
 
{
555
 
        Xpos = newXPos;
556
 
        Ypos = newYPos;
557
 
        if (drawingOnly || m_Doc->isLoading())
558
 
                return;
559
 
        checkChanges();
560
 
        emit position(Xpos, Ypos);
561
 
}
562
 
 
563
 
void PageItem::moveBy(const double dX, const double dY, bool drawingOnly)
564
 
{
565
 
        if (dX==0.0 && dY==0.0)
566
 
                return;
567
 
        invalid = true;
568
 
        if (dX!=0.0)
569
 
                Xpos+=dX;
570
 
        if (dY!=0.0)
571
 
                Ypos+=dY;
572
 
        if (drawingOnly || m_Doc->isLoading())
573
 
                return;
574
 
        checkChanges();
575
 
        emit position(Xpos, Ypos);
576
 
}
577
 
 
578
 
void PageItem::setWidth(const double newWidth)
579
 
{
580
 
        Width = newWidth;
581
 
        updateConstants();
582
 
        checkChanges();
583
 
        emit widthAndHeight(Width, Height);
584
 
}
585
 
 
586
 
void PageItem::setHeight(const double newHeight)
587
 
{
588
 
        Height = newHeight;
589
 
        updateConstants();
590
 
        checkChanges();
591
 
        emit widthAndHeight(Width, Height);
592
 
}
593
 
 
594
 
void PageItem::setWidthHeight(const double newWidth, const double newHeight, bool drawingOnly)
595
 
{
596
 
        Width = newWidth;
597
 
        Height = newHeight;
598
 
        updateConstants();
599
 
        if (drawingOnly)
600
 
                return;
601
 
        checkChanges();
602
 
        emit widthAndHeight(Width, Height);
603
 
}
604
 
 
605
 
void PageItem::setWidthHeight(const double newWidth, const double newHeight)
606
 
{
607
 
        Width = newWidth;
608
 
        Height = newHeight;
609
 
        updateConstants();
610
 
        checkChanges();
611
 
        emit widthAndHeight(Width, Height);
612
 
}
613
 
 
614
 
void PageItem::resizeBy(const double dH, const double dW)
615
 
{
616
 
        if (dH==0.0 && dW==0.0)
617
 
                return;
618
 
        if (dH!=0.0)
619
 
                Width+=dH;
620
 
        if (dW!=0.0)
621
 
                Height+=dW;
622
 
        updateConstants();
623
 
        checkChanges();
624
 
        emit widthAndHeight(Width, Height);
625
 
}
626
 
 
627
 
void PageItem::setRotation(const double newRotation, bool drawingOnly)
628
 
{
629
 
        Rot=newRotation;
630
 
        checkChanges();
631
 
        if (drawingOnly || m_Doc->isLoading())
632
 
                return;
633
 
        emit rotation(Rot);
634
 
}
635
 
 
636
 
void PageItem::rotateBy(const double dR)
637
 
{
638
 
        if (dR==0.0)
639
 
                return;
640
 
        Rot+=dR;
641
 
        checkChanges();
642
 
        emit rotation(Rot);
643
 
}
644
 
 
645
 
void PageItem::setSelected(const bool toSelect)
646
 
{
647
 
        Select=toSelect;
648
 
}
649
 
 
650
 
void PageItem::setImageXScale(const double newImageXScale)
651
 
{
652
 
        LocalScX=newImageXScale;
653
 
        checkChanges();
654
 
        emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
655
 
}
656
 
 
657
 
void PageItem::setImageYScale(const double newImageYScale)
658
 
{
659
 
        LocalScY=newImageYScale;
660
 
        checkChanges();
661
 
        emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
662
 
}
663
 
 
664
 
void PageItem::setImageXYScale(const double newImageXScale, const double newImageYScale)
665
 
{
666
 
        LocalScX=newImageXScale;
667
 
        LocalScY=newImageYScale;
668
 
        checkChanges();
669
 
        emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
670
 
}
671
 
 
672
 
void PageItem::setImageXOffset(const double newImageXOffset)
673
 
{
674
 
        LocalX=newImageXOffset;
675
 
        checkChanges();
676
 
        emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
677
 
}
678
 
 
679
 
void PageItem::setImageYOffset(const double newImageYOffset)
680
 
{
681
 
        LocalY=newImageYOffset;
682
 
        checkChanges();
683
 
        emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
684
 
}
685
 
 
686
 
void PageItem::setImageXYOffset(const double newImageXOffset, const double newImageYOffset)
687
 
{
688
 
        LocalX=newImageXOffset;
689
 
        LocalY=newImageYOffset;
690
 
        checkChanges();
691
 
        emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
692
 
}
693
 
 
694
 
void PageItem::moveImageXYOffsetBy(const double dX, const double dY)
695
 
{
696
 
        if (dX==0.0 && dY==0.0)
697
 
                return;
698
 
        if (dX!=0.0)
699
 
                LocalX+=dX;
700
 
        if (dY!=0.0)
701
 
                LocalY+=dY;
702
 
        checkChanges();
703
 
        emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
704
 
}
705
 
 
706
 
void PageItem::setReversed(bool newReversed)
707
 
{
708
 
        Reverse=newReversed;
709
 
}
710
 
 
711
 
 
712
 
/// returns true if text overflows
713
 
bool PageItem::frameOverflows() const
714
 
{
715
 
#ifndef NLS_PROTO
716
 
        // Fix #6991 : "Text overflow" warning when there is a text underflow in fact
717
 
        /*return NextBox == NULL && itemText.length() > static_cast<int>(MaxChars);*/
718
 
        return ( NextBox == NULL )
719
 
               && ( static_cast<int> ( firstChar ) < itemText.length() )
720
 
                   // Fix #7766 : scribus.textOverflows() returns 0 if there is no place for the overflow mark
721
 
               /*&& ( firstChar < MaxChars )*/
722
 
                   && ( firstChar <= MaxChars )
723
 
               && ( itemText.length() > static_cast<int> ( MaxChars ) );
724
 
#else
725
 
        return false; // FIXME:NLS
726
 
#endif
727
 
}
728
 
 
729
 
int PageItem::firstInFrame() const
730
 
{
731
 
        return firstChar;
732
 
}
733
 
int PageItem::lastInFrame() const
734
 
{
735
 
#ifndef NLS_PROTO
736
 
        return qMin(signed(MaxChars), itemText.length()) - 1;
737
 
#else
738
 
        return itemText.length() - 1;
739
 
#endif
740
 
}
741
 
 
742
 
 
743
 
void PageItem::link(PageItem* nxt)
744
 
{
745
 
        assert( !nextInChain() );
746
 
        assert( !nxt->prevInChain() );
747
 
        for (PageItem* ff=nxt; ff; ff=ff->nextInChain())
748
 
        {
749
 
                assert (ff != this);
750
 
        }
751
 
        // Append only if necessary to avoid the
752
 
        // charstyle: access at end of text warning
753
 
        if (nxt->itemText.length() > 0)
754
 
                itemText.append(nxt->itemText);
755
 
        NextBox = nxt;
756
 
        nxt->BackBox = this;
757
 
        // update AutoText
758
 
        if (isAutoText)
759
 
        {
760
 
                PageItem* after = nxt;
761
 
                while (after)
762
 
                {
763
 
                        after->isAutoText = true;
764
 
                        m_Doc->LastAuto = after;
765
 
                        after = after->NextBox;
766
 
                }
767
 
        }
768
 
        else if (nxt->isAutoText)
769
 
        {
770
 
                PageItem* before = this;
771
 
                while (before)
772
 
                {
773
 
                        before->isAutoText = true;
774
 
                        m_Doc->FirstAuto = before;
775
 
                        before = before->BackBox;
776
 
                }
777
 
        }
778
 
        invalid = true;
779
 
        while (nxt)
780
 
        {
781
 
                nxt->itemText = itemText;
782
 
                nxt->invalid = true;
783
 
                nxt->firstChar = 0;
784
 
                nxt = nxt->NextBox;
785
 
        }
786
 
        if (UndoManager::undoEnabled())
787
 
        {
788
 
                ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >(UndoManager::LinkTextFrame);
789
 
                is->set("LINK_TEXT_FRAME", "linkTextFrame");
790
 
                is->setItem(std::pair<PageItem*, PageItem*>(this, NextBox));
791
 
                undoManager->action(this, is);
792
 
        }
793
 
}
794
 
 
795
 
void PageItem::unlink()
796
 
{
797
 
        if( NextBox )
798
 
        {
799
 
                PageItem *undoNextBox=NextBox;
800
 
                // make sure lastInFrame is valid
801
 
                layout();
802
 
                /*
803
 
                //<< CB #6332: Stop the StoryText cut and break and act like other publishing apps
804
 
                // move following text to new StoryText
805
 
                itemText.select(lastInFrame()+1, itemText.length()-lastInFrame()-1);
806
 
                */
807
 
                StoryText follow(m_Doc);
808
 
                /*
809
 
                follow.setDefaultStyle(itemText.defaultStyle());
810
 
                follow.insert(0, itemText, true);
811
 
                // remove following text from this chain
812
 
                itemText.removeSelection();
813
 
                //>> 
814
 
                */
815
 
                // update auto pointers
816
 
                if (isAutoText)
817
 
                {
818
 
                        PageItem* before = this;
819
 
                        while (before) 
820
 
                        {
821
 
                                before->isAutoText = false;
822
 
                                before = before->BackBox;
823
 
                        }
824
 
                        m_Doc->FirstAuto = NextBox;
825
 
                }
826
 
                // link following frames to new text
827
 
                NextBox->firstChar = 0;
828
 
                NextBox->BackBox = NULL;
829
 
                while (NextBox) {
830
 
                        NextBox->itemText = follow;
831
 
                        NextBox->invalid = true;
832
 
                        NextBox->firstChar = 0;
833
 
                        NextBox = NextBox->NextBox;
834
 
                }
835
 
                // NextBox == NULL now
836
 
                NextBox = NULL;
837
 
                if (UndoManager::undoEnabled())
838
 
                {
839
 
                        ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >(UndoManager::UnlinkTextFrame);
840
 
                        is->set("UNLINK_TEXT_FRAME", "unlinkTextFrame");
841
 
                        is->setItem(std::pair<PageItem*, PageItem*>(this, undoNextBox));
842
 
                        undoManager->action(this, is);
843
 
                }
844
 
        }
845
 
}
846
 
 
847
 
 
848
 
void PageItem::dropLinks()
849
 
{
850
 
        // update auto pointers
851
 
        if (isAutoText && NextBox == 0)
852
 
        {
853
 
                m_Doc->LastAuto = BackBox;
854
 
        }
855
 
        if (isAutoText && BackBox == 0)
856
 
        {
857
 
                m_Doc->FirstAuto = NextBox;
858
 
        }
859
 
        isAutoText = false;
860
 
 
861
 
        // leave text in remaining chain
862
 
        PageItem* before = BackBox;
863
 
        PageItem* after = NextBox;
864
 
        if (after != 0 || before != 0)
865
 
        {
866
 
                itemText = StoryText(m_Doc);
867
 
                if (before)
868
 
                        before->NextBox = after;
869
 
                if (after) 
870
 
                {
871
 
                        after->BackBox = before;
872
 
                        while (after)
873
 
                        { 
874
 
                                after->invalid = true;
875
 
                                after->firstChar = 0;
876
 
                                after = after->NextBox;
877
 
                        }
878
 
                }
879
 
                // JG we should set BackBox and NextBox to NULL at a point
880
 
                BackBox = NextBox = NULL;
881
 
        }
882
 
}
883
 
 
884
 
/// tests if a character is displayed by this frame
885
 
bool PageItem::frameDisplays(int textpos) const
886
 
{
887
 
#ifndef NLS_PROTO
888
 
        return 0 <= textpos && textpos < signed(MaxChars) &&  textpos < itemText.length();
889
 
#else
890
 
        return true; // FIXME:NLS
891
 
#endif
892
 
}
893
 
 
894
 
 
895
 
/// returns the style at the current charpos
896
 
const ParagraphStyle& PageItem::currentStyle() const
897
 
{
898
 
        if (frameDisplays(CPos))
899
 
                return itemText.paragraphStyle(CPos);
900
 
        else
901
 
                return itemText.defaultStyle();
902
 
}
903
 
 
904
 
/// returns the style at the current charpos for changing
905
 
ParagraphStyle& PageItem::changeCurrentStyle()
906
 
{
907
 
        if (frameDisplays(CPos))
908
 
                return const_cast<ParagraphStyle&>(itemText.paragraphStyle(CPos));
909
 
        else
910
 
                return const_cast<ParagraphStyle&>(itemText.defaultStyle());
911
 
}
912
 
 
913
 
/// returns the style at the current charpos
914
 
const CharStyle& PageItem::currentCharStyle() const
915
 
{
916
 
        if (frameDisplays(CPos))
917
 
                return itemText.charStyle(CPos);
918
 
        else
919
 
                return itemText.defaultStyle().charStyle();
920
 
}
921
 
 
922
 
void PageItem::setTextToFrameDistLeft(double newLeft)
923
 
{
924
 
        Extra=newLeft;
925
 
        emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
926
 
}
927
 
 
928
 
void PageItem::setTextToFrameDistRight(double newRight)
929
 
{
930
 
        RExtra=newRight;
931
 
        emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
932
 
}
933
 
 
934
 
void PageItem::setTextToFrameDistTop(double newTop)
935
 
{
936
 
        TExtra=newTop;
937
 
        emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
938
 
}
939
 
 
940
 
void PageItem::setTextToFrameDistBottom(double newBottom)
941
 
{
942
 
        BExtra=newBottom;
943
 
        emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
944
 
}
945
 
 
946
 
void PageItem::setTextToFrameDist(double newLeft, double newRight, double newTop, double newBottom)
947
 
{
948
 
        Extra=newLeft;
949
 
        RExtra=newRight;
950
 
        TExtra=newTop;
951
 
        BExtra=newBottom;
952
 
        emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
953
 
}
954
 
 
955
 
double PageItem::gridOffset() const { return m_Doc->typographicSettings.offsetBaseGrid; }
956
 
double PageItem::gridDistance() const { return m_Doc->typographicSettings.valueBaseGrid; }
957
 
 
958
 
void PageItem::setGridOffset(double) { } // FIXME
959
 
void PageItem::setGridDistance(double) { } // FIXME
960
 
void PageItem::setColumns(int n) 
961
 
{
962
 
        Cols = qMax(1, n); //FIXME: undo
963
 
}
964
 
void PageItem::setColumnGap(double gap)
965
 
{
966
 
        ColGap = gap; //FIXME: undo
967
 
}
968
 
 
969
 
void PageItem::setCornerRadius(double newRadius)
970
 
{
971
 
        RadRect=newRadius;
972
 
        emit cornerRadius(RadRect);
973
 
}
974
 
 
975
 
 
976
 
 
977
 
 
978
 
 
979
 
 
980
 
 
981
 
 
982
 
 
983
 
/** Paints the item.
984
 
    CHANGE: cullingArea is in doc coordinates!
985
 
 */
986
 
void PageItem::DrawObj(ScPainter *p, QRectF cullingArea)
987
 
{
988
 
//      qDebug << "PageItem::DrawObj";
989
 
        double sc;
990
 
        if (!m_Doc->DoDrawing)
991
 
        {
992
 
//              Tinput = false;
993
 
                return;
994
 
        }
995
 
        if (cullingArea.isNull())
996
 
        {
997
 
                cullingArea = QRectF(QPointF(m_Doc->minCanvasCoordinate.x(), m_Doc->minCanvasCoordinate.y()), 
998
 
                                                         QPointF(m_Doc->maxCanvasCoordinate.x(), m_Doc->maxCanvasCoordinate.y())).toAlignedRect();
999
 
        }
1000
 
        
1001
 
        DrawObj_Pre(p, sc);
1002
 
        if (m_Doc->layerOutline(LayerNr))
1003
 
        {
1004
 
                if ((itemType()==TextFrame || itemType()==ImageFrame || itemType()==PathText || itemType()==Line || itemType()==PolyLine) && (!isGroupControl))
1005
 
                        DrawObj_Item(p, cullingArea, sc);
1006
 
        }
1007
 
        else
1008
 
        {
1009
 
                if (!isGroupControl)
1010
 
                        DrawObj_Item(p, cullingArea, sc);
1011
 
        }
1012
 
        DrawObj_Post(p);
1013
 
}
1014
 
 
1015
 
void PageItem::DrawObj_Pre(ScPainter *p, double &sc)
1016
 
{
1017
 
        ScribusView* view = m_Doc->view();
1018
 
        sc = view->scale();
1019
 
        p->save();
1020
 
        if (!isEmbedded)
1021
 
                p->translate(Xpos, Ypos);
1022
 
        p->rotate(Rot);
1023
 
        if (m_Doc->layerOutline(LayerNr))
1024
 
        {
1025
 
                p->setPen(m_Doc->layerMarker(LayerNr), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1026
 
                p->setFillMode(ScPainter::None);
1027
 
                p->setBrushOpacity(1.0);
1028
 
                p->setPenOpacity(1.0);
1029
 
        }
1030
 
        else
1031
 
        {
1032
 
        if (!isGroupControl)
1033
 
        {
1034
 
                if (fillBlendmode() != 0)
1035
 
                        p->beginLayer(1.0 - fillTransparency(), fillBlendmode());
1036
 
 
1037
 
                p->setLineWidth(m_lineWidth);
1038
 
                if (GrType != 0)
1039
 
                {
1040
 
                        if (GrType == 8)
1041
 
                        {
1042
 
                                if ((patternVal.isEmpty()) || (!m_Doc->docPatterns.contains(patternVal)))
1043
 
                                {
1044
 
                                        p->fill_gradient = VGradient(VGradient::linear);
1045
 
                                        if (fillColor() != CommonStrings::None)
1046
 
                                        {
1047
 
                                                p->setBrush(fillQColor);
1048
 
                                                p->setFillMode(ScPainter::Solid);
1049
 
                                        }
1050
 
                                        else
1051
 
                                                p->setFillMode(ScPainter::None);
1052
 
                                        if ((!patternVal.isEmpty()) && (!m_Doc->docPatterns.contains(patternVal)))
1053
 
                                        {
1054
 
                                                GrType = 0;
1055
 
                                                patternVal = "";
1056
 
                                        }
1057
 
                                }
1058
 
                                else
1059
 
                                {
1060
 
                                        p->setPattern(&m_Doc->docPatterns[patternVal], patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
1061
 
                                        p->setFillMode(ScPainter::Pattern);
1062
 
                                }
1063
 
                        }
1064
 
                        else
1065
 
                        {
1066
 
                                if (fill_gradient.Stops() < 2) // fall back to solid filling if there are not enough colorstops in the gradient.
1067
 
                                {
1068
 
                                        if (fillColor() != CommonStrings::None)
1069
 
                                        {
1070
 
                                                p->setBrush(fillQColor);
1071
 
                                                p->setFillMode(ScPainter::Solid);
1072
 
                                        }
1073
 
                                        else
1074
 
                                                p->setFillMode(ScPainter::None);
1075
 
                                }
1076
 
                                else
1077
 
                                {
1078
 
                                        p->setFillMode(ScPainter::Gradient);
1079
 
                                        p->fill_gradient = fill_gradient;
1080
 
                                        QMatrix grm;
1081
 
                                        grm.rotate(Rot);
1082
 
                                        FPointArray gra;
1083
 
                                        switch (GrType)
1084
 
                                        {
1085
 
                                                case 1:
1086
 
                                                case 2:
1087
 
                                                case 3:
1088
 
                                                case 4:
1089
 
                                                case 6:
1090
 
                                                        p->setGradient(VGradient::linear, FPoint(GrStartX, GrStartY), FPoint(GrEndX, GrEndY));
1091
 
                                                        break;
1092
 
                                                case 5:
1093
 
                                                case 7:
1094
 
                                                        gra.setPoints(2, GrStartX, GrStartY, GrEndX, GrEndY);
1095
 
                                                        p->setGradient(VGradient::radial, gra.point(0), gra.point(1), gra.point(0));
1096
 
                                                        break;
1097
 
                                        }
1098
 
                                }
1099
 
                        }
1100
 
                }
1101
 
                else
1102
 
                {
1103
 
                        p->fill_gradient = VGradient(VGradient::linear);
1104
 
                        if (fillColor() != CommonStrings::None)
1105
 
                        {
1106
 
                                p->setBrush(fillQColor);
1107
 
                                p->setFillMode(ScPainter::Solid);
1108
 
                        }
1109
 
                        else
1110
 
                                p->setFillMode(ScPainter::None);
1111
 
                }
1112
 
                if (lineColor() != CommonStrings::None)
1113
 
                {
1114
 
//                      if ((m_lineWidth == 0) && ! asLine())
1115
 
//                              p->setLineWidth(0);
1116
 
//                      else
1117
 
//                      {
1118
 
                                p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin);
1119
 
                                if (DashValues.count() != 0)
1120
 
                                        p->setDash(DashValues, DashOffset);
1121
 
//                      }
1122
 
                }
1123
 
                else
1124
 
                        p->setLineWidth(0);
1125
 
                if (fillBlendmode() == 0)
1126
 
                        p->setBrushOpacity(1.0 - fillTransparency());
1127
 
                if (lineBlendmode() == 0)
1128
 
                        p->setPenOpacity(1.0 - lineTransparency());
1129
 
                p->setFillRule(fillRule);
1130
 
                }
1131
 
        }
1132
 
}
1133
 
 
1134
 
void PageItem::DrawObj_Post(ScPainter *p)
1135
 
{
1136
 
        bool doStroke=true;
1137
 
        ScribusView* view = m_Doc->view();
1138
 
        if (!isGroupControl)
1139
 
        {
1140
 
                if (m_Doc->layerOutline(LayerNr))
1141
 
                {
1142
 
                        if (itemType()!=Line)
1143
 
                        {
1144
 
                                p->setPen(m_Doc->layerMarker(LayerNr), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1145
 
                                p->setFillMode(ScPainter::None);
1146
 
                                p->setBrushOpacity(1.0);
1147
 
                                p->setPenOpacity(1.0);
1148
 
                                if (itemType()==PolyLine)
1149
 
                                        p->setupPolygon(&PoLine, false);
1150
 
                                else if (itemType() == PathText)
1151
 
                                {
1152
 
                                        if (PoShow)
1153
 
                                                p->setupPolygon(&PoLine, false);
1154
 
                                        else
1155
 
                                                doStroke = false;
1156
 
                                }
1157
 
                                else
1158
 
                                        p->setupPolygon(&PoLine);
1159
 
                                if (doStroke)
1160
 
                                        p->strokePath();
1161
 
                                if (itemType()==ImageFrame)
1162
 
                                {
1163
 
                                        if (imageClip.size() != 0)
1164
 
                                        {
1165
 
                                                p->setupPolygon(&imageClip);
1166
 
                                                p->strokePath();
1167
 
                                        }
1168
 
                                }
1169
 
                        }
1170
 
                }
1171
 
                else
1172
 
                {
1173
 
                        if (fillBlendmode() != 0)
1174
 
                                p->endLayer();
1175
 
                        if (itemType()==PathText || itemType()==PolyLine || itemType()==Line)
1176
 
                                doStroke=false;
1177
 
                        if ((doStroke) && (!m_Doc->RePos))
1178
 
                        {
1179
 
                                if (lineBlendmode() != 0)
1180
 
                                        p->beginLayer(1.0 - lineTransparency(), lineBlendmode());
1181
 
//                              if (lineColor() != CommonStrings::None)
1182
 
//                              {
1183
 
//                                      p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin);
1184
 
//                                      if (DashValues.count() != 0)
1185
 
//                                              p->setDash(DashValues, DashOffset);
1186
 
//                              }
1187
 
//                              else
1188
 
//                                      p->setLineWidth(0);
1189
 
                                if (!isTableItem)
1190
 
                                {
1191
 
                                        if ((itemType() == LatexFrame) || (itemType() == ImageFrame))
1192
 
                                                p->setupPolygon(&PoLine);
1193
 
                                        if (NamedLStyle.isEmpty())
1194
 
                                        {
1195
 
                                                if (lineColor() != CommonStrings::None)
1196
 
                                                {
1197
 
                                                        p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin);
1198
 
                                                        if (DashValues.count() != 0)
1199
 
                                                                p->setDash(DashValues, DashOffset);
1200
 
                                                        p->strokePath();
1201
 
                                                }
1202
 
                                        }
1203
 
                                        else
1204
 
                                        {
1205
 
                                                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
1206
 
                                                QColor tmp;
1207
 
                                                for (int it = ml.size()-1; it > -1; it--)
1208
 
                                                {
1209
 
                                                        struct SingleLine& sl = ml[it];
1210
 
                                                        // Qt4 if ((!sl.Color != CommonStrings::None) && (sl.Width != 0))
1211
 
                                                        if (sl.Color != CommonStrings::None) // && (sl.Width != 0))
1212
 
                                                        {
1213
 
                                                                SetQColor(&tmp, sl.Color, sl.Shade);
1214
 
                                                                p->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), static_cast<Qt::PenCapStyle>(sl.LineEnd), static_cast<Qt::PenJoinStyle>(sl.LineJoin));
1215
 
                                                                p->strokePath();
1216
 
                                                        }
1217
 
                                                }
1218
 
                                        }
1219
 
                                }
1220
 
                                if (lineBlendmode() != 0)
1221
 
                                        p->endLayer();
1222
 
                        }
1223
 
                }
1224
 
        }
1225
 
        if ((!isEmbedded) && (!m_Doc->RePos))
1226
 
        {
1227
 
                double aestheticFactor(5.0);
1228
 
                double scpInv = 1.0 / (qMax(view->scale(), 1.0) * aestheticFactor);
1229
 
                if (!isGroupControl)
1230
 
                {
1231
 
                        if ((Frame) && (m_Doc->guidesSettings.framesShown) && ((itemType() == ImageFrame) || (itemType() == LatexFrame) || (itemType() == PathText)))
1232
 
                        {
1233
 
                                p->setPen(PrefsManager::instance()->appPrefs.DFrameNormColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1234
 
                                if ((isBookmark) || (m_isAnnotation))
1235
 
                                        p->setPen(PrefsManager::instance()->appPrefs.DFrameAnnotationColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1236
 
                                if ((BackBox != 0) || (NextBox != 0))
1237
 
                                        p->setPen(PrefsManager::instance()->appPrefs.DFrameLinkColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1238
 
                                if (m_Locked)
1239
 
                                        p->setPen(PrefsManager::instance()->appPrefs.DFrameLockColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1240
 
                                p->setFillMode(0);
1241
 
                                if (itemType()==PathText)
1242
 
                                {
1243
 
                                        if (Clip.count() != 0)
1244
 
                                        {
1245
 
                                                FPointArray tclip;
1246
 
                                                FPoint np = FPoint(Clip.point(0));
1247
 
                                                tclip.resize(2);
1248
 
                                                tclip.setPoint(0, np);
1249
 
                                                tclip.setPoint(1, np);
1250
 
                                                for (int a = 1; a < Clip.size(); ++a)
1251
 
                                                {
1252
 
                                                        np = FPoint(Clip.point(a));
1253
 
                                                        tclip.putPoints(tclip.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y());
1254
 
                                                }
1255
 
                                                np = FPoint(Clip.point(0));
1256
 
                                                tclip.putPoints(tclip.size(), 2, np.x(), np.y(), np.x(), np.y());
1257
 
                                                p->setupPolygon(&tclip);
1258
 
                                        }
1259
 
                                }
1260
 
                                else
1261
 
// Ugly Hack to fix rendering problems with cairo >=1.5.10 && <1.8.0 follows
1262
 
#ifdef HAVE_CAIRO
1263
 
        #if ((CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 10)) && (CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 8, 0)))
1264
 
                                        p->setupPolygon(&PoLine, false);
1265
 
        #else
1266
 
                                        p->setupPolygon(&PoLine);
1267
 
        #endif
1268
 
#else
1269
 
                                        p->setupPolygon(&PoLine);
1270
 
#endif
1271
 
                                p->strokePath();
1272
 
                        }
1273
 
                }
1274
 
                if ((m_Doc->guidesSettings.framesShown) && textFlowUsesContourLine() && (ContourLine.size() != 0))
1275
 
                {
1276
 
                        p->setPen(Qt::darkGray, 1.0 / qMax(view->scale(), 1.0), Qt::DotLine, Qt::FlatCap, Qt::MiterJoin);
1277
 
// Ugly Hack to fix rendering problems with cairo >=1.5.10 && <1.8.0 follows
1278
 
#ifdef HAVE_CAIRO
1279
 
        #if ((CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 10)) && (CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 8, 0)))
1280
 
                        p->setupPolygon(&ContourLine, false);
1281
 
        #else
1282
 
                        p->setupPolygon(&ContourLine);
1283
 
        #endif
1284
 
#else
1285
 
                        p->setupPolygon(&ContourLine);
1286
 
#endif
1287
 
                        p->strokePath();
1288
 
                }
1289
 
                if ((m_Doc->guidesSettings.layerMarkersShown) && (m_Doc->layerCount() > 1) && (!m_Doc->layerOutline(LayerNr)) && ((isGroupControl) || (Groups.count() == 0)) && (!view->m_canvas->isPreviewMode()))
1290
 
                {
1291
 
                        p->setPen(Qt::black, 0.5/ m_Doc->view()->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1292
 
                        p->setPenOpacity(1.0);
1293
 
                        p->setBrush(m_Doc->layerMarker(LayerNr));
1294
 
                        p->setBrushOpacity(1.0);
1295
 
                        p->setFillMode(ScPainter::Solid);
1296
 
                        double ofwh = 10;
1297
 
                        double ofx = Width - ofwh/2;
1298
 
                        double ofy = Height - ofwh*3;
1299
 
                        p->drawRect(ofx, ofy, ofwh, ofwh);
1300
 
                }
1301
 
                //CB disabled for now
1302
 
                //if (m_Doc->m_Selection->findItem(this)!=-1)
1303
 
                //      drawLockedMarker(p);
1304
 
        }
1305
 
//      Tinput = false;
1306
 
        FrameOnly = false;
1307
 
        p->restore();
1308
 
}
1309
 
 
1310
 
void PageItem::DrawObj_Embedded(ScPainter *p, QRectF cullingArea, const CharStyle& style, PageItem* cembedded)
1311
 
{
1312
 
        if (!cembedded)
1313
 
                return;
1314
 
        if (!m_Doc->DoDrawing)
1315
 
                return;
1316
 
        QList<PageItem*> emG;
1317
 
        QStack<PageItem*> groupStack;
1318
 
        groupStack.clear();
1319
 
        emG.clear();
1320
 
        emG.append(cembedded);
1321
 
        if (cembedded->Groups.count() != 0)
1322
 
        {
1323
 
                for (int ga=0; ga<m_Doc->FrameItems.count(); ++ga)
1324
 
                {
1325
 
                        if (m_Doc->FrameItems.at(ga)->Groups.count() != 0)
1326
 
                        {
1327
 
                                if (m_Doc->FrameItems.at(ga)->Groups.top() == cembedded->Groups.top())
1328
 
                                {
1329
 
                                        if (m_Doc->FrameItems.at(ga)->ItemNr != cembedded->ItemNr)
1330
 
                                        {
1331
 
                                                if (!emG.contains(m_Doc->FrameItems.at(ga)))
1332
 
                                                        emG.append(m_Doc->FrameItems.at(ga));
1333
 
                                        }
1334
 
                                }
1335
 
                        }
1336
 
                }
1337
 
        }
1338
 
        for (int em = 0; em < emG.count(); ++em)
1339
 
        {
1340
 
                PageItem* embedded = emG.at(em);
1341
 
                if (embedded->isGroupControl)
1342
 
                {
1343
 
                        p->save();
1344
 
                        FPointArray cl = embedded->PoLine.copy();
1345
 
                        QMatrix mm;
1346
 
                        mm.translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
1347
 
                        if (style.baselineOffset() != 0)
1348
 
                                mm.translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
1349
 
                        mm.scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1350
 
                        mm.rotate(embedded->rotation());
1351
 
                        cl.map( mm );
1352
 
                        p->beginLayer(1.0 - embedded->fillTransparency(), embedded->fillBlendmode(), &cl);
1353
 
                        groupStack.push(embedded->groupsLastItem);
1354
 
                        continue;
1355
 
                }
1356
 
                p->save();
1357
 
                double x = embedded->xPos();
1358
 
                double y = embedded->yPos();
1359
 
                embedded->Xpos = embedded->gXpos;
1360
 
                embedded->Ypos = (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos;
1361
 
                p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
1362
 
                if (style.baselineOffset() != 0)
1363
 
                {
1364
 
                        p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
1365
 
                        embedded->Ypos -= embedded->gHeight * (style.baselineOffset() / 1000.0);
1366
 
                }
1367
 
                p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1368
 
                embedded->Dirty = Dirty;
1369
 
                embedded->invalid = true;
1370
 
                double sc;
1371
 
                double pws = embedded->m_lineWidth;
1372
 
                embedded->DrawObj_Pre(p, sc);
1373
 
                switch(embedded->itemType())
1374
 
                {
1375
 
                        case ImageFrame:
1376
 
                        case TextFrame:
1377
 
                        case LatexFrame:
1378
 
                        case Polygon:
1379
 
                        case PathText:
1380
 
                                embedded->DrawObj_Item(p, cullingArea, sc);
1381
 
                                break;
1382
 
                        case Line:
1383
 
                        case PolyLine:
1384
 
                                embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1385
 
                                embedded->DrawObj_Item(p, cullingArea, sc);
1386
 
                                break;
1387
 
                        default:
1388
 
                                break;
1389
 
                }
1390
 
                embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1391
 
                embedded->DrawObj_Post(p);
1392
 
                embedded->Xpos = x;
1393
 
                embedded->Ypos = y;
1394
 
                p->restore();
1395
 
                if (groupStack.count() != 0)
1396
 
                {
1397
 
                        while (embedded == groupStack.top())
1398
 
                        {
1399
 
                                p->endLayer();
1400
 
                                p->restore();
1401
 
                                groupStack.pop();
1402
 
                                if (groupStack.count() == 0)
1403
 
                                        break;
1404
 
                        }
1405
 
                }
1406
 
                embedded->m_lineWidth = pws;
1407
 
        }
1408
 
        for (int em = 0; em < emG.count(); ++em)
1409
 
        {
1410
 
                PageItem* embedded = emG.at(em);
1411
 
                if (!embedded->isTableItem)
1412
 
                        continue;
1413
 
                p->save();
1414
 
                double x = embedded->xPos();
1415
 
                double y = embedded->yPos();
1416
 
                embedded->Xpos = embedded->gXpos;
1417
 
                embedded->Ypos = (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos;
1418
 
                p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
1419
 
                if (style.baselineOffset() != 0)
1420
 
                {
1421
 
                        p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
1422
 
                        embedded->Ypos -= embedded->gHeight * (style.baselineOffset() / 1000.0);
1423
 
                }
1424
 
                p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1425
 
                p->rotate(embedded->rotation());
1426
 
                double pws = embedded->m_lineWidth;
1427
 
                embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1428
 
                if ((embedded->lineColor() != CommonStrings::None) && (embedded->lineWidth() != 0.0))
1429
 
                {
1430
 
                        QColor tmp;
1431
 
                        embedded->SetQColor(&tmp, embedded->lineColor(), embedded->lineShade());
1432
 
                        if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine))
1433
 
                        {
1434
 
                                p->setPen(tmp, embedded->lineWidth(), embedded->PLineArt, Qt::SquareCap, embedded->PLineJoin);
1435
 
                                if (embedded->TopLine)
1436
 
                                        p->drawLine(FPoint(0.0, 0.0), FPoint(embedded->width(), 0.0));
1437
 
                                if (embedded->RightLine)
1438
 
                                        p->drawLine(FPoint(embedded->width(), 0.0), FPoint(embedded->width(), embedded->height()));
1439
 
                                if (embedded->BottomLine)
1440
 
                                        p->drawLine(FPoint(embedded->width(), embedded->height()), FPoint(0.0, embedded->height()));
1441
 
                                if (embedded->LeftLine)
1442
 
                                        p->drawLine(FPoint(0.0, embedded->height()), FPoint(0.0, 0.0));
1443
 
                        }
1444
 
                }
1445
 
                embedded->m_lineWidth = pws;
1446
 
                embedded->Xpos = x;
1447
 
                embedded->Ypos = y;
1448
 
                p->restore();
1449
 
        }
1450
 
}
1451
 
 
1452
 
 
1453
 
void PageItem::paintObj(QPainter *p)
1454
 
{
1455
 
        if ((!m_Doc->DoDrawing) || (m_Doc->RePos))
1456
 
        {
1457
 
                FrameOnly = false;
1458
 
                return;
1459
 
        }
1460
 
        double sc = m_Doc->view()->scale();
1461
 
        double handleSize = 6.0 / sc;
1462
 
        double halfSize = 3.0 / sc;
1463
 
        if ((!FrameOnly) && (!m_Doc->RePos))
1464
 
        {
1465
 
                if (!m_Doc->m_Selection->isEmpty())
1466
 
                {
1467
 
//                              qDebug() << "Item: " << ItemNr << "W: " << Width << "H: " << Height;
1468
 
                        if (Groups.count() == 0)
1469
 
                        {
1470
 
                                //Locked line colour selection
1471
 
                                if (m_Locked)
1472
 
                                        p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameLockColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1473
 
                                else
1474
 
                                        p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1475
 
                                p->setBrush(Qt::NoBrush);
1476
 
                                double lw2 = 1.0 / sc;
1477
 
                                double lw = 1.0 / sc;
1478
 
                                Qt::PenCapStyle le = Qt::FlatCap;
1479
 
                                if (NamedLStyle.isEmpty())
1480
 
                                {
1481
 
                                        lw2 = (m_lineWidth / 2.0)  / sc;
1482
 
                                        lw = qMax(m_lineWidth, 1.0)  / sc;
1483
 
                                        le = PLineEnd;
1484
 
                                }
1485
 
                                else
1486
 
                                {
1487
 
                                        multiLine ml = m_Doc->MLineStyles[NamedLStyle];
1488
 
                                        lw2 = (ml[ml.size()-1].Width / 2.0) / sc;
1489
 
                                        lw = qMax(ml[ml.size()-1].Width, 1.0) / sc;
1490
 
                                        le = static_cast<Qt::PenCapStyle>(ml[ml.size()-1].LineEnd);
1491
 
                                }
1492
 
                                //Draw our frame outline
1493
 
                                if (asLine())
1494
 
                                {
1495
 
                                        if (le != Qt::FlatCap)
1496
 
                                                p->drawRect(QRectF(-lw2, -lw2, Width+lw, lw));
1497
 
                                        else
1498
 
                                                p->drawRect(QRectF(-1 / sc, -lw2, Width, lw));
1499
 
                                }
1500
 
                                else
1501
 
                                        p->drawRect(QRectF(0, 0, Width, Height));
1502
 
//                              p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1503
 
                                p->setBrush(PrefsManager::instance()->appPrefs.DFrameColor);
1504
 
                                p->setPen(Qt::NoPen);
1505
 
                                if ((!m_Locked) && (!m_SizeLocked))
1506
 
                                {
1507
 
                                        if (! asLine())
1508
 
                                        {
1509
 
                                                p->drawRect(QRectF(0.0, 0.0, handleSize, handleSize));
1510
 
                                                p->drawRect(QRectF(Width - handleSize, Height - handleSize, handleSize, handleSize));
1511
 
                                                p->drawRect(QRectF(Width - handleSize, 0.0, handleSize, handleSize));
1512
 
                                                p->drawRect(QRectF(0.0, Height - handleSize, handleSize, handleSize));
1513
 
                                                if (Width > 6)
1514
 
                                                {
1515
 
                                                        p->drawRect(QRectF(Width / 2.0 - halfSize, Height - handleSize, handleSize, handleSize));
1516
 
                                                        p->drawRect(QRectF(Width / 2.0 - halfSize, 0.0, handleSize, handleSize));
1517
 
                                                }
1518
 
                                                if (Height > 6)
1519
 
                                                {
1520
 
                                                        p->drawRect(QRectF(Width - handleSize, Height / 2.0 - halfSize, handleSize, handleSize));
1521
 
                                                        p->drawRect(QRectF(0.0, Height / 2.0 - halfSize, handleSize, handleSize));
1522
 
                                                }
1523
 
                                        }
1524
 
                                        else
1525
 
                                        {
1526
 
                                                p->drawRect(QRectF(-halfSize, -halfSize, handleSize, handleSize));
1527
 
                                                p->drawRect(QRectF(Width + halfSize, -halfSize, -handleSize, handleSize));
1528
 
                                        }
1529
 
                                }
1530
 
                        }
1531
 
                        else
1532
 
                        {
1533
 
                                p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameGroupColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1534
 
                                p->setBrush(Qt::NoBrush);
1535
 
                                p->drawRect(QRectF(0.0, 0.0, Width, Height));
1536
 
                                if (m_Doc->m_Selection->count() == 1)
1537
 
                                {
1538
 
                                        p->setPen(Qt::NoPen);
1539
 
//                                      p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameGroupColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1540
 
                                        p->setBrush(PrefsManager::instance()->appPrefs.DFrameGroupColor);
1541
 
                                        p->drawRect(QRectF(0.0, 0.0, handleSize, handleSize));
1542
 
                                        p->drawRect(QRectF(Width - handleSize, Height - handleSize, handleSize, handleSize));
1543
 
                                        p->drawRect(QRectF(Width - handleSize, 0.0, handleSize, handleSize));
1544
 
                                        p->drawRect(QRectF(0.0, Height - handleSize, handleSize, handleSize));
1545
 
                                        if (Width > 6)
1546
 
                                        {
1547
 
                                                p->drawRect(QRectF(Width / 2.0 - halfSize, Height - handleSize, handleSize, handleSize));
1548
 
                                                p->drawRect(QRectF(Width / 2.0 - halfSize, 0.0, handleSize, handleSize));
1549
 
                                        }
1550
 
                                        if (Height > 6)
1551
 
                                        {
1552
 
                                                p->drawRect(QRectF(Width - handleSize, Height / 2.0 - halfSize, handleSize, handleSize));
1553
 
                                                p->drawRect(QRectF(0.0, Height / 2.0 - halfSize, handleSize, handleSize));
1554
 
                                        }
1555
 
                                }
1556
 
                        }
1557
 
                }
1558
 
        }
1559
 
        FrameOnly = false;
1560
 
}
1561
 
 
1562
 
QImage PageItem::DrawObj_toImage()
1563
 
{
1564
 
        QList<PageItem*> emG;
1565
 
        emG.clear();
1566
 
        double minx =  std::numeric_limits<double>::max();
1567
 
        double miny =  std::numeric_limits<double>::max();
1568
 
        double maxx = -std::numeric_limits<double>::max();
1569
 
        double maxy = -std::numeric_limits<double>::max();
1570
 
        if (Groups.count() != 0)
1571
 
        {
1572
 
                for (int ga=0; ga<m_Doc->Items->count(); ++ga)
1573
 
                {
1574
 
                        if (m_Doc->Items->at(ga)->Groups.count() != 0)
1575
 
                        {
1576
 
                                if (m_Doc->Items->at(ga)->Groups.top() == Groups.top())
1577
 
                                {
1578
 
                                        if (!emG.contains(m_Doc->Items->at(ga)))
1579
 
                                        {
1580
 
                                                emG.append(m_Doc->Items->at(ga));
1581
 
                                                PageItem *currItem = m_Doc->Items->at(ga);
1582
 
                                                double x1, x2, y1, y2;
1583
 
                                                currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
1584
 
                                                minx = qMin(minx, x1);
1585
 
                                                miny = qMin(miny, y1);
1586
 
                                                maxx = qMax(maxx, x2);
1587
 
                                                maxy = qMax(maxy, y2);
1588
 
                                        }
1589
 
                                }
1590
 
                        }
1591
 
                }
1592
 
                for (int em = 0; em < emG.count(); ++em)
1593
 
                {
1594
 
                        PageItem* currItem = emG.at(em);
1595
 
                        currItem->gXpos = currItem->xPos() - minx;
1596
 
                        currItem->gYpos = currItem->yPos() - miny;
1597
 
                        currItem->gWidth = maxx - minx;
1598
 
                        currItem->gHeight = maxy - miny;
1599
 
                }
1600
 
        }
1601
 
        else
1602
 
        {
1603
 
                double x1, x2, y1, y2;
1604
 
                getVisualBoundingRect(&x1, &y1, &x2, &y2);
1605
 
                minx = qMin(minx, x1);
1606
 
                miny = qMin(miny, y1);
1607
 
                maxx = qMax(maxx, x2);
1608
 
                maxy = qMax(maxy, y2);
1609
 
                gXpos = xPos() - minx;
1610
 
                gYpos = yPos() - miny;
1611
 
                gWidth = maxx - minx;
1612
 
                gHeight = maxy - miny;
1613
 
                emG.append(this);
1614
 
        }
1615
 
        return DrawObj_toImage(emG);
1616
 
}
1617
 
 
1618
 
QImage PageItem::DrawObj_toImage(QList<PageItem*> &emG)
1619
 
{
1620
 
        QImage retImg = QImage(qRound(gWidth), qRound(gHeight), QImage::Format_ARGB32);
1621
 
//      retImg.fill( qRgba(255, 255, 255, 0) );
1622
 
        retImg.fill( qRgba(0, 0, 0, 0) );
1623
 
        ScPainter *painter = new ScPainter(&retImg, retImg.width(), retImg.height(), 1, 0);
1624
 
//      painter->setZoomFactor(1.0);
1625
 
        painter->setZoomFactor(qMax(qRound(gWidth) / gWidth, qRound(gHeight) / gHeight));
1626
 
        QStack<PageItem*> groupStack;
1627
 
        for (int em = 0; em < emG.count(); ++em)
1628
 
        {
1629
 
                PageItem* embedded = emG.at(em);
1630
 
                if (embedded->isGroupControl)
1631
 
                {
1632
 
                        painter->save();
1633
 
                        FPointArray cl = embedded->PoLine.copy();
1634
 
                        QMatrix mm;
1635
 
                        mm.translate(embedded->gXpos, embedded->gYpos);
1636
 
                        mm.rotate(embedded->rotation());
1637
 
                        cl.map( mm );
1638
 
                        painter->beginLayer(1.0 - embedded->fillTransparency(), embedded->fillBlendmode(), &cl);
1639
 
                        groupStack.push(embedded->groupsLastItem);
1640
 
                        continue;
1641
 
                }
1642
 
                painter->save();
1643
 
//              qDebug()<<embedded<<embedded->xPos()<<embedded->yPos()<<embedded->gXpos<<embedded->gYpos;
1644
 
//              double x = embedded->xPos();
1645
 
//              double y = embedded->yPos();
1646
 
//              embedded->Xpos = embedded->gXpos;
1647
 
//              embedded->Ypos = embedded->gYpos;
1648
 
                // Seems to work without all this coordinates mess. To monitor tho
1649
 
                painter->translate(embedded->gXpos, embedded->gYpos);
1650
 
                embedded->isEmbedded = true;
1651
 
                embedded->invalid = true;
1652
 
                embedded->DrawObj(painter, QRectF());
1653
 
//              embedded->Xpos = x;
1654
 
//              embedded->Ypos = y;
1655
 
                embedded->isEmbedded = false;
1656
 
                painter->restore();
1657
 
                if (groupStack.count() != 0)
1658
 
                {
1659
 
                        while (embedded == groupStack.top())
1660
 
                        {
1661
 
                                painter->endLayer();
1662
 
                                painter->restore();
1663
 
                                groupStack.pop();
1664
 
                                if (groupStack.count() == 0)
1665
 
                                        break;
1666
 
                        }
1667
 
                }
1668
 
        }
1669
 
        for (int em = 0; em < emG.count(); ++em)
1670
 
        {
1671
 
                PageItem* embedded = emG.at(em);
1672
 
                if (!embedded->isTableItem)
1673
 
                        continue;
1674
 
                painter->save();
1675
 
//              double x = embedded->xPos();
1676
 
//              double y = embedded->yPos();
1677
 
//              embedded->Xpos = embedded->gXpos;
1678
 
//              embedded->Ypos = embedded->gYpos;
1679
 
                painter->translate(embedded->gXpos, embedded->gYpos);
1680
 
                painter->rotate(embedded->rotation());
1681
 
                embedded->isEmbedded = true;
1682
 
                embedded->invalid = true;
1683
 
                if ((embedded->lineColor() != CommonStrings::None) && (embedded->lineWidth() != 0.0))
1684
 
                {
1685
 
                        QColor tmp;
1686
 
                        embedded->SetQColor(&tmp, embedded->lineColor(), embedded->lineShade());
1687
 
                        if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine))
1688
 
                        {
1689
 
                                painter->setPen(tmp, embedded->lineWidth(), embedded->PLineArt, Qt::SquareCap, embedded->PLineJoin);
1690
 
                                if (embedded->TopLine)
1691
 
                                        painter->drawLine(FPoint(0.0, 0.0), FPoint(embedded->width(), 0.0));
1692
 
                                if (embedded->RightLine)
1693
 
                                        painter->drawLine(FPoint(embedded->width(), 0.0), FPoint(embedded->width(), embedded->height()));
1694
 
                                if (embedded->BottomLine)
1695
 
                                        painter->drawLine(FPoint(embedded->width(), embedded->height()), FPoint(0.0, embedded->height()));
1696
 
                                if (embedded->LeftLine)
1697
 
                                        painter->drawLine(FPoint(0.0, embedded->height()), FPoint(0.0, 0.0));
1698
 
                        }
1699
 
                }
1700
 
                embedded->isEmbedded = false;
1701
 
//              embedded->Xpos = x;
1702
 
//              embedded->Ypos = y;
1703
 
                painter->restore();
1704
 
        }
1705
 
        painter->end();
1706
 
        delete painter;
1707
 
        return retImg;
1708
 
}
1709
 
 
1710
 
QString PageItem::ExpandToken(uint base)
1711
 
{
1712
 
        uint zae = 0;
1713
 
        QChar ch = itemText.text(base);
1714
 
        QString chstr = ch;
1715
 
        if (ch == SpecialChars::PAGENUMBER)
1716
 
        {
1717
 
                // compatibility mode: ignore subsequent pagenumber chars
1718
 
                if (base > 0 && itemText.text(base-1) == SpecialChars::PAGENUMBER)
1719
 
                        return "";
1720
 
                if ((!m_Doc->masterPageMode()) && (OwnPage != -1))
1721
 
                {
1722
 
                        QString out("%1");
1723
 
                        //CB Section numbering
1724
 
                        chstr = out.arg(m_Doc->getSectionPageNumberForPageIndex(OwnPage), -(int)zae);
1725
 
                }
1726
 
                else
1727
 
                        return "#";
1728
 
        }
1729
 
        else if (ch == SpecialChars::PAGECOUNT)
1730
 
        {
1731
 
                if (!m_Doc->masterPageMode())
1732
 
                {
1733
 
                        QString out("%1");
1734
 
                        int key = m_Doc->getSectionKeyForPageIndex(OwnPage);
1735
 
                        if (key == -1)
1736
 
                                return "%";
1737
 
                        chstr = out.arg(getStringFromSequence(m_Doc->sections[key].type, m_Doc->sections[key].toindex - m_Doc->sections[key].fromindex + 1));
1738
 
                }
1739
 
                else
1740
 
                        return "%";
1741
 
        }
1742
 
        return chstr;
1743
 
}
1744
 
 
1745
 
void PageItem::SetQColor(QColor *tmp, QString farbe, double shad)
1746
 
{
1747
 
        const ScColor& col = m_Doc->PageColors[farbe];
1748
 
        *tmp = ScColorEngine::getShadeColorProof(col, m_Doc, shad);
1749
 
        if ((m_Doc->view()) && (m_Doc->view()->m_canvas->usePreviewVisual()))
1750
 
        {
1751
 
                VisionDefectColor defect;
1752
 
                *tmp = defect.convertDefect(*tmp, m_Doc->view()->m_canvas->previewVisual());
1753
 
        }
1754
 
}
1755
 
 
1756
 
/**
1757
 
    layout glyphs translates the chars into a number of glyphs, applying the Charstyle
1758
 
    'style'. The following fields are set in layout: glyph, more, scaleH, scaleV, xoffset, yoffset, xadvance.
1759
 
    If the DropCap-bit in style.effects is set and yadvance is > 0, scaleH/V, x/yoffset and xadvance
1760
 
    are modified to scale the glyphs to this height.
1761
 
    Otherwise yadvance is set to the max ascender of all generated glyphs.
1762
 
    It scales according to smallcaps and
1763
 
    sets xadvance to the advance width without kerning. If more than one glyph
1764
 
    is generated, kerning is included in all but the last xadvance.
1765
 
*/
1766
 
double PageItem::layoutGlyphs(const CharStyle& style, const QString& chars, GlyphLayout& layout)
1767
 
{
1768
 
        double retval = 0.0;
1769
 
        double asce = style.font().ascent(style.fontSize() / 10.0);
1770
 
        int chst = style.effects() & 1919;
1771
 
/*      if (chars[0] == SpecialChars::ZWSPACE ||
1772
 
                chars[0] == SpecialChars::ZWNBSPACE ||
1773
 
                chars[0] == SpecialChars::NBSPACE ||
1774
 
                chars[0] == SpecialChars::NBHYPHEN ||
1775
 
                chars[0] == SpecialChars::SHYPHEN ||
1776
 
                chars[0] == SpecialChars::PARSEP ||
1777
 
                chars[0] == SpecialChars::COLBREAK ||
1778
 
                chars[0] == SpecialChars::LINEBREAK ||
1779
 
                chars[0] == SpecialChars::FRAMEBREAK ||
1780
 
                chars[0] == SpecialChars::TAB)
1781
 
        {
1782
 
                layout.glyph = ScFace::CONTROL_GLYPHS + chars[0].unicode();
1783
 
        }
1784
 
        else */
1785
 
        {
1786
 
                layout.glyph = style.font().char2CMap(chars[0].unicode());
1787
 
        }
1788
 
        
1789
 
        double tracking = 0.0;
1790
 
        if ( (style.effects() & ScStyle_StartOfLine) == 0)
1791
 
                tracking = style.fontSize() * style.tracking() / 10000.0;
1792
 
 
1793
 
        layout.xoffset = tracking;
1794
 
        layout.yoffset = 0;
1795
 
        if (chst != ScStyle_Default)
1796
 
        {
1797
 
                if (chst & ScStyle_Superscript)
1798
 
                {
1799
 
                        retval -= asce * m_Doc->typographicSettings.valueSuperScript / 100.0;
1800
 
                        layout.yoffset -= asce * m_Doc->typographicSettings.valueSuperScript / 100.0;
1801
 
                        layout.scaleV = layout.scaleH = qMax(m_Doc->typographicSettings.scalingSuperScript / 100.0, 10.0 / style.fontSize());
1802
 
                }
1803
 
                else if (chst & ScStyle_Subscript)
1804
 
                {
1805
 
                        retval += asce * m_Doc->typographicSettings.valueSubScript / 100.0;
1806
 
                        layout.yoffset += asce * m_Doc->typographicSettings.valueSubScript / 100.0;
1807
 
                        layout.scaleV = layout.scaleH = qMax(m_Doc->typographicSettings.scalingSubScript / 100.0, 10.0 / style.fontSize());
1808
 
                }
1809
 
                else {
1810
 
                        layout.scaleV = layout.scaleH = 1.0;
1811
 
                }
1812
 
                layout.scaleH *= style.scaleH() / 1000.0;
1813
 
                layout.scaleV *= style.scaleV() / 1000.0;
1814
 
                if (chst & ScStyle_AllCaps)
1815
 
                {
1816
 
                        layout.glyph = style.font().char2CMap(chars[0].toUpper().unicode());
1817
 
                }
1818
 
                if (chst & ScStyle_SmallCaps)
1819
 
                {
1820
 
                        double smallcapsScale = m_Doc->typographicSettings.valueSmallCaps / 100.0;
1821
 
                        QChar uc = chars[0].toUpper();
1822
 
                        if (uc != chars[0])
1823
 
                        {
1824
 
                                layout.glyph = style.font().char2CMap(chars[0].toUpper().unicode());
1825
 
                                layout.scaleV *= smallcapsScale;
1826
 
                                layout.scaleH *= smallcapsScale;
1827
 
                        }
1828
 
                }
1829
 
        }
1830
 
        else {
1831
 
                layout.scaleH = style.scaleH() / 1000.0;
1832
 
                layout.scaleV = style.scaleV() / 1000.0;
1833
 
        }       
1834
 
        
1835
 
/*      if (layout.glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode())) {
1836
 
                uint replGlyph = style.font().char2CMap(QChar(' '));
1837
 
                layout.xadvance = style.font().glyphWidth(replGlyph, style.fontSize() / 10) * layout.scaleH;
1838
 
                layout.yadvance = style.font().glyphBBox(replGlyph, style.fontSize() / 10).ascent * layout.scaleV;
1839
 
        }
1840
 
        else if (layout.glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode())) {
1841
 
                uint replGlyph = style.font().char2CMap(QChar('-'));
1842
 
                layout.xadvance = style.font().glyphWidth(replGlyph, style.fontSize() / 10) * layout.scaleH;
1843
 
                layout.yadvance = style.font().glyphBBox(replGlyph, style.fontSize() / 10).ascent * layout.scaleV;
1844
 
        }
1845
 
        else if (layout.glyph >= ScFace::CONTROL_GLYPHS) {
1846
 
                layout.xadvance = 0;
1847
 
                layout.yadvance = 0;
1848
 
        }
1849
 
        else */
1850
 
        {
1851
 
                layout.xadvance = style.font().glyphWidth(layout.glyph, style.fontSize() / 10) * layout.scaleH;
1852
 
                layout.yadvance = style.font().glyphBBox(layout.glyph, style.fontSize() / 10).ascent * layout.scaleV;
1853
 
        }
1854
 
        if (layout.xadvance > 0)
1855
 
                layout.xadvance += tracking;
1856
 
 
1857
 
        if (chars.length() > 1) {
1858
 
                layout.grow();
1859
 
                layoutGlyphs(style, chars.mid(1), *layout.more);
1860
 
                layout.xadvance += style.font().glyphKerning(layout.glyph, layout.more->glyph, style.fontSize() / 10) * layout.scaleH;
1861
 
                if (layout.more->yadvance > layout.yadvance)
1862
 
                        layout.yadvance = layout.more->yadvance;
1863
 
        }
1864
 
        else {
1865
 
                layout.shrink();
1866
 
        }
1867
 
        return retval;
1868
 
}
1869
 
 
1870
 
void PageItem::drawGlyphs(ScPainter *p, const CharStyle& style, GlyphLayout& glyphs)
1871
 
{
1872
 
        uint glyph = glyphs.glyph;
1873
 
        if ((m_Doc->guidesSettings.showControls) && 
1874
 
                (glyph == style.font().char2CMap(QChar(' ')) || glyph >=  ScFace::CONTROL_GLYPHS))
1875
 
        {
1876
 
                bool stroke = false;
1877
 
                if (glyph >=  ScFace::CONTROL_GLYPHS)
1878
 
                        glyph -= ScFace::CONTROL_GLYPHS;
1879
 
                else
1880
 
                        glyph = 32;
1881
 
                QMatrix chma, chma4, chma5;
1882
 
                FPointArray points;
1883
 
                if (glyph == SpecialChars::TAB.unicode())
1884
 
                {
1885
 
                        points = m_Doc->symTab.copy();
1886
 
                        chma4.translate(glyphs.xoffset + glyphs.xadvance - ((style.fontSize() / 10.0) * glyphs.scaleH * 0.7), glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV * 0.5));
1887
 
                }
1888
 
                else if (glyph == SpecialChars::COLBREAK.unicode())
1889
 
                {
1890
 
                        points = m_Doc->symNewCol.copy();
1891
 
                        chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.6));
1892
 
                }
1893
 
                else if (glyph == SpecialChars::FRAMEBREAK.unicode())
1894
 
                {
1895
 
                        points = m_Doc->symNewFrame.copy();
1896
 
                        chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.6));
1897
 
                }
1898
 
                else if (glyph == SpecialChars::PARSEP.unicode())
1899
 
                {
1900
 
                        points = m_Doc->symReturn.copy();
1901
 
                        chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.8));
1902
 
                }
1903
 
                else if (glyph == SpecialChars::LINEBREAK.unicode())
1904
 
                {
1905
 
                        points = m_Doc->symNewLine.copy();
1906
 
                        chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.4));
1907
 
                }
1908
 
                else if (glyph == SpecialChars::NBSPACE.unicode() ||
1909
 
                                 glyph == 32)
1910
 
                {
1911
 
                        stroke = (glyph == 32);
1912
 
                        points = m_Doc->symNonBreak.copy();
1913
 
                        chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.4));
1914
 
                }
1915
 
                else if (glyph == SpecialChars::NBHYPHEN.unicode())
1916
 
                {
1917
 
                        points = style.font().glyphOutline(style.font().char2CMap(QChar('-')), style.fontSize() / 100);
1918
 
                        chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV));
1919
 
                }
1920
 
                else if (glyph == SpecialChars::SHYPHEN.unicode())
1921
 
                {
1922
 
                        points.resize(0);
1923
 
                        points.addQuadPoint(0, -10, 0, -10, 0, -6, 0, -6);
1924
 
                        stroke = true;
1925
 
                }
1926
 
                else // ???
1927
 
                {
1928
 
                        points.resize(0);
1929
 
                        points.addQuadPoint(0, -10, 0, -10, 0, -9, 0, -9);                      
1930
 
                        points.addQuadPoint(0, -9, 0, -9, 1, -9, 1, -9);                        
1931
 
                        points.addQuadPoint(1, -9, 1, -9, 1, -10, 1, -10);                      
1932
 
                        points.addQuadPoint(1, -10, 1, -10, 0, -10, 0, -10);                    
1933
 
                }
1934
 
                chma.scale(glyphs.scaleH * style.fontSize() / 100.0, glyphs.scaleV * style.fontSize() / 100.0);
1935
 
                points.map(chma * chma4);
1936
 
                p->setupPolygon(&points, true);
1937
 
                QColor oldBrush = p->brush();
1938
 
                p->setBrush( (style.effects() & ScStyle_SuppressSpace) ? Qt::green
1939
 
                                        : PrefsManager::instance()->appPrefs.DControlCharColor);
1940
 
                if (stroke)
1941
 
                {
1942
 
                        QColor tmp = p->pen();
1943
 
                        p->setPen(p->brush(), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1944
 
                        p->setLineWidth(style.fontSize() * glyphs.scaleV / 200.0);
1945
 
                        p->strokePath();
1946
 
                        p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1947
 
                }
1948
 
                else
1949
 
                {
1950
 
                        p->setFillMode(1);
1951
 
                        p->fillPath();
1952
 
                }
1953
 
                p->setBrush(oldBrush);
1954
 
                if (glyphs.more)
1955
 
                {
1956
 
                        p->translate(glyphs.xadvance, 0);
1957
 
                        drawGlyphs(p, style, *glyphs.more);
1958
 
                }                       
1959
 
                return;
1960
 
        }
1961
 
        else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode()) ||
1962
 
                         glyph == (ScFace::CONTROL_GLYPHS + 32)) 
1963
 
                glyph = style.font().char2CMap(QChar(' '));
1964
 
        else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode()))
1965
 
                glyph = style.font().char2CMap(QChar('-'));
1966
 
        
1967
 
        if (glyph >= ScFace::CONTROL_GLYPHS || (style.effects() & ScStyle_SuppressSpace)) {
1968
 
//              qDebug("drawGlyphs: skipping %d", glyph);
1969
 
                // all those are empty
1970
 
                if (glyphs.more)
1971
 
                {
1972
 
                        p->translate(glyphs.xadvance, 0);
1973
 
                        drawGlyphs(p, style, *glyphs.more);
1974
 
                }                       
1975
 
                return;
1976
 
        }
1977
 
//      if (style.font().canRender(QChar(glyph)))
1978
 
        {
1979
 
                FPointArray gly = style.font().glyphOutline(glyph);
1980
 
                // Do underlining first so you can get typographically correct
1981
 
                // underlines when drawing a white outline
1982
 
                if (((style.effects() & ScStyle_Underline) || ((style.effects() & ScStyle_UnderlineWords) && glyph != style.font().char2CMap(QChar(' ')))) && (style.strokeColor() != CommonStrings::None))
1983
 
                {
1984
 
                        double st, lw;
1985
 
                        if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1))
1986
 
                        {
1987
 
                                if (style.underlineOffset() != -1)
1988
 
                                        st = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0));
1989
 
                                else
1990
 
                                        st = style.font().underlinePos(style.fontSize() / 10.0);
1991
 
                                if (style.underlineWidth() != -1)
1992
 
                                        lw = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0);
1993
 
                                else
1994
 
                                        lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
1995
 
                        }
1996
 
                        else
1997
 
                        {
1998
 
                                st = style.font().underlinePos(style.fontSize() / 10.0);
1999
 
                                lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2000
 
                        }
2001
 
                        if (style.baselineOffset() != 0)
2002
 
                                st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
2003
 
                        QColor tmpC = p->pen();
2004
 
                        p->setPen(p->brush());
2005
 
                        p->setLineWidth(lw);
2006
 
                        if (style.effects() & ScStyle_Subscript)
2007
 
                                p->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
2008
 
                        else
2009
 
                                p->drawLine(FPoint(glyphs.xoffset, -st), FPoint(glyphs.xoffset + glyphs.xadvance, -st));
2010
 
                        p->setPen(tmpC);
2011
 
                }
2012
 
                if (gly.size() > 3)
2013
 
                {
2014
 
                        if (glyph == 0)
2015
 
                        {
2016
 
//                              qDebug() << QString("glyph 0: (%1,%2) * %3 %4 + %5").arg(glyphs.xoffset).arg(glyphs.yoffset).arg(glyphs.scaleH).arg(glyphs.scaleV).arg(glyphs.xadvance));
2017
 
                        }
2018
 
                        p->save();
2019
 
                        p->translate(glyphs.xoffset, glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV));
2020
 
                        if (Reverse)
2021
 
                        {
2022
 
                                p->scale(-1, 1);
2023
 
                                p->translate(-glyphs.xadvance, 0);
2024
 
                        }
2025
 
                        if (style.baselineOffset() != 0)
2026
 
                                p->translate(0, -(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0));
2027
 
                        double glxSc = glyphs.scaleH * style.fontSize() / 100.00;
2028
 
                        double glySc = glyphs.scaleV * style.fontSize() / 100.0;
2029
 
                        p->scale(glxSc, glySc);
2030
 
//                      p->setFillMode(1);
2031
 
                        bool fr = p->fillRule();
2032
 
                        p->setFillRule(false);
2033
 
//                      double  a = gly.point(0).x();
2034
 
//                      double  b = gly.point(0).y();
2035
 
//                      double  c = gly.point(3).x();
2036
 
//                      double  d = gly.point(3).y();
2037
 
//                      qDebug() << QString("drawglyphs: %1 (%2,%3) (%4,%5) scaled %6,%7 trans %8,%9")
2038
 
//                                 .arg(gly.size()).arg(a).arg(b).arg(c).arg(d)
2039
 
//                                 .arg(p->worldMatrix().m11()).arg(p->worldMatrix().m22()).arg(p->worldMatrix().dx()).arg(p->worldMatrix().dy());
2040
 
                        p->setupPolygon(&gly, true);
2041
 
                        if (m_Doc->layerOutline(LayerNr))
2042
 
                        {
2043
 
                                p->save();
2044
 
                                p->setPen(m_Doc->layerMarker(LayerNr), 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2045
 
                                p->setFillMode(ScPainter::None);
2046
 
                                p->setBrushOpacity(1.0);
2047
 
                                p->setPenOpacity(1.0);
2048
 
                                p->strokePath();
2049
 
                                p->restore();
2050
 
                                p->setFillRule(fr);
2051
 
                                p->restore();
2052
 
                                if (glyphs.more)
2053
 
                                {
2054
 
                                        p->translate(glyphs.xadvance, 0);
2055
 
                                        drawGlyphs(p, style, *glyphs.more);
2056
 
                                }
2057
 
                                return;
2058
 
                        }
2059
 
                        if (glyph == 0)
2060
 
                        {
2061
 
                                p->setPen(PrefsManager::instance()->appPrefs.DControlCharColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2062
 
                                p->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() * 2 / 10000.0);
2063
 
                                p->strokePath();
2064
 
                        }
2065
 
                        else if ((style.font().isStroked()) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
2066
 
                        {
2067
 
                                QColor tmp = p->brush();
2068
 
                                p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2069
 
                                p->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0);
2070
 
                                p->strokePath();
2071
 
                        }
2072
 
                        else
2073
 
                        {
2074
 
                                if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None))
2075
 
                                {
2076
 
                                        p->save();
2077
 
                                        p->translate((style.fontSize() * glyphs.scaleH * style.shadowXOffset() / 10000.0) / glxSc, -(style.fontSize() * glyphs.scaleV * style.shadowYOffset() / 10000.0) / glySc);
2078
 
                                        QColor tmp = p->brush();
2079
 
                                        p->setBrush(p->pen());
2080
 
                                        p->setupPolygon(&gly, true);
2081
 
                                        p->fillPath();
2082
 
                                        p->setBrush(tmp);
2083
 
                                        p->restore();
2084
 
                                        p->setupPolygon(&gly, true);
2085
 
                                }
2086
 
                                if (style.fillColor() != CommonStrings::None)
2087
 
                                        p->fillPath();
2088
 
                                if ((style.effects() & ScStyle_Outline) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
2089
 
                                {
2090
 
                                        p->setLineWidth((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) / glySc);
2091
 
                                        p->strokePath();
2092
 
                                }
2093
 
                        }
2094
 
                        p->setFillRule(fr);
2095
 
                        p->restore();
2096
 
                }
2097
 
                else {
2098
 
//                      qDebug() << "drawGlyphs: empty glyph" << glyph;
2099
 
                }
2100
 
                if ((style.effects() & ScStyle_Strikethrough) && (style.strokeColor() != CommonStrings::None))
2101
 
                {
2102
 
                        double st, lw;
2103
 
                        if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1))
2104
 
                        {
2105
 
                                if (style.strikethruOffset() != -1)
2106
 
                                        st = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0));
2107
 
                                else
2108
 
                                        st = style.font().strikeoutPos(style.fontSize() / 10.0);
2109
 
                                if (style.strikethruWidth() != -1)
2110
 
                                        lw = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0);
2111
 
                                else
2112
 
                                        lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2113
 
                        }
2114
 
                        else
2115
 
                        {
2116
 
                                st = style.font().strikeoutPos(style.fontSize() / 10.0);
2117
 
                                lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2118
 
                        }
2119
 
                        if (style.baselineOffset() != 0)
2120
 
                                st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
2121
 
                        p->setPen(p->brush());
2122
 
                        p->setLineWidth(lw);
2123
 
                        p->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
2124
 
                }
2125
 
        }
2126
 
/*      else
2127
 
        {
2128
 
                p->setLineWidth(1);
2129
 
                p->setPen(red);
2130
 
                p->setBrush(red);
2131
 
                p->setFillMode(1);
2132
 
                p->drawRect(glyphs.xoffset, glyphs.yoffset - (style.fontSize() / 10.0) * glyphs.scaleV , (style.fontSize() / 10.0) * glyphs.scaleH, (style.fontSize() / 10.0) * glyphs.scaleV);
2133
 
        }
2134
 
        */      
2135
 
        if (glyphs.more)
2136
 
        {
2137
 
                p->translate(glyphs.xadvance, 0);
2138
 
                drawGlyphs(p, style, *glyphs.more);
2139
 
        }
2140
 
}
2141
 
 
2142
 
void PageItem::DrawPolyL(QPainter *p, QPolygon pts)
2143
 
{
2144
 
        if (Segments.count() != 0)
2145
 
        {
2146
 
                QList<uint>::Iterator it2end=Segments.end();
2147
 
                uint FirstVal = 0;
2148
 
                for (QList<uint>::Iterator it2 = Segments.begin(); it2 != it2end; ++it2)
2149
 
                {
2150
 
                                p->drawPolygon(pts.constData() + FirstVal, (*it2)-FirstVal);
2151
 
                        FirstVal = (*it2);
2152
 
                }
2153
 
                p->drawPolygon(pts.constData() + FirstVal, pts.size() - FirstVal);
2154
 
        }
2155
 
        else
2156
 
                p->drawPolygon(pts);
2157
 
/*
2158
 
        QColor tmp;
2159
 
        if (Segments.count() != 0)
2160
 
        {
2161
 
                QList<uint>::Iterator it2end=Segments.end();
2162
 
                uint FirstVal = 0;
2163
 
                for (QList<uint>::Iterator it2 = Segments.begin(); it2 != it2end; ++it2)
2164
 
                {
2165
 
                        if (NamedLStyle.isEmpty())
2166
 
                        {
2167
 
                                if (lineColor() != CommonStrings::None)
2168
 
                                        p->setPen(QPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin));
2169
 
                                p->drawPolygon(pts.constData() + FirstVal, (*it2)-FirstVal);
2170
 
                        }
2171
 
                        else
2172
 
                        {
2173
 
                                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
2174
 
                                for (int it = ml.size()-1; it > -1; it--)
2175
 
                                {
2176
 
                                        SetQColor(&tmp, ml[it].Color, ml[it].Shade);
2177
 
                                        p->setPen(QPen(tmp,
2178
 
                                                                         qMax(static_cast<int>(ml[it].Width), 1),
2179
 
                                                                         static_cast<Qt::PenStyle>(ml[it].Dash),
2180
 
                                                                         static_cast<Qt::PenCapStyle>(ml[it].LineEnd),
2181
 
                                                                         static_cast<Qt::PenJoinStyle>(ml[it].LineJoin)));
2182
 
                                        p->drawPolygon(pts.constData() + FirstVal, (*it2)-FirstVal);
2183
 
                                }
2184
 
                        }
2185
 
                        FirstVal = (*it2);
2186
 
                }
2187
 
                if (NamedLStyle.isEmpty())
2188
 
                {
2189
 
                        if (lineColor() != CommonStrings::None)
2190
 
                                p->setPen(QPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin));
2191
 
                        p->drawPolygon(pts.constData() + FirstVal, pts.size() - FirstVal);
2192
 
                }
2193
 
                else
2194
 
                {
2195
 
                        multiLine ml = m_Doc->MLineStyles[NamedLStyle];
2196
 
                        for (int it = ml.size()-1; it > -1; it--)
2197
 
                        {
2198
 
                                SetQColor(&tmp, ml[it].Color, ml[it].Shade);
2199
 
                                p->setPen(QPen(tmp,
2200
 
                                                                 qMax(static_cast<int>(ml[it].Width), 1),
2201
 
                                                                 static_cast<Qt::PenStyle>(ml[it].Dash),
2202
 
                                                                 static_cast<Qt::PenCapStyle>(ml[it].LineEnd),
2203
 
                                                                 static_cast<Qt::PenJoinStyle>(ml[it].LineJoin)));
2204
 
                                p->drawPolygon(pts.constData() + FirstVal, pts.size() - FirstVal);
2205
 
                        }
2206
 
                }
2207
 
        }
2208
 
        else
2209
 
        {
2210
 
                if (NamedLStyle.isEmpty())
2211
 
                {
2212
 
                        if (lineColor() != CommonStrings::None)
2213
 
                                p->setPen(QPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin));
2214
 
                        p->drawPolygon(pts);
2215
 
                }
2216
 
                else
2217
 
                {
2218
 
                        multiLine ml = m_Doc->MLineStyles[NamedLStyle];
2219
 
                        for (int it = ml.size()-1; it > -1; it--)
2220
 
                        {
2221
 
                                SetQColor(&tmp, ml[it].Color, ml[it].Shade);
2222
 
                                p->setPen(QPen(tmp,
2223
 
                                                                 qMax(static_cast<int>(ml[it].Width), 1),
2224
 
                                                                 static_cast<Qt::PenStyle>(ml[it].Dash),
2225
 
                                                                 static_cast<Qt::PenCapStyle>(ml[it].LineEnd),
2226
 
                                                                 static_cast<Qt::PenJoinStyle>(ml[it].LineJoin)));
2227
 
                                p->drawPolygon(pts);
2228
 
                        }
2229
 
                }
2230
 
        } */
2231
 
}
2232
 
 
2233
 
void PageItem::setItemName(const QString& newName)
2234
 
{
2235
 
        if (AnName == newName)
2236
 
                return; // nothing to do -> return
2237
 
        if (newName.isEmpty())
2238
 
                return;
2239
 
        QString oldName = AnName;
2240
 
        AnName = generateUniqueCopyName(newName);
2241
 
        AutoName = false;
2242
 
        if (UndoManager::undoEnabled())
2243
 
        {
2244
 
                SimpleState *ss = new SimpleState(Um::Rename, QString(Um::FromTo).arg(AnName).arg(newName));
2245
 
                ss->set("OLD_NAME", oldName);
2246
 
                ss->set("NEW_NAME", newName);
2247
 
                undoManager->action(this, ss);
2248
 
        }
2249
 
        setUName(AnName); // set the name for the UndoObject too
2250
 
}
2251
 
 
2252
 
void PageItem::setPattern(const QString &newPattern)
2253
 
{
2254
 
        if (patternVal != newPattern)
2255
 
                patternVal = newPattern;
2256
 
}
2257
 
 
2258
 
void PageItem::gradientVector(double& startX, double& startY, double& endX, double& endY) const
2259
 
{
2260
 
        startX = GrStartX;
2261
 
        startY = GrStartY;
2262
 
        endX   = GrEndX;
2263
 
        endY   = GrEndY;
2264
 
}
2265
 
 
2266
 
void PageItem::setGradientVector(double startX, double startY, double endX, double endY)
2267
 
{
2268
 
        GrStartX = startX;
2269
 
        GrStartY = startY;
2270
 
        GrEndX   = endX;
2271
 
        GrEndY   = endY;
2272
 
}
2273
 
 
2274
 
void PageItem::setPatternTransform(double scaleX, double scaleY, double offsetX, double offsetY, double rotation)
2275
 
{
2276
 
        patternScaleX = scaleX;
2277
 
        patternScaleY = scaleY;
2278
 
        patternOffsetX = offsetX;
2279
 
        patternOffsetY = offsetY;
2280
 
        patternRotation = rotation;
2281
 
}
2282
 
 
2283
 
void  PageItem::patternTransform(double &scaleX, double &scaleY, double &offsetX, double &offsetY, double &rotation) const
2284
 
{
2285
 
         scaleX = patternScaleX;
2286
 
         scaleY = patternScaleY;
2287
 
         offsetX = patternOffsetX;
2288
 
         offsetY = patternOffsetY;
2289
 
         rotation = patternRotation;
2290
 
}
2291
 
 
2292
 
void PageItem::setFillColor(const QString &newColor)
2293
 
{
2294
 
        QString tmp = newColor;
2295
 
        if (tmp != CommonStrings::None)
2296
 
        {
2297
 
                if (!m_Doc->PageColors.contains(newColor))
2298
 
                {
2299
 
                        switch(itemType())
2300
 
                        {
2301
 
                                case ImageFrame:
2302
 
                                case LatexFrame:
2303
 
                                        tmp = m_Doc->toolSettings.dBrushPict;
2304
 
                                case TextFrame:
2305
 
                                case PathText:
2306
 
                                        tmp = m_Doc->toolSettings.dTextBackGround;
2307
 
                                        break;
2308
 
                                case Line:
2309
 
                                case PolyLine:
2310
 
                                case Polygon:
2311
 
                                        tmp = m_Doc->toolSettings.dBrush;
2312
 
                                        break;
2313
 
                                default:
2314
 
                                        break;
2315
 
                        }
2316
 
                }
2317
 
        }
2318
 
        if (fillColorVal == tmp)
2319
 
        {
2320
 
                setFillQColor();
2321
 
                return;
2322
 
        }
2323
 
        if (UndoManager::undoEnabled())
2324
 
        {
2325
 
                SimpleState *ss = new SimpleState(Um::SetFill,
2326
 
                                                                                  QString(Um::ColorFromTo).arg(fillColorVal).arg(tmp),
2327
 
                                          Um::IFill);
2328
 
                ss->set("FILL", "fill");
2329
 
                ss->set("OLD_FILL", fillColorVal);
2330
 
                ss->set("NEW_FILL", tmp);
2331
 
                undoManager->action(this, ss);
2332
 
        }
2333
 
        fillColorVal = tmp;
2334
 
        if (GrType == 0)
2335
 
        {
2336
 
                fill_gradient = VGradient(VGradient::linear);
2337
 
                fill_gradient.clearStops();
2338
 
                if (fillColorVal != CommonStrings::None)
2339
 
                {
2340
 
                        const ScColor& col = m_Doc->PageColors[fillColorVal];
2341
 
                        fill_gradient.addStop(ScColorEngine::getRGBColor(col, m_Doc), 0.0, 0.5, 1.0, fillColorVal, 100);
2342
 
                        fill_gradient.addStop(ScColorEngine::getRGBColor(col, m_Doc), 1.0, 0.5, 1.0, fillColorVal, 100);
2343
 
                }
2344
 
        }
2345
 
        setFillQColor();
2346
 
//CB unused in 135      emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
2347
 
}
2348
 
 
2349
 
void PageItem::setFillShade(double newShade)
2350
 
{
2351
 
        if (fillShadeVal == newShade)
2352
 
        {
2353
 
                setFillQColor();
2354
 
                return;
2355
 
        }
2356
 
        if (UndoManager::undoEnabled())
2357
 
        {
2358
 
                SimpleState *ss = new SimpleState(Um::SetShade,
2359
 
                                                                                  QString(Um::FromTo).arg(fillShadeVal).arg(newShade),
2360
 
                                                                                  Um::IShade);
2361
 
                ss->set("SHADE", "shade");
2362
 
                ss->set("OLD_SHADE", fillShadeVal);
2363
 
                ss->set("NEW_SHADE", newShade);
2364
 
                undoManager->action(this, ss);
2365
 
        }
2366
 
        fillShadeVal = newShade;
2367
 
        setFillQColor();
2368
 
//CB unused in 135      emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
2369
 
}
2370
 
 
2371
 
void PageItem::setFillTransparency(double newTransparency)
2372
 
{
2373
 
        if (fillTransparencyVal == newTransparency)
2374
 
                return; // nothing to do -> return
2375
 
        if (UndoManager::undoEnabled())
2376
 
        {
2377
 
                SimpleState *ss = new SimpleState(Um::Transparency,
2378
 
                                                                                  QString(Um::FromTo).arg(fillTransparencyVal).arg(newTransparency),
2379
 
                                                                                  Um::ITransparency);
2380
 
                ss->set("TRANSPARENCY", "transparency");
2381
 
                ss->set("OLD_TP", fillTransparencyVal);
2382
 
                ss->set("NEW_TP", newTransparency);
2383
 
                undoManager->action(this, ss);
2384
 
        }
2385
 
        fillTransparencyVal = newTransparency;
2386
 
}
2387
 
 
2388
 
void PageItem::setFillBlendmode(int newBlendmode)
2389
 
{
2390
 
        if (fillBlendmodeVal == newBlendmode)
2391
 
                return; // nothing to do -> return
2392
 
        fillBlendmodeVal = newBlendmode;
2393
 
}
2394
 
 
2395
 
void PageItem::setLineColor(const QString &newColor)
2396
 
{
2397
 
        QString tmp = newColor;
2398
 
        if (tmp != CommonStrings::None)
2399
 
        {
2400
 
                if (!m_Doc->PageColors.contains(newColor))
2401
 
                {
2402
 
                        switch(itemType())
2403
 
                        {
2404
 
                                case TextFrame:
2405
 
                                case PathText:
2406
 
                                        tmp = m_Doc->toolSettings.dTextLineColor;
2407
 
                                        break;
2408
 
                                case Line:
2409
 
                                        tmp = m_Doc->toolSettings.dPenLine;
2410
 
                                        break;
2411
 
                                case PolyLine:
2412
 
                                case Polygon:
2413
 
                                case ImageFrame:
2414
 
                                case LatexFrame:
2415
 
                                        tmp = m_Doc->toolSettings.dPen;
2416
 
                                        break;
2417
 
                                default:
2418
 
                                        break;
2419
 
                        }
2420
 
                }
2421
 
        }
2422
 
        if (lineColorVal == tmp)
2423
 
        {
2424
 
                setLineQColor();
2425
 
                return;
2426
 
        }
2427
 
        if (UndoManager::undoEnabled())
2428
 
        {
2429
 
                SimpleState *ss = new SimpleState(Um::SetLineColor,
2430
 
                                                                                  QString(Um::ColorFromTo).arg(lineColorVal).arg(tmp),
2431
 
                                                                                  Um::IFill);
2432
 
                ss->set("LINE_COLOR", "line_color");
2433
 
                ss->set("OLD_COLOR", lineColorVal);
2434
 
                ss->set("NEW_COLOR", tmp);
2435
 
                undoManager->action(this, ss);
2436
 
        }
2437
 
        lineColorVal = tmp;
2438
 
        setLineQColor();
2439
 
//CB unused in 135      emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
2440
 
}
2441
 
 
2442
 
void PageItem::setLineShade(double newShade)
2443
 
{
2444
 
        if (lineShadeVal == newShade)
2445
 
        {
2446
 
                setLineQColor();
2447
 
                return;
2448
 
        }
2449
 
        if (UndoManager::undoEnabled())
2450
 
        {
2451
 
                SimpleState *ss = new SimpleState(Um::SetLineShade,
2452
 
                                                                                  QString(Um::FromTo).arg(lineShadeVal).arg(newShade),
2453
 
                                                                                  Um::IShade);
2454
 
                ss->set("LINE_SHADE", "line_shade");
2455
 
                ss->set("OLD_SHADE", lineShadeVal);
2456
 
                ss->set("NEW_SHADE", newShade);
2457
 
                undoManager->action(this, ss);
2458
 
        }
2459
 
        lineShadeVal = newShade;
2460
 
        setLineQColor();
2461
 
//CB unused in 135      emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
2462
 
}
2463
 
 
2464
 
void PageItem::setLineQColor()
2465
 
{
2466
 
        if (lineColorVal != CommonStrings::None)
2467
 
        {
2468
 
                if (!m_Doc->PageColors.contains(lineColorVal))
2469
 
                {
2470
 
                        switch(itemType())
2471
 
                        {
2472
 
                                case TextFrame:
2473
 
                                case PathText:
2474
 
                                        lineColorVal = m_Doc->toolSettings.dTextLineColor;
2475
 
                                        break;
2476
 
                                case Line:
2477
 
                                        lineColorVal = m_Doc->toolSettings.dPenLine;
2478
 
                                        break;
2479
 
                                case PolyLine:
2480
 
                                case Polygon:
2481
 
                                case ImageFrame:
2482
 
                                case LatexFrame:
2483
 
                                        lineColorVal = m_Doc->toolSettings.dPen;
2484
 
                                        break;
2485
 
                                default:
2486
 
                                        break;
2487
 
                        }
2488
 
                }
2489
 
                if (!m_Doc->PageColors.contains(lineColorVal))
2490
 
                        lineColorVal = m_Doc->toolSettings.dPen;
2491
 
                const ScColor& col = m_Doc->PageColors[lineColorVal];
2492
 
                strokeQColor = ScColorEngine::getShadeColorProof(col, m_Doc, lineShadeVal);
2493
 
        }
2494
 
        if ((m_Doc->view()) && (m_Doc->view()->m_canvas->usePreviewVisual()))
2495
 
        {
2496
 
                VisionDefectColor defect;
2497
 
                strokeQColor = defect.convertDefect(strokeQColor, m_Doc->view()->m_canvas->previewVisual());
2498
 
        }
2499
 
}
2500
 
 
2501
 
void PageItem::setFillQColor()
2502
 
{
2503
 
        if (fillColorVal != CommonStrings::None)
2504
 
        {
2505
 
                if (!m_Doc->PageColors.contains(fillColorVal))
2506
 
                {
2507
 
                        switch(itemType())
2508
 
                        {
2509
 
                                case ImageFrame:
2510
 
                                case LatexFrame:
2511
 
                                        fillColorVal = m_Doc->toolSettings.dBrushPict;
2512
 
                                case TextFrame:
2513
 
                                case PathText:
2514
 
                                        fillColorVal = m_Doc->toolSettings.dTextBackGround;
2515
 
                                        break;
2516
 
                                case Line:
2517
 
                                case PolyLine:
2518
 
                                case Polygon:
2519
 
                                        fillColorVal = m_Doc->toolSettings.dBrush;
2520
 
                                        break;
2521
 
                                default:
2522
 
                                        break;
2523
 
                        }
2524
 
                }
2525
 
                const ScColor& col = m_Doc->PageColors[fillColorVal];
2526
 
                fillQColor = ScColorEngine::getShadeColorProof(col, m_Doc, fillShadeVal);
2527
 
        }
2528
 
        if ((m_Doc->view()) && (m_Doc->view()->m_canvas->usePreviewVisual()))
2529
 
        {
2530
 
                VisionDefectColor defect;
2531
 
                fillQColor = defect.convertDefect(fillQColor, m_Doc->view()->m_canvas->previewVisual());
2532
 
        }
2533
 
}
2534
 
 
2535
 
void PageItem::setLineTransparency(double newTransparency)
2536
 
{
2537
 
        if (lineTransparencyVal == newTransparency)
2538
 
                return; // nothing to do -> return
2539
 
        if (UndoManager::undoEnabled())
2540
 
        {
2541
 
                SimpleState *ss = new SimpleState(Um::LineTransparency,
2542
 
                                                                                  QString(Um::FromTo).arg(lineTransparencyVal).arg(newTransparency),
2543
 
                                                                                  Um::ITransparency);
2544
 
                ss->set("LINE_TRANSPARENCY", "transparency");
2545
 
                ss->set("OLD_TP", lineTransparencyVal);
2546
 
                ss->set("NEW_TP", newTransparency);
2547
 
                undoManager->action(this, ss);
2548
 
        }
2549
 
        lineTransparencyVal = newTransparency;
2550
 
}
2551
 
 
2552
 
void PageItem::setLineBlendmode(int newBlendmode)
2553
 
{
2554
 
        if (lineBlendmodeVal == newBlendmode)
2555
 
                return; // nothing to do -> return
2556
 
        lineBlendmodeVal = newBlendmode;
2557
 
}
2558
 
 
2559
 
void PageItem::setLineStyle(Qt::PenStyle newStyle)
2560
 
{
2561
 
        if (PLineArt == newStyle)
2562
 
                return; // nothing to do -> return
2563
 
        if (UndoManager::undoEnabled())
2564
 
        {
2565
 
                SimpleState *ss = new SimpleState(Um::LineStyle,"",Um::ILineStyle);
2566
 
                ss->set("LINE_STYLE", "line_style");
2567
 
                ss->set("OLD_STYLE", static_cast<int>(PLineArt));
2568
 
                ss->set("NEW_STYLE", static_cast<int>(newStyle));
2569
 
                undoManager->action(this, ss);
2570
 
        }
2571
 
        PLineArt = newStyle;
2572
 
}
2573
 
 
2574
 
void PageItem::setLineWidth(double newWidth)
2575
 
{
2576
 
        if (m_lineWidth == newWidth)
2577
 
                return; // nothing to do -> return
2578
 
        if (UndoManager::undoEnabled())
2579
 
        {
2580
 
                SimpleState *ss = new SimpleState(Um::LineWidth,
2581
 
                                                QString(Um::FromTo).arg(m_lineWidth).arg(newWidth),Um::ILineStyle);
2582
 
                ss->set("LINE_WIDTH", "line_width");
2583
 
                ss->set("OLD_WIDTH", m_lineWidth);
2584
 
                ss->set("NEW_WIDTH", newWidth);
2585
 
                undoManager->action(this, ss);
2586
 
        }
2587
 
        Oldm_lineWidth=m_lineWidth;
2588
 
        m_lineWidth = newWidth;
2589
 
}
2590
 
 
2591
 
void PageItem::setLineEnd(Qt::PenCapStyle newStyle)
2592
 
{
2593
 
        if (PLineEnd == newStyle)
2594
 
                return; // nothing to do -> return
2595
 
        if (UndoManager::undoEnabled())
2596
 
        {
2597
 
                SimpleState *ss = new SimpleState(Um::LineEnd,"",Um::ILineStyle);
2598
 
                ss->set("LINE_END", "line_end");
2599
 
                ss->set("OLD_STYLE", static_cast<int>(PLineEnd));
2600
 
                ss->set("NEW_STYLE", static_cast<int>(newStyle));
2601
 
                undoManager->action(this, ss);
2602
 
        }
2603
 
        PLineEnd = newStyle;
2604
 
}
2605
 
 
2606
 
void PageItem::setLineJoin(Qt::PenJoinStyle newStyle)
2607
 
{
2608
 
        if (PLineJoin == newStyle)
2609
 
                return; // nothing to do -> return
2610
 
        if (UndoManager::undoEnabled())
2611
 
        {
2612
 
                SimpleState *ss = new SimpleState(Um::LineJoin,"",Um::ILineStyle);
2613
 
                ss->set("LINE_JOIN", "line_join");
2614
 
                ss->set("OLD_STYLE", static_cast<int>(PLineJoin));
2615
 
                ss->set("NEW_STYLE", static_cast<int>(newStyle));
2616
 
                undoManager->action(this, ss);
2617
 
        }
2618
 
        PLineJoin = newStyle;
2619
 
}
2620
 
 
2621
 
void PageItem::setCustomLineStyle(const QString& newStyle)
2622
 
{
2623
 
        if (NamedLStyle == newStyle)
2624
 
                return; // nothing to do -> return
2625
 
        if (UndoManager::undoEnabled())
2626
 
        {
2627
 
                QString oldStyle = NamedLStyle.isEmpty() ? Um::NoStyle : NamedLStyle;
2628
 
                QString nStyle   = newStyle.isEmpty() ? Um::NoStyle : newStyle;
2629
 
                QString action   = newStyle.isEmpty() ? Um::NoLineStyle : Um::CustomLineStyle;
2630
 
                SimpleState *ss = new SimpleState(action,
2631
 
                                QString(Um::FromTo).arg(oldStyle).arg(nStyle),Um::ILineStyle);
2632
 
                ss->set("CUSTOM_LINE_STYLE", "customlinestyle");
2633
 
                ss->set("OLD_STYLE", NamedLStyle);
2634
 
                ss->set("NEW_STYLE", newStyle);
2635
 
                undoManager->action(this, ss);
2636
 
        }
2637
 
        NamedLStyle = newStyle;
2638
 
}
2639
 
 
2640
 
void PageItem::setStartArrowIndex(int newIndex)
2641
 
{
2642
 
        if (m_startArrowIndex == newIndex)
2643
 
                return; // nothing to do -> return
2644
 
        if (UndoManager::undoEnabled())
2645
 
        {
2646
 
                SimpleState *ss = new SimpleState(Um::StartArrow,"",Um::IArrow);
2647
 
                ss->set("START_ARROW", "startarrow");
2648
 
                ss->set("OLD_INDEX", m_startArrowIndex);
2649
 
                ss->set("NEW_INDEX", newIndex);
2650
 
                undoManager->action(this, ss);
2651
 
        }
2652
 
        m_startArrowIndex = newIndex;
2653
 
}
2654
 
 
2655
 
void PageItem::setEndArrowIndex(int newIndex)
2656
 
{
2657
 
        if (m_endArrowIndex == newIndex)
2658
 
                return; // nothing to do -> return
2659
 
        if (UndoManager::undoEnabled())
2660
 
        {
2661
 
                SimpleState *ss = new SimpleState(Um::EndArrow,"",Um::IArrow);
2662
 
                ss->set("END_ARROW", "endarrow");
2663
 
                ss->set("OLD_INDEX", m_endArrowIndex);
2664
 
                ss->set("NEW_INDEX", newIndex);
2665
 
                undoManager->action(this, ss);
2666
 
        }
2667
 
        m_endArrowIndex = newIndex;
2668
 
}
2669
 
 
2670
 
void PageItem::setImageFlippedH(bool flipped)
2671
 
{
2672
 
        if (flipped != m_ImageIsFlippedH)
2673
 
                flipImageH();
2674
 
}
2675
 
 
2676
 
void PageItem::flipImageH()
2677
 
{
2678
 
        if (UndoManager::undoEnabled())
2679
 
        {
2680
 
                SimpleState *ss = new SimpleState(Um::FlipH, 0, Um::IFlipH);
2681
 
                ss->set("IMAGEFLIPH", "imagefliph");
2682
 
                undoManager->action(this, ss);
2683
 
        }
2684
 
        m_ImageIsFlippedH = !m_ImageIsFlippedH;
2685
 
        emit frameFlippedH(m_ImageIsFlippedH);
2686
 
}
2687
 
 
2688
 
void PageItem::setImageFlippedV(bool flipped)
2689
 
{
2690
 
        if (flipped != m_ImageIsFlippedV)
2691
 
                flipImageV();
2692
 
}
2693
 
 
2694
 
void PageItem::flipImageV()
2695
 
{
2696
 
        if (UndoManager::undoEnabled())
2697
 
        {
2698
 
                SimpleState *ss = new SimpleState(Um::FlipV, 0, Um::IFlipV);
2699
 
                ss->set("IMAGEFLIPV", "imageflipv");
2700
 
                undoManager->action(this, ss);
2701
 
        }
2702
 
        m_ImageIsFlippedV = !m_ImageIsFlippedV;
2703
 
        emit frameFlippedV(m_ImageIsFlippedV);
2704
 
}
2705
 
 
2706
 
void PageItem::setImageScalingMode(bool freeScale, bool keepRatio)
2707
 
{
2708
 
        if (ScaleType == freeScale && AspectRatio == keepRatio)
2709
 
                return;
2710
 
        if (UndoManager::undoEnabled())
2711
 
        {
2712
 
                QString from = ScaleType ? Um::FreeScaling : Um::FrameSize;
2713
 
                from += ", ";
2714
 
                from += AspectRatio ? Um::KeepRatio : Um::BreakRatio;
2715
 
                QString to = freeScale ? Um::FreeScaling : Um::FrameSize;
2716
 
                to += ", ";
2717
 
                to += keepRatio ? Um::KeepRatio : Um::BreakRatio;
2718
 
                SimpleState *ss = new SimpleState(Um::ImageScaling, QString(Um::FromTo).arg(from).arg(to), Um::IImageScaling);
2719
 
                ss->set("SCALE_MODE", "scaling_mode");
2720
 
                if (freeScale != ScaleType)
2721
 
                {
2722
 
                        ss->set("SCALE_TYPE", freeScale);
2723
 
                        if (!freeScale)
2724
 
                        {
2725
 
                                //if switching from free scaling to frame size
2726
 
                                //in undo must be offset and scale saved
2727
 
                                ss->set("OLD_IMAGEXOFFSET", LocalX);
2728
 
                                ss->set("OLD_IMAGEYOFFSET", LocalY);
2729
 
                                ss->set("OLD_IMAGEXSCALE", LocalScX);
2730
 
                                ss->set("OLD_IMAGEYSCALE", LocalScY);
2731
 
                        }
2732
 
                }
2733
 
                if (keepRatio != AspectRatio)
2734
 
                        ss->set("ASPECT_RATIO", keepRatio);
2735
 
                undoManager->action(this, ss);
2736
 
        }
2737
 
        ScaleType = freeScale;
2738
 
        AspectRatio = keepRatio;
2739
 
        AdjustPictScale();
2740
 
        update();
2741
 
}
2742
 
 
2743
 
void PageItem::toggleLock()
2744
 
{
2745
 
        if (UndoManager::undoEnabled())
2746
 
        {
2747
 
                SimpleState *ss;
2748
 
                if (m_Locked)
2749
 
                        ss = new SimpleState(Um::UnLock, 0, Um::IUnLock);
2750
 
                else
2751
 
                        ss = new SimpleState(Um::Lock, 0, Um::ILock);
2752
 
                ss->set("LOCK", "lock");
2753
 
                undoManager->action(this, ss);
2754
 
        }
2755
 
        m_Locked = !m_Locked;
2756
 
        emit frameLocked(m_Locked);
2757
 
}
2758
 
 
2759
 
void PageItem::setLocked(bool isLocked)
2760
 
{
2761
 
        if (isLocked != m_Locked)
2762
 
                toggleLock();
2763
 
}
2764
 
 
2765
 
void PageItem::setGroupsLastItem(PageItem* item)
2766
 
{
2767
 
        if (UndoManager::undoEnabled())
2768
 
        {
2769
 
                ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >("GroupsLastItem");
2770
 
                is->set("GROUPS_LASTITEM", "groups_lastitem");
2771
 
                is->setItem(std::pair<PageItem*, PageItem*>(this->groupsLastItem, item));
2772
 
                undoManager->action(this, is);
2773
 
        }
2774
 
        groupsLastItem = item;
2775
 
}
2776
 
 
2777
 
void PageItem::toggleSizeLock()
2778
 
{
2779
 
        if (UndoManager::undoEnabled())
2780
 
        {
2781
 
                SimpleState *ss;
2782
 
                if (m_SizeLocked)
2783
 
                        ss = new SimpleState(Um::SizeUnLock, 0, Um::IUnLock);
2784
 
                else
2785
 
                        ss = new SimpleState(Um::SizeLock, 0, Um::ILock);
2786
 
                ss->set("SIZE_LOCK", "size_lock");
2787
 
                undoManager->action(this, ss);
2788
 
        }
2789
 
        m_SizeLocked = !m_SizeLocked;
2790
 
        emit frameSizeLocked(m_SizeLocked);
2791
 
}
2792
 
 
2793
 
void PageItem::setSizeLocked(bool isLocked)
2794
 
{
2795
 
        if (isLocked != m_SizeLocked)
2796
 
                toggleSizeLock();
2797
 
}
2798
 
 
2799
 
 
2800
 
void PageItem::setPrintEnabled(bool toPrint)
2801
 
{
2802
 
        if (toPrint != m_PrintEnabled)
2803
 
                togglePrintEnabled();
2804
 
}
2805
 
 
2806
 
void PageItem::togglePrintEnabled()
2807
 
{
2808
 
        if (UndoManager::undoEnabled())
2809
 
        {
2810
 
                SimpleState *ss;
2811
 
                if (m_PrintEnabled)
2812
 
                        ss = new SimpleState(Um::DisablePrint, 0, Um::IDisablePrint);
2813
 
                else
2814
 
                        ss = new SimpleState(Um::EnablePrint, 0, Um::IEnablePrint);
2815
 
                ss->set("PRINT_ENABLED", "print_enabled");
2816
 
                undoManager->action(this, ss);
2817
 
        }
2818
 
        m_PrintEnabled=!m_PrintEnabled;
2819
 
        emit printEnabled(m_PrintEnabled);
2820
 
}
2821
 
 
2822
 
void PageItem::setTextFlowMode(TextFlowMode mode)
2823
 
{
2824
 
        if (textFlowModeVal == mode)
2825
 
                return;
2826
 
        if (UndoManager::undoEnabled())
2827
 
        {
2828
 
                QString stateMessage;
2829
 
                if( mode == TextFlowUsesFrameShape )
2830
 
                        stateMessage = Um::ObjectFrame;
2831
 
                else if( mode == TextFlowUsesBoundingBox )
2832
 
                        stateMessage = Um::BoundingBox;
2833
 
                else if( mode == TextFlowUsesContourLine )
2834
 
                        stateMessage = Um::ContourLine;
2835
 
                else if( mode == TextFlowUsesImageClipping )
2836
 
                        stateMessage = Um::ImageClip;
2837
 
                else
2838
 
                        stateMessage = Um::NoTextFlow;
2839
 
                SimpleState *ss = new SimpleState(stateMessage, "", Um::IFont);
2840
 
                ss->set("TEXTFLOW_OLDMODE", (int) textFlowModeVal);
2841
 
                ss->set("TEXTFLOW_NEWMODE", (int) mode);
2842
 
                undoManager->action(this, ss);
2843
 
        }
2844
 
        textFlowModeVal = mode;
2845
 
        
2846
 
        checkTextFlowInteractions();
2847
 
}
2848
 
 
2849
 
void PageItem::checkTextFlowInteractions(bool allItems)
2850
 
{       
2851
 
        if(!m_Doc->isLoading())
2852
 
        {
2853
 
                QRectF baseRect(getBoundingRect());
2854
 
                QList<PageItem*>* items = OnMasterPage.isEmpty() ? &m_Doc->DocItems : &m_Doc->MasterItems;
2855
 
                for(int idx = (allItems ? items->count()-1 : ItemNr-1); idx >= 0 ; --idx)
2856
 
                {
2857
 
                        if(idx != static_cast<int>(ItemNr)) // avoids itself
2858
 
                        {
2859
 
                                if(items->at(idx)->asTextFrame()) // do not bother with no text frames
2860
 
                                {
2861
 
                                        QRectF uRect(items->at(idx)->getBoundingRect());
2862
 
                                        if(baseRect.intersects(uRect))
2863
 
                                        {
2864
 
                                                items->at(idx)->update();
2865
 
                                        }
2866
 
                                }
2867
 
                        }
2868
 
                }
2869
 
        }
2870
 
}
2871
 
 
2872
 
void PageItem::convertTo(ItemType newType)
2873
 
{
2874
 
        if (m_ItemType == newType)
2875
 
                return; // nothing to do -> return
2876
 
        assert(newType != 1);   //DEBUG CR 2005-02-06
2877
 
        assert(newType != 3);   //DEBUG CR 2005-02-06
2878
 
        QString fromType = "", toType = "";
2879
 
        switch (m_ItemType)
2880
 
        {
2881
 
                case ImageFrame:
2882
 
                        if (asLatexFrame()) {
2883
 
                                fromType = Um::LatexFrame;
2884
 
                        } else {
2885
 
                                fromType = Um::ImageFrame;
2886
 
                        }
2887
 
                        break;
2888
 
                case TextFrame:
2889
 
                        fromType = Um::TextFrame;
2890
 
                        break;
2891
 
                case Polygon:
2892
 
                        fromType = Um::Polygon;
2893
 
                        break;
2894
 
                default:
2895
 
                        fromType = "";
2896
 
                        break;
2897
 
        }
2898
 
        switch (newType)
2899
 
        {
2900
 
                case ImageFrame:
2901
 
                        toType = Um::ImageFrame;
2902
 
                        setUPixmap(Um::IImageFrame);
2903
 
                        break;
2904
 
                case LatexFrame:
2905
 
                        toType = Um::LatexFrame;
2906
 
                        setUPixmap(Um::ILatexFrame);
2907
 
                        break;
2908
 
                case TextFrame:
2909
 
                        toType = Um::TextFrame;
2910
 
                        setUPixmap(Um::ITextFrame);
2911
 
                        break;
2912
 
                case Polygon:
2913
 
                        toType = Um::Polygon;
2914
 
                        setUPixmap(Um::IPolygon);
2915
 
                        break;
2916
 
                case PolyLine:
2917
 
                        toType = Um::Polyline;
2918
 
                        setUPixmap(Um::IPolyline);
2919
 
                        break;
2920
 
                default:
2921
 
                        toType = "";
2922
 
                        setUPixmap(NULL);
2923
 
                        break;
2924
 
        }
2925
 
        /*
2926
 
        if (UndoManager::undoEnabled())
2927
 
        {
2928
 
                SimpleState *ss = new SimpleState(Um::ConvertTo + " " + toType,
2929
 
                                                                                  QString(Um::FromTo).arg(fromType).arg(toType));
2930
 
                ss->set("CONVERT", "convert");
2931
 
                ss->set("PAGEITEM", reinterpret_cast<int>(this));
2932
 
                ss->set("OLD_TYPE", m_ItemType);
2933
 
                ss->set("NEW_TYPE", newType);
2934
 
                undoManager->action(this, ss);
2935
 
        }
2936
 
        */
2937
 
        m_ItemType = newType;
2938
 
        emit frameType(m_ItemType);
2939
 
}
2940
 
 
2941
 
void PageItem::setLayer(int layerId)
2942
 
{
2943
 
        if (LayerNr == layerId)
2944
 
                return;
2945
 
        if (UndoManager::undoEnabled())
2946
 
        {
2947
 
                SimpleState *ss = new SimpleState(Um::SendToLayer,
2948
 
                                                                                  QString(Um::FromTo).arg(LayerNr).arg(layerId),
2949
 
                                                                                  Um::ILayerAction);
2950
 
                ss->set("SEND_TO_LAYER", "send_to_layer");
2951
 
                ss->set("OLD_LAYER", LayerNr);
2952
 
                ss->set("NEW_LAYER", layerId);
2953
 
                undoManager->action(this, ss);
2954
 
        }
2955
 
        LayerNr = layerId;
2956
 
}
2957
 
 
2958
 
void PageItem::checkChanges(bool force)
2959
 
{
2960
 
        bool spreadChanges(false);
2961
 
        // has the item been resized
2962
 
        if (force || ((oldWidth != Width || oldHeight != Height) && shouldCheck()))
2963
 
        {
2964
 
                resizeUndoAction();
2965
 
                spreadChanges = (textFlowMode() != TextFlowDisabled );
2966
 
        }
2967
 
        // has the item been rotated
2968
 
        if (force || ((oldRot != Rot) && (shouldCheck())))
2969
 
        {
2970
 
                rotateUndoAction();
2971
 
                spreadChanges = (textFlowMode() != TextFlowDisabled );
2972
 
        }
2973
 
        // has the item been moved
2974
 
        if (force || ((oldXpos != Xpos || oldYpos != Ypos) && shouldCheck()))
2975
 
        {
2976
 
                moveUndoAction();
2977
 
                spreadChanges = (textFlowMode() != TextFlowDisabled );
2978
 
        }
2979
 
        // has the item's image been moved
2980
 
        if (force || ((oldLocalX != LocalX || oldLocalY != LocalY) && shouldCheck()))
2981
 
                changeImageOffsetUndoAction();
2982
 
        // has the item's image been scaled
2983
 
        if (force || ((oldLocalScX != LocalScX || oldLocalScY != LocalScY) && shouldCheck()))
2984
 
                changeImageScaleUndoAction();
2985
 
        
2986
 
        if(spreadChanges)
2987
 
        {
2988
 
                checkTextFlowInteractions();
2989
 
        }
2990
 
}
2991
 
 
2992
 
bool PageItem::shouldCheck()
2993
 
{
2994
 
        return ((!m_Doc->view()->mousePressed()) &&
2995
 
                        (!ScCore->primaryMainWindow()->arrowKeyDown()) &&
2996
 
                        (!ScCore->primaryMainWindow()->propertiesPalette->userActionOn()));
2997
 
}
2998
 
 
2999
 
void PageItem::moveUndoAction()
3000
 
{
3001
 
        if (oldXpos == Xpos && oldYpos == Ypos)
3002
 
                return;
3003
 
        if (UndoManager::undoEnabled())
3004
 
        {
3005
 
                QString oldp;
3006
 
                QString newp;
3007
 
                if (oldOwnPage == -1)
3008
 
                        oldp = Um::ScratchSpace;
3009
 
                else
3010
 
                        oldp = QString(Um::PageNmbr).arg(m_Doc->FirstPnum + oldOwnPage);
3011
 
                if (OwnPage == -1)
3012
 
                        newp = Um::ScratchSpace;
3013
 
                else
3014
 
                        newp = QString(Um::PageNmbr).arg(m_Doc->FirstPnum + OwnPage);
3015
 
                SimpleState *ss = new SimpleState(Um::Move,
3016
 
                                          QString(Um::MoveFromTo).arg(oldXpos).arg(oldYpos).arg(oldp).
3017
 
                                                                  arg(Xpos).arg(Ypos).arg(newp), Um::IMove);
3018
 
                ss->set("OLD_XPOS", oldXpos);
3019
 
                ss->set("OLD_YPOS", oldYpos);
3020
 
                ss->set("NEW_XPOS", Xpos);
3021
 
                ss->set("NEW_YPOS", Ypos);
3022
 
                undoManager->action(this, ss);
3023
 
        }
3024
 
        oldXpos = Xpos;
3025
 
        oldYpos = Ypos;
3026
 
        oldOwnPage = OwnPage;
3027
 
}
3028
 
 
3029
 
void PageItem::resizeUndoAction()
3030
 
{
3031
 
        if (oldHeight == Height && oldWidth == Width)
3032
 
                return;
3033
 
        if (UndoManager::undoEnabled())
3034
 
        {
3035
 
                SimpleState *ss = new SimpleState(Um::Resize,
3036
 
                           QString(Um::ResizeFromTo).arg(oldWidth).arg(oldHeight).arg(Width).arg(Height),
3037
 
                                          Um::IResize);
3038
 
                ss->set("OLD_WIDTH", oldWidth);
3039
 
                ss->set("OLD_HEIGHT", oldHeight);
3040
 
                ss->set("NEW_WIDTH", Width);
3041
 
                ss->set("NEW_HEIGHT", Height);
3042
 
                ss->set("OLD_RXPOS", oldXpos);
3043
 
                ss->set("OLD_RYPOS", oldYpos);
3044
 
                ss->set("NEW_RXPOS", Xpos);
3045
 
                ss->set("NEW_RYPOS", Ypos);
3046
 
                ss->set("OLD_RROT", oldRot);
3047
 
                ss->set("NEW_RROT", Rot);
3048
 
                undoManager->action(this, ss);
3049
 
        }
3050
 
        oldXpos = Xpos;
3051
 
        oldYpos = Ypos;
3052
 
        oldHeight = Height;
3053
 
        oldWidth = Width;
3054
 
        oldOwnPage = OwnPage;
3055
 
        oldRot = Rot;
3056
 
}
3057
 
 
3058
 
void PageItem::rotateUndoAction()
3059
 
{
3060
 
        if (oldRot == Rot)
3061
 
                return;
3062
 
        if (UndoManager::undoEnabled())
3063
 
        {
3064
 
                SimpleState *ss = new SimpleState(Um::Rotate,
3065
 
                                          QString(Um::FromTo).arg(oldRot).arg(Rot),
3066
 
                                          Um::IRotate);
3067
 
                ss->set("OLD_ROT", oldRot);
3068
 
                ss->set("NEW_ROT", Rot);
3069
 
                ss->set("OLD_RXPOS", oldXpos);
3070
 
                ss->set("OLD_RYPOS", oldYpos);
3071
 
                ss->set("NEW_RXPOS", Xpos);
3072
 
                ss->set("NEW_RYPOS", Ypos);
3073
 
                ss->set("OLD_RWIDTH", oldWidth);
3074
 
                ss->set("OLD_RHEIGHT", oldHeight);
3075
 
                ss->set("NEW_RWIDTH", Width);
3076
 
                ss->set("NEW_RHEIGHT", Height);
3077
 
                undoManager->action(this, ss);
3078
 
        }
3079
 
        oldRot = Rot;
3080
 
        oldXpos = Xpos;
3081
 
        oldYpos = Ypos;
3082
 
        oldOwnPage = OwnPage;
3083
 
        oldWidth = Width;
3084
 
        oldHeight = Height;
3085
 
}
3086
 
 
3087
 
void PageItem::changeImageOffsetUndoAction()
3088
 
{
3089
 
        if (oldLocalX == LocalX && oldLocalY == LocalY)
3090
 
                return;
3091
 
        if (UndoManager::undoEnabled())
3092
 
        {
3093
 
                SimpleState *ss = new SimpleState(Um::ImageOffset,
3094
 
                        QString(Um::ImageOffsetFromTo).arg(oldLocalX).arg(oldLocalY).arg(LocalX).arg(LocalY), Um::IMove);
3095
 
                ss->set("IMAGE_OFFSET", "image_offset");
3096
 
                ss->set("OLD_IMAGEXOFFSET", oldLocalX);
3097
 
                ss->set("OLD_IMAGEYOFFSET", oldLocalY);
3098
 
                ss->set("NEW_IMAGEXOFFSET", LocalX);
3099
 
                ss->set("NEW_IMAGEYOFFSET", LocalY);
3100
 
                undoManager->action(this, ss);
3101
 
        }
3102
 
        oldLocalX = LocalX;
3103
 
        oldLocalY = LocalY;
3104
 
}
3105
 
 
3106
 
void PageItem::changeImageScaleUndoAction()
3107
 
{
3108
 
        //#9817: Hack for this rounding issue caused by conversion to text values. Undo needs fixing.
3109
 
        if ((ScCLocale::toDoubleC(ScCLocale::toQStringC(oldLocalScX)) ==
3110
 
                ScCLocale::toDoubleC(ScCLocale::toQStringC(LocalScX)))
3111
 
                && (ScCLocale::toDoubleC(ScCLocale::toQStringC(oldLocalScY)) ==
3112
 
                ScCLocale::toDoubleC(ScCLocale::toQStringC(LocalScY))))
3113
 
                return;
3114
 
        if (UndoManager::undoEnabled())
3115
 
        {
3116
 
                SimpleState *ss = new SimpleState(Um::ImageScale,
3117
 
                        QString(Um::ImageScaleFromTo).arg(oldLocalScX).arg(oldLocalScY).arg(LocalScX).arg(LocalScY), Um::IMove);
3118
 
                ss->set("IMAGE_SCALE", "image_scale");
3119
 
                ss->set("OLD_IMAGEXSCALE", oldLocalScX);
3120
 
                ss->set("OLD_IMAGEYSCALE", oldLocalScY);
3121
 
                ss->set("NEW_IMAGEXSCALE", LocalScX);
3122
 
                ss->set("NEW_IMAGEYSCALE", LocalScY);
3123
 
                undoManager->action(this, ss);
3124
 
        }
3125
 
        oldLocalScX = LocalScX;
3126
 
        oldLocalScY = LocalScY;
3127
 
}
3128
 
 
3129
 
void PageItem::restore(UndoState *state, bool isUndo)
3130
 
{
3131
 
        bool useRasterBackup = m_Doc->useRaster;
3132
 
        bool SnapGuidesBackup = m_Doc->SnapGuides;
3133
 
        m_Doc->useRaster = false;
3134
 
        m_Doc->SnapGuides = false;
3135
 
        SimpleState *ss = dynamic_cast<SimpleState*>(state);
3136
 
        bool oldMPMode=m_Doc->masterPageMode();
3137
 
        m_Doc->setMasterPageMode(!OnMasterPage.isEmpty());
3138
 
        Page *oldCurrentPage = m_Doc->currentPage();
3139
 
        if (!OnMasterPage.isEmpty())
3140
 
        {
3141
 
                oldCurrentPage = m_Doc->currentPage();
3142
 
                m_Doc->setCurrentPage(m_Doc->MasterPages.at(m_Doc->MasterNames[OnMasterPage]));
3143
 
        }
3144
 
        if (ss)
3145
 
        {
3146
 
                if (ss->contains("OLD_XPOS"))
3147
 
                        restoreMove(ss, isUndo);
3148
 
                else if (ss->contains("OLD_HEIGHT"))
3149
 
                        restoreResize(ss, isUndo);
3150
 
                else if (ss->contains("OLD_ROT"))
3151
 
                        restoreRotate(ss, isUndo);
3152
 
                else if (ss->contains("FILL"))
3153
 
                        restoreFill(ss, isUndo);
3154
 
                else if (ss->contains("SHADE"))
3155
 
                        restoreShade(ss, isUndo);
3156
 
                else if (ss->contains("LINE_COLOR"))
3157
 
                        restoreLineColor(ss, isUndo);
3158
 
                else if (ss->contains("LINE_SHADE"))
3159
 
                        restoreLineShade(ss, isUndo);
3160
 
                else if (ss->contains("IMAGEFLIPH"))
3161
 
                {
3162
 
                        select();
3163
 
                        m_Doc->itemSelection_FlipH();
3164
 
                }
3165
 
                else if (ss->contains("IMAGEFLIPV"))
3166
 
                {
3167
 
                        select();
3168
 
                        m_Doc->itemSelection_FlipV();
3169
 
                }
3170
 
                else if (ss->contains("LOCK"))
3171
 
                {
3172
 
                        select();
3173
 
                        m_Doc->itemSelection_ToggleLock();
3174
 
                }
3175
 
                else if (ss->contains("SIZE_LOCK"))
3176
 
                {
3177
 
                        select();
3178
 
                        m_Doc->itemSelection_ToggleSizeLock();
3179
 
                }
3180
 
                else if (ss->contains("PRINT_ENABLED"))
3181
 
                {
3182
 
                        select();
3183
 
                        m_Doc->itemSelection_TogglePrintEnabled();
3184
 
                }
3185
 
                else if (ss->contains("NEW_NAME"))
3186
 
                        restoreName(ss, isUndo);
3187
 
                else if (ss->contains("TRANSPARENCY"))
3188
 
                        restoreFillTP(ss, isUndo);
3189
 
                else if (ss->contains("LINE_TRANSPARENCY"))
3190
 
                        restoreLineTP(ss, isUndo);
3191
 
                else if (ss->contains("LINE_STYLE"))
3192
 
                        restoreLineStyle(ss, isUndo);
3193
 
                else if (ss->contains("LINE_END"))
3194
 
                        restoreLineEnd(ss, isUndo);
3195
 
                else if (ss->contains("LINE_JOIN"))
3196
 
                        restoreLineJoin(ss, isUndo);
3197
 
                else if (ss->contains("LINE_WIDTH"))
3198
 
                        restoreLineWidth(ss, isUndo);
3199
 
                else if (ss->contains("CUSTOM_LINE_STYLE"))
3200
 
                        restoreCustomLineStyle(ss, isUndo);
3201
 
                else if (ss->contains("START_ARROW"))
3202
 
                        restoreArrow(ss, isUndo, true);
3203
 
                else if (ss->contains("END_ARROW"))
3204
 
                        restoreArrow(ss, isUndo, false);
3205
 
                else if (ss->contains("PSTYLE"))
3206
 
                        restorePStyle(ss, isUndo);
3207
 
                else if (ss->contains("CONVERT"))
3208
 
                        restoreType(ss, isUndo);
3209
 
                else if (ss->contains("TEXTFLOW_OLDMODE"))
3210
 
                        restoreTextFlowing(ss, isUndo);
3211
 
                else if (ss->contains("SCALE_MODE"))
3212
 
                        restoreImageScaleMode(ss, isUndo);
3213
 
                else if (ss->contains("IMAGE_SCALE"))
3214
 
                        restoreImageScaleChange(ss, isUndo);
3215
 
                else if (ss->contains("IMAGE_OFFSET"))
3216
 
                        restoreImageOffsetChange(ss, isUndo);   
3217
 
                else if (ss->contains("EDIT_CONTOUR"))
3218
 
                        restorePoly(ss, isUndo, true);
3219
 
                else if (ss->contains("EDIT_SHAPE"))
3220
 
                        restorePoly(ss, isUndo, false);
3221
 
                else if (ss->contains("RESET_CONTOUR"))
3222
 
                        restoreContourLine(ss, isUndo);
3223
 
                else if (ss->contains("CHANGE_SHAPE_TYPE"))
3224
 
                        restoreShapeType(ss, isUndo);
3225
 
                else if (ss->contains("MIRROR_PATH_H"))
3226
 
                {
3227
 
                        bool editContour = m_Doc->nodeEdit.isContourLine;
3228
 
                        m_Doc->nodeEdit.isContourLine = ss->getBool("IS_CONTOUR");
3229
 
                        select();
3230
 
                        m_Doc->MirrorPolyH(m_Doc->m_Selection->itemAt(0));
3231
 
                        m_Doc->nodeEdit.isContourLine = editContour;
3232
 
                }
3233
 
                else if (ss->contains("MIRROR_PATH_V"))
3234
 
                {
3235
 
                        bool editContour = m_Doc->nodeEdit.isContourLine;
3236
 
                        m_Doc->nodeEdit.isContourLine = ss->getBool("IS_CONTOUR");
3237
 
                        select();
3238
 
                        m_Doc->MirrorPolyV(m_Doc->m_Selection->itemAt(0));
3239
 
                        m_Doc->nodeEdit.isContourLine = editContour;
3240
 
                }
3241
 
                else if (ss->contains("SEND_TO_LAYER"))
3242
 
                        restoreLayer(ss, isUndo);
3243
 
                else if (ss->contains("GET_IMAGE"))
3244
 
                        restoreGetImage(ss, isUndo);
3245
 
                else if (ss->contains("GROUPS_LASTITEM"))
3246
 
                        restoreGroupsLastItem(ss, isUndo);
3247
 
                else if (ss->contains("EDIT_SHAPE_OR_CONTOUR"))
3248
 
                        restoreShapeContour(ss, isUndo);
3249
 
                else if (ss->contains("APPLY_IMAGE_EFFECTS"))
3250
 
                        restoreImageEffects(ss, isUndo);
3251
 
                else if (ss->contains("STEXT"))
3252
 
                        restoreEditText(ss, isUndo);
3253
 
                else if (ss->contains("CLEAR_IMAGE"))
3254
 
                        restoreClearImage(ss,isUndo);
3255
 
                else if (ss->contains("LINK_TEXT_FRAME"))
3256
 
                        restoreLinkTextFrame(ss,isUndo);
3257
 
                else if (ss->contains("UNLINK_TEXT_FRAME"))
3258
 
                        restoreUnlinkTextFrame(ss,isUndo);
3259
 
        }
3260
 
        if (!OnMasterPage.isEmpty())
3261
 
                m_Doc->setCurrentPage(oldCurrentPage);
3262
 
        m_Doc->setMasterPageMode(oldMPMode);
3263
 
        m_Doc->useRaster = useRasterBackup;
3264
 
        m_Doc->SnapGuides = SnapGuidesBackup;
3265
 
}
3266
 
 
3267
 
void PageItem::restoreMove(SimpleState *state, bool isUndo)
3268
 
{
3269
 
        double ox = state->getDouble("OLD_XPOS");
3270
 
        double oy = state->getDouble("OLD_YPOS");
3271
 
        double  x = state->getDouble("NEW_XPOS");
3272
 
        double  y = state->getDouble("NEW_YPOS");
3273
 
        double mx = ox - x;
3274
 
        double my = oy - y;
3275
 
        if (!isUndo)
3276
 
        {
3277
 
                mx = -mx;
3278
 
                my = -my;
3279
 
        }
3280
 
        m_Doc->MoveItem(mx, my, this, false);
3281
 
        oldXpos = Xpos;
3282
 
        oldYpos = Ypos;
3283
 
        oldOwnPage = OwnPage;
3284
 
}
3285
 
 
3286
 
void PageItem::restoreResize(SimpleState *state, bool isUndo)
3287
 
{
3288
 
        double  ow = state->getDouble("OLD_WIDTH");
3289
 
        double  oh = state->getDouble("OLD_HEIGHT");
3290
 
        double   w = state->getDouble("NEW_WIDTH");
3291
 
        double   h = state->getDouble("NEW_HEIGHT");
3292
 
        double  ox = state->getDouble("OLD_RXPOS");
3293
 
        double  oy = state->getDouble("OLD_RYPOS");
3294
 
        double   x = state->getDouble("NEW_RXPOS");
3295
 
        double   y = state->getDouble("NEW_RYPOS");
3296
 
        double ort = state->getDouble("OLD_RROT");
3297
 
        double  rt = state->getDouble("NEW_RROT");
3298
 
        double  mx = ox - x;
3299
 
        double  my = oy - y;
3300
 
        int  stateCode = state->transactionCode;
3301
 
        bool redraw = ((stateCode != 1) && (stateCode != 3));
3302
 
        if (isUndo)
3303
 
        {
3304
 
                m_Doc->SizeItem(ow, oh, this, false, true, redraw);
3305
 
                m_Doc->MoveItem(mx, my, this, false);
3306
 
                m_Doc->RotateItem(ort, this);
3307
 
        }
3308
 
        else
3309
 
        {
3310
 
                mx = -mx;
3311
 
                my = -my;
3312
 
                m_Doc->SizeItem(w, h, this, false, true, redraw);
3313
 
                m_Doc->MoveItem(mx, my, this, false);
3314
 
                m_Doc->RotateItem(rt, this);
3315
 
        }
3316
 
        oldWidth = Width;
3317
 
        oldHeight = Height;
3318
 
        oldXpos = Xpos;
3319
 
        oldYpos = Ypos;
3320
 
        oldOwnPage = OwnPage;
3321
 
        oldRot = Rot;
3322
 
}
3323
 
 
3324
 
void PageItem::restoreRotate(SimpleState *state, bool isUndo)
3325
 
{
3326
 
        double ort = state->getDouble("OLD_ROT");
3327
 
        double  rt = state->getDouble("NEW_ROT");
3328
 
        double  ox = state->getDouble("OLD_RXPOS");
3329
 
        double  oy = state->getDouble("OLD_RYPOS");
3330
 
        double   x = state->getDouble("NEW_RXPOS");
3331
 
        double   y = state->getDouble("NEW_RYPOS");
3332
 
        double  ow = state->getDouble("OLD_RWIDTH");
3333
 
        double  oh = state->getDouble("OLD_RHEIGHT");
3334
 
        double   w = state->getDouble("NEW_RWIDTH");
3335
 
        double   h = state->getDouble("NEW_RHEIGHT");
3336
 
        int  stateCode = state->transactionCode;
3337
 
        bool redraw = ((stateCode != 1) && (stateCode != 3));;
3338
 
        //CB Commented out test code
3339
 
        //QRect oldR(getRedrawBounding(view->scale()));
3340
 
        //double mx = ox - x;
3341
 
        //double my = oy - y;
3342
 
        if (isUndo)
3343
 
        {
3344
 
                /*Rot=ort;
3345
 
                Xpos+=mx;
3346
 
                Ypos+=my;
3347
 
                Width=ow;
3348
 
                Height=oh;*/
3349
 
                m_Doc->RotateItem(ort, this);
3350
 
                m_Doc->MoveItem(ox - Xpos, oy - Ypos, this, false);
3351
 
                m_Doc->SizeItem(ow, oh, this, false, true, redraw);
3352
 
        }
3353
 
        else
3354
 
        {
3355
 
                /*mx = -mx;
3356
 
                my = -my;
3357
 
                Rot=rt;
3358
 
                Xpos-=mx;
3359
 
                Ypos-=my;
3360
 
                Width=w;
3361
 
                Height=h;
3362
 
                */
3363
 
                m_Doc->RotateItem(rt, this);
3364
 
                m_Doc->MoveItem(x - Xpos, y - Ypos, this, false);
3365
 
                m_Doc->SizeItem(w, h, this, false, true, redraw);
3366
 
        }
3367
 
        /*
3368
 
        m_Doc->setRedrawBounding(this);
3369
 
        QRect newR(getRedrawBounding(view->scale()));
3370
 
        view->updateContents(newR.unite(oldR));
3371
 
        OwnPage = m_Doc->OnPage(this);
3372
 
        */
3373
 
        oldRot = Rot;
3374
 
        oldXpos = Xpos;
3375
 
        oldYpos = Ypos;
3376
 
        oldOwnPage = OwnPage;
3377
 
        oldWidth = Width;
3378
 
        oldHeight = Height;
3379
 
}
3380
 
 
3381
 
void PageItem::restoreFill(SimpleState *state, bool isUndo)
3382
 
{
3383
 
        QString fill = state->get("OLD_FILL");
3384
 
        if (!isUndo)
3385
 
                fill = state->get("NEW_FILL");
3386
 
        select();
3387
 
        m_Doc->itemSelection_SetItemBrush(fill);
3388
 
}
3389
 
 
3390
 
void PageItem::restoreShade(SimpleState *state, bool isUndo)
3391
 
{
3392
 
        int shade = state->getInt("OLD_SHADE");
3393
 
        if (!isUndo)
3394
 
                shade = state->getInt("NEW_SHADE");
3395
 
        select();
3396
 
        m_Doc->itemSelection_SetItemBrushShade(shade);
3397
 
}
3398
 
 
3399
 
void PageItem::restoreLineColor(SimpleState *state, bool isUndo)
3400
 
{
3401
 
        QString fill = state->get("OLD_COLOR");
3402
 
        if (!isUndo)
3403
 
                fill = state->get("NEW_COLOR");
3404
 
        select();
3405
 
        m_Doc->itemSelection_SetItemPen(fill);
3406
 
}
3407
 
 
3408
 
void PageItem::restoreLineShade(SimpleState *state, bool isUndo)
3409
 
{
3410
 
        int shade = state->getInt("OLD_SHADE");
3411
 
        if (!isUndo)
3412
 
                shade = state->getInt("NEW_SHADE");
3413
 
        select();
3414
 
        m_Doc->itemSelection_SetItemPenShade(shade);
3415
 
}
3416
 
 
3417
 
void PageItem::restoreFillTP(SimpleState *state, bool isUndo)
3418
 
{
3419
 
        double tp = state->getDouble("OLD_TP");
3420
 
        if (!isUndo)
3421
 
                tp = state->getDouble("NEW_TP");
3422
 
        select();
3423
 
        m_Doc->itemSelection_SetItemFillTransparency(tp);
3424
 
}
3425
 
 
3426
 
void PageItem::restoreLineTP(SimpleState *state, bool isUndo)
3427
 
{
3428
 
        double tp = state->getDouble("OLD_TP");
3429
 
        if (!isUndo)
3430
 
                tp = state->getDouble("NEW_TP");
3431
 
        select();
3432
 
        m_Doc->itemSelection_SetItemLineTransparency(tp);
3433
 
}
3434
 
 
3435
 
 
3436
 
void PageItem::restoreLineStyle(SimpleState *state, bool isUndo)
3437
 
{
3438
 
        Qt::PenStyle ps = static_cast<Qt::PenStyle>(state->getInt("OLD_STYLE"));
3439
 
        if (!isUndo)
3440
 
                ps = static_cast<Qt::PenStyle>(state->getInt("NEW_STYLE"));
3441
 
        select();
3442
 
        m_Doc->itemSelection_SetLineArt(ps);
3443
 
}
3444
 
 
3445
 
void PageItem::restoreLineEnd(SimpleState *state, bool isUndo)
3446
 
{
3447
 
        Qt::PenCapStyle pcs = static_cast<Qt::PenCapStyle>(state->getInt("OLD_STYLE"));
3448
 
        if (!isUndo)
3449
 
                pcs = static_cast<Qt::PenCapStyle>(state->getInt("NEW_STYLE"));
3450
 
        select();
3451
 
        m_Doc->itemSelection_SetLineEnd(pcs);
3452
 
}
3453
 
 
3454
 
void PageItem::restoreLineJoin(SimpleState *state, bool isUndo)
3455
 
{
3456
 
        Qt::PenJoinStyle pjs = static_cast<Qt::PenJoinStyle>(state->getInt("OLD_STYLE"));
3457
 
        if (!isUndo)
3458
 
                pjs = static_cast<Qt::PenJoinStyle>(state->getInt("NEW_STYLE"));
3459
 
        select();
3460
 
        m_Doc->itemSelection_SetLineJoin(pjs);
3461
 
}
3462
 
 
3463
 
void PageItem::restoreLineWidth(SimpleState *state, bool isUndo)
3464
 
{
3465
 
        double w = state->getDouble("OLD_WIDTH");
3466
 
        if (!isUndo)
3467
 
                w = state->getDouble("NEW_WIDTH");
3468
 
        select();
3469
 
        m_Doc->itemSelection_SetLineWidth(w);
3470
 
}
3471
 
 
3472
 
void PageItem::restoreCustomLineStyle(SimpleState *state, bool isUndo)
3473
 
{
3474
 
        QString style = state->get("OLD_STYLE");
3475
 
        if (!isUndo)
3476
 
                style = state->get("NEW_STYLE");
3477
 
        setCustomLineStyle(style);
3478
 
}
3479
 
 
3480
 
void PageItem::restoreName(SimpleState *state, bool isUndo)
3481
 
{
3482
 
        QString name = state->get("OLD_NAME");
3483
 
        if (!isUndo)
3484
 
                name = state->get("NEW_NAME");
3485
 
        setItemName(name);
3486
 
}
3487
 
 
3488
 
void PageItem::restoreArrow(SimpleState *state, bool isUndo, bool isStart)
3489
 
{
3490
 
        int i = state->getInt("OLD_INDEX");
3491
 
        if (!isUndo)
3492
 
                i = state->getInt("NEW_INDEX");
3493
 
        if (isStart)
3494
 
                setStartArrowIndex(i);
3495
 
        else
3496
 
                setEndArrowIndex(i);
3497
 
}
3498
 
 
3499
 
 
3500
 
void PageItem::restorePStyle(SimpleState *state, bool isUndo)
3501
 
{
3502
 
        int styleid = state->getInt("OLD_STYLE");
3503
 
        if (!isUndo)
3504
 
                styleid = state->getInt("NEW_STYLE");
3505
 
        //will be done later with other text-undo:
3506
 
        //      m_Doc->chAbStyle(this, styleid);
3507
 
}
3508
 
 
3509
 
 
3510
 
// FIXME: This must go into class ScribusDoc!
3511
 
// For now we'll just make it independent of 'this' -- AV
3512
 
void PageItem::restoreType(SimpleState *state, bool isUndo)
3513
 
{
3514
 
        // well, probably not the best way to handle pointers...
3515
 
        PageItem * item = reinterpret_cast<PageItem *>(state->getInt("PAGEITEM"));
3516
 
        int type = state->getInt("OLD_TYPE");
3517
 
        if (!isUndo)
3518
 
                type = state->getInt("NEW_TYPE");
3519
 
        ScribusView* view = m_Doc->view();
3520
 
        view->Deselect(false);
3521
 
        view->SelectItem(item, false);
3522
 
        switch (type) {
3523
 
                case ImageFrame: view->ToPicFrame(); break;
3524
 
                case TextFrame: view->ToTextFrame(); break;
3525
 
                case Polygon: view->ToPolyFrame(); break;
3526
 
                case PolyLine: view->ToBezierFrame(); break;
3527
 
        }
3528
 
        view->requestMode(modeNormal);
3529
 
}
3530
 
 
3531
 
void PageItem::restoreTextFlowing(SimpleState *state, bool isUndo)
3532
 
{
3533
 
        TextFlowMode oldMode = (TextFlowMode) state->getInt("TEXTFLOW_OLDMODE");
3534
 
        TextFlowMode newMode = (TextFlowMode) state->getInt("TEXTFLOW_NEWMODE");
3535
 
        if (isUndo)
3536
 
                textFlowModeVal = oldMode;
3537
 
        else
3538
 
                textFlowModeVal = newMode;
3539
 
        
3540
 
        QList<PageItem*> pList;
3541
 
        for(int idx = ItemNr-1; idx >= 0 ; --idx)
3542
 
        {
3543
 
                pList << m_Doc->Items->at(idx);
3544
 
        }
3545
 
                
3546
 
        QRectF baseRect(getBoundingRect());
3547
 
        for(int idx(0); idx < pList.count(); ++idx)
3548
 
        {
3549
 
                QRectF uRect(pList.at(idx)->getBoundingRect());
3550
 
                if(baseRect.intersects(uRect))
3551
 
                        pList.at(idx)->update();
3552
 
        }
3553
 
}
3554
 
 
3555
 
void PageItem::restoreImageScaleMode(SimpleState *state, bool isUndo)
3556
 
{
3557
 
        bool type=ScaleType;
3558
 
        if (state->contains("SCALE_TYPE"))
3559
 
        {
3560
 
                if (isUndo)
3561
 
                        type = !state->getBool("SCALE_TYPE");
3562
 
                else
3563
 
                        type = state->getBool("SCALE_TYPE");
3564
 
                //if restoring free scaling
3565
 
                //old offset and scale ratio must be restored
3566
 
                if (type)
3567
 
                {
3568
 
                        double oscx = state->getDouble("OLD_IMAGEXSCALE");
3569
 
                        double oscy = state->getDouble("OLD_IMAGEYSCALE");
3570
 
                        double ox = state->getDouble("OLD_IMAGEXOFFSET");
3571
 
                        double oy = state->getDouble("OLD_IMAGEYOFFSET");
3572
 
                        Selection tempSelection(this, false);
3573
 
                        tempSelection.addItem(this, true);
3574
 
                        m_Doc->itemSelection_SetImageScale(oscx, oscy, &tempSelection);
3575
 
                        m_Doc->itemSelection_SetImageOffset(ox, oy, &tempSelection);
3576
 
                }
3577
 
 
3578
 
        }
3579
 
 
3580
 
        bool ratio=AspectRatio;
3581
 
        if (state->contains("ASPECT_RATIO"))
3582
 
        {
3583
 
                if (isUndo)
3584
 
                        ratio = !state->getBool("ASPECT_RATIO");
3585
 
                else
3586
 
                        ratio = state->getBool("ASPECT_RATIO");
3587
 
        }
3588
 
 
3589
 
        setImageScalingMode(type, ratio);
3590
 
}
3591
 
 
3592
 
void PageItem::restoreImageScaleChange(SimpleState *state, bool isUndo)
3593
 
{
3594
 
        double oscx = state->getDouble("OLD_IMAGEXSCALE");
3595
 
        double oscy = state->getDouble("OLD_IMAGEYSCALE");
3596
 
        double  scx = state->getDouble("NEW_IMAGEXSCALE");
3597
 
        double  scy = state->getDouble("NEW_IMAGEYSCALE");
3598
 
        Selection tempSelection(this, false);
3599
 
        tempSelection.addItem(this, true);
3600
 
        if (!isUndo)
3601
 
                m_Doc->itemSelection_SetImageScale(scx, scy, &tempSelection);
3602
 
        else
3603
 
                m_Doc->itemSelection_SetImageScale(oscx, oscy, &tempSelection);
3604
 
}
3605
 
 
3606
 
void PageItem::restoreImageOffsetChange(SimpleState *state, bool isUndo)
3607
 
{
3608
 
        double ox = state->getDouble("OLD_IMAGEXOFFSET");
3609
 
        double oy = state->getDouble("OLD_IMAGEYOFFSET");
3610
 
        double  x = state->getDouble("NEW_IMAGEXOFFSET");
3611
 
        double  y = state->getDouble("NEW_IMAGEYOFFSET");
3612
 
        Selection tempSelection(this, false);
3613
 
        tempSelection.addItem(this, true);
3614
 
        if (!isUndo)
3615
 
                m_Doc->itemSelection_SetImageOffset(x, y, &tempSelection);
3616
 
        else
3617
 
                m_Doc->itemSelection_SetImageOffset(ox, oy, &tempSelection);
3618
 
}
3619
 
 
3620
 
void PageItem::restoreClearImage(UndoState *state, bool isUndo)
3621
 
{
3622
 
        if (!isImageFrame())
3623
 
                return;
3624
 
        if (isUndo)
3625
 
        {
3626
 
                ItemState<ScImageEffectList> *is = dynamic_cast<ItemState<ScImageEffectList>*>(state);
3627
 
                Pfile = is->get("CI_PFILE");
3628
 
                loadImage(Pfile, false);
3629
 
                effectsInUse = is->getItem();
3630
 
                setImageFlippedH(is->getBool("CI_FLIPPH"));
3631
 
                setImageFlippedV(is->getBool("CI_FLIPPV"));
3632
 
                setImageScalingMode(is->getBool("CI_SCALING"),is->getBool("CI_ASPECT"));
3633
 
                setImageXYOffset(is->getDouble("CI_XOFF"), is->getDouble("CI_YOFF"));
3634
 
                setImageXYScale(is->getDouble("CI_XSCALE"), is->getDouble("CI_YSCALE"));
3635
 
                setFillTransparency(is->getDouble("CI_FILLT"));
3636
 
                setLineTransparency(is->getDouble("CI_LINET"));
3637
 
                select();
3638
 
                m_Doc->updatePic();
3639
 
        }
3640
 
        else
3641
 
                asImageFrame()->clearContents();
3642
 
}
3643
 
 
3644
 
void PageItem::restoreLinkTextFrame(UndoState *state, bool isUndo)
3645
 
{
3646
 
        if (!isTextFrame())
3647
 
                return;
3648
 
        if (isUndo)
3649
 
        {
3650
 
                unlink();
3651
 
        }
3652
 
        else
3653
 
        {
3654
 
                ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> >*>(state);
3655
 
                asTextFrame()->link(is->getItem().second->asTextFrame());
3656
 
        }
3657
 
}
3658
 
 
3659
 
void PageItem::restoreUnlinkTextFrame(UndoState *state, bool isUndo)
3660
 
{
3661
 
        if (!isTextFrame())
3662
 
                return;
3663
 
        if (isUndo)
3664
 
        {
3665
 
                ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> >*>(state);
3666
 
                asTextFrame()->link(is->getItem().second->asTextFrame());
3667
 
        }
3668
 
        else
3669
 
        {
3670
 
                unlink();
3671
 
        }
3672
 
}
3673
 
 
3674
 
 
3675
 
void PageItem::restorePoly(SimpleState *state, bool isUndo, bool isContour)
3676
 
{
3677
 
        int mode    = state->getInt("MODE");
3678
 
        int rot     = state->getInt("ROT");
3679
 
        ScribusView* view = m_Doc->view();
3680
 
        double scaling = state->getDouble("SCALING");
3681
 
        bool editContour = m_Doc->nodeEdit.isContourLine;
3682
 
        m_Doc->nodeEdit.isContourLine = isContour;
3683
 
        select();
3684
 
        if (isUndo)
3685
 
        {
3686
 
                if (mode % 2 != 0 && mode != 0)
3687
 
                        --mode;
3688
 
                else
3689
 
                        ++mode;
3690
 
                if (mode == 2)
3691
 
                        scaling = (1.0 - (100.0 / (100.0 + scaling))) * 100.0;
3692
 
                else if (mode == 3)
3693
 
                        scaling = ((100.0 / (100.0 - scaling)) - 1.0) * 100.0;
3694
 
        }
3695
 
        view->TransformPoly(mode, rot, scaling);
3696
 
        m_Doc->nodeEdit.isContourLine = editContour;
3697
 
}
3698
 
 
3699
 
void PageItem::restoreContourLine(SimpleState *state, bool isUndo)
3700
 
{
3701
 
        ItemState<FPointArray> *is = dynamic_cast<ItemState<FPointArray>*>(state);
3702
 
        if (is)
3703
 
        {
3704
 
                if (isUndo)
3705
 
                        ContourLine = is->getItem();
3706
 
                else
3707
 
                        ContourLine = PoLine.copy();
3708
 
                ClipEdited = true;
3709
 
        }
3710
 
}
3711
 
 
3712
 
void PageItem::restoreShapeType(SimpleState *state, bool isUndo)
3713
 
{
3714
 
        // Store shape info in this form:
3715
 
        // CHANGE_SHAPE_TYPE - ID of the undo operation
3716
 
        // OLD_FRAME_TYPE - original frame type
3717
 
        // NEW_FRAME_TYPE - change of frame type
3718
 
        // binary QPair<FPointArray, FPointArray> - .first original shape, .second new shape
3719
 
        ItemState<QPair<FPointArray,FPointArray> > *is = dynamic_cast<ItemState<QPair<FPointArray,FPointArray> >*>(state);
3720
 
        if (is)
3721
 
        {
3722
 
                if (isUndo)
3723
 
                {
3724
 
                        this->FrameType = is->getInt("OLD_FRAME_TYPE");
3725
 
                        this->PoLine = is->getItem().first;
3726
 
                }
3727
 
                else
3728
 
                {
3729
 
                        this->FrameType = is->getInt("NEW_FRAME_TYPE");
3730
 
                        this->PoLine = is->getItem().second;
3731
 
                }
3732
 
                ClipEdited = true;
3733
 
        }
3734
 
}
3735
 
 
3736
 
void PageItem::restoreLayer(SimpleState *state, bool isUndo)
3737
 
{
3738
 
        ScribusView* view = m_Doc->view();
3739
 
        setLayer(isUndo ? state->getInt("OLD_LAYER") : state->getInt("NEW_LAYER"));
3740
 
        view->Deselect(true);
3741
 
        m_Doc->regionsChanged()->update(QRectF());
3742
 
}
3743
 
 
3744
 
void PageItem::restoreGetImage(UndoState *state, bool isUndo)
3745
 
{
3746
 
        ItemState<ScImageEffectList> *is = dynamic_cast<ItemState<ScImageEffectList>*>(state);
3747
 
        QString fn = is->get("OLD_IMAGE_PATH");
3748
 
        if (!isUndo)
3749
 
                fn = is->get("NEW_IMAGE_PATH");
3750
 
        if (fn.isEmpty())
3751
 
        {
3752
 
                Selection tempSelection(this, false);
3753
 
                tempSelection.addItem(this, true);
3754
 
                m_Doc->itemSelection_ClearItem(&tempSelection);
3755
 
        }
3756
 
        else
3757
 
        {
3758
 
                loadImage(fn, false);
3759
 
                if (isUndo)
3760
 
                {
3761
 
                        //restore old image settings
3762
 
                        effectsInUse = is->getItem();
3763
 
                        setImageFlippedH(is->getBool("FLIPPH"));
3764
 
                        setImageFlippedV(is->getBool("FLIPPV"));
3765
 
                        setImageScalingMode(is->getBool("SCALING"), is->getBool("ASPECT"));
3766
 
                        setImageXYOffset(is->getDouble("XOFF"), is->getDouble("YOFF"));
3767
 
                        setImageXYScale(is->getDouble("XSCALE"), is->getDouble("YSCALE"));
3768
 
                        setFillTransparency(is->getDouble("FILLT"));
3769
 
                        setLineTransparency(is->getDouble("LINET"));
3770
 
                }
3771
 
                select();
3772
 
                m_Doc->updatePic();
3773
 
        }
3774
 
}
3775
 
 
3776
 
void PageItem::restoreGroupsLastItem(SimpleState *state, bool isUndo)
3777
 
{
3778
 
        ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> > *>(state);
3779
 
        if (is)
3780
 
        {
3781
 
                if (isUndo)
3782
 
                        this->groupsLastItem = is->getItem().first;
3783
 
                else
3784
 
                        this->groupsLastItem = is->getItem().second;
3785
 
        }
3786
 
}
3787
 
 
3788
 
void PageItem::restoreShapeContour(UndoState *state, bool isUndo)
3789
 
{
3790
 
        ItemState<QPair<FPointArray,FPointArray> > *istate =
3791
 
                        dynamic_cast<ItemState<QPair<FPointArray,FPointArray> >*>(state);
3792
 
        if (istate)
3793
 
        {
3794
 
                FPointArray oldClip = istate->getItem().first;
3795
 
                FPointArray newClip = istate->getItem().second;
3796
 
                bool isContour = istate->getBool("IS_CONTOUR");
3797
 
                double oldX = istate->getDouble("OLD_X");
3798
 
                double oldY = istate->getDouble("OLD_Y");
3799
 
                double newX = istate->getDouble("NEW_X");
3800
 
                double newY = istate->getDouble("NEW_Y");
3801
 
                double mx = oldX - newX;
3802
 
                double my = oldY - newY;
3803
 
 
3804
 
                if (isUndo)
3805
 
                {
3806
 
                        if (isContour)
3807
 
                                ContourLine = oldClip;
3808
 
                        else
3809
 
                                PoLine = oldClip;
3810
 
                }
3811
 
                else
3812
 
                {
3813
 
                        mx = -mx;
3814
 
                        my = -my;
3815
 
                        if (isContour)
3816
 
                                ContourLine = newClip;
3817
 
                        else
3818
 
                                PoLine = newClip;
3819
 
                }
3820
 
                m_Doc->AdjustItemSize(this);
3821
 
                m_Doc->MoveItem(mx, my, this, false);
3822
 
                m_Doc->regionsChanged()->update(QRectF());
3823
 
        }
3824
 
 
3825
 
}
3826
 
 
3827
 
void PageItem::restoreImageEffects(UndoState *state, bool isUndo)
3828
 
{
3829
 
        ItemState<QPair<ScImageEffectList, ScImageEffectList> > *istate =
3830
 
        dynamic_cast<ItemState<QPair<ScImageEffectList,ScImageEffectList> >*>(state);
3831
 
        if (istate)
3832
 
        {
3833
 
                if (isUndo)
3834
 
                        effectsInUse = istate->getItem().first;
3835
 
                else
3836
 
                        effectsInUse = istate->getItem().second;
3837
 
 
3838
 
                select();
3839
 
                m_Doc->updatePic();
3840
 
        }
3841
 
}
3842
 
 
3843
 
void PageItem::restoreEditText(SimpleState *state, bool isUndo)
3844
 
{
3845
 
        if (!isTextFrame())
3846
 
                return;
3847
 
        itemText.deselectAll();
3848
 
        HasSel = false;
3849
 
        EditAct action = (EditAct) state->getInt("STEXT");
3850
 
        if (action == PARAMFULL || action == PARAMSEL)
3851
 
        {
3852
 
                QString buffer;
3853
 
                if (isUndo)
3854
 
                        buffer.append(state->get("STEXT_OLD"));
3855
 
                else
3856
 
                        buffer.append(state->get("STEXT_NEW"));
3857
 
                if (!buffer.isEmpty())
3858
 
                {
3859
 
                        Serializer dig(*m_Doc);
3860
 
                        dig.store<ScribusDoc>("<scribusdoc>", m_Doc);
3861
 
                        StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
3862
 
                        dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
3863
 
                        dig.parseMemory(buffer.toStdString().c_str(), buffer.length());
3864
 
                        StoryText* story = dig.result<StoryText>();
3865
 
                        if (action == PARAMFULL)
3866
 
                        {
3867
 
                                itemText.selectAll();
3868
 
                                itemText.clear();
3869
 
                                itemText.append(*story);
3870
 
                        }
3871
 
                        else if (action == PARAMSEL)
3872
 
                        {
3873
 
                                itemText.deselectAll();
3874
 
                                int SelStart = state->getInt("STEXT_SELSTART");
3875
 
                                itemText.select(SelStart,state->getInt("STEXT_SELLEN"));
3876
 
                                asTextFrame()->deleteSelectedTextFromFrame();
3877
 
                                int ItemLength = itemText.length();
3878
 
                                itemText.insert(SelStart, *story);
3879
 
                                // If we have inserted at end of text we have to restore trailing style
3880
 
                                if (ItemLength == SelStart && story->length() > 0 && story->text(-1) != SpecialChars::PARSEP)
3881
 
                                {
3882
 
                                        itemText.setStyle(-1, story->paragraphStyle(story->length()));
3883
 
                                }
3884
 
                                itemText.select(SelStart, story->length());
3885
 
                                HasSel = true;
3886
 
                        }
3887
 
                        CPos = itemText.endOfSelection();
3888
 
                        delete story;
3889
 
                }
3890
 
                else { qDebug() << "UNDO buffer EMPTY";}
3891
 
        }
3892
 
        else if (action == REPSAX)
3893
 
        {
3894
 
                QString buffout, buffin;  //buffout is deleted, buffin is inserted
3895
 
                int pos = state->getInt("STEXT_CPOS");
3896
 
                if (isUndo)
3897
 
                {
3898
 
                        buffin.append(state->get("STEXT_OLD"));
3899
 
                        buffout.append(state->get("STEXT_NEW"));
3900
 
                }
3901
 
                else
3902
 
                {
3903
 
                        buffin.append(state->get("STEXT_NEW"));
3904
 
                        buffout.append(state->get("STEXT_OLD"));
3905
 
                }
3906
 
 
3907
 
                Serializer dig(*m_Doc);
3908
 
                dig.store<ScribusDoc>("<scribusdoc>", m_Doc);
3909
 
                StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
3910
 
                dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
3911
 
                dig.parseMemory(buffout.toStdString().c_str(), buffout.length());
3912
 
                StoryText* story = dig.result<StoryText>();
3913
 
                itemText.select(pos,story->length());
3914
 
                asTextFrame()->deleteSelectedTextFromFrame();
3915
 
 
3916
 
                Serializer dig2(*m_Doc);
3917
 
                dig2.store<ScribusDoc>("<scribusdoc>", m_Doc);
3918
 
                StoryText::desaxeRules("/", dig2, "SCRIBUSTEXT");
3919
 
                dig2.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
3920
 
                dig2.parseMemory(buffin.toStdString().c_str(), buffin.length());
3921
 
                story = dig2.result<StoryText>();
3922
 
                itemText.insert(pos,*story);
3923
 
                itemText.select(pos, story->length());
3924
 
                HasSel = true;
3925
 
                CPos = pos + story->length();
3926
 
                delete story;
3927
 
        }
3928
 
        else if (action == INSSAX || action == DELSAX)
3929
 
        {
3930
 
                QString str = state->get("STEXT_STR");
3931
 
                if (str.isEmpty())
3932
 
                        str = itemTextSaxed;
3933
 
                int pos = state->getInt("STEXT_CPOS");
3934
 
                Serializer dig(*m_Doc);
3935
 
                dig.store<ScribusDoc>("<scribusdoc>", m_Doc);
3936
 
                StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
3937
 
                dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
3938
 
                dig.parseMemory(str.toStdString().c_str(), str.length());
3939
 
                StoryText* story = dig.result<StoryText>();
3940
 
                if ((action == INSSAX && isUndo) || (action == DELSAX && !isUndo))
3941
 
                {
3942
 
                        //undo for INSSAX, redo for DELSAX
3943
 
                        itemText.select(pos, story->length());
3944
 
                        asTextFrame()->deleteSelectedTextFromFrame();
3945
 
                }
3946
 
                else
3947
 
                {
3948
 
                        //undo for DELSAX, redo for INSSAX
3949
 
                        itemText.insert(pos, *story);
3950
 
                        CPos = pos + story->length();
3951
 
                }
3952
 
                delete story;
3953
 
        }
3954
 
        else if (action == INS)
3955
 
        {
3956
 
                QString str = state->get("STEXT_STR");
3957
 
                int pos = state->getInt("STEXT_CPOS");
3958
 
                if (isUndo)
3959
 
                {
3960
 
                        itemText.select(pos, str.length());
3961
 
                        asTextFrame()->deleteSelectedTextFromFrame();
3962
 
                }
3963
 
                else
3964
 
                {
3965
 
                        itemText.insertChars(pos, str, true);
3966
 
                        CPos = pos + str.length();
3967
 
                }
3968
 
        }
3969
 
        // after Undo or Redo new actions should create new undoStates
3970
 
        asTextFrame()->lastUndoAction = NOACTION;
3971
 
 
3972
 
        m_Doc->scMW()->setTBvals(this);
3973
 
        update();
3974
 
}
3975
 
 
3976
 
QString PageItem::getItemTextSaxed(EditActPlace undoItem)
3977
 
{
3978
 
        if (!isTextFrame()) return "";
3979
 
        StoryText iT(m_Doc);
3980
 
        iT.setDefaultStyle(itemText.defaultStyle());
3981
 
        if (undoItem == FRAME)
3982
 
                iT.insert(0, itemText);
3983
 
        else
3984
 
        {
3985
 
                int StartOldSel = -1, LenOldSel = -1;
3986
 
                if (undoItem == PARAGRAPH)
3987
 
                {
3988
 
                        LenOldSel = 0;
3989
 
                        if (HasSel)
3990
 
                        {
3991
 
                                StartOldSel = itemText.startOfSelection();
3992
 
                                LenOldSel = itemText.lengthOfSelection();
3993
 
                        }
3994
 
                        asTextFrame()->expandParaSelection(true);
3995
 
                }
3996
 
                else if (undoItem == CHAR || (undoItem == SELECTION && !HasSel))
3997
 
                {
3998
 
                        LenOldSel = itemText.lengthOfSelection();
3999
 
                        if (LenOldSel > 0)
4000
 
                                StartOldSel = itemText.startOfSelection();
4001
 
                        if (CPos >= itemText.length())
4002
 
                                return  "";
4003
 
                        itemText.select(CPos,1);
4004
 
                        HasSel = true;
4005
 
                }
4006
 
                //is SELECTION
4007
 
                iT.insert(0, itemText, HasSel);
4008
 
                if (LenOldSel > 0) //restoring old selection if undoItem was PARAPGRAPH
4009
 
                {
4010
 
                        itemText.select(StartOldSel, LenOldSel);
4011
 
                        HasSel = true;
4012
 
                }
4013
 
                else if (LenOldSel == 0)
4014
 
                {
4015
 
                        itemText.deselectAll();
4016
 
                        HasSel = false;
4017
 
                }
4018
 
        }
4019
 
        //saxing text
4020
 
        std::ostringstream xmlString;
4021
 
        SaxXML xmlStream(xmlString);
4022
 
        xmlStream.beginDoc();
4023
 
        iT.saxx(xmlStream, "SCRIBUSTEXT");
4024
 
        xmlStream.endDoc();
4025
 
        std::string xml(xmlString.str());
4026
 
        return QString(xml.c_str());
4027
 
}
4028
 
 
4029
 
QString PageItem::getItemTextSaxed(int selStart, int selLength)
4030
 
{
4031
 
        if (selStart < 0 || selLength < 0)
4032
 
                return QString();
4033
 
        
4034
 
        StoryText it(m_Doc);
4035
 
        it.setDefaultStyle(itemText.defaultStyle());
4036
 
 
4037
 
        int oldSelStart = -1, oldSelLength = -1;
4038
 
        oldSelStart  = itemText.startOfSelection();
4039
 
        oldSelLength = itemText.lengthOfSelection();
4040
 
 
4041
 
        itemText.select(selStart, selLength);
4042
 
        it.insert(0, itemText, (selLength > 0));
4043
 
        
4044
 
        if (oldSelLength > 0) //restoring old selection if undoItem was PARAPGRAPH
4045
 
        {
4046
 
                itemText.select(oldSelStart, oldSelLength);
4047
 
                HasSel = true;
4048
 
        }
4049
 
        else if (oldSelLength == 0)
4050
 
        {
4051
 
                itemText.deselectAll();
4052
 
                HasSel = false;
4053
 
        }
4054
 
 
4055
 
        //saxing text
4056
 
        std::ostringstream xmlString;
4057
 
        SaxXML xmlStream(xmlString);
4058
 
        xmlStream.beginDoc();
4059
 
        it.saxx(xmlStream, "SCRIBUSTEXT");
4060
 
        xmlStream.endDoc();
4061
 
        std::string xml(xmlString.str());
4062
 
        return QString(xml.c_str());
4063
 
}
4064
 
 
4065
 
QString PageItem::getTextSaxed(QString str)
4066
 
{
4067
 
        StoryText iT(m_Doc);
4068
 
        iT.setDefaultStyle(itemText.defaultStyle());
4069
 
        iT.insertChars(0,str,true);
4070
 
        std::ostringstream xmlString;
4071
 
        SaxXML xmlStream(xmlString);
4072
 
        xmlStream.beginDoc();
4073
 
        iT.saxx(xmlStream, "SCRIBUSTEXT");
4074
 
        xmlStream.endDoc();
4075
 
        std::string xml(xmlString.str());
4076
 
        return QString(xml.c_str());
4077
 
}
4078
 
 
4079
 
void PageItem::select()
4080
 
{
4081
 
        if (m_Doc->m_Selection->count() == 1 && m_Doc->m_Selection->itemAt()->isTextFrame())
4082
 
                m_Doc->m_Selection->itemAt()->asTextFrame()->lastUndoAction = PageItem::NOACTION;
4083
 
        m_Doc->view()->Deselect(false);
4084
 
        //CB #2969 add this true parm to addItem so we dont connectToGUI, the rest of view->SelectItem isnt needed anyway
4085
 
        m_Doc->m_Selection->addItem(this, true);
4086
 
}
4087
 
 
4088
 
ObjAttrVector* PageItem::getObjectAttributes()
4089
 
{
4090
 
        return &pageItemAttributes;
4091
 
}
4092
 
 
4093
 
ObjectAttribute PageItem::getObjectAttribute(QString attributeName) const
4094
 
{
4095
 
        int countFound=0;
4096
 
        ObjAttrVector::const_iterator foundIt = pageItemAttributes.begin();
4097
 
        for(ObjAttrVector::const_iterator objAttrIt = pageItemAttributes.begin() ; objAttrIt != pageItemAttributes.end(); ++objAttrIt )
4098
 
        {
4099
 
                if ((*objAttrIt).name==attributeName)
4100
 
                {
4101
 
                        ++countFound;
4102
 
                        foundIt=objAttrIt;
4103
 
                }
4104
 
        }
4105
 
        ObjectAttribute returnAttribute;
4106
 
        if(countFound==1)
4107
 
                returnAttribute=(*foundIt);
4108
 
        else
4109
 
                returnAttribute.name=QString::null;
4110
 
        return returnAttribute;
4111
 
}
4112
 
 
4113
 
 
4114
 
void PageItem::setObjectAttributes(ObjAttrVector* map)
4115
 
{
4116
 
        pageItemAttributes=*map;
4117
 
}
4118
 
 
4119
 
QString PageItem::generateUniqueCopyName(const QString originalName) const
4120
 
{
4121
 
        if (!m_Doc->itemNameExists(originalName))
4122
 
                return originalName;
4123
 
 
4124
 
        // Start embellishing the name until we get an acceptable unique name
4125
 
        // first we prefix `Copy of' if it's not already there
4126
 
        QString newname(originalName);
4127
 
        if (!originalName.startsWith( tr("Copy of")))
4128
 
                newname.prepend( tr("Copy of")+" ");
4129
 
 
4130
 
        // See if the name prefixed by "Copy of " is free
4131
 
        if (m_Doc->itemNameExists(newname))
4132
 
        {
4133
 
                // Search the string for (number) at the end and capture
4134
 
                // both the number and the text leading up to it sans brackets.
4135
 
                //     Copy of fred (5)
4136
 
                //     ^^^^^^^^^^^^  ^   (where ^ means captured)
4137
 
                static QRegExp rx("^(.*)\\s+\\((\\d+)\\)$");
4138
 
                int numMatches = rx.lastIndexIn(newname);
4139
 
                // Add a (number) suffix to the end of the name. We start at the
4140
 
                // old suffix's value if there was one, or at 2 if there was not.
4141
 
                int suffixnum = 2;
4142
 
                QString prefix(newname);
4143
 
                if (numMatches != -1)
4144
 
                {
4145
 
                        // Already had a suffix; use the name w/o suffix for prefix and
4146
 
                        // grab the old suffix value as a starting point.
4147
 
                        QStringList matches = rx.capturedTexts();
4148
 
                        prefix = matches[1];
4149
 
                        suffixnum = matches[2].toInt();
4150
 
                }
4151
 
                // Keep on incrementing the suffix 'till we find a free name
4152
 
                do
4153
 
                {
4154
 
                        newname = prefix + " (" + QString::number(suffixnum) + ")";
4155
 
                        suffixnum ++;
4156
 
                }
4157
 
                while (m_Doc->itemNameExists(newname));
4158
 
        }
4159
 
        // Unnecessary assert, previous code ensure condition is always true - JG
4160
 
        // assert(!m_Doc->itemNameExists(newname));
4161
 
        return newname;
4162
 
}
4163
 
 
4164
 
void PageItem::setTagged(bool tag)
4165
 
{
4166
 
        tagged=tag;
4167
 
}
4168
 
 
4169
 
void PageItem::replaceNamedResources(ResourceCollection& newNames) 
4170
 
{
4171
 
        QMap<QString,QString>::ConstIterator it;
4172
 
 
4173
 
        it = newNames.colors().find(fillColor());
4174
 
        if (it != newNames.colors().end())
4175
 
                setFillColor(*it);
4176
 
 
4177
 
        it = newNames.colors().find(lineColor());
4178
 
        if (it != newNames.colors().end())
4179
 
                setLineColor(*it);
4180
 
 
4181
 
        QList<VColorStop*> cstops = fill_gradient.colorStops();
4182
 
        for (uint cst = 0; cst < fill_gradient.Stops(); ++cst)
4183
 
        {
4184
 
                it = newNames.colors().find(cstops.at(cst)->name);
4185
 
                if (it != newNames.colors().end())
4186
 
                {
4187
 
                        if (*it != CommonStrings::None)
4188
 
                                cstops.at(cst)->name = *it;
4189
 
                }
4190
 
        }
4191
 
        if (effectsInUse.count() != 0)
4192
 
        {
4193
 
                QString col1 = CommonStrings::None;
4194
 
                QString col2 = CommonStrings::None;
4195
 
                QString col3 = CommonStrings::None;
4196
 
                QString col4 = CommonStrings::None;
4197
 
                for (int a = 0; a < effectsInUse.count(); ++a)
4198
 
                {
4199
 
                        QString tmpstr = effectsInUse.at(a).effectParameters;
4200
 
                        QString tmpstr2 = "";
4201
 
                        ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
4202
 
                        switch (effectsInUse.at(a).effectCode)
4203
 
                        {
4204
 
                                case ScImage::EF_QUADTONE:
4205
 
                                        col1 = fp.readLine();
4206
 
                                        col2 = fp.readLine();
4207
 
                                        col3 = fp.readLine();
4208
 
                                        col4 = fp.readLine();
4209
 
                                        it = newNames.colors().find(col1);
4210
 
                                        if (it != newNames.colors().end())
4211
 
                                        {
4212
 
                                                if (*it != CommonStrings::None)
4213
 
                                                        tmpstr2 += *it + "\n";
4214
 
                                                else
4215
 
                                                        tmpstr2 += col1 + "\n";
4216
 
                                        }
4217
 
                                        else
4218
 
                                                tmpstr2 += col1 + "\n";
4219
 
                                        it = newNames.colors().find(col2);
4220
 
                                        if (it != newNames.colors().end())
4221
 
                                        {
4222
 
                                                if (*it != CommonStrings::None)
4223
 
                                                        tmpstr2 += *it + "\n";
4224
 
                                                else
4225
 
                                                        tmpstr2 += col2 + "\n";
4226
 
                                        }
4227
 
                                        else
4228
 
                                                tmpstr2 += col2 + "\n";
4229
 
                                        it = newNames.colors().find(col3);
4230
 
                                        if (it != newNames.colors().end())
4231
 
                                        {
4232
 
                                                if (*it != CommonStrings::None)
4233
 
                                                        tmpstr2 += *it + "\n";
4234
 
                                                else
4235
 
                                                        tmpstr2 += col3 + "\n";
4236
 
                                        }
4237
 
                                        else
4238
 
                                                tmpstr2 += col3 + "\n";
4239
 
                                        it = newNames.colors().find(col4);
4240
 
                                        if (it != newNames.colors().end())
4241
 
                                        {
4242
 
                                                if (*it != CommonStrings::None)
4243
 
                                                        tmpstr2 += *it + "\n";
4244
 
                                                else
4245
 
                                                        tmpstr2 += col4 + "\n";
4246
 
                                        }
4247
 
                                        else
4248
 
                                                tmpstr2 += col4 + "\n";
4249
 
                                        tmpstr2 += fp.readAll();
4250
 
                                        break;
4251
 
                                case ScImage::EF_TRITONE:
4252
 
                                        col1 = fp.readLine();
4253
 
                                        col2 = fp.readLine();
4254
 
                                        col3 = fp.readLine();
4255
 
                                        it = newNames.colors().find(col1);
4256
 
                                        if (it != newNames.colors().end())
4257
 
                                        {
4258
 
                                                if (*it != CommonStrings::None)
4259
 
                                                        tmpstr2 += *it + "\n";
4260
 
                                                else
4261
 
                                                        tmpstr2 += col1 + "\n";
4262
 
                                        }
4263
 
                                        else
4264
 
                                                tmpstr2 += col1 + "\n";
4265
 
                                        it = newNames.colors().find(col2);
4266
 
                                        if (it != newNames.colors().end())
4267
 
                                        {
4268
 
                                                if (*it != CommonStrings::None)
4269
 
                                                        tmpstr2 += *it + "\n";
4270
 
                                                else
4271
 
                                                        tmpstr2 += col2 + "\n";
4272
 
                                        }
4273
 
                                        else
4274
 
                                                tmpstr2 += col2 + "\n";
4275
 
                                        it = newNames.colors().find(col3);
4276
 
                                        if (it != newNames.colors().end())
4277
 
                                        {
4278
 
                                                if (*it != CommonStrings::None)
4279
 
                                                        tmpstr2 += *it + "\n";
4280
 
                                                else
4281
 
                                                        tmpstr2 += col3 + "\n";
4282
 
                                        }
4283
 
                                        else
4284
 
                                                tmpstr2 += col3 + "\n";
4285
 
                                        tmpstr2 += fp.readAll();
4286
 
                                        break;
4287
 
                                case ScImage::EF_DUOTONE:
4288
 
                                        col1 = fp.readLine();
4289
 
                                        col2 = fp.readLine();
4290
 
                                        it = newNames.colors().find(col1);
4291
 
                                        if (it != newNames.colors().end())
4292
 
                                        {
4293
 
                                                if (*it != CommonStrings::None)
4294
 
                                                        tmpstr2 += *it + "\n";
4295
 
                                                else
4296
 
                                                        tmpstr2 += col1 + "\n";
4297
 
                                        }
4298
 
                                        else
4299
 
                                                tmpstr2 += col1 + "\n";
4300
 
                                        it = newNames.colors().find(col2);
4301
 
                                        if (it != newNames.colors().end())
4302
 
                                        {
4303
 
                                                if (*it != CommonStrings::None)
4304
 
                                                        tmpstr2 += *it + "\n";
4305
 
                                                else
4306
 
                                                        tmpstr2 += col2 + "\n";
4307
 
                                        }
4308
 
                                        else
4309
 
                                                tmpstr2 += col2 + "\n";
4310
 
                                        tmpstr2 += fp.readAll();
4311
 
                                        break;
4312
 
                                case ScImage::EF_COLORIZE:
4313
 
                                        col1 = fp.readLine();
4314
 
                                        it = newNames.colors().find(col1);
4315
 
                                        if (it != newNames.colors().end())
4316
 
                                        {
4317
 
                                                if (*it != CommonStrings::None)
4318
 
                                                        tmpstr2 += *it + "\n" + fp.readAll();
4319
 
                                                else
4320
 
                                                        tmpstr2 += col1 + "\n" + fp.readAll();
4321
 
                                        }
4322
 
                                        else
4323
 
                                                tmpstr2 += col1 + "\n" + fp.readAll();
4324
 
                                        break;
4325
 
                                default:
4326
 
                                        tmpstr2 = tmpstr;
4327
 
                                        break;
4328
 
                        }
4329
 
                        effectsInUse[a].effectParameters = tmpstr2;
4330
 
                }
4331
 
        }
4332
 
        
4333
 
        it = newNames.patterns().find(pattern());
4334
 
        if (it != newNames.patterns().end())
4335
 
                setPattern(*it);
4336
 
 
4337
 
        it = newNames.lineStyles().find(customLineStyle());
4338
 
        if (it != newNames.lineStyles().end())
4339
 
                setCustomLineStyle(*it);
4340
 
 
4341
 
        if (prevInChain() == NULL)
4342
 
                itemText.replaceNamedResources(newNames);
4343
 
}
4344
 
 
4345
 
 
4346
 
void PageItem::getNamedResources(ResourceCollection& lists) const
4347
 
{
4348
 
        lists.collectColor(lineColor());
4349
 
        if (GrType == 0)
4350
 
                lists.collectColor(fillColor());
4351
 
        else if (GrType < 8)
4352
 
        {
4353
 
                QList<VColorStop*> cstops = fill_gradient.colorStops();
4354
 
                for (uint cst = 0; cst < fill_gradient.Stops(); ++cst)
4355
 
                {
4356
 
                        lists.collectColor(cstops.at(cst)->name);
4357
 
                }
4358
 
        }
4359
 
        if (effectsInUse.count() != 0)
4360
 
        {
4361
 
                for (int a = 0; a < effectsInUse.count(); ++a)
4362
 
                {
4363
 
                        QString tmpstr = effectsInUse.at(a).effectParameters;
4364
 
                        ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
4365
 
                        switch (effectsInUse.at(a).effectCode)
4366
 
                        {
4367
 
                                case ScImage::EF_QUADTONE:
4368
 
                                        lists.collectColor(fp.readLine());
4369
 
                                case ScImage::EF_TRITONE:
4370
 
                                        lists.collectColor(fp.readLine());
4371
 
                                case ScImage::EF_DUOTONE:
4372
 
                                        lists.collectColor(fp.readLine());
4373
 
                                case ScImage::EF_COLORIZE:
4374
 
                                        lists.collectColor(fp.readLine());
4375
 
                                        break;
4376
 
                                default:
4377
 
                                        break;
4378
 
                        }
4379
 
                }
4380
 
        }
4381
 
        lists.collectPattern(pattern());
4382
 
        lists.collectLineStyle(customLineStyle());
4383
 
        if (prevInChain() == NULL)
4384
 
                itemText.getNamedResources(lists);
4385
 
}
4386
 
 
4387
 
void PageItem::copyToCopyPasteBuffer(struct CopyPasteBuffer *Buffer)
4388
 
{
4389
 
        Buffer->PType = realItemType();
4390
 
        Buffer->Xpos = Xpos;
4391
 
        Buffer->Ypos = Ypos;
4392
 
        Buffer->Width = Width;
4393
 
        Buffer->Height = Height;
4394
 
        Buffer->RadRect = RadRect;
4395
 
        Buffer->FrameType = FrameType;
4396
 
        Buffer->ClipEdited = ClipEdited;
4397
 
        Buffer->Pwidth = m_lineWidth;
4398
 
        Buffer->Pcolor = fillColor();
4399
 
        Buffer->Pcolor2 = lineColor();
4400
 
        Buffer->Shade = fillShade();
4401
 
        Buffer->Shade2 = lineShade();
4402
 
        Buffer->FillRule = fillRule;
4403
 
        Buffer->GrColor = "";
4404
 
        Buffer->GrColor2 = "";
4405
 
        Buffer->GrShade = 100;
4406
 
        Buffer->GrShade2 = 100;
4407
 
        Buffer->fill_gradient = fill_gradient;
4408
 
        Buffer->GrType = GrType;
4409
 
        Buffer->GrStartX = GrStartX;
4410
 
        Buffer->GrStartY = GrStartY;
4411
 
        Buffer->GrEndX = GrEndX;
4412
 
        Buffer->GrEndY = GrEndY;
4413
 
        Buffer->Rot = Rot;
4414
 
        Buffer->PLineArt = PLineArt;
4415
 
        Buffer->PLineEnd = PLineEnd;
4416
 
        Buffer->PLineJoin = PLineJoin;
4417
 
        Buffer->LocalScX = LocalScX;
4418
 
        Buffer->LocalScY = LocalScY;
4419
 
        Buffer->LocalX = LocalX;
4420
 
        Buffer->LocalY = LocalY;
4421
 
        Buffer->PicArt = PicArt;
4422
 
        Buffer->flippedH = imageFlippedH();
4423
 
        Buffer->flippedV = imageFlippedV();
4424
 
/*      Buffer->BBoxX = BBoxX;
4425
 
        Buffer->BBoxH = BBoxH; */
4426
 
        Buffer->isPrintable = printEnabled();
4427
 
        Buffer->isBookmark = isBookmark;
4428
 
//      Buffer->BMnr = BMnr;
4429
 
        Buffer->m_isAnnotation = m_isAnnotation;
4430
 
        Buffer->m_annotation = m_annotation;
4431
 
        Buffer->Extra = Extra;
4432
 
        Buffer->TExtra = TExtra;
4433
 
        Buffer->BExtra = BExtra;
4434
 
        Buffer->RExtra = RExtra;
4435
 
        Buffer->firstLineOffsetP = firstLineOffsetP;
4436
 
        Buffer->Pfile = Pfile;
4437
 
        Buffer->Pfile2 = Pfile2;
4438
 
        Buffer->Pfile3 = Pfile3;
4439
 
        QString Text = "";
4440
 
        uint itemTextCount=itemText.length();
4441
 
        if (itemTextCount != 0)
4442
 
        {
4443
 
                for (uint a=0; a<itemTextCount; ++a)
4444
 
                {
4445
 
                        if( (itemText.text(a) == '\n') || (itemText.text(a) == '\r'))
4446
 
                                Text += QString(QChar(5))+"\t";
4447
 
                        else if(itemText.text(a) == '\t')
4448
 
                                Text += QString(QChar(4))+"\t";
4449
 
                        else
4450
 
                                Text += itemText.text(a,1)+"\t";
4451
 
                        Text += itemText.charStyle(a).font().scName()+"\t";
4452
 
                        Text += QString::number(itemText.charStyle(a).fontSize() / 10.0)+"\t";
4453
 
                        Text += itemText.charStyle(a).fillColor()+"\t";
4454
 
                        Text += QString::number(itemText.charStyle(a).tracking())+"\t";
4455
 
                        Text += QString::number(itemText.charStyle(a).fillShade())+'\t';
4456
 
                        Text += QString::number(itemText.charStyle(a).effects())+'\t';
4457
 
                        Text += QString::number(findParagraphStyle(m_Doc, itemText.paragraphStyle(a)))+'\t';
4458
 
                        Text += itemText.charStyle(a).strokeColor()+"\t";
4459
 
                        Text += QString::number(itemText.charStyle(a).strokeShade())+'\t';
4460
 
                        Text += QString::number(itemText.charStyle(a).scaleH())+'\t';
4461
 
                        Text += QString::number(itemText.charStyle(a).scaleV())+'\t';
4462
 
                        Text += QString::number(itemText.charStyle(a).baselineOffset())+'\t';
4463
 
                        Text += QString::number(itemText.charStyle(a).shadowXOffset())+'\t';
4464
 
                        Text += QString::number(itemText.charStyle(a).shadowYOffset())+'\t';
4465
 
                        Text += QString::number(itemText.charStyle(a).outlineWidth())+'\t';
4466
 
                        Text += QString::number(itemText.charStyle(a).underlineOffset())+'\t';
4467
 
                        Text += QString::number(itemText.charStyle(a).underlineWidth())+'\t';
4468
 
                        Text += QString::number(itemText.charStyle(a).strikethruOffset())+'\t';
4469
 
                        Text += QString::number(itemText.charStyle(a).strikethruWidth())+'\n';
4470
 
                }
4471
 
        }
4472
 
        if (asLatexFrame()) {
4473
 
                Buffer->itemText = asLatexFrame()->formula();
4474
 
        } else {
4475
 
                Buffer->itemText = Text;
4476
 
        }
4477
 
        Buffer->Clip = Clip;
4478
 
        Buffer->PoLine = PoLine.copy();
4479
 
        Buffer->ContourLine = ContourLine.copy();
4480
 
        //Buffer->UseContour = textFlowUsesContourLine();
4481
 
        Buffer->DashValues = DashValues;
4482
 
        Buffer->DashOffset = DashOffset;
4483
 
        Buffer->PoShow = PoShow;
4484
 
        Buffer->BaseOffs = BaseOffs;
4485
 
        Buffer->textPathFlipped = textPathFlipped;
4486
 
        Buffer->textPathType = textPathType;
4487
 
        Buffer->TextflowMode = textFlowMode();
4488
 
        Buffer->Groups = Groups;
4489
 
        Buffer->IProfile = IProfile;
4490
 
        Buffer->IRender = IRender;
4491
 
        Buffer->UseEmbedded = UseEmbedded;
4492
 
        Buffer->EmProfile = EmProfile;
4493
 
        Buffer->LayerNr = LayerNr;
4494
 
        Buffer->ScaleType = ScaleType;
4495
 
        Buffer->AspectRatio = AspectRatio;
4496
 
        Buffer->Locked = locked();
4497
 
        Buffer->LockRes = sizeLocked();
4498
 
        Buffer->Transparency = fillTransparency();
4499
 
        Buffer->TranspStroke = lineTransparency();
4500
 
        Buffer->TransBlend = fillBlendmode();
4501
 
        Buffer->TransBlendS = lineBlendmode();
4502
 
        Buffer->Reverse = Reverse;
4503
 
        Buffer->NamedLStyle = NamedLStyle;
4504
 
        Buffer->Cols = Cols;
4505
 
        Buffer->ColGap = ColGap;
4506
 
        Buffer->isTableItem = isTableItem;
4507
 
        Buffer->TopLine = TopLine;
4508
 
        Buffer->LeftLine = LeftLine;
4509
 
        Buffer->RightLine = RightLine;
4510
 
        Buffer->BottomLine = BottomLine;
4511
 
        if (isTableItem)
4512
 
        {
4513
 
                if (TopLink != 0)
4514
 
                        Buffer->TopLinkID = TopLink->ItemNr;
4515
 
                else
4516
 
                        Buffer->TopLinkID = -1;
4517
 
                if (LeftLink != 0)
4518
 
                        Buffer->LeftLinkID = LeftLink->ItemNr;
4519
 
                else
4520
 
                        Buffer->LeftLinkID = -1;
4521
 
                if (RightLink != 0)
4522
 
                        Buffer->RightLinkID = RightLink->ItemNr;
4523
 
                else
4524
 
                        Buffer->RightLinkID = -1;
4525
 
                if (BottomLink != 0)
4526
 
                        Buffer->BottomLinkID = BottomLink->ItemNr;
4527
 
                else
4528
 
                        Buffer->BottomLinkID = -1;
4529
 
        }
4530
 
        Buffer->startArrowIndex = m_startArrowIndex;
4531
 
        Buffer->endArrowIndex = m_endArrowIndex;
4532
 
}
4533
 
 
4534
 
 
4535
 
//Moved from View
4536
 
void PageItem::SetFrameShape(int count, double *vals)
4537
 
{
4538
 
        PoLine.resize(0);
4539
 
        for (int a = 0; a < count-3; a += 4)
4540
 
        {
4541
 
                if (vals[a] < 0)
4542
 
                {
4543
 
                        PoLine.setMarker();
4544
 
                        continue;
4545
 
                }
4546
 
                double x1 = Width * vals[a] / 100.0;
4547
 
                double y1 = Height * vals[a+1] / 100.0;
4548
 
                double x2 = Width * vals[a+2] / 100.0;
4549
 
                double y2 = Height * vals[a+3] / 100.0;
4550
 
                PoLine.addPoint(x1, y1);
4551
 
                PoLine.addPoint(x2, y2);
4552
 
        }
4553
 
        Clip = FlattenPath(PoLine, Segments);
4554
 
        ClipEdited = true;
4555
 
}
4556
 
 
4557
 
void PageItem::SetRectFrame()
4558
 
{
4559
 
        static double rect[] = {  0.0,   0.0,   0.0,   0.0,
4560
 
                                                        100.0,   0.0, 100.0,   0.0,
4561
 
                                                        100.0,   0.0, 100.0,   0.0,
4562
 
                                                        100.0, 100.0, 100.0, 100.0,
4563
 
                                                        100.0, 100.0, 100.0, 100.0,
4564
 
                                                          0.0, 100.0,   0.0, 100.0,
4565
 
                                                          0.0, 100.0,   0.0, 100.0,
4566
 
                                                          0.0,   0.0,   0.0,   0.0};
4567
 
        SetFrameShape(32, rect);
4568
 
        ClipEdited = false;
4569
 
        FrameType = 0;
4570
 
}
4571
 
 
4572
 
void PageItem::SetOvalFrame()
4573
 
{
4574
 
        static double rect[] = {   100.0,  50.0, 100.0,       77.615235,
4575
 
                                                                50.0, 100.0,  77.615235, 100.0,
4576
 
                                                                50.0, 100.0,  22.385765, 100.0,
4577
 
                                                                 0.0,  50.0,   0.0,       77.615235,
4578
 
                                                                 0.0,  50.0,   0.0,       22.385765,
4579
 
                                                                50.0,   0.0,  22.385765,   0.0,
4580
 
                                                                50.0,   0.0,  77.615235,   0.0,
4581
 
                                                           100.0,  50.0, 100.0,       22.385765};
4582
 
        SetFrameShape(32, rect);
4583
 
        FrameType = 1;
4584
 
        ClipEdited = false;
4585
 
}
4586
 
 
4587
 
void PageItem::SetFrameRound()
4588
 
{
4589
 
        setCornerRadius(qMin(RadRect, qMin(Width,Height)/2));
4590
 
        PoLine.resize(0);
4591
 
        double rr = fabs(RadRect);
4592
 
        double bezierFactor=0.552284749; //Bezier Control Point Factor: 8/3*(sin(45)-0.5)
4593
 
        double rrxBezierFactor=rr*bezierFactor;
4594
 
        double Width_rr=Width-rr;
4595
 
        double Height_rr=Height-rr;
4596
 
        if (RadRect > 0)
4597
 
        {
4598
 
                PoLine.addQuadPoint(rr, 0, rr, 0, Width_rr, 0, Width_rr, 0);
4599
 
                PoLine.addQuadPoint(Width_rr, 0, Width_rr+rrxBezierFactor, 0, Width, rr, Width, rr-rrxBezierFactor);
4600
 
                PoLine.addQuadPoint(Width, rr, Width, rr, Width, Height_rr, Width, Height_rr);
4601
 
                PoLine.addQuadPoint(Width, Height_rr, Width, Height_rr+rrxBezierFactor, Width_rr, Height, Width_rr+rrxBezierFactor, Height);
4602
 
                PoLine.addQuadPoint(Width_rr, Height, Width_rr, Height, rr, Height, rr, Height);
4603
 
                PoLine.addQuadPoint(rr, Height, rr-rrxBezierFactor, Height, 0, Height_rr, 0, Height_rr+rrxBezierFactor);
4604
 
                PoLine.addQuadPoint(0, Height_rr, 0, Height_rr, 0, rr, 0, rr);
4605
 
                PoLine.addQuadPoint(0, rr, 0, rr-rrxBezierFactor, rr, 0, rr-rrxBezierFactor, 0);
4606
 
        }
4607
 
        else
4608
 
        {
4609
 
                PoLine.addQuadPoint(rr, 0, rr, 0, Width_rr, 0, Width_rr, 0);
4610
 
                PoLine.addQuadPoint(Width_rr, 0, Width_rr, rrxBezierFactor, Width, rr, Width-rrxBezierFactor, rr);
4611
 
                PoLine.addQuadPoint(Width, rr, Width, rr, Width, Height_rr, Width, Height_rr);
4612
 
                PoLine.addQuadPoint(Width, Height_rr, Width-rrxBezierFactor, Height_rr, Width_rr, Height, Width_rr, Height-rrxBezierFactor);
4613
 
                PoLine.addQuadPoint(Width_rr, Height, Width_rr, Height, rr, Height, rr, Height);
4614
 
                PoLine.addQuadPoint(rr, Height, rr, Height-rrxBezierFactor, 0, Height_rr, rrxBezierFactor, Height_rr);
4615
 
                PoLine.addQuadPoint(0, Height_rr, 0, Height_rr, 0, rr, 0, rr);
4616
 
                PoLine.addQuadPoint(0, rr, rrxBezierFactor, rr, rr, 0, rr, rr*bezierFactor);
4617
 
        }
4618
 
        Clip = FlattenPath(PoLine, Segments);
4619
 
        ClipEdited = false;
4620
 
        FrameType = 2;
4621
 
}
4622
 
 
4623
 
 
4624
 
 
4625
 
void PageItem::getTransform(QMatrix& mat) const
4626
 
{
4627
 
        mat.translate(Xpos, Ypos);
4628
 
        mat.rotate(Rot);
4629
 
}
4630
 
 
4631
 
QMatrix PageItem::getTransform() const
4632
 
{
4633
 
        QMatrix result;
4634
 
        getTransform(result);
4635
 
        return result;
4636
 
}
4637
 
 
4638
 
QRectF PageItem::getBoundingRect() const
4639
 
{
4640
 
        double x,y,x2,y2;
4641
 
        getBoundingRect(&x, &y, &x2, &y2);
4642
 
        return QRectF(x,y,x2-x,y2-y);
4643
 
}
4644
 
 
4645
 
QRectF PageItem::getCurrentBoundingRect(double moreSpace) const
4646
 
{
4647
 
        double x = BoundingX - moreSpace / 2.0;
4648
 
        double y = BoundingY - moreSpace / 2.0;
4649
 
        double w = BoundingW + moreSpace;
4650
 
        double h = BoundingH + moreSpace;
4651
 
        QRectF ret = QRectF(x, y, w, h);
4652
 
        return ret;
4653
 
}
4654
 
 
4655
 
QRectF PageItem::getVisualBoundingRect() const
4656
 
{
4657
 
        double x,y,x2,y2;
4658
 
        getVisualBoundingRect(&x, &y, &x2, &y2);
4659
 
        return QRectF(x,y,x2-x,y2-y);
4660
 
}
4661
 
 
4662
 
void PageItem::getBoundingRect(double *x1, double *y1, double *x2, double *y2) const
4663
 
{
4664
 
        double minx =  std::numeric_limits<double>::max();
4665
 
        double miny =  std::numeric_limits<double>::max();
4666
 
        double maxx = -std::numeric_limits<double>::max();
4667
 
        double maxy = -std::numeric_limits<double>::max();
4668
 
        if (Rot != 0)
4669
 
        {
4670
 
                FPointArray pb;
4671
 
                pb.resize(0);
4672
 
                pb.addPoint(FPoint(Xpos, Ypos));
4673
 
                pb.addPoint(FPoint(Width,    0.0, Xpos, Ypos, Rot, 1.0, 1.0));
4674
 
                pb.addPoint(FPoint(Width, Height, Xpos, Ypos, Rot, 1.0, 1.0));
4675
 
                pb.addPoint(FPoint(  0.0, Height, Xpos, Ypos, Rot, 1.0, 1.0));
4676
 
                for (uint pc = 0; pc < 4; ++pc)
4677
 
                {
4678
 
                        minx = qMin(minx, pb.point(pc).x());
4679
 
                        miny = qMin(miny, pb.point(pc).y());
4680
 
                        maxx = qMax(maxx, pb.point(pc).x());
4681
 
                        maxy = qMax(maxy, pb.point(pc).y());
4682
 
                }
4683
 
                *x1 = minx;
4684
 
                *y1 = miny;
4685
 
                *x2 = maxx;
4686
 
                *y2 = maxy;
4687
 
        }
4688
 
        else
4689
 
        {
4690
 
                *x1 = Xpos;
4691
 
                *y1 = Ypos;
4692
 
                *x2 = Xpos + qMax(Width, m_lineWidth);
4693
 
                *y2 = Ypos + qMax(Height, m_lineWidth);
4694
 
        }
4695
 
        QRectF totalRect = QRectF(QPointF(*x1, *y1), QPointF(*x2, *y2));
4696
 
        if (m_startArrowIndex != 0)
4697
 
        {
4698
 
                QMatrix arrowTrans;
4699
 
                FPointArray arrow = m_Doc->arrowStyles.at(m_startArrowIndex-1).points.copy();
4700
 
                arrowTrans.translate(Xpos, Ypos);
4701
 
                arrowTrans.rotate(Rot);
4702
 
                if (itemType() == Line)
4703
 
                {
4704
 
                        arrowTrans.translate(0, 0);
4705
 
                        if (NamedLStyle.isEmpty())
4706
 
                        {
4707
 
                                if (m_lineWidth != 0.0)
4708
 
                                        arrowTrans.scale(m_lineWidth, m_lineWidth);
4709
 
                        }
4710
 
                        else
4711
 
                        {
4712
 
                                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4713
 
                                if (ml[ml.size()-1].Width != 0.0)
4714
 
                                        arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4715
 
                        }
4716
 
                        arrowTrans.scale(-1,1);
4717
 
                        arrow.map(arrowTrans);
4718
 
                }
4719
 
                else
4720
 
                {
4721
 
                        FPoint Start = PoLine.point(0);
4722
 
                        for (uint xx = 1; xx < PoLine.size(); xx += 2)
4723
 
                        {
4724
 
                                FPoint Vector = PoLine.point(xx);
4725
 
                                if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
4726
 
                                {
4727
 
                                        arrowTrans.translate(Start.x(), Start.y());
4728
 
                                        arrowTrans.rotate(atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI));
4729
 
                                        if (NamedLStyle.isEmpty())
4730
 
                                        {
4731
 
                                                if (m_lineWidth != 0.0)
4732
 
                                                        arrowTrans.scale(m_lineWidth, m_lineWidth);
4733
 
                                        }
4734
 
                                        else
4735
 
                                        {
4736
 
                                                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4737
 
                                                if (ml[ml.size()-1].Width != 0.0)
4738
 
                                                        arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4739
 
                                        }
4740
 
                                        arrow.map(arrowTrans);
4741
 
                                        break;
4742
 
                                }
4743
 
                        }
4744
 
                }
4745
 
                FPoint minAr = getMinClipF(&arrow);
4746
 
                FPoint maxAr = getMaxClipF(&arrow);
4747
 
                totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
4748
 
        }
4749
 
        if (m_endArrowIndex != 0)
4750
 
        {
4751
 
                QMatrix arrowTrans;
4752
 
                FPointArray arrow = m_Doc->arrowStyles.at(m_endArrowIndex-1).points.copy();
4753
 
                arrowTrans.translate(Xpos, Ypos);
4754
 
                arrowTrans.rotate(Rot);
4755
 
                if (itemType() == Line)
4756
 
                {
4757
 
                        arrowTrans.translate(Width, 0);
4758
 
                        if (NamedLStyle.isEmpty())
4759
 
                        {
4760
 
                                if (m_lineWidth != 0.0)
4761
 
                                        arrowTrans.scale(m_lineWidth, m_lineWidth);
4762
 
                        }
4763
 
                        else
4764
 
                        {
4765
 
                                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4766
 
                                if (ml[ml.size()-1].Width != 0.0)
4767
 
                                        arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4768
 
                        }
4769
 
                        arrow.map(arrowTrans);
4770
 
                }
4771
 
                else
4772
 
                {
4773
 
                        FPoint End = PoLine.point(PoLine.size()-2);
4774
 
                        for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
4775
 
                        {
4776
 
                                FPoint Vector = PoLine.point(xx);
4777
 
                                if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
4778
 
                                {
4779
 
                                        arrowTrans.translate(End.x(), End.y());
4780
 
                                        arrowTrans.rotate(atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI));
4781
 
                                        if (NamedLStyle.isEmpty())
4782
 
                                        {
4783
 
                                                if (m_lineWidth != 0.0)
4784
 
                                                        arrowTrans.scale(m_lineWidth, m_lineWidth);
4785
 
                                        }
4786
 
                                        else
4787
 
                                        {
4788
 
                                                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4789
 
                                                if (ml[ml.size()-1].Width != 0.0)
4790
 
                                                        arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4791
 
                                        }
4792
 
                                        arrow.map(arrowTrans);
4793
 
                                        break;
4794
 
                                }
4795
 
                        }
4796
 
                }
4797
 
                FPoint minAr = getMinClipF(&arrow);
4798
 
                FPoint maxAr = getMaxClipF(&arrow);
4799
 
                totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
4800
 
        }
4801
 
        totalRect.getCoords(x1, y1, x2, y2);
4802
 
}
4803
 
 
4804
 
void PageItem::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
4805
 
{
4806
 
        double minx =  std::numeric_limits<double>::max();
4807
 
        double miny =  std::numeric_limits<double>::max();
4808
 
        double maxx = -std::numeric_limits<double>::max();
4809
 
        double maxy = -std::numeric_limits<double>::max();
4810
 
        double extraSpace = 0.0;
4811
 
        if (NamedLStyle.isEmpty())
4812
 
        {
4813
 
                if (lineColor() != CommonStrings::None)
4814
 
                        extraSpace = m_lineWidth / 2.0;
4815
 
        }
4816
 
        else
4817
 
        {
4818
 
                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4819
 
                struct SingleLine& sl = ml[ml.size()-1];
4820
 
                if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
4821
 
                        extraSpace = sl.Width / 2.0;
4822
 
        }
4823
 
        if (Rot != 0)
4824
 
        {
4825
 
                FPointArray pb;
4826
 
                pb.resize(0);
4827
 
                pb.addPoint(FPoint(-extraSpace,                 -extraSpace,                    xPos(), yPos(), Rot, 1.0, 1.0));
4828
 
                pb.addPoint(FPoint(visualWidth()-extraSpace,    -extraSpace,                    xPos(), yPos(), Rot, 1.0, 1.0));
4829
 
                pb.addPoint(FPoint(visualWidth()-extraSpace,    visualHeight()-extraSpace,      xPos(), yPos(), Rot, 1.0, 1.0));
4830
 
                pb.addPoint(FPoint(-extraSpace,                 visualHeight()-extraSpace,      xPos(), yPos(), Rot, 1.0, 1.0));
4831
 
                for (uint pc = 0; pc < 4; ++pc)
4832
 
                {
4833
 
                        minx = qMin(minx, pb.point(pc).x());
4834
 
                        miny = qMin(miny, pb.point(pc).y());
4835
 
                        maxx = qMax(maxx, pb.point(pc).x());
4836
 
                        maxy = qMax(maxy, pb.point(pc).y());
4837
 
                }
4838
 
                *x1 = minx;
4839
 
                *y1 = miny;
4840
 
                *x2 = maxx;
4841
 
                *y2 = maxy;
4842
 
        }
4843
 
        else
4844
 
        {
4845
 
                *x1 = visualXPos();
4846
 
                *y1 = visualYPos();
4847
 
                *x2 = *x1 + qMax(visualWidth(), extraSpace);
4848
 
                *y2 = *y1 + qMax(visualHeight(), extraSpace);
4849
 
        }
4850
 
        QRectF totalRect = QRectF(QPointF(*x1, *y1), QPointF(*x2, *y2));
4851
 
        if (m_startArrowIndex != 0)
4852
 
        {
4853
 
                QMatrix arrowTrans;
4854
 
                FPointArray arrow = m_Doc->arrowStyles.at(m_startArrowIndex-1).points.copy();
4855
 
                arrowTrans.translate(Xpos, Ypos);
4856
 
                arrowTrans.rotate(Rot);
4857
 
                if (itemType() == Line)
4858
 
                {
4859
 
                        arrowTrans.translate(0, 0);
4860
 
                        if (NamedLStyle.isEmpty())
4861
 
                        {
4862
 
                                if (m_lineWidth != 0.0)
4863
 
                                        arrowTrans.scale(m_lineWidth, m_lineWidth);
4864
 
                        }
4865
 
                        else
4866
 
                        {
4867
 
                                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4868
 
                                if (ml[ml.size()-1].Width != 0.0)
4869
 
                                        arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4870
 
                        }
4871
 
                        arrowTrans.scale(-1,1);
4872
 
                        arrow.map(arrowTrans);
4873
 
                }
4874
 
                else
4875
 
                {
4876
 
                        FPoint Start = PoLine.point(0);
4877
 
                        for (uint xx = 1; xx < PoLine.size(); xx += 2)
4878
 
                        {
4879
 
                                FPoint Vector = PoLine.point(xx);
4880
 
                                if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
4881
 
                                {
4882
 
                                        arrowTrans.translate(Start.x(), Start.y());
4883
 
                                        arrowTrans.rotate(atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI));
4884
 
                                        if (NamedLStyle.isEmpty())
4885
 
                                        {
4886
 
                                                if (m_lineWidth != 0.0)
4887
 
                                                        arrowTrans.scale(m_lineWidth, m_lineWidth);
4888
 
                                        }
4889
 
                                        else
4890
 
                                        {
4891
 
                                                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4892
 
                                                if (ml[ml.size()-1].Width != 0.0)
4893
 
                                                        arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4894
 
                                        }
4895
 
                                        arrow.map(arrowTrans);
4896
 
                                        break;
4897
 
                                }
4898
 
                        }
4899
 
                }
4900
 
                FPoint minAr = getMinClipF(&arrow);
4901
 
                FPoint maxAr = getMaxClipF(&arrow);
4902
 
                totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
4903
 
        }
4904
 
        if (m_endArrowIndex != 0)
4905
 
        {
4906
 
                QMatrix arrowTrans;
4907
 
                FPointArray arrow = m_Doc->arrowStyles.at(m_endArrowIndex-1).points.copy();
4908
 
                arrowTrans.translate(Xpos, Ypos);
4909
 
                arrowTrans.rotate(Rot);
4910
 
                if (itemType() == Line)
4911
 
                {
4912
 
                        arrowTrans.translate(Width, 0);
4913
 
                        if (NamedLStyle.isEmpty())
4914
 
                        {
4915
 
                                if (m_lineWidth != 0.0)
4916
 
                                        arrowTrans.scale(m_lineWidth, m_lineWidth);
4917
 
                        }
4918
 
                        else
4919
 
                        {
4920
 
                                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4921
 
                                if (ml[ml.size()-1].Width != 0.0)
4922
 
                                        arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4923
 
                        }
4924
 
                        arrow.map(arrowTrans);
4925
 
                }
4926
 
                else
4927
 
                {
4928
 
                        FPoint End = PoLine.point(PoLine.size()-2);
4929
 
                        for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
4930
 
                        {
4931
 
                                FPoint Vector = PoLine.point(xx);
4932
 
                                if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
4933
 
                                {
4934
 
                                        arrowTrans.translate(End.x(), End.y());
4935
 
                                        arrowTrans.rotate(atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI));
4936
 
                                        if (NamedLStyle.isEmpty())
4937
 
                                        {
4938
 
                                                if (m_lineWidth != 0.0)
4939
 
                                                        arrowTrans.scale(m_lineWidth, m_lineWidth);
4940
 
                                        }
4941
 
                                        else
4942
 
                                        {
4943
 
                                                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4944
 
                                                if (ml[ml.size()-1].Width != 0.0)
4945
 
                                                        arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4946
 
                                        }
4947
 
                                        arrow.map(arrowTrans);
4948
 
                                        break;
4949
 
                                }
4950
 
                        }
4951
 
                }
4952
 
                FPoint minAr = getMinClipF(&arrow);
4953
 
                FPoint maxAr = getMaxClipF(&arrow);
4954
 
                totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
4955
 
        }
4956
 
        totalRect.getCoords(x1, y1, x2, y2);
4957
 
}
4958
 
 
4959
 
double PageItem::visualXPos() const
4960
 
{
4961
 
        double extraSpace = 0.0;
4962
 
        if (!isLine())
4963
 
        {
4964
 
                if (NamedLStyle.isEmpty())
4965
 
                {
4966
 
                        if (lineColor() != CommonStrings::None)
4967
 
                                extraSpace = m_lineWidth / 2.0;
4968
 
                }
4969
 
                else
4970
 
                {
4971
 
                        multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4972
 
                        struct SingleLine& sl = ml[ml.size()-1];
4973
 
                        if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
4974
 
                                extraSpace = sl.Width / 2.0;
4975
 
                }
4976
 
        }
4977
 
        return Xpos - extraSpace;
4978
 
}
4979
 
 
4980
 
double PageItem::visualYPos() const
4981
 
{
4982
 
        double extraSpace = 0.0;
4983
 
        if (NamedLStyle.isEmpty())
4984
 
        {
4985
 
                if (lineColor() != CommonStrings::None)
4986
 
                        extraSpace = m_lineWidth / 2.0;
4987
 
        }
4988
 
        else
4989
 
        {
4990
 
                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4991
 
                struct SingleLine& sl = ml[ml.size()-1];
4992
 
                if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
4993
 
                        extraSpace = sl.Width / 2.0;
4994
 
        }
4995
 
        return Ypos - extraSpace;
4996
 
}
4997
 
 
4998
 
double PageItem::visualWidth() const
4999
 
{
5000
 
        double extraSpace = 0.0;
5001
 
        if (!isLine())
5002
 
        {
5003
 
                if (NamedLStyle.isEmpty())
5004
 
                {
5005
 
                        if (lineColor() != CommonStrings::None)
5006
 
                                extraSpace = m_lineWidth;
5007
 
                }
5008
 
                else
5009
 
                {
5010
 
                        multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5011
 
                        struct SingleLine& sl = ml[ml.size()-1];
5012
 
                        if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
5013
 
                                extraSpace = sl.Width;
5014
 
                }
5015
 
        }
5016
 
        return Width + extraSpace;
5017
 
}
5018
 
 
5019
 
double PageItem::visualHeight() const
5020
 
{
5021
 
        double extraSpace = 0.0;
5022
 
        if (NamedLStyle.isEmpty())
5023
 
        {
5024
 
                if (lineColor() != CommonStrings::None)
5025
 
                        extraSpace = m_lineWidth;
5026
 
        }
5027
 
        else
5028
 
        {
5029
 
                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5030
 
                struct SingleLine& sl = ml[ml.size()-1];
5031
 
                if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
5032
 
                        extraSpace = sl.Width;
5033
 
        }
5034
 
        return isLine() ? extraSpace : Height + extraSpace;
5035
 
}
5036
 
 
5037
 
bool PageItem::pointWithinItem(const int x, const int y) const
5038
 
{
5039
 
        const_cast<PageItem*>(this)-> setRedrawBounding();
5040
 
        // FIXME: We should be rounding or truncating here, not letting the compiler do it.
5041
 
        // Should we be rounding, truncating up, or truncating down?
5042
 
        //CB is this now correct?
5043
 
        QRect itemRect( static_cast<int>(floor(BoundingX)), static_cast<int>(floor(BoundingY)), static_cast<int>(ceil(BoundingW)), static_cast<int>(ceil(BoundingH)) );
5044
 
        return itemRect.contains(x, y);
5045
 
}
5046
 
 
5047
 
bool PageItem::mouseWithinItem(const int x, const int y, double scale) const
5048
 
{
5049
 
        QMatrix p;
5050
 
        QRectF transRect;
5051
 
        p.translate(Xpos * scale, Ypos*scale);
5052
 
        p.scale(scale, scale);
5053
 
        p.rotate(rotation());
5054
 
        transRect = p.mapRect(QRectF(0.0, 0.0, width(), height()));
5055
 
        return transRect.contains(x, y);
5056
 
}
5057
 
 
5058
 
bool PageItem::loadImage(const QString& filename, const bool reload, const int gsResolution, bool showMsg)
5059
 
{
5060
 
        bool useImage = (asImageFrame() != NULL);
5061
 
        useImage |= (isAnnotation() && annotation().UseIcons());
5062
 
        if (!useImage)
5063
 
                return false;
5064
 
        QFileInfo fi(filename);
5065
 
        QString clPath(pixm.imgInfo.usedPath);
5066
 
        pixm.imgInfo.valid = false;
5067
 
        pixm.imgInfo.clipPath="";
5068
 
        pixm.imgInfo.PDSpathData.clear();
5069
 
        pixm.imgInfo.layerInfo.clear();
5070
 
        pixm.imgInfo.usedPath="";
5071
 
        imageClip.resize(0);
5072
 
        int lowResTypeBack = pixm.imgInfo.lowResType;
5073
 
        int gsRes=gsResolution;
5074
 
        if (gsResolution==-1) //If it wasn't supplied, get it from PrefsManager.
5075
 
                gsRes=PrefsManager::instance()->gsResolution();
5076
 
        bool dummy;
5077
 
        CMSettings cms(m_Doc, IProfile, IRender);
5078
 
        if (!pixm.LoadPicture(filename, pixm.imgInfo.actualPageNumber, cms, UseEmbedded, true, ScImage::RGBProof, gsRes, &dummy, showMsg))
5079
 
        {
5080
 
                Pfile = fi.absoluteFilePath();
5081
 
                PictureIsAvailable = false;
5082
 
//              PicArt = false;
5083
 
                return false;
5084
 
        }
5085
 
        else
5086
 
        {
5087
 
                QString ext = fi.suffix().toLower();
5088
 
                if (UndoManager::undoEnabled() && !reload)
5089
 
                {
5090
 
                        ItemState<ScImageEffectList> *is = new ItemState<ScImageEffectList>(Um::GetImage, filename, Um::IGetImage);
5091
 
                        is->set("GET_IMAGE", "get_image");
5092
 
                        is->set("OLD_IMAGE_PATH", Pfile);
5093
 
                        is->set("NEW_IMAGE_PATH", filename);
5094
 
                        is->set("FLIPPH",imageFlippedH());
5095
 
                        is->set("FLIPPV",imageFlippedV());
5096
 
                        is->set("SCALING",ScaleType);
5097
 
                        is->set("ASPECT",AspectRatio);
5098
 
                        is->set("XOFF",imageXOffset());
5099
 
                        is->set("XSCALE",imageXScale());
5100
 
                        is->set("YOFF",imageYOffset());
5101
 
                        is->set("YSCALE",imageYScale());
5102
 
                        is->set("FILLT", fillTransparency());
5103
 
                        is->set("LINET", lineTransparency());
5104
 
                        is->setItem(effectsInUse);
5105
 
                        undoManager->action(this, is);
5106
 
                }
5107
 
                double xres = pixm.imgInfo.xres;
5108
 
                double yres = pixm.imgInfo.yres;
5109
 
                PictureIsAvailable = true;
5110
 
//              PicArt = true;
5111
 
                
5112
 
                if (Pfile != filename)
5113
 
                {
5114
 
                        oldLocalScX = LocalScX = 72.0 / xres;
5115
 
                        oldLocalScY = LocalScY = 72.0 / yres;
5116
 
                        oldLocalX = LocalX = 0;
5117
 
                        oldLocalY = LocalY = 0;
5118
 
                        
5119
 
                        if ((m_Doc->toolSettings.useEmbeddedPath) && (!pixm.imgInfo.clipPath.isEmpty()))
5120
 
                        {
5121
 
                                pixm.imgInfo.usedPath = pixm.imgInfo.clipPath;
5122
 
                                clPath = pixm.imgInfo.clipPath;
5123
 
                                if (pixm.imgInfo.PDSpathData.contains(clPath))
5124
 
                                {
5125
 
                                        imageClip = pixm.imgInfo.PDSpathData[clPath].copy();
5126
 
                                        pixm.imgInfo.usedPath = clPath;
5127
 
                                        QMatrix cl;
5128
 
                                        cl.translate(LocalX*LocalScX, LocalY*LocalScY);
5129
 
                                        cl.scale(LocalScX, LocalScY);
5130
 
                                        imageClip.map(cl);
5131
 
                                }
5132
 
                        }
5133
 
                }
5134
 
                
5135
 
                Pfile = fi.absoluteFilePath();
5136
 
                if (reload && pixm.imgInfo.PDSpathData.contains(clPath))
5137
 
                {
5138
 
                        imageClip = pixm.imgInfo.PDSpathData[clPath].copy();
5139
 
                        pixm.imgInfo.usedPath = clPath;
5140
 
                        QMatrix cl;
5141
 
                        cl.translate(LocalX*LocalScX, LocalY*LocalScY);
5142
 
                        cl.scale(LocalScX, LocalScY);
5143
 
                        imageClip.map(cl);
5144
 
                }
5145
 
                BBoxX = pixm.imgInfo.BBoxX;
5146
 
                BBoxH = pixm.imgInfo.BBoxH;
5147
 
                OrigW = pixm.width();
5148
 
                OrigH = pixm.height();
5149
 
                isRaster = !(extensionIndicatesPDF(ext) || extensionIndicatesEPSorPS(ext));
5150
 
                if (!isRaster)
5151
 
                        effectsInUse.clear();
5152
 
                UseEmbedded=pixm.imgInfo.isEmbedded;
5153
 
                if (pixm.imgInfo.isEmbedded)
5154
 
                {
5155
 
                        IProfile = "Embedded " + pixm.imgInfo.profileName;
5156
 
                        EmProfile = "Embedded " + pixm.imgInfo.profileName;
5157
 
                }
5158
 
                else
5159
 
                        IProfile = pixm.imgInfo.profileName;
5160
 
                AdjustPictScale();
5161
 
        }
5162
 
        if (PictureIsAvailable)
5163
 
        {
5164
 
                if ((pixm.imgInfo.colorspace == ColorSpaceDuotone) && (pixm.imgInfo.duotoneColors.count() != 0) && (!reload))
5165
 
                {
5166
 
                        QString efVal = "";
5167
 
                        for (int cc = 0; cc < pixm.imgInfo.duotoneColors.count(); cc++)
5168
 
                        {
5169
 
                                if (!m_Doc->PageColors.contains(pixm.imgInfo.duotoneColors[cc].Name))
5170
 
                                        m_Doc->PageColors.insert(pixm.imgInfo.duotoneColors[cc].Name, pixm.imgInfo.duotoneColors[cc].Color);
5171
 
                                efVal += pixm.imgInfo.duotoneColors[cc].Name+"\n";
5172
 
                        }
5173
 
                        m_Doc->scMW()->propertiesPalette->updateColorList();
5174
 
                        struct ImageEffect ef;
5175
 
                        if (pixm.imgInfo.duotoneColors.count() == 1)
5176
 
                        {
5177
 
                                efVal += "100";
5178
 
                                ef.effectCode = ScImage::EF_COLORIZE;
5179
 
                                ef.effectParameters = efVal;
5180
 
                        }
5181
 
                        else if (pixm.imgInfo.duotoneColors.count() == 2)
5182
 
                        {
5183
 
                                efVal += "100 100";
5184
 
                                QString tmp;
5185
 
                                FPointArray Vals = pixm.imgInfo.duotoneColors[0].Curve;
5186
 
                                tmp.setNum(Vals.size());
5187
 
                                efVal += " "+tmp;
5188
 
                                for (uint p = 0; p < Vals.size(); p++)
5189
 
                                {
5190
 
                                        FPoint pv = Vals.point(p);
5191
 
                                        efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5192
 
                                }
5193
 
                                efVal += " 0";
5194
 
                                Vals = pixm.imgInfo.duotoneColors[1].Curve;
5195
 
                                tmp.setNum(Vals.size());
5196
 
                                efVal += " "+tmp;
5197
 
                                for (uint p = 0; p < Vals.size(); p++)
5198
 
                                {
5199
 
                                        FPoint pv = Vals.point(p);
5200
 
                                        efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5201
 
                                }
5202
 
                                efVal += " 0";
5203
 
                                ef.effectCode = ScImage::EF_DUOTONE;
5204
 
                                ef.effectParameters = efVal;
5205
 
                        }
5206
 
                        else if (pixm.imgInfo.duotoneColors.count() == 3)
5207
 
                        {
5208
 
                                efVal += "100 100 100";
5209
 
                                QString tmp;
5210
 
                                FPointArray Vals = pixm.imgInfo.duotoneColors[0].Curve;
5211
 
                                tmp.setNum(Vals.size());
5212
 
                                efVal += " "+tmp;
5213
 
                                for (uint p = 0; p < Vals.size(); p++)
5214
 
                                {
5215
 
                                        FPoint pv = Vals.point(p);
5216
 
                                        efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5217
 
                                }
5218
 
                                efVal += " 0";
5219
 
                                Vals = pixm.imgInfo.duotoneColors[1].Curve;
5220
 
                                tmp.setNum(Vals.size());
5221
 
                                efVal += " "+tmp;
5222
 
                                for (uint p = 0; p < Vals.size(); p++)
5223
 
                                {
5224
 
                                        FPoint pv = Vals.point(p);
5225
 
                                        efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5226
 
                                }
5227
 
                                efVal += " 0";
5228
 
                                Vals = pixm.imgInfo.duotoneColors[2].Curve;
5229
 
                                tmp.setNum(Vals.size());
5230
 
                                efVal += " "+tmp;
5231
 
                                for (uint p = 0; p < Vals.size(); p++)
5232
 
                                {
5233
 
                                        FPoint pv = Vals.point(p);
5234
 
                                        efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5235
 
                                }
5236
 
                                efVal += " 0";
5237
 
                                ef.effectCode = ScImage::EF_TRITONE;
5238
 
                                ef.effectParameters = efVal;
5239
 
                        }
5240
 
                        else if (pixm.imgInfo.duotoneColors.count() == 4)
5241
 
                        {
5242
 
                                efVal += "100 100 100 100";
5243
 
                                QString tmp;
5244
 
                                FPointArray Vals = pixm.imgInfo.duotoneColors[0].Curve;
5245
 
                                tmp.setNum(Vals.size());
5246
 
                                efVal += " "+tmp;
5247
 
                                for (uint p = 0; p < Vals.size(); p++)
5248
 
                                {
5249
 
                                        FPoint pv = Vals.point(p);
5250
 
                                        efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5251
 
                                }
5252
 
                                efVal += " 0";
5253
 
                                Vals = pixm.imgInfo.duotoneColors[1].Curve;
5254
 
                                tmp.setNum(Vals.size());
5255
 
                                efVal += " "+tmp;
5256
 
                                for (uint p = 0; p < Vals.size(); p++)
5257
 
                                {
5258
 
                                        FPoint pv = Vals.point(p);
5259
 
                                        efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5260
 
                                }
5261
 
                                efVal += " 0";
5262
 
                                Vals = pixm.imgInfo.duotoneColors[2].Curve;
5263
 
                                tmp.setNum(Vals.size());
5264
 
                                efVal += " "+tmp;
5265
 
                                for (uint p = 0; p < Vals.size(); p++)
5266
 
                                {
5267
 
                                        FPoint pv = Vals.point(p);
5268
 
                                        efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5269
 
                                }
5270
 
                                efVal += " 0";
5271
 
                                Vals = pixm.imgInfo.duotoneColors[3].Curve;
5272
 
                                tmp.setNum(Vals.size());
5273
 
                                efVal += " "+tmp;
5274
 
                                for (uint p = 0; p < Vals.size(); p++)
5275
 
                                {
5276
 
                                        FPoint pv = Vals.point(p);
5277
 
                                        efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5278
 
                                }
5279
 
                                efVal += " 0";
5280
 
                                ef.effectCode = ScImage::EF_QUADTONE;
5281
 
                                ef.effectParameters = efVal;
5282
 
                        }
5283
 
                        effectsInUse.append(ef);
5284
 
                }
5285
 
                pixm.applyEffect(effectsInUse, m_Doc->PageColors, false);
5286
 
//              if (reload)
5287
 
                        pixm.imgInfo.lowResType = lowResTypeBack;
5288
 
                if (pixm.imgInfo.lowResType != 0)
5289
 
                {
5290
 
                        double scaling = pixm.imgInfo.xres / 36.0;
5291
 
                        if (pixm.imgInfo.lowResType == 1)
5292
 
                                scaling = pixm.imgInfo.xres / 72.0;
5293
 
                        // Prevent exagerately large images when using low res preview modes
5294
 
                        uint pixels = qRound(pixm.width() * pixm.height() / (scaling * scaling));
5295
 
                        if (pixels > 3000000)
5296
 
                        {
5297
 
                                double ratio = pixels / 3000000.0;
5298
 
                                scaling *= sqrt(ratio);
5299
 
                        }
5300
 
                        pixm.createLowRes(scaling);
5301
 
                        pixm.imgInfo.lowResScale = scaling;
5302
 
                }
5303
 
                if ((m_Doc->view()->m_canvas->usePreviewVisual()))
5304
 
                {
5305
 
                        VisionDefectColor defect;
5306
 
                        QColor tmpC;
5307
 
                        int h = pixm.qImagePtr()->height();
5308
 
                        int w = pixm.qImagePtr()->width();
5309
 
                        int r, g, b, a;
5310
 
                        QRgb *s;
5311
 
                        QRgb rgb;
5312
 
                        for( int yi=0; yi < h; ++yi )
5313
 
                        {
5314
 
                                s = (QRgb*)(pixm.qImagePtr()->scanLine( yi ));
5315
 
                                for( int xi = 0; xi < w; ++xi )
5316
 
                                {
5317
 
                                        rgb = *s;
5318
 
                                        tmpC.setRgb(rgb);
5319
 
                                        tmpC = defect.convertDefect(tmpC, m_Doc->view()->m_canvas->previewVisual());
5320
 
                                        a = qAlpha(rgb);
5321
 
                                        tmpC.getRgb(&r, &g, &b);
5322
 
                                        *s = qRgba(r, g, b, a);
5323
 
                                        s++;
5324
 
                                }
5325
 
                        }
5326
 
                }
5327
 
        }
5328
 
        return true;
5329
 
}
5330
 
 
5331
 
 
5332
 
void PageItem::drawLockedMarker(ScPainter *p)
5333
 
{
5334
 
        //TODO: CB clean
5335
 
        double scp1 = 1 ;// / ScMW->view->scale();
5336
 
        double ofwh = 6 * scp1;
5337
 
        double ofx = Width - ofwh/2;
5338
 
        double ofy = Height - ofwh*1.5;
5339
 
        double bx1= ofx+ scp1;
5340
 
        double by1= ofy+3 * scp1;
5341
 
        double bw= 4*scp1;
5342
 
        double bh= 2*scp1;
5343
 
        ScribusView* view = m_Doc->view();
5344
 
        p->setPen(Qt::black, 0.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
5345
 
        p->setPenOpacity(1.0);
5346
 
        p->setBrush(Qt::white);
5347
 
        p->setBrushOpacity(1.0);
5348
 
        p->setFillMode(ScPainter::Solid);
5349
 
        p->drawRect(ofx, ofy, ofwh, ofwh);
5350
 
        p->setBrush(Qt::black);
5351
 
        p->drawRect(bx1, by1, bw, bh);
5352
 
        p->setPen(Qt::black, 1.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin);
5353
 
        if (m_Locked)
5354
 
                p->drawLine(FPoint(bx1+scp1/2, ofy+scp1), FPoint(bx1+scp1/2, by1));
5355
 
        p->drawLine(FPoint(bx1+scp1*3.5, ofy+scp1), FPoint(bx1+scp1*3.5, by1));
5356
 
        p->drawLine(FPoint(bx1+scp1/2, ofy+scp1), FPoint(bx1+scp1*3.5, ofy+scp1));
5357
 
}
5358
 
 
5359
 
void PageItem::drawArrow(ScPainter *p, QMatrix &arrowTrans, int arrowIndex)
5360
 
{
5361
 
        FPointArray arrow = m_Doc->arrowStyles.at(arrowIndex-1).points.copy();
5362
 
        if (NamedLStyle.isEmpty())
5363
 
        {
5364
 
                if (m_lineWidth != 0.0)
5365
 
                        arrowTrans.scale(m_lineWidth, m_lineWidth);
5366
 
        }
5367
 
        else
5368
 
        {
5369
 
                multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5370
 
                if (ml[ml.size()-1].Width != 0.0)
5371
 
                        arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
5372
 
        }
5373
 
        arrow.map(arrowTrans);
5374
 
        p->setupPolygon(&arrow);
5375
 
        if (m_Doc->layerOutline(LayerNr))
5376
 
                p->strokePath();
5377
 
        else
5378
 
        {
5379
 
                if (NamedLStyle.isEmpty())
5380
 
                {
5381
 
                        if (lineColor() != CommonStrings::None)
5382
 
                        {
5383
 
                                p->setBrush(strokeQColor);
5384
 
                                p->setBrushOpacity(1.0 - lineTransparency());
5385
 
                                p->setLineWidth(0);
5386
 
                                p->setFillMode(ScPainter::Solid);
5387
 
                                p->fillPath();
5388
 
                        }
5389
 
                }
5390
 
                else
5391
 
                {
5392
 
                        multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5393
 
                        QColor tmp;
5394
 
                        if (ml[0].Color != CommonStrings::None)
5395
 
                        {
5396
 
                                SetQColor(&tmp, ml[0].Color, ml[0].Shade);
5397
 
                                p->setBrush(tmp);
5398
 
                                p->setLineWidth(0);
5399
 
                                p->setFillMode(ScPainter::Solid);
5400
 
                                p->fillPath();
5401
 
                        }
5402
 
                        for (int it = ml.size()-1; it > 0; it--)
5403
 
                        {
5404
 
                                if (ml[it].Color != CommonStrings::None)
5405
 
                                {
5406
 
                                        SetQColor(&tmp, ml[it].Color, ml[it].Shade);
5407
 
                                        p->setPen(tmp, ml[it].Width, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
5408
 
                                        p->strokePath();
5409
 
                                }
5410
 
                        }
5411
 
                }
5412
 
        }
5413
 
}
5414
 
 
5415
 
void PageItem::AdjustPictScale()
5416
 
{
5417
 
        if (itemType()!=PageItem::ImageFrame)
5418
 
                return;
5419
 
        if (ScaleType)
5420
 
                return;
5421
 
        if (OrigW == 0 || OrigH == 0)
5422
 
                return;
5423
 
        LocalX = 0;
5424
 
        LocalY = 0;
5425
 
        double xs = Width / static_cast<double>(OrigW);
5426
 
        double ys = Height / static_cast<double>(OrigH);
5427
 
        if (AspectRatio)
5428
 
        {
5429
 
                LocalScX = qMin(xs, ys);
5430
 
                LocalScY = qMin(xs, ys);
5431
 
        }
5432
 
        else
5433
 
        {
5434
 
                LocalScX = xs;
5435
 
                LocalScY = ys;
5436
 
        }
5437
 
        // Disable broken code. Code must be independent from doc in that function
5438
 
        /*switch (m_Doc->RotMode)
5439
 
        {
5440
 
                case 0:
5441
 
                        LocalX = 0;
5442
 
                        LocalY = 0;
5443
 
                        break;
5444
 
                case 1:
5445
 
                        LocalX = (Width - static_cast<double>(OrigW) * LocalScX) / LocalScX;
5446
 
                        LocalY = 0;
5447
 
                        break;
5448
 
                case 2:
5449
 
                        LocalX = ((Width - static_cast<double>(OrigW) * LocalScX) / LocalScX) / 2.0;
5450
 
                        LocalY = ((Height - static_cast<double>(OrigH) * LocalScY) / LocalScY) / 2.0;
5451
 
                        break;
5452
 
                case 3:
5453
 
                        LocalX = 0;
5454
 
                        LocalY = (Height - static_cast<double>(OrigH) * LocalScY) / LocalScY;
5455
 
                        break;
5456
 
                case 4:
5457
 
                        LocalX = (Width - static_cast<double>(OrigW) * LocalScX) / LocalScX;
5458
 
                        LocalY = (Height - static_cast<double>(OrigH) * LocalScY) / LocalScY;
5459
 
                        break;
5460
 
        }*/
5461
 
        if (imageClip.size() != 0)
5462
 
        {
5463
 
                imageClip = pixm.imgInfo.PDSpathData[pixm.imgInfo.usedPath].copy();
5464
 
                QMatrix cl;
5465
 
                cl.translate(LocalX*LocalScX, LocalY*LocalScY);
5466
 
                cl.scale(LocalScX, LocalScY);
5467
 
                imageClip.map(cl);
5468
 
        }
5469
 
        emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY );
5470
 
}
5471
 
 
5472
 
void PageItem::setExternalFile(QString val)
5473
 
{
5474
 
        Pfile = val;
5475
 
        if (!Pfile.isEmpty())
5476
 
        {
5477
 
                QString test = Pfile;
5478
 
                if (QDir::isRelativePath(test))
5479
 
                        test = QDir::homePath()+"/"+Pfile;
5480
 
                test = QDir::cleanPath(QDir::convertSeparators(test));
5481
 
                QFileInfo pfi2(test);
5482
 
                Pfile = pfi2.absoluteFilePath();
5483
 
        }
5484
 
}
5485
 
 
5486
 
void PageItem::setFileIconPressed(QString val)
5487
 
{
5488
 
        Pfile2 = val;
5489
 
        if (!Pfile2.isEmpty())
5490
 
        {
5491
 
                QString test = QDir::cleanPath(QDir::convertSeparators(QDir::homePath()+"/"+Pfile2));
5492
 
                QFileInfo pfi2(test);
5493
 
                Pfile2 = pfi2.absoluteFilePath();
5494
 
        }
5495
 
}
5496
 
 
5497
 
void PageItem::setFileIconRollover(QString val)
5498
 
{
5499
 
        Pfile3 = val;
5500
 
        if (!Pfile3.isEmpty())
5501
 
        {
5502
 
                QString test = QDir::cleanPath(QDir::convertSeparators(QDir::homePath()+"/"+Pfile3));
5503
 
                QFileInfo pfi2(test);
5504
 
                Pfile3 = pfi2.absoluteFilePath();
5505
 
        }
5506
 
}
5507
 
 
5508
 
QRect PageItem::getRedrawBounding(const double viewScale)
5509
 
{
5510
 
        int x = qRound(floor(BoundingX - Oldm_lineWidth / 2.0 - 5) * viewScale);
5511
 
        int y = qRound(floor(BoundingY - Oldm_lineWidth / 2.0 - 5) * viewScale);
5512
 
        int w = qRound(ceil(BoundingW + Oldm_lineWidth + 10) * viewScale);
5513
 
        int h = qRound(ceil(BoundingH + Oldm_lineWidth + 10) * viewScale);
5514
 
        QRect ret = QRect(x, y, w, h);
5515
 
        ret.translate(qRound(-m_Doc->minCanvasCoordinate.x() * viewScale), qRound(-m_Doc->minCanvasCoordinate.y() * viewScale));
5516
 
        return ret;
5517
 
}
5518
 
 
5519
 
 
5520
 
void PageItem::setRedrawBounding()
5521
 
{
5522
 
        double bw, bh;
5523
 
        getBoundingRect(&BoundingX, &BoundingY, &bw, &bh);
5524
 
        BoundingW = bw - BoundingX;
5525
 
        BoundingH = bh - BoundingY;
5526
 
        if (asLine())
5527
 
                BoundingH = qMax(BoundingH, 1.0);
5528
 
}
5529
 
 
5530
 
void PageItem::updateGradientVectors()
5531
 
{
5532
 
        switch (GrType)
5533
 
        {
5534
 
                case 0:
5535
 
                case 1:
5536
 
                        GrStartX = 0;
5537
 
                        GrStartY = Height / 2.0;
5538
 
                        GrEndX = Width;
5539
 
                        GrEndY = Height / 2.0;
5540
 
                        break;
5541
 
                case 2:
5542
 
                        GrStartX = Width / 2.0;
5543
 
                        GrStartY = 0;
5544
 
                        GrEndX = Width / 2.0;
5545
 
                        GrEndY = Height;
5546
 
                        break;
5547
 
                case 3:
5548
 
                        GrStartX = 0;
5549
 
                        GrStartY = 0;
5550
 
                        GrEndX = Width;
5551
 
                        GrEndY = Height;
5552
 
                        break;
5553
 
                case 4:
5554
 
                        GrStartX = 0;
5555
 
                        GrStartY = Height;
5556
 
                        GrEndX = Width;
5557
 
                        GrEndY = 0;
5558
 
                        break;
5559
 
                case 5:
5560
 
                        GrStartX = Width / 2.0;
5561
 
                        GrStartY = Height / 2.0;
5562
 
                        if (Width >= Height)
5563
 
                        {
5564
 
                                GrEndX = Width;
5565
 
                                GrEndY = Height / 2.0;
5566
 
                        }
5567
 
                        else
5568
 
                        {
5569
 
                                GrEndX = Width / 2.0;
5570
 
                                GrEndY = Height;
5571
 
                        }
5572
 
                        break;
5573
 
                default:
5574
 
                        break;
5575
 
        }
5576
 
        //if (ScMW->view->SelItem.count()!=0 && this==ScMW->view->SelItem.at(0))
5577
 
        //if (m_Doc->m_Selection->count()!=0 && m_Doc->m_Selection->primarySelectionIsMyself(this))
5578
 
        //      ScMW->propertiesPalette->updateColorSpecialGradient();
5579
 
        //CB Will only emit if connected, ie is first in GUI selection
5580
 
        double dur=m_Doc->unitRatio();
5581
 
        emit gradientColorUpdate(GrStartX*dur, GrStartY*dur, GrEndX*dur, GrEndY*dur, Width*dur, Height*dur);
5582
 
}
5583
 
 
5584
 
void PageItem::setPolyClip(int up, int down)
5585
 
{
5586
 
        if (PoLine.size() < 4)
5587
 
                return;
5588
 
        double rot;
5589
 
        int upval = up;
5590
 
        int downval = down;
5591
 
        if (up == 0)
5592
 
                upval = 1;
5593
 
        if (textPathFlipped)
5594
 
        {
5595
 
                upval *= -1;
5596
 
                downval *= -1;
5597
 
        }
5598
 
        QPoint np, np2;
5599
 
        QPolygon cl, cl1, cl2;
5600
 
        cl = FlattenPath(PoLine, Segments);
5601
 
        if (cl.size() > 1)
5602
 
        {
5603
 
                Clip.resize(0);
5604
 
                for (int a = 0; a < cl.size()-1; ++a)
5605
 
                {
5606
 
                        rot = xy2Deg(cl.point(a+1).x()-cl.point(a).x(),cl.point(a+1).y()-cl.point(a).y());
5607
 
                        QMatrix ma;
5608
 
                        ma.rotate(rot);
5609
 
                        np = QPoint(0, -upval) * ma;
5610
 
                        np2 = QPoint(0, -downval) * ma;
5611
 
                        cl1.resize(cl1.size()+1);
5612
 
                        cl1.setPoint(cl1.size()-1, np+cl.point(a));
5613
 
                        cl1.resize(cl1.size()+1);
5614
 
                        cl1.setPoint(cl1.size()-1, np+cl.point(a+1));
5615
 
                        cl2.resize(cl2.size()+1);
5616
 
                        cl2.setPoint(cl2.size()-1, np2+cl.point(a));
5617
 
                        cl2.resize(cl2.size()+1);
5618
 
                        cl2.setPoint(cl2.size()-1, np2+cl.point(a+1));
5619
 
                }
5620
 
                cl1.resize(cl1.size()+1);
5621
 
                cl1.setPoint(cl1.size()-1, np+cl.point(cl.size()-1));
5622
 
                cl2.resize(cl2.size()+1);
5623
 
                cl2.setPoint(cl2.size()-1, np2+cl.point(cl.size()-1));
5624
 
                Clip.putPoints(Clip.size(), cl1.size(), cl1);
5625
 
                for (int a2 = cl2.size()-1; a2 > -1; a2--)
5626
 
                {
5627
 
                        Clip.resize(Clip.size()+1);
5628
 
                        Clip.setPoint(Clip.size()-1, cl2.point(a2));
5629
 
                }
5630
 
        }
5631
 
}
5632
 
 
5633
 
void PageItem::updatePolyClip()
5634
 
{
5635
 
        int asce = 1;
5636
 
        int desc = 1;
5637
 
        uint itemTextCount=itemText.length();
5638
 
        for (uint a = 0; a < itemTextCount; ++a)
5639
 
        {
5640
 
                const CharStyle& hl (itemText.charStyle(a));
5641
 
                int des = static_cast<int>(hl.font().descent(hl.fontSize() / 10.0));
5642
 
                int asc = static_cast<int>(hl.font().ascent(hl.fontSize() / 10.0));
5643
 
                asce = qMax(asce, asc);
5644
 
                desc = qMax(desc, des);
5645
 
        }
5646
 
        setPolyClip(static_cast<int>(asce-BaseOffs), static_cast<int>(desc-BaseOffs));
5647
 
}
5648
 
 
5649
 
void PageItem::handleModeEditKey(QKeyEvent * /* k */, bool & /* keyRepeat */)
5650
 
{
5651
 
}
5652
 
 
5653
 
bool PageItem::connectToGUI()
5654
 
{
5655
 
        if (!ScCore->usingGUI())
5656
 
                return false;
5657
 
        if (!m_Doc->m_Selection->primarySelectionIs(this))
5658
 
                return false;
5659
 
        PropertiesPalette* pp=m_Doc->scMW()->propertiesPalette;
5660
 
        connect(this, SIGNAL(myself(PageItem *)), pp, SLOT(SetCurItem(PageItem *)));
5661
 
        connect(this, SIGNAL(frameType(int)), m_Doc->scMW(), SLOT(HaveNewSel(int)));
5662
 
        connect(this, SIGNAL(frameType(int)), m_Doc->view(), SLOT(selectionChanged()));
5663
 
        connect(this, SIGNAL(frameType(int)), pp, SLOT(NewSel(int)));
5664
 
        connect(this, SIGNAL(frameLocked(bool)), pp, SLOT(setLocked(bool)));
5665
 
        connect(this, SIGNAL(frameSizeLocked(bool)), pp, SLOT(setSizeLocked(bool)));
5666
 
        connect(this, SIGNAL(frameFlippedH(bool)), pp, SLOT(setFlippedH(bool)));
5667
 
        connect(this, SIGNAL(frameFlippedV(bool)), pp, SLOT(setFlippedV(bool)));
5668
 
        connect(this, SIGNAL(printEnabled(bool)), pp, SLOT(setPrintingEnabled(bool)));
5669
 
        connect(this, SIGNAL(position(double, double)), pp, SLOT(setXY(double, double)));
5670
 
        connect(this, SIGNAL(widthAndHeight(double, double)), pp, SLOT(setBH(double, double)));
5671
 
//CB unused in 135 connect(this, SIGNAL(colors(QString, QString, double, double)), m_Doc->scMW(), SLOT(setCSMenu()));
5672
 
//      connect(this, SIGNAL(colors(QString, QString, double, double)), pp->Cpal, SLOT(setActFarben(QString, QString, int, int)));
5673
 
//      connect(this, SIGNAL(gradientType(int)), pp->Cpal, SLOT(setActGradient(int)));
5674
 
        connect(this, SIGNAL(patternFill(QString, double, double, double, double, double)), pp->Cpal, SLOT(setActPattern(QString, double, double, double, double, double)));
5675
 
//      connect(this, SIGNAL(gradientColorUpdate(double, double, double, double, double, double)), pp->Cpal, SLOT(setSpecialGradient(double, double, double, double, double, double)));
5676
 
        connect(this, SIGNAL(rotation(double)), pp, SLOT(setR(double)));
5677
 
//      connect(this, SIGNAL(transparency(double, double)), pp->Cpal, SLOT(setActTrans(double, double)));
5678
 
//      connect(this, SIGNAL(blendmode(int, int)), pp->Cpal, SLOT(setActBlend(int, int)));
5679
 
        //Shape signals
5680
 
        //Not connected when transferring code: void columns(int, double); //Number, gap
5681
 
        connect(this, SIGNAL(cornerRadius(double)), pp, SLOT(setRR(double)));
5682
 
        //      connect(view, SIGNAL(ItemTextCols(int, double)), propertiesPalette, SLOT(setCols(int, double)));
5683
 
        //Line signals
5684
 
        connect(this, SIGNAL(lineWidth(double)), pp, SLOT(setLineWidth(double)));
5685
 
        connect(this, SIGNAL(imageOffsetScale(double, double, double, double)), pp, SLOT(setScaleAndOffset(double, double, double, double)));
5686
 
        connect(this, SIGNAL(lineStyleCapJoin(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle)), pp, SLOT( setLIvalue(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle)));
5687
 
        //Frame text signals
5688
 
        connect(this, SIGNAL(lineSpacing(double)), pp, SLOT(setLsp(double)));
5689
 
        connect(this, SIGNAL(textToFrameDistances(double, double, double, double)), pp, SLOT(setTextToFrameDistances(double, double, double, double)));
5690
 
        connect(this, SIGNAL(textKerning(double)), pp, SLOT(setExtra(double)));
5691
 
        connect(this, SIGNAL(textStyle(int)), pp, SLOT(setStil(int)));
5692
 
        connect(this, SIGNAL(textStyle(int)), m_Doc->scMW(), SLOT(setStilvalue(int)));
5693
 
        connect(this, SIGNAL(textFont(const QString&)), pp, SLOT(setFontFace(const QString&)));
5694
 
        connect(this, SIGNAL(textSize(double)), pp, SLOT(setSize(double)));
5695
 
        connect(this, SIGNAL(textWidthScale(double)), pp, SLOT(setTScale(double)));
5696
 
        connect(this, SIGNAL(textHeightScale(double)), pp, SLOT(setTScaleV(double)));
5697
 
        connect(this, SIGNAL(textBaseLineOffset(double)), pp, SLOT(setTBase(double)));
5698
 
        connect(this, SIGNAL(textOutline(double)), pp, SLOT(setOutlineW(double)));
5699
 
        connect(this, SIGNAL(textShadow(double, double )), pp, SLOT(setShadowOffs(double, double )));
5700
 
        connect(this, SIGNAL(textUnderline(double, double)), pp, SLOT(setUnderline(double, double)));
5701
 
        connect(this, SIGNAL(textStrike(double, double)), pp, SLOT(setStrike(double, double)));
5702
 
        connect(this, SIGNAL(textColor(QString, QString, double, double)), pp, SLOT(setActFarben(QString, QString, double, double)));
5703
 
//      connect(this, SIGNAL(textFormatting(int)), pp, SLOT(setAli(int)));
5704
 
//      connect(this, SIGNAL(textFormatting(int)), ScMW, SLOT(setAbsValue(int)));
5705
 
 
5706
 
        return true;
5707
 
}
5708
 
 
5709
 
bool PageItem::disconnectFromGUI()
5710
 
{
5711
 
        if (!ScCore->usingGUI())
5712
 
                return false;
5713
 
        // Disconnecting only signals from PP will leave some remaining connections
5714
 
        // and cause progressive slowdowns
5715
 
        // PropertiesPalette* pp=m_Doc->scMW()->propertiesPalette;
5716
 
        // disconnect(this, 0, pp, 0);
5717
 
        disconnect(this, 0, 0, 0);
5718
 
        return true;
5719
 
}
5720
 
 
5721
 
void PageItem::emitAllToGUI()
5722
 
{
5723
 
        updateConstants();
5724
 
 
5725
 
        emit myself(this);
5726
 
        emit frameType(m_ItemType);
5727
 
/*CB using the emit myself* instead of all of these
5728
 
        emit position(Xpos, Ypos);
5729
 
        emit widthAndHeight(Width, Height);
5730
 
        emit rotation(Rot);
5731
 
        emit frameLocked(m_Locked);
5732
 
        emit frameSizeLocked(m_SizeLocked);
5733
 
        emit frameFlippedH(m_ImageIsFlippedH);
5734
 
        emit frameFlippedV(m_ImageIsFlippedV);
5735
 
        emit printEnabled(m_PrintEnabled);
5736
 
        emit lineWidth(m_lineWidth);
5737
 
        emit lineStyleCapJoin(PLineArt, PLineEnd, PLineJoin);
5738
 
        emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
5739
 
*/
5740
 
//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
5741
 
//      emit gradientType(GrType);
5742
 
//      double dur=m_Doc->unitRatio();
5743
 
//      emit gradientColorUpdate(GrStartX*dur, GrStartY*dur, GrEndX*dur, GrEndY*dur, Width*dur, Height*dur);
5744
 
//      emit transparency(fillTransparencyVal, lineTransparencyVal);
5745
 
//      emit blendmode(fillBlendmodeVal, lineBlendmodeVal);
5746
 
/*CB using the emit myself* instead of all of these
5747
 
        emit patternFill(patternVal, patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
5748
 
        emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
5749
 
        emit columns(Cols, ColGap);
5750
 
*/
5751
 
        if (m_Doc->appMode == modeEdit)
5752
 
        {
5753
 
/* maybe already done elsewhere? -- av
5754
 
                emit lineSpacing(currentStyle().lineSpacing());
5755
 
                emit textKerning(currentCharStyle().tracking());
5756
 
                emit textStyle(currentCharStyle().effects());
5757
 
                emit textFont(currentCharStyle().font()->scName());
5758
 
                emit textSize(currentCharStyle().fontSize());
5759
 
*/
5760
 
                //              emit textFormatting(currentStyle().alignment());
5761
 
        }
5762
 
        else
5763
 
        {
5764
 
//TODO remove and use the emit myself
5765
 
                emit lineSpacing(itemText.defaultStyle().lineSpacing());
5766
 
                emit textKerning(itemText.defaultStyle().charStyle().tracking());
5767
 
                emit textStyle(itemText.defaultStyle().charStyle().effects());
5768
 
                emit textFont(itemText.defaultStyle().charStyle().font().scName());
5769
 
                emit textSize(itemText.defaultStyle().charStyle().fontSize());
5770
 
//              emit textFormatting(itemText.defaultStyle().alignment());
5771
 
        }
5772
 
}
5773
 
 
5774
 
void PageItem::setIsAnnotation(bool isAnnot)
5775
 
{
5776
 
        m_isAnnotation=isAnnot;
5777
 
}
5778
 
 
5779
 
void PageItem::setAnnotation(const Annotation& ad)
5780
 
{
5781
 
        m_annotation=ad;
5782
 
}
5783
 
 
5784
 
void PageItem::setImageShown(bool isShown)
5785
 
{
5786
 
        PicArt=isShown;
5787
 
}
5788
 
 
5789
 
void PageItem::updateConstants()
5790
 
{
5791
 
        if (OwnPage!=-1)
5792
 
        {
5793
 
                m_Doc->constants().insert("pagewidth", m_Doc->Pages->at(OwnPage)->width());
5794
 
                m_Doc->constants().insert("pageheight", m_Doc->Pages->at(OwnPage)->height());
5795
 
        }
5796
 
        m_Doc->constants().insert("width", Width);
5797
 
        m_Doc->constants().insert("height", Height);
5798
 
}
5799
 
 
5800
 
//CB Old ScribusView MoveItemI
5801
 
void PageItem::moveImageInFrame(double newX, double newY)
5802
 
{
5803
 
        if (m_ItemType!=PageItem::ImageFrame)
5804
 
                return;
5805
 
        if ((locked()) || (!ScaleType))
5806
 
                return;
5807
 
        double dX=0.0, dY=0.0;
5808
 
        if (imageFlippedH())
5809
 
                dX=-newX;
5810
 
        else
5811
 
                dX=newX;
5812
 
        if (imageFlippedV())
5813
 
                dY=-newY;
5814
 
        else
5815
 
                dY=newY;
5816
 
        moveImageXYOffsetBy(dX, dY);
5817
 
        if (imageClip.size() != 0)
5818
 
        {
5819
 
                imageClip = pixm.imgInfo.PDSpathData[pixm.imgInfo.usedPath].copy();
5820
 
                QMatrix cl;
5821
 
                cl.translate(imageXOffset()*imageXScale(), imageYOffset()*imageYScale());
5822
 
                cl.scale(imageXScale(), imageYScale());
5823
 
                imageClip.map(cl);
5824
 
        }
5825
 
}
5826
 
 
5827
 
 
5828
 
 
5829
 
void PageItem::convertClip()
5830
 
{
5831
 
        if (Clip.count() != 0)
5832
 
        {
5833
 
                FPoint np(Clip.point(0));
5834
 
                PoLine.resize(2);
5835
 
                PoLine.setPoint(0, np);
5836
 
                PoLine.setPoint(1, np);
5837
 
                for (int a = 1; a < Clip.size(); ++a)
5838
 
                {
5839
 
                        np = FPoint(Clip.point(a));
5840
 
                        PoLine.putPoints(PoLine.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y());
5841
 
                }
5842
 
                np = FPoint(Clip.point(0));
5843
 
                PoLine.putPoints(PoLine.size(), 2, np.x(), np.y(), np.x(), np.y());
5844
 
                Clip = FlattenPath(PoLine, Segments);
5845
 
        }
5846
 
        else
5847
 
        {
5848
 
                SetRectFrame();
5849
 
                m_Doc->setRedrawBounding(this);
5850
 
        }
5851
 
}
5852
 
 
5853
 
void PageItem::updateClip()
5854
 
{
5855
 
        if (m_Doc->appMode == modeDrawBezierLine)
5856
 
                return;
5857
 
        if (ContourLine.size() == 0)
5858
 
                ContourLine = PoLine.copy();
5859
 
        int ph = static_cast<int>(qMax(1.0, lineWidth() / 2.0));
5860
 
        bool clipBackup = ClipEdited;
5861
 
        switch (itemType())
5862
 
        {
5863
 
        case PageItem::Line:
5864
 
                Clip.setPoints(4, -ph,-ph, static_cast<int>(width()+ph),-ph,
5865
 
                                  static_cast<int>(width()+ph),static_cast<int>(height()+ph),
5866
 
                                  -ph,static_cast<int>(height()+ph));
5867
 
                break;
5868
 
        default:
5869
 
                if (((!ClipEdited) || (FrameType < 3)) && !(asPathText()))
5870
 
                {
5871
 
                        switch (FrameType)
5872
 
                        {
5873
 
                        case 0:
5874
 
                                SetRectFrame();
5875
 
                                m_Doc->setRedrawBounding(this);
5876
 
                                break;
5877
 
                        case 1:
5878
 
                                SetOvalFrame();
5879
 
                                m_Doc->setRedrawBounding(this);
5880
 
                                break;
5881
 
                        case 2:
5882
 
                                //CB FIXME: stop using nodeEdit.clre or move out of here
5883
 
                                m_Doc->nodeEdit.deselect();
5884
 
                                SetFrameRound();
5885
 
                                m_Doc->setRedrawBounding(this);
5886
 
                                break;
5887
 
                        default:
5888
 
                                break;
5889
 
                        }
5890
 
                        ClipEdited = clipBackup;
5891
 
                        if ((OldB2 != 0) && (OldH2 != 0) && (width() != 0) && (height() != 0))
5892
 
                        {
5893
 
                                double scx = width() / OldB2;
5894
 
                                double scy = height() / OldH2;
5895
 
                                QMatrix ma;
5896
 
                                ma.scale(scx, scy);
5897
 
                                FPointArray gr;
5898
 
                                gr.addPoint(GrStartX, GrStartY);
5899
 
                                gr.addPoint(GrEndX, GrEndY);
5900
 
                                gr.map(ma);
5901
 
                                GrStartX = gr.point(0).x();
5902
 
                                GrStartY = gr.point(0).y();
5903
 
                                GrEndX = gr.point(1).x();
5904
 
                                GrEndY = gr.point(1).y();
5905
 
                                ContourLine.map(ma);
5906
 
                                if (FrameType > 2)
5907
 
                                {
5908
 
                                        PoLine.map(ma);
5909
 
                                        if (asPathText())
5910
 
                                                updatePolyClip();
5911
 
                                        else
5912
 
                                                Clip = FlattenPath(PoLine, Segments);
5913
 
                                }
5914
 
                        }
5915
 
                        OldB2 = width();
5916
 
                        OldH2 = height();
5917
 
                        if ((FrameType < 3) && (!ClipEdited))
5918
 
                                ContourLine = PoLine.copy();
5919
 
                }
5920
 
                else
5921
 
                {
5922
 
                        if (m_Doc->SubMode != -1)
5923
 
                        {
5924
 
                                switch (m_Doc->SubMode)
5925
 
                                {
5926
 
                                case 0:
5927
 
                                        SetRectFrame();
5928
 
                                        m_Doc->setRedrawBounding(this);
5929
 
                                        break;
5930
 
                                case 1:
5931
 
                                        SetOvalFrame();
5932
 
                                        m_Doc->setRedrawBounding(this);
5933
 
                                        break;
5934
 
                                default:
5935
 
                                        SetFrameShape(m_Doc->ValCount, m_Doc->ShapeValues);
5936
 
                                        m_Doc->setRedrawBounding(this);
5937
 
                                        break;
5938
 
                                }
5939
 
                                OldB2 = width();
5940
 
                                OldH2 = height();
5941
 
                                ContourLine = PoLine.copy();
5942
 
                        }
5943
 
                        if ((OldB2 == 0) || (OldH2 == 0) || (width() == 0) || (height() == 0))
5944
 
                                return;
5945
 
                        double scx = width() / OldB2;
5946
 
                        double scy = height() / OldH2;
5947
 
                        QMatrix ma;
5948
 
                        ma.scale(scx, scy);
5949
 
                        FPointArray gr;
5950
 
                        gr.addPoint(GrStartX, GrStartY);
5951
 
                        gr.addPoint(GrEndX, GrEndY);
5952
 
                        gr.map(ma);
5953
 
                        GrStartX = gr.point(0).x();
5954
 
                        GrStartY = gr.point(0).y();
5955
 
                        GrEndX = gr.point(1).x();
5956
 
                        GrEndY = gr.point(1).y();
5957
 
                        PoLine.map(ma);
5958
 
                        ContourLine.map(ma);
5959
 
                        if (asPathText())
5960
 
                                updatePolyClip();
5961
 
                        else
5962
 
                                Clip = FlattenPath(PoLine, Segments);
5963
 
                        OldB2 = width();
5964
 
                        OldH2 = height();
5965
 
                }
5966
 
                break;
5967
 
        }
5968
 
        updateGradientVectors();
5969
 
}
5970
 
 
5971
 
QString PageItem::infoDescription()
5972
 
{
5973
 
        QString htmlText;
5974
 
        htmlText.append(ScribusView::tr("Print: "));
5975
 
        if (printEnabled())
5976
 
                htmlText.append(ScribusView::tr("Enabled"));
5977
 
        else
5978
 
                htmlText.append(ScribusView::tr("Disabled"));
5979
 
        htmlText.append("<br/>");
5980
 
        return htmlText;
5981
 
}
5982
 
 
5983
 
FirstLineOffsetPolicy PageItem::firstLineOffset() const
5984
 
{
5985
 
        return firstLineOffsetP;
5986
 
}
5987
 
 
5988
 
void PageItem::setFirstLineOffset(FirstLineOffsetPolicy flop)
5989
 
{
5990
 
        if(firstLineOffsetP != flop)
5991
 
        {
5992
 
                firstLineOffsetP = flop;
5993
 
        }
5994
 
}
5995
 
 
5996
 
 
5997
 
 
5998
 
 
5999