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

« back to all changes in this revision

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

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
 
to the COPYING file provided with the program. Following this notice may exist
4
 
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
 
for which a new license (GPL+exception) is in place.
6
 
*/
7
 
/***************************************************************************
8
 
                          pslib.cpp  -  description
9
 
                             -------------------
10
 
    begin                : Sat May 26 2001
11
 
    copyright            : (C) 2001 by Franz Schmid
12
 
    email                : Franz.Schmid@altmuehlnet.de
13
 
 ***************************************************************************/
14
 
 
15
 
/***************************************************************************
16
 
 *                                                                         *
17
 
 *   This program is free software; you can redistribute it and/or modify  *
18
 
 *   it under the terms of the GNU General Public License as published by  *
19
 
 *   the Free Software Foundation; either version 2 of the License, or     *
20
 
 *   (at your option) any later version.                                   *
21
 
 *                                                                         *
22
 
 ***************************************************************************/
23
 
 
24
 
#include "pslib.h"
25
 
 
26
 
#include <cstdlib>
27
 
 
28
 
#include <QBuffer>
29
 
#include <QByteArray>
30
 
#include <QColor>
31
 
#include <QFileInfo>
32
 
#include <QFontInfo>
33
 
#include <QImage>
34
 
#include <QList>
35
 
#include <QRegExp>
36
 
#include <QStack>
37
 
 
38
 
#include "cmsettings.h"
39
 
#include "commonstrings.h"
40
 
#include "scconfig.h"
41
 
#include "pluginapi.h"
42
 
#include "multiprogressdialog.h"
43
 
#include "pageitem_latexframe.h"
44
 
#include "prefsmanager.h"
45
 
#include "scclocale.h"
46
 
#include "sccolorengine.h"
47
 
#include "scfonts.h"
48
 
#include "scribusapp.h"
49
 
#include "scribusdoc.h"
50
 
#include "scribus.h"
51
 
#include "scribuscore.h"
52
 
#include "selection.h"
53
 
#include "scpattern.h"
54
 
#include "scstreamfilter_ascii85.h"
55
 
#include "scstreamfilter_flate.h"
56
 
#include "util.h"
57
 
#include "util_formats.h"
58
 
#include "util_math.h"
59
 
 
60
 
#include "text/nlsconfig.h"
61
 
 
62
 
PSLib::PSLib(PrintOptions &options, bool psart, SCFonts &AllFonts, QMap<QString, QMap<uint, FPointArray> > DocFonts, ColorList DocColors, bool pdf, bool spot)
63
 
{
64
 
        Options = options;
65
 
        optimization = OptimizeCompat;
66
 
        usingGUI=ScCore->usingGUI();
67
 
        abortExport=false;
68
 
        QString tmp, tmp2, tmp3, tmp4, CHset;
69
 
        QStringList wt;
70
 
        Seiten = 0;
71
 
        User = "";
72
 
        Creator = "Scribus" + QString(VERSION);
73
 
        Titel = "";
74
 
        FillColor = "0.0 0.0 0.0 0.0";
75
 
        StrokeColor = "0.0 0.0 0.0 0.0";
76
 
        Header = psart ? "%!PS-Adobe-3.0\n" : "%!PS-Adobe-3.0 EPSF-3.0\n";
77
 
        BBox = "";
78
 
        BBoxH = "";
79
 
        psExport = psart;
80
 
        isPDF = pdf;
81
 
        UsedFonts.clear();
82
 
        Fonts = "";
83
 
        FontDesc = "";
84
 
        GraySc = false;
85
 
        DoSep = false;
86
 
        abortExport = false;
87
 
        useSpotColors = spot;
88
 
        GrayCalc =  "/setcmykcolor {exch 0.11 mul add exch 0.59 mul add exch 0.3 mul add\n";
89
 
        GrayCalc += "               dup 1 gt {pop 1} if 1 exch sub oldsetgray} bind def\n";
90
 
        GrayCalc += "/setrgbcolor {0.11 mul exch 0.59 mul add exch 0.3 mul add\n";
91
 
        GrayCalc += "              oldsetgray} bind def\n";
92
 
        Farben = "";
93
 
        FNamen = "";
94
 
        CMYKColor cmykValues;
95
 
        ColorList::Iterator itf;
96
 
        int c, m, y, k;
97
 
        int spotCount = 1;
98
 
        bool erst = true;
99
 
        colorsToUse = DocColors;
100
 
        spotMap.clear();
101
 
        colorDesc = "";
102
 
        for (itf = DocColors.begin(); itf != DocColors.end(); ++itf)
103
 
        {
104
 
                if (((itf->isSpotColor()) || (itf->isRegistrationColor())) && (useSpotColors))
105
 
                {
106
 
                        ScColorEngine::getCMYKValues(*itf, DocColors.document(), cmykValues);
107
 
                        cmykValues.getValues(c, m, y, k);
108
 
                        colorDesc += "/Spot"+QString::number(spotCount)+" { [ /Separation (";
109
 
                        if (DocColors[itf.key()].isRegistrationColor())
110
 
                                colorDesc += "All";
111
 
                        else
112
 
                                colorDesc += itf.key();
113
 
                        colorDesc += ")\n";
114
 
                        colorDesc += "/DeviceCMYK\n{\ndup "+ToStr(static_cast<double>(c) / 255)+"\nmul exch dup ";
115
 
                        colorDesc += ToStr(static_cast<double>(m) / 255)+"\nmul exch dup ";
116
 
                        colorDesc += ToStr(static_cast<double>(y) / 255)+"\nmul exch ";
117
 
                        colorDesc += ToStr(static_cast<double>(k) / 255)+" mul }] setcolorspace setcolor} bind def\n";
118
 
                        spotMap.insert(itf.key(), "Spot"+QString::number(spotCount));
119
 
                        ++spotCount;
120
 
                }
121
 
                if ((itf.key() != "Cyan") && (itf.key() != "Magenta") && (itf.key() != "Yellow") && (itf.key() != "Black") && DocColors[itf.key()].isSpotColor())
122
 
                {
123
 
                        ScColorEngine::getCMYKValues(DocColors[itf.key()], DocColors.document(), cmykValues);
124
 
                        cmykValues.getValues(c, m, y, k);
125
 
                        if (!erst)
126
 
                        {
127
 
                                Farben += "%%+ ";
128
 
                                FNamen += "%%+ ";
129
 
                        }
130
 
                        Farben += ToStr(static_cast<double>(c) / 255) + " " + ToStr(static_cast<double>(m) / 255) + " ";
131
 
                        Farben += ToStr(static_cast<double>(y) / 255) + " " + ToStr(static_cast<double>(k) / 255) + " (" + itf.key() + ")\n";
132
 
                        FNamen += "(" + itf.key() + ")\n";
133
 
                        erst = false;
134
 
                }
135
 
        }
136
 
        QMap<QString, QString> psNameMap;
137
 
        QMap<QString, QMap<uint, FPointArray> >::Iterator it;
138
 
        int a = 0;
139
 
        for (it = DocFonts.begin(); it != DocFonts.end(); ++it)
140
 
        {
141
 
                // Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed
142
 
                // Subset also font whose postscript name conflicts with an already used font
143
 
                ScFace &face (AllFonts[it.key()]);
144
 
                ScFace::FontType type = face.type();
145
 
                QString encodedName = face.psName().simplified().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" );
146
 
 
147
 
                if ((type == ScFace::TTF) || (face.isOTF()) || (face.subset()) || psNameMap.contains(encodedName))
148
 
                {
149
 
                        QMap<uint, FPointArray>& RealGlyphs(it.value());
150
 
                        // Handle possible PostScript name conflict in oft/ttf fonts
151
 
                        int psNameIndex = 1;
152
 
                        QString initialName = encodedName;
153
 
                        while (psNameMap.contains(encodedName))
154
 
                        {
155
 
                                encodedName = QString("%1-%2").arg(initialName).arg(psNameIndex);
156
 
                                ++psNameIndex;
157
 
                        }
158
 
                        FontDesc += "/" + encodedName + " " + IToStr(RealGlyphs.count()+1) + " dict def\n";
159
 
                        FontDesc += encodedName + " begin\n";
160
 
                        QMap<uint,FPointArray>::Iterator ig;
161
 
                        for (ig = RealGlyphs.begin(); ig != RealGlyphs.end(); ++ig)
162
 
                        {
163
 
                                FontDesc += "/G"+IToStr(ig.key())+" { newpath\n";
164
 
                                FPoint np, np1, np2;
165
 
                                bool nPath = true;
166
 
                                if (ig.value().size() > 3)
167
 
                                {
168
 
                                        for (uint poi = 0; poi < ig.value().size()-3; poi += 4)
169
 
                                        {
170
 
                                                if (ig.value().point(poi).x() > 900000)
171
 
                                                {
172
 
                                                        FontDesc += "cl\n";
173
 
                                                        nPath = true;
174
 
                                                        continue;
175
 
                                                }
176
 
                                                if (nPath)
177
 
                                                {
178
 
                                                        np = ig.value().point(poi);
179
 
                                                        FontDesc += ToStr(np.x()) + " " + ToStr(-np.y()) + " m\n";
180
 
                                                        nPath = false;
181
 
                                                }
182
 
                                                np = ig.value().point(poi+1);
183
 
                                                np1 = ig.value().point(poi+3);
184
 
                                                np2 = ig.value().point(poi+2);
185
 
                                                FontDesc += ToStr(np.x()) + " " + ToStr(-np.y()) + " " +
186
 
                                                                ToStr(np1.x()) + " " + ToStr(-np1.y()) + " " +
187
 
                                                                ToStr(np2.x()) + " " + ToStr(-np2.y()) + " cu\n";
188
 
                                        }
189
 
                                }
190
 
                                FontDesc += "cl\n} bind def\n";
191
 
                        }
192
 
                        FontDesc += "end\n";
193
 
                        FontSubsetMap.insert(face.scName(), encodedName);
194
 
                }
195
 
                else
196
 
                {
197
 
                        UsedFonts.insert(it.key(), "/Fo"+IToStr(a));
198
 
                        Fonts += "/Fo" + IToStr(a) + " /" + encodedName + " findfont definefont pop\n";
199
 
                        if (AllFonts[it.key()].embedPs())
200
 
                        {
201
 
                                QString tmp;
202
 
                                if(face.EmbedFont(tmp))
203
 
                                {
204
 
                                        FontDesc += "%%BeginFont: " + encodedName + "\n";
205
 
                                        FontDesc += tmp + "\n%%EndFont\n";
206
 
                                }
207
 
                        }
208
 
                        GlyphList gl;
209
 
                        face.glyphNames(gl);
210
 
                        GlyphsOfFont.insert(it.key(), gl);
211
 
                        a++;
212
 
                }
213
 
                psNameMap.insert(encodedName, face.scName());
214
 
        }
215
 
        Prolog = "%%BeginProlog\n";
216
 
        Prolog += "/Scribusdict 100 dict def\n";
217
 
        Prolog += "Scribusdict begin\n";
218
 
        Prolog += "/sp {showpage} bind def\n";
219
 
        Prolog += "/oldsetgray /setgray load def\n";
220
 
        Prolog += "/cmyk {setcmykcolor} def\n";
221
 
        Prolog += "/m {moveto} bind def\n";
222
 
        Prolog += "/l {lineto} bind def\n";
223
 
        Prolog += "/li {lineto} bind def\n";
224
 
        Prolog += "/cu {curveto} bind def\n";
225
 
        Prolog += "/cl {closepath} bind def\n";
226
 
        Prolog += "/gs {gsave} bind def\n";
227
 
        Prolog += "/gr {grestore} bind def\n";
228
 
        Prolog += "/tr {translate} bind def\n";
229
 
        Prolog += "/ro {rotate} bind def\n";
230
 
        Prolog += "/sh {show} bind def\n";
231
 
        Prolog += "/shg {setcmykcolor moveto glyphshow} def\n";
232
 
        Prolog += "/shgsp {moveto glyphshow} def\n";
233
 
        Prolog += "/sc {scale} bind def\n";
234
 
        Prolog += "/se {selectfont} bind def\n";
235
 
        Prolog += "/sf {setfont} bind def\n";
236
 
        Prolog += "/sw {setlinewidth} bind def\n";
237
 
        Prolog += "/f  {findfont} bind def\n";
238
 
        Prolog += "/fi {fill} bind def\n";
239
 
        Prolog += "/st {stroke} bind def\n";
240
 
        Prolog += "/shgf {gs dup scale begin cvx exec fill end gr} bind def\n";
241
 
        Prolog += "/shgs {gs dup 1 exch div currentlinewidth mul sw dup scale\n";
242
 
        Prolog += "       begin cvx exec st end gr} bind def\n";
243
 
        Prolog += "/bEPS {\n";
244
 
        Prolog += "    /b4_Inc_state save def\n";
245
 
        Prolog += "    /dict_count countdictstack def\n";
246
 
        Prolog += "    /op_count count 1 sub def\n";
247
 
        Prolog += "    userdict begin\n";
248
 
        Prolog += "    /showpage { } def\n";
249
 
        Prolog += "    0 setgray 0 setlinecap\n";
250
 
        Prolog += "    1 setlinewidth 0 setlinejoin\n";
251
 
        Prolog += "    10 setmiterlimit [ ] 0 setdash newpath\n";
252
 
        Prolog += "    /languagelevel where\n";
253
 
        Prolog += "    {pop languagelevel\n";
254
 
        Prolog += "    1 ne\n";
255
 
        Prolog += "    {false setstrokeadjust false setoverprint\n";
256
 
        Prolog += "    } if } if } bind def\n";
257
 
        Prolog += "/eEPS { count op_count sub {pop} repeat\n";
258
 
        Prolog += "    countdictstack dict_count sub {end} repeat\n";
259
 
        Prolog += "    b4_Inc_state restore } bind def\n";
260
 
        Prolog += "    end\n";
261
 
        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks))
262
 
                Prolog += "/rb { [ /Separation (All)\n/DeviceCMYK { dup 0 mul exch dup 0 mul exch dup 0 mul exch 1 mul }\n] setcolorspace setcolor} bind def\n";
263
 
        Prolog += "%%EndProlog\n";
264
 
}
265
 
 
266
 
void PSLib::PutStream(const QString& c)
267
 
{
268
 
        QByteArray utf8Array = c.toUtf8();
269
 
        spoolStream.writeRawData(utf8Array.data(), utf8Array.length());
270
 
}
271
 
 
272
 
void PSLib::PutStream(const QByteArray& array, bool hexEnc)
273
 
{
274
 
        if(hexEnc)
275
 
                WriteASCII85Bytes(array);
276
 
        else
277
 
                spoolStream.writeRawData(array.data(), array.size());
278
 
}
279
 
 
280
 
void PSLib::PutStream(const char* array, int length, bool hexEnc)
281
 
{
282
 
        if(hexEnc)
283
 
                WriteASCII85Bytes((const unsigned char*) array, length);
284
 
        else
285
 
                spoolStream.writeRawData(array, length);
286
 
}
287
 
 
288
 
bool PSLib::PutImageToStream(ScImage& image, int plate)
289
 
{
290
 
        bool writeSucceed = false;
291
 
        ScASCII85EncodeFilter asciiEncode(&spoolStream);
292
 
        ScFlateEncodeFilter   flateEncode(&asciiEncode);
293
 
        if (flateEncode.openFilter())
294
 
        {
295
 
                writeSucceed  = image.writePSImageToFilter(&flateEncode, plate);
296
 
                writeSucceed &= flateEncode.closeFilter();
297
 
        }
298
 
        return writeSucceed;
299
 
}
300
 
 
301
 
bool PSLib::PutImageToStream(ScImage& image, const QByteArray& mask, int plate)
302
 
{
303
 
        bool writeSucceed = false;
304
 
        ScASCII85EncodeFilter asciiEncode(&spoolStream);
305
 
        ScFlateEncodeFilter   flateEncode(&asciiEncode);
306
 
        if (flateEncode.openFilter())
307
 
        {
308
 
                writeSucceed  = image.writePSImageToFilter(&flateEncode, mask, plate);
309
 
                writeSucceed &= flateEncode.closeFilter();
310
 
        }
311
 
        return writeSucceed;
312
 
}
313
 
 
314
 
bool PSLib::PutImageDataToStream(const QByteArray& image)
315
 
{
316
 
        bool writeSucceed = false;
317
 
        ScASCII85EncodeFilter asciiEncode(&spoolStream);
318
 
        ScFlateEncodeFilter   flateEncode(&asciiEncode);
319
 
        if (flateEncode.openFilter())
320
 
        {
321
 
                writeSucceed  = flateEncode.writeData(image, image.size());
322
 
                writeSucceed &= flateEncode.closeFilter();
323
 
        }
324
 
        return writeSucceed;
325
 
}
326
 
 
327
 
bool PSLib::PutInterleavedImageMaskToStream(const QByteArray& image, const QByteArray& mask, bool gray)
328
 
{
329
 
        int pending = 0;
330
 
        int bIndex  = 0;
331
 
        unsigned char bytes[1505];
332
 
        const unsigned char* imageData = (const unsigned char*) image.constData();
333
 
        const unsigned char* maskData  = (const unsigned char*) mask.constData();
334
 
        bool  writeSuccess = true;
335
 
 
336
 
        int channels = gray ? 1 : 4;
337
 
        int pixels   = image.size() / channels;
338
 
        assert((image.size() % channels) == 0);
339
 
        assert( mask.size() >= pixels );
340
 
 
341
 
        ScASCII85EncodeFilter asciiEncode(&spoolStream);
342
 
        ScFlateEncodeFilter   flateEncode(&asciiEncode);
343
 
        if (!flateEncode.openFilter()) 
344
 
                return false;
345
 
 
346
 
        for (int i = 0; i < pixels; ++i)
347
 
        {
348
 
                bIndex = 4 *i;
349
 
                bytes[pending++] = maskData [i];
350
 
                bytes[pending++] = *imageData++; // cyan/black
351
 
                if (channels > 1)
352
 
                {
353
 
                        bytes[pending++] = *imageData++; // magenta
354
 
                        bytes[pending++] = *imageData++; // yellow
355
 
                        bytes[pending++] = *imageData++; // green
356
 
                }
357
 
                if (pending >= 1500)
358
 
                {
359
 
                        writeSuccess &= flateEncode.writeData((const char* ) bytes, pending);
360
 
                        pending = 0;
361
 
                }
362
 
        }
363
 
        // To close the stream
364
 
        if (pending > 0)
365
 
                writeSuccess &= flateEncode.writeData((const char* ) bytes, pending);
366
 
        writeSuccess &= flateEncode.closeFilter();
367
 
        return writeSuccess;
368
 
}
369
 
 
370
 
void PSLib::WriteASCII85Bytes(const QByteArray& array)
371
 
{
372
 
        WriteASCII85Bytes((const unsigned char*) array.data(), array.size());
373
 
}
374
 
 
375
 
void PSLib::WriteASCII85Bytes(const unsigned char* array, int length)
376
 
{
377
 
        ScASCII85EncodeFilter filter(&spoolStream);
378
 
        filter.openFilter();
379
 
        filter.writeData((const char*) array, length);
380
 
        filter.closeFilter();
381
 
}
382
 
 
383
 
QString PSLib::ToStr(double c)
384
 
{
385
 
        QString cc;
386
 
        return cc.setNum(c);
387
 
}
388
 
 
389
 
QString PSLib::IToStr(int c)
390
 
{
391
 
        QString cc;
392
 
        return cc.setNum(c);
393
 
}
394
 
 
395
 
QString PSLib::MatrixToStr(double m11, double m12, double m21, double m22, double x, double y)
396
 
{
397
 
        QString cc("[%1 %2 %3 %4 %5 %6]");
398
 
        return  cc.arg(m11).arg(m12).arg(m21).arg(m22).arg(x).arg(y);
399
 
}
400
 
 
401
 
void PSLib::PS_set_Info(QString art, QString was)
402
 
{
403
 
        if (art == "Author")
404
 
                User = was;
405
 
        if (art == "Creator")
406
 
                Creator = was;
407
 
        if (art == "Title")
408
 
                Titel = was;
409
 
}
410
 
 
411
 
bool PSLib::PS_set_file(QString fn)
412
 
{
413
 
        Spool.setFileName(fn);
414
 
        if (Spool.exists())
415
 
                Spool.remove();
416
 
        bool ret = Spool.open(QIODevice::WriteOnly);
417
 
        spoolStream.setDevice(&Spool);
418
 
        return ret;
419
 
}
420
 
 
421
 
bool PSLib::PS_begin_doc(ScribusDoc *doc, double x, double y, double breite, double hoehe, int numpage, bool doDev, bool sep, bool farb, bool ic, bool gcr)
422
 
{
423
 
        m_Doc = doc;
424
 
        PutStream(Header);
425
 
        PutStream("%%For: " + User + "\n");
426
 
        PutStream("%%Title: " + Titel + "\n");
427
 
        PutStream("%%Creator: " + Creator + "\n");
428
 
        PutStream("%%Pages: " + IToStr(numpage) + "\n");
429
 
//      if(breite<hoehe)
430
 
        if(breite < hoehe || !psExport)
431
 
        {
432
 
                BBox = "%%BoundingBox: " + IToStr(qRound(x)) + " " + IToStr(qRound(y)) + " " + IToStr(qRound(breite)) + " " + IToStr(qRound(hoehe)) + "\n";
433
 
                BBoxH = "%%HiResBoundingBox: " + ToStr(x) + " " + ToStr(y) + " " + ToStr(breite) + " " + ToStr(hoehe) + "\n";
434
 
        }
435
 
        else
436
 
        {
437
 
                
438
 
                BBox = "%%BoundingBox: " + IToStr(qRound(x)) + " " + IToStr(qRound(y)) + " " + IToStr(qRound(hoehe)) + " " + IToStr(qRound(breite)) + "\n";
439
 
                BBoxH = "%%HiResBoundingBox: " + ToStr(x) + " " + ToStr(y) + " " + ToStr(hoehe) + " " + ToStr(breite) + "\n";
440
 
        }
441
 
 //     if (!Art)
442
 
//      {
443
 
                PutStream(BBox);
444
 
                PutStream(BBoxH);
445
 
//      }
446
 
        if (!FNamen.isEmpty())
447
 
                PutStream("%%DocumentCustomColors: "+FNamen);
448
 
        if (!Farben.isEmpty())
449
 
                PutStream("%%CMYKCustomColor: "+Farben);
450
 
        PutStream("%%LanguageLevel: 3\n");
451
 
        PutStream("%%EndComments\n");
452
 
        PutStream(Prolog);
453
 
        PutStream("%%BeginSetup\n");
454
 
        if (isPDF)
455
 
                PutStream("/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse\n");
456
 
        if (!FontDesc.isEmpty())
457
 
                PutStream(FontDesc);
458
 
        if ((!colorDesc.isEmpty()) && (!sep))
459
 
                PutStream(colorDesc);
460
 
//      PutStream("Scribusdict begin\n");
461
 
        PutStream(Fonts);
462
 
        if (GraySc)
463
 
                PutStream(GrayCalc);
464
 
        Optimization optim = optimization;
465
 
        optimization = OptimizeSize;
466
 
        QStringList patterns = m_Doc->getUsedPatterns();
467
 
        for (int c = 0; c < patterns.count(); ++c)
468
 
        {
469
 
                ScPattern pa = m_Doc->docPatterns[patterns[c]];
470
 
                for (int em = 0; em < pa.items.count(); ++em)
471
 
                {
472
 
                        PageItem* item = pa.items.at(em);
473
 
                        if ((item->asImageFrame()) && (item->PictureIsAvailable) && (!item->Pfile.isEmpty()) && (item->printEnabled()) && (!sep) && (farb))
474
 
                        {
475
 
                                if (!PS_ImageData(item, item->Pfile, item->itemName(), item->IProfile, item->UseEmbedded, ic))
476
 
                                        return false;
477
 
                        }
478
 
                }
479
 
                uint patHash = qHash(patterns[c]);
480
 
                PutStream("/Pattern"+QString::number(patHash)+" 8 dict def\n");
481
 
                PutStream("Pattern"+QString::number(patHash)+" begin\n");
482
 
                PutStream("/PatternType 1 def\n");
483
 
                PutStream("/PaintType 1 def\n");
484
 
                PutStream("/TilingType 1 def\n");
485
 
                PutStream("/BBox [ 0 0 "+ToStr(pa.width)+" "+ToStr(pa.height)+"] def\n");
486
 
                PutStream("/XStep "+ToStr(pa.width)+" def\n");
487
 
                PutStream("/YStep "+ToStr(pa.height)+" def\n");
488
 
                PutStream("/PaintProc {\n");
489
 
                QIODevice *spStream = spoolStream.device();
490
 
                QByteArray buf;
491
 
                // Qt4 QBuffer b(buf);
492
 
                QBuffer b(&buf);
493
 
                b.open( QIODevice::WriteOnly );
494
 
                spoolStream.setDevice(&b);
495
 
                QStack<PageItem*> groupStack;
496
 
                for (int em = 0; em < pa.items.count(); ++em)
497
 
                {
498
 
                        PageItem* item = pa.items.at(em);
499
 
                        if (item->isGroupControl)
500
 
                        {
501
 
                                PS_save();
502
 
                                FPointArray cl = item->PoLine.copy();
503
 
                                QMatrix mm;
504
 
                                mm.translate(item->gXpos, item->gYpos - pa.height);
505
 
                                mm.rotate(item->rotation());
506
 
                                cl.map( mm );
507
 
                                SetClipPath(&cl);
508
 
                                PS_closepath();
509
 
                                PS_clip(true);
510
 
                                groupStack.push(item->groupsLastItem);
511
 
                                continue;
512
 
                        }
513
 
                        PutStream("{\n");
514
 
                        PS_save();
515
 
                        PS_translate(item->gXpos, pa.height - item->gYpos);
516
 
                        ProcessItem(m_Doc, m_Doc->Pages->at(0), item, 0, sep, farb, ic, gcr, false, true, true);
517
 
                        PS_restore();
518
 
                        if (groupStack.count() != 0)
519
 
                        {
520
 
                                while (item == groupStack.top())
521
 
                                {
522
 
                                        PS_restore();
523
 
                                        groupStack.pop();
524
 
                                        if (groupStack.count() == 0)
525
 
                                                break;
526
 
                                }
527
 
                        }
528
 
                        PutStream("} exec\n");
529
 
                }
530
 
                for (int em = 0; em < pa.items.count(); ++em)
531
 
                {
532
 
                        int h, s, v, k;
533
 
                        PageItem* item = pa.items.at(em);
534
 
                        if (!item->isTableItem)
535
 
                                continue;
536
 
                        if ((item->lineColor() == CommonStrings::None) || (item->lineWidth() == 0.0))
537
 
                                continue;
538
 
                        PutStream("{\n");
539
 
                        PS_save();
540
 
                        PS_translate(item->gXpos, pa.height - item->gYpos);
541
 
                        PS_rotate(item->rotation());
542
 
                        if (item->lineColor() != CommonStrings::None)
543
 
                        {
544
 
                                SetColor(item->lineColor(), item->lineShade(), &h, &s, &v, &k, gcr);
545
 
                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
546
 
                        }
547
 
                        PS_setlinewidth(item->lineWidth());
548
 
                        PS_setcapjoin(Qt::SquareCap, item->PLineJoin);
549
 
                        PS_setdash(item->PLineArt, item->DashOffset, item->DashValues);
550
 
                        if ((item->TopLine) || (item->RightLine) || (item->BottomLine) || (item->LeftLine))
551
 
                        {
552
 
                                if (item->TopLine)
553
 
                                {
554
 
                                        PS_moveto(0, 0);
555
 
                                        PS_lineto(item->width(), 0);
556
 
                                }
557
 
                                if (item->RightLine)
558
 
                                {
559
 
                                        PS_moveto(item->width(), 0);
560
 
                                        PS_lineto(item->width(), -item->height());
561
 
                                }
562
 
                                if (item->BottomLine)
563
 
                                {
564
 
                                        PS_moveto(0, -item->height());
565
 
                                        PS_lineto(item->width(), -item->height());
566
 
                                }
567
 
                                if (item->LeftLine)
568
 
                                {
569
 
                                        PS_moveto(0, 0);
570
 
                                        PS_lineto(0, -item->height());
571
 
                                }
572
 
                                putColor(item->lineColor(), item->lineShade(), false);
573
 
                        }
574
 
                        PS_restore();
575
 
                        PutStream("} exec\n");
576
 
                }
577
 
                spoolStream.setDevice(spStream);
578
 
                PutStream(buf);
579
 
                PutStream("} def\n");
580
 
                PutStream("end\n");
581
 
        }
582
 
        optimization = optim;
583
 
//      PutStream("end\n");
584
 
//      PutStream("%%EndSetup\n");
585
 
        Prolog = "";
586
 
        FontDesc = "";
587
 
        return true;
588
 
}
589
 
 
590
 
QString PSLib::PSEncode(QString in)
591
 
{
592
 
        static QRegExp badchars("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]");
593
 
        QString tmp = "";
594
 
        tmp = in.simplified().replace( badchars, "_" );
595
 
        return tmp;
596
 
}
597
 
 
598
 
void PSLib::PS_TemplateStart(QString Name)
599
 
{
600
 
        PutStream("/"+PSEncode(Name)+"\n{\n");
601
 
}
602
 
 
603
 
void PSLib::PS_UseTemplate(QString Name)
604
 
{
605
 
        PutStream(PSEncode(Name)+"\n");
606
 
}
607
 
 
608
 
void PSLib::PS_TemplateEnd()
609
 
{
610
 
        PutStream("} bind def\n");
611
 
}
612
 
 
613
 
void PSLib::PS_begin_page(Page* pg, MarginStruct* Ma, bool Clipping)
614
 
{
615
 
        double bleedRight = 0.0;
616
 
        double bleedLeft = 0.0;
617
 
        double markOffs = 0.0;
618
 
        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks))
619
 
                markOffs = 20.0 + Options.markOffset;
620
 
        GetBleeds(pg, bleedLeft, bleedRight);
621
 
        double maxBoxX = pg->width()+bleedLeft+bleedRight+markOffs*2.0;
622
 
        double maxBoxY = pg->height()+Options.bleeds.Bottom+Options.bleeds.Top+markOffs*2.0;
623
 
        Seiten++;
624
 
        PutStream("%%Page: " + IToStr(Seiten) + " " + IToStr(Seiten) + "\n");
625
 
        PutStream("%%PageOrientation: ");
626
 
// when creating EPS files determine the orientation from the bounding box
627
 
        if (!psExport)
628
 
        {
629
 
                if ((pg->width() - Ma->Left - Ma->Right) <= (pg->height() - Ma->Bottom - Ma->Top))
630
 
                        PutStream("Portrait\n");
631
 
                else
632
 
                        PutStream("Landscape\n");
633
 
        }       
634
 
        else
635
 
        {
636
 
                if (pg->PageOri == 0)
637
 
                {
638
 
                        PutStream("Portrait\n");
639
 
                        PutStream("%%PageBoundingBox: 0 0 "+IToStr(qRound(maxBoxX))+" "+IToStr(qRound(maxBoxY))+"\n");
640
 
                        PutStream("%%PageCropBox: "+ToStr(bleedLeft+markOffs)+" "+ToStr(Options.bleeds.Bottom+markOffs)+" "+ToStr(maxBoxX-bleedRight-markOffs*2.0)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs*2.0)+"\n");
641
 
                }
642
 
                else
643
 
                {
644
 
                        PutStream("Landscape\n");
645
 
                        PutStream("%%PageBoundingBox: 0 0 "+IToStr(qRound(maxBoxY))+" "+IToStr(qRound(maxBoxX))+"\n");
646
 
                        PutStream("%%PageCropBox: "+ToStr(bleedLeft+markOffs)+" "+ToStr(Options.bleeds.Bottom+markOffs)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs*2.0)+" "+ToStr(maxBoxX-bleedRight-markOffs*2.0)+"\n");
647
 
                }
648
 
        }
649
 
        PutStream("Scribusdict begin\n");
650
 
        if ((psExport) && (Options.setDevParam))
651
 
        {
652
 
                PutStream("<< /PageSize [ "+ToStr(maxBoxX)+" "+ToStr(maxBoxY)+" ]\n");
653
 
                PutStream(">> setpagedevice\n");
654
 
        }
655
 
        PutStream("save\n");
656
 
        if(pg->PageOri == 1 && psExport)
657
 
                PutStream("90 rotate 0 "+IToStr(qRound(maxBoxY))+" neg translate\n");
658
 
        PutStream("/DeviceCMYK setcolorspace\n");
659
 
        PutStream(ToStr(bleedLeft+markOffs)+" "+ToStr(Options.bleeds.Bottom+markOffs)+" tr\n");
660
 
        ActPage = pg;
661
 
        if (Clipping)
662
 
        {
663
 
                PDev = ToStr(Ma->Left) + " " + ToStr(Ma->Bottom) + " m\n";
664
 
                PDev += ToStr(pg->width() - Ma->Right) + " " + ToStr(Ma->Bottom) + " li\n";
665
 
                PDev += ToStr(pg->width() - Ma->Right) + " " + ToStr(pg->height() - Ma->Top) + " li\n";
666
 
                PDev += ToStr(Ma->Left) + " " + ToStr(pg->height() - Ma->Top) + " li cl clip newpath\n";
667
 
                PutStream(PDev);
668
 
        }
669
 
}
670
 
 
671
 
void PSLib::PS_end_page()
672
 
{
673
 
        PutStream("%%PageTrailer\nrestore\n");
674
 
        double markOffs = 0.0;
675
 
        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks))
676
 
                markOffs = 20.0 + Options.markOffset;
677
 
        double bleedRight, bleedLeft;
678
 
        GetBleeds(ActPage, bleedLeft, bleedRight);
679
 
        double maxBoxX = ActPage->width()+bleedLeft+bleedRight+markOffs*2.0;
680
 
        double maxBoxY = ActPage->height()+Options.bleeds.Bottom+Options.bleeds.Top+markOffs*2.0;
681
 
        PutStream("gs\n");
682
 
        if(ActPage->PageOri == 1 && psExport)
683
 
                PutStream("90 rotate 0 "+IToStr(qRound(maxBoxY))+" neg translate\n");
684
 
        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks))
685
 
        {
686
 
                PutStream("gs\n");
687
 
                PS_setlinewidth(0.5);
688
 
                PutStream("[] 0 setdash\n");
689
 
                PutStream("0 setlinecap\n");
690
 
                PutStream("0 setlinejoin\n");
691
 
                PutStream("1 rb\n");
692
 
                if (Options.cropMarks)
693
 
                {
694
 
                // Bottom Left
695
 
                        PutStream("0 "+ToStr(markOffs+Options.bleeds.Bottom)+" m\n");
696
 
                        PutStream(ToStr(20.0)+" "+ToStr(markOffs+Options.bleeds.Bottom)+" li\n");
697
 
                        PutStream("st\n");
698
 
                        PutStream(ToStr(markOffs+bleedLeft)+" 0 m\n");
699
 
                        PutStream(ToStr(markOffs+bleedLeft)+" 20 li\n");
700
 
                        PutStream("st\n");
701
 
                // Top Left
702
 
                        PutStream("0 "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" m\n");
703
 
                        PutStream(ToStr(20.0)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" li\n");
704
 
                        PutStream("st\n");
705
 
                        PutStream(ToStr(markOffs+bleedLeft)+" "+ToStr(maxBoxY)+" m\n");
706
 
                        PutStream(ToStr(markOffs+bleedLeft)+" "+ToStr(maxBoxY-20.0)+" li\n");
707
 
                        PutStream("st\n");
708
 
                // Bottom Right
709
 
                        PutStream(ToStr(maxBoxX)+" "+ToStr(markOffs+Options.bleeds.Bottom)+" m\n");
710
 
                        PutStream(ToStr(maxBoxX-20.0)+" "+ToStr(markOffs+Options.bleeds.Bottom)+" li\n");
711
 
                        PutStream("st\n");
712
 
                        PutStream(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(0.0)+" m\n");
713
 
                        PutStream(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(20.0)+" li\n");
714
 
                        PutStream("st\n");
715
 
                // Top Right
716
 
                        PutStream(ToStr(maxBoxX)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" m\n");
717
 
                        PutStream(ToStr(maxBoxX-20.0)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" li\n");
718
 
                        PutStream("st\n");
719
 
                        PutStream(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(maxBoxY)+" m\n");
720
 
                        PutStream(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(maxBoxY-20.0)+" li\n");
721
 
                        PutStream("st\n");
722
 
                }
723
 
                if (Options.bleedMarks)
724
 
                {
725
 
                        PutStream("gs\n");
726
 
                        PutStream("[3 1 1 1] 0 setdash\n");
727
 
                // Bottom Left
728
 
                        PutStream("0 "+ToStr(markOffs)+" m\n");
729
 
                        PutStream(ToStr(20.0)+" "+ToStr(markOffs)+" li\n");
730
 
                        PutStream("st\n");
731
 
                        PutStream(ToStr(markOffs)+" 0 m\n");
732
 
                        PutStream(ToStr(markOffs)+" 20 l\n");
733
 
                        PutStream("st\n");
734
 
                // Top Left
735
 
                        PutStream("0 "+ToStr(maxBoxY-markOffs)+" m\n");
736
 
                        PutStream(ToStr(20.0)+" "+ToStr(maxBoxY-markOffs)+" li\n");
737
 
                        PutStream("st\n");
738
 
                        PutStream(ToStr(markOffs)+" "+ToStr(maxBoxY)+" m\n");
739
 
                        PutStream(ToStr(markOffs)+" "+ToStr(maxBoxY-20.0)+" li\n");
740
 
                        PutStream("st\n");
741
 
                // Bottom Right
742
 
                        PutStream(ToStr(maxBoxX)+" "+ToStr(markOffs)+" m\n");
743
 
                        PutStream(ToStr(maxBoxX-20.0)+" "+ToStr(markOffs)+" li\n");
744
 
                        PutStream("st\n");
745
 
                        PutStream(ToStr(maxBoxX-markOffs)+" "+ToStr(0.0)+" m\n");
746
 
                        PutStream(ToStr(maxBoxX-markOffs)+" "+ToStr(20.0)+" li\n");
747
 
                        PutStream("st\n");
748
 
                // Top Right
749
 
                        PutStream(ToStr(maxBoxX)+" "+ToStr(maxBoxY-markOffs)+" m\n");
750
 
                        PutStream(ToStr(maxBoxX-20.0)+" "+ToStr(maxBoxY-markOffs)+" li\n");
751
 
                        PutStream("st\n");
752
 
                        PutStream(ToStr(maxBoxX-markOffs)+" "+ToStr(maxBoxY)+" m\n");
753
 
                        PutStream(ToStr(maxBoxX-markOffs)+" "+ToStr(maxBoxY-20.0)+" li\n");
754
 
                        PutStream("st\n");
755
 
                        PutStream("gr\n");
756
 
                }
757
 
                if (Options.registrationMarks)
758
 
                {
759
 
                        QString regCross = "0 7 m\n14 7 li\n7 0 m\n7 14 li\n13 7 m\n13 10.31383 10.31383 13 7 13 cu\n3.68629 13 1 10.31383 1 7 cu\n1 3.68629 3.68629 1 7 1 cu\n";
760
 
                        regCross += "10.31383 1 13 3.68629 13 7 cu\ncl\n10.5 7 m\n10.5 8.93307 8.93307 10.5 7 10.5 cu\n5.067 10.5 3.5 8.93307 3.5 7 cu\n";
761
 
                        regCross += "3.5 5.067 5.067 3.5 7 3.5 cu\n8.93307 3.5 10.5 5.067 10.5 7 cu\ncl\nst\n";
762
 
                        PutStream("gs\n");
763
 
                        PutStream(ToStr(maxBoxX / 2.0 - 7.0)+" 3 tr\n");
764
 
                        PutStream(regCross);
765
 
                        PutStream("gr\n");
766
 
                        PutStream("gs\n");
767
 
                        PutStream("3 "+ToStr(maxBoxY / 2.0 - 7.0)+" tr\n");
768
 
                        PutStream(regCross);
769
 
                        PutStream("gr\n");
770
 
                        PutStream("gs\n");
771
 
                        PutStream(ToStr(maxBoxX / 2.0 - 7.0)+" "+ToStr(maxBoxY - 17.0)+" tr\n");
772
 
                        PutStream(regCross);
773
 
                        PutStream("gr\n");
774
 
                        PutStream("gs\n");
775
 
                        PutStream(ToStr(maxBoxX - 17.0)+" "+ToStr(maxBoxY / 2.0 - 7.0)+" tr\n");
776
 
                        PutStream(regCross);
777
 
                        PutStream("gr\n");
778
 
                }
779
 
                if (Options.colorMarks)
780
 
                {
781
 
                        double startX = markOffs+bleedLeft+6.0;
782
 
                        double startY = maxBoxY - 18.0;
783
 
                        PutStream("0 0 0 1 cmyk\n");
784
 
                        double col = 1.0;
785
 
                        for (int bl = 0; bl < 11; bl++)
786
 
                        {
787
 
                                PutStream("0 0 0 "+ToStr(col)+" cmyk\n");
788
 
                                PutStream(ToStr(startX+bl*14.0)+" "+ToStr(startY)+" 14 14 rectfill\n");
789
 
                                PutStream("0 0 0 1 cmyk\n");
790
 
                                PutStream(ToStr(startX+bl*14.0)+" "+ToStr(startY)+" 14 14 rectstroke\n");
791
 
                                col -= 0.1;
792
 
                        }
793
 
                        startX = maxBoxX-bleedRight-markOffs-20.0;
794
 
                        PutStream("0 0 0 0.5 cmyk\n");
795
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
796
 
                        PutStream("0 0 0 1 cmyk\n");
797
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
798
 
                        startX -= 14.0;
799
 
                        PutStream("0 0 0.5 0 cmyk\n");
800
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
801
 
                        PutStream("0 0 0 1 cmyk\n");
802
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
803
 
                        startX -= 14.0;
804
 
                        PutStream("0 0.5 0 0 cmyk\n");
805
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
806
 
                        PutStream("0 0 0 1 cmyk\n");
807
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
808
 
                        startX -= 14.0;
809
 
                        PutStream("0.5 0 0 0 cmyk\n");
810
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
811
 
                        PutStream("0 0 0 1 cmyk\n");
812
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
813
 
                        startX -= 14.0;
814
 
                        PutStream("1 1 0 0 cmyk\n");
815
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
816
 
                        PutStream("0 0 0 1 cmyk\n");
817
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
818
 
                        startX -= 14.0;
819
 
                        PutStream("1 0 1 0 cmyk\n");
820
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
821
 
                        PutStream("0 0 0 1 cmyk\n");
822
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
823
 
                        startX -= 14.0;
824
 
                        PutStream("0 1 1 0 cmyk\n");
825
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
826
 
                        PutStream("0 0 0 1 cmyk\n");
827
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
828
 
                        startX -= 14.0;
829
 
                        PutStream("0 0 0 1 cmyk\n");
830
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
831
 
                        PutStream("0 0 0 1 cmyk\n");
832
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
833
 
                        startX -= 14.0;
834
 
                        PutStream("0 0 1 0 cmyk\n");
835
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
836
 
                        PutStream("0 0 0 1 cmyk\n");
837
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
838
 
                        startX -= 14.0;
839
 
                        PutStream("0 1 0 0 cmyk\n");
840
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
841
 
                        PutStream("0 0 0 1 cmyk\n");
842
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
843
 
                        startX -= 14.0;
844
 
                        PutStream("1 0 0 0 cmyk\n");
845
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
846
 
                        PutStream("0 0 0 1 cmyk\n");
847
 
                        PutStream(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
848
 
                }
849
 
                PutStream("gr\n");
850
 
        }
851
 
        PutStream("gr\n");
852
 
        PutStream("sp\n");
853
 
        PutStream("end\n");
854
 
}
855
 
 
856
 
void PSLib::PS_curve(double x1, double y1, double x2, double y2, double x3, double y3)
857
 
{
858
 
        PutStream(ToStr(x1) + " " + ToStr(y1) + " " + ToStr(x2) + " " + ToStr(y2) + " " + ToStr(x3) + " " + ToStr(y3) + " cu\n");
859
 
}
860
 
 
861
 
void PSLib::PS_moveto(double x, double y)
862
 
{
863
 
        PutStream(ToStr(x) + " " + ToStr(y) + " m\n");
864
 
}
865
 
 
866
 
void PSLib::PS_lineto(double x, double y)
867
 
{
868
 
        PutStream(ToStr(x) + " " + ToStr(y) + " li\n");
869
 
}
870
 
 
871
 
void PSLib::PS_closepath()
872
 
{
873
 
        PutStream("cl\n");
874
 
}
875
 
 
876
 
void PSLib::PS_translate(double x, double y)
877
 
{
878
 
        PutStream(ToStr(x) + " " + ToStr(y) + " tr\n");
879
 
}
880
 
 
881
 
void PSLib::PS_scale(double x, double y)
882
 
{
883
 
        PutStream(ToStr(x) + " " + ToStr(y) + " sc\n");
884
 
}
885
 
 
886
 
void PSLib::PS_rotate(double x)
887
 
{
888
 
        PutStream(ToStr(x) + " ro\n");
889
 
}
890
 
 
891
 
void PSLib::PS_clip(bool mu)
892
 
{
893
 
        PutStream( mu ? "eoclip newpath\n" : "clip newpath\n" );
894
 
}
895
 
 
896
 
void PSLib::PS_save()
897
 
{
898
 
        PutStream("gs\n");
899
 
}
900
 
 
901
 
void PSLib::PS_restore()
902
 
{
903
 
        PutStream("gr\n");
904
 
}
905
 
 
906
 
void PSLib::PS_setcmykcolor_fill(double c, double m, double y, double k)
907
 
{
908
 
        FillColor = ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k);
909
 
}
910
 
 
911
 
void PSLib::PS_setcmykcolor_dummy()
912
 
{
913
 
        PutStream("0 0 0 0 cmyk\n");
914
 
}
915
 
 
916
 
void PSLib::PS_setcmykcolor_stroke(double c, double m, double y, double k)
917
 
{
918
 
        StrokeColor = ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k);
919
 
}
920
 
 
921
 
void PSLib::PS_setlinewidth(double w)
922
 
{
923
 
        PutStream(ToStr(w) + " sw\n");
924
 
        LineW = w;
925
 
}
926
 
 
927
 
void PSLib::PS_setdash(Qt::PenStyle st, double offset, QVector<double> dash)
928
 
{
929
 
        if (dash.count() != 0)
930
 
        {
931
 
                PutStream("[ ");
932
 
                QVector<double>::iterator it;
933
 
                for ( it = dash.begin(); it != dash.end(); ++it )
934
 
                {
935
 
                        PutStream(ToStr(*it)+" ");
936
 
                }
937
 
                PutStream("] "+ToStr(offset)+" setdash\n");
938
 
        }
939
 
        else
940
 
                PutStream("["+getDashString(st, LineW)+"] 0 setdash\n");
941
 
}
942
 
 
943
 
void PSLib::PS_setcapjoin(Qt::PenCapStyle ca, Qt::PenJoinStyle jo)
944
 
{
945
 
        switch (ca)
946
 
                {
947
 
                case Qt::FlatCap:
948
 
                        PutStream("0 setlinecap\n");
949
 
                        break;
950
 
                case Qt::SquareCap:
951
 
                        PutStream("2 setlinecap\n");
952
 
                        break;
953
 
                case Qt::RoundCap:
954
 
                        PutStream("1 setlinecap\n");
955
 
                        break;
956
 
                default:
957
 
                        PutStream("0 setlinecap\n");
958
 
                        break;
959
 
                }
960
 
        switch (jo)
961
 
                {
962
 
                case Qt::MiterJoin:
963
 
                        PutStream("0 setlinejoin\n");
964
 
                        break;
965
 
                case Qt::BevelJoin:
966
 
                        PutStream("2 setlinejoin\n");
967
 
                        break;
968
 
                case Qt::RoundJoin:
969
 
                        PutStream("1 setlinejoin\n");
970
 
                        break;
971
 
                default:
972
 
                        PutStream("0 setlinejoin\n");
973
 
                        break;
974
 
                }
975
 
}
976
 
 
977
 
void PSLib::PS_selectfont(QString f, double s)
978
 
{
979
 
        PutStream(UsedFonts[f] + " " + ToStr(s) + " se\n");
980
 
}
981
 
 
982
 
void PSLib::PS_fill()
983
 
{
984
 
        if (fillRule)
985
 
                PutStream(FillColor + " cmyk eofill\n");
986
 
        else
987
 
                PutStream(FillColor + " cmyk fill\n");
988
 
}
989
 
 
990
 
void PSLib::PS_fillspot(QString color, double shade)
991
 
{
992
 
        if (fillRule)
993
 
                PutStream(ToStr(shade / 100.0)+" "+spotMap[color]+" eofill\n");
994
 
        else
995
 
                PutStream(ToStr(shade / 100.0)+" "+spotMap[color]+" fill\n");
996
 
}
997
 
 
998
 
void PSLib::PS_strokespot(QString color, double shade)
999
 
{
1000
 
        PutStream(ToStr(shade / 100.0)+" "+spotMap[color]+" st\n");
1001
 
}
1002
 
 
1003
 
void PSLib::PS_stroke()
1004
 
{
1005
 
        PutStream(StrokeColor + " cmyk st\n");
1006
 
}
1007
 
 
1008
 
void PSLib::PS_fill_stroke()
1009
 
{
1010
 
        PS_save();
1011
 
        PS_fill();
1012
 
        PS_restore();
1013
 
        PS_stroke();
1014
 
}
1015
 
 
1016
 
void PSLib::PS_newpath()
1017
 
{
1018
 
        PutStream("newpath\n");
1019
 
}
1020
 
 
1021
 
void PSLib::PS_MultiRadGradient(double w, double h, double x, double y, QList<double> Stops, QStringList Colors, QStringList colorNames, QList<int> colorShades)
1022
 
{
1023
 
        bool first = true;
1024
 
        bool oneSameSpot = false;
1025
 
        bool oneSpot1 = false;
1026
 
        bool oneSpot2 = false;
1027
 
        bool twoSpot = false;
1028
 
        int cc = 0;
1029
 
        int mc = 0;
1030
 
        int yc = 0;
1031
 
        int kc = 0;
1032
 
        CMYKColor cmykValues;
1033
 
        PutStream( "clipsave\n" );
1034
 
        PutStream("eoclip\n");
1035
 
        for (int c = 0; c < Colors.count()-1; ++c)
1036
 
        {
1037
 
                oneSameSpot = false;
1038
 
                oneSpot1 = false;
1039
 
                oneSpot2 = false;
1040
 
                twoSpot = false;
1041
 
                QString spot1 = colorNames[c];
1042
 
                QString spot2 = colorNames[c+1];
1043
 
                PutStream("<<\n");
1044
 
                PutStream("/ShadingType 3\n");
1045
 
                if (DoSep)
1046
 
                        PutStream("/ColorSpace /DeviceGray\n");
1047
 
                else
1048
 
                {
1049
 
                        if (spotMap.contains(colorNames[c]))
1050
 
                                oneSpot1 = true;
1051
 
                        if  (spotMap.contains(colorNames[c+1]))
1052
 
                                oneSpot2 = true;
1053
 
                        if (oneSpot1 && oneSpot2)
1054
 
                        {
1055
 
                                oneSameSpot = (colorNames[c] == colorNames[c+1]);
1056
 
                                oneSpot1 = oneSpot2 = false;
1057
 
                                twoSpot  = true;
1058
 
                        }
1059
 
                        if (((!oneSpot1) && (!oneSpot2) && (!twoSpot)) || (!useSpotColors) || (GraySc))
1060
 
                        {
1061
 
                                if (GraySc)
1062
 
                                        PutStream("/ColorSpace /DeviceGray\n");
1063
 
                                else
1064
 
                                        PutStream("/ColorSpace /DeviceCMYK\n");
1065
 
                                // #7654 : Necessary when printing spot colors to grayscale
1066
 
                                oneSpot1 = oneSpot2 = oneSameSpot = twoSpot = false;
1067
 
                        }
1068
 
                        else
1069
 
                        {
1070
 
                                PutStream("/ColorSpace [ /DeviceN [");
1071
 
                                if (oneSameSpot)
1072
 
                                {
1073
 
                                        PutStream(" ("+spot1+") ]\n");
1074
 
                                }
1075
 
                                else if (oneSpot1)
1076
 
                                {
1077
 
                                        PutStream(" /Cyan /Magenta /Yellow /Black ("+spot1+") ]\n");
1078
 
                                        ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues);
1079
 
                                        cmykValues.getValues(cc, mc, yc, kc);
1080
 
                                }
1081
 
                                else if (oneSpot2)
1082
 
                                {
1083
 
                                        PutStream(" /Cyan /Magenta /Yellow /Black ("+spot2+") ]\n");
1084
 
                                        ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c+1]], m_Doc, cmykValues);
1085
 
                                        cmykValues.getValues(cc, mc, yc, kc);
1086
 
                                }
1087
 
                                else if (twoSpot)
1088
 
                                {
1089
 
                                        PutStream(" ("+spot1+") ("+spot2+") ]\n");
1090
 
                                }
1091
 
                                PutStream("/DeviceCMYK\n");
1092
 
                                PutStream("{\n");
1093
 
                                if (oneSameSpot)
1094
 
                                {
1095
 
                                        ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues);
1096
 
                                        cmykValues.getValues(cc, mc, yc, kc);
1097
 
                                        PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul exch\n");
1098
 
                                        PutStream("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul exch\n");
1099
 
                                        PutStream("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul exch\n");
1100
 
                                        PutStream("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul exch pop\n");
1101
 
                                }
1102
 
                                else if (twoSpot)
1103
 
                                {
1104
 
                                        ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues);
1105
 
                                        cmykValues.getValues(cc, mc, yc, kc);
1106
 
                                        PutStream("exch\n");
1107
 
                                        PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 1.0 exch sub exch\n");
1108
 
                                        PutStream("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 1.0 exch sub exch\n");
1109
 
                                        PutStream("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 1.0 exch sub exch\n");
1110
 
                                        PutStream("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 1.0 exch sub exch pop 5 -1 roll\n");
1111
 
                                        ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c+1]], m_Doc, cmykValues);
1112
 
                                        cmykValues.getValues(cc, mc, yc, kc);
1113
 
                                        PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 1.0 exch sub 6 -1 roll mul 1.0 exch sub 5 1 roll\n");
1114
 
                                        PutStream("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 1.0 exch sub 5 -1 roll mul 1.0 exch sub 4 1 roll\n");
1115
 
                                        PutStream("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 1.0 exch sub 4 -1 roll mul 1.0 exch sub 3 1 roll\n");
1116
 
                                        PutStream("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 1.0 exch sub 3 -1 roll mul 1.0 exch sub 2 1 roll pop\n");
1117
 
                                }
1118
 
                                else
1119
 
                                {
1120
 
                                        PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 1.0 exch sub 6 -1 roll 1.0 exch sub mul 1.0 exch sub 5 1 roll\n");
1121
 
                                        PutStream("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 1.0 exch sub 5 -1 roll 1.0 exch sub mul 1.0 exch sub 4 1 roll\n");
1122
 
                                        PutStream("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 1.0 exch sub 4 -1 roll 1.0 exch sub mul 1.0 exch sub 3 1 roll\n");
1123
 
                                        PutStream("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 1.0 exch sub 3 -1 roll 1.0 exch sub mul 1.0 exch sub 2 1 roll pop\n");
1124
 
                                }
1125
 
                                PutStream("} ]\n");
1126
 
                        }
1127
 
                }
1128
 
                PutStream("/BBox [0 "+ToStr(h)+" "+ToStr(w)+" 0]\n");
1129
 
                if (Colors.count() == 2)
1130
 
                        PutStream("/Extend [true true]\n");
1131
 
                else
1132
 
                {
1133
 
                        if (first)
1134
 
                                PutStream("/Extend [false true]\n");
1135
 
                        else
1136
 
                        {
1137
 
                                if (c == Colors.count()-2)
1138
 
                                        PutStream("/Extend [true false]\n");
1139
 
                                else
1140
 
                                        PutStream("/Extend [false false]\n");
1141
 
                        }
1142
 
                }
1143
 
                PutStream("/Coords ["+ToStr(x)+" "+ToStr(y)+" "+ToStr(Stops.at(c+1))+" "+ToStr(x)+" "+ToStr(y)+" "+ToStr(Stops.at(c))+"]\n");
1144
 
                PutStream("/Function\n");
1145
 
                PutStream("<<\n");
1146
 
                PutStream("/FunctionType 2\n");
1147
 
                PutStream("/Domain [0 1]\n");
1148
 
                if (DoSep)
1149
 
                {
1150
 
                        int pla = Plate - 1 < 0 ? 3 : Plate - 1;
1151
 
                        QStringList cols1 = Colors[c+1].split(" ", QString::SkipEmptyParts);
1152
 
                        QStringList cols2 = Colors[c].split(" ", QString::SkipEmptyParts);
1153
 
                        PutStream("/C1 ["+ToStr(1 - ScCLocale::toDoubleC(cols1[pla]))+"]\n");
1154
 
                        PutStream("/C0 ["+ToStr(1 - ScCLocale::toDoubleC(cols2[pla]))+"]\n");
1155
 
                }
1156
 
                else
1157
 
                {
1158
 
                        if (useSpotColors)
1159
 
                        {
1160
 
                                if (oneSameSpot)
1161
 
                                {
1162
 
                                        PutStream("/C1 ["+ToStr(colorShades[c] / 100.0)+"]\n");
1163
 
                                        PutStream("/C0 ["+ToStr(colorShades[c+1] / 100.0)+"]\n");
1164
 
                                }
1165
 
                                else if (oneSpot1)
1166
 
                                {
1167
 
                                        PutStream("/C1 [0 0 0 0 "+ToStr(colorShades[c] / 100.0)+"]\n");
1168
 
                                        PutStream("/C0 ["+Colors[c+1]+" 0 ]\n");
1169
 
                                }
1170
 
                                else if (oneSpot2)
1171
 
                                {
1172
 
                                        PutStream("/C1 ["+Colors[c]+" 0 ]\n");
1173
 
                                        PutStream("/C0 [0 0 0 0 "+ToStr(colorShades[c+1] / 100.0)+"]\n");
1174
 
                                }
1175
 
                                else if (twoSpot)
1176
 
                                {
1177
 
                                        PutStream("/C1 ["+ToStr(colorShades[c] / 100.0)+" 0]\n");
1178
 
                                        PutStream("/C0 [0 "+ToStr(colorShades[c+1] / 100.0)+"]\n");
1179
 
                                }
1180
 
                                else
1181
 
                                {
1182
 
                                        PutStream("/C1 ["+Colors[c]+"]\n");
1183
 
                                        PutStream("/C0 ["+Colors[c+1]+"]\n");
1184
 
                                }
1185
 
                        }
1186
 
                        else
1187
 
                        {
1188
 
                                PutStream("/C1 ["+Colors[c]+"]\n");
1189
 
                                PutStream("/C0 ["+Colors[c+1]+"]\n");
1190
 
                        }
1191
 
                }
1192
 
                PutStream("/N 1\n");
1193
 
                PutStream(">>\n");
1194
 
                PutStream(">>\n");
1195
 
                PutStream("shfill\n");
1196
 
                first = false;
1197
 
        }
1198
 
        PutStream("cliprestore\n");
1199
 
}
1200
 
 
1201
 
void PSLib::PS_MultiLinGradient(double w, double h, QList<double> Stops, QStringList Colors, QStringList colorNames, QList<int> colorShades)
1202
 
{
1203
 
        bool first = true;
1204
 
        bool oneSameSpot = false;
1205
 
        bool oneSpot1 = false;
1206
 
        bool oneSpot2 = false;
1207
 
        bool twoSpot = false;
1208
 
        int cc = 0;
1209
 
        int mc = 0;
1210
 
        int yc = 0;
1211
 
        int kc = 0;
1212
 
        CMYKColor cmykValues;
1213
 
        PutStream( "clipsave\n" );
1214
 
        PutStream("eoclip\n");
1215
 
        for (int c = 0; c < Colors.count()-1; ++c)
1216
 
        {
1217
 
                oneSameSpot = false;
1218
 
                oneSpot1 = false;
1219
 
                oneSpot2 = false;
1220
 
                twoSpot = false;
1221
 
                QRegExp badchars("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]");
1222
 
                QString spot1 = colorNames[c];
1223
 
                QString spot2 = colorNames[c+1];
1224
 
                PutStream("<<\n");
1225
 
                PutStream("/ShadingType 2\n");
1226
 
                if (DoSep)
1227
 
                        PutStream("/ColorSpace /DeviceGray\n");
1228
 
                else
1229
 
                {
1230
 
                        if (spotMap.contains(colorNames[c]))
1231
 
                                oneSpot1 = true;
1232
 
                        if (spotMap.contains(colorNames[c+1]))
1233
 
                                oneSpot2 = true;
1234
 
                        if (oneSpot1 && oneSpot2)
1235
 
                        {
1236
 
                                oneSameSpot = (colorNames[c] == colorNames[c+1]);
1237
 
                                oneSpot1 = oneSpot2 = false;
1238
 
                                twoSpot  = true;
1239
 
                        }
1240
 
                        if (((!oneSpot1) && (!oneSpot2) && (!twoSpot)) || (!useSpotColors) || (GraySc))
1241
 
                        {
1242
 
                                if (GraySc)
1243
 
                                        PutStream("/ColorSpace /DeviceGray\n");
1244
 
                                else
1245
 
                                        PutStream("/ColorSpace /DeviceCMYK\n");
1246
 
                                // #7654 : Necessary when printing spot colors to grayscale
1247
 
                                oneSpot1 = oneSpot2 = oneSameSpot = twoSpot = false;
1248
 
                        }
1249
 
                        else
1250
 
                        {
1251
 
                                PutStream("/ColorSpace [ /DeviceN [");
1252
 
                                if (oneSameSpot)
1253
 
                                {
1254
 
                                        PutStream(" ("+spot1+") ]\n");
1255
 
                                }
1256
 
                                else if (oneSpot1)
1257
 
                                {
1258
 
                                        PutStream(" /Cyan /Magenta /Yellow /Black ("+spot1+") ]\n");
1259
 
                                        ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues);
1260
 
                                        cmykValues.getValues(cc, mc, yc, kc);
1261
 
                                }
1262
 
                                else if (oneSpot2)
1263
 
                                {
1264
 
                                        PutStream(" /Cyan /Magenta /Yellow /Black ("+spot2+") ]\n");
1265
 
                                        ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c+1]], m_Doc, cmykValues);
1266
 
                                        cmykValues.getValues(cc, mc, yc, kc);
1267
 
                                }
1268
 
                                else if (twoSpot)
1269
 
                                {
1270
 
                                        PutStream(" ("+spot1+") ("+spot2+") ]\n");
1271
 
                                }
1272
 
                                PutStream("/DeviceCMYK\n");
1273
 
                                PutStream("{\n");
1274
 
                                if (oneSameSpot)
1275
 
                                {
1276
 
                                        ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues);
1277
 
                                        cmykValues.getValues(cc, mc, yc, kc);
1278
 
                                        PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul exch\n");
1279
 
                                        PutStream("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul exch\n");
1280
 
                                        PutStream("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul exch\n");
1281
 
                                        PutStream("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul exch pop\n");
1282
 
                                }
1283
 
                                else if (twoSpot)
1284
 
                                {
1285
 
                                        ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues);
1286
 
                                        cmykValues.getValues(cc, mc, yc, kc);
1287
 
                                        PutStream("exch\n");
1288
 
                                        PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 1.0 exch sub exch\n");
1289
 
                                        PutStream("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 1.0 exch sub exch\n");
1290
 
                                        PutStream("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 1.0 exch sub exch\n");
1291
 
                                        PutStream("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 1.0 exch sub exch pop 5 -1 roll\n");
1292
 
                                        ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c+1]], m_Doc, cmykValues);
1293
 
                                        cmykValues.getValues(cc, mc, yc, kc);
1294
 
                                        PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 1.0 exch sub 6 -1 roll mul 1.0 exch sub 5 1 roll\n");
1295
 
                                        PutStream("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 1.0 exch sub 5 -1 roll mul 1.0 exch sub 4 1 roll\n");
1296
 
                                        PutStream("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 1.0 exch sub 4 -1 roll mul 1.0 exch sub 3 1 roll\n");
1297
 
                                        PutStream("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 1.0 exch sub 3 -1 roll mul 1.0 exch sub 2 1 roll pop\n");
1298
 
                                }
1299
 
                                else
1300
 
                                {
1301
 
                                        PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 1.0 exch sub 6 -1 roll 1.0 exch sub mul 1.0 exch sub 5 1 roll\n");
1302
 
                                        PutStream("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 1.0 exch sub 5 -1 roll 1.0 exch sub mul 1.0 exch sub 4 1 roll\n");
1303
 
                                        PutStream("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 1.0 exch sub 4 -1 roll 1.0 exch sub mul 1.0 exch sub 3 1 roll\n");
1304
 
                                        PutStream("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 1.0 exch sub 3 -1 roll 1.0 exch sub mul 1.0 exch sub 2 1 roll pop\n");
1305
 
                                }
1306
 
                                PutStream("} ]\n");
1307
 
                        }
1308
 
                }
1309
 
                PutStream("/BBox [0 "+ToStr(h)+" "+ToStr(w)+" 0]\n");
1310
 
                if (Colors.count() == 2)
1311
 
                        PutStream("/Extend [true true]\n");
1312
 
                else
1313
 
                {
1314
 
                        if (first)
1315
 
                                PutStream("/Extend [true false]\n");
1316
 
                        else
1317
 
                        {
1318
 
                                if (c == Colors.count()-2)
1319
 
                                        PutStream("/Extend [false true]\n");
1320
 
                                else
1321
 
                                        PutStream("/Extend [false false]\n");
1322
 
                        }
1323
 
                }
1324
 
                first = false;
1325
 
                PutStream("/Coords ["+ToStr(Stops.at(c*2))+"  "+ToStr(Stops.at(c*2+1))+" "+ToStr(Stops.at(c*2+2))+" "+ToStr(Stops.at(c*2+3))+"]\n");
1326
 
                PutStream("/Function\n");
1327
 
                PutStream("<<\n");
1328
 
                PutStream("/FunctionType 2\n");
1329
 
                PutStream("/Domain [0 1]\n");
1330
 
                if (DoSep)
1331
 
                {
1332
 
                        int pla = Plate - 1 < 0 ? 3 : Plate - 1;
1333
 
                        QStringList cols1 = Colors[c].split(" ", QString::SkipEmptyParts);
1334
 
                        QStringList cols2 = Colors[c+1].split(" ", QString::SkipEmptyParts);
1335
 
                        PutStream("/C1 ["+ToStr(1 - ScCLocale::toDoubleC(cols1[pla]))+"]\n");
1336
 
                        PutStream("/C0 ["+ToStr(1 - ScCLocale::toDoubleC(cols2[pla]))+"]\n");
1337
 
                }
1338
 
                else
1339
 
                {
1340
 
                        if (useSpotColors)
1341
 
                        {
1342
 
                                if (oneSameSpot)
1343
 
                                {
1344
 
                                        PutStream("/C0 ["+ToStr(colorShades[c] / 100.0)+"]\n");
1345
 
                                        PutStream("/C1 ["+ToStr(colorShades[c+1] / 100.0)+"]\n");
1346
 
                                }
1347
 
                                else if (oneSpot1)
1348
 
                                {
1349
 
                                        PutStream("/C0 [0 0 0 0 "+ToStr(colorShades[c] / 100.0)+"]\n");
1350
 
                                        PutStream("/C1 ["+Colors[c+1]+" 0 ]\n");
1351
 
                                }
1352
 
                                else if (oneSpot2)
1353
 
                                {
1354
 
                                        PutStream("/C0 ["+Colors[c]+" 0 ]\n");
1355
 
                                        PutStream("/C1 [0 0 0 0 "+ToStr(colorShades[c+1] / 100.0)+"]\n");
1356
 
                                }
1357
 
                                else if (twoSpot)
1358
 
                                {
1359
 
                                        PutStream("/C0 ["+ToStr(colorShades[c] / 100.0)+" 0]\n");
1360
 
                                        PutStream("/C1 [0 "+ToStr(colorShades[c+1] / 100.0)+"]\n");
1361
 
                                }
1362
 
                                else
1363
 
                                {
1364
 
                                        PutStream("/C0 ["+Colors[c]+"]\n");
1365
 
                                        PutStream("/C1 ["+Colors[c+1]+"]\n");
1366
 
                                }
1367
 
                        }
1368
 
                        else
1369
 
                        {
1370
 
                                PutStream("/C0 ["+Colors[c]+"]\n");
1371
 
                                PutStream("/C1 ["+Colors[c+1]+"]\n");
1372
 
                        }
1373
 
                }
1374
 
                PutStream("/N 1\n");
1375
 
                PutStream(">>\n");
1376
 
                PutStream(">>\n");
1377
 
                PutStream("shfill\n");
1378
 
        }
1379
 
        PutStream("cliprestore\n");
1380
 
}
1381
 
 
1382
 
void PSLib::PS_show_xyG(QString font, uint glyph, double x, double y, QString colorName, double shade)
1383
 
{
1384
 
        QString glyphName;
1385
 
        glyphName = GlyphsOfFont[font].contains(glyph) ? GlyphsOfFont[font][glyph].second : QString(".notdef");
1386
 
 
1387
 
        QString colorString;
1388
 
        ScColor& color(colorsToUse[colorName]);
1389
 
        bool spot = false;
1390
 
        if (((color.isSpotColor()) || (color.isRegistrationColor())) && (useSpotColors))
1391
 
        {
1392
 
                if (!DoSep)
1393
 
                {
1394
 
                        colorString = ToStr(shade / 100.0)+" "+spotMap[colorName];
1395
 
                        spot = true;
1396
 
                }
1397
 
                else if ((colorName == currentSpot) || (color.isRegistrationColor()))
1398
 
                        colorString = "0 0 0 "+ToStr(shade / 100.0);
1399
 
                else
1400
 
                        colorString = "0 0 0 0";
1401
 
        }
1402
 
        else
1403
 
        {
1404
 
                int c, m, y, k;
1405
 
                SetColor(color, shade, &c, &m, &y, &k, Options.doGCR);
1406
 
                if (!DoSep || (Plate == 0 || Plate == 1 || Plate == 2 || Plate == 3))
1407
 
                        colorString = ToStr(c / 255.0) + " " + ToStr(m / 255.0) + " " + ToStr(y / 255.0) + " " + ToStr(k / 255.0);
1408
 
                else
1409
 
                        colorString = "0 0 0 0";
1410
 
        }
1411
 
        if (spot)
1412
 
        {
1413
 
                PutStream(colorString + "\n");
1414
 
                PutStream("/"+glyphName+" "+ToStr(x)+" "+ToStr(y)+" shgsp\n");
1415
 
        }
1416
 
        else
1417
 
                PutStream("/"+glyphName+" "+ToStr(x)+" "+ToStr(y)+" "+colorString+" shg\n");
1418
 
}
1419
 
 
1420
 
void PSLib::PS_show(double x, double y)
1421
 
{
1422
 
        PS_moveto(x, y);
1423
 
        PutStream("/hyphen glyphshow\n");
1424
 
}
1425
 
 
1426
 
void PSLib::PS_showSub(uint chr, QString font, double size, bool stroke)
1427
 
{
1428
 
        PutStream(" (G"+IToStr(chr)+") "+font+" "+ToStr(size / 10.0)+" ");
1429
 
        PutStream(stroke ? "shgs\n" : "shgf\n");
1430
 
}
1431
 
 
1432
 
bool PSLib::PS_ImageData(PageItem *c, QString fn, QString Name, QString Prof, bool UseEmbedded, bool UseProf)
1433
 
{
1434
 
        bool dummy;
1435
 
        QByteArray tmp;
1436
 
        QFileInfo fi = QFileInfo(fn);
1437
 
        QString ext = fi.suffix().toLower();
1438
 
        if (ext.isEmpty())
1439
 
                ext = getImageType(fn);
1440
 
        if (extensionIndicatesEPS(ext) && (c->pixm.imgInfo.type != ImageType7))
1441
 
        {
1442
 
                if (loadRawText(fn, tmp))
1443
 
                {
1444
 
                        PutStream("currentfile 1 (%ENDEPSDATA) /SubFileDecode filter /ReusableStreamDecode filter\n");
1445
 
                        PutStream("%%BeginDocument: " + fi.fileName() + "\n");
1446
 
                        if (getDouble(QString(tmp.mid(0, 4)), true) == 0xC5D0D3C6)
1447
 
                        {
1448
 
                                char* data = tmp.data();
1449
 
                                uint startPos = getDouble(QString(tmp.mid(4, 4)), false);
1450
 
                                uint length = getDouble(QString(tmp.mid(8, 4)), false);
1451
 
                                PutStream(data+startPos, length, false);
1452
 
                        }
1453
 
                        else
1454
 
                                PutStream(tmp, false);
1455
 
                        PutStream("\n%ENDEPSDATA\n");
1456
 
                        PutStream("%%EndDocument\n");
1457
 
                        PutStream("/"+PSEncode(Name)+"Bild exch def\n");
1458
 
                        return true;
1459
 
                }
1460
 
                return false;
1461
 
        }
1462
 
        ScImage image;
1463
 
        QByteArray imgArray;
1464
 
        image.imgInfo.valid = false;
1465
 
        image.imgInfo.clipPath = "";
1466
 
        image.imgInfo.PDSpathData.clear();
1467
 
        image.imgInfo.layerInfo.clear();
1468
 
        image.imgInfo.RequestProps = c->pixm.imgInfo.RequestProps;
1469
 
        image.imgInfo.isRequest = c->pixm.imgInfo.isRequest;
1470
 
        CMSettings cms(c->doc(), Prof, c->IRender);
1471
 
        if (!image.LoadPicture(fn, c->pixm.imgInfo.actualPageNumber, cms, UseEmbedded, UseProf, ScImage::CMYKData, 300, &dummy))
1472
 
        {
1473
 
                PS_Error_ImageLoadFailure(fn);
1474
 
                return false;
1475
 
        }
1476
 
        image.applyEffect(c->effectsInUse, colorsToUse, true);
1477
 
        QByteArray maskArray;
1478
 
        bool alphaLoaded = image.getAlpha(fn, c->pixm.imgInfo.actualPageNumber, maskArray, false, true, 300);
1479
 
        if (!alphaLoaded)
1480
 
        {
1481
 
                PS_Error_MaskLoadFailure(fn);
1482
 
                return false;
1483
 
        }
1484
 
        if ((maskArray.size() > 0) && (c->pixm.imgInfo.type != ImageType7))
1485
 
        {
1486
 
                PutStream("currentfile /ASCII85Decode filter /FlateDecode filter /ReusableStreamDecode filter\n");
1487
 
                if (!PutImageToStream(image, maskArray, -1))
1488
 
                {
1489
 
                        PS_Error_ImageDataWriteFailure();
1490
 
                        return false;
1491
 
                }
1492
 
                PutStream("/"+PSEncode(Name)+"Bild exch def\n");
1493
 
        }
1494
 
        else
1495
 
        {
1496
 
                PutStream("currentfile /ASCII85Decode filter /FlateDecode filter /ReusableStreamDecode filter\n");
1497
 
                if (!PutImageToStream(image, -1))
1498
 
                {
1499
 
                        PS_Error_ImageDataWriteFailure();
1500
 
                        return false;
1501
 
                }
1502
 
                PutStream("/"+PSEncode(Name)+"Bild exch def\n");
1503
 
                imgArray.resize(0);
1504
 
        }
1505
 
        return true;
1506
 
}
1507
 
 
1508
 
bool PSLib::PS_image(PageItem *c, double x, double y, QString fn, double scalex, double scaley, QString Prof, bool UseEmbedded, bool UseProf, QString Name)
1509
 
{
1510
 
        bool dummy;
1511
 
        QByteArray tmp;
1512
 
        QFileInfo fi = QFileInfo(fn);
1513
 
        QString ext = fi.suffix().toLower();
1514
 
        if (ext.isEmpty())
1515
 
                ext = getImageType(fn);
1516
 
        if (extensionIndicatesEPS(ext) && (c->pixm.imgInfo.type != ImageType7))
1517
 
        {
1518
 
                if (loadRawText(fn, tmp))
1519
 
                {
1520
 
                        PutStream("bEPS\n");
1521
 
                        PutStream(ToStr(PrefsManager::instance()->appPrefs.gs_Resolution / 72.0 * scalex) + " " + ToStr(PrefsManager::instance()->appPrefs.gs_Resolution / 72.0 * scaley) + " sc\n");
1522
 
                        PutStream(ToStr(-c->BBoxX+x * scalex) + " " + ToStr(y * scalex) + " tr\n");
1523
 
                        if (!Name.isEmpty())
1524
 
                        {
1525
 
                                PutStream(PSEncode(Name)+"Bild cvx exec\n");
1526
 
                                PutStream(PSEncode(Name)+"Bild resetfile\n");
1527
 
                        }
1528
 
                        else
1529
 
                        {
1530
 
                                PutStream("%%BeginDocument: " + fi.fileName() + "\n");
1531
 
                                        if (getDouble(QString(tmp.mid(0, 4)), true) == 0xC5D0D3C6)
1532
 
                                        {
1533
 
                                                char* data = tmp.data();
1534
 
                                                uint startPos = getDouble(tmp.mid(4, 4), false);
1535
 
                                                uint length = getDouble(tmp.mid(8, 4), false);
1536
 
                                                PutStream(data+startPos, length, false);
1537
 
                                        }
1538
 
                                        else
1539
 
                                                PutStream(tmp);
1540
 
                                        PutStream("\n%%EndDocument\n");
1541
 
                        }
1542
 
                        PutStream("eEPS\n");
1543
 
                        return true;
1544
 
                }
1545
 
                return false;
1546
 
        }
1547
 
        else
1548
 
        {
1549
 
                ScImage image;
1550
 
                QByteArray imgArray;
1551
 
                image.imgInfo.valid = false;
1552
 
                image.imgInfo.clipPath = "";
1553
 
                image.imgInfo.PDSpathData.clear();
1554
 
                image.imgInfo.layerInfo.clear();
1555
 
                image.imgInfo.RequestProps = c->pixm.imgInfo.RequestProps;
1556
 
                image.imgInfo.isRequest = c->pixm.imgInfo.isRequest;
1557
 
                CMSettings cms(c->doc(), Prof, c->IRender);
1558
 
                int resolution = 300;
1559
 
                if (c->asLatexFrame())
1560
 
                        resolution = c->asLatexFrame()->realDpi();
1561
 
                else if (c->pixm.imgInfo.type == ImageType7)
1562
 
                        resolution = 72;
1563
 
//              int resolution = (c->pixm.imgInfo.type == ImageType7) ? 72 : 300;
1564
 
                if ( !image.LoadPicture(fn, c->pixm.imgInfo.actualPageNumber, cms, UseEmbedded, UseProf, ScImage::CMYKData, resolution, &dummy) )
1565
 
                {
1566
 
                        PS_Error_ImageLoadFailure(fn);
1567
 
                        return false;
1568
 
                }
1569
 
                image.applyEffect(c->effectsInUse, colorsToUse, true);
1570
 
                int w = image.width();
1571
 
                int h = image.height();
1572
 
                PutStream(ToStr(x*scalex) + " " + ToStr(y*scaley) + " tr\n");
1573
 
                if ((extensionIndicatesPDF(ext)) && (!c->asLatexFrame()))
1574
 
                {
1575
 
                        scalex *= PrefsManager::instance()->appPrefs.gs_Resolution / 300.0;
1576
 
                        scaley *= PrefsManager::instance()->appPrefs.gs_Resolution / 300.0;
1577
 
                }
1578
 
//              PutStream(ToStr(x*scalex) + " " + ToStr(y*scaley) + " tr\n");
1579
 
                PutStream(ToStr(qRound(scalex*w)) + " " + ToStr(qRound(scaley*h)) + " sc\n");
1580
 
                PutStream(((!DoSep) && (!GraySc)) ? "/DeviceCMYK setcolorspace\n" : "/DeviceGray setcolorspace\n");
1581
 
                QByteArray maskArray;
1582
 
                ScImage img2;
1583
 
                img2.imgInfo.clipPath = "";
1584
 
                img2.imgInfo.PDSpathData.clear();
1585
 
                img2.imgInfo.layerInfo.clear();
1586
 
                img2.imgInfo.RequestProps = c->pixm.imgInfo.RequestProps;
1587
 
                img2.imgInfo.isRequest = c->pixm.imgInfo.isRequest;
1588
 
                if (c->pixm.imgInfo.type != ImageType7)
1589
 
                {
1590
 
                        bool alphaLoaded = img2.getAlpha(fn, c->pixm.imgInfo.actualPageNumber, maskArray, false, true, resolution);
1591
 
                        if (!alphaLoaded)
1592
 
                        {
1593
 
                                PS_Error_MaskLoadFailure(fn);
1594
 
                                return false;
1595
 
                        }
1596
 
                }
1597
 
                if ((maskArray.size() > 0) && (c->pixm.imgInfo.type != ImageType7))
1598
 
                {
1599
 
                        int plate = DoSep ? Plate : (GraySc ? -2 : -1);
1600
 
                        // JG - Experimental code using Type3 image instead of patterns
1601
 
                        PutStream("<< /ImageType 3\n");
1602
 
                        PutStream("   /DataDict <<\n");
1603
 
                        PutStream("      /ImageType 1\n");
1604
 
                        PutStream("      /Width  " + IToStr(w) + "\n");
1605
 
                        PutStream("      /Height " + IToStr(h) + "\n");
1606
 
                        PutStream("      /BitsPerComponent 8\n");
1607
 
                        PutStream( (GraySc || DoSep) ? "      /Decode [1 0]\n" : "      /Decode [0 1 0 1 0 1 0 1]\n");
1608
 
                        PutStream("      /ImageMatrix [" + IToStr(w) + " 0 0 " + IToStr(-h) + " 0 " + IToStr(h) + "]\n");
1609
 
                        if (Name.length() > 0)
1610
 
                                PutStream("      /DataSource "+PSEncode(Name)+"Bild\n");
1611
 
                        else
1612
 
                            PutStream("      /DataSource currentfile /ASCII85Decode filter /FlateDecode filter\n");
1613
 
                        PutStream("      >>\n");
1614
 
                        PutStream("   /MaskDict <<\n");
1615
 
                        PutStream("      /ImageType 1\n");
1616
 
                        PutStream("      /Width  " + IToStr(w) + "\n");
1617
 
                        PutStream("      /Height " + IToStr(h) + "\n");
1618
 
                        PutStream("      /BitsPerComponent 8\n");
1619
 
                        PutStream("      /Decode [1 0]\n");
1620
 
                        PutStream("      /ImageMatrix [" + IToStr(w) + " 0 0 " + IToStr(-h) + " 0 " + IToStr(h) + "]\n");
1621
 
                        PutStream("      >>\n");
1622
 
                        PutStream("   /InterleaveType 1\n");
1623
 
                        PutStream(">>\n");
1624
 
                        PutStream("image\n");
1625
 
                        if (Name.isEmpty())
1626
 
                        {
1627
 
                                if (!PutImageToStream(image, maskArray, plate))
1628
 
                                {
1629
 
                                        PS_Error_ImageDataWriteFailure();
1630
 
                                        return false;
1631
 
                                }
1632
 
                        }
1633
 
                        else
1634
 
                        {
1635
 
                                PutStream(PSEncode(Name)+"Bild resetfile\n");
1636
 
                                //PutStream(PSEncode(Name)+"Mask resetfile\n");
1637
 
                        }
1638
 
                }
1639
 
                else
1640
 
                {
1641
 
                        PutStream("<< /ImageType 1\n");
1642
 
                        PutStream("   /Width " + IToStr(w) + "\n");
1643
 
                        PutStream("   /Height " + IToStr(h) + "\n");
1644
 
                        PutStream("   /BitsPerComponent 8\n");
1645
 
                        if (DoSep)
1646
 
                                PutStream("   /Decode [1 0]\n");
1647
 
                        else
1648
 
                                PutStream( GraySc ? "   /Decode [1 0]\n" : "   /Decode [0 1 0 1 0 1 0 1]\n");
1649
 
                        PutStream("   /ImageMatrix [" + IToStr(w) + " 0 0 " + IToStr(-h) + " 0 " + IToStr(h) + "]\n");
1650
 
                        if (!Name.isEmpty())
1651
 
                        {
1652
 
                                PutStream("   /DataSource "+PSEncode(Name)+"Bild >>\n");
1653
 
                                PutStream("image\n");
1654
 
                                PutStream(PSEncode(Name)+"Bild resetfile\n");
1655
 
                        }
1656
 
                        else
1657
 
                        {
1658
 
                                int plate = DoSep ? Plate : (GraySc ? -2 : -1);
1659
 
                                PutStream("   /DataSource currentfile /ASCII85Decode filter /FlateDecode filter >>\n");
1660
 
                                PutStream("image\n");
1661
 
                                if (!PutImageToStream(image, plate))
1662
 
                                {
1663
 
                                        PS_Error_ImageDataWriteFailure();
1664
 
                                        return false;
1665
 
                                }
1666
 
                        }
1667
 
                }
1668
 
        }
1669
 
        return true;
1670
 
}
1671
 
 
1672
 
 
1673
 
void PSLib::PS_plate(int nr, QString name)
1674
 
{
1675
 
        switch (nr)
1676
 
        {
1677
 
                case 0:
1678
 
                        PutStream("%%PlateColor Black\n");
1679
 
                        PutStream("/setcmykcolor {exch pop exch pop exch pop 1 exch sub oldsetgray} bind def\n");
1680
 
                        PutStream("/setrgbcolor {pop pop pop 1 oldsetgray} bind def\n");
1681
 
                        break;
1682
 
                case 1:
1683
 
                        PutStream("%%PlateColor Cyan\n");
1684
 
                        PutStream("/setcmykcolor {pop pop pop 1 exch sub oldsetgray} bind def\n");
1685
 
                        PutStream("/setrgbcolor {pop pop oldsetgray} bind def\n");
1686
 
                        break;
1687
 
                case 2:
1688
 
                        PutStream("%%PlateColor Magenta\n");
1689
 
                        PutStream("/setcmykcolor {pop pop exch pop 1 exch sub oldsetgray} bind def\n");
1690
 
                        PutStream("/setrgbcolor {pop exch pop oldsetgray} bind def\n");
1691
 
                        break;
1692
 
                case 3:
1693
 
                        PutStream("%%PlateColor Yellow\n");
1694
 
                        PutStream("/setcmykcolor {pop exch pop exch pop 1 exch sub oldsetgray} bind def\n");
1695
 
                        PutStream("/setrgbcolor {exch pop exch pop oldsetgray} bind def\n");
1696
 
                        break;
1697
 
                default:
1698
 
                        PutStream("%%PlateColor "+name+"\n");
1699
 
                        PutStream("/setcmykcolor {exch 0.11 mul add exch 0.59 mul add exch 0.3 mul add dup 1 gt {pop 1} if 1 exch sub oldsetgray} bind def\n");
1700
 
                        PutStream("/setrgbcolor {0.11 mul exch 0.59 mul add exch 0.3 mul add oldsetgray} bind def\n");
1701
 
                        break;
1702
 
        }
1703
 
        Plate = nr;
1704
 
        currentSpot = name;
1705
 
        DoSep = true;
1706
 
}
1707
 
 
1708
 
void PSLib::PS_setGray()
1709
 
{
1710
 
        GraySc = true;
1711
 
}
1712
 
 
1713
 
void PSLib::PDF_Bookmark(QString text, uint Seite)
1714
 
{
1715
 
        PutStream("[/Title ("+text+") /Page "+IToStr(Seite)+" /View [/Fit]\n");
1716
 
        PutStream("/OUT pdfmark\n");
1717
 
}
1718
 
 
1719
 
void PSLib::PDF_Annotation(PageItem *item, QString text, double x, double y, double b, double h)
1720
 
{
1721
 
        PutStream("[\n/Rect [ "+ToStr(x)+" "+ToStr(y) +" "+ToStr(b)+" "+ToStr(h)+" ]\n");
1722
 
        switch (item->annotation().Type())
1723
 
        {
1724
 
                case 0:
1725
 
                case 10:
1726
 
                        PutStream("/Subtype /Text\n");
1727
 
                        PutStream("/Contents ("+text+")\n/Open false\n");
1728
 
                        break;
1729
 
                case 1:
1730
 
                case 11:
1731
 
                        PutStream("/Subtype /Link\n");
1732
 
                        if (item->annotation().ActionType() == 2)
1733
 
                        {
1734
 
                                PutStream("/Page " + QString::number(item->annotation().Ziel() + 1) + "\n");
1735
 
                                PutStream("/View [ /XYZ " + item->annotation().Action() + "]\n");
1736
 
                        }
1737
 
                        if (item->annotation().ActionType() == 7)
1738
 
                        {
1739
 
                                QFileInfo fiBase(Spool.fileName());
1740
 
                                QString baseDir = fiBase.absolutePath();
1741
 
                                PutStream("/Action /GoToR\n");
1742
 
                                PutStream("/File (" + Path2Relative(item->annotation().Extern(), baseDir) + ")\n");
1743
 
                                PutStream("/Page " + QString::number(item->annotation().Ziel() + 1) + "\n");
1744
 
                                PutStream("/View [ /XYZ " + item->annotation().Action() + "]\n");
1745
 
                        }
1746
 
                        if (item->annotation().ActionType() == 8)
1747
 
                        {
1748
 
                        /* The PDFMark docs say that for URI actions should contain an entry /Subtype /URI
1749
 
                           but tests with Ghostscript shows that only /S /URI works. Don't know if that is
1750
 
                           an error in the docs or a bug in Ghostscript
1751
 
                                PutStream("/Action << /Subtype /URI /URI (" + item->annotation().Extern() + ") >>\n");
1752
 
                        */
1753
 
                                PutStream("/Action << /S /URI /URI (" + item->annotation().Extern() + ") >>\n");
1754
 
                        }
1755
 
                        if (item->annotation().ActionType() == 9)
1756
 
                        {
1757
 
                                PutStream("/Action /GoToR\n");
1758
 
                                PutStream("/File (" + item->annotation().Extern() + ")\n");
1759
 
                                PutStream("/Page " + QString::number(item->annotation().Ziel() + 1) + "\n");
1760
 
                                PutStream("/View [ /XYZ " + item->annotation().Action() + "]\n");
1761
 
                        }
1762
 
                        break;
1763
 
                default:
1764
 
                        break;
1765
 
        }
1766
 
        if ((item->annotation().Type() < 2) || (item->annotation().Type() > 9))
1767
 
                PutStream("/Border [ 0 0 0 ]\n");
1768
 
        PutStream("/Title (" + item->itemName().replace(".", "_" ) + ")\n");
1769
 
        PutStream("/ANN pdfmark\n");
1770
 
}
1771
 
 
1772
 
 
1773
 
void PSLib::PS_close()
1774
 
{
1775
 
        PutStream("%%Trailer\n");
1776
 
//      PutStream("end\n");
1777
 
        PutStream("%%EOF\n");
1778
 
        Spool.close();
1779
 
}
1780
 
 
1781
 
void PSLib::PS_insert(QString i)
1782
 
{
1783
 
        PutStream(i);
1784
 
}
1785
 
 
1786
 
void PSLib::PS_Error(const QString& message)
1787
 
{
1788
 
        ErrorMessage = message;
1789
 
        if (!ScCore->usingGUI())
1790
 
                qDebug("%s", message.toLocal8Bit().data());
1791
 
}
1792
 
 
1793
 
void PSLib::PS_Error_ImageDataWriteFailure(void)
1794
 
{
1795
 
        PS_Error( tr("Failed to write data for an image"));
1796
 
}
1797
 
 
1798
 
void PSLib::PS_Error_ImageLoadFailure(const QString& fileName)
1799
 
{
1800
 
        PS_Error( tr("Failed to load an image : %1").arg(fileName) );
1801
 
}
1802
 
 
1803
 
void PSLib::PS_Error_MaskLoadFailure(const QString& fileName)
1804
 
{
1805
 
        PS_Error( tr("Failed to load an image mask : %1").arg(fileName) );
1806
 
}
1807
 
 
1808
 
void PSLib::PS_Error_InsufficientMemory(void)
1809
 
{
1810
 
        PS_Error( tr("Insufficient memory for processing an image"));
1811
 
}
1812
 
 
1813
 
int PSLib::CreatePS(ScribusDoc* Doc, PrintOptions &options)
1814
 
{
1815
 
        bool errorOccured = false;
1816
 
        Options = options;
1817
 
        std::vector<int> &pageNs = options.pageNumbers;
1818
 
        bool sep = options.outputSeparations;
1819
 
        QString SepNam = options.separationName;
1820
 
        QStringList spots = options.allSeparations;
1821
 
        bool farb = options.useColor;
1822
 
        bool Hm = options.mirrorH;
1823
 
        bool Vm = options.mirrorV;
1824
 
        bool Ic = options.useICC;
1825
 
        bool gcr = options.doGCR;
1826
 
        bool doDev = options.setDevParam;
1827
 
        bool doClip = options.doClip;
1828
 
        QStack<PageItem*> groupStack;
1829
 
        int sepac;
1830
 
        int pagemult;
1831
 
        if ((sep) && (SepNam == QObject::tr("All")))
1832
 
                pagemult = spots.count();
1833
 
        else
1834
 
                pagemult = 1;
1835
 
        QVector<double> dum;
1836
 
        double gx = 0.0;
1837
 
        double gy = 0.0;
1838
 
        double gw = 0.0;
1839
 
        double gh = 0.0;;
1840
 
        dum.clear();
1841
 
        PS_set_Info("Author", Doc->documentInfo.getAuthor());
1842
 
        PS_set_Info("Title", Doc->documentInfo.getTitle());
1843
 
        if (!farb)
1844
 
                PS_setGray();
1845
 
        applyICC = Ic;
1846
 
        if ((Doc->HasCMS) && (ScCore->haveCMS()) && (applyICC))
1847
 
                solidTransform = ScColorMgmtEngine::createTransform(Doc->DocInputCMYKProf, Format_CMYK_16, Doc->DocPrinterProf, Format_CMYK_16, Doc->IntentColors, 0);
1848
 
        else
1849
 
                applyICC = false;
1850
 
        if (usingGUI)
1851
 
        {
1852
 
                QString title=QObject::tr("Exporting PostScript File");
1853
 
                if (psExport)
1854
 
                        title=QObject::tr("Printing File");
1855
 
                progressDialog=new MultiProgressDialog(title, CommonStrings::tr_Cancel, Doc->scMW());
1856
 
                if (progressDialog==0)
1857
 
                        usingGUI=false;
1858
 
                else
1859
 
                {
1860
 
                        QStringList barNames, barTexts;
1861
 
                        barNames << "EMP" << "EP";
1862
 
                        barTexts << tr("Processing Master Page:") << tr("Exporting Page:");
1863
 
                        QList<bool> barsNumeric;
1864
 
                        barsNumeric << true << true;
1865
 
                        progressDialog->addExtraProgressBars(barNames, barTexts, barsNumeric);
1866
 
                        progressDialog->setOverallTotalSteps(pageNs.size()+Doc->MasterPages.count());
1867
 
                        progressDialog->setTotalSteps("EMP", Doc->MasterPages.count());
1868
 
                        progressDialog->setTotalSteps("EP", pageNs.size());
1869
 
                        progressDialog->setOverallProgress(0);
1870
 
                        progressDialog->setProgress("EMP", 0);
1871
 
                        progressDialog->setProgress("EP", 0);
1872
 
                        progressDialog->show();
1873
 
                        connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelRequested()));
1874
 
                        ScQApp->processEvents();
1875
 
                }
1876
 
        }
1877
 
        //if ((!Art) && (view->SelItem.count() != 0))
1878
 
        uint docSelectionCount=Doc->m_Selection->count();
1879
 
        if ((!psExport) && (docSelectionCount != 0))
1880
 
        {
1881
 
                double minx = 99999.9;
1882
 
                double miny = 99999.9;
1883
 
                double maxx = -99999.9;
1884
 
                double maxy = -99999.9;
1885
 
                for (uint ep = 0; ep < docSelectionCount; ++ep)
1886
 
                {
1887
 
                        //PageItem* currItem = view->SelItem.at(ep);
1888
 
                        PageItem* currItem = Doc->m_Selection->itemAt(ep);
1889
 
                        double lw = currItem->lineWidth() / 2.0;
1890
 
                        if (currItem->rotation() != 0)
1891
 
                        {
1892
 
                                FPointArray pb;
1893
 
                                pb.resize(0);
1894
 
                                pb.addPoint(FPoint(currItem->xPos()-lw, currItem->yPos()-lw));
1895
 
                                pb.addPoint(FPoint(currItem->width()+lw*2.0, -lw, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
1896
 
                                pb.addPoint(FPoint(currItem->width()+lw*2.0, currItem->height()+lw*2.0, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
1897
 
                                pb.addPoint(FPoint(-lw, currItem->height()+lw*2.0, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
1898
 
                                for (uint pc = 0; pc < 4; ++pc)
1899
 
                                {
1900
 
                                        minx = qMin(minx, pb.point(pc).x());
1901
 
                                        miny = qMin(miny, pb.point(pc).y());
1902
 
                                        maxx = qMax(maxx, pb.point(pc).x());
1903
 
                                        maxy = qMax(maxy, pb.point(pc).y());
1904
 
                                }
1905
 
                        }
1906
 
                        else
1907
 
                        {
1908
 
                                minx = qMin(minx, currItem->xPos()-lw);
1909
 
                                miny = qMin(miny, currItem->yPos()-lw);
1910
 
                                maxx = qMax(maxx, currItem->xPos()-lw + currItem->width()+lw*2.0);
1911
 
                                maxy = qMax(maxy, currItem->yPos()-lw + currItem->height()+lw*2.0);
1912
 
                        }
1913
 
                }
1914
 
                gx = minx;
1915
 
                gy = miny;
1916
 
                gw = maxx - minx;
1917
 
                gh = maxy - miny;
1918
 
                int pgNum = pageNs[0]-1;
1919
 
                gx -= Doc->Pages->at(pgNum)->xOffset();
1920
 
                gy -= Doc->Pages->at(pgNum)->yOffset();
1921
 
                errorOccured = !PS_begin_doc(Doc, gx, Doc->pageHeight - (gy+gh), gx + gw, Doc->pageHeight - gy, 1*pagemult, false, sep, farb, Ic, gcr);
1922
 
        }
1923
 
        else
1924
 
        {
1925
 
                uint a;
1926
 
                double maxWidth = 0.0;
1927
 
                double maxHeight = 0.0;
1928
 
                for (uint aa = 0; aa < pageNs.size(); ++aa)
1929
 
                {
1930
 
                        a = pageNs[aa]-1;
1931
 
                        maxWidth = qMax(Doc->Pages->at(a)->width(), maxWidth);
1932
 
                        maxHeight = qMax(Doc->Pages->at(a)->height(), maxHeight);
1933
 
                }
1934
 
                errorOccured = !PS_begin_doc(Doc, 0.0, 0.0, maxWidth, maxHeight, pageNs.size()*pagemult, doDev, sep, farb, Ic, gcr);
1935
 
        }
1936
 
        int ap=0;
1937
 
        for (; ap < Doc->MasterPages.count() && !abortExport && !errorOccured; ++ap)
1938
 
        {
1939
 
                progressDialog->setOverallProgress(ap);
1940
 
                progressDialog->setProgress("EMP", ap);
1941
 
                ScQApp->processEvents();
1942
 
                if (Doc->MasterItems.count() != 0)
1943
 
                {
1944
 
                        int Lnr = 0;
1945
 
                        ScLayer ll;
1946
 
                        ll.isPrintable = false;
1947
 
                        ll.LNr = 0;
1948
 
                        for (int lam = 0; lam < Doc->Layers.count() && !abortExport && !errorOccured; ++lam)
1949
 
                        {
1950
 
                                Doc->Layers.levelToLayer(ll, Lnr);
1951
 
                                if (ll.isPrintable)
1952
 
                                {
1953
 
                                        for (int api = 0; api < Doc->MasterItems.count() && !abortExport; ++api)
1954
 
                                        {
1955
 
                                                QString tmps;
1956
 
                                                PageItem *it = Doc->MasterItems.at(api);
1957
 
                                                if (usingGUI)
1958
 
                                                        ScQApp->processEvents();
1959
 
                                                if ((it->LayerNr != ll.LNr) || (!it->printEnabled()))
1960
 
                                                        continue;
1961
 
                                                double bLeft, bRight, bBottom, bTop;
1962
 
                                                GetBleeds(Doc->MasterPages.at(ap), bLeft, bRight, bBottom, bTop);
1963
 
                                                double x  = Doc->MasterPages.at(ap)->xOffset() - bLeft;
1964
 
                                                double y  = Doc->MasterPages.at(ap)->yOffset() - bTop;
1965
 
                                                double w  = Doc->MasterPages.at(ap)->width() + bLeft + bRight;
1966
 
                                                double h1 = Doc->MasterPages.at(ap)->height()+ bBottom + bTop;
1967
 
                                                double ilw = it->lineWidth();
1968
 
                                                double x2 = it->BoundingX - ilw / 2.0;
1969
 
                                                double y2 = it->BoundingY - ilw / 2.0;
1970
 
                                                double w2 = qMax(it->BoundingW + ilw, 1.0);
1971
 
                                                double h2 = qMax(it->BoundingH + ilw, 1.0);
1972
 
                                                if (!( qMax( x, x2 ) <= qMin( x+w, x2+w2 ) && qMax( y, y2 ) <= qMin( y+h1, y2+h2 )))
1973
 
                                                        continue;
1974
 
                                                if ((it->OwnPage != static_cast<int>(Doc->MasterPages.at(ap)->pageNr())) && (it->OwnPage != -1))
1975
 
                                                        continue;
1976
 
                                                if ((optimization == OptimizeSize) && it->asImageFrame() && it->PictureIsAvailable && (!it->Pfile.isEmpty()) && it->printEnabled() && (!sep) && farb)
1977
 
                                                {
1978
 
                                                        errorOccured = !PS_ImageData(it, it->Pfile, it->itemName(), it->IProfile, it->UseEmbedded, Ic);
1979
 
                                                        if (errorOccured) break;
1980
 
                                                }
1981
 
                                                PS_TemplateStart(QString("mp_obj_%1_%2").arg(ap).arg(it->ItemNr));
1982
 
                                                ProcessItem(Doc, Doc->MasterPages.at(ap), it, ap+1, sep, farb, Ic, gcr, true);
1983
 
                                                PS_TemplateEnd();
1984
 
                                        }
1985
 
                                }
1986
 
                                Lnr++;
1987
 
                                if (errorOccured) break;
1988
 
                        }
1989
 
                }
1990
 
                if (errorOccured) break;
1991
 
        }
1992
 
        sepac = 0;
1993
 
        uint aa = 0;
1994
 
        uint a; 
1995
 
        PutStream("%%EndSetup\n");
1996
 
        while (aa < pageNs.size() && !abortExport && !errorOccured)
1997
 
        {
1998
 
                progressDialog->setProgress("EP", aa);
1999
 
                progressDialog->setOverallProgress(ap+aa);
2000
 
                if (usingGUI)
2001
 
                        ScQApp->processEvents();
2002
 
                a = pageNs[aa]-1;
2003
 
                //if ((!Art) && (view->SelItem.count() != 0))
2004
 
                if ((!psExport) && (Doc->m_Selection->count() != 0))
2005
 
                {
2006
 
                        MarginStruct Ma;
2007
 
                        Ma.Left = gx;
2008
 
                        Ma.Top = gy;
2009
 
                        Ma.Bottom = Doc->Pages->at(a)->height() - (gy + gh);
2010
 
                        Ma.Right = Doc->Pages->at(a)->width() - (gx + gw);
2011
 
                        PS_begin_page(Doc->Pages->at(a), &Ma, true);
2012
 
                }
2013
 
                else
2014
 
                        PS_begin_page(Doc->Pages->at(a), &Doc->Pages->at(a)->Margins, doClip);
2015
 
                if (Hm)
2016
 
                {
2017
 
                        PS_translate(Doc->Pages->at(a)->width(), 0);
2018
 
                        PS_scale(-1, 1);
2019
 
                }
2020
 
                if (Vm)
2021
 
                {
2022
 
                        PS_translate(0, Doc->Pages->at(a)->height());
2023
 
                        PS_scale(1, -1);
2024
 
                }
2025
 
                if (sep)
2026
 
                {
2027
 
                        if (SepNam == QObject::tr("Black"))
2028
 
                                PS_plate(0);
2029
 
                        else if (SepNam == QObject::tr("Cyan"))
2030
 
                                PS_plate(1);
2031
 
                        else if (SepNam == QObject::tr("Magenta"))
2032
 
                                PS_plate(2);
2033
 
                        else if (SepNam == QObject::tr("Yellow"))
2034
 
                                PS_plate(3);
2035
 
                        else if (SepNam == QObject::tr("All"))
2036
 
                                PS_plate(sepac, spots[sepac]);
2037
 
                        else
2038
 
                                PS_plate(4, SepNam);
2039
 
                }
2040
 
                if (!Doc->Pages->at(a)->MPageNam.isEmpty() && !abortExport && !errorOccured)
2041
 
                {
2042
 
                        int h, s, v, k;
2043
 
                        QByteArray chstrc;
2044
 
                        QString chstr;
2045
 
                        int Lnr = 0;
2046
 
                        ScLayer ll;
2047
 
                        ll.isPrintable = false;
2048
 
                        ll.LNr = 0;
2049
 
                        Page* mPage = Doc->MasterPages.at(Doc->MasterNames[Doc->Pages->at(a)->MPageNam]);
2050
 
                        if (Doc->MasterItems.count() != 0)
2051
 
                        {
2052
 
                                for (int lam = 0; lam < Doc->Layers.count() && !abortExport && !errorOccured; ++lam)
2053
 
                                {
2054
 
                                        Doc->Layers.levelToLayer(ll, Lnr);
2055
 
                                        if (ll.isPrintable)
2056
 
                                        {
2057
 
                                                for (int am = 0; am < Doc->Pages->at(a)->FromMaster.count() && !abortExport; ++am)
2058
 
                                                {
2059
 
                                                        QString tmps;
2060
 
                                                        PageItem *ite = Doc->Pages->at(a)->FromMaster.at(am);
2061
 
                                                        if (usingGUI)
2062
 
                                                                ScQApp->processEvents();
2063
 
                                                        if ((ite->LayerNr != ll.LNr) || (!ite->printEnabled()))
2064
 
                                                                continue;
2065
 
                                                        if (ite->isGroupControl)
2066
 
                                                        {
2067
 
                                                                PS_save();
2068
 
                                                                FPointArray cl = ite->PoLine.copy();
2069
 
                                                                QMatrix mm;
2070
 
                                                                mm.translate(ite->xPos() - mPage->xOffset(), (ite->yPos() - mPage->yOffset()) - Doc->Pages->at(a)->height());
2071
 
                                                                mm.rotate(ite->rotation());
2072
 
                                                                cl.map( mm );
2073
 
                                                                SetClipPath(&cl);
2074
 
                                                                PS_closepath();
2075
 
                                                                PS_clip(true);
2076
 
                                                                groupStack.push(ite->groupsLastItem);
2077
 
                                                                continue;
2078
 
                                                        }
2079
 
                                                        if (!(ite->asTextFrame()) && !(ite->asImageFrame()))
2080
 
                                                        {
2081
 
                                                                int mpIndex = Doc->MasterNames[Doc->Pages->at(a)->MPageNam];
2082
 
                                                                PS_UseTemplate(QString("mp_obj_%1_%2").arg(mpIndex).arg(ite->ItemNr));
2083
 
                                                        }
2084
 
                                                        else if (ite->asImageFrame())
2085
 
                                                        {
2086
 
                                                                PS_save();
2087
 
                                                                // JG : replace what seems mostly duplicate code by corresponding function call (#3936)
2088
 
                                                                errorOccured = !ProcessItem(Doc, mPage, ite, a, sep, farb, Ic, gcr, false, false, true);
2089
 
                                                                if (errorOccured) break;
2090
 
                                                                PS_restore();
2091
 
                                                        }
2092
 
                                                        else if (ite->asTextFrame())
2093
 
                                                        {
2094
 
                                                                PS_save();
2095
 
                                                                if (ite->doOverprint)
2096
 
                                                                {
2097
 
                                                                        PutStream("true setoverprint\n");
2098
 
                                                                        PutStream("true setoverprintmode\n");
2099
 
                                                                }
2100
 
                                                                if (ite->fillColor() != CommonStrings::None)
2101
 
                                                                {
2102
 
                                                                        SetColor(ite->fillColor(), ite->fillShade(), &h, &s, &v, &k, gcr);
2103
 
                                                                        PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2104
 
                                                                }
2105
 
                                                                PS_translate(ite->xPos() - mPage->xOffset(), mPage->height() - (ite->yPos() - mPage->yOffset()));
2106
 
                                                                if (ite->rotation() != 0)
2107
 
                                                                        PS_rotate(-ite->rotation());
2108
 
                                                                if ((ite->fillColor() != CommonStrings::None) || (ite->GrType != 0))
2109
 
                                                                {
2110
 
                                                                        SetClipPath(&ite->PoLine);
2111
 
                                                                        PS_closepath();
2112
 
                                                                        if (ite->GrType != 0)
2113
 
                                                                                HandleGradient(ite, ite->width(), ite->height(), gcr);
2114
 
                                                                        else
2115
 
                                                                                putColor(ite->fillColor(), ite->fillShade(), true);
2116
 
                                                                }
2117
 
                                                                if (ite->imageFlippedH())
2118
 
                                                                {
2119
 
                                                                        PS_translate(ite->width(), 0);
2120
 
                                                                        PS_scale(-1, 1);
2121
 
                                                                }
2122
 
                                                                if (ite->imageFlippedV())
2123
 
                                                                {
2124
 
                                                                        PS_translate(0, -ite->height());
2125
 
                                                                        PS_scale(1, -1);
2126
 
                                                                }
2127
 
                                                                setTextSt(Doc, ite, gcr, a, mPage, sep, farb, Ic, true);
2128
 
                                                                if (((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty())) && (!ite->isTableItem))
2129
 
                                                                {
2130
 
                                                                        if (ite->NamedLStyle.isEmpty()) // && (ite->lineWidth() != 0.0))
2131
 
                                                                        {
2132
 
                                                                                SetColor(ite->lineColor(), ite->lineShade(), &h, &s, &v, &k, gcr);
2133
 
                                                                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2134
 
                                                                                PS_setlinewidth(ite->lineWidth());
2135
 
                                                                                PS_setcapjoin(ite->PLineEnd, ite->PLineJoin);
2136
 
                                                                                PS_setdash(ite->PLineArt, ite->DashOffset, ite->DashValues);
2137
 
                                                                                SetClipPath(&ite->PoLine);
2138
 
                                                                                PS_closepath();
2139
 
                                                                                putColor(ite->lineColor(), ite->lineShade(), false);
2140
 
                                                                        }
2141
 
                                                                        else
2142
 
                                                                        {
2143
 
                                                                                multiLine ml = Doc->MLineStyles[ite->NamedLStyle];
2144
 
                                                                                for (int it = ml.size()-1; it > -1; it--)
2145
 
                                                                                {
2146
 
                                                                                        if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
2147
 
                                                                                        {
2148
 
                                                                                                SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
2149
 
                                                                                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2150
 
                                                                                                PS_setlinewidth(ml[it].Width);
2151
 
                                                                                                PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
2152
 
                                                                                                PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2153
 
                                                                                                SetClipPath(&ite->PoLine);
2154
 
                                                                                                PS_closepath();
2155
 
                                                                                                putColor(ml[it].Color, ml[it].Shade, false);
2156
 
                                                                                        }
2157
 
                                                                                }
2158
 
                                                                        }
2159
 
                                                                }
2160
 
                                                                PS_restore();
2161
 
                                                        }
2162
 
                                                        if (groupStack.count() != 0)
2163
 
                                                        {
2164
 
                                                                while (ite == groupStack.top())
2165
 
                                                                {
2166
 
                                                                        PS_restore();
2167
 
                                                                        groupStack.pop();
2168
 
                                                                        if (groupStack.count() == 0)
2169
 
                                                                                break;
2170
 
                                                                }
2171
 
                                                        }
2172
 
                                                }
2173
 
                                        }
2174
 
                                        for (int am = 0; am < Doc->Pages->at(a)->FromMaster.count() && !abortExport; ++am)
2175
 
                                        {
2176
 
                                                PageItem *ite = Doc->Pages->at(a)->FromMaster.at(am);
2177
 
                                                if (!ite->isTableItem)
2178
 
                                                        continue;
2179
 
                                                if ((ite->lineColor() == CommonStrings::None) || (ite->lineWidth() == 0.0))
2180
 
                                                        continue;
2181
 
                                                if (ite->printEnabled())
2182
 
                                                {
2183
 
                                                        PS_save();
2184
 
                                                        if (ite->doOverprint)
2185
 
                                                        {
2186
 
                                                                PutStream("true setoverprint\n");
2187
 
                                                                PutStream("true setoverprintmode\n");
2188
 
                                                        }
2189
 
                                                        if (ite->lineColor() != CommonStrings::None)
2190
 
                                                        {
2191
 
                                                                SetColor(ite->lineColor(), ite->lineShade(), &h, &s, &v, &k, gcr);
2192
 
                                                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2193
 
                                                        }
2194
 
                                                        PS_setlinewidth(ite->lineWidth());
2195
 
                                                        PS_setcapjoin(ite->PLineEnd, ite->PLineJoin);
2196
 
                                                        PS_setdash(ite->PLineArt, ite->DashOffset, ite->DashValues);
2197
 
                                                        PS_translate(ite->xPos() - mPage->xOffset(), mPage->height() - (ite->yPos() - mPage->yOffset()));
2198
 
                                                        if (ite->rotation() != 0)
2199
 
                                                                PS_rotate(-ite->rotation());
2200
 
                                                        if ((ite->TopLine) || (ite->RightLine) || (ite->BottomLine) || (ite->LeftLine))
2201
 
                                                        {
2202
 
                                                                if (ite->TopLine)
2203
 
                                                                {
2204
 
                                                                        PS_moveto(0, 0);
2205
 
                                                                        PS_lineto(ite->width(), 0);
2206
 
                                                                }
2207
 
                                                                if (ite->RightLine)
2208
 
                                                                {
2209
 
                                                                        PS_moveto(ite->width(), 0);
2210
 
                                                                        PS_lineto(ite->width(), -ite->height());
2211
 
                                                                }
2212
 
                                                                if (ite->BottomLine)
2213
 
                                                                {
2214
 
                                                                        PS_moveto(0, -ite->height());
2215
 
                                                                        PS_lineto(ite->width(), -ite->height());
2216
 
                                                                }
2217
 
                                                                if (ite->LeftLine)
2218
 
                                                                {
2219
 
                                                                        PS_moveto(0, 0);
2220
 
                                                                        PS_lineto(0, -ite->height());
2221
 
                                                                }
2222
 
                                                                putColor(ite->lineColor(), ite->lineShade(), false);
2223
 
                                                        }
2224
 
                                                        PS_restore();
2225
 
                                                }
2226
 
                                        }
2227
 
                                        Lnr++;
2228
 
                                }
2229
 
                                if (abortExport || errorOccured) break;
2230
 
                        }
2231
 
                }
2232
 
                if (!abortExport && !errorOccured)
2233
 
                        ProcessPage(Doc, Doc->Pages->at(a), a+1, sep, farb, Ic, gcr);
2234
 
                if (!abortExport && !errorOccured)
2235
 
                        PS_end_page();
2236
 
                if (sep)
2237
 
                {
2238
 
                        if (SepNam != QObject::tr("All"))
2239
 
                                aa++;
2240
 
                        else
2241
 
                        {
2242
 
                                if (sepac == static_cast<int>(spots.count()-1))
2243
 
                                {
2244
 
                                        aa++;
2245
 
                                        sepac = 0;
2246
 
                                }
2247
 
                                else
2248
 
                                        sepac++;
2249
 
                        }
2250
 
                }
2251
 
                else
2252
 
                        aa++;
2253
 
        }
2254
 
        PS_close();
2255
 
        if (usingGUI) progressDialog->close();
2256
 
        if (errorOccured)
2257
 
                return 1;
2258
 
        else if (abortExport)
2259
 
                return 2; //CB Lets leave 1 for general error condition
2260
 
        return 0; 
2261
 
}
2262
 
 
2263
 
bool PSLib::ProcessItem(ScribusDoc* Doc, Page* a, PageItem* c, uint PNr, bool sep, bool farb, bool ic, bool gcr, bool master, bool embedded, bool useTemplate)
2264
 
{
2265
 
        double tsz;
2266
 
        int h, s, v, k;
2267
 
        int d;
2268
 
        ScText *hl;
2269
 
        QVector<double> dum;
2270
 
        dum.clear();
2271
 
        QChar chstr;
2272
 
        QString tmps;
2273
 
        if (c->printEnabled())
2274
 
        {
2275
 
                fillRule = true;
2276
 
                PS_save();
2277
 
                if (c->doOverprint)
2278
 
                {
2279
 
                        PutStream("true setoverprint\n");
2280
 
                        PutStream("true setoverprintmode\n");
2281
 
                }
2282
 
                if (c->fillColor() != CommonStrings::None)
2283
 
                {
2284
 
                        SetColor(c->fillColor(), c->fillShade(), &h, &s, &v, &k, gcr);
2285
 
                        PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2286
 
                }
2287
 
                if (c->lineColor() != CommonStrings::None)
2288
 
                {
2289
 
                        SetColor(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
2290
 
                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2291
 
                }
2292
 
                PS_setlinewidth(c->lineWidth());
2293
 
                PS_setcapjoin(c->PLineEnd, c->PLineJoin);
2294
 
                PS_setdash(c->PLineArt, c->DashOffset, c->DashValues);
2295
 
                if (!embedded)
2296
 
                {
2297
 
                        PS_translate(c->xPos() - a->xOffset(), a->height() - (c->yPos() - a->yOffset()));
2298
 
                }
2299
 
                if (c->rotation() != 0)
2300
 
                        PS_rotate(-c->rotation());
2301
 
                switch (c->itemType())
2302
 
                {
2303
 
                case PageItem::ImageFrame:
2304
 
                case PageItem::LatexFrame:
2305
 
                        if (master)
2306
 
                                break;
2307
 
                        if ((c->fillColor() != CommonStrings::None) || (c->GrType != 0))
2308
 
                        {
2309
 
                                SetClipPath(&c->PoLine);
2310
 
                                PS_closepath();
2311
 
                                if ((c->GrType != 0) && (master == false))
2312
 
                                        HandleGradient(c, c->width(), c->height(), gcr);
2313
 
                                else
2314
 
                                        putColor(c->fillColor(), c->fillShade(), true);
2315
 
                                PS_newpath();
2316
 
                        }
2317
 
                        PS_save();
2318
 
                        if (c->imageClip.size() != 0)
2319
 
                        {
2320
 
                                SetClipPath(&c->imageClip);
2321
 
                                PS_closepath();
2322
 
                                PS_clip(true);
2323
 
                        }
2324
 
                        SetClipPath(&c->PoLine);
2325
 
                        PS_closepath();
2326
 
                        PS_clip(true);
2327
 
                        if (c->imageFlippedH())
2328
 
                        {
2329
 
                                PS_translate(c->width(), 0);
2330
 
                                PS_scale(-1, 1);
2331
 
                        }
2332
 
                        if (c->imageFlippedV())
2333
 
                        {
2334
 
                                PS_translate(0, -c->height());
2335
 
                                PS_scale(1, -1);
2336
 
                        }
2337
 
                        if ((c->PictureIsAvailable) && (!c->Pfile.isEmpty()))
2338
 
                        {
2339
 
                                bool imageOk = false;
2340
 
                                PS_translate(0, -c->BBoxH*c->imageYScale());
2341
 
                                if ((optimization == OptimizeSize) && (((!a->pageName().isEmpty()) && !sep && farb) || useTemplate))
2342
 
                                        imageOk = PS_image(c, c->imageXOffset(), -c->imageYOffset(), c->Pfile, c->imageXScale(), c->imageYScale(), c->IProfile, c->UseEmbedded, ic, c->itemName());
2343
 
                                else
2344
 
                                        imageOk = PS_image(c, c->imageXOffset(), -c->imageYOffset(), c->Pfile, c->imageXScale(), c->imageYScale(), c->IProfile, c->UseEmbedded, ic);
2345
 
                                if (!imageOk) return false;
2346
 
                        }
2347
 
                        PS_restore();
2348
 
                        if (((c->lineColor() != CommonStrings::None) || (!c->NamedLStyle.isEmpty())) && (!c->isTableItem))
2349
 
                        {
2350
 
                                if (c->NamedLStyle.isEmpty()) // && (c->lineWidth() != 0.0))
2351
 
                                {
2352
 
                                        SetColor(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
2353
 
                                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2354
 
                                        PS_setlinewidth(c->lineWidth());
2355
 
                                        PS_setcapjoin(c->PLineEnd, c->PLineJoin);
2356
 
                                        PS_setdash(c->PLineArt, c->DashOffset, c->DashValues);
2357
 
                                        SetClipPath(&c->PoLine);
2358
 
                                        PS_closepath();
2359
 
                                        putColor(c->lineColor(), c->lineShade(), false);
2360
 
                                }
2361
 
                                else
2362
 
                                {
2363
 
                                        multiLine ml = Doc->MLineStyles[c->NamedLStyle];
2364
 
                                        for (int it = ml.size()-1; it > -1; it--)
2365
 
                                        {
2366
 
                                                if (ml[it].Color != CommonStrings::None) // && (ml[it].Width != 0))
2367
 
                                                {
2368
 
                                                        SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
2369
 
                                                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2370
 
                                                        PS_setlinewidth(ml[it].Width);
2371
 
                                                        PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
2372
 
                                                        PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2373
 
                                                        SetClipPath(&c->PoLine);
2374
 
                                                        PS_closepath();
2375
 
                                                        putColor(ml[it].Color, ml[it].Shade, false);
2376
 
                                                }
2377
 
                                        }
2378
 
                                }
2379
 
                        }
2380
 
                        break;
2381
 
                case PageItem::TextFrame:
2382
 
                        if (master)
2383
 
                                break;
2384
 
                        if ((c->isBookmark || c->isAnnotation()) && (!isPDF))
2385
 
                                break;
2386
 
                        if (c->isBookmark)
2387
 
                        {
2388
 
                                QString bm = "";
2389
 
                                QString cc;
2390
 
                                for (int d = 0; d < c->itemText.length(); ++d)
2391
 
                                {
2392
 
                                        if ((c->itemText.text(d) == QChar(13)) || (c->itemText.text(d) == QChar(10)) || (c->itemText.text(d) == QChar(28)))
2393
 
                                                break;
2394
 
                                        bm += "\\"+cc.setNum(qMax(c->itemText.text(d).unicode(), (ushort) 32), 8);
2395
 
                                }
2396
 
                                PDF_Bookmark(bm, a->pageNr()+1);
2397
 
                        }
2398
 
                        if (c->isAnnotation())
2399
 
                        {
2400
 
                                if ((c->annotation().Type() == 0) || (c->annotation().Type() == 1) || (c->annotation().Type() == 10) || (c->annotation().Type() == 11))
2401
 
                                {
2402
 
                                        QString bm = "";
2403
 
                                        QString cc;
2404
 
                                        for (int d = 0; d < c->itemText.length(); ++d)
2405
 
                                        {
2406
 
                                                bm += "\\"+cc.setNum(qMax(c->itemText.text(d).unicode(), (ushort) 32), 8);
2407
 
                                        }
2408
 
                                        PDF_Annotation(c, bm, 0, 0, c->width(), -c->height());
2409
 
                                }
2410
 
                                break;
2411
 
                        }
2412
 
                        if ((c->fillColor() != CommonStrings::None) || (c->GrType != 0))
2413
 
                        {
2414
 
                                SetClipPath(&c->PoLine);
2415
 
                                PS_closepath();
2416
 
                                if ((c->GrType != 0) && (master == false))
2417
 
                                        HandleGradient(c, c->width(), c->height(), gcr);
2418
 
                                else
2419
 
                                        putColor(c->fillColor(), c->fillShade(), true);
2420
 
                        }
2421
 
                        if (c->imageFlippedH())
2422
 
                        {
2423
 
                                PS_translate(c->width(), 0);
2424
 
                                PS_scale(-1, 1);
2425
 
                        }
2426
 
                        if (c->imageFlippedV())
2427
 
                        {
2428
 
                                PS_translate(0, -c->height());
2429
 
                                PS_scale(1, -1);
2430
 
                        }
2431
 
                        setTextSt(Doc, c, gcr, PNr-1, a, sep, farb, ic, master);
2432
 
                        if (((c->lineColor() != CommonStrings::None) || (!c->NamedLStyle.isEmpty())) && (!c->isTableItem))
2433
 
                        {
2434
 
                                SetColor(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
2435
 
                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2436
 
                                PS_setlinewidth(c->lineWidth());
2437
 
                                PS_setcapjoin(c->PLineEnd, c->PLineJoin);
2438
 
                                PS_setdash(c->PLineArt, c->DashOffset, c->DashValues);
2439
 
                                if ((c->NamedLStyle.isEmpty()) && (c->lineWidth() != 0.0))
2440
 
                                {
2441
 
                                        SetClipPath(&c->PoLine);
2442
 
                                        PS_closepath();
2443
 
                                        putColor(c->lineColor(), c->lineShade(), false);
2444
 
                                }
2445
 
                                else
2446
 
                                {
2447
 
                                        multiLine ml = Doc->MLineStyles[c->NamedLStyle];
2448
 
                                        for (int it = ml.size()-1; it > -1; it--)
2449
 
                                        {
2450
 
                                                if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
2451
 
                                                {
2452
 
                                                        SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
2453
 
                                                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2454
 
                                                        PS_setlinewidth(ml[it].Width);
2455
 
                                                        PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
2456
 
                                                        PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2457
 
                                                        SetClipPath(&c->PoLine);
2458
 
                                                        PS_closepath();
2459
 
                                                        putColor(ml[it].Color, ml[it].Shade, false);
2460
 
                                                }
2461
 
                                        }
2462
 
                                }
2463
 
                        }
2464
 
                        break;
2465
 
                case PageItem::Line:
2466
 
                        if (c->NamedLStyle.isEmpty()) // && (c->lineWidth() != 0.0))
2467
 
                        {
2468
 
                                if (c->lineColor() != CommonStrings::None)
2469
 
                                {
2470
 
                                        PS_moveto(0, 0);
2471
 
                                        PS_lineto(c->width(), 0);
2472
 
                                        putColor(c->lineColor(), c->lineShade(), false);
2473
 
                                }
2474
 
                        }
2475
 
                        else
2476
 
                        {
2477
 
                                multiLine ml = Doc->MLineStyles[c->NamedLStyle];
2478
 
                                for (int it = ml.size()-1; it > -1; it--)
2479
 
                                {
2480
 
                                        if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
2481
 
                                        {
2482
 
                                                SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
2483
 
                                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2484
 
                                                PS_setlinewidth(ml[it].Width);
2485
 
                                                PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
2486
 
                                                PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2487
 
                                                PS_moveto(0, 0);
2488
 
                                                PS_lineto(c->width(), 0);
2489
 
                                                putColor(ml[it].Color, ml[it].Shade, false);
2490
 
                                        }
2491
 
                                }
2492
 
                        }
2493
 
                        if (c->startArrowIndex() != 0)
2494
 
                        {
2495
 
                                QMatrix arrowTrans;
2496
 
                                arrowTrans.scale(-1,1);
2497
 
                                drawArrow(c, arrowTrans, c->startArrowIndex(), gcr);
2498
 
                        }
2499
 
                        if (c->endArrowIndex() != 0)
2500
 
                        {
2501
 
                                QMatrix arrowTrans;
2502
 
                                arrowTrans.translate(c->width(), 0);
2503
 
                                drawArrow(c, arrowTrans, c->endArrowIndex(), gcr);
2504
 
                        }
2505
 
                        break;
2506
 
                /* OBSOLETE CR 2005-02-06
2507
 
                case 1:
2508
 
                case 3:
2509
 
                */
2510
 
                case PageItem::ItemType1:
2511
 
                case PageItem::ItemType3:
2512
 
                case PageItem::Polygon:
2513
 
                        if ((c->fillColor() != CommonStrings::None) || (c->GrType != 0))
2514
 
                        {
2515
 
                                SetClipPath(&c->PoLine);
2516
 
                                PS_closepath();
2517
 
                                fillRule = c->fillRule;
2518
 
                                if (c->GrType != 0)
2519
 
                                        HandleGradient(c, c->width(), c->height(), gcr);
2520
 
                                else
2521
 
                                        putColor(c->fillColor(), c->fillShade(), true);
2522
 
                        }
2523
 
                        if ((c->lineColor() != CommonStrings::None) || (!c->NamedLStyle.isEmpty()))
2524
 
                        {
2525
 
                                if (c->NamedLStyle.isEmpty()) //&& (c->lineWidth() != 0.0))
2526
 
                                {
2527
 
                                        if (c->lineColor() != CommonStrings::None)
2528
 
                                        {
2529
 
                                                SetClipPath(&c->PoLine);
2530
 
                                                PS_closepath();
2531
 
                                                putColor(c->lineColor(), c->lineShade(), false);
2532
 
                                        }
2533
 
                                }
2534
 
                                else
2535
 
                                {
2536
 
                                        multiLine ml = Doc->MLineStyles[c->NamedLStyle];
2537
 
                                        for (int it = ml.size()-1; it > -1; it--)
2538
 
                                        {
2539
 
                                                if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
2540
 
                                                {
2541
 
                                                        SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
2542
 
                                                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2543
 
                                                        PS_setlinewidth(ml[it].Width);
2544
 
                                                        PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
2545
 
                                                        PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2546
 
                                                        SetClipPath(&c->PoLine);
2547
 
                                                        PS_closepath();
2548
 
                                                        putColor(ml[it].Color, ml[it].Shade, false);
2549
 
                                                }
2550
 
                                        }
2551
 
                                }
2552
 
                        }
2553
 
                        break;
2554
 
                case PageItem::PolyLine:
2555
 
                        if ((c->fillColor() != CommonStrings::None) || (c->GrType != 0))
2556
 
                        {
2557
 
                                SetClipPath(&c->PoLine);
2558
 
                                PS_closepath();
2559
 
                                if (c->GrType != 0)
2560
 
                                        HandleGradient(c, c->width(), c->height(), gcr);
2561
 
                                else
2562
 
                                        putColor(c->fillColor(), c->fillShade(), true);
2563
 
                                PS_newpath();
2564
 
                        }
2565
 
                        if ((c->lineColor() != CommonStrings::None) || (!c->NamedLStyle.isEmpty()))
2566
 
                        {
2567
 
                                if (c->NamedLStyle.isEmpty()) //&& (c->lineWidth() != 0.0))
2568
 
                                {
2569
 
                                        if (c->lineColor() != CommonStrings::None)
2570
 
                                        {
2571
 
                                                SetClipPath(&c->PoLine, false);
2572
 
                                                putColor(c->lineColor(), c->lineShade(), false);
2573
 
                                        }
2574
 
                                }
2575
 
                                else
2576
 
                                {
2577
 
                                        multiLine ml = Doc->MLineStyles[c->NamedLStyle];
2578
 
                                        for (int it = ml.size()-1; it > -1; it--)
2579
 
                                        {
2580
 
                                                if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
2581
 
                                                {
2582
 
                                                        SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
2583
 
                                                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2584
 
                                                        PS_setlinewidth(ml[it].Width);
2585
 
                                                        PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
2586
 
                                                        PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2587
 
                                                        SetClipPath(&c->PoLine, false);
2588
 
                                                        putColor(ml[it].Color, ml[it].Shade, false);
2589
 
                                                }
2590
 
                                        }
2591
 
                                }
2592
 
                        }
2593
 
                        if (c->startArrowIndex() != 0)
2594
 
                        {
2595
 
                                FPoint Start = c->PoLine.point(0);
2596
 
                                for (uint xx = 1; xx < c->PoLine.size(); xx += 2)
2597
 
                                {
2598
 
                                        FPoint Vector = c->PoLine.point(xx);
2599
 
                                        if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
2600
 
                                        {
2601
 
                                                double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI);
2602
 
                                                QMatrix arrowTrans;
2603
 
                                                arrowTrans.translate(Start.x(), Start.y());
2604
 
                                                arrowTrans.rotate(r);
2605
 
                                                drawArrow(c, arrowTrans, c->startArrowIndex(), gcr);
2606
 
                                                break;
2607
 
                                        }
2608
 
                                }
2609
 
                        }
2610
 
                        if (c->endArrowIndex() != 0)
2611
 
                        {
2612
 
                                FPoint End = c->PoLine.point(c->PoLine.size()-2);
2613
 
                                for (uint xx = c->PoLine.size()-1; xx > 0; xx -= 2)
2614
 
                                {
2615
 
                                        FPoint Vector = c->PoLine.point(xx);
2616
 
                                        if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
2617
 
                                        {
2618
 
                                                double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI);
2619
 
                                                QMatrix arrowTrans;
2620
 
                                                arrowTrans.translate(End.x(), End.y());
2621
 
                                                arrowTrans.rotate(r);
2622
 
                                                drawArrow(c, arrowTrans, c->endArrowIndex(), gcr);
2623
 
                                                break;
2624
 
                                        }
2625
 
                                }
2626
 
                        }
2627
 
                        break;
2628
 
                case PageItem::PathText:
2629
 
                        if (c->PoShow)
2630
 
                        {
2631
 
                                if (c->PoLine.size() > 3)
2632
 
                                {
2633
 
                                        PS_save();
2634
 
                                        if (c->NamedLStyle.isEmpty()) //&& (c->lineWidth() != 0.0))
2635
 
                                        {
2636
 
                                                if (c->lineColor() != CommonStrings::None)
2637
 
                                                {
2638
 
                                                        SetClipPath(&c->PoLine, false);
2639
 
                                                        putColor(c->lineColor(), c->lineShade(), false);
2640
 
                                                }
2641
 
                                        }
2642
 
                                        else
2643
 
                                        {
2644
 
                                                multiLine ml = Doc->MLineStyles[c->NamedLStyle];
2645
 
                                                for (int it = ml.size()-1; it > -1; it--)
2646
 
                                                {
2647
 
                                                        if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
2648
 
                                                        {
2649
 
                                                                SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
2650
 
                                                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2651
 
                                                                PS_setlinewidth(ml[it].Width);
2652
 
                                                                PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
2653
 
                                                                PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2654
 
                                                                SetClipPath(&c->PoLine, false);
2655
 
                                                                putColor(ml[it].Color, ml[it].Shade, false);
2656
 
                                                        }
2657
 
                                                }
2658
 
                                        }
2659
 
                                        PS_restore();
2660
 
                                }
2661
 
                        }
2662
 
#ifndef NLS_PROTO
2663
 
                        for (d = c->firstInFrame(); d <= c->lastInFrame(); ++d)
2664
 
                        {
2665
 
                                hl = c->itemText.item(d);
2666
 
                                const CharStyle & style(c->itemText.charStyle(d));
2667
 
                                if ((hl->ch == QChar(13)) || (hl->ch == QChar(30)) || (hl->ch == QChar(9)) || (hl->ch == QChar(28)))
2668
 
                                        continue;
2669
 
                                QPointF tangt = QPointF( cos(hl->PRot), sin(hl->PRot) );
2670
 
                                tsz = style.fontSize();
2671
 
                                chstr = hl->ch;
2672
 
                                if (hl->ch == QChar(29))
2673
 
                                        chstr = ' ';
2674
 
                                if (hl->ch == QChar(0xA0))
2675
 
                                        chstr = ' ';
2676
 
                                if (style.effects() & 32)
2677
 
                                {
2678
 
                                        if (chstr.toUpper() != chstr)
2679
 
                                                chstr = chstr.toUpper();
2680
 
                                }
2681
 
                                if (style.effects() & 64)
2682
 
                                {
2683
 
                                        if (chstr.toUpper() != chstr)
2684
 
                                        {
2685
 
                                                tsz = style.fontSize() * Doc->typographicSettings.valueSmallCaps / 100;
2686
 
                                                chstr = chstr.toUpper();
2687
 
                                        }
2688
 
                                }
2689
 
                                if (style.effects() & 1)
2690
 
                                        tsz = style.fontSize() * Doc->typographicSettings.scalingSuperScript / 100;
2691
 
                                if (style.effects() & 2)
2692
 
                                        tsz = style.fontSize() * Doc->typographicSettings.scalingSuperScript / 100;
2693
 
                                if (style.fillColor() != CommonStrings::None)
2694
 
                                {
2695
 
                                        SetColor(style.fillColor(), style.fillShade(), &h, &s, &v, &k, gcr);
2696
 
                                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2697
 
                                }
2698
 
                                if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem()))
2699
 
                                {
2700
 
                                        PS_save();
2701
 
                                        PutStream( MatrixToStr(1.0, 0.0, 0.0, -1.0, -hl->PDx, 0.0) + "\n");
2702
 
                                        if (c->textPathFlipped)
2703
 
                                        {
2704
 
                                                PutStream("[1 0 0 -1 0 0]\n");
2705
 
                                                PutStream("[0 0 0  0 0 0] concatmatrix\n"); //???????
2706
 
                                        }
2707
 
                                        if (c->textPathType == 0)
2708
 
                                                PutStream( MatrixToStr(tangt.x(), -tangt.y(), -tangt.y(), -tangt.x(), hl->PtransX, -hl->PtransY) + "\n");
2709
 
                                        else if (c->textPathType == 1)
2710
 
                                                PutStream( MatrixToStr(1.0, 0.0, 0.0, -1.0, hl->PtransX, -hl->PtransY) + "\n");
2711
 
                                        else if (c->textPathType == 2)
2712
 
                                        {
2713
 
                                                double a = 1;
2714
 
                                                double b = -1;
2715
 
                                                if (tangt.x()< 0)
2716
 
                                                {
2717
 
                                                        a = -1;
2718
 
                                                        b = 1;
2719
 
                                                }
2720
 
                                                if (fabs(tangt.x()) > 0.1)
2721
 
                                                        PutStream( MatrixToStr(a, (tangt.y() / tangt.x()) * b, 0.0, -1.0, hl->PtransX, -hl->PtransY) + "\n");
2722
 
                                                else
2723
 
                                                        PutStream( MatrixToStr(a, 4.0, 0.0, -1.0, hl->PtransX, -hl->PtransY) + "\n");
2724
 
                                        }
2725
 
                                        PutStream("[0.0 0.0 0.0 0.0 0.0 0.0] concatmatrix\nconcat\n");
2726
 
//                                      PS_translate(0, (tsz / 10.0));
2727
 
                                        if (c->BaseOffs != 0)
2728
 
                                                PS_translate(0, -c->BaseOffs);
2729
 
                                        if (style.scaleH() != 1000)
2730
 
                                                PS_scale(style.scaleH() / 1000.0, 1);
2731
 
                                        QList<PageItem*> emG = hl->embedded.getGroupedItems();
2732
 
                                        QStack<PageItem*> groupStack;
2733
 
                                        for (int em = 0; em < emG.count(); ++em)
2734
 
                                        {
2735
 
                                                PageItem* embedded = emG.at(em);
2736
 
                                                if (embedded->isGroupControl)
2737
 
                                                {
2738
 
                                                        PS_save();
2739
 
                                                        FPointArray cl = embedded->PoLine.copy();
2740
 
                                                        QMatrix mm;
2741
 
                                                        mm.translate(embedded->gXpos * (style.scaleH() / 1000.0), ((embedded->gHeight * (style.scaleV() / 1000.0)) - embedded->gYpos * (style.scaleV() / 1000.0)) * -1);
2742
 
                                                        if (style.baselineOffset() != 0)
2743
 
                                                                mm.translate(0, embedded->gHeight * (style.baselineOffset() / 1000.0));
2744
 
                                                        if (style.scaleH() != 1000)
2745
 
                                                                mm.scale(style.scaleH() / 1000.0, 1);
2746
 
                                                        if (style.scaleV() != 1000)
2747
 
                                                                mm.scale(1, style.scaleV() / 1000.0);
2748
 
                                                        mm.rotate(embedded->rotation());
2749
 
                                                        cl.map( mm );
2750
 
                                                        SetClipPath(&cl);
2751
 
                                                        PS_closepath();
2752
 
                                                        PS_clip(true);
2753
 
                                                        groupStack.push(embedded->groupsLastItem);
2754
 
                                                        continue;
2755
 
                                                }
2756
 
                                                PS_save();
2757
 
                                                PS_translate(embedded->gXpos * (style.scaleH() / 1000.0), ((embedded->gHeight * (style.scaleV() / 1000.0)) - embedded->gYpos * (style.scaleV() / 1000.0)));
2758
 
                                                if (style.baselineOffset() != 0)
2759
 
                                                        PS_translate(0, embedded->gHeight * (style.baselineOffset() / 1000.0));
2760
 
                                                if (style.scaleH() != 1000)
2761
 
                                                        PS_scale(style.scaleH() / 1000.0, 1);
2762
 
                                                if (style.scaleV() != 1000)
2763
 
                                                        PS_scale(1, style.scaleV() / 1000.0);
2764
 
                                                ProcessItem(Doc, a, embedded, PNr, sep, farb, ic, gcr, master, true);
2765
 
                                                PS_restore();
2766
 
                                                if (groupStack.count() != 0)
2767
 
                                                {
2768
 
                                                        while (embedded == groupStack.top())
2769
 
                                                        {
2770
 
                                                                PS_restore();
2771
 
                                                                groupStack.pop();
2772
 
                                                                if (groupStack.count() == 0)
2773
 
                                                                        break;
2774
 
                                                        }
2775
 
                                                }
2776
 
                                        }
2777
 
                                        PS_restore();
2778
 
                                        continue;
2779
 
                                }
2780
 
                                /* Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed */
2781
 
                                if (FontSubsetMap.contains(style.font().scName()))
2782
 
                                {
2783
 
//                                      uint chr = chstr.unicode();
2784
 
                                        uint chr = style.font().char2CMap(chstr);
2785
 
                                        if (style.font().canRender(chstr))
2786
 
                                        {
2787
 
                                                PS_save();
2788
 
                                                if (style.fillColor() != CommonStrings::None)
2789
 
                                                {
2790
 
                                                        PutStream( MatrixToStr(1.0, 0.0, 0.0, -1.0, -hl->PDx, 0.0) + "\n");
2791
 
                                                        if (c->textPathFlipped)
2792
 
                                                        {
2793
 
                                                                PutStream("[1.0 0.0 0.0 -1.0 0.0 0.0]\n");
2794
 
                                                                PutStream("[0.0 0.0 0.0  0.0 0.0 0.0] concatmatrix\n");
2795
 
                                                        }
2796
 
                                                        if (c->textPathType == 0)
2797
 
                                                                PutStream( MatrixToStr(tangt.x(), -tangt.y(), -tangt.y(), -tangt.x(), hl->PtransX, -hl->PtransY) + "\n");
2798
 
                                                        else if (c->textPathType == 1)
2799
 
                                                                PutStream( MatrixToStr(1.0, 0.0, 0.0, -1.0, hl->PtransX, -hl->PtransY) + "\n");
2800
 
                                                        else if (c->textPathType == 2)
2801
 
                                                        {
2802
 
                                                                double a = 1;
2803
 
                                                                double b = -1;
2804
 
                                                                if (tangt.x() < 0)
2805
 
                                                                {
2806
 
                                                                        a = -1;
2807
 
                                                                        b = 1;
2808
 
                                                                }
2809
 
                                                                if (fabs(tangt.x()) > 0.1)
2810
 
                                                                        PutStream( MatrixToStr(a, (tangt.y() / tangt.x()) * b, 0.0, -1.0, hl->PtransX, -hl->PtransY) + "\n");
2811
 
                                                                else
2812
 
                                                                        PutStream( MatrixToStr(a, 4.0, 0.0, -1.0, hl->PtransX, -hl->PtransY) + "\n");
2813
 
                                                        }
2814
 
                                                        PutStream("[0.0 0.0 0.0 0.0 0.0 0.0] concatmatrix\nconcat\n");
2815
 
                                                        PS_translate(0, (tsz / 10.0));
2816
 
                                                        if (c->BaseOffs != 0)
2817
 
                                                                PS_translate(0, -c->BaseOffs);
2818
 
                                                        if (hl->glyph.xoffset !=0 || hl->glyph.yoffset != 0)
2819
 
                                                                PS_translate(hl->glyph.xoffset, -hl->glyph.yoffset);
2820
 
                                                        if (style.scaleH() != 1000)
2821
 
                                                                PS_scale(style.scaleH() / 1000.0, 1);
2822
 
                                                        if (((style.effects() & ScStyle_Underline) && !SpecialChars::isBreak(chstr)) //FIXME && (chstr != QChar(13)))  
2823
 
                                                                || ((style.effects() & ScStyle_UnderlineWords) && !chstr.isSpace() && !SpecialChars::isBreak(chstr)))
2824
 
                                                        {
2825
 
                                                                PS_save();
2826
 
                                                                PS_translate(0, -(tsz / 10.0));
2827
 
                                                                double Ulen = hl->glyph.xadvance;
2828
 
                                                                double Upos, Uwid, kern;
2829
 
                                                                if (style.effects() & ScStyle_StartOfLine)
2830
 
                                                                        kern = 0;
2831
 
                                                                else
2832
 
                                                                        kern = style.fontSize() * style.tracking() / 10000.0;
2833
 
                                                                if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1))
2834
 
                                                                {
2835
 
                                                                        if (style.underlineOffset() != -1)
2836
 
                                                                                Upos = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0));
2837
 
                                                                        else
2838
 
                                                                                Upos = style.font().underlinePos(style.fontSize() / 10.0);
2839
 
                                                                        if (style.underlineWidth() != -1)
2840
 
                                                                                Uwid = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0);
2841
 
                                                                        else
2842
 
                                                                                Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2843
 
                                                                }
2844
 
                                                                else
2845
 
                                                                {
2846
 
                                                                        Upos = style.font().underlinePos(style.fontSize() / 10.0);
2847
 
                                                                        Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2848
 
                                                                }
2849
 
                                                                if (style.baselineOffset() != 0)
2850
 
                                                                        Upos += (style.fontSize() / 10.0) * hl->glyph.scaleV * (style.baselineOffset() / 1000.0);
2851
 
                                                                if (style.fillColor() != CommonStrings::None)
2852
 
                                                                {
2853
 
                                                                        SetColor(style.fillColor(), style.fillShade(), &h, &s, &v, &k, gcr);
2854
 
                                                                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2855
 
                                                                }
2856
 
                                                                PS_setlinewidth(Uwid);
2857
 
                                                                if (style.effects() & ScStyle_Subscript)
2858
 
                                                                {
2859
 
                                                                        PS_moveto(hl->glyph.xoffset     , Upos);
2860
 
                                                                        PS_lineto(hl->glyph.xoffset+Ulen, Upos);
2861
 
                                                                }
2862
 
                                                                else
2863
 
                                                                {
2864
 
                                                                        PS_moveto(hl->glyph.xoffset     , hl->glyph.yoffset+Upos);
2865
 
                                                                        PS_lineto(hl->glyph.xoffset+Ulen, hl->glyph.yoffset+Upos);
2866
 
                                                                }
2867
 
                                                                putColor(style.fillColor(), style.fillShade(), false);
2868
 
                                                                PS_restore();
2869
 
                                                        }
2870
 
                                                        if (chstr != ' ')
2871
 
                                                        {
2872
 
                                                                if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None))
2873
 
                                                                {
2874
 
                                                                        PS_save();
2875
 
                                                                        PS_translate(style.fontSize() * style.shadowXOffset() / 10000.0, style.fontSize() * style.shadowYOffset() / 10000.0);
2876
 
                                                                        putColorNoDraw(style.strokeColor(), style.strokeShade(), gcr);
2877
 
                                                                        PS_showSub(chr, FontSubsetMap[style.font().scName()], tsz / 10.0, false);
2878
 
                                                                        PS_restore();
2879
 
                                                                }
2880
 
                                                                putColorNoDraw(style.fillColor(), style.fillShade(), gcr);
2881
 
                                                                PS_showSub(chr, FontSubsetMap[style.font().scName()], tsz / 10.0, false);
2882
 
                                                                if ((style.effects() & ScStyle_Outline))
2883
 
                                                                {
2884
 
                                                                        if ((style.strokeColor() != CommonStrings::None) && ((tsz * style.outlineWidth() / 10000.0) != 0))
2885
 
                                                                        {
2886
 
                                                                                PS_save();
2887
 
                                                                                PS_setlinewidth(tsz * style.outlineWidth() / 10000.0);
2888
 
                                                                                putColorNoDraw(style.strokeColor(), style.strokeShade(), gcr);
2889
 
                                                                                PS_showSub(chr, FontSubsetMap[style.font().scName()], tsz / 10.0, true);
2890
 
                                                                                PS_restore();
2891
 
                                                                        }
2892
 
                                                                }
2893
 
                                                        }
2894
 
                                                        if ((style.effects() & ScStyle_Strikethrough) && (chstr != SpecialChars::PARSEP))
2895
 
                                                        {
2896
 
                                                                PS_save();
2897
 
                                                                PS_translate(0, -(tsz / 10.0));
2898
 
                                                                double Ulen = hl->glyph.xadvance;
2899
 
                                                                double Upos, Uwid, kern;
2900
 
                                                                if (hl->effects() & ScStyle_StartOfLine)
2901
 
                                                                        kern = 0;
2902
 
                                                                else
2903
 
                                                                        kern = style.fontSize() * style.tracking() / 10000.0;
2904
 
                                                                if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1))
2905
 
                                                                {
2906
 
                                                                        if (style.strikethruOffset() != -1)
2907
 
                                                                                Upos = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0));
2908
 
                                                                        else
2909
 
                                                                                Upos = style.font().strikeoutPos(style.fontSize() / 10.0);
2910
 
                                                                        if (style.strikethruWidth() != -1)
2911
 
                                                                                Uwid = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0);
2912
 
                                                                        else
2913
 
                                                                                Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2914
 
                                                                }
2915
 
                                                                else
2916
 
                                                                {
2917
 
                                                                        Upos = style.font().strikeoutPos(style.fontSize() / 10.0);
2918
 
                                                                        Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2919
 
                                                                }
2920
 
                                                                if (style.baselineOffset() != 0)
2921
 
                                                                        Upos += (style.fontSize() / 10.0) * hl->glyph.scaleV * (style.baselineOffset() / 1000.0);
2922
 
                                                                if (style.fillColor() != CommonStrings::None)
2923
 
                                                                {
2924
 
                                                                        SetColor(style.fillColor(), style.fillShade(), &h, &s, &v, &k, gcr);
2925
 
                                                                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
2926
 
                                                                }
2927
 
                                                                PS_setlinewidth(Uwid);
2928
 
                                                                PS_moveto(hl->glyph.xoffset     , Upos);
2929
 
                                                                PS_lineto(hl->glyph.xoffset+Ulen, Upos);
2930
 
                                                                putColor(style.fillColor(), style.fillShade(), false);
2931
 
                                                                PS_restore();
2932
 
                                                        }
2933
 
                                                }
2934
 
                                                PS_restore();
2935
 
                                        }
2936
 
                                }
2937
 
                                else
2938
 
                                {
2939
 
                                        uint glyph = hl->glyph.glyph;
2940
 
                                        PS_selectfont(style.font().replacementName(), tsz / 10.0);
2941
 
                                        PS_save();
2942
 
                                        PutStream( MatrixToStr(1.0, 0.0, 0.0, -1.0, -hl->PDx, 0.0) + "\n");
2943
 
                                        if (c->textPathFlipped)
2944
 
                                        {
2945
 
                                                PutStream("[1.0 0.0 0.0 -1.0 0.0 0.0]\n");
2946
 
                                                PutStream("[0.0 0.0 0.0  0.0 0.0 0.0] concatmatrix\n");
2947
 
                                        }
2948
 
                                        if (c->textPathType == 0)
2949
 
                                                PutStream( MatrixToStr(tangt.x(), -tangt.y(), -tangt.y(), -tangt.x(), hl->PtransX, -hl->PtransY) + "\n");
2950
 
                                        else if (c->textPathType == 1)
2951
 
                                                PutStream( MatrixToStr(1.0, 0.0, 0.0, -1.0, hl->PtransX, -hl->PtransY) + "\n");
2952
 
                                        else if (c->textPathType == 2)
2953
 
                                        {
2954
 
                                                double a = 1;
2955
 
                                                double b = -1;
2956
 
                                                if (tangt.x() < 0)
2957
 
                                                {
2958
 
                                                        a = -1;
2959
 
                                                        b = 1;
2960
 
                                                }
2961
 
                                                if (fabs(tangt.x()) > 0.1)
2962
 
                                                        PutStream( MatrixToStr(a, (tangt.y() / tangt.x()) * b, 0.0, -1.0, hl->PtransX, -hl->PtransY) + "\n");
2963
 
                                                else
2964
 
                                                        PutStream( MatrixToStr(a, 4.0, 0.0, -1.0, hl->PtransX, -hl->PtransY) + "\n");
2965
 
                                        }
2966
 
                                        PutStream("[0.0 0.0 0.0 0.0 0.0 0.0] concatmatrix\nconcat\n");
2967
 
                                        if (c->BaseOffs != 0)
2968
 
                                                PS_translate(0, -c->BaseOffs);
2969
 
                                        if (hl->glyph.xoffset !=0 || hl->glyph.yoffset != 0)
2970
 
                                                PS_translate(hl->glyph.xoffset, -hl->glyph.yoffset);
2971
 
                                        if (((style.effects() & ScStyle_Underline) && !SpecialChars::isBreak(chstr)) //FIXME && (chstr != QChar(13)))  
2972
 
                                                || ((style.effects() & ScStyle_UnderlineWords) && !chstr.isSpace() && !SpecialChars::isBreak(chstr)))
2973
 
                                        {
2974
 
                                                PS_save();
2975
 
                                                double Ulen = hl->glyph.xadvance;
2976
 
                                                double Upos, Uwid, kern;
2977
 
                                                if (style.effects() & ScStyle_StartOfLine)
2978
 
                                                        kern = 0;
2979
 
                                                else
2980
 
                                                        kern = style.fontSize() * style.tracking() / 10000.0;
2981
 
                                                if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1))
2982
 
                                                {
2983
 
                                                        if (style.underlineOffset() != -1)
2984
 
                                                                Upos = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0));
2985
 
                                                        else
2986
 
                                                                Upos = style.font().underlinePos(style.fontSize() / 10.0);
2987
 
                                                        if (style.underlineWidth() != -1)
2988
 
                                                                Uwid = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0);
2989
 
                                                        else
2990
 
                                                                Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2991
 
                                                }
2992
 
                                                else
2993
 
                                                {
2994
 
                                                        Upos = style.font().underlinePos(style.fontSize() / 10.0);
2995
 
                                                        Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2996
 
                                                }
2997
 
                                                if (style.baselineOffset() != 0)
2998
 
                                                        Upos += (style.fontSize() / 10.0) * hl->glyph.scaleV * (style.baselineOffset() / 1000.0);
2999
 
                                                if (style.fillColor() != CommonStrings::None)
3000
 
                                                {
3001
 
                                                        SetColor(style.fillColor(), style.fillShade(), &h, &s, &v, &k, gcr);
3002
 
                                                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
3003
 
                                                }
3004
 
                                                PS_setlinewidth(Uwid);
3005
 
                                                if (style.effects() & ScStyle_Subscript)
3006
 
                                                {
3007
 
                                                        PS_moveto(hl->glyph.xoffset     , Upos);
3008
 
                                                        PS_lineto(hl->glyph.xoffset+Ulen, Upos);
3009
 
                                                }
3010
 
                                                else
3011
 
                                                {
3012
 
                                                        PS_moveto(hl->glyph.xoffset     , hl->glyph.yoffset+Upos);
3013
 
                                                        PS_lineto(hl->glyph.xoffset+Ulen, hl->glyph.yoffset+Upos);
3014
 
                                                }
3015
 
                                                putColor(style.fillColor(), style.fillShade(), false);
3016
 
                                                PS_restore();
3017
 
                                        }
3018
 
                                        if (chstr != ' ')
3019
 
                                        {
3020
 
                                                if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None))
3021
 
                                                {
3022
 
                                                        PS_save();
3023
 
                                                        PS_translate(style.fontSize() * style.shadowXOffset() / 10000.0, style.fontSize() * style.shadowYOffset() / 10000.0);
3024
 
                                                        PS_show_xyG(style.font().replacementName(), glyph, 0, 0, style.strokeColor(), style.strokeShade());
3025
 
                                                        PS_restore();
3026
 
                                                }
3027
 
                                                PS_show_xyG(style.font().replacementName(), glyph, 0, 0, style.fillColor(), style.fillShade());
3028
 
                                                if ((style.effects() & ScStyle_Outline))
3029
 
                                                {
3030
 
                                                        if ((style.strokeColor() != CommonStrings::None) && ((tsz * style.outlineWidth() / 10000.0) != 0))
3031
 
                                                        {
3032
 
                                                                uint gl = style.font().char2CMap(chstr);
3033
 
                                                                FPointArray gly = style.font().glyphOutline(gl);
3034
 
                                                                QMatrix chma;
3035
 
                                                                chma.scale(tsz / 100.0, tsz / 100.0);
3036
 
                                                                gly.map(chma);
3037
 
                                                                PS_save();
3038
 
                                                                PS_setlinewidth(tsz * style.outlineWidth() / 10000.0);
3039
 
                                                                PS_translate(0,  tsz / 10.0);
3040
 
                                                                SetColor(style.strokeColor(), style.strokeShade(), &h, &s, &v, &k, gcr);
3041
 
                                                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
3042
 
                                                                SetClipPath(&gly);
3043
 
                                                                PS_closepath();
3044
 
                                                                putColor(style.strokeColor(), style.strokeShade(), false);
3045
 
                                                                PS_restore();
3046
 
                                                        }
3047
 
                                                }
3048
 
                                        }
3049
 
                                        if ((style.effects() & ScStyle_Strikethrough) && (chstr != SpecialChars::PARSEP))
3050
 
                                        {
3051
 
                                                PS_save();
3052
 
                                                double Ulen = hl->glyph.xadvance;
3053
 
                                                double Upos, Uwid, kern;
3054
 
                                                if (hl->effects() & ScStyle_StartOfLine)
3055
 
                                                        kern = 0;
3056
 
                                                else
3057
 
                                                        kern = style.fontSize() * style.tracking() / 10000.0;
3058
 
                                                if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1))
3059
 
                                                {
3060
 
                                                        if (style.strikethruOffset() != -1)
3061
 
                                                                Upos = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0));
3062
 
                                                        else
3063
 
                                                                Upos = style.font().strikeoutPos(style.fontSize() / 10.0);
3064
 
                                                        if (style.strikethruWidth() != -1)
3065
 
                                                                Uwid = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0);
3066
 
                                                        else
3067
 
                                                                Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
3068
 
                                                }
3069
 
                                                else
3070
 
                                                {
3071
 
                                                        Upos = style.font().strikeoutPos(style.fontSize() / 10.0);
3072
 
                                                        Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
3073
 
                                                }
3074
 
                                                if (style.baselineOffset() != 0)
3075
 
                                                        Upos += (style.fontSize() / 10.0) * hl->glyph.scaleV * (style.baselineOffset() / 1000.0);
3076
 
                                                if (style.fillColor() != CommonStrings::None)
3077
 
                                                if (style.fillColor() != CommonStrings::None)
3078
 
                                                {
3079
 
                                                        SetColor(style.fillColor(), style.fillShade(), &h, &s, &v, &k, gcr);
3080
 
                                                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
3081
 
                                                }
3082
 
                                                PS_setlinewidth(Uwid);
3083
 
                                                PS_moveto(hl->glyph.xoffset     , Upos);
3084
 
                                                PS_lineto(hl->glyph.xoffset+Ulen, Upos);
3085
 
                                                putColor(style.fillColor(), style.fillShade(), false);
3086
 
                                                PS_restore();
3087
 
                                        }
3088
 
                                        PS_restore();
3089
 
                                }
3090
 
                        }
3091
 
#endif
3092
 
                        break;
3093
 
                default:
3094
 
                        break;
3095
 
                }
3096
 
                PS_restore();
3097
 
        }
3098
 
        return true;
3099
 
}
3100
 
 
3101
 
void PSLib::ProcessPage(ScribusDoc* Doc, Page* a, uint PNr, bool sep, bool farb, bool ic, bool gcr)
3102
 
{
3103
 
        int b;
3104
 
        int h, s, v, k;
3105
 
        QByteArray chstrc;
3106
 
        QString chstr, chglyph, tmp;
3107
 
        PageItem *c;
3108
 
        QList<PageItem*> PItems;
3109
 
        QStack<PageItem*> groupStack;
3110
 
        int Lnr = 0;
3111
 
        ScLayer ll;
3112
 
        ll.isPrintable = false;
3113
 
        ll.LNr = 0;
3114
 
        PItems = (a->pageName().isEmpty()) ? Doc->DocItems : Doc->MasterItems;
3115
 
        for (int la = 0; la < Doc->Layers.count(); ++la)
3116
 
        {
3117
 
                Doc->Layers.levelToLayer(ll, Lnr);
3118
 
                if (ll.isPrintable && !abortExport)
3119
 
                {
3120
 
                        for (b = 0; b < PItems.count() && !abortExport; ++b)
3121
 
                        {
3122
 
                                c = PItems.at(b);
3123
 
                                if (usingGUI)
3124
 
                                        ScQApp->processEvents();
3125
 
                                if (c->LayerNr != ll.LNr)
3126
 
                                        continue;
3127
 
                                if ((!a->pageName().isEmpty()) && (c->asTextFrame()))
3128
 
                                        continue;
3129
 
                                if ((!a->pageName().isEmpty()) && (c->asImageFrame()) && ((sep) || (!farb)))
3130
 
                                        continue;
3131
 
                                //if ((!Art) && (view->SelItem.count() != 0) && (!c->Select))
3132
 
                                if ((!psExport) && (!c->isSelected()) && (Doc->m_Selection->count() != 0))
3133
 
                                        continue;
3134
 
                                double bLeft, bRight, bBottom, bTop;
3135
 
                                GetBleeds(a, bLeft, bRight, bBottom, bTop);
3136
 
                                double x  = a->xOffset() - bLeft;
3137
 
                                double y  = a->yOffset() - bTop;
3138
 
                                double w  = a->width() + bLeft + bRight;
3139
 
                                double h1 = a->height() + bBottom + bTop;
3140
 
                                double ilw = c->lineWidth();
3141
 
                                double x2 = c->BoundingX - ilw / 2.0;
3142
 
                                double y2 = c->BoundingY - ilw / 2.0;
3143
 
                                double w2 = qMax(c->BoundingW + ilw, 1.0);
3144
 
                                double h2 = qMax(c->BoundingH + ilw, 1.0);
3145
 
                                if (!( qMax( x, x2 ) <= qMin( x+w, x2+w2 ) && qMax( y, y2 ) <= qMin( y+h1, y2+h2 )))
3146
 
                                        continue;
3147
 
                                if (c->ChangedMasterItem)
3148
 
                                        continue;
3149
 
                                if ((!a->pageName().isEmpty()) && (c->OwnPage != static_cast<int>(a->pageNr())) && (c->OwnPage != -1))
3150
 
                                        continue;
3151
 
                                if (c->isGroupControl)
3152
 
                                {
3153
 
                                        PS_save();
3154
 
                                        FPointArray cl = c->PoLine.copy();
3155
 
                                        QMatrix mm;
3156
 
                                        mm.translate(c->xPos() - a->xOffset(), (c->yPos() - a->yOffset()) - a->height());
3157
 
                                        mm.rotate(c->rotation());
3158
 
                                        cl.map( mm );
3159
 
                                        SetClipPath(&cl);
3160
 
                                        PS_closepath();
3161
 
                                        PS_clip(true);
3162
 
                                        groupStack.push(c->groupsLastItem);
3163
 
                                        continue;
3164
 
                                }
3165
 
                                ProcessItem(Doc, a, c, PNr, sep, farb, ic, gcr, false);
3166
 
                                if (groupStack.count() != 0)
3167
 
                                {
3168
 
                                        while (c == groupStack.top())
3169
 
                                        {
3170
 
                                                PS_restore();
3171
 
                                                groupStack.pop();
3172
 
                                                if (groupStack.count() == 0)
3173
 
                                                        break;
3174
 
                                        }
3175
 
                                }
3176
 
                        }
3177
 
                }
3178
 
                for (b = 0; b < PItems.count() && !abortExport; ++b)
3179
 
                {
3180
 
                        c = PItems.at(b);
3181
 
                        if (usingGUI)
3182
 
                                ScQApp->processEvents();
3183
 
                        if (c->LayerNr != ll.LNr)
3184
 
                                continue;
3185
 
                        if ((!a->pageName().isEmpty()) && (c->asTextFrame()))
3186
 
                                continue;
3187
 
                        if ((!a->pageName().isEmpty()) && (c->asImageFrame()) && ((sep) || (!farb)))
3188
 
                                continue;
3189
 
                        double bLeft, bRight, bBottom, bTop;
3190
 
                        GetBleeds(a, bLeft, bRight, bBottom, bTop);
3191
 
                        double x = a->xOffset() - bLeft;
3192
 
                        double y = a->yOffset() - bTop;
3193
 
                        double w = a->width() + bLeft + bRight;
3194
 
                        double h1 = a->height() + bBottom + bTop;
3195
 
                        double ilw=c->lineWidth();
3196
 
                        double x2 = c->BoundingX - ilw / 2.0;
3197
 
                        double y2 = c->BoundingY - ilw / 2.0;
3198
 
                        double w2 = qMax(c->BoundingW + ilw, 1.0);
3199
 
                        double h2 = qMax(c->BoundingH + ilw, 1.0);
3200
 
                        if (!( qMax( x, x2 ) <= qMin( x+w, x2+w2 ) && qMax( y, y2 ) <= qMin( y+h1, y2+h2 )))
3201
 
                                continue;
3202
 
                        if (c->ChangedMasterItem)
3203
 
                                continue;
3204
 
                        if (!c->isTableItem)
3205
 
                                continue;
3206
 
                        if (c->lineColor() == CommonStrings::None) //|| (c->lineWidth() == 0.0))
3207
 
                                continue;
3208
 
                        if ((!a->pageName().isEmpty()) && (c->OwnPage != static_cast<int>(a->pageNr())) && (c->OwnPage != -1))
3209
 
                                continue;
3210
 
                        if (c->printEnabled())
3211
 
                        {
3212
 
                                PS_save();
3213
 
                                if (c->doOverprint)
3214
 
                                {
3215
 
                                        PutStream("true setoverprint\n");
3216
 
                                        PutStream("true setoverprintmode\n");
3217
 
                                }
3218
 
                                if (c->lineColor() != CommonStrings::None)
3219
 
                                {
3220
 
                                        SetColor(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
3221
 
                                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
3222
 
                                }
3223
 
                                PS_setlinewidth(c->lineWidth());
3224
 
                                PS_setcapjoin(c->PLineEnd, c->PLineJoin);
3225
 
                                PS_setdash(c->PLineArt, c->DashOffset, c->DashValues);
3226
 
                                PS_translate(c->xPos() - a->xOffset(), a->height() - (c->yPos() - a->yOffset()));
3227
 
                                if (c->rotation() != 0)
3228
 
                                        PS_rotate(-c->rotation());
3229
 
                                if ((c->TopLine) || (c->RightLine) || (c->BottomLine) || (c->LeftLine))
3230
 
                                {
3231
 
                                        if (c->TopLine)
3232
 
                                        {
3233
 
                                                PS_moveto(0, 0);
3234
 
                                                PS_lineto(c->width(), 0);
3235
 
                                        }
3236
 
                                        if (c->RightLine)
3237
 
                                        {
3238
 
                                                PS_moveto(c->width(), 0);
3239
 
                                                PS_lineto(c->width(), -c->height());
3240
 
                                        }
3241
 
                                        if (c->BottomLine)
3242
 
                                        {
3243
 
                                                PS_moveto(0, -c->height());
3244
 
                                                PS_lineto(c->width(), -c->height());
3245
 
                                        }
3246
 
                                        if (c->LeftLine)
3247
 
                                        {
3248
 
                                                PS_moveto(0, 0);
3249
 
                                                PS_lineto(0, -c->height());
3250
 
                                        }
3251
 
                                        putColor(c->lineColor(), c->lineShade(), false);
3252
 
                                }
3253
 
                                PS_restore();
3254
 
                        }
3255
 
                }
3256
 
                Lnr++;
3257
 
        }
3258
 
}
3259
 
 
3260
 
void PSLib::HandleGradient(PageItem *c, double w, double h, bool gcr)
3261
 
{
3262
 
        int ch,cs,cv,ck;
3263
 
        double StartX = 0;
3264
 
        double StartY = 0;
3265
 
        double EndX = 0;
3266
 
        double EndY =0;
3267
 
        ScPattern *pat;
3268
 
        QMatrix patternMatrix;
3269
 
        double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation;
3270
 
        QList<VColorStop*> cstops = c->fill_gradient.colorStops();
3271
 
        switch (c->GrType)
3272
 
        {
3273
 
/*              case 1:
3274
 
                        StartX = 0;
3275
 
                        StartY = h / 2.0;
3276
 
                        EndX = w;
3277
 
                        EndY = h / 2.0;
3278
 
                        break;
3279
 
                case 2:
3280
 
                        StartX = w / 2.0;
3281
 
                        StartY = 0;
3282
 
                        EndX = w / 2.0;
3283
 
                        EndY = h;
3284
 
                        break;
3285
 
                case 3:
3286
 
                        StartX = 0;
3287
 
                        StartY = 0;
3288
 
                        EndX = w;
3289
 
                        EndY = h;
3290
 
                        break;
3291
 
                case 4:
3292
 
                        StartX = 0;
3293
 
                        StartY = h;
3294
 
                        EndX = w;
3295
 
                        EndY = 0;
3296
 
                        break;
3297
 
                case 5:
3298
 
                        StartX = w / 2.0;
3299
 
                        StartY = h / 2.0;
3300
 
                        if (w >= h)
3301
 
                        {
3302
 
                                EndX = w;
3303
 
                                EndY = h / 2.0;
3304
 
                        }
3305
 
                        else
3306
 
                        {
3307
 
                                EndX = w / 2.0;
3308
 
                                EndY = h;
3309
 
                        }
3310
 
                        break; */
3311
 
                case 1:
3312
 
                case 2:
3313
 
                case 3:
3314
 
                case 4:
3315
 
                case 5:
3316
 
                case 6:
3317
 
                case 7:
3318
 
                        StartX = c->GrStartX;
3319
 
                        StartY = c->GrStartY;
3320
 
                        EndX = c->GrEndX;
3321
 
                        EndY = c->GrEndY;
3322
 
                        break;
3323
 
                case 8:
3324
 
                        pat = &m_Doc->docPatterns[c->pattern()];
3325
 
                        uint patHash = qHash(c->pattern());
3326
 
                        c->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
3327
 
                        patternMatrix.translate(patternOffsetX, -patternOffsetY);
3328
 
                        patternMatrix.rotate(-patternRotation);
3329
 
                        patternMatrix.scale(pat->scaleX, pat->scaleY);
3330
 
                        patternMatrix.scale(patternScaleX / 100.0 , patternScaleY / 100.0);
3331
 
                        PutStream("Pattern"+QString::number(patHash)+" ["+ToStr(patternMatrix.m11())+" "+ToStr(patternMatrix.m12())+" "+ToStr(patternMatrix.m21())+" "+ToStr(patternMatrix.m22())+" "+ToStr(patternMatrix.dx())+" "+ToStr(patternMatrix.dy())+"] makepattern setpattern\n");
3332
 
                        if (fillRule)
3333
 
                                PutStream("eofill\n");
3334
 
                        else
3335
 
                                PutStream("fill\n");
3336
 
                        return;
3337
 
                        break;
3338
 
        }
3339
 
        QList<double> StopVec;
3340
 
        QStringList Gcolors;
3341
 
        QStringList colorNames;
3342
 
        QList<int> colorShades;
3343
 
        QString hs,ss,vs,ks;
3344
 
        double lastStop = -1.0;
3345
 
        double actualStop = 0.0;
3346
 
        bool isFirst = true;
3347
 
        if ((c->GrType == 5) || (c->GrType == 7))
3348
 
        {
3349
 
                StopVec.clear();
3350
 
                for (uint cst = 0; cst < c->fill_gradient.Stops(); ++cst)
3351
 
                {
3352
 
                        actualStop = cstops.at(cst)->rampPoint;
3353
 
                        if ((actualStop != lastStop) || (isFirst))
3354
 
                        {
3355
 
                                isFirst = false;
3356
 
                                lastStop = actualStop;
3357
 
                                StopVec.prepend(sqrt(pow(EndX - StartX, 2) + pow(EndY - StartY,2))*cstops.at(cst)->rampPoint);
3358
 
                                SetColor(cstops.at(cst)->name, cstops.at(cst)->shade, &ch, &cs, &cv, &ck, gcr);
3359
 
                                QString GCol;
3360
 
                                if (GraySc)
3361
 
                                        GCol = hs.setNum((255.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 255.0))  / 255.0);
3362
 
                                else
3363
 
                                        GCol = hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
3364
 
                                Gcolors.prepend(GCol);
3365
 
                                colorNames.prepend(cstops.at(cst)->name);
3366
 
                                colorShades.prepend(cstops.at(cst)->shade);
3367
 
                        }
3368
 
                }
3369
 
                PS_MultiRadGradient(w, -h, StartX, -StartY, StopVec, Gcolors, colorNames, colorShades);
3370
 
        }
3371
 
        else
3372
 
        {
3373
 
                StopVec.clear();
3374
 
                for (uint cst = 0; cst < c->fill_gradient.Stops(); ++cst)
3375
 
                {
3376
 
                        actualStop = cstops.at(cst)->rampPoint;
3377
 
                        if ((actualStop != lastStop) || (isFirst))
3378
 
                        {
3379
 
                                isFirst = false;
3380
 
                                lastStop = actualStop;
3381
 
                                double x = (1 - cstops.at(cst)->rampPoint) * StartX + cstops.at(cst)->rampPoint * EndX;
3382
 
                                double y = (1 - cstops.at(cst)->rampPoint) * StartY + cstops.at(cst)->rampPoint * EndY;
3383
 
                                StopVec.append(x);
3384
 
                                StopVec.append(-y);
3385
 
                                SetColor(cstops.at(cst)->name, cstops.at(cst)->shade, &ch, &cs, &cv, &ck, gcr);
3386
 
                                QString GCol;
3387
 
                                if (GraySc)
3388
 
                                        GCol = hs.setNum((255.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 255.0))  / 255.0);
3389
 
                                else
3390
 
                                        GCol = hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
3391
 
                                Gcolors.append(GCol);
3392
 
                                colorNames.append(cstops.at(cst)->name);
3393
 
                                colorShades.append(cstops.at(cst)->shade);
3394
 
                        }
3395
 
                }
3396
 
                PS_MultiLinGradient(w, -h, StopVec, Gcolors, colorNames, colorShades);
3397
 
        }
3398
 
}
3399
 
 
3400
 
void PSLib::drawArrow(PageItem *ite, QMatrix &arrowTrans, int arrowIndex, bool gcr)
3401
 
{
3402
 
        int h, s, v, k;
3403
 
        QVector<double> dum;
3404
 
        FPointArray arrow = m_Doc->arrowStyles.at(arrowIndex-1).points.copy();
3405
 
        if (ite->NamedLStyle.isEmpty())
3406
 
        {
3407
 
                if (ite->lineWidth() != 0.0)
3408
 
                        arrowTrans.scale(ite->lineWidth(), ite->lineWidth());
3409
 
        }
3410
 
        else
3411
 
        {
3412
 
                multiLine ml = m_Doc->MLineStyles[ite->NamedLStyle];
3413
 
                if (ml[ml.size()-1].Width != 0.0)
3414
 
                        arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
3415
 
        }
3416
 
        arrow.map(arrowTrans);
3417
 
        if (ite->NamedLStyle.isEmpty())
3418
 
        {
3419
 
                if (ite->lineColor() != CommonStrings::None)
3420
 
                {
3421
 
                        SetColor(ite->lineColor(), ite->lineShade(), &h, &s, &v, &k, gcr);
3422
 
                        PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
3423
 
                        PS_newpath();
3424
 
                        SetClipPath(&arrow);
3425
 
                        PS_closepath();
3426
 
                        putColor(ite->lineColor(), ite->lineShade(), true);
3427
 
                }
3428
 
        }
3429
 
        else
3430
 
        {
3431
 
                multiLine ml = m_Doc->MLineStyles[ite->NamedLStyle];
3432
 
                if (ml[0].Color != CommonStrings::None)
3433
 
                {
3434
 
                        SetColor(ml[0].Color, ml[0].Shade, &h, &s, &v, &k, gcr);
3435
 
                        PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
3436
 
                        PS_newpath();
3437
 
                        SetClipPath(&arrow);
3438
 
                        PS_closepath();
3439
 
                        putColor(ite->lineColor(), ite->lineShade(), true);
3440
 
                }
3441
 
                for (int it = ml.size()-1; it > 0; it--)
3442
 
                {
3443
 
                        if (ml[it].Color != CommonStrings::None)
3444
 
                        {
3445
 
                                SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
3446
 
                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
3447
 
                                PS_setlinewidth(ml[it].Width);
3448
 
                                PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
3449
 
                                PS_setdash(Qt::SolidLine, 0, dum);
3450
 
                                SetClipPath(&arrow);
3451
 
                                PS_closepath();
3452
 
                                putColor(ml[it].Color, ml[it].Shade, false);
3453
 
                        }
3454
 
                }
3455
 
        }
3456
 
}
3457
 
 
3458
 
void PSLib::SetColor(const QString& farb, double shade, int *h, int *s, int *v, int *k, bool gcr)
3459
 
{
3460
 
        ScColor& col = m_Doc->PageColors[farb];
3461
 
        SetColor(col, shade, h, s, v, k, gcr);
3462
 
}
3463
 
 
3464
 
void PSLib::SetColor(const ScColor& farb, double shade, int *h, int *s, int *v, int *k, bool gcr)
3465
 
{
3466
 
        int h1, s1, v1, k1;
3467
 
        h1 = *h;
3468
 
        s1 = *s;
3469
 
        v1 = *v;
3470
 
        k1 = *k;
3471
 
        ScColor tmp(farb);
3472
 
        if (farb.getColorModel() == colorModelRGB)
3473
 
                tmp = ScColorEngine::convertToModel(farb, m_Doc, colorModelCMYK);
3474
 
        if ((gcr) && (!farb.isRegistrationColor()))
3475
 
                ScColorEngine::applyGCR(tmp, m_Doc);
3476
 
        tmp.getCMYK(&h1, &s1, &v1, &k1);
3477
 
        if ((m_Doc->HasCMS) && (ScCore->haveCMS()) && (applyICC))
3478
 
        {
3479
 
                h1 = qRound(h1 * shade / 100.0);
3480
 
                s1 = qRound(s1 * shade / 100.0);
3481
 
                v1 = qRound(v1 * shade / 100.0);
3482
 
                k1 = qRound(k1 * shade / 100.0);
3483
 
                unsigned short inC[4];
3484
 
                unsigned short outC[4];
3485
 
                inC[0] = h1 * 257;
3486
 
                inC[1] = s1 * 257;
3487
 
                inC[2] = v1 * 257;
3488
 
                inC[3] = k1 * 257;
3489
 
                solidTransform.apply(inC, outC, 1);
3490
 
                *h= outC[0] / 257;
3491
 
                *s = outC[1] / 257;
3492
 
                *v = outC[2] / 257;
3493
 
                *k = outC[3] / 257;
3494
 
        }
3495
 
        else
3496
 
        {
3497
 
                *h = qRound(h1 * shade / 100.0);
3498
 
                *s = qRound(s1 * shade / 100.0);
3499
 
                *v = qRound(v1 * shade / 100.0);
3500
 
                *k = qRound(k1 * shade / 100.0);
3501
 
        }
3502
 
}
3503
 
 
3504
 
void PSLib::setTextSt(ScribusDoc* Doc, PageItem* ite, bool gcr, uint argh, Page* pg, bool sep, bool farb, bool ic, bool master)
3505
 
{
3506
 
//      qDebug() << QString("pslib setTextSt: ownPage=%1 pageNr=%2 OnMasterPage=%3;").arg(ite->OwnPage).arg(pg->pageNr()).arg(ite->OnMasterPage);
3507
 
        int tabCc = 0;
3508
 
        int savedOwnPage = ite->OwnPage;
3509
 
        double tabDist = ite->textToFrameDistLeft();
3510
 
        double colLeft = 0.0;
3511
 
        QList<ParagraphStyle::TabRecord> tTabValues;
3512
 
 
3513
 
        ite->OwnPage = argh;
3514
 
        ite->layout();
3515
 
        ite->OwnPage = savedOwnPage;
3516
 
#ifndef NLS_PROTO
3517
 
        if (ite->lineColor() != CommonStrings::None)
3518
 
                tabDist += ite->lineWidth() / 2.0;
3519
 
 
3520
 
        for (uint ll=0; ll < ite->itemText.lines(); ++ll) {
3521
 
                LineSpec ls = ite->itemText.line(ll);
3522
 
                colLeft = ls.colLeft;
3523
 
                tabDist = ls.x;
3524
 
                double CurX = ls.x;
3525
 
 
3526
 
                for (int d = ls.firstItem; d <= ls.lastItem; ++d)
3527
 
                {
3528
 
                        ScText *hl = ite->itemText.item(d);
3529
 
                        const CharStyle & cstyle(ite->itemText.charStyle(d));
3530
 
                        const ParagraphStyle& pstyle(ite->itemText.paragraphStyle(d));
3531
 
                        
3532
 
//                      if ((hl->ch == QChar(13)) || (hl->ch == QChar(10)) || (hl->ch == QChar(28)) || (hl->ch == QChar(27)) || (hl->ch == QChar(26)))
3533
 
//                              continue;
3534
 
                        if (hl->effects() & 4096)
3535
 
                                continue;
3536
 
                        tTabValues = pstyle.tabValues();
3537
 
                        if (hl->effects() & 16384)
3538
 
                                tabCc = 0;
3539
 
                        if ((hl->ch == SpecialChars::TAB) && (tTabValues.count() != 0))
3540
 
                        {
3541
 
                                QChar tabFillChar;
3542
 
                                const TabLayout* tabLayout = dynamic_cast<const TabLayout*>(hl->glyph.more);
3543
 
                                if (tabLayout)
3544
 
                                        tabFillChar = tabLayout->fillChar;
3545
 
                                if (!tabFillChar.isNull())
3546
 
                                {
3547
 
                                        ScText hl2;
3548
 
                                        static_cast<CharStyle&>(hl2) = static_cast<const CharStyle&>(*hl);
3549
 
                                        const GlyphLayout * const gl = hl->glyph.more;
3550
 
                                        double scale = gl ? gl->scaleV : 1.0;
3551
 
                                        double wt    = cstyle.font().charWidth(tabFillChar, cstyle.fontSize() * scale / 10.0);
3552
 
                                        double len   = hl->glyph.xadvance;
3553
 
                                        int coun     = static_cast<int>(len / wt);
3554
 
                                        // JG - #6728 : update code according to fillInTabLeaders() and PageItem::layout()
3555
 
                                        double sPos  = 0.0 /*CurX - len + cstyle.fontSize() / 10.0 * 0.7 + 1*/;
3556
 
                                        hl2.ch = tabFillChar;
3557
 
                                        hl2.setTracking(0);
3558
 
                                        hl2.setScaleH(1000);
3559
 
                                        hl2.setScaleV(1000);
3560
 
                                        hl2.glyph.glyph   = cstyle.font().char2CMap(tabFillChar);
3561
 
                                        hl2.glyph.yoffset = hl->glyph.yoffset;
3562
 
                                        for (int cx = 0; cx < coun; ++cx)
3563
 
                                        {
3564
 
                                                hl2.glyph.xoffset =  sPos + wt * cx;
3565
 
                                                if ((hl2.effects() & 256) && (hl2.strokeColor() != CommonStrings::None))
3566
 
                                                {
3567
 
                                                        ScText hl3;
3568
 
                                                        static_cast<CharStyle&>(hl3) = static_cast<const CharStyle&>(hl2);
3569
 
                                                        hl3.ch = hl2.ch;
3570
 
                                                        hl3.glyph.glyph = hl2.glyph.glyph;
3571
 
                                                        hl3.setFillColor(hl2.strokeColor());
3572
 
                                                        hl3.glyph.yoffset = hl2.glyph.yoffset - (hl2.fontSize() * hl2.shadowYOffset() / 10000.0);
3573
 
                                                        hl3.glyph.xoffset = hl2.glyph.xoffset + (hl2.fontSize() * hl2.shadowXOffset() / 10000.0);
3574
 
                                                        setTextCh(Doc, ite, CurX, ls.y, gcr, argh, d, &hl3, pstyle, pg, sep, farb, ic, master);
3575
 
                                                }
3576
 
                                                setTextCh(Doc, ite, CurX, ls.y, gcr, argh, d, &hl2, pstyle, pg, sep, farb, ic, master);
3577
 
                                        }
3578
 
                                }
3579
 
                                tabCc++;
3580
 
                        }
3581
 
                        if (hl->ch == SpecialChars::TAB) {
3582
 
                                CurX += hl->glyph.wide();
3583
 
                                continue;
3584
 
                        }
3585
 
                        if ((cstyle.effects() & ScStyle_Shadowed) && (cstyle.strokeColor() != CommonStrings::None))
3586
 
                        {
3587
 
                                ScText hl2;
3588
 
                                static_cast<CharStyle&>(hl2) = static_cast<const CharStyle&>(*hl);
3589
 
                                hl2.ch = hl->ch;
3590
 
                                hl2.glyph.glyph = hl->glyph.glyph;
3591
 
                                const GlyphLayout *gl1 = &hl->glyph;
3592
 
                                GlyphLayout     *gl2 = &hl2.glyph;
3593
 
                                while (gl1->more)
3594
 
                                {
3595
 
                                        gl2->more = new GlyphLayout(*gl1->more);
3596
 
                                        gl2->more->yoffset -= (cstyle.fontSize() * cstyle.shadowYOffset() / 10000.0);
3597
 
                                        gl2->more->xoffset += (cstyle.fontSize() * cstyle.shadowXOffset() / 10000.0);
3598
 
                                        gl2->more->more = NULL;
3599
 
                                        gl1 = gl1->more;
3600
 
                                        gl2 = gl2->more;
3601
 
                                }
3602
 
                                hl2.setFillColor(cstyle.strokeColor());
3603
 
                                hl2.setFillShade(cstyle.strokeShade());
3604
 
                                hl2.glyph.xadvance = hl->glyph.xadvance;
3605
 
                                hl2.glyph.yadvance = hl->glyph.yadvance;
3606
 
                                hl2.glyph.yoffset = hl->glyph.yoffset - (cstyle.fontSize() * cstyle.shadowYOffset() / 10000.0);
3607
 
                                hl2.glyph.xoffset = hl->glyph.xoffset + (cstyle.fontSize() * cstyle.shadowXOffset() / 10000.0);
3608
 
                                hl2.glyph.scaleH = hl->glyph.scaleH;
3609
 
                                hl2.glyph.scaleV = hl->glyph.scaleV;
3610
 
                                
3611
 
                                setTextCh(Doc, ite, CurX, ls.y, gcr, argh, d, &hl2, pstyle, pg, sep, farb, ic, master);
3612
 
                        }
3613
 
                        setTextCh(Doc, ite, CurX, ls.y, gcr, argh, d, hl, pstyle, pg, sep, farb, ic, master);
3614
 
                        if (hl->ch == SpecialChars::OBJECT)
3615
 
                        {
3616
 
                                InlineFrame& embedded(const_cast<InlineFrame&>(hl->embedded));
3617
 
                                CurX += (embedded.getItem()->gWidth + embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
3618
 
                        }
3619
 
                        else
3620
 
                                CurX += hl->glyph.wide();
3621
 
                        tabDist = CurX;
3622
 
                }
3623
 
        }
3624
 
#endif
3625
 
}
3626
 
 
3627
 
void PSLib::setTextCh(ScribusDoc* Doc, PageItem* ite, double x, double y, bool gcr, uint argh, uint doh, ScText *hl, const ParagraphStyle& pstyle, Page* pg, bool sep, bool farb, bool ic, bool master)
3628
 
{
3629
 
        const CharStyle & cstyle(*hl);
3630
 
        const GlyphLayout & glyphs(hl->glyph);
3631
 
        uint glyph = glyphs.glyph;
3632
 
 
3633
 
        int h, s, v, k;
3634
 
        double tsz;
3635
 
        double wideR = 0.0;
3636
 
        QVector<double> dum;
3637
 
        dum.clear();
3638
 
 
3639
 
        QChar chstr = hl->ch;
3640
 
 
3641
 
        tsz = cstyle.fontSize();
3642
 
 
3643
 
/*      if (cstyle.effects() & ScStyle_DropCap)
3644
 
        {
3645
 
//              QString chstr; // dummy, FIXME: replace by glyph
3646
 
                if (pstyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
3647
 
                        tsz = qRound(10 * ((Doc->typographicSettings.valueBaseGrid *  (pstyle.dropCapLines()-1)+(cstyle.font().ascent(pstyle.charStyle().fontSize() / 10.0))) / (cstyle.font().realCharHeight(chstr, 10))));
3648
 
                else
3649
 
                {
3650
 
                        if (pstyle.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
3651
 
                                tsz = qRound(10 * ((pstyle.lineSpacing() *  (pstyle.dropCapLines()-1)+(cstyle.font().ascent(pstyle.charStyle().fontSize() / 10.0))) / (cstyle.font().realCharHeight(chstr, 10))));
3652
 
                        else
3653
 
                        {
3654
 
                                double currasce = cstyle.font().height(pstyle.charStyle().fontSize());
3655
 
                                tsz = qRound(10 * ((currasce * (pstyle.dropCapLines()-1)+(cstyle.font().ascent(pstyle.charStyle().fontSize() / 10.0))) / cstyle.font().realCharHeight(chstr, 10)));
3656
 
                        }
3657
 
                }
3658
 
        }
3659
 
        */
3660
 
        if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem()))
3661
 
        {
3662
 
                QList<PageItem*> emG = hl->embedded.getGroupedItems();
3663
 
                QStack<PageItem*> groupStack;
3664
 
                for (int em = 0; em < emG.count(); ++em)
3665
 
                {
3666
 
                        PageItem* embedded = emG.at(em);
3667
 
                        if (embedded->isGroupControl)
3668
 
                        {
3669
 
                                PS_save();
3670
 
                                FPointArray cl = embedded->PoLine.copy();
3671
 
                                QMatrix mm;
3672
 
                                mm.translate(x + hl->glyph.xoffset + embedded->gXpos * (cstyle.scaleH() / 1000.0), (y + hl->glyph.yoffset - (embedded->gHeight * (cstyle.scaleV() / 1000.0)) + embedded->gYpos * (cstyle.scaleV() / 1000.0)));
3673
 
                                if (cstyle.baselineOffset() != 0)
3674
 
                                        mm.translate(0, embedded->gHeight * (cstyle.baselineOffset() / 1000.0));
3675
 
                                if (cstyle.scaleH() != 1000)
3676
 
                                        mm.scale(cstyle.scaleH() / 1000.0, 1);
3677
 
                                if (cstyle.scaleV() != 1000)
3678
 
                                        mm.scale(1, cstyle.scaleV() / 1000.0);
3679
 
                                mm.rotate(embedded->rotation());
3680
 
                                cl.map( mm );
3681
 
                                SetClipPath(&cl);
3682
 
                                PS_closepath();
3683
 
                                PS_clip(true);
3684
 
                                groupStack.push(embedded->groupsLastItem);
3685
 
                                continue;
3686
 
                        }
3687
 
                        PS_save();
3688
 
                        PS_translate(x + hl->glyph.xoffset + embedded->gXpos * (cstyle.scaleH() / 1000.0), (y + hl->glyph.yoffset - (embedded->gHeight * (cstyle.scaleV() / 1000.0)) + embedded->gYpos * (cstyle.scaleV() / 1000.0)) * -1);
3689
 
                        if (cstyle.baselineOffset() != 0)
3690
 
                                PS_translate(0, embedded->gHeight * (cstyle.baselineOffset() / 1000.0));
3691
 
                        if (cstyle.scaleH() != 1000)
3692
 
                                PS_scale(cstyle.scaleH() / 1000.0, 1);
3693
 
                        if (cstyle.scaleV() != 1000)
3694
 
                                PS_scale(1, cstyle.scaleV() / 1000.0);
3695
 
                        ProcessItem(Doc, pg, embedded, argh, sep, farb, ic, gcr, master, true);
3696
 
                        PS_restore();
3697
 
                        if (groupStack.count() != 0)
3698
 
                        {
3699
 
                                while (embedded == groupStack.top())
3700
 
                                {
3701
 
                                        PS_restore();
3702
 
                                        groupStack.pop();
3703
 
                                        if (groupStack.count() == 0)
3704
 
                                                break;
3705
 
                                }
3706
 
                        }
3707
 
                }
3708
 
                for (int em = 0; em < emG.count(); ++em)
3709
 
                {
3710
 
                        int h, s, v, k;
3711
 
                        PageItem* item = emG.at(em);
3712
 
                        if (!item->isTableItem)
3713
 
                                continue;
3714
 
                        if ((item->lineColor() == CommonStrings::None) || (item->lineWidth() == 0.0))
3715
 
                                continue;
3716
 
                        PS_save();
3717
 
                        PS_translate(x + hl->glyph.xoffset + item->gXpos * (cstyle.scaleH() / 1000.0), (y + hl->glyph.yoffset - (item->gHeight * (cstyle.scaleV() / 1000.0)) + item->gYpos * (cstyle.scaleV() / 1000.0)) * -1);
3718
 
                        if (cstyle.baselineOffset() != 0)
3719
 
                                PS_translate(0, -item->gHeight * (cstyle.baselineOffset() / 1000.0));
3720
 
                        PS_scale(cstyle.scaleH() / 1000.0, cstyle.scaleV() / 1000.0);
3721
 
                        PS_rotate(item->rotation());
3722
 
                        double pws = item->m_lineWidth;
3723
 
                        if (item->lineColor() != CommonStrings::None)
3724
 
                        {
3725
 
                                SetColor(item->lineColor(), item->lineShade(), &h, &s, &v, &k, gcr);
3726
 
                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
3727
 
                        }
3728
 
                        PS_setlinewidth(item->lineWidth());
3729
 
                        PS_setcapjoin(Qt::SquareCap, item->PLineJoin);
3730
 
                        PS_setdash(item->PLineArt, item->DashOffset, item->DashValues);
3731
 
                        if ((item->TopLine) || (item->RightLine) || (item->BottomLine) || (item->LeftLine))
3732
 
                        {
3733
 
                                if (item->TopLine)
3734
 
                                {
3735
 
                                        PS_moveto(0, 0);
3736
 
                                        PS_lineto(item->width(), 0);
3737
 
                                }
3738
 
                                if (item->RightLine)
3739
 
                                {
3740
 
                                        PS_moveto(item->width(), 0);
3741
 
                                        PS_lineto(item->width(), -item->height());
3742
 
                                }
3743
 
                                if (item->BottomLine)
3744
 
                                {
3745
 
                                        PS_moveto(0, -item->height());
3746
 
                                        PS_lineto(item->width(), -item->height());
3747
 
                                }
3748
 
                                if (item->LeftLine)
3749
 
                                {
3750
 
                                        PS_moveto(0, 0);
3751
 
                                        PS_lineto(0, -item->height());
3752
 
                                }
3753
 
                                putColor(item->lineColor(), item->lineShade(), false);
3754
 
                        }
3755
 
                        PS_restore();
3756
 
                        item->m_lineWidth = pws;
3757
 
                }
3758
 
                return;
3759
 
        }
3760
 
 
3761
 
        if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode()) ||
3762
 
                glyph == (ScFace::CONTROL_GLYPHS + 32)) 
3763
 
        {
3764
 
                glyph = cstyle.font().char2CMap(QChar(' '));
3765
 
                chstr = ' ';
3766
 
        }
3767
 
        else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode()))
3768
 
        {
3769
 
                glyph = cstyle.font().char2CMap(QChar('-'));
3770
 
                chstr = '-';
3771
 
        }
3772
 
        
3773
 
        if (glyph < ScFace::CONTROL_GLYPHS)
3774
 
        {
3775
 
                if (((cstyle.effects() & ScStyle_Underline) && !SpecialChars::isBreak(chstr)) //FIXME && (chstr != QChar(13)))  
3776
 
                        || ((cstyle.effects() & ScStyle_UnderlineWords) && !chstr.isSpace() && !SpecialChars::isBreak(chstr)))
3777
 
                {
3778
 
        //              double Ulen = cstyle.font().glyphWidth(glyph, cstyle.fontSize()) * glyphs.scaleH;
3779
 
                        double Ulen = glyphs.xadvance;
3780
 
                        double Upos, lw, kern;
3781
 
                        if (cstyle.effects() & ScStyle_StartOfLine)
3782
 
                                kern = 0;
3783
 
                        else
3784
 
                                kern = cstyle.fontSize() * cstyle.tracking() / 10000.0;
3785
 
                        if ((cstyle.underlineOffset() != -1) || (cstyle.underlineWidth() != -1))
3786
 
                        {
3787
 
                                if (cstyle.underlineOffset() != -1)
3788
 
                                        Upos = (cstyle.underlineOffset() / 1000.0) * (cstyle.font().descent(cstyle.fontSize() / 10.0));
3789
 
                                else
3790
 
                                        Upos = cstyle.font().underlinePos(cstyle.fontSize() / 10.0);
3791
 
                                if (cstyle.underlineWidth() != -1)
3792
 
                                        lw = (cstyle.underlineWidth() / 1000.0) * (cstyle.fontSize() / 10.0);
3793
 
                                else
3794
 
                                        lw = qMax(cstyle.font().strokeWidth(cstyle.fontSize() / 10.0), 1.0);
3795
 
                        }
3796
 
                        else
3797
 
                        {
3798
 
                                Upos = cstyle.font().underlinePos(cstyle.fontSize() / 10.0);
3799
 
                                lw = qMax(cstyle.font().strokeWidth(cstyle.fontSize() / 10.0), 1.0);
3800
 
                        }
3801
 
                        if (cstyle.baselineOffset() != 0)
3802
 
                                Upos += (cstyle.fontSize() / 10.0) * glyphs.scaleV * (cstyle.baselineOffset() / 1000.0);
3803
 
                        if (cstyle.fillColor() != CommonStrings::None)
3804
 
                        {
3805
 
                                PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
3806
 
                                PS_setdash(Qt::SolidLine, 0, dum);
3807
 
                                SetColor(cstyle.fillColor(), cstyle.fillShade(), &h, &s, &v, &k, gcr);
3808
 
                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
3809
 
                        }
3810
 
                        PS_setlinewidth(lw);
3811
 
                        if (cstyle.effects() & ScStyle_Subscript)
3812
 
                        {
3813
 
                                PS_moveto(x + glyphs.xoffset     , -y - glyphs.yoffset+Upos);
3814
 
                                PS_lineto(x + glyphs.xoffset+Ulen, -y - glyphs.yoffset+Upos);
3815
 
                        }
3816
 
                        else
3817
 
                        {
3818
 
                                PS_moveto(x + glyphs.xoffset     , -y + Upos);
3819
 
                                PS_lineto(x + glyphs.xoffset+Ulen, -y + Upos);
3820
 
                        }
3821
 
                        putColor(cstyle.fillColor(), cstyle.fillShade(), false);
3822
 
                }
3823
 
                /* Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed */
3824
 
                if (FontSubsetMap.contains(cstyle.font().scName()))
3825
 
                {
3826
 
                        if (glyph != 0 && glyph != cstyle.font().char2CMap(QChar(' ')) && (!SpecialChars::isBreak(chstr)))
3827
 
                        {
3828
 
                                PS_save();
3829
 
                                if (ite->reversed())
3830
 
                                {
3831
 
                                        PS_translate(x + hl->glyph.xoffset, (y + hl->glyph.yoffset - (tsz / 10.0)) * -1);
3832
 
                                        PS_scale(-1, 1);
3833
 
                                        PS_translate(-glyphs.xadvance, 0);
3834
 
                                }
3835
 
                                else
3836
 
                                        PS_translate(x + glyphs.xoffset, (y + glyphs.yoffset - (cstyle.fontSize() / 10.0)) * -1);
3837
 
                                if (cstyle.baselineOffset() != 0)
3838
 
                                        PS_translate(0, (cstyle.fontSize() / 10.0) * (cstyle.baselineOffset() / 1000.0));
3839
 
                                if (glyphs.scaleH != 1.0)
3840
 
                                        PS_scale(glyphs.scaleH, 1);
3841
 
                                if (glyphs.scaleV != 1.0)
3842
 
                                {
3843
 
                                        PS_translate(0, -((tsz / 10.0) - (tsz / 10.0) * (glyphs.scaleV)));
3844
 
                                        PS_scale(1, glyphs.scaleV);
3845
 
                                }
3846
 
                                if (cstyle.fillColor() != CommonStrings::None)
3847
 
                                {
3848
 
                                        putColorNoDraw(cstyle.fillColor(), cstyle.fillShade(), gcr);
3849
 
                                        PS_showSub(glyph, FontSubsetMap[cstyle.font().scName()], tsz / 10.0, false);
3850
 
                                }
3851
 
                                PS_restore();
3852
 
                        }
3853
 
                }
3854
 
                else if (glyph != 0)
3855
 
                {
3856
 
                        PS_selectfont(cstyle.font().replacementName(), tsz / 10.0);
3857
 
                        PS_save();
3858
 
                        PS_translate(x + glyphs.xoffset, -y - glyphs.yoffset);
3859
 
                        if (ite->reversed())
3860
 
                        {
3861
 
                                PS_scale(-1, 1);
3862
 
                                PS_translate(glyphs.xadvance, 0);
3863
 
                        }
3864
 
                        if (cstyle.baselineOffset() != 0)
3865
 
                                PS_translate(0, (cstyle.fontSize() / 10.0) * (cstyle.baselineOffset() / 1000.0));
3866
 
                        if (glyphs.scaleH != 1.0 || glyphs.scaleV != 1.0)
3867
 
                                PS_scale(glyphs.scaleH, glyphs.scaleV);
3868
 
                        if (cstyle.fillColor() != CommonStrings::None)
3869
 
                        {
3870
 
                                PS_show_xyG(cstyle.font().replacementName(), glyph, 0, 0, cstyle.fillColor(), cstyle.fillShade());
3871
 
                        }
3872
 
                        PS_restore();
3873
 
                }
3874
 
                if ((cstyle.effects() & ScStyle_Outline) || glyph == 0)//&& (chstr != QChar(13)))
3875
 
                {
3876
 
//              if (cstyle.font().canRender(chstr))
3877
 
                        {
3878
 
                                FPointArray gly = cstyle.font().glyphOutline(glyph);
3879
 
                                QMatrix chma, chma2, chma3;
3880
 
                                chma.scale(tsz / 100.0, tsz / 100.0);
3881
 
                                chma2.scale(glyphs.scaleH, glyphs.scaleV);
3882
 
                                if (cstyle.baselineOffset() != 0)
3883
 
                                        chma3.translate(0, -(cstyle.fontSize() / 10.0) * (cstyle.baselineOffset() / 1000.0));
3884
 
                                gly.map(chma * chma2 * chma3);
3885
 
                                if (ite->reversed())
3886
 
                                {
3887
 
                                        chma = QMatrix();
3888
 
                                        chma.scale(-1, 1);
3889
 
                                        chma.translate(wideR, 0);
3890
 
                                        gly.map(chma);
3891
 
                                }
3892
 
                                if ((cstyle.strokeColor() != CommonStrings::None) && ((tsz * cstyle.outlineWidth() / 10000.0) != 0))
3893
 
                                {
3894
 
                                        PS_save();
3895
 
                                        PS_setlinewidth(tsz * cstyle.outlineWidth() / 10000.0);
3896
 
                                        PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
3897
 
                                        PS_setdash(Qt::SolidLine, 0, dum);
3898
 
                                        PS_translate(x + glyphs.xoffset, (y + glyphs.yoffset - (tsz / 10.0)) * -1);
3899
 
                                        PS_translate(0, -((tsz / 10.0) - (tsz / 10.0) * glyphs.scaleV));
3900
 
                                        SetColor(cstyle.strokeColor(), cstyle.strokeShade(), &h, &s, &v, &k, gcr);
3901
 
                                        PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
3902
 
                                        SetClipPath(&gly);
3903
 
                                        PS_closepath();
3904
 
                                        putColor(cstyle.strokeColor(), cstyle.strokeShade(), false);
3905
 
                                        PS_restore();
3906
 
                                }
3907
 
                        }
3908
 
                }
3909
 
                if ((cstyle.effects() & ScStyle_Strikethrough))//&& (chstr != QChar(13)))
3910
 
                {
3911
 
                        //              double Ulen = cstyle.font().glyphWidth(glyph, cstyle.fontSize()) * glyphs.scaleH;
3912
 
                        double Ulen = glyphs.xadvance;
3913
 
                        double Upos, lw, kern;
3914
 
                        if (cstyle.effects() & 16384)
3915
 
                                kern = 0;
3916
 
                        else
3917
 
                                kern = cstyle.fontSize() * cstyle.tracking() / 10000.0;
3918
 
                        if ((cstyle.strikethruOffset() != -1) || (cstyle.strikethruWidth() != -1))
3919
 
                        {
3920
 
                                if (cstyle.strikethruOffset() != -1)
3921
 
                                        Upos = (cstyle.strikethruOffset() / 1000.0) * (cstyle.font().ascent(cstyle.fontSize() / 10.0));
3922
 
                                else
3923
 
                                        Upos = cstyle.font().strikeoutPos(cstyle.fontSize() / 10.0);
3924
 
                                if (cstyle.strikethruWidth() != -1)
3925
 
                                        lw = (cstyle.strikethruWidth() / 1000.0) * (cstyle.fontSize() / 10.0);
3926
 
                                else
3927
 
                                        lw = qMax(cstyle.font().strokeWidth(cstyle.fontSize() / 10.0), 1.0);
3928
 
                        }
3929
 
                        else
3930
 
                        {
3931
 
                                Upos = cstyle.font().strikeoutPos(cstyle.fontSize() / 10.0);
3932
 
                                lw = qMax(cstyle.font().strokeWidth(cstyle.fontSize() / 10.0), 1.0);
3933
 
                        }
3934
 
                        if (cstyle.baselineOffset() != 0)
3935
 
                                Upos += (cstyle.fontSize() / 10.0) * glyphs.scaleV * (cstyle.baselineOffset() / 1000.0);
3936
 
                        if (cstyle.fillColor() != CommonStrings::None)
3937
 
                        {
3938
 
                                PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
3939
 
                                PS_setdash(Qt::SolidLine, 0, dum);
3940
 
                                SetColor(cstyle.fillColor(), cstyle.fillShade(), &h, &s, &v, &k, gcr);
3941
 
                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
3942
 
                        }
3943
 
                        PS_setlinewidth(lw);
3944
 
                        PS_moveto(x + glyphs.xoffset     , -y-glyphs.yoffset+Upos);
3945
 
                        PS_lineto(x + glyphs.xoffset+Ulen, -y-glyphs.yoffset+Upos);
3946
 
                        putColor(cstyle.fillColor(), cstyle.fillShade(), false);
3947
 
                }
3948
 
        }
3949
 
        if (glyphs.more) {
3950
 
                // ugly hack until setTextCh interface is changed
3951
 
                ScText hl2(*hl);
3952
 
                hl2.glyph = *glyphs.more;
3953
 
                setTextCh(Doc, ite, x + glyphs.xadvance, y, gcr, argh, doh, &hl2, pstyle, pg, sep, farb, ic, master);
3954
 
                // don't let hl2's destructor delete these!
3955
 
                hl2.glyph.more = 0;
3956
 
        }
3957
 
/*      if (cstyle.effects() & ScStyle_SmartHyphenVisible)
3958
 
        {
3959
 
                int chs = cstyle.fontSize();
3960
 
//              double wide = cstyle.font().charWidth(chstr, chs) * (cstyle.scaleH() / 1000.0);
3961
 
//              chstr = '-';
3962
 
//              if (cstyle.font().canRender(chstr))
3963
 
                {
3964
 
                        FPointArray gly = cstyle.font().glyphOutline(glyph);
3965
 
                        QMatrix chma;
3966
 
                        chma.scale(tsz / 100.0, tsz / 100.0);
3967
 
                        gly.map(chma);
3968
 
                        chma = QMatrix();
3969
 
                        chma.scale(glyphs.scaleH, glyphs.scaleV);
3970
 
                        gly.map(chma);
3971
 
                        if (cstyle.fillColor() != CommonStrings::None)
3972
 
                        {
3973
 
                                PS_save();
3974
 
                                PS_newpath();
3975
 
                                PS_translate(x + glyphs.xoffset + glyphs.xadvance, (y + glyphs.yoffset - (tsz / 10.0)) * -1);
3976
 
                                SetColor(cstyle.fillColor(), cstyle.fillShade(), &h, &s, &v, &k, gcr);
3977
 
                                PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
3978
 
                                SetClipPath(&gly);
3979
 
                                PS_closepath();
3980
 
                                putColor(cstyle.fillColor(), cstyle.fillShade(), true);
3981
 
                                PS_restore();
3982
 
                        }
3983
 
                }
3984
 
        }*/
3985
 
}
3986
 
 
3987
 
void PSLib::putColor(const QString& colorName, double shade, bool fill)
3988
 
{
3989
 
        ScColor& color(colorsToUse[colorName]);
3990
 
        if (fill)
3991
 
        {
3992
 
                if (((color.isSpotColor()) || (color.isRegistrationColor())) && (useSpotColors))
3993
 
                {
3994
 
                        if (!DoSep)
3995
 
                                PS_fillspot(colorName, shade);
3996
 
                        else
3997
 
                        {
3998
 
                                if ((colorName == currentSpot) || (color.isRegistrationColor()))
3999
 
                                {
4000
 
                                        if (fillRule)
4001
 
                                                PutStream("0 0 0 "+ToStr(shade / 100.0)+" cmyk eofill\n");
4002
 
                                        else
4003
 
                                                PutStream("0 0 0 "+ToStr(shade / 100.0)+" cmyk fill\n");
4004
 
                                }
4005
 
                                else
4006
 
                                {
4007
 
                                        if (fillRule)
4008
 
                                                PutStream("0 0 0 0 cmyk eofill\n");
4009
 
                                        else
4010
 
                                                PutStream("0 0 0 0 cmyk fill\n");
4011
 
                                }
4012
 
                        }
4013
 
                }
4014
 
                else
4015
 
                {
4016
 
                        if (!DoSep || (Plate == 0) || (Plate == 1) || (Plate == 2) || (Plate == 3))
4017
 
                                PS_fill();
4018
 
                        else if (fillRule)
4019
 
                                PutStream("0 0 0 0 cmyk eofill\n");
4020
 
                        else
4021
 
                                PutStream("0 0 0 0 cmyk fill\n");
4022
 
                }
4023
 
        }
4024
 
        else
4025
 
        {
4026
 
                if (((color.isSpotColor()) || (color.isRegistrationColor())) && (useSpotColors))
4027
 
                {
4028
 
                        if (!DoSep)
4029
 
                                PS_strokespot(colorName, shade);
4030
 
                        else
4031
 
                        {
4032
 
                                if ((colorName == currentSpot) || (color.isRegistrationColor()))
4033
 
                                        PutStream("0 0 0 "+ToStr(shade / 100.0)+" cmyk st\n");
4034
 
                        }
4035
 
                }
4036
 
                else
4037
 
                {
4038
 
                        if (!DoSep || (Plate == 0) || (Plate == 1) || (Plate == 2) || (Plate == 3))
4039
 
                                PS_stroke();
4040
 
                        else
4041
 
                                PutStream("0 0 0 0 cmyk st\n");
4042
 
                }
4043
 
        }
4044
 
}
4045
 
 
4046
 
void PSLib::putColorNoDraw(const QString& colorName, double shade, bool gcr)
4047
 
{
4048
 
        ScColor& color(colorsToUse[colorName]);
4049
 
        if (((color.isSpotColor()) || (color.isRegistrationColor())) && (useSpotColors))
4050
 
        {
4051
 
                if (!DoSep)
4052
 
                        PutStream(ToStr(shade / 100.0)+" "+spotMap[colorName] + "\n");
4053
 
                else if ((colorName == currentSpot) || (color.isRegistrationColor()))
4054
 
                        PutStream("0 0 0 "+ToStr(shade / 100.0)+" cmyk\n");
4055
 
                else
4056
 
                        PutStream("0 0 0 0 cmyk\n");
4057
 
        }
4058
 
        else
4059
 
        {
4060
 
                int c, m, y, k;
4061
 
                SetColor(color, shade, &c, &m, &y, &k, gcr);
4062
 
                if (!DoSep || (Plate == 0 || Plate == 1 || Plate == 2 || Plate == 3))
4063
 
                        PutStream(ToStr(c / 255.0) + " " + ToStr(m / 255.0) + " " + ToStr(y / 255.0) + " " + ToStr(k / 255.0) + " cmyk\n");
4064
 
                else
4065
 
                        PutStream("0 0 0 0 cmyk\n");
4066
 
        }
4067
 
}
4068
 
 
4069
 
void PSLib::GetBleeds(Page* page, double& left, double& right)
4070
 
{
4071
 
        MarginStruct values;
4072
 
        m_Doc->getBleeds(page, Options.bleeds, values);
4073
 
        left   = values.Left;
4074
 
        right  = values.Right;
4075
 
}
4076
 
 
4077
 
void PSLib::GetBleeds(Page* page, double& left, double& right, double& bottom, double& top)
4078
 
{
4079
 
        MarginStruct values;
4080
 
        m_Doc->getBleeds(page, Options.bleeds, values);
4081
 
        left   = values.Left;
4082
 
        right  = values.Right;
4083
 
        bottom = values.Bottom;
4084
 
        top    = values.Top;
4085
 
}
4086
 
 
4087
 
void PSLib::SetClipPath(FPointArray *c, bool poly)
4088
 
{
4089
 
        FPoint np, np1, np2, np3;
4090
 
        bool nPath = true;
4091
 
        if (c->size() > 3)
4092
 
        {
4093
 
                for (uint poi=0; poi<c->size()-3; poi += 4)
4094
 
                {
4095
 
                        if (c->point(poi).x() > 900000)
4096
 
                        {
4097
 
                                if (poly)
4098
 
                                        PS_closepath();
4099
 
                                nPath = true;
4100
 
                                continue;
4101
 
                        }
4102
 
                        if (nPath)
4103
 
                        {
4104
 
                                np = c->point(poi);
4105
 
                                PS_moveto(np.x(), -np.y());
4106
 
                                nPath = false;
4107
 
                        }
4108
 
                        np = c->point(poi);
4109
 
                        np1 = c->point(poi+1);
4110
 
                        np2 = c->point(poi+3);
4111
 
                        np3 = c->point(poi+2);
4112
 
                        if ((np == np1) && (np2 == np3))
4113
 
                                PS_lineto(np3.x(), -np3.y());
4114
 
                        else
4115
 
                                PS_curve(np1.x(), -np1.y(), np2.x(), -np2.y(), np3.x(), -np3.y());
4116
 
/*                      np = c->point(poi+1);
4117
 
                        np1 = c->point(poi+3);
4118
 
                        np2 = c->point(poi+2);
4119
 
                        PS_curve(np.x(), -np.y(), np1.x(), -np1.y(), np2.x(), -np2.y()); */
4120
 
                }
4121
 
        }
4122
 
}
4123
 
 
4124
 
const QString& PSLib::errorMessage(void)
4125
 
{
4126
 
        return ErrorMessage;
4127
 
}
4128
 
 
4129
 
void PSLib::cancelRequested()
4130
 
{
4131
 
        abortExport=true;
4132
 
}