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

« back to all changes in this revision

Viewing changes to .pc/0001-qreal-double-fixes.patch/scribus/scpageoutput.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
 
#include "scpageoutput.h"
8
 
 
9
 
#include <QList>
10
 
#include <QPointF>
11
 
#include <QRectF>
12
 
#include <QStack>
13
 
 
14
 
#include "cmsettings.h"
15
 
#include "commonstrings.h"
16
 
#include "page.h"
17
 
#include "pageitem.h"
18
 
#include "pageitem_imageframe.h"
19
 
#include "pageitem_line.h"
20
 
#include "pageitem_pathtext.h"
21
 
#include "pageitem_polygon.h"
22
 
#include "pageitem_polyline.h"
23
 
#include "pageitem_textframe.h"
24
 
#include "prefsmanager.h"
25
 
#include "scfonts.h"
26
 
#include "scimage.h"
27
 
#include "scpattern.h"
28
 
#include "scribus.h"
29
 
#include "scribusdoc.h"
30
 
#include "util.h"
31
 
#include "util_formats.h"
32
 
#include "util_math.h"
33
 
 
34
 
 
35
 
MarksOptions::MarksOptions(void)
36
 
{
37
 
        markOffset = 0.0;
38
 
        BleedTop = 0.0;
39
 
        BleedLeft = 0.0;
40
 
        BleedRight = 0.0;
41
 
        BleedBottom = 0.0;
42
 
        cropMarks = false;
43
 
        bleedMarks = false;
44
 
        registrationMarks = false;
45
 
        colorMarks = false;
46
 
        docInfoMarks = false;
47
 
}
48
 
 
49
 
MarksOptions::MarksOptions(struct PrintOptions& opt)
50
 
{
51
 
        markOffset = opt.markOffset;
52
 
        BleedTop = opt.bleeds.Top;
53
 
        BleedLeft = opt.bleeds.Left;
54
 
        BleedRight = opt.bleeds.Right;
55
 
        BleedBottom = opt.bleeds.Bottom;
56
 
        cropMarks = opt.cropMarks;
57
 
        bleedMarks = opt.bleedMarks;
58
 
        registrationMarks = opt.registrationMarks;
59
 
        colorMarks = opt.colorMarks;
60
 
        docInfoMarks = true;
61
 
}
62
 
 
63
 
ScPageOutput::ScPageOutput(ScribusDoc* doc, bool reloadImages, int resolution, bool useProfiles) 
64
 
                        : m_marksOptions()
65
 
{
66
 
        m_doc = doc;
67
 
        m_reloadImages = reloadImages;
68
 
        m_imageRes = resolution;
69
 
        m_useProfiles = useProfiles;
70
 
}
71
 
 
72
 
ScImage::RequestType ScPageOutput::translateImageModeToRequest( ScPainterExBase::ImageMode mode )
73
 
{
74
 
        ScImage::RequestType value = ScImage::RGBData;
75
 
        if ( mode == ScPainterExBase::cmykImages )
76
 
                value = ScImage::CMYKData;
77
 
        else if ( mode == ScPainterExBase::rgbImages )
78
 
                value = ScImage::RGBData;
79
 
        else if ( mode == ScPainterExBase::rgbProofImages )
80
 
                value = ScImage::RGBProof;
81
 
        else if ( mode == ScPainterExBase::rawImages )
82
 
                value = ScImage::RawData;
83
 
        return value;
84
 
}
85
 
 
86
 
void ScPageOutput::drawPage( Page* page, ScPainterExBase* painter)
87
 
{
88
 
        int clipx = static_cast<int>(page->xOffset());
89
 
        int clipy = static_cast<int>(page->yOffset());
90
 
        int clipw = qRound(page->width());
91
 
        int cliph = qRound(page->height());
92
 
        drawMasterItems(painter, page, QRect(clipx, clipy, clipw, cliph));
93
 
        drawPageItems(painter, page, QRect(clipx, clipy, clipw, cliph));
94
 
        drawMarks(page, painter, m_marksOptions);
95
 
}
96
 
 
97
 
void ScPageOutput::drawMasterItems(ScPainterExBase *painter, Page *page, const QRect& clip)
98
 
{
99
 
        QStack<PageItem*> groupStack;
100
 
        QStack<PageItem*> groupClips;
101
 
        if (!page->MPageNam.isEmpty())
102
 
        {
103
 
                Page* Mp = m_doc->MasterPages.at(m_doc->MasterNames[page->MPageNam]);
104
 
                if (page->FromMaster.count() != 0)
105
 
                {
106
 
                        int Lnr;
107
 
                        ScLayer ll;
108
 
                        PageItem *currItem;
109
 
                        ll.isViewable = false;
110
 
                        ll.LNr = 0;
111
 
                        Lnr = 0;
112
 
                        uint layerCount = m_doc->layerCount();
113
 
                        for (uint la = 0; la < layerCount; ++la)
114
 
                        {
115
 
                                m_doc->Layers.levelToLayer(ll, Lnr);
116
 
                                bool pr = true;
117
 
                                if ( !ll.isPrintable )
118
 
                                        pr = false;
119
 
                                if ((ll.isViewable) && (pr))
120
 
                                {
121
 
                                        uint pageFromMasterCount=page->FromMaster.count();
122
 
                                        for (uint a = 0; a < pageFromMasterCount; ++a)
123
 
                                        {
124
 
                                                currItem = page->FromMaster.at(a);
125
 
                                                if (currItem->LayerNr != ll.LNr)
126
 
                                                        continue;
127
 
                                                if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->pageNr())))
128
 
                                                        continue;
129
 
                                                if (!currItem->printEnabled())
130
 
                                                        continue;
131
 
                                                if (currItem->isGroupControl)
132
 
                                                {
133
 
                                                        painter->save();
134
 
                                                        groupClips.push(currItem);
135
 
                                                        groupStack.push(currItem->groupsLastItem);
136
 
                                                        continue;
137
 
                                                }
138
 
                                                int savedOwnPage = currItem->OwnPage;
139
 
                                                double OldX = currItem->xPos();
140
 
                                                double OldY = currItem->yPos();
141
 
                                                double OldBX = currItem->BoundingX;
142
 
                                                double OldBY = currItem->BoundingY;
143
 
                                                currItem->OwnPage = page->pageNr();
144
 
                                                if (!currItem->ChangedMasterItem)
145
 
                                                {
146
 
                                                        currItem->moveBy(-Mp->xOffset() + page->xOffset(), -Mp->yOffset() + page->yOffset(), true);
147
 
                                                        currItem->BoundingX = OldBX - Mp->xOffset() + page->xOffset();
148
 
                                                        currItem->BoundingY = OldBY - Mp->yOffset() + page->yOffset();
149
 
                                                }
150
 
                                                /*if (evSpon)
151
 
                                                        currItem->Dirty = true;*/
152
 
                                                QRect oldR(currItem->getRedrawBounding(1.0));
153
 
                                                if (clip.intersects(oldR))
154
 
                                                {
155
 
                                                        // relayout necessary to get page number ok
156
 
                                                        currItem->invalidateLayout();
157
 
                                                        currItem->layout();
158
 
                                                        drawItem(currItem, painter, clip);
159
 
                                                }
160
 
                                                currItem->OwnPage = savedOwnPage;
161
 
                                                if (!currItem->ChangedMasterItem)
162
 
                                                {
163
 
                                                        currItem->setXYPos(OldX, OldY, true);
164
 
                                                        currItem->BoundingX = OldBX;
165
 
                                                        currItem->BoundingY = OldBY;
166
 
                                                }
167
 
                                                if (groupStack.count() != 0)
168
 
                                                {
169
 
                                                        while (currItem == groupStack.top())
170
 
                                                        {
171
 
                                                                QMatrix mm;
172
 
                                                                PageItem *tmpItem = groupClips.pop();
173
 
                                                                FPointArray cl = tmpItem->PoLine.copy();
174
 
                                                                mm.translate(tmpItem->xPos(), tmpItem->yPos());
175
 
                                                                mm.rotate(tmpItem->rotation());
176
 
                                                                cl.map( mm );
177
 
                                                                painter->setupPolygon(&cl);
178
 
                                                                painter->setClipPath();
179
 
                                                                painter->restore();
180
 
                                                                groupStack.pop();
181
 
                                                                if (groupStack.count() == 0)
182
 
                                                                        break;
183
 
                                                        }
184
 
                                                }
185
 
                                        }
186
 
                                        for (uint a = 0; a < pageFromMasterCount; ++a)
187
 
                                        {
188
 
                                                currItem = page->FromMaster.at(a);
189
 
                                                if (currItem->LayerNr != ll.LNr)
190
 
                                                        continue;
191
 
                                                if (!currItem->isTableItem)
192
 
                                                        continue;
193
 
                                                if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->pageNr())))
194
 
                                                        continue;
195
 
                                                double OldX = currItem->xPos();
196
 
                                                double OldY = currItem->yPos();
197
 
                                                double OldBX = currItem->BoundingX;
198
 
                                                double OldBY = currItem->BoundingY;
199
 
                                                if (!currItem->ChangedMasterItem)
200
 
                                                {
201
 
                                                        currItem->setXPos(OldX - Mp->xOffset() + page->xOffset(), true);
202
 
                                                        currItem->setYPos(OldY - Mp->yOffset() + page->yOffset(), true);
203
 
                                                        currItem->BoundingX = OldBX - Mp->xOffset() + page->xOffset();
204
 
                                                        currItem->BoundingY = OldBY - Mp->yOffset() + page->yOffset();
205
 
                                                }
206
 
                                                QRect oldR(currItem->getRedrawBounding(1.0));
207
 
                                                if (clip.intersects(oldR))
208
 
                                                {
209
 
                                                        painter->save();
210
 
                                                        painter->translate(currItem->xPos(), currItem->yPos());
211
 
                                                        painter->rotate(currItem->rotation());
212
 
                                                        if (currItem->lineColor() != CommonStrings::None)
213
 
                                                        {
214
 
                                                                ScColorShade tmp( m_doc->PageColors[currItem->lineColor()], (int) currItem->lineShade());
215
 
                                                                if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine))
216
 
                                                                {
217
 
                                                                        painter->setPen(tmp, currItem->lineWidth(), currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin);
218
 
                                                                        if (currItem->TopLine)
219
 
                                                                                painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->width(), 0.0));
220
 
                                                                        if (currItem->RightLine)
221
 
                                                                                painter->drawLine(FPoint(currItem->width(), 0.0), FPoint(currItem->width(), currItem->height()));
222
 
                                                                        if (currItem->BottomLine)
223
 
                                                                                painter->drawLine(FPoint(currItem->width(), currItem->height()), FPoint(0.0, currItem->height()));
224
 
                                                                        if (currItem->LeftLine)
225
 
                                                                                painter->drawLine(FPoint(0.0, currItem->height()), FPoint(0.0, 0.0));
226
 
                                                                }
227
 
                                                        }
228
 
                                                        painter->restore();
229
 
                                                }
230
 
                                                if (!currItem->ChangedMasterItem)
231
 
                                                {
232
 
                                                        currItem->setXPos(OldX, true);
233
 
                                                        currItem->setYPos(OldY, true);
234
 
                                                        currItem->BoundingX = OldBX;
235
 
                                                        currItem->BoundingY = OldBY;
236
 
                                                }
237
 
                                        }
238
 
                                }
239
 
                                Lnr++;
240
 
                        }
241
 
                }
242
 
        }
243
 
}
244
 
 
245
 
void ScPageOutput::drawPageItems(ScPainterExBase *painter, Page *page, const QRect& clip)
246
 
{
247
 
        //linkedFramesToShow.clear();
248
 
        QStack<PageItem*> groupStack;
249
 
        QStack<PageItem*> groupClips;
250
 
        if (m_doc->Items->count() != 0)
251
 
        {
252
 
                int Lnr=0;
253
 
                ScLayer ll;
254
 
                PageItem *currItem;
255
 
                ll.isViewable = false;
256
 
                ll.LNr = 0;
257
 
                uint layerCount = m_doc->layerCount();
258
 
                //int docCurrPageNo=static_cast<int>(m_doc->currentPageNumber());
259
 
                int docCurrPageNo=static_cast<int>(page->pageNr());
260
 
                for (uint la2 = 0; la2 < layerCount; ++la2)
261
 
                {
262
 
                        m_doc->Layers.levelToLayer(ll, Lnr);
263
 
                        bool pr = true;
264
 
                        if (!ll.isPrintable)
265
 
                                pr = false;
266
 
                        if ((ll.isViewable) && (pr))
267
 
                        {
268
 
                                for (int it = 0; it < m_doc->Items->count(); ++it)
269
 
                                {
270
 
                                        currItem = m_doc->Items->at(it);
271
 
                                        if (currItem->LayerNr != ll.LNr)
272
 
                                                continue;
273
 
                                        if (!currItem->printEnabled())
274
 
                                                continue;
275
 
                                        if ((m_doc->masterPageMode()) && ((currItem->OwnPage != -1) && (currItem->OwnPage != docCurrPageNo)))
276
 
                                                continue;
277
 
                                        if (!m_doc->masterPageMode() && !currItem->OnMasterPage.isEmpty())
278
 
                                        {
279
 
                                                if (currItem->OnMasterPage != page->pageName())
280
 
                                                        continue;
281
 
                                        }
282
 
                                        if (currItem->isGroupControl)
283
 
                                        {
284
 
                                                painter->save();
285
 
                                                groupClips.push(currItem);
286
 
                                                groupStack.push(currItem->groupsLastItem);
287
 
                                                continue;
288
 
                                        }
289
 
                                        QRect oldR(currItem->getRedrawBounding(1.0));
290
 
                                        if (clip.intersects(oldR))
291
 
                                        {
292
 
                                                drawItem( currItem, painter, clip );
293
 
                                                if ((currItem->asTextFrame()) && ((currItem->nextInChain() != 0) || (currItem->prevInChain() != 0)))
294
 
                                                {
295
 
                                                        PageItem *nextItem = currItem;
296
 
                                                        while (nextItem != 0)
297
 
                                                        {
298
 
                                                                if (nextItem->prevInChain() != 0)
299
 
                                                                        nextItem = nextItem->prevInChain();
300
 
                                                                else
301
 
                                                                        break;
302
 
                                                        }
303
 
                                                }
304
 
                                        }
305
 
                                        if (groupStack.count() != 0)
306
 
                                        {
307
 
                                                while (currItem == groupStack.top())
308
 
                                                {
309
 
                                                        QMatrix mm;
310
 
                                                        PageItem *tmpItem = groupClips.pop();
311
 
                                                        FPointArray cl = tmpItem->PoLine.copy();
312
 
                                                        mm.translate(tmpItem->xPos(), tmpItem->yPos());
313
 
                                                        mm.rotate(tmpItem->rotation());
314
 
                                                        cl.map( mm );
315
 
                                                        painter->setupPolygon(&cl);
316
 
                                                        painter->setClipPath();
317
 
                                                        painter->restore();
318
 
                                                        groupStack.pop();
319
 
                                                        if (groupStack.count() == 0)
320
 
                                                                break;
321
 
                                                }
322
 
                                        }
323
 
                                }
324
 
                                for (int it = 0; it < m_doc->Items->count(); ++it)
325
 
                                {
326
 
                                        currItem = m_doc->Items->at(it);
327
 
                                        if (currItem->LayerNr != ll.LNr)
328
 
                                                continue;
329
 
                                        if (!currItem->isTableItem)
330
 
                                                continue;
331
 
                                        QRect oldR(currItem->getRedrawBounding(1.0));
332
 
                                        if (clip.intersects(oldR))
333
 
                                        {
334
 
                                                painter->save();
335
 
                                                painter->translate(currItem->xPos(), currItem->yPos());
336
 
                                                painter->rotate(currItem->rotation());
337
 
                                                if (currItem->lineColor() != CommonStrings::None)
338
 
                                                {
339
 
                                                        ScColorShade tmp( m_doc->PageColors[currItem->lineColor()], (int) currItem->lineShade() );
340
 
                                                        if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine))
341
 
                                                        {
342
 
                                                                painter->setPen(tmp, currItem->lineWidth(), currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin);
343
 
                                                                if (currItem->TopLine)
344
 
                                                                        painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->width(), 0.0));
345
 
                                                                if (currItem->RightLine)
346
 
                                                                        painter->drawLine(FPoint(currItem->width(), 0.0), FPoint(currItem->width(), currItem->height()));
347
 
                                                                if (currItem->BottomLine)
348
 
                                                                        painter->drawLine(FPoint(currItem->width(), currItem->height()), FPoint(0.0, currItem->height()));
349
 
                                                                if (currItem->LeftLine)
350
 
                                                                        painter->drawLine(FPoint(0.0, currItem->height()), FPoint(0.0, 0.0));
351
 
                                                        }
352
 
                                                }
353
 
                                                painter->restore();
354
 
                                        }
355
 
                                }
356
 
                        }
357
 
                        Lnr++;
358
 
                }
359
 
        }
360
 
}
361
 
 
362
 
void ScPageOutput::drawItem( PageItem* item, ScPainterExBase* painter, const QRect& clip )
363
 
{
364
 
        drawItem_Pre(item, painter);
365
 
        PageItem::ItemType itemType = item->itemType();
366
 
        if( itemType == PageItem::ImageFrame )
367
 
                drawItem_ImageFrame( (PageItem_ImageFrame*) item, painter, clip);
368
 
        else if( itemType == PageItem::Line )
369
 
                drawItem_Line( (PageItem_Line*) item, painter, clip);
370
 
        else if( itemType == PageItem::PathText )
371
 
                drawItem_PathText(  (PageItem_PathText*) item, painter, clip);
372
 
        else if( itemType == PageItem::Polygon )
373
 
                drawItem_Polygon( (PageItem_Polygon*) item, painter, clip);
374
 
        else if( itemType == PageItem::PolyLine )
375
 
                drawItem_PolyLine( (PageItem_PolyLine*) item, painter, clip);
376
 
        else if( itemType == PageItem::TextFrame )
377
 
                drawItem_TextFrame( (PageItem_TextFrame*) item, painter, clip);
378
 
        drawItem_Post(item, painter);
379
 
}
380
 
 
381
 
void ScPageOutput::drawItem_Pre( PageItem* item, ScPainterExBase* painter)
382
 
{
383
 
        painter->save();
384
 
        if (!item->isEmbedded)
385
 
        {
386
 
                painter->translate( item->xPos(), item->yPos());
387
 
//              painter->rotate(item->rotation());
388
 
        }
389
 
        painter->rotate(item->rotation());
390
 
        painter->setLineWidth(item->lineWidth());
391
 
        if (item->GrType == 8)
392
 
        {
393
 
                QString pat = item->pattern();
394
 
                if ((pat.isEmpty()) || (!m_doc->docPatterns.contains(pat)))
395
 
                {
396
 
                        painter->m_fillGradient = VGradientEx(VGradientEx::linear);
397
 
                        if (item->fillColor() != CommonStrings::None)
398
 
                        {
399
 
                                painter->setBrush(ScColorShade(m_doc->PageColors[item->fillColor()], (int) item->fillShade()));
400
 
                                painter->setFillMode(ScPainterExBase::Solid);
401
 
                        }
402
 
                        else
403
 
                                painter->setFillMode(ScPainterExBase::None);
404
 
                }
405
 
                else
406
 
                {
407
 
                        QMatrix patternTransform;
408
 
                        ScPattern& pattern = m_doc->docPatterns[item->pattern()];
409
 
                        double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation;
410
 
                        item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
411
 
                        patternTransform.translate(patternOffsetX, patternOffsetY);
412
 
                        patternTransform.rotate(patternRotation);
413
 
                        patternTransform.scale(pattern.scaleX, pattern.scaleY);
414
 
                        patternTransform.scale(patternScaleX / 100.0 , patternScaleY / 100.0);
415
 
                        painter->setPattern(&pattern, patternTransform);
416
 
                        painter->setFillMode(ScPainterExBase::Pattern);
417
 
                }
418
 
        }
419
 
        else if (item->GrType != 0)
420
 
        {
421
 
                painter->setFillMode(ScPainterExBase::Gradient);
422
 
                painter->m_fillGradient = VGradientEx(item->fill_gradient, *m_doc);
423
 
                QMatrix grm;
424
 
                grm.rotate(item->rotation());
425
 
                FPointArray gra;
426
 
                switch (item->GrType)
427
 
                {
428
 
                        case 1:
429
 
                        case 2:
430
 
                        case 3:
431
 
                        case 4:
432
 
                        case 6:
433
 
                                gra.setPoints(2, item->GrStartX, item->GrStartY, item->GrEndX, item->GrEndY);
434
 
                                gra.map(grm);
435
 
                                painter->setGradient(VGradientEx::linear, gra.point(0), gra.point(1));
436
 
                                break;
437
 
                        case 5:
438
 
                        case 7:
439
 
                                gra.setPoints(2, item->GrStartX, item->GrStartY, item->GrEndX, item->GrEndY);
440
 
                                painter->setGradient(VGradientEx::radial, gra.point(0), gra.point(1), gra.point(0));
441
 
                                break;
442
 
                }
443
 
        }
444
 
        else
445
 
        {
446
 
                painter->m_fillGradient = VGradientEx(VGradientEx::linear);
447
 
                if (item->fillColor() != CommonStrings::None)
448
 
                {
449
 
                        painter->setBrush( ScColorShade(m_doc->PageColors[item->fillColor()], (int) item->fillShade()) );
450
 
                        painter->setFillMode(ScPainterExBase::Solid);
451
 
                }
452
 
                else
453
 
                        painter->setFillMode(ScPainterExBase::None);
454
 
        }
455
 
        if (item->lineColor() != CommonStrings::None)
456
 
        {
457
 
                if ((item->lineWidth() == 0) && !item->asLine())
458
 
                        painter->setLineWidth(0);
459
 
                else
460
 
                {
461
 
                        ScColorShade tmp(m_doc->PageColors[item->lineColor()], (int) item->lineShade());
462
 
                        painter->setPen( tmp , item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin);
463
 
                        if (item->DashValues.count() != 0)
464
 
                                painter->setDash(item->DashValues, item->DashOffset);
465
 
                }
466
 
        }
467
 
        else
468
 
                painter->setLineWidth(0);
469
 
        painter->setBrushOpacity(1.0 - item->fillTransparency());
470
 
        painter->setPenOpacity(1.0 - item->lineTransparency());
471
 
        painter->setFillRule(item->fillRule);
472
 
}
473
 
 
474
 
void ScPageOutput::drawItem_Post( PageItem* item, ScPainterExBase* painter )
475
 
{
476
 
        bool doStroke=true;
477
 
        if ( item->itemType() == PageItem::PathText || item->itemType() == PageItem::PolyLine || item->itemType() == PageItem::Line )
478
 
                doStroke=false;
479
 
        if ((doStroke))
480
 
        {
481
 
                if (item->lineColor() != CommonStrings::None)
482
 
                {
483
 
                        ScColorShade tmp(m_doc->PageColors[item->lineColor()], (int) item->lineShade());
484
 
                        painter->setPen(tmp, item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin);
485
 
                        if (item->DashValues.count() != 0)
486
 
                                painter->setDash(item->DashValues, item->DashOffset);
487
 
                }
488
 
                else
489
 
                        painter->setLineWidth(0);
490
 
                if (!item->isTableItem)
491
 
                {
492
 
                        painter->setupPolygon(&item->PoLine);
493
 
                        if (item->NamedLStyle.isEmpty())
494
 
                                painter->strokePath();
495
 
                        else
496
 
                        {
497
 
                                multiLine ml = m_doc->MLineStyles[item->NamedLStyle];
498
 
                                for (int it = ml.size()-1; it > -1; it--)
499
 
                                {
500
 
                                        const SingleLine& sl = ml[it];
501
 
                                        if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
502
 
                                        {
503
 
                                                ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade);
504
 
                                                painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash),
505
 
                                                                static_cast<Qt::PenCapStyle>(sl.LineEnd),
506
 
                                                                static_cast<Qt::PenJoinStyle>(sl.LineJoin));
507
 
                                                painter->strokePath();
508
 
                                        }
509
 
                                }
510
 
                        }
511
 
                }
512
 
        }
513
 
//      item->Tinput = false;
514
 
        painter->restore();
515
 
}
516
 
 
517
 
void ScPageOutput::drawGlyphs(PageItem* item, ScPainterExBase *painter, const CharStyle& style, GlyphLayout& glyphs, const QRect& clip)
518
 
{
519
 
        uint glyph = glyphs.glyph;
520
 
        if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode())) // NBSPACE
521
 
                glyph = style.font().char2CMap(QChar(' '));
522
 
        else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode())) // NBHYPHEN
523
 
                glyph = style.font().char2CMap(QChar('-'));
524
 
        
525
 
        if (glyph >= ScFace::CONTROL_GLYPHS)
526
 
        {
527
 
                if (glyphs.more)
528
 
                {
529
 
                        painter->translate(glyphs.xadvance, 0);
530
 
                        drawGlyphs(item, painter, style, *glyphs.more, clip);
531
 
                }
532
 
                return;
533
 
        }
534
 
        
535
 
        //if (style.font().canRender(QChar(glyph)))
536
 
        {
537
 
                QMatrix chma, chma2, chma3, chma4, chma5, chma6;
538
 
                chma.scale(glyphs.scaleH * style.fontSize() / 100.00, glyphs.scaleV * style.fontSize() / 100.0);
539
 
                FPointArray gly = style.font().glyphOutline(glyph);
540
 
                // Do underlining first so you can get typographically correct
541
 
                // underlines when drawing a white outline
542
 
                if ((style.effects() & ScStyle_Underline) || ((style.effects() & ScStyle_UnderlineWords) && (glyph != style.font().char2CMap(QChar(' ')))))
543
 
                {
544
 
                        double st, lw;
545
 
                        if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1))
546
 
                        {
547
 
                                if (style.underlineOffset() != -1)
548
 
                                        st = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0));
549
 
                                else
550
 
                                        st = style.font().underlinePos(style.fontSize() / 10.0);
551
 
                                if (style.underlineWidth() != -1)
552
 
                                        lw = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0);
553
 
                                else
554
 
                                        lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
555
 
                        }
556
 
                        else
557
 
                        {
558
 
                                st = style.font().underlinePos(style.fontSize() / 10.0);
559
 
                                lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
560
 
                        }
561
 
                        if (style.baselineOffset() != 0)
562
 
                                st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
563
 
                        ScColorShade tmpPen = painter->pen();
564
 
                        painter->setPen(painter->brush());
565
 
                        painter->setLineWidth(lw);
566
 
                        if (style.effects() & ScStyle_Subscript)
567
 
                                painter->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
568
 
                        else
569
 
                                painter->drawLine(FPoint(glyphs.xoffset, -st), FPoint(glyphs.xoffset + glyphs.xadvance, -st));
570
 
                        painter->setPen(tmpPen);
571
 
                }
572
 
                if (gly.size() > 3)
573
 
                {
574
 
                        painter->save();
575
 
                        painter->translate(glyphs.xoffset, glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV));
576
 
                        if (item->reversed())
577
 
                        {
578
 
                                painter->scale(-1, 1);
579
 
                                painter->translate(-glyphs.xadvance, 0);
580
 
                        }
581
 
                        if (style.baselineOffset() != 0)
582
 
                                painter->translate(0, -(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0));
583
 
                        double glxSc = glyphs.scaleH * style.fontSize() / 100.00;
584
 
                        double glySc = glyphs.scaleV * style.fontSize() / 100.0;
585
 
                        painter->scale(glxSc, glySc);
586
 
                        painter->setFillMode(ScPainterExBase::Solid);
587
 
                        bool fr = painter->fillRule();
588
 
                        painter->setFillRule(false);
589
 
                        painter->setupPolygon(&gly, true);
590
 
                        if (glyph == 0)
591
 
                        {
592
 
                                ScColorShade tmp(PrefsManager::instance()->appPrefs.DControlCharColor, 100);
593
 
                                painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
594
 
                                painter->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() * 2 / 10000.0);
595
 
                                painter->strokePath();
596
 
                        }
597
 
                        else if ((style.font().isStroked()) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
598
 
                        {
599
 
                                ScColorShade tmp = painter->brush();
600
 
                                painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
601
 
                                painter->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0);
602
 
                                painter->strokePath();
603
 
                        }
604
 
                        else
605
 
                        {
606
 
                                if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None))
607
 
                                {
608
 
                                        painter->save();
609
 
                                        painter->translate((style.fontSize() * glyphs.scaleH * style.shadowXOffset() / 10000.0) / glxSc, -(style.fontSize() * glyphs.scaleV * style.shadowYOffset() / 10000.0) / glySc);
610
 
                                        ScColorShade tmp = painter->brush();
611
 
                                        painter->setBrush(painter->pen());
612
 
                                        painter->setupPolygon(&gly, true);
613
 
                                        fillPath(item, painter, clip);
614
 
                                        painter->setBrush(tmp);
615
 
                                        painter->restore();
616
 
                                        painter->setupPolygon(&gly, true);
617
 
                                }
618
 
                                if (style.fillColor() != CommonStrings::None)
619
 
                                        fillPath(item, painter, clip);
620
 
                                if ((style.effects() & ScStyle_Outline) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
621
 
                                {
622
 
                                        painter->setLineWidth((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) / glySc);
623
 
                                        painter->strokePath();
624
 
                                }
625
 
                        }
626
 
                        painter->setFillRule(fr);
627
 
                        painter->restore();
628
 
                }
629
 
                if (style.effects() & ScStyle_Strikethrough)
630
 
                {
631
 
                        double st, lw;
632
 
                        if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1))
633
 
                        {
634
 
                                if (style.strikethruOffset() != -1)
635
 
                                        st = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0));
636
 
                                else
637
 
                                        st = style.font().strikeoutPos(style.fontSize() / 10.0);
638
 
                                if (style.strikethruWidth() != -1)
639
 
                                        lw = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0);
640
 
                                else
641
 
                                        lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
642
 
                        }
643
 
                        else
644
 
                        {
645
 
                                st = style.font().strikeoutPos(style.fontSize() / 10.0);
646
 
                                lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
647
 
                        }
648
 
                        if (style.baselineOffset() != 0)
649
 
                                st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
650
 
                        painter->setPen(painter->brush());
651
 
                        painter->setLineWidth(lw);
652
 
                        painter->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
653
 
                }
654
 
        }
655
 
        /*else
656
 
        {
657
 
                painter->setLineWidth(1);
658
 
                painter->setPen(ScColorShade(Qt::red, 100));
659
 
                painter->setBrush(ScColorShade(Qt::red, 100));
660
 
                painter->setFillMode(1);
661
 
                painter->drawRect(glyphs.xoffset, glyphs.yoffset - (style.fontSize() / 10.0) * glyphs.scaleV , (style.fontSize() / 10.0) * glyphs.scaleH, (style.fontSize() / 10.0) * glyphs.scaleV);
662
 
        }*/
663
 
        if (glyphs.more)
664
 
        {
665
 
                painter->translate(glyphs.xadvance, 0);
666
 
                drawGlyphs(item, painter, style, *glyphs.more, clip);
667
 
        }
668
 
}
669
 
 
670
 
void ScPageOutput::drawItem_Embedded( PageItem* item, ScPainterExBase *p, const QRect& clip, const CharStyle& style, PageItem* cembedded)
671
 
{
672
 
        if (!cembedded)
673
 
                return;
674
 
        QList<PageItem*> emG;
675
 
        QStack<PageItem*> groupStack;
676
 
        emG.append(cembedded);
677
 
        if (cembedded->Groups.count() != 0)
678
 
        {
679
 
                for (int ga=0; ga < m_doc->FrameItems.count(); ++ga)
680
 
                {
681
 
                        if (m_doc->FrameItems.at(ga)->Groups.count() != 0)
682
 
                        {
683
 
                                if (m_doc->FrameItems.at(ga)->Groups.top() == cembedded->Groups.top())
684
 
                                {
685
 
                                        if (m_doc->FrameItems.at(ga)->ItemNr != cembedded->ItemNr)
686
 
                                        {
687
 
                                                if (!emG.contains(m_doc->FrameItems.at(ga)))
688
 
                                                        emG.append(m_doc->FrameItems.at(ga));
689
 
                                        }
690
 
                                }
691
 
                        }
692
 
                }
693
 
        }
694
 
        for (int em = 0; em < emG.count(); ++em)
695
 
        {
696
 
                PageItem* embedded = emG.at(em);
697
 
                if (embedded->isGroupControl)
698
 
                {
699
 
                        p->save();
700
 
                        FPointArray cl = embedded->PoLine.copy();
701
 
                        QMatrix mm;
702
 
                        mm.translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
703
 
                        if (style.baselineOffset() != 0)
704
 
                                mm.translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
705
 
                        mm.scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
706
 
                        cl.map( mm );
707
 
                        groupStack.push(embedded->groupsLastItem);
708
 
                        continue;
709
 
                }
710
 
                p->save();
711
 
                double x = embedded->xPos();
712
 
                double y = embedded->yPos();
713
 
                embedded->setXPos( embedded->gXpos, true );
714
 
                embedded->setYPos((embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos, true );
715
 
                p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
716
 
                if (style.baselineOffset() != 0)
717
 
                {
718
 
                        p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
719
 
                        embedded->setYPos( embedded->yPos() - embedded->gHeight * (style.baselineOffset() / 1000.0) );
720
 
                }
721
 
                p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
722
 
                double pws = embedded->m_lineWidth;
723
 
                drawItem_Pre(embedded, p);
724
 
                switch(embedded->itemType())
725
 
                {
726
 
                        case PageItem::ImageFrame:
727
 
                        case PageItem::LatexFrame:
728
 
                        case PageItem::TextFrame:
729
 
                        case PageItem::Polygon:
730
 
                        case PageItem::PathText:
731
 
                                drawItem(embedded, p, clip);
732
 
                                break;
733
 
                        case PageItem::Line:
734
 
                        case PageItem::PolyLine:
735
 
                                embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
736
 
                                drawItem(embedded, p, clip);
737
 
                                break;
738
 
                        default:
739
 
                                break;
740
 
                }
741
 
                embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
742
 
                drawItem_Post(embedded, p);
743
 
                embedded->setXPos(x, true);
744
 
                embedded->setYPos(y, true);
745
 
                p->restore();
746
 
                if (groupStack.count() != 0)
747
 
                {
748
 
                        while (embedded == groupStack.top())
749
 
                        {
750
 
                                p->restore();
751
 
                                groupStack.pop();
752
 
                                if (groupStack.count() == 0)
753
 
                                        break;
754
 
                        }
755
 
                }
756
 
                embedded->m_lineWidth = pws;
757
 
        }
758
 
        for (int em = 0; em < emG.count(); ++em)
759
 
        {
760
 
                PageItem* embedded = emG.at(em);
761
 
                if (!embedded->isTableItem)
762
 
                        continue;
763
 
                p->save();
764
 
                double x = embedded->xPos();
765
 
                double y = embedded->yPos();
766
 
                embedded->setXPos(embedded->gXpos, true);
767
 
                embedded->setYPos ((embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos, true);
768
 
                p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
769
 
                if (style.baselineOffset() != 0)
770
 
                {
771
 
                        p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
772
 
                        embedded->setYPos(embedded->yPos() - embedded->gHeight * (style.baselineOffset() / 1000.0));
773
 
                }
774
 
                p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
775
 
                p->rotate(embedded->rotation());
776
 
                double pws = embedded->m_lineWidth;
777
 
                embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
778
 
                if ((embedded->lineColor() != CommonStrings::None) && (embedded->lineWidth() != 0.0))
779
 
                {
780
 
                        ScColorShade colorShade(m_doc->PageColors[embedded->lineColor()], embedded->lineShade());
781
 
                        if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine))
782
 
                        {
783
 
                                p->setPen(colorShade, embedded->lineWidth(), embedded->PLineArt, Qt::SquareCap, embedded->PLineJoin);
784
 
                                if (embedded->TopLine)
785
 
                                        p->drawLine(FPoint(0.0, 0.0), FPoint(embedded->width(), 0.0));
786
 
                                if (embedded->RightLine)
787
 
                                        p->drawLine(FPoint(embedded->width(), 0.0), FPoint(embedded->width(), embedded->height()));
788
 
                                if (embedded->BottomLine)
789
 
                                        p->drawLine(FPoint(embedded->width(), embedded->height()), FPoint(0.0, embedded->height()));
790
 
                                if (embedded->LeftLine)
791
 
                                        p->drawLine(FPoint(0.0, embedded->height()), FPoint(0.0, 0.0));
792
 
                        }
793
 
                }
794
 
                embedded->m_lineWidth = pws;
795
 
                embedded->setXPos(x, true);
796
 
                embedded->setYPos(y, true);
797
 
                p->restore();
798
 
        }
799
 
}
800
 
 
801
 
void ScPageOutput::drawPattern( PageItem* item, ScPainterExBase* painter, const QRect& clip)
802
 
{
803
 
        double x1, x2, y1, y2;
804
 
        ScPattern& pattern = m_doc->docPatterns[item->pattern()];
805
 
        double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation;
806
 
        item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
807
 
 
808
 
        // Compute pattern tansformation matrix and its inverse for converting pattern coordinates
809
 
        // to pageitem coordinates 
810
 
        QMatrix matrix, invMat;
811
 
        matrix.translate(patternOffsetX, patternOffsetY);
812
 
        matrix.rotate(patternRotation);
813
 
        matrix.scale(pattern.scaleX, pattern.scaleY);
814
 
        matrix.scale(patternScaleX / 100.0 , patternScaleY / 100.0);
815
 
        invMat.scale((patternScaleX != 0) ? (100 /patternScaleX) : 1.0, (patternScaleY != 0) ? (100 /patternScaleY) : 1.0);
816
 
        invMat.scale((pattern.scaleX != 0) ? (1 /pattern.scaleX) : 1.0, (pattern.scaleY != 0) ? (1 /pattern.scaleY) : 1.0);
817
 
        invMat.rotate(-patternRotation);
818
 
        invMat.translate(-patternOffsetX, -patternOffsetY);
819
 
 
820
 
        // Compute bounding box in which pattern item will be drawn
821
 
        double width  = item->width();
822
 
        double height = item->height();
823
 
        double rot    = patternRotation - floor(patternRotation / 90) * 90;
824
 
        double ctheta = cos(rot * M_PI / 180);
825
 
        double stheta = sin(rot * M_PI / 180);
826
 
        QRectF  itemRect(0.0, 0.0, item->width(), item->height());
827
 
        QPointF pa( width * stheta * stheta, -width * stheta * ctheta );
828
 
        QPointF pb( width + height * ctheta * stheta, height * stheta * stheta );
829
 
        QPointF pc( -height * ctheta * stheta, height * ctheta * ctheta );
830
 
        QPointF pd( width * ctheta * ctheta, height + width * ctheta * stheta );
831
 
        QPointF ipa = invMat.map(pa), ipb = invMat.map(pb);
832
 
        QPointF ipc = invMat.map(pc), ipd = invMat.map(pd);
833
 
 
834
 
        painter->save();
835
 
        if (item->imageClip.size() != 0)
836
 
        {
837
 
                painter->setupPolygon(&item->imageClip);
838
 
                painter->setClipPath();
839
 
        }
840
 
        painter->setupPolygon(&item->PoLine);
841
 
        painter->setClipPath();
842
 
        for (int index = 0; index < pattern.items.count(); index++)
843
 
        {
844
 
                QRectF itRect;
845
 
                PageItem* it = pattern.items.at(index);
846
 
                if (it->isGroupControl)
847
 
                        continue;
848
 
 
849
 
                painter->save();
850
 
                painter->translate(patternOffsetX, patternOffsetY);
851
 
                painter->rotate(patternRotation);
852
 
                painter->scale(pattern.scaleX, pattern.scaleY);
853
 
                painter->scale(patternScaleX / 100.0, patternScaleY / 100.0);
854
 
 
855
 
                double patWidth  = (pattern.width != 0.0) ? pattern.width : 1.0;
856
 
                double patHeight = (pattern.height != 0.0) ? pattern.height : 1.0;
857
 
                double kxa = (ipa.x() - it->gXpos) / patWidth;
858
 
                double kxb = (ipb.x() - it->gXpos) / patWidth;
859
 
                double kxc = (ipc.x() - it->gXpos) / patWidth;
860
 
                double kxd = (ipd.x() - it->gXpos) / patWidth;
861
 
                double kya = (ipa.y() - it->gYpos) / patHeight;
862
 
                double kyb = (ipb.y() - it->gYpos) / patHeight;
863
 
                double kyc = (ipc.y() - it->gYpos) / patHeight;
864
 
                double kyd = (ipd.y() - it->gYpos) / patHeight;
865
 
                int kxMin  = (int) floor( qMin(qMin(kxa, kxb), qMin(kxc, kxd)) );
866
 
                int kxMax  = (int) ceil ( qMax(qMax(kxa, kxb), qMax(kxc, kxd)) );
867
 
                int kyMin  = (int) floor( qMin(qMin(kya, kyb), qMin(kyc, kyd)) );
868
 
                int kyMax  = (int) ceil ( qMax(qMax(kya, kyb), qMax(kyc, kyd)) );
869
 
 
870
 
                double itx = it->xPos();
871
 
                double ity = it->yPos();
872
 
                double itPosX = it->gXpos, itPosY = it->gYpos;
873
 
                for ( int kx = kxMin; kx <= kxMax; kx++ )
874
 
                {
875
 
                        for ( int ky = kyMin; ky <= kyMax; ky++ )
876
 
                        {
877
 
                                itPosX = it->gXpos + kx * pattern.width;
878
 
                                itPosY = it->gYpos + ky * pattern.height;
879
 
                                it->setXYPos(itPosX, itPosY);
880
 
                                it->getBoundingRect(&x1, &y1, &x2, &y2);
881
 
                                itRect.setCoords(x1, y1, x2, y2);
882
 
                                itRect = matrix.mapRect( itRect );
883
 
                                if ( itRect.intersects(itemRect) )
884
 
                                        drawItem(it, painter, clip);
885
 
                        }
886
 
                }
887
 
                it->setXYPos(itx, ity);
888
 
                painter->restore();
889
 
        }
890
 
        painter->restore();
891
 
}
892
 
 
893
 
void ScPageOutput::drawItem_ImageFrame( PageItem_ImageFrame* item, ScPainterExBase* painter, const QRect& clip  )
894
 
{
895
 
        ScPainterExBase::ImageMode mode = ScPainterExBase::rgbImages;
896
 
        if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0))
897
 
        {
898
 
                painter->setupPolygon(&item->PoLine);
899
 
                fillPath(item, painter, clip);
900
 
        }
901
 
        if (item->Pfile.isEmpty())
902
 
        {
903
 
                /*painter->setPen( ScColorShade(Qt::black, 100), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
904
 
                painter->drawLine(FPoint(0, 0), FPoint(item->width(), item->height()));
905
 
                painter->drawLine(FPoint(0, item->height()), FPoint(item->width(), 0));*/
906
 
        }
907
 
        else
908
 
        {
909
 
                if ((!item->imageShown()) || (!item->PictureIsAvailable))
910
 
                {
911
 
                        /*painter->setPen( ScColorShade(Qt::red, 100), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
912
 
                        painter->drawLine(FPoint(0, 0), FPoint(item->width(), item->height()));
913
 
                        painter->drawLine(FPoint(0, item->height()), FPoint(item->width(), 0));*/
914
 
                }
915
 
                else
916
 
                {
917
 
                        ScImage scImg;
918
 
                        ScImage* pImage = NULL;
919
 
                        double imScaleX = item->imageXScale();
920
 
                        double imScaleY = item->imageYScale();
921
 
                        if( m_reloadImages )
922
 
                        {
923
 
                                bool dummy;
924
 
                                bool useCmyk = false;
925
 
                                ScPainterExBase::ImageMode imageMode = painter->imageMode();
926
 
                                if ( imageMode == ScPainterExBase::cmykImages )
927
 
                                        useCmyk = true;
928
 
                                QFileInfo fInfo(item->Pfile);
929
 
                                QString ext = fInfo.suffix();
930
 
                                CMSettings cmsSettings(item->doc(), item->IProfile, item->IRender);
931
 
                                scImg.imgInfo.valid = false;
932
 
                                scImg.imgInfo.clipPath = "";
933
 
                                scImg.imgInfo.PDSpathData.clear();
934
 
                                scImg.imgInfo.layerInfo.clear();
935
 
                                scImg.imgInfo.RequestProps = item->pixm.imgInfo.RequestProps;
936
 
                                scImg.imgInfo.isRequest = item->pixm.imgInfo.isRequest;
937
 
                                scImg.LoadPicture(item->Pfile, item->pixm.imgInfo.actualPageNumber, cmsSettings, item->UseEmbedded, m_useProfiles, translateImageModeToRequest(imageMode), m_imageRes, &dummy);
938
 
                                if( extensionIndicatesEPSorPS(ext) || extensionIndicatesPDF(ext)  )
939
 
                                {
940
 
                                        imScaleX *= (72.0 / (double) m_imageRes);
941
 
                                        imScaleY *= (72.0 / (double) m_imageRes);
942
 
                                }
943
 
                                scImg.applyEffect(item->effectsInUse, m_doc->PageColors, useCmyk);
944
 
                                mode = imageMode;
945
 
                                pImage = &scImg;
946
 
                        }
947
 
                        else
948
 
                                pImage = &item->pixm;
949
 
 
950
 
                        painter->save();
951
 
                        if (item->imageClip.size() != 0)
952
 
                        {
953
 
                                painter->setupPolygon(&item->imageClip);
954
 
                                painter->setClipPath();
955
 
                        }
956
 
                        painter->setupPolygon(&item->PoLine);
957
 
                        painter->setClipPath();
958
 
                        if (item->imageFlippedH())
959
 
                        {
960
 
                                painter->translate(item->width(), 0);
961
 
                                painter->scale(-1, 1);
962
 
                        }
963
 
                        if (item->imageFlippedV())
964
 
                        {
965
 
                                painter->translate(0, item->height());
966
 
                                painter->scale(1, -1);
967
 
                        }
968
 
                        painter->translate(item->imageXOffset() * item->imageXScale(), item->imageYOffset() * item->imageYScale());
969
 
                        //painter->translate(item->LocalX * imScaleX * scale, item->LocalY * imScaleY * scale); ??
970
 
                        painter->scale( imScaleX, imScaleY );
971
 
                        if (pImage->imgInfo.lowResType != 0)
972
 
                                painter->scale(pImage->imgInfo.lowResScale, pImage->imgInfo.lowResScale);
973
 
                        painter->drawImage(pImage, mode);
974
 
                        painter->restore();
975
 
                }
976
 
        }
977
 
}
978
 
 
979
 
void ScPageOutput::drawItem_Line( PageItem_Line* item, ScPainterExBase* painter, const QRect& clip )
980
 
{
981
 
        int startArrowIndex = item->startArrowIndex();
982
 
        int endArrowIndex = item->endArrowIndex();
983
 
 
984
 
        if (item->NamedLStyle.isEmpty())
985
 
                painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0));
986
 
        else
987
 
        {
988
 
                multiLine ml = m_doc->MLineStyles[item->NamedLStyle];
989
 
                for (int it = ml.size()-1; it > -1; it--)
990
 
                {
991
 
                        const SingleLine& sl = ml[it];
992
 
                        if (sl.Color != CommonStrings::None)
993
 
                        {
994
 
                                ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade);
995
 
                                painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash),
996
 
                                                static_cast<Qt::PenCapStyle>(sl.LineEnd),
997
 
                                                static_cast<Qt::PenJoinStyle>(sl.LineJoin));
998
 
                                painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0));
999
 
                        }
1000
 
                }
1001
 
        }
1002
 
        if (startArrowIndex != 0)
1003
 
        {
1004
 
                QMatrix arrowTrans;
1005
 
                arrowTrans.translate(0, 0);
1006
 
                arrowTrans.scale(-1,1);
1007
 
                drawArrow(painter, item, arrowTrans, startArrowIndex);
1008
 
        }
1009
 
        if (endArrowIndex != 0)
1010
 
        {
1011
 
                QMatrix arrowTrans;
1012
 
                arrowTrans.translate(item->width(), 0);
1013
 
                drawArrow(painter, item, arrowTrans, endArrowIndex);
1014
 
        }
1015
 
}
1016
 
 
1017
 
void ScPageOutput::drawItem_PathText( PageItem_PathText* item, ScPainterExBase* painter, const QRect& clip )
1018
 
{
1019
 
        QString chstr, chstr2, chstr3;
1020
 
        ScText *hl;
1021
 
        FPoint point = FPoint(0, 0);
1022
 
        FPoint tangent = FPoint(0, 0);
1023
 
        uint seg = 0;
1024
 
        double chs, dx, segLen = 0;
1025
 
        double CurX = item->textToFrameDistLeft(); // item->CurX = item->textToFrameDistLeft()
1026
 
        double CurY = 0;
1027
 
        QString actFill, actStroke;
1028
 
        double actFillShade, actStrokeShade;
1029
 
        StoryText& itemText = item->itemText;
1030
 
        if (item->pathTextShowFrame())
1031
 
        {
1032
 
                painter->setupPolygon(&item->PoLine, false);
1033
 
                if (item->NamedLStyle.isEmpty())
1034
 
                {
1035
 
                        if (item->lineColor() != CommonStrings::None)
1036
 
                                painter->strokePath();
1037
 
                }
1038
 
                else
1039
 
                {
1040
 
                        multiLine ml = m_doc->MLineStyles[item->NamedLStyle];
1041
 
                        for (int it = ml.size() - 1; it > -1; it--)
1042
 
                        {
1043
 
                                const SingleLine& sl = ml[it];
1044
 
                                if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
1045
 
                                {
1046
 
                                        ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade);
1047
 
                                        painter->setPen(tmp, sl.Width,  static_cast<Qt::PenStyle>(sl.Dash), 
1048
 
                                                         static_cast<Qt::PenCapStyle>(sl.LineEnd), 
1049
 
                                                         static_cast<Qt::PenJoinStyle>(sl.LineJoin));
1050
 
                                        painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0));
1051
 
                                }
1052
 
                        }
1053
 
                }
1054
 
        }
1055
 
        double totalTextLen = 0.0;
1056
 
        double totalCurveLen = 0.0;
1057
 
        double extraOffset = 0.0;
1058
 
        if (itemText.length() != 0)
1059
 
        {
1060
 
                CurX += itemText.item(0)->fontSize() * itemText.charStyle(0).tracking() / 10000.0;
1061
 
                totalTextLen += itemText.charStyle(0).fontSize() * itemText.charStyle(0).tracking() / 10000.0;
1062
 
        }
1063
 
        segLen = item->PoLine.lenPathSeg(seg);
1064
 
        for (int a = 0; a < itemText.length(); ++a)
1065
 
        {
1066
 
                hl = itemText.item(a);
1067
 
                chstr = hl->ch;
1068
 
                if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT
1069
 
                        || chstr[0] == SpecialChars::TAB || chstr == SpecialChars::LINEBREAK)
1070
 
                        continue;
1071
 
                if (a < itemText.length()-1)
1072
 
                        chstr += itemText.text(a+1, 1);
1073
 
                hl->glyph.yadvance = 0;
1074
 
                item->layoutGlyphs(itemText.charStyle(a), chstr, hl->glyph);
1075
 
                hl->glyph.shrink();
1076
 
                if (hl->ch == SpecialChars::OBJECT)
1077
 
                        totalTextLen += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
1078
 
                else
1079
 
                        totalTextLen += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0;
1080
 
        }
1081
 
        for (uint segs = 0; segs < item->PoLine.size()-3; segs += 4)
1082
 
        {
1083
 
                totalCurveLen += item->PoLine.lenPathSeg(segs);
1084
 
        }
1085
 
        if ((itemText.defaultStyle().alignment() != 0) && (totalCurveLen >= totalTextLen + item->textToFrameDistLeft()))
1086
 
        {
1087
 
                if (itemText.defaultStyle().alignment() == 2)
1088
 
                {
1089
 
                        CurX = totalCurveLen  - totalTextLen;
1090
 
                        CurX -= item->textToFrameDistLeft();
1091
 
                }
1092
 
                if (itemText.defaultStyle().alignment() == 1)
1093
 
                        CurX = (totalCurveLen - totalTextLen) / 2.0;
1094
 
                if ((itemText.defaultStyle().alignment() == 3) || (itemText.defaultStyle().alignment() == 4))
1095
 
                        extraOffset = (totalCurveLen - item->textToFrameDistLeft()  - totalTextLen) / static_cast<double>(itemText.length());
1096
 
        }
1097
 
 
1098
 
        QPainterPath guidePath = item->PoLine.toQPainterPath(false);
1099
 
        QList<QPainterPath> pathList = decomposePath(guidePath);
1100
 
        QPainterPath currPath = pathList[0];
1101
 
        int currPathIndex = 0;
1102
 
        for (int a = item->firstInFrame(); a < itemText.length(); ++a)
1103
 
        {
1104
 
                CurY = 0;
1105
 
                hl = itemText.item(a);
1106
 
                chstr = hl->ch;
1107
 
                if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT
1108
 
                        || chstr[0] == SpecialChars::TAB || chstr[0] == SpecialChars::LINEBREAK)
1109
 
                        continue;
1110
 
                chs = hl->fontSize();
1111
 
                if (a < itemText.length()-1)
1112
 
                        chstr += itemText.text(a+1, 1);
1113
 
                hl->glyph.yadvance = 0;
1114
 
                item->layoutGlyphs(itemText.charStyle(a), chstr, hl->glyph);
1115
 
                hl->glyph.shrink();                                                           // HACK
1116
 
                if (hl->ch == SpecialChars::OBJECT)
1117
 
                        dx = (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH / 2.0;
1118
 
                else
1119
 
                        dx = hl->glyph.wide() / 2.0;
1120
 
 
1121
 
                CurX += dx;
1122
 
 
1123
 
                double currPerc = currPath.percentAtLength(CurX);
1124
 
                if (currPerc >= 0.9999999)
1125
 
                {
1126
 
                        currPathIndex++;
1127
 
                        if (currPathIndex == pathList.count())
1128
 
                                break;
1129
 
                        currPath = pathList[currPathIndex];
1130
 
                        CurX = dx;
1131
 
                        currPerc = currPath.percentAtLength(CurX);
1132
 
                }
1133
 
                double currAngle = currPath.angleAtPercent(currPerc);
1134
 
                if (currAngle <= 180.0)
1135
 
                        currAngle *= -1.0;
1136
 
                else
1137
 
                        currAngle = 360.0 - currAngle;
1138
 
                QPointF currPoint = currPath.pointAtPercent(currPerc);
1139
 
                tangent = FPoint(cos(currAngle * M_PI / 180.0), sin(currAngle * M_PI / 180.0));
1140
 
                point = FPoint(currPoint.x(), currPoint.y());
1141
 
 
1142
 
                hl->glyph.xoffset = 0;
1143
 
                hl->PtransX = point.x();
1144
 
                hl->PtransY = point.y();
1145
 
                hl->PRot    = currAngle * M_PI / 180.0;
1146
 
                hl->PDx     = dx;
1147
 
                QMatrix trafo = QMatrix( 1, 0, 0, -1, -dx, 0 );
1148
 
                if (item->textPathFlipped)
1149
 
                        trafo *= QMatrix(1, 0, 0, -1, 0, 0);
1150
 
                if (item->textPathType == 0)
1151
 
                        trafo *= QMatrix( tangent.x(), tangent.y(), tangent.y(), -tangent.x(), point.x(), point.y() ); // ID's Rainbow mode
1152
 
                else if (item->textPathType == 1)
1153
 
                        trafo *= QMatrix( 1, 0, 0, -1, point.x(), point.y() ); // ID's Stair Step mode
1154
 
                else if (item->textPathType == 2)
1155
 
                {
1156
 
                        double a = 1;
1157
 
                        if (tangent.x() < 0)
1158
 
                                a = -1;
1159
 
                        if (fabs(tangent.x()) > 0.1)
1160
 
                                trafo *= QMatrix( a, (tangent.y() / tangent.x()) * a, 0, -1, point.x(), point.y() ); // ID's Skew mode
1161
 
                        else
1162
 
                                trafo *= QMatrix( a, 4 * a, 0, -1, point.x(), point.y() );
1163
 
                }
1164
 
                QMatrix sca = painter->worldMatrix();
1165
 
                trafo *= sca;
1166
 
                painter->save();
1167
 
                QMatrix savWM = painter->worldMatrix();
1168
 
                painter->setWorldMatrix(trafo);
1169
 
 
1170
 
                actFill = itemText.charStyle(a).fillColor();
1171
 
                actFillShade = itemText.charStyle(a).fillShade();
1172
 
                if (actFill != CommonStrings::None)
1173
 
                {
1174
 
                        ScColorShade tmp(m_doc->PageColors[actFill], qRound(actFillShade));
1175
 
                        painter->setBrush(tmp);
1176
 
                }
1177
 
                actStroke = itemText.charStyle(a).strokeColor();
1178
 
                actStrokeShade = itemText.charStyle(a).strokeShade();
1179
 
                if (actStroke != CommonStrings::None)
1180
 
                {
1181
 
                        ScColorShade tmp(m_doc->PageColors[actStroke], qRound(actStrokeShade));
1182
 
                        painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1183
 
                }
1184
 
                painter->translate(0.0, item->pathTextBaseOffset());
1185
 
                if (hl->ch == SpecialChars::OBJECT)
1186
 
                        drawItem_Embedded(hl->embedded.getItem(), painter, clip, itemText.charStyle(a), hl->embedded.getItem());
1187
 
                else
1188
 
                        drawGlyphs(item, painter, itemText.charStyle(a), hl->glyph, clip);
1189
 
 
1190
 
                painter->setWorldMatrix(savWM);
1191
 
                painter->restore();
1192
 
                CurX -= dx;
1193
 
                if (hl->ch == SpecialChars::OBJECT)
1194
 
                        CurX += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
1195
 
                else
1196
 
                        CurX += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0 + extraOffset;
1197
 
        }
1198
 
}
1199
 
 
1200
 
void ScPageOutput::drawItem_Polygon ( PageItem_Polygon* item , ScPainterExBase* painter, const QRect& clip )
1201
 
{
1202
 
        painter->setupPolygon(&item->PoLine);
1203
 
        fillPath(item, painter, clip);
1204
 
}
1205
 
 
1206
 
void ScPageOutput::drawItem_PolyLine( PageItem_PolyLine* item, ScPainterExBase* painter, const QRect& clip )
1207
 
{
1208
 
        int startArrowIndex = item->startArrowIndex();
1209
 
        int endArrowIndex = item->endArrowIndex();
1210
 
 
1211
 
        if (item->PoLine.size()>=4)
1212
 
        {
1213
 
                if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0))
1214
 
                {
1215
 
                        FPointArray cli;
1216
 
                        FPoint Start;
1217
 
                        bool firstp = true;
1218
 
                        for (uint n = 0; n < item->PoLine.size()-3; n += 4)
1219
 
                        {
1220
 
                                if (firstp)
1221
 
                                {
1222
 
                                        Start = item->PoLine.point(n);
1223
 
                                        firstp = false;
1224
 
                                }
1225
 
                                if (item->PoLine.point(n).x() > 900000)
1226
 
                                {
1227
 
                                        cli.addPoint(item->PoLine.point(n-2));
1228
 
                                        cli.addPoint(item->PoLine.point(n-2));
1229
 
                                        cli.addPoint(Start);
1230
 
                                        cli.addPoint(Start);
1231
 
                                        cli.setMarker();
1232
 
                                        firstp = true;
1233
 
                                        continue;
1234
 
                                }
1235
 
                                cli.addPoint(item->PoLine.point(n));
1236
 
                                cli.addPoint(item->PoLine.point(n+1));
1237
 
                                cli.addPoint(item->PoLine.point(n+2));
1238
 
                                cli.addPoint(item->PoLine.point(n+3));
1239
 
                        }
1240
 
                        if (cli.size() > 2)
1241
 
                        {
1242
 
                                FPoint l1 = cli.point(cli.size()-2);
1243
 
                                cli.addPoint(l1);
1244
 
                                cli.addPoint(l1);
1245
 
                                cli.addPoint(Start);
1246
 
                                cli.addPoint(Start);
1247
 
                        }
1248
 
                        painter->setupPolygon(&cli);
1249
 
                        fillPath(item, painter, clip);
1250
 
                }
1251
 
                painter->setupPolygon(&item->PoLine, false);
1252
 
                if (item->NamedLStyle.isEmpty())
1253
 
                {
1254
 
                        if (item->lineColor() != CommonStrings::None)
1255
 
                                painter->strokePath();
1256
 
                }
1257
 
                else
1258
 
                {
1259
 
                        multiLine ml = m_doc->MLineStyles[item->NamedLStyle];
1260
 
                        for (int it = ml.size()-1; it > -1; it--)
1261
 
                        {
1262
 
                                const SingleLine& sl = ml[it];
1263
 
                                if (sl.Color != CommonStrings::None)
1264
 
                                {
1265
 
                                        ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade);
1266
 
                                        painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash),
1267
 
                                                        static_cast<Qt::PenCapStyle>(sl.LineEnd),
1268
 
                                                        static_cast<Qt::PenJoinStyle>(sl.LineJoin));
1269
 
                                        painter->strokePath();
1270
 
                                }
1271
 
                        }
1272
 
                }
1273
 
                if (startArrowIndex != 0)
1274
 
                {
1275
 
                        FPoint Start = item->PoLine.point(0);
1276
 
                        for (uint xx = 1; xx < item->PoLine.size(); xx += 2)
1277
 
                        {
1278
 
                                FPoint Vector = item->PoLine.point(xx);
1279
 
                                if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
1280
 
                                {
1281
 
                                        double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI);
1282
 
                                        QMatrix arrowTrans;
1283
 
                                        arrowTrans.translate(Start.x(), Start.y());
1284
 
                                        arrowTrans.rotate(r);
1285
 
                                        drawArrow(painter, item, arrowTrans, startArrowIndex);
1286
 
                                        break;
1287
 
                                }
1288
 
                        }
1289
 
                }
1290
 
                if (endArrowIndex != 0)
1291
 
                {
1292
 
                        FPoint End = item->PoLine.point(item->PoLine.size()-2);
1293
 
                        for (uint xx = item->PoLine.size()-1; xx > 0; xx -= 2)
1294
 
                        {
1295
 
                                FPoint Vector = item->PoLine.point(xx);
1296
 
                                if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
1297
 
                                {
1298
 
                                        double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI);
1299
 
                                        QMatrix arrowTrans;
1300
 
                                        arrowTrans.translate(End.x(), End.y());
1301
 
                                        arrowTrans.rotate(r);
1302
 
                                        drawArrow(painter, item, arrowTrans, endArrowIndex);
1303
 
                                        break;
1304
 
                                }
1305
 
                        }
1306
 
                }
1307
 
        }
1308
 
}
1309
 
 
1310
 
void ScPageOutput::drawItem_TextFrame( PageItem_TextFrame* item, ScPainterExBase* painter, const QRect& clip )
1311
 
{
1312
 
        QMatrix wm;
1313
 
        QPoint pt1, pt2;
1314
 
        FPoint ColBound;
1315
 
        QRegion cm;
1316
 
        int a;
1317
 
        double lineCorr;
1318
 
        QString chstr, chstr2, chstr3;
1319
 
        ScText *hl;
1320
 
        double desc, asce, tabDist;
1321
 
        
1322
 
        QRect e2;
1323
 
        painter->save();
1324
 
        if (item->isEmbedded)
1325
 
                e2 = clip;
1326
 
        else
1327
 
        {
1328
 
                e2 = QRect(qRound(clip.x() + m_doc->minCanvasCoordinate.x()), qRound(clip.y() + m_doc->minCanvasCoordinate.y()), qRound(clip.width()), qRound(clip.height()));
1329
 
                wm.translate(item->xPos(), item->yPos());
1330
 
        }
1331
 
        wm.rotate(item->rotation());
1332
 
        if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0))
1333
 
        {
1334
 
                painter->setupPolygon(&item->PoLine);
1335
 
                fillPath(item, painter, clip);
1336
 
        }
1337
 
        if (item->lineColor() != CommonStrings::None)
1338
 
                lineCorr = item->lineWidth() / 2.0;
1339
 
        else
1340
 
                lineCorr = 0;
1341
 
        if ((item->isAnnotation()) && (item->annotation().Type() == 2) && (!item->Pfile.isEmpty()) && (item->PictureIsAvailable) && (item->imageShown()) && (item->annotation().UseIcons()))
1342
 
        {
1343
 
                painter->save();
1344
 
                painter->setupPolygon(&item->PoLine);
1345
 
                painter->setClipPath();
1346
 
                painter->scale(item->imageXScale(), item->imageYScale());
1347
 
                painter->translate(static_cast<int>(item->imageXOffset() * item->imageXScale()), static_cast<int>(item->imageYOffset()  * item->imageYScale()));
1348
 
                if (!item->pixm.qImage().isNull())
1349
 
                        painter->drawImage(&item->pixm, ScPainterExBase::rgbImages);
1350
 
                painter->restore();
1351
 
        }
1352
 
        if ((item->itemText.length() != 0))
1353
 
        {
1354
 
                if (item->imageFlippedH())
1355
 
                {
1356
 
                        painter->translate(item->width(), 0);
1357
 
                        painter->scale(-1, 1);
1358
 
                }
1359
 
                if (item->imageFlippedV())
1360
 
                {
1361
 
                        painter->translate(0, item->height());
1362
 
                        painter->scale(1, -1);
1363
 
                }
1364
 
                uint tabCc = 0;
1365
 
                for (uint ll=0; ll < item->itemText.lines(); ++ll)
1366
 
                {
1367
 
                        LineSpec ls = item->itemText.line(ll);
1368
 
                        tabDist = ls.x;
1369
 
                        double CurX = ls.x;
1370
 
                        for (a = ls.firstItem; a <= ls.lastItem; ++a)
1371
 
                        {
1372
 
                                hl = item->itemText.item(a);
1373
 
                                const CharStyle& charStyle  = item->itemText.charStyle(a);
1374
 
                                double chs = charStyle.fontSize() * hl->glyph.scaleV;
1375
 
                                if (charStyle.effects() & ScStyle_StartOfLine)
1376
 
                                        tabCc = 0;
1377
 
                                chstr = hl->ch;
1378
 
                                if (charStyle.fillColor() != CommonStrings::None)
1379
 
                                {
1380
 
                                        ScColorShade tmp(m_doc->PageColors[charStyle.fillColor()], (int) hl->fillShade());
1381
 
                                        painter->setBrush(tmp);
1382
 
                                }
1383
 
                                if (charStyle.strokeColor() != CommonStrings::None)
1384
 
                                {
1385
 
                                        ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], (int) hl->strokeShade());
1386
 
                                        painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1387
 
                                }
1388
 
                                if (charStyle.effects() & ScStyle_DropCap)
1389
 
                                {
1390
 
                                        const ParagraphStyle& style(item->itemText.paragraphStyle(a));
1391
 
                                        if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
1392
 
                                                chs = qRound(10 * ((m_doc->typographicSettings.valueBaseGrid * (style.dropCapLines()-1) + (charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
1393
 
                                        else
1394
 
                                        {
1395
 
                                                if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
1396
 
                                                        chs = qRound(10 * ((style.lineSpacing() * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
1397
 
                                                else
1398
 
                                                {
1399
 
                                                        double currasce = charStyle.font().height(style.charStyle().fontSize() / 10.0);
1400
 
                                                        chs = qRound(10 * ((currasce * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
1401
 
                                                }
1402
 
                                        }
1403
 
                                }
1404
 
                                if (chstr[0] == SpecialChars::TAB)
1405
 
                                        tabCc++;
1406
 
                                //if (!m_doc->RePos)
1407
 
                                {
1408
 
                                        //double xcoZli = CurX + hl->glyph.xoffset;
1409
 
                                        desc = - charStyle.font().descent(charStyle.fontSize() / 10.0);
1410
 
                                        asce = charStyle.font().ascent(charStyle.fontSize() / 10.0);
1411
 
                                        if (charStyle.strokeColor() != CommonStrings::None)
1412
 
                                        {
1413
 
                                                ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], (int) charStyle.strokeShade());
1414
 
                                                painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1415
 
                                        }
1416
 
                                        if (e2.intersects(wm.mapRect(QRect(qRound(CurX + hl->glyph.xoffset),qRound(ls.y + hl->glyph.yoffset-asce), qRound(hl->glyph.xadvance+1), qRound(asce+desc)))))
1417
 
                                        {
1418
 
                                                painter->save();
1419
 
                                                painter->translate(CurX, ls.y);
1420
 
                                                if (hl->ch == SpecialChars::OBJECT)
1421
 
                                                        drawItem_Embedded(item, painter, clip, charStyle, hl->embedded.getItem());
1422
 
                                                else
1423
 
                                                        drawGlyphs(item, painter, charStyle, hl->glyph, clip);
1424
 
                                                painter->restore();
1425
 
                                        }
1426
 
                                        if (hl->ch == SpecialChars::OBJECT)
1427
 
                                                CurX += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth());
1428
 
                                        else
1429
 
                                                CurX += hl->glyph.wide();
1430
 
                                }
1431
 
                                tabDist = CurX;
1432
 
                        }
1433
 
                }
1434
 
        }
1435
 
        painter->restore();
1436
 
}
1437
 
 
1438
 
void ScPageOutput::drawArrow(ScPainterExBase* painter, PageItem* item, QMatrix &arrowTrans, int arrowIndex)
1439
 
{
1440
 
        FPointArray arrow = m_doc->arrowStyles.at(arrowIndex-1).points.copy();
1441
 
        if (item->NamedLStyle.isEmpty())
1442
 
        {
1443
 
                if (item->lineWidth() != 0.0)
1444
 
                        arrowTrans.scale(item->lineWidth(), item->lineWidth());
1445
 
        }
1446
 
        else
1447
 
        {
1448
 
                multiLine ml = m_doc->MLineStyles[item->NamedLStyle];
1449
 
                if (ml[ml.size()-1].Width != 0.0)
1450
 
                        arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
1451
 
        }
1452
 
        arrow.map(arrowTrans);
1453
 
        painter->setupPolygon(&arrow);
1454
 
        if (item->NamedLStyle.isEmpty())
1455
 
        {
1456
 
                if (item->lineColor() != CommonStrings::None)
1457
 
                {
1458
 
                        ScColorShade tmp(m_doc->PageColors[item->lineColor()], item->lineShade());
1459
 
                        painter->setBrush(tmp);
1460
 
                        painter->setBrushOpacity(1.0 - item->lineTransparency());
1461
 
                        painter->setLineWidth(0);
1462
 
                        painter->setFillMode(ScPainterExBase::Solid);
1463
 
                        painter->fillPath();
1464
 
                }
1465
 
        }
1466
 
        else
1467
 
        {
1468
 
                multiLine ml = m_doc->MLineStyles[item->NamedLStyle];
1469
 
                QColor tmp;
1470
 
                if (ml[0].Color != CommonStrings::None)
1471
 
                {
1472
 
                        ScColorShade tmp(m_doc->PageColors[ml[0].Color], ml[0].Shade);
1473
 
                        painter->setBrush(tmp);
1474
 
                        painter->setLineWidth(0);
1475
 
                        painter->setFillMode(ScPainterExBase::Solid);
1476
 
                        painter->fillPath();
1477
 
                }
1478
 
                for (int it = ml.size()-1; it > 0; it--)
1479
 
                {
1480
 
                        if (ml[it].Color != CommonStrings::None)
1481
 
                        {
1482
 
                                ScColorShade tmp(m_doc->PageColors[ml[it].Color], ml[it].Shade);
1483
 
                                painter->setPen(tmp, ml[it].Width, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1484
 
                                painter->strokePath();
1485
 
                        }
1486
 
                }
1487
 
        }
1488
 
}
1489
 
 
1490
 
void ScPageOutput::drawMarks( Page* page, ScPainterExBase* painter, const MarksOptions& options )
1491
 
{
1492
 
        double markOffs  = options.markOffset;
1493
 
        double bleedLeft = 0.0, bleedRight = 0.0;
1494
 
        double bleedBottom = options.BleedBottom;
1495
 
        double bleedTop = options.BleedTop;
1496
 
        if (!options.cropMarks && !options.bleedMarks && !options.registrationMarks && !options.colorMarks)
1497
 
                return;
1498
 
        if (m_doc->locationOfPage(page->pageNr()) == LeftPage)
1499
 
        {
1500
 
                bleedRight = options.BleedRight;
1501
 
                bleedLeft  = options.BleedLeft;
1502
 
        }
1503
 
        else if (m_doc->locationOfPage(page->pageNr()) == RightPage)
1504
 
        {
1505
 
                bleedRight = options.BleedLeft;
1506
 
                bleedLeft  = options.BleedRight;
1507
 
        }
1508
 
        else
1509
 
        {
1510
 
                bleedRight = options.BleedLeft;
1511
 
                bleedLeft  = options.BleedLeft;
1512
 
        }
1513
 
        double width = page->width();
1514
 
        double height = page->height();
1515
 
        double offsetX = page->xOffset();
1516
 
        double offsetY = page->yOffset();
1517
 
        QPointF bleedTopLeft(offsetX - bleedLeft, offsetY - bleedTop);
1518
 
        QPointF bleedBottomRight(offsetX + width + bleedRight, offsetY + height + bleedBottom);
1519
 
        QRectF  bleedBox(bleedTopLeft, bleedBottomRight);
1520
 
        painter->save();
1521
 
        painter->setLineWidth(0.5);
1522
 
        painter->setPen(ScColorShade(Qt::black, 100), 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin );
1523
 
        if (options.cropMarks)
1524
 
        {
1525
 
                FPoint start, end;
1526
 
                double left = offsetX, right = offsetX + width;
1527
 
                double bottom = offsetY + height, top = offsetY;
1528
 
                drawBoxMarks( painter, QRectF(QPointF(left, top), QPointF(right, bottom)), bleedBox, markOffs );
1529
 
        }
1530
 
        if (options.bleedMarks)
1531
 
        {
1532
 
                FPoint start, end;
1533
 
                double left = offsetX - bleedLeft, right = offsetX + width + bleedRight;
1534
 
                double bottom = offsetY + height + bleedBottom, top = offsetY - bleedTop;;
1535
 
                drawBoxMarks( painter, QRectF(QPointF(left, top), QPointF(right, bottom)), bleedBox, markOffs );
1536
 
        }
1537
 
        if (options.registrationMarks)
1538
 
        {
1539
 
                double posX = (2* offsetX + width) / 2.0 - 7.0;
1540
 
                double posY = (offsetY + height + bleedBottom + markOffs + 3.0);
1541
 
                painter->save();
1542
 
                painter->translate(posX, posY);
1543
 
                drawRegistrationCross( painter );
1544
 
                painter->restore();
1545
 
                posX = (2 * offsetX + width) / 2.0 - 7.0;
1546
 
                posY = (offsetY - bleedTop - markOffs - 17);
1547
 
                painter->save();
1548
 
                painter->translate(posX, posY);
1549
 
                drawRegistrationCross( painter );
1550
 
                painter->restore();
1551
 
 
1552
 
                posX = (offsetX - bleedLeft - markOffs - 17);
1553
 
                posY = (2 * offsetY + height) / 2.0 - 7.0;
1554
 
                painter->save();
1555
 
                painter->translate(posX, posY);
1556
 
                drawRegistrationCross( painter );
1557
 
                painter->restore();
1558
 
                posX = (offsetX + width + bleedRight + markOffs + 3.0);
1559
 
                posY = (2 * offsetY + height) / 2.0 - 7.0;
1560
 
                painter->save();
1561
 
                painter->translate(posX, posY);
1562
 
                drawRegistrationCross( painter );
1563
 
                painter->restore();
1564
 
        }
1565
 
        if (options.colorMarks)
1566
 
        {
1567
 
                int shade = 100;
1568
 
                double startX = offsetX + 6.0;
1569
 
                double startY = offsetY - bleedTop - markOffs - 16.0;
1570
 
                ScColorShade strokecolor( ScColor(0, 0, 0, 255), 100 );
1571
 
                painter->setPen( strokecolor, 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin );
1572
 
                painter->setFillMode( ScPainterExBase::Solid );
1573
 
                for (int i = 0; i < 11; i++ )
1574
 
                {
1575
 
                        ScColorShade fillcolor( ScColor(0, 0, 0, 255), shade );
1576
 
                        painter->setBrush( fillcolor );
1577
 
                        painter->drawRect( startX + i * 14, startY, 14, 14 );
1578
 
                        shade -= 10;
1579
 
                }
1580
 
                startX = offsetX + width - 20.0;
1581
 
                painter->setBrush( ScColorShade(ScColor(0, 0, 0, 255), 50) );
1582
 
                painter->drawRect( startX, startY, 14, 14 );
1583
 
                startX -= 14;
1584
 
                painter->setBrush( ScColorShade(ScColor(0, 0, 255, 0), 50) );
1585
 
                painter->drawRect( startX, startY, 14, 14 );
1586
 
                startX -= 14;
1587
 
                painter->setBrush( ScColorShade(ScColor(0, 255, 0, 0), 50) );
1588
 
                painter->drawRect( startX, startY, 14, 14 );
1589
 
                startX -= 14;
1590
 
                painter->setBrush( ScColorShade(ScColor(255, 0, 0, 0), 50) );
1591
 
                painter->drawRect( startX, startY, 14, 14 );
1592
 
                startX -= 14;
1593
 
                painter->setBrush( ScColorShade(ScColor(255, 255, 0, 0), 100) );
1594
 
                painter->drawRect( startX, startY, 14, 14 );
1595
 
                startX -= 14;
1596
 
                painter->setBrush( ScColorShade(ScColor(255, 0, 255, 0), 100) );
1597
 
                painter->drawRect( startX, startY, 14, 14 );
1598
 
                startX -= 14;
1599
 
                painter->setBrush( ScColorShade(ScColor(0, 255, 255, 0), 100) );
1600
 
                painter->drawRect( startX, startY, 14, 14 );
1601
 
                startX -= 14;
1602
 
                painter->setBrush( ScColorShade(ScColor(0, 0, 0, 255), 100) );
1603
 
                painter->drawRect( startX, startY, 14, 14 );
1604
 
                startX -= 14;
1605
 
                painter->setBrush( ScColorShade(ScColor(0, 0, 255, 0), 100) );
1606
 
                painter->drawRect( startX, startY, 14, 14 );
1607
 
                startX -= 14;
1608
 
                painter->setBrush( ScColorShade(ScColor(0, 255, 0, 0), 100) );
1609
 
                painter->drawRect( startX, startY, 14, 14 );
1610
 
                startX -= 14;
1611
 
                painter->setBrush( ScColorShade(ScColor(255, 0, 0, 0), 100) );
1612
 
                painter->drawRect( startX, startY, 14, 14 );
1613
 
        }
1614
 
        painter->restore();
1615
 
}
1616
 
 
1617
 
void ScPageOutput::drawBoxMarks( ScPainterExBase* painter, const QRectF& box, const QRectF& bleedBox, double offset )
1618
 
{
1619
 
        FPoint start, end;
1620
 
        double left   = box.left(), right = box.right();
1621
 
        double bottom = box.bottom(), top = box.top();
1622
 
        double bleedLeft = bleedBox.left(), bleedRight = bleedBox.right();
1623
 
        double bleedBottom = bleedBox.bottom(), bleedTop = bleedBox.top();
1624
 
        // Top Left
1625
 
        start.setXY( bleedLeft - offset, top );
1626
 
        end.setXY  ( bleedLeft - offset - 20, top );
1627
 
        painter->drawLine(start, end);
1628
 
        start.setXY( left, bleedTop - offset );
1629
 
        end.setXY  ( left, bleedTop - offset - 20);
1630
 
        painter->drawLine(start, end);
1631
 
        // Top Right
1632
 
        start.setXY( bleedRight + offset, top );
1633
 
        end.setXY  ( bleedRight + offset + 20, top );
1634
 
        painter->drawLine(start, end);
1635
 
        start.setXY( right, bleedTop - offset );
1636
 
        end.setXY  ( right, bleedTop - offset - 20);
1637
 
        painter->drawLine(start, end);
1638
 
        // Bottom Left
1639
 
        start.setXY( bleedLeft - offset, bottom );
1640
 
        end.setXY  ( bleedLeft - offset - 20, bottom  );
1641
 
        painter->drawLine(start, end);
1642
 
        start.setXY( left, bleedBottom + offset );
1643
 
        end.setXY  ( left, bleedBottom + offset + 20);
1644
 
        painter->drawLine(start, end);
1645
 
        // Bottom Right
1646
 
        start.setXY( bleedRight + offset, bottom );
1647
 
        end.setXY  ( bleedRight + offset + 20, bottom  );
1648
 
        painter->drawLine(start, end);
1649
 
        start.setXY( right, bleedBottom + offset );
1650
 
        end.setXY  ( right, bleedBottom + offset + 20);
1651
 
        painter->drawLine(start, end);
1652
 
}
1653
 
 
1654
 
void ScPageOutput::drawRegistrationCross( ScPainterExBase* painter )
1655
 
{
1656
 
        painter->save();
1657
 
 
1658
 
        painter->newPath();
1659
 
        painter->moveTo(0.0, 7.0);
1660
 
        painter->lineTo(14.0, 7.0);
1661
 
        painter->strokePath();
1662
 
 
1663
 
        painter->newPath();
1664
 
        painter->moveTo(7.0, 0.0);
1665
 
        painter->lineTo(7.0, 14.0);
1666
 
        painter->strokePath();
1667
 
 
1668
 
        painter->newPath();
1669
 
        painter->moveTo(13.0, 7.0);
1670
 
        painter->curveTo( FPoint(13.0, 10.31383), FPoint(10.31383, 13.0), FPoint(7.0, 13.0) );
1671
 
        painter->curveTo( FPoint(3.68629, 13.0) , FPoint(1.0, 10.31383) , FPoint(1.0, 7.0) );
1672
 
        painter->curveTo( FPoint(1.0, 3.68629)  , FPoint(3.68629, 1.0) , FPoint(7.0, 1.0) );
1673
 
        painter->curveTo( FPoint(10.31383, 1.0) , FPoint(13.0, 3.68629) , FPoint(13.0, 7.0) );
1674
 
        painter->strokePath();
1675
 
 
1676
 
        painter->newPath();
1677
 
        painter->moveTo(10.5, 7.0);
1678
 
        painter->curveTo( FPoint(10.5, 8.93307), FPoint(8.93307, 10.5), FPoint(7.0, 10.5) );
1679
 
        painter->curveTo( FPoint(5.067, 10.5)  , FPoint(3.5, 8.93307) , FPoint(3.5, 7.0) );
1680
 
        painter->curveTo( FPoint(3.5, 5.067)   , FPoint(5.067, 3.5)   , FPoint(7.0, 3.5) );
1681
 
        painter->curveTo( FPoint(8.93307, 3.5) , FPoint(10.5, 5.067)  , FPoint(10.5, 7.0) );
1682
 
        painter->strokePath();
1683
 
 
1684
 
        painter->restore();
1685
 
}
1686
 
 
1687
 
void ScPageOutput::fillPath( PageItem* item, ScPainterExBase* painter, const QRect& clip )
1688
 
{
1689
 
        if( painter->fillMode() == ScPainterExBase::Pattern && !painter->hasCapability(ScPainterExBase::patterns) )
1690
 
                drawPattern( item, painter, clip );
1691
 
        else
1692
 
                painter->fillPath();
1693
 
}
1694
 
 
1695
 
void ScPageOutput::strokePath( PageItem* item, ScPainterExBase* painter, const QRect& clip )
1696
 
{
1697
 
        painter->strokePath();
1698
 
}
1699
 
 
1700
 
 
1701
 
 
1702