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.
7
/***************************************************************************
8
pslib.cpp - description
10
begin : Sat May 26 2001
11
copyright : (C) 2001 by Franz Schmid
12
email : Franz.Schmid@altmuehlnet.de
13
***************************************************************************/
15
/***************************************************************************
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. *
22
***************************************************************************/
38
#include "cmsettings.h"
39
#include "commonstrings.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"
48
#include "scribusapp.h"
49
#include "scribusdoc.h"
51
#include "scribuscore.h"
52
#include "selection.h"
53
#include "scpattern.h"
54
#include "scstreamfilter_ascii85.h"
55
#include "scstreamfilter_flate.h"
57
#include "util_formats.h"
58
#include "util_math.h"
60
#include "text/nlsconfig.h"
62
PSLib::PSLib(PrintOptions &options, bool psart, SCFonts &AllFonts, QMap<QString, QMap<uint, FPointArray> > DocFonts, ColorList DocColors, bool pdf, bool spot)
65
optimization = OptimizeCompat;
66
usingGUI=ScCore->usingGUI();
68
QString tmp, tmp2, tmp3, tmp4, CHset;
72
Creator = "Scribus" + QString(VERSION);
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";
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";
95
ColorList::Iterator itf;
99
colorsToUse = DocColors;
102
for (itf = DocColors.begin(); itf != DocColors.end(); ++itf)
104
if (((itf->isSpotColor()) || (itf->isRegistrationColor())) && (useSpotColors))
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())
112
colorDesc += itf.key();
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));
121
if ((itf.key() != "Cyan") && (itf.key() != "Magenta") && (itf.key() != "Yellow") && (itf.key() != "Black") && DocColors[itf.key()].isSpotColor())
123
ScColorEngine::getCMYKValues(DocColors[itf.key()], DocColors.document(), cmykValues);
124
cmykValues.getValues(c, m, y, k);
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";
136
QMap<QString, QString> psNameMap;
137
QMap<QString, QMap<uint, FPointArray> >::Iterator it;
139
for (it = DocFonts.begin(); it != DocFonts.end(); ++it)
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\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" );
147
if ((type == ScFace::TTF) || (face.isOTF()) || (face.subset()) || psNameMap.contains(encodedName))
149
QMap<uint, FPointArray>& RealGlyphs(it.value());
150
// Handle possible PostScript name conflict in oft/ttf fonts
152
QString initialName = encodedName;
153
while (psNameMap.contains(encodedName))
155
encodedName = QString("%1-%2").arg(initialName).arg(psNameIndex);
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)
163
FontDesc += "/G"+IToStr(ig.key())+" { newpath\n";
166
if (ig.value().size() > 3)
168
for (uint poi = 0; poi < ig.value().size()-3; poi += 4)
170
if (ig.value().point(poi).x() > 900000)
178
np = ig.value().point(poi);
179
FontDesc += ToStr(np.x()) + " " + ToStr(-np.y()) + " m\n";
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";
190
FontDesc += "cl\n} bind def\n";
193
FontSubsetMap.insert(face.scName(), encodedName);
197
UsedFonts.insert(it.key(), "/Fo"+IToStr(a));
198
Fonts += "/Fo" + IToStr(a) + " /" + encodedName + " findfont definefont pop\n";
199
if (AllFonts[it.key()].embedPs())
202
if(face.EmbedFont(tmp))
204
FontDesc += "%%BeginFont: " + encodedName + "\n";
205
FontDesc += tmp + "\n%%EndFont\n";
210
GlyphsOfFont.insert(it.key(), gl);
213
psNameMap.insert(encodedName, face.scName());
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";
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";
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";
266
void PSLib::PutStream(const QString& c)
268
QByteArray utf8Array = c.toUtf8();
269
spoolStream.writeRawData(utf8Array.data(), utf8Array.length());
272
void PSLib::PutStream(const QByteArray& array, bool hexEnc)
275
WriteASCII85Bytes(array);
277
spoolStream.writeRawData(array.data(), array.size());
280
void PSLib::PutStream(const char* array, int length, bool hexEnc)
283
WriteASCII85Bytes((const unsigned char*) array, length);
285
spoolStream.writeRawData(array, length);
288
bool PSLib::PutImageToStream(ScImage& image, int plate)
290
bool writeSucceed = false;
291
ScASCII85EncodeFilter asciiEncode(&spoolStream);
292
ScFlateEncodeFilter flateEncode(&asciiEncode);
293
if (flateEncode.openFilter())
295
writeSucceed = image.writePSImageToFilter(&flateEncode, plate);
296
writeSucceed &= flateEncode.closeFilter();
301
bool PSLib::PutImageToStream(ScImage& image, const QByteArray& mask, int plate)
303
bool writeSucceed = false;
304
ScASCII85EncodeFilter asciiEncode(&spoolStream);
305
ScFlateEncodeFilter flateEncode(&asciiEncode);
306
if (flateEncode.openFilter())
308
writeSucceed = image.writePSImageToFilter(&flateEncode, mask, plate);
309
writeSucceed &= flateEncode.closeFilter();
314
bool PSLib::PutImageDataToStream(const QByteArray& image)
316
bool writeSucceed = false;
317
ScASCII85EncodeFilter asciiEncode(&spoolStream);
318
ScFlateEncodeFilter flateEncode(&asciiEncode);
319
if (flateEncode.openFilter())
321
writeSucceed = flateEncode.writeData(image, image.size());
322
writeSucceed &= flateEncode.closeFilter();
327
bool PSLib::PutInterleavedImageMaskToStream(const QByteArray& image, const QByteArray& mask, bool gray)
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;
336
int channels = gray ? 1 : 4;
337
int pixels = image.size() / channels;
338
assert((image.size() % channels) == 0);
339
assert( mask.size() >= pixels );
341
ScASCII85EncodeFilter asciiEncode(&spoolStream);
342
ScFlateEncodeFilter flateEncode(&asciiEncode);
343
if (!flateEncode.openFilter())
346
for (int i = 0; i < pixels; ++i)
349
bytes[pending++] = maskData [i];
350
bytes[pending++] = *imageData++; // cyan/black
353
bytes[pending++] = *imageData++; // magenta
354
bytes[pending++] = *imageData++; // yellow
355
bytes[pending++] = *imageData++; // green
359
writeSuccess &= flateEncode.writeData((const char* ) bytes, pending);
363
// To close the stream
365
writeSuccess &= flateEncode.writeData((const char* ) bytes, pending);
366
writeSuccess &= flateEncode.closeFilter();
370
void PSLib::WriteASCII85Bytes(const QByteArray& array)
372
WriteASCII85Bytes((const unsigned char*) array.data(), array.size());
375
void PSLib::WriteASCII85Bytes(const unsigned char* array, int length)
377
ScASCII85EncodeFilter filter(&spoolStream);
379
filter.writeData((const char*) array, length);
380
filter.closeFilter();
383
QString PSLib::ToStr(double c)
389
QString PSLib::IToStr(int c)
395
QString PSLib::MatrixToStr(double m11, double m12, double m21, double m22, double x, double y)
397
QString cc("[%1 %2 %3 %4 %5 %6]");
398
return cc.arg(m11).arg(m12).arg(m21).arg(m22).arg(x).arg(y);
401
void PSLib::PS_set_Info(QString art, QString was)
405
if (art == "Creator")
411
bool PSLib::PS_set_file(QString fn)
413
Spool.setFileName(fn);
416
bool ret = Spool.open(QIODevice::WriteOnly);
417
spoolStream.setDevice(&Spool);
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)
425
PutStream("%%For: " + User + "\n");
426
PutStream("%%Title: " + Titel + "\n");
427
PutStream("%%Creator: " + Creator + "\n");
428
PutStream("%%Pages: " + IToStr(numpage) + "\n");
430
if(breite < hoehe || !psExport)
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";
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";
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");
453
PutStream("%%BeginSetup\n");
455
PutStream("/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse\n");
456
if (!FontDesc.isEmpty())
458
if ((!colorDesc.isEmpty()) && (!sep))
459
PutStream(colorDesc);
460
// PutStream("Scribusdict begin\n");
464
Optimization optim = optimization;
465
optimization = OptimizeSize;
466
QStringList patterns = m_Doc->getUsedPatterns();
467
for (int c = 0; c < patterns.count(); ++c)
469
ScPattern pa = m_Doc->docPatterns[patterns[c]];
470
for (int em = 0; em < pa.items.count(); ++em)
472
PageItem* item = pa.items.at(em);
473
if ((item->asImageFrame()) && (item->PictureIsAvailable) && (!item->Pfile.isEmpty()) && (item->printEnabled()) && (!sep) && (farb))
475
if (!PS_ImageData(item, item->Pfile, item->itemName(), item->IProfile, item->UseEmbedded, ic))
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();
491
// Qt4 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)
498
PageItem* item = pa.items.at(em);
499
if (item->isGroupControl)
502
FPointArray cl = item->PoLine.copy();
504
mm.translate(item->gXpos, item->gYpos - pa.height);
505
mm.rotate(item->rotation());
510
groupStack.push(item->groupsLastItem);
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);
518
if (groupStack.count() != 0)
520
while (item == groupStack.top())
524
if (groupStack.count() == 0)
528
PutStream("} exec\n");
530
for (int em = 0; em < pa.items.count(); ++em)
533
PageItem* item = pa.items.at(em);
534
if (!item->isTableItem)
536
if ((item->lineColor() == CommonStrings::None) || (item->lineWidth() == 0.0))
540
PS_translate(item->gXpos, pa.height - item->gYpos);
541
PS_rotate(item->rotation());
542
if (item->lineColor() != CommonStrings::None)
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);
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))
555
PS_lineto(item->width(), 0);
559
PS_moveto(item->width(), 0);
560
PS_lineto(item->width(), -item->height());
562
if (item->BottomLine)
564
PS_moveto(0, -item->height());
565
PS_lineto(item->width(), -item->height());
570
PS_lineto(0, -item->height());
572
putColor(item->lineColor(), item->lineShade(), false);
575
PutStream("} exec\n");
577
spoolStream.setDevice(spStream);
579
PutStream("} def\n");
582
optimization = optim;
583
// PutStream("end\n");
584
// PutStream("%%EndSetup\n");
590
QString PSLib::PSEncode(QString in)
592
static QRegExp badchars("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]");
594
tmp = in.simplified().replace( badchars, "_" );
598
void PSLib::PS_TemplateStart(QString Name)
600
PutStream("/"+PSEncode(Name)+"\n{\n");
603
void PSLib::PS_UseTemplate(QString Name)
605
PutStream(PSEncode(Name)+"\n");
608
void PSLib::PS_TemplateEnd()
610
PutStream("} bind def\n");
613
void PSLib::PS_begin_page(Page* pg, MarginStruct* Ma, bool Clipping)
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;
624
PutStream("%%Page: " + IToStr(Seiten) + " " + IToStr(Seiten) + "\n");
625
PutStream("%%PageOrientation: ");
626
// when creating EPS files determine the orientation from the bounding box
629
if ((pg->width() - Ma->Left - Ma->Right) <= (pg->height() - Ma->Bottom - Ma->Top))
630
PutStream("Portrait\n");
632
PutStream("Landscape\n");
636
if (pg->PageOri == 0)
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");
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");
649
PutStream("Scribusdict begin\n");
650
if ((psExport) && (Options.setDevParam))
652
PutStream("<< /PageSize [ "+ToStr(maxBoxX)+" "+ToStr(maxBoxY)+" ]\n");
653
PutStream(">> setpagedevice\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");
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";
671
void PSLib::PS_end_page()
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;
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))
687
PS_setlinewidth(0.5);
688
PutStream("[] 0 setdash\n");
689
PutStream("0 setlinecap\n");
690
PutStream("0 setlinejoin\n");
692
if (Options.cropMarks)
695
PutStream("0 "+ToStr(markOffs+Options.bleeds.Bottom)+" m\n");
696
PutStream(ToStr(20.0)+" "+ToStr(markOffs+Options.bleeds.Bottom)+" li\n");
698
PutStream(ToStr(markOffs+bleedLeft)+" 0 m\n");
699
PutStream(ToStr(markOffs+bleedLeft)+" 20 li\n");
702
PutStream("0 "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" m\n");
703
PutStream(ToStr(20.0)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" li\n");
705
PutStream(ToStr(markOffs+bleedLeft)+" "+ToStr(maxBoxY)+" m\n");
706
PutStream(ToStr(markOffs+bleedLeft)+" "+ToStr(maxBoxY-20.0)+" li\n");
709
PutStream(ToStr(maxBoxX)+" "+ToStr(markOffs+Options.bleeds.Bottom)+" m\n");
710
PutStream(ToStr(maxBoxX-20.0)+" "+ToStr(markOffs+Options.bleeds.Bottom)+" li\n");
712
PutStream(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(0.0)+" m\n");
713
PutStream(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(20.0)+" li\n");
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");
719
PutStream(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(maxBoxY)+" m\n");
720
PutStream(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(maxBoxY-20.0)+" li\n");
723
if (Options.bleedMarks)
726
PutStream("[3 1 1 1] 0 setdash\n");
728
PutStream("0 "+ToStr(markOffs)+" m\n");
729
PutStream(ToStr(20.0)+" "+ToStr(markOffs)+" li\n");
731
PutStream(ToStr(markOffs)+" 0 m\n");
732
PutStream(ToStr(markOffs)+" 20 l\n");
735
PutStream("0 "+ToStr(maxBoxY-markOffs)+" m\n");
736
PutStream(ToStr(20.0)+" "+ToStr(maxBoxY-markOffs)+" li\n");
738
PutStream(ToStr(markOffs)+" "+ToStr(maxBoxY)+" m\n");
739
PutStream(ToStr(markOffs)+" "+ToStr(maxBoxY-20.0)+" li\n");
742
PutStream(ToStr(maxBoxX)+" "+ToStr(markOffs)+" m\n");
743
PutStream(ToStr(maxBoxX-20.0)+" "+ToStr(markOffs)+" li\n");
745
PutStream(ToStr(maxBoxX-markOffs)+" "+ToStr(0.0)+" m\n");
746
PutStream(ToStr(maxBoxX-markOffs)+" "+ToStr(20.0)+" li\n");
749
PutStream(ToStr(maxBoxX)+" "+ToStr(maxBoxY-markOffs)+" m\n");
750
PutStream(ToStr(maxBoxX-20.0)+" "+ToStr(maxBoxY-markOffs)+" li\n");
752
PutStream(ToStr(maxBoxX-markOffs)+" "+ToStr(maxBoxY)+" m\n");
753
PutStream(ToStr(maxBoxX-markOffs)+" "+ToStr(maxBoxY-20.0)+" li\n");
757
if (Options.registrationMarks)
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";
763
PutStream(ToStr(maxBoxX / 2.0 - 7.0)+" 3 tr\n");
767
PutStream("3 "+ToStr(maxBoxY / 2.0 - 7.0)+" tr\n");
771
PutStream(ToStr(maxBoxX / 2.0 - 7.0)+" "+ToStr(maxBoxY - 17.0)+" tr\n");
775
PutStream(ToStr(maxBoxX - 17.0)+" "+ToStr(maxBoxY / 2.0 - 7.0)+" tr\n");
779
if (Options.colorMarks)
781
double startX = markOffs+bleedLeft+6.0;
782
double startY = maxBoxY - 18.0;
783
PutStream("0 0 0 1 cmyk\n");
785
for (int bl = 0; bl < 11; bl++)
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");
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");
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");
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");
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");
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");
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");
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");
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");
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");
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");
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");
856
void PSLib::PS_curve(double x1, double y1, double x2, double y2, double x3, double y3)
858
PutStream(ToStr(x1) + " " + ToStr(y1) + " " + ToStr(x2) + " " + ToStr(y2) + " " + ToStr(x3) + " " + ToStr(y3) + " cu\n");
861
void PSLib::PS_moveto(double x, double y)
863
PutStream(ToStr(x) + " " + ToStr(y) + " m\n");
866
void PSLib::PS_lineto(double x, double y)
868
PutStream(ToStr(x) + " " + ToStr(y) + " li\n");
871
void PSLib::PS_closepath()
876
void PSLib::PS_translate(double x, double y)
878
PutStream(ToStr(x) + " " + ToStr(y) + " tr\n");
881
void PSLib::PS_scale(double x, double y)
883
PutStream(ToStr(x) + " " + ToStr(y) + " sc\n");
886
void PSLib::PS_rotate(double x)
888
PutStream(ToStr(x) + " ro\n");
891
void PSLib::PS_clip(bool mu)
893
PutStream( mu ? "eoclip newpath\n" : "clip newpath\n" );
896
void PSLib::PS_save()
901
void PSLib::PS_restore()
906
void PSLib::PS_setcmykcolor_fill(double c, double m, double y, double k)
908
FillColor = ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k);
911
void PSLib::PS_setcmykcolor_dummy()
913
PutStream("0 0 0 0 cmyk\n");
916
void PSLib::PS_setcmykcolor_stroke(double c, double m, double y, double k)
918
StrokeColor = ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k);
921
void PSLib::PS_setlinewidth(double w)
923
PutStream(ToStr(w) + " sw\n");
927
void PSLib::PS_setdash(Qt::PenStyle st, double offset, QVector<double> dash)
929
if (dash.count() != 0)
932
QVector<double>::iterator it;
933
for ( it = dash.begin(); it != dash.end(); ++it )
935
PutStream(ToStr(*it)+" ");
937
PutStream("] "+ToStr(offset)+" setdash\n");
940
PutStream("["+getDashString(st, LineW)+"] 0 setdash\n");
943
void PSLib::PS_setcapjoin(Qt::PenCapStyle ca, Qt::PenJoinStyle jo)
948
PutStream("0 setlinecap\n");
951
PutStream("2 setlinecap\n");
954
PutStream("1 setlinecap\n");
957
PutStream("0 setlinecap\n");
963
PutStream("0 setlinejoin\n");
966
PutStream("2 setlinejoin\n");
969
PutStream("1 setlinejoin\n");
972
PutStream("0 setlinejoin\n");
977
void PSLib::PS_selectfont(QString f, double s)
979
PutStream(UsedFonts[f] + " " + ToStr(s) + " se\n");
982
void PSLib::PS_fill()
985
PutStream(FillColor + " cmyk eofill\n");
987
PutStream(FillColor + " cmyk fill\n");
990
void PSLib::PS_fillspot(QString color, double shade)
993
PutStream(ToStr(shade / 100.0)+" "+spotMap[color]+" eofill\n");
995
PutStream(ToStr(shade / 100.0)+" "+spotMap[color]+" fill\n");
998
void PSLib::PS_strokespot(QString color, double shade)
1000
PutStream(ToStr(shade / 100.0)+" "+spotMap[color]+" st\n");
1003
void PSLib::PS_stroke()
1005
PutStream(StrokeColor + " cmyk st\n");
1008
void PSLib::PS_fill_stroke()
1016
void PSLib::PS_newpath()
1018
PutStream("newpath\n");
1021
void PSLib::PS_MultiRadGradient(double w, double h, double x, double y, QList<double> Stops, QStringList Colors, QStringList colorNames, QList<int> colorShades)
1024
bool oneSameSpot = false;
1025
bool oneSpot1 = false;
1026
bool oneSpot2 = false;
1027
bool twoSpot = false;
1032
CMYKColor cmykValues;
1033
PutStream( "clipsave\n" );
1034
PutStream("eoclip\n");
1035
for (int c = 0; c < Colors.count()-1; ++c)
1037
oneSameSpot = false;
1041
QString spot1 = colorNames[c];
1042
QString spot2 = colorNames[c+1];
1044
PutStream("/ShadingType 3\n");
1046
PutStream("/ColorSpace /DeviceGray\n");
1049
if (spotMap.contains(colorNames[c]))
1051
if (spotMap.contains(colorNames[c+1]))
1053
if (oneSpot1 && oneSpot2)
1055
oneSameSpot = (colorNames[c] == colorNames[c+1]);
1056
oneSpot1 = oneSpot2 = false;
1059
if (((!oneSpot1) && (!oneSpot2) && (!twoSpot)) || (!useSpotColors) || (GraySc))
1062
PutStream("/ColorSpace /DeviceGray\n");
1064
PutStream("/ColorSpace /DeviceCMYK\n");
1065
// #7654 : Necessary when printing spot colors to grayscale
1066
oneSpot1 = oneSpot2 = oneSameSpot = twoSpot = false;
1070
PutStream("/ColorSpace [ /DeviceN [");
1073
PutStream(" ("+spot1+") ]\n");
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);
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);
1089
PutStream(" ("+spot1+") ("+spot2+") ]\n");
1091
PutStream("/DeviceCMYK\n");
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");
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");
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");
1128
PutStream("/BBox [0 "+ToStr(h)+" "+ToStr(w)+" 0]\n");
1129
if (Colors.count() == 2)
1130
PutStream("/Extend [true true]\n");
1134
PutStream("/Extend [false true]\n");
1137
if (c == Colors.count()-2)
1138
PutStream("/Extend [true false]\n");
1140
PutStream("/Extend [false false]\n");
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");
1146
PutStream("/FunctionType 2\n");
1147
PutStream("/Domain [0 1]\n");
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");
1162
PutStream("/C1 ["+ToStr(colorShades[c] / 100.0)+"]\n");
1163
PutStream("/C0 ["+ToStr(colorShades[c+1] / 100.0)+"]\n");
1167
PutStream("/C1 [0 0 0 0 "+ToStr(colorShades[c] / 100.0)+"]\n");
1168
PutStream("/C0 ["+Colors[c+1]+" 0 ]\n");
1172
PutStream("/C1 ["+Colors[c]+" 0 ]\n");
1173
PutStream("/C0 [0 0 0 0 "+ToStr(colorShades[c+1] / 100.0)+"]\n");
1177
PutStream("/C1 ["+ToStr(colorShades[c] / 100.0)+" 0]\n");
1178
PutStream("/C0 [0 "+ToStr(colorShades[c+1] / 100.0)+"]\n");
1182
PutStream("/C1 ["+Colors[c]+"]\n");
1183
PutStream("/C0 ["+Colors[c+1]+"]\n");
1188
PutStream("/C1 ["+Colors[c]+"]\n");
1189
PutStream("/C0 ["+Colors[c+1]+"]\n");
1192
PutStream("/N 1\n");
1195
PutStream("shfill\n");
1198
PutStream("cliprestore\n");
1201
void PSLib::PS_MultiLinGradient(double w, double h, QList<double> Stops, QStringList Colors, QStringList colorNames, QList<int> colorShades)
1204
bool oneSameSpot = false;
1205
bool oneSpot1 = false;
1206
bool oneSpot2 = false;
1207
bool twoSpot = false;
1212
CMYKColor cmykValues;
1213
PutStream( "clipsave\n" );
1214
PutStream("eoclip\n");
1215
for (int c = 0; c < Colors.count()-1; ++c)
1217
oneSameSpot = false;
1221
QRegExp badchars("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]");
1222
QString spot1 = colorNames[c];
1223
QString spot2 = colorNames[c+1];
1225
PutStream("/ShadingType 2\n");
1227
PutStream("/ColorSpace /DeviceGray\n");
1230
if (spotMap.contains(colorNames[c]))
1232
if (spotMap.contains(colorNames[c+1]))
1234
if (oneSpot1 && oneSpot2)
1236
oneSameSpot = (colorNames[c] == colorNames[c+1]);
1237
oneSpot1 = oneSpot2 = false;
1240
if (((!oneSpot1) && (!oneSpot2) && (!twoSpot)) || (!useSpotColors) || (GraySc))
1243
PutStream("/ColorSpace /DeviceGray\n");
1245
PutStream("/ColorSpace /DeviceCMYK\n");
1246
// #7654 : Necessary when printing spot colors to grayscale
1247
oneSpot1 = oneSpot2 = oneSameSpot = twoSpot = false;
1251
PutStream("/ColorSpace [ /DeviceN [");
1254
PutStream(" ("+spot1+") ]\n");
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);
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);
1270
PutStream(" ("+spot1+") ("+spot2+") ]\n");
1272
PutStream("/DeviceCMYK\n");
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");
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");
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");
1309
PutStream("/BBox [0 "+ToStr(h)+" "+ToStr(w)+" 0]\n");
1310
if (Colors.count() == 2)
1311
PutStream("/Extend [true true]\n");
1315
PutStream("/Extend [true false]\n");
1318
if (c == Colors.count()-2)
1319
PutStream("/Extend [false true]\n");
1321
PutStream("/Extend [false false]\n");
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");
1328
PutStream("/FunctionType 2\n");
1329
PutStream("/Domain [0 1]\n");
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");
1344
PutStream("/C0 ["+ToStr(colorShades[c] / 100.0)+"]\n");
1345
PutStream("/C1 ["+ToStr(colorShades[c+1] / 100.0)+"]\n");
1349
PutStream("/C0 [0 0 0 0 "+ToStr(colorShades[c] / 100.0)+"]\n");
1350
PutStream("/C1 ["+Colors[c+1]+" 0 ]\n");
1354
PutStream("/C0 ["+Colors[c]+" 0 ]\n");
1355
PutStream("/C1 [0 0 0 0 "+ToStr(colorShades[c+1] / 100.0)+"]\n");
1359
PutStream("/C0 ["+ToStr(colorShades[c] / 100.0)+" 0]\n");
1360
PutStream("/C1 [0 "+ToStr(colorShades[c+1] / 100.0)+"]\n");
1364
PutStream("/C0 ["+Colors[c]+"]\n");
1365
PutStream("/C1 ["+Colors[c+1]+"]\n");
1370
PutStream("/C0 ["+Colors[c]+"]\n");
1371
PutStream("/C1 ["+Colors[c+1]+"]\n");
1374
PutStream("/N 1\n");
1377
PutStream("shfill\n");
1379
PutStream("cliprestore\n");
1382
void PSLib::PS_show_xyG(QString font, uint glyph, double x, double y, QString colorName, double shade)
1385
glyphName = GlyphsOfFont[font].contains(glyph) ? GlyphsOfFont[font][glyph].second : QString(".notdef");
1387
QString colorString;
1388
ScColor& color(colorsToUse[colorName]);
1390
if (((color.isSpotColor()) || (color.isRegistrationColor())) && (useSpotColors))
1394
colorString = ToStr(shade / 100.0)+" "+spotMap[colorName];
1397
else if ((colorName == currentSpot) || (color.isRegistrationColor()))
1398
colorString = "0 0 0 "+ToStr(shade / 100.0);
1400
colorString = "0 0 0 0";
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);
1409
colorString = "0 0 0 0";
1413
PutStream(colorString + "\n");
1414
PutStream("/"+glyphName+" "+ToStr(x)+" "+ToStr(y)+" shgsp\n");
1417
PutStream("/"+glyphName+" "+ToStr(x)+" "+ToStr(y)+" "+colorString+" shg\n");
1420
void PSLib::PS_show(double x, double y)
1423
PutStream("/hyphen glyphshow\n");
1426
void PSLib::PS_showSub(uint chr, QString font, double size, bool stroke)
1428
PutStream(" (G"+IToStr(chr)+") "+font+" "+ToStr(size / 10.0)+" ");
1429
PutStream(stroke ? "shgs\n" : "shgf\n");
1432
bool PSLib::PS_ImageData(PageItem *c, QString fn, QString Name, QString Prof, bool UseEmbedded, bool UseProf)
1436
QFileInfo fi = QFileInfo(fn);
1437
QString ext = fi.suffix().toLower();
1439
ext = getImageType(fn);
1440
if (extensionIndicatesEPS(ext) && (c->pixm.imgInfo.type != ImageType7))
1442
if (loadRawText(fn, tmp))
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)
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);
1454
PutStream(tmp, false);
1455
PutStream("\n%ENDEPSDATA\n");
1456
PutStream("%%EndDocument\n");
1457
PutStream("/"+PSEncode(Name)+"Bild exch def\n");
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))
1473
PS_Error_ImageLoadFailure(fn);
1476
image.applyEffect(c->effectsInUse, colorsToUse, true);
1477
QByteArray maskArray;
1478
bool alphaLoaded = image.getAlpha(fn, c->pixm.imgInfo.actualPageNumber, maskArray, false, true, 300);
1481
PS_Error_MaskLoadFailure(fn);
1484
if ((maskArray.size() > 0) && (c->pixm.imgInfo.type != ImageType7))
1486
PutStream("currentfile /ASCII85Decode filter /FlateDecode filter /ReusableStreamDecode filter\n");
1487
if (!PutImageToStream(image, maskArray, -1))
1489
PS_Error_ImageDataWriteFailure();
1492
PutStream("/"+PSEncode(Name)+"Bild exch def\n");
1496
PutStream("currentfile /ASCII85Decode filter /FlateDecode filter /ReusableStreamDecode filter\n");
1497
if (!PutImageToStream(image, -1))
1499
PS_Error_ImageDataWriteFailure();
1502
PutStream("/"+PSEncode(Name)+"Bild exch def\n");
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)
1512
QFileInfo fi = QFileInfo(fn);
1513
QString ext = fi.suffix().toLower();
1515
ext = getImageType(fn);
1516
if (extensionIndicatesEPS(ext) && (c->pixm.imgInfo.type != ImageType7))
1518
if (loadRawText(fn, tmp))
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())
1525
PutStream(PSEncode(Name)+"Bild cvx exec\n");
1526
PutStream(PSEncode(Name)+"Bild resetfile\n");
1530
PutStream("%%BeginDocument: " + fi.fileName() + "\n");
1531
if (getDouble(QString(tmp.mid(0, 4)), true) == 0xC5D0D3C6)
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);
1540
PutStream("\n%%EndDocument\n");
1542
PutStream("eEPS\n");
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)
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) )
1566
PS_Error_ImageLoadFailure(fn);
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()))
1575
scalex *= PrefsManager::instance()->appPrefs.gs_Resolution / 300.0;
1576
scaley *= PrefsManager::instance()->appPrefs.gs_Resolution / 300.0;
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;
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)
1590
bool alphaLoaded = img2.getAlpha(fn, c->pixm.imgInfo.actualPageNumber, maskArray, false, true, resolution);
1593
PS_Error_MaskLoadFailure(fn);
1597
if ((maskArray.size() > 0) && (c->pixm.imgInfo.type != ImageType7))
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");
1612
PutStream(" /DataSource currentfile /ASCII85Decode filter /FlateDecode filter\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");
1622
PutStream(" /InterleaveType 1\n");
1624
PutStream("image\n");
1627
if (!PutImageToStream(image, maskArray, plate))
1629
PS_Error_ImageDataWriteFailure();
1635
PutStream(PSEncode(Name)+"Bild resetfile\n");
1636
//PutStream(PSEncode(Name)+"Mask resetfile\n");
1641
PutStream("<< /ImageType 1\n");
1642
PutStream(" /Width " + IToStr(w) + "\n");
1643
PutStream(" /Height " + IToStr(h) + "\n");
1644
PutStream(" /BitsPerComponent 8\n");
1646
PutStream(" /Decode [1 0]\n");
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())
1652
PutStream(" /DataSource "+PSEncode(Name)+"Bild >>\n");
1653
PutStream("image\n");
1654
PutStream(PSEncode(Name)+"Bild resetfile\n");
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))
1663
PS_Error_ImageDataWriteFailure();
1673
void PSLib::PS_plate(int nr, QString name)
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");
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");
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");
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");
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");
1708
void PSLib::PS_setGray()
1713
void PSLib::PDF_Bookmark(QString text, uint Seite)
1715
PutStream("[/Title ("+text+") /Page "+IToStr(Seite)+" /View [/Fit]\n");
1716
PutStream("/OUT pdfmark\n");
1719
void PSLib::PDF_Annotation(PageItem *item, QString text, double x, double y, double b, double h)
1721
PutStream("[\n/Rect [ "+ToStr(x)+" "+ToStr(y) +" "+ToStr(b)+" "+ToStr(h)+" ]\n");
1722
switch (item->annotation().Type())
1726
PutStream("/Subtype /Text\n");
1727
PutStream("/Contents ("+text+")\n/Open false\n");
1731
PutStream("/Subtype /Link\n");
1732
if (item->annotation().ActionType() == 2)
1734
PutStream("/Page " + QString::number(item->annotation().Ziel() + 1) + "\n");
1735
PutStream("/View [ /XYZ " + item->annotation().Action() + "]\n");
1737
if (item->annotation().ActionType() == 7)
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");
1746
if (item->annotation().ActionType() == 8)
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");
1753
PutStream("/Action << /S /URI /URI (" + item->annotation().Extern() + ") >>\n");
1755
if (item->annotation().ActionType() == 9)
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");
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");
1773
void PSLib::PS_close()
1775
PutStream("%%Trailer\n");
1776
// PutStream("end\n");
1777
PutStream("%%EOF\n");
1781
void PSLib::PS_insert(QString i)
1786
void PSLib::PS_Error(const QString& message)
1788
ErrorMessage = message;
1789
if (!ScCore->usingGUI())
1790
qDebug("%s", message.toLocal8Bit().data());
1793
void PSLib::PS_Error_ImageDataWriteFailure(void)
1795
PS_Error( tr("Failed to write data for an image"));
1798
void PSLib::PS_Error_ImageLoadFailure(const QString& fileName)
1800
PS_Error( tr("Failed to load an image : %1").arg(fileName) );
1803
void PSLib::PS_Error_MaskLoadFailure(const QString& fileName)
1805
PS_Error( tr("Failed to load an image mask : %1").arg(fileName) );
1808
void PSLib::PS_Error_InsufficientMemory(void)
1810
PS_Error( tr("Insufficient memory for processing an image"));
1813
int PSLib::CreatePS(ScribusDoc* Doc, PrintOptions &options)
1815
bool errorOccured = false;
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;
1831
if ((sep) && (SepNam == QObject::tr("All")))
1832
pagemult = spots.count();
1835
QVector<double> dum;
1841
PS_set_Info("Author", Doc->documentInfo.getAuthor());
1842
PS_set_Info("Title", Doc->documentInfo.getTitle());
1846
if ((Doc->HasCMS) && (ScCore->haveCMS()) && (applyICC))
1847
solidTransform = ScColorMgmtEngine::createTransform(Doc->DocInputCMYKProf, Format_CMYK_16, Doc->DocPrinterProf, Format_CMYK_16, Doc->IntentColors, 0);
1852
QString title=QObject::tr("Exporting PostScript File");
1854
title=QObject::tr("Printing File");
1855
progressDialog=new MultiProgressDialog(title, CommonStrings::tr_Cancel, Doc->scMW());
1856
if (progressDialog==0)
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();
1877
//if ((!Art) && (view->SelItem.count() != 0))
1878
uint docSelectionCount=Doc->m_Selection->count();
1879
if ((!psExport) && (docSelectionCount != 0))
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)
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)
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)
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());
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);
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);
1926
double maxWidth = 0.0;
1927
double maxHeight = 0.0;
1928
for (uint aa = 0; aa < pageNs.size(); ++aa)
1931
maxWidth = qMax(Doc->Pages->at(a)->width(), maxWidth);
1932
maxHeight = qMax(Doc->Pages->at(a)->height(), maxHeight);
1934
errorOccured = !PS_begin_doc(Doc, 0.0, 0.0, maxWidth, maxHeight, pageNs.size()*pagemult, doDev, sep, farb, Ic, gcr);
1937
for (; ap < Doc->MasterPages.count() && !abortExport && !errorOccured; ++ap)
1939
progressDialog->setOverallProgress(ap);
1940
progressDialog->setProgress("EMP", ap);
1941
ScQApp->processEvents();
1942
if (Doc->MasterItems.count() != 0)
1946
ll.isPrintable = false;
1948
for (int lam = 0; lam < Doc->Layers.count() && !abortExport && !errorOccured; ++lam)
1950
Doc->Layers.levelToLayer(ll, Lnr);
1953
for (int api = 0; api < Doc->MasterItems.count() && !abortExport; ++api)
1956
PageItem *it = Doc->MasterItems.at(api);
1958
ScQApp->processEvents();
1959
if ((it->LayerNr != ll.LNr) || (!it->printEnabled()))
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 )))
1974
if ((it->OwnPage != static_cast<int>(Doc->MasterPages.at(ap)->pageNr())) && (it->OwnPage != -1))
1976
if ((optimization == OptimizeSize) && it->asImageFrame() && it->PictureIsAvailable && (!it->Pfile.isEmpty()) && it->printEnabled() && (!sep) && farb)
1978
errorOccured = !PS_ImageData(it, it->Pfile, it->itemName(), it->IProfile, it->UseEmbedded, Ic);
1979
if (errorOccured) break;
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);
1987
if (errorOccured) break;
1990
if (errorOccured) break;
1995
PutStream("%%EndSetup\n");
1996
while (aa < pageNs.size() && !abortExport && !errorOccured)
1998
progressDialog->setProgress("EP", aa);
1999
progressDialog->setOverallProgress(ap+aa);
2001
ScQApp->processEvents();
2003
//if ((!Art) && (view->SelItem.count() != 0))
2004
if ((!psExport) && (Doc->m_Selection->count() != 0))
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);
2014
PS_begin_page(Doc->Pages->at(a), &Doc->Pages->at(a)->Margins, doClip);
2017
PS_translate(Doc->Pages->at(a)->width(), 0);
2022
PS_translate(0, Doc->Pages->at(a)->height());
2027
if (SepNam == QObject::tr("Black"))
2029
else if (SepNam == QObject::tr("Cyan"))
2031
else if (SepNam == QObject::tr("Magenta"))
2033
else if (SepNam == QObject::tr("Yellow"))
2035
else if (SepNam == QObject::tr("All"))
2036
PS_plate(sepac, spots[sepac]);
2038
PS_plate(4, SepNam);
2040
if (!Doc->Pages->at(a)->MPageNam.isEmpty() && !abortExport && !errorOccured)
2047
ll.isPrintable = false;
2049
Page* mPage = Doc->MasterPages.at(Doc->MasterNames[Doc->Pages->at(a)->MPageNam]);
2050
if (Doc->MasterItems.count() != 0)
2052
for (int lam = 0; lam < Doc->Layers.count() && !abortExport && !errorOccured; ++lam)
2054
Doc->Layers.levelToLayer(ll, Lnr);
2057
for (int am = 0; am < Doc->Pages->at(a)->FromMaster.count() && !abortExport; ++am)
2060
PageItem *ite = Doc->Pages->at(a)->FromMaster.at(am);
2062
ScQApp->processEvents();
2063
if ((ite->LayerNr != ll.LNr) || (!ite->printEnabled()))
2065
if (ite->isGroupControl)
2068
FPointArray cl = ite->PoLine.copy();
2070
mm.translate(ite->xPos() - mPage->xOffset(), (ite->yPos() - mPage->yOffset()) - Doc->Pages->at(a)->height());
2071
mm.rotate(ite->rotation());
2076
groupStack.push(ite->groupsLastItem);
2079
if (!(ite->asTextFrame()) && !(ite->asImageFrame()))
2081
int mpIndex = Doc->MasterNames[Doc->Pages->at(a)->MPageNam];
2082
PS_UseTemplate(QString("mp_obj_%1_%2").arg(mpIndex).arg(ite->ItemNr));
2084
else if (ite->asImageFrame())
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;
2092
else if (ite->asTextFrame())
2095
if (ite->doOverprint)
2097
PutStream("true setoverprint\n");
2098
PutStream("true setoverprintmode\n");
2100
if (ite->fillColor() != CommonStrings::None)
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);
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))
2110
SetClipPath(&ite->PoLine);
2112
if (ite->GrType != 0)
2113
HandleGradient(ite, ite->width(), ite->height(), gcr);
2115
putColor(ite->fillColor(), ite->fillShade(), true);
2117
if (ite->imageFlippedH())
2119
PS_translate(ite->width(), 0);
2122
if (ite->imageFlippedV())
2124
PS_translate(0, -ite->height());
2127
setTextSt(Doc, ite, gcr, a, mPage, sep, farb, Ic, true);
2128
if (((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty())) && (!ite->isTableItem))
2130
if (ite->NamedLStyle.isEmpty()) // && (ite->lineWidth() != 0.0))
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);
2139
putColor(ite->lineColor(), ite->lineShade(), false);
2143
multiLine ml = Doc->MLineStyles[ite->NamedLStyle];
2144
for (int it = ml.size()-1; it > -1; it--)
2146
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
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);
2155
putColor(ml[it].Color, ml[it].Shade, false);
2162
if (groupStack.count() != 0)
2164
while (ite == groupStack.top())
2168
if (groupStack.count() == 0)
2174
for (int am = 0; am < Doc->Pages->at(a)->FromMaster.count() && !abortExport; ++am)
2176
PageItem *ite = Doc->Pages->at(a)->FromMaster.at(am);
2177
if (!ite->isTableItem)
2179
if ((ite->lineColor() == CommonStrings::None) || (ite->lineWidth() == 0.0))
2181
if (ite->printEnabled())
2184
if (ite->doOverprint)
2186
PutStream("true setoverprint\n");
2187
PutStream("true setoverprintmode\n");
2189
if (ite->lineColor() != CommonStrings::None)
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);
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))
2205
PS_lineto(ite->width(), 0);
2209
PS_moveto(ite->width(), 0);
2210
PS_lineto(ite->width(), -ite->height());
2212
if (ite->BottomLine)
2214
PS_moveto(0, -ite->height());
2215
PS_lineto(ite->width(), -ite->height());
2220
PS_lineto(0, -ite->height());
2222
putColor(ite->lineColor(), ite->lineShade(), false);
2229
if (abortExport || errorOccured) break;
2232
if (!abortExport && !errorOccured)
2233
ProcessPage(Doc, Doc->Pages->at(a), a+1, sep, farb, Ic, gcr);
2234
if (!abortExport && !errorOccured)
2238
if (SepNam != QObject::tr("All"))
2242
if (sepac == static_cast<int>(spots.count()-1))
2255
if (usingGUI) progressDialog->close();
2258
else if (abortExport)
2259
return 2; //CB Lets leave 1 for general error condition
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)
2269
QVector<double> dum;
2273
if (c->printEnabled())
2279
PutStream("true setoverprint\n");
2280
PutStream("true setoverprintmode\n");
2282
if (c->fillColor() != CommonStrings::None)
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);
2287
if (c->lineColor() != CommonStrings::None)
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);
2292
PS_setlinewidth(c->lineWidth());
2293
PS_setcapjoin(c->PLineEnd, c->PLineJoin);
2294
PS_setdash(c->PLineArt, c->DashOffset, c->DashValues);
2297
PS_translate(c->xPos() - a->xOffset(), a->height() - (c->yPos() - a->yOffset()));
2299
if (c->rotation() != 0)
2300
PS_rotate(-c->rotation());
2301
switch (c->itemType())
2303
case PageItem::ImageFrame:
2304
case PageItem::LatexFrame:
2307
if ((c->fillColor() != CommonStrings::None) || (c->GrType != 0))
2309
SetClipPath(&c->PoLine);
2311
if ((c->GrType != 0) && (master == false))
2312
HandleGradient(c, c->width(), c->height(), gcr);
2314
putColor(c->fillColor(), c->fillShade(), true);
2318
if (c->imageClip.size() != 0)
2320
SetClipPath(&c->imageClip);
2324
SetClipPath(&c->PoLine);
2327
if (c->imageFlippedH())
2329
PS_translate(c->width(), 0);
2332
if (c->imageFlippedV())
2334
PS_translate(0, -c->height());
2337
if ((c->PictureIsAvailable) && (!c->Pfile.isEmpty()))
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());
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;
2348
if (((c->lineColor() != CommonStrings::None) || (!c->NamedLStyle.isEmpty())) && (!c->isTableItem))
2350
if (c->NamedLStyle.isEmpty()) // && (c->lineWidth() != 0.0))
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);
2359
putColor(c->lineColor(), c->lineShade(), false);
2363
multiLine ml = Doc->MLineStyles[c->NamedLStyle];
2364
for (int it = ml.size()-1; it > -1; it--)
2366
if (ml[it].Color != CommonStrings::None) // && (ml[it].Width != 0))
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);
2375
putColor(ml[it].Color, ml[it].Shade, false);
2381
case PageItem::TextFrame:
2384
if ((c->isBookmark || c->isAnnotation()) && (!isPDF))
2390
for (int d = 0; d < c->itemText.length(); ++d)
2392
if ((c->itemText.text(d) == QChar(13)) || (c->itemText.text(d) == QChar(10)) || (c->itemText.text(d) == QChar(28)))
2394
bm += "\\"+cc.setNum(qMax(c->itemText.text(d).unicode(), (ushort) 32), 8);
2396
PDF_Bookmark(bm, a->pageNr()+1);
2398
if (c->isAnnotation())
2400
if ((c->annotation().Type() == 0) || (c->annotation().Type() == 1) || (c->annotation().Type() == 10) || (c->annotation().Type() == 11))
2404
for (int d = 0; d < c->itemText.length(); ++d)
2406
bm += "\\"+cc.setNum(qMax(c->itemText.text(d).unicode(), (ushort) 32), 8);
2408
PDF_Annotation(c, bm, 0, 0, c->width(), -c->height());
2412
if ((c->fillColor() != CommonStrings::None) || (c->GrType != 0))
2414
SetClipPath(&c->PoLine);
2416
if ((c->GrType != 0) && (master == false))
2417
HandleGradient(c, c->width(), c->height(), gcr);
2419
putColor(c->fillColor(), c->fillShade(), true);
2421
if (c->imageFlippedH())
2423
PS_translate(c->width(), 0);
2426
if (c->imageFlippedV())
2428
PS_translate(0, -c->height());
2431
setTextSt(Doc, c, gcr, PNr-1, a, sep, farb, ic, master);
2432
if (((c->lineColor() != CommonStrings::None) || (!c->NamedLStyle.isEmpty())) && (!c->isTableItem))
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))
2441
SetClipPath(&c->PoLine);
2443
putColor(c->lineColor(), c->lineShade(), false);
2447
multiLine ml = Doc->MLineStyles[c->NamedLStyle];
2448
for (int it = ml.size()-1; it > -1; it--)
2450
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
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);
2459
putColor(ml[it].Color, ml[it].Shade, false);
2465
case PageItem::Line:
2466
if (c->NamedLStyle.isEmpty()) // && (c->lineWidth() != 0.0))
2468
if (c->lineColor() != CommonStrings::None)
2471
PS_lineto(c->width(), 0);
2472
putColor(c->lineColor(), c->lineShade(), false);
2477
multiLine ml = Doc->MLineStyles[c->NamedLStyle];
2478
for (int it = ml.size()-1; it > -1; it--)
2480
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
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);
2488
PS_lineto(c->width(), 0);
2489
putColor(ml[it].Color, ml[it].Shade, false);
2493
if (c->startArrowIndex() != 0)
2496
arrowTrans.scale(-1,1);
2497
drawArrow(c, arrowTrans, c->startArrowIndex(), gcr);
2499
if (c->endArrowIndex() != 0)
2502
arrowTrans.translate(c->width(), 0);
2503
drawArrow(c, arrowTrans, c->endArrowIndex(), gcr);
2506
/* OBSOLETE CR 2005-02-06
2510
case PageItem::ItemType1:
2511
case PageItem::ItemType3:
2512
case PageItem::Polygon:
2513
if ((c->fillColor() != CommonStrings::None) || (c->GrType != 0))
2515
SetClipPath(&c->PoLine);
2517
fillRule = c->fillRule;
2519
HandleGradient(c, c->width(), c->height(), gcr);
2521
putColor(c->fillColor(), c->fillShade(), true);
2523
if ((c->lineColor() != CommonStrings::None) || (!c->NamedLStyle.isEmpty()))
2525
if (c->NamedLStyle.isEmpty()) //&& (c->lineWidth() != 0.0))
2527
if (c->lineColor() != CommonStrings::None)
2529
SetClipPath(&c->PoLine);
2531
putColor(c->lineColor(), c->lineShade(), false);
2536
multiLine ml = Doc->MLineStyles[c->NamedLStyle];
2537
for (int it = ml.size()-1; it > -1; it--)
2539
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
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);
2548
putColor(ml[it].Color, ml[it].Shade, false);
2554
case PageItem::PolyLine:
2555
if ((c->fillColor() != CommonStrings::None) || (c->GrType != 0))
2557
SetClipPath(&c->PoLine);
2560
HandleGradient(c, c->width(), c->height(), gcr);
2562
putColor(c->fillColor(), c->fillShade(), true);
2565
if ((c->lineColor() != CommonStrings::None) || (!c->NamedLStyle.isEmpty()))
2567
if (c->NamedLStyle.isEmpty()) //&& (c->lineWidth() != 0.0))
2569
if (c->lineColor() != CommonStrings::None)
2571
SetClipPath(&c->PoLine, false);
2572
putColor(c->lineColor(), c->lineShade(), false);
2577
multiLine ml = Doc->MLineStyles[c->NamedLStyle];
2578
for (int it = ml.size()-1; it > -1; it--)
2580
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
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);
2593
if (c->startArrowIndex() != 0)
2595
FPoint Start = c->PoLine.point(0);
2596
for (uint xx = 1; xx < c->PoLine.size(); xx += 2)
2598
FPoint Vector = c->PoLine.point(xx);
2599
if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
2601
double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI);
2603
arrowTrans.translate(Start.x(), Start.y());
2604
arrowTrans.rotate(r);
2605
drawArrow(c, arrowTrans, c->startArrowIndex(), gcr);
2610
if (c->endArrowIndex() != 0)
2612
FPoint End = c->PoLine.point(c->PoLine.size()-2);
2613
for (uint xx = c->PoLine.size()-1; xx > 0; xx -= 2)
2615
FPoint Vector = c->PoLine.point(xx);
2616
if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
2618
double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI);
2620
arrowTrans.translate(End.x(), End.y());
2621
arrowTrans.rotate(r);
2622
drawArrow(c, arrowTrans, c->endArrowIndex(), gcr);
2628
case PageItem::PathText:
2631
if (c->PoLine.size() > 3)
2634
if (c->NamedLStyle.isEmpty()) //&& (c->lineWidth() != 0.0))
2636
if (c->lineColor() != CommonStrings::None)
2638
SetClipPath(&c->PoLine, false);
2639
putColor(c->lineColor(), c->lineShade(), false);
2644
multiLine ml = Doc->MLineStyles[c->NamedLStyle];
2645
for (int it = ml.size()-1; it > -1; it--)
2647
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
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);
2663
for (d = c->firstInFrame(); d <= c->lastInFrame(); ++d)
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)))
2669
QPointF tangt = QPointF( cos(hl->PRot), sin(hl->PRot) );
2670
tsz = style.fontSize();
2672
if (hl->ch == QChar(29))
2674
if (hl->ch == QChar(0xA0))
2676
if (style.effects() & 32)
2678
if (chstr.toUpper() != chstr)
2679
chstr = chstr.toUpper();
2681
if (style.effects() & 64)
2683
if (chstr.toUpper() != chstr)
2685
tsz = style.fontSize() * Doc->typographicSettings.valueSmallCaps / 100;
2686
chstr = chstr.toUpper();
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)
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);
2698
if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem()))
2701
PutStream( MatrixToStr(1.0, 0.0, 0.0, -1.0, -hl->PDx, 0.0) + "\n");
2702
if (c->textPathFlipped)
2704
PutStream("[1 0 0 -1 0 0]\n");
2705
PutStream("[0 0 0 0 0 0] concatmatrix\n"); //???????
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)
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");
2723
PutStream( MatrixToStr(a, 4.0, 0.0, -1.0, hl->PtransX, -hl->PtransY) + "\n");
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)
2735
PageItem* embedded = emG.at(em);
2736
if (embedded->isGroupControl)
2739
FPointArray cl = embedded->PoLine.copy();
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());
2753
groupStack.push(embedded->groupsLastItem);
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);
2766
if (groupStack.count() != 0)
2768
while (embedded == groupStack.top())
2772
if (groupStack.count() == 0)
2780
/* Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed */
2781
if (FontSubsetMap.contains(style.font().scName()))
2783
// uint chr = chstr.unicode();
2784
uint chr = style.font().char2CMap(chstr);
2785
if (style.font().canRender(chstr))
2788
if (style.fillColor() != CommonStrings::None)
2790
PutStream( MatrixToStr(1.0, 0.0, 0.0, -1.0, -hl->PDx, 0.0) + "\n");
2791
if (c->textPathFlipped)
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");
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)
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");
2812
PutStream( MatrixToStr(a, 4.0, 0.0, -1.0, hl->PtransX, -hl->PtransY) + "\n");
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)))
2826
PS_translate(0, -(tsz / 10.0));
2827
double Ulen = hl->glyph.xadvance;
2828
double Upos, Uwid, kern;
2829
if (style.effects() & ScStyle_StartOfLine)
2832
kern = style.fontSize() * style.tracking() / 10000.0;
2833
if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1))
2835
if (style.underlineOffset() != -1)
2836
Upos = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0));
2838
Upos = style.font().underlinePos(style.fontSize() / 10.0);
2839
if (style.underlineWidth() != -1)
2840
Uwid = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0);
2842
Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2846
Upos = style.font().underlinePos(style.fontSize() / 10.0);
2847
Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2849
if (style.baselineOffset() != 0)
2850
Upos += (style.fontSize() / 10.0) * hl->glyph.scaleV * (style.baselineOffset() / 1000.0);
2851
if (style.fillColor() != CommonStrings::None)
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);
2856
PS_setlinewidth(Uwid);
2857
if (style.effects() & ScStyle_Subscript)
2859
PS_moveto(hl->glyph.xoffset , Upos);
2860
PS_lineto(hl->glyph.xoffset+Ulen, Upos);
2864
PS_moveto(hl->glyph.xoffset , hl->glyph.yoffset+Upos);
2865
PS_lineto(hl->glyph.xoffset+Ulen, hl->glyph.yoffset+Upos);
2867
putColor(style.fillColor(), style.fillShade(), false);
2872
if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None))
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);
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))
2884
if ((style.strokeColor() != CommonStrings::None) && ((tsz * style.outlineWidth() / 10000.0) != 0))
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);
2894
if ((style.effects() & ScStyle_Strikethrough) && (chstr != SpecialChars::PARSEP))
2897
PS_translate(0, -(tsz / 10.0));
2898
double Ulen = hl->glyph.xadvance;
2899
double Upos, Uwid, kern;
2900
if (hl->effects() & ScStyle_StartOfLine)
2903
kern = style.fontSize() * style.tracking() / 10000.0;
2904
if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1))
2906
if (style.strikethruOffset() != -1)
2907
Upos = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0));
2909
Upos = style.font().strikeoutPos(style.fontSize() / 10.0);
2910
if (style.strikethruWidth() != -1)
2911
Uwid = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0);
2913
Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2917
Upos = style.font().strikeoutPos(style.fontSize() / 10.0);
2918
Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2920
if (style.baselineOffset() != 0)
2921
Upos += (style.fontSize() / 10.0) * hl->glyph.scaleV * (style.baselineOffset() / 1000.0);
2922
if (style.fillColor() != CommonStrings::None)
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);
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);
2939
uint glyph = hl->glyph.glyph;
2940
PS_selectfont(style.font().replacementName(), tsz / 10.0);
2942
PutStream( MatrixToStr(1.0, 0.0, 0.0, -1.0, -hl->PDx, 0.0) + "\n");
2943
if (c->textPathFlipped)
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");
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)
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");
2964
PutStream( MatrixToStr(a, 4.0, 0.0, -1.0, hl->PtransX, -hl->PtransY) + "\n");
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)))
2975
double Ulen = hl->glyph.xadvance;
2976
double Upos, Uwid, kern;
2977
if (style.effects() & ScStyle_StartOfLine)
2980
kern = style.fontSize() * style.tracking() / 10000.0;
2981
if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1))
2983
if (style.underlineOffset() != -1)
2984
Upos = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0));
2986
Upos = style.font().underlinePos(style.fontSize() / 10.0);
2987
if (style.underlineWidth() != -1)
2988
Uwid = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0);
2990
Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2994
Upos = style.font().underlinePos(style.fontSize() / 10.0);
2995
Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2997
if (style.baselineOffset() != 0)
2998
Upos += (style.fontSize() / 10.0) * hl->glyph.scaleV * (style.baselineOffset() / 1000.0);
2999
if (style.fillColor() != CommonStrings::None)
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);
3004
PS_setlinewidth(Uwid);
3005
if (style.effects() & ScStyle_Subscript)
3007
PS_moveto(hl->glyph.xoffset , Upos);
3008
PS_lineto(hl->glyph.xoffset+Ulen, Upos);
3012
PS_moveto(hl->glyph.xoffset , hl->glyph.yoffset+Upos);
3013
PS_lineto(hl->glyph.xoffset+Ulen, hl->glyph.yoffset+Upos);
3015
putColor(style.fillColor(), style.fillShade(), false);
3020
if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None))
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());
3027
PS_show_xyG(style.font().replacementName(), glyph, 0, 0, style.fillColor(), style.fillShade());
3028
if ((style.effects() & ScStyle_Outline))
3030
if ((style.strokeColor() != CommonStrings::None) && ((tsz * style.outlineWidth() / 10000.0) != 0))
3032
uint gl = style.font().char2CMap(chstr);
3033
FPointArray gly = style.font().glyphOutline(gl);
3035
chma.scale(tsz / 100.0, tsz / 100.0);
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);
3044
putColor(style.strokeColor(), style.strokeShade(), false);
3049
if ((style.effects() & ScStyle_Strikethrough) && (chstr != SpecialChars::PARSEP))
3052
double Ulen = hl->glyph.xadvance;
3053
double Upos, Uwid, kern;
3054
if (hl->effects() & ScStyle_StartOfLine)
3057
kern = style.fontSize() * style.tracking() / 10000.0;
3058
if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1))
3060
if (style.strikethruOffset() != -1)
3061
Upos = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0));
3063
Upos = style.font().strikeoutPos(style.fontSize() / 10.0);
3064
if (style.strikethruWidth() != -1)
3065
Uwid = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0);
3067
Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
3071
Upos = style.font().strikeoutPos(style.fontSize() / 10.0);
3072
Uwid = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
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)
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);
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);
3101
void PSLib::ProcessPage(ScribusDoc* Doc, Page* a, uint PNr, bool sep, bool farb, bool ic, bool gcr)
3106
QString chstr, chglyph, tmp;
3108
QList<PageItem*> PItems;
3109
QStack<PageItem*> groupStack;
3112
ll.isPrintable = false;
3114
PItems = (a->pageName().isEmpty()) ? Doc->DocItems : Doc->MasterItems;
3115
for (int la = 0; la < Doc->Layers.count(); ++la)
3117
Doc->Layers.levelToLayer(ll, Lnr);
3118
if (ll.isPrintable && !abortExport)
3120
for (b = 0; b < PItems.count() && !abortExport; ++b)
3124
ScQApp->processEvents();
3125
if (c->LayerNr != ll.LNr)
3127
if ((!a->pageName().isEmpty()) && (c->asTextFrame()))
3129
if ((!a->pageName().isEmpty()) && (c->asImageFrame()) && ((sep) || (!farb)))
3131
//if ((!Art) && (view->SelItem.count() != 0) && (!c->Select))
3132
if ((!psExport) && (!c->isSelected()) && (Doc->m_Selection->count() != 0))
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 )))
3147
if (c->ChangedMasterItem)
3149
if ((!a->pageName().isEmpty()) && (c->OwnPage != static_cast<int>(a->pageNr())) && (c->OwnPage != -1))
3151
if (c->isGroupControl)
3154
FPointArray cl = c->PoLine.copy();
3156
mm.translate(c->xPos() - a->xOffset(), (c->yPos() - a->yOffset()) - a->height());
3157
mm.rotate(c->rotation());
3162
groupStack.push(c->groupsLastItem);
3165
ProcessItem(Doc, a, c, PNr, sep, farb, ic, gcr, false);
3166
if (groupStack.count() != 0)
3168
while (c == groupStack.top())
3172
if (groupStack.count() == 0)
3178
for (b = 0; b < PItems.count() && !abortExport; ++b)
3182
ScQApp->processEvents();
3183
if (c->LayerNr != ll.LNr)
3185
if ((!a->pageName().isEmpty()) && (c->asTextFrame()))
3187
if ((!a->pageName().isEmpty()) && (c->asImageFrame()) && ((sep) || (!farb)))
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 )))
3202
if (c->ChangedMasterItem)
3204
if (!c->isTableItem)
3206
if (c->lineColor() == CommonStrings::None) //|| (c->lineWidth() == 0.0))
3208
if ((!a->pageName().isEmpty()) && (c->OwnPage != static_cast<int>(a->pageNr())) && (c->OwnPage != -1))
3210
if (c->printEnabled())
3215
PutStream("true setoverprint\n");
3216
PutStream("true setoverprintmode\n");
3218
if (c->lineColor() != CommonStrings::None)
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);
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))
3234
PS_lineto(c->width(), 0);
3238
PS_moveto(c->width(), 0);
3239
PS_lineto(c->width(), -c->height());
3243
PS_moveto(0, -c->height());
3244
PS_lineto(c->width(), -c->height());
3249
PS_lineto(0, -c->height());
3251
putColor(c->lineColor(), c->lineShade(), false);
3260
void PSLib::HandleGradient(PageItem *c, double w, double h, bool gcr)
3268
QMatrix patternMatrix;
3269
double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation;
3270
QList<VColorStop*> cstops = c->fill_gradient.colorStops();
3318
StartX = c->GrStartX;
3319
StartY = c->GrStartY;
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");
3333
PutStream("eofill\n");
3335
PutStream("fill\n");
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))
3350
for (uint cst = 0; cst < c->fill_gradient.Stops(); ++cst)
3352
actualStop = cstops.at(cst)->rampPoint;
3353
if ((actualStop != lastStop) || (isFirst))
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);
3361
GCol = hs.setNum((255.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 255.0)) / 255.0);
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);
3369
PS_MultiRadGradient(w, -h, StartX, -StartY, StopVec, Gcolors, colorNames, colorShades);
3374
for (uint cst = 0; cst < c->fill_gradient.Stops(); ++cst)
3376
actualStop = cstops.at(cst)->rampPoint;
3377
if ((actualStop != lastStop) || (isFirst))
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;
3385
SetColor(cstops.at(cst)->name, cstops.at(cst)->shade, &ch, &cs, &cv, &ck, gcr);
3388
GCol = hs.setNum((255.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 255.0)) / 255.0);
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);
3396
PS_MultiLinGradient(w, -h, StopVec, Gcolors, colorNames, colorShades);
3400
void PSLib::drawArrow(PageItem *ite, QMatrix &arrowTrans, int arrowIndex, bool gcr)
3403
QVector<double> dum;
3404
FPointArray arrow = m_Doc->arrowStyles.at(arrowIndex-1).points.copy();
3405
if (ite->NamedLStyle.isEmpty())
3407
if (ite->lineWidth() != 0.0)
3408
arrowTrans.scale(ite->lineWidth(), ite->lineWidth());
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);
3416
arrow.map(arrowTrans);
3417
if (ite->NamedLStyle.isEmpty())
3419
if (ite->lineColor() != CommonStrings::None)
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);
3424
SetClipPath(&arrow);
3426
putColor(ite->lineColor(), ite->lineShade(), true);
3431
multiLine ml = m_Doc->MLineStyles[ite->NamedLStyle];
3432
if (ml[0].Color != CommonStrings::None)
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);
3437
SetClipPath(&arrow);
3439
putColor(ite->lineColor(), ite->lineShade(), true);
3441
for (int it = ml.size()-1; it > 0; it--)
3443
if (ml[it].Color != CommonStrings::None)
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);
3452
putColor(ml[it].Color, ml[it].Shade, false);
3458
void PSLib::SetColor(const QString& farb, double shade, int *h, int *s, int *v, int *k, bool gcr)
3460
ScColor& col = m_Doc->PageColors[farb];
3461
SetColor(col, shade, h, s, v, k, gcr);
3464
void PSLib::SetColor(const ScColor& farb, double shade, int *h, int *s, int *v, int *k, bool gcr)
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))
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];
3489
solidTransform.apply(inC, outC, 1);
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);
3504
void PSLib::setTextSt(ScribusDoc* Doc, PageItem* ite, bool gcr, uint argh, Page* pg, bool sep, bool farb, bool ic, bool master)
3506
// qDebug() << QString("pslib setTextSt: ownPage=%1 pageNr=%2 OnMasterPage=%3;").arg(ite->OwnPage).arg(pg->pageNr()).arg(ite->OnMasterPage);
3508
int savedOwnPage = ite->OwnPage;
3509
double tabDist = ite->textToFrameDistLeft();
3510
double colLeft = 0.0;
3511
QList<ParagraphStyle::TabRecord> tTabValues;
3513
ite->OwnPage = argh;
3515
ite->OwnPage = savedOwnPage;
3517
if (ite->lineColor() != CommonStrings::None)
3518
tabDist += ite->lineWidth() / 2.0;
3520
for (uint ll=0; ll < ite->itemText.lines(); ++ll) {
3521
LineSpec ls = ite->itemText.line(ll);
3522
colLeft = ls.colLeft;
3526
for (int d = ls.firstItem; d <= ls.lastItem; ++d)
3528
ScText *hl = ite->itemText.item(d);
3529
const CharStyle & cstyle(ite->itemText.charStyle(d));
3530
const ParagraphStyle& pstyle(ite->itemText.paragraphStyle(d));
3532
// if ((hl->ch == QChar(13)) || (hl->ch == QChar(10)) || (hl->ch == QChar(28)) || (hl->ch == QChar(27)) || (hl->ch == QChar(26)))
3534
if (hl->effects() & 4096)
3536
tTabValues = pstyle.tabValues();
3537
if (hl->effects() & 16384)
3539
if ((hl->ch == SpecialChars::TAB) && (tTabValues.count() != 0))
3542
const TabLayout* tabLayout = dynamic_cast<const TabLayout*>(hl->glyph.more);
3544
tabFillChar = tabLayout->fillChar;
3545
if (!tabFillChar.isNull())
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;
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)
3564
hl2.glyph.xoffset = sPos + wt * cx;
3565
if ((hl2.effects() & 256) && (hl2.strokeColor() != CommonStrings::None))
3568
static_cast<CharStyle&>(hl3) = static_cast<const CharStyle&>(hl2);
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);
3576
setTextCh(Doc, ite, CurX, ls.y, gcr, argh, d, &hl2, pstyle, pg, sep, farb, ic, master);
3581
if (hl->ch == SpecialChars::TAB) {
3582
CurX += hl->glyph.wide();
3585
if ((cstyle.effects() & ScStyle_Shadowed) && (cstyle.strokeColor() != CommonStrings::None))
3588
static_cast<CharStyle&>(hl2) = static_cast<const CharStyle&>(*hl);
3590
hl2.glyph.glyph = hl->glyph.glyph;
3591
const GlyphLayout *gl1 = &hl->glyph;
3592
GlyphLayout *gl2 = &hl2.glyph;
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;
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;
3611
setTextCh(Doc, ite, CurX, ls.y, gcr, argh, d, &hl2, pstyle, pg, sep, farb, ic, master);
3613
setTextCh(Doc, ite, CurX, ls.y, gcr, argh, d, hl, pstyle, pg, sep, farb, ic, master);
3614
if (hl->ch == SpecialChars::OBJECT)
3616
InlineFrame& embedded(const_cast<InlineFrame&>(hl->embedded));
3617
CurX += (embedded.getItem()->gWidth + embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
3620
CurX += hl->glyph.wide();
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)
3629
const CharStyle & cstyle(*hl);
3630
const GlyphLayout & glyphs(hl->glyph);
3631
uint glyph = glyphs.glyph;
3636
QVector<double> dum;
3639
QChar chstr = hl->ch;
3641
tsz = cstyle.fontSize();
3643
/* if (cstyle.effects() & ScStyle_DropCap)
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))));
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))));
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)));
3660
if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem()))
3662
QList<PageItem*> emG = hl->embedded.getGroupedItems();
3663
QStack<PageItem*> groupStack;
3664
for (int em = 0; em < emG.count(); ++em)
3666
PageItem* embedded = emG.at(em);
3667
if (embedded->isGroupControl)
3670
FPointArray cl = embedded->PoLine.copy();
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());
3684
groupStack.push(embedded->groupsLastItem);
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);
3697
if (groupStack.count() != 0)
3699
while (embedded == groupStack.top())
3703
if (groupStack.count() == 0)
3708
for (int em = 0; em < emG.count(); ++em)
3711
PageItem* item = emG.at(em);
3712
if (!item->isTableItem)
3714
if ((item->lineColor() == CommonStrings::None) || (item->lineWidth() == 0.0))
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)
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);
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))
3736
PS_lineto(item->width(), 0);
3738
if (item->RightLine)
3740
PS_moveto(item->width(), 0);
3741
PS_lineto(item->width(), -item->height());
3743
if (item->BottomLine)
3745
PS_moveto(0, -item->height());
3746
PS_lineto(item->width(), -item->height());
3751
PS_lineto(0, -item->height());
3753
putColor(item->lineColor(), item->lineShade(), false);
3756
item->m_lineWidth = pws;
3761
if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode()) ||
3762
glyph == (ScFace::CONTROL_GLYPHS + 32))
3764
glyph = cstyle.font().char2CMap(QChar(' '));
3767
else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode()))
3769
glyph = cstyle.font().char2CMap(QChar('-'));
3773
if (glyph < ScFace::CONTROL_GLYPHS)
3775
if (((cstyle.effects() & ScStyle_Underline) && !SpecialChars::isBreak(chstr)) //FIXME && (chstr != QChar(13)))
3776
|| ((cstyle.effects() & ScStyle_UnderlineWords) && !chstr.isSpace() && !SpecialChars::isBreak(chstr)))
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)
3784
kern = cstyle.fontSize() * cstyle.tracking() / 10000.0;
3785
if ((cstyle.underlineOffset() != -1) || (cstyle.underlineWidth() != -1))
3787
if (cstyle.underlineOffset() != -1)
3788
Upos = (cstyle.underlineOffset() / 1000.0) * (cstyle.font().descent(cstyle.fontSize() / 10.0));
3790
Upos = cstyle.font().underlinePos(cstyle.fontSize() / 10.0);
3791
if (cstyle.underlineWidth() != -1)
3792
lw = (cstyle.underlineWidth() / 1000.0) * (cstyle.fontSize() / 10.0);
3794
lw = qMax(cstyle.font().strokeWidth(cstyle.fontSize() / 10.0), 1.0);
3798
Upos = cstyle.font().underlinePos(cstyle.fontSize() / 10.0);
3799
lw = qMax(cstyle.font().strokeWidth(cstyle.fontSize() / 10.0), 1.0);
3801
if (cstyle.baselineOffset() != 0)
3802
Upos += (cstyle.fontSize() / 10.0) * glyphs.scaleV * (cstyle.baselineOffset() / 1000.0);
3803
if (cstyle.fillColor() != CommonStrings::None)
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);
3810
PS_setlinewidth(lw);
3811
if (cstyle.effects() & ScStyle_Subscript)
3813
PS_moveto(x + glyphs.xoffset , -y - glyphs.yoffset+Upos);
3814
PS_lineto(x + glyphs.xoffset+Ulen, -y - glyphs.yoffset+Upos);
3818
PS_moveto(x + glyphs.xoffset , -y + Upos);
3819
PS_lineto(x + glyphs.xoffset+Ulen, -y + Upos);
3821
putColor(cstyle.fillColor(), cstyle.fillShade(), false);
3823
/* Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed */
3824
if (FontSubsetMap.contains(cstyle.font().scName()))
3826
if (glyph != 0 && glyph != cstyle.font().char2CMap(QChar(' ')) && (!SpecialChars::isBreak(chstr)))
3829
if (ite->reversed())
3831
PS_translate(x + hl->glyph.xoffset, (y + hl->glyph.yoffset - (tsz / 10.0)) * -1);
3833
PS_translate(-glyphs.xadvance, 0);
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)
3843
PS_translate(0, -((tsz / 10.0) - (tsz / 10.0) * (glyphs.scaleV)));
3844
PS_scale(1, glyphs.scaleV);
3846
if (cstyle.fillColor() != CommonStrings::None)
3848
putColorNoDraw(cstyle.fillColor(), cstyle.fillShade(), gcr);
3849
PS_showSub(glyph, FontSubsetMap[cstyle.font().scName()], tsz / 10.0, false);
3854
else if (glyph != 0)
3856
PS_selectfont(cstyle.font().replacementName(), tsz / 10.0);
3858
PS_translate(x + glyphs.xoffset, -y - glyphs.yoffset);
3859
if (ite->reversed())
3862
PS_translate(glyphs.xadvance, 0);
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)
3870
PS_show_xyG(cstyle.font().replacementName(), glyph, 0, 0, cstyle.fillColor(), cstyle.fillShade());
3874
if ((cstyle.effects() & ScStyle_Outline) || glyph == 0)//&& (chstr != QChar(13)))
3876
// if (cstyle.font().canRender(chstr))
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())
3889
chma.translate(wideR, 0);
3892
if ((cstyle.strokeColor() != CommonStrings::None) && ((tsz * cstyle.outlineWidth() / 10000.0) != 0))
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);
3904
putColor(cstyle.strokeColor(), cstyle.strokeShade(), false);
3909
if ((cstyle.effects() & ScStyle_Strikethrough))//&& (chstr != QChar(13)))
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)
3917
kern = cstyle.fontSize() * cstyle.tracking() / 10000.0;
3918
if ((cstyle.strikethruOffset() != -1) || (cstyle.strikethruWidth() != -1))
3920
if (cstyle.strikethruOffset() != -1)
3921
Upos = (cstyle.strikethruOffset() / 1000.0) * (cstyle.font().ascent(cstyle.fontSize() / 10.0));
3923
Upos = cstyle.font().strikeoutPos(cstyle.fontSize() / 10.0);
3924
if (cstyle.strikethruWidth() != -1)
3925
lw = (cstyle.strikethruWidth() / 1000.0) * (cstyle.fontSize() / 10.0);
3927
lw = qMax(cstyle.font().strokeWidth(cstyle.fontSize() / 10.0), 1.0);
3931
Upos = cstyle.font().strikeoutPos(cstyle.fontSize() / 10.0);
3932
lw = qMax(cstyle.font().strokeWidth(cstyle.fontSize() / 10.0), 1.0);
3934
if (cstyle.baselineOffset() != 0)
3935
Upos += (cstyle.fontSize() / 10.0) * glyphs.scaleV * (cstyle.baselineOffset() / 1000.0);
3936
if (cstyle.fillColor() != CommonStrings::None)
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);
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);
3950
// ugly hack until setTextCh interface is changed
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!
3957
/* if (cstyle.effects() & ScStyle_SmartHyphenVisible)
3959
int chs = cstyle.fontSize();
3960
// double wide = cstyle.font().charWidth(chstr, chs) * (cstyle.scaleH() / 1000.0);
3962
// if (cstyle.font().canRender(chstr))
3964
FPointArray gly = cstyle.font().glyphOutline(glyph);
3966
chma.scale(tsz / 100.0, tsz / 100.0);
3969
chma.scale(glyphs.scaleH, glyphs.scaleV);
3971
if (cstyle.fillColor() != CommonStrings::None)
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);
3980
putColor(cstyle.fillColor(), cstyle.fillShade(), true);
3987
void PSLib::putColor(const QString& colorName, double shade, bool fill)
3989
ScColor& color(colorsToUse[colorName]);
3992
if (((color.isSpotColor()) || (color.isRegistrationColor())) && (useSpotColors))
3995
PS_fillspot(colorName, shade);
3998
if ((colorName == currentSpot) || (color.isRegistrationColor()))
4001
PutStream("0 0 0 "+ToStr(shade / 100.0)+" cmyk eofill\n");
4003
PutStream("0 0 0 "+ToStr(shade / 100.0)+" cmyk fill\n");
4008
PutStream("0 0 0 0 cmyk eofill\n");
4010
PutStream("0 0 0 0 cmyk fill\n");
4016
if (!DoSep || (Plate == 0) || (Plate == 1) || (Plate == 2) || (Plate == 3))
4019
PutStream("0 0 0 0 cmyk eofill\n");
4021
PutStream("0 0 0 0 cmyk fill\n");
4026
if (((color.isSpotColor()) || (color.isRegistrationColor())) && (useSpotColors))
4029
PS_strokespot(colorName, shade);
4032
if ((colorName == currentSpot) || (color.isRegistrationColor()))
4033
PutStream("0 0 0 "+ToStr(shade / 100.0)+" cmyk st\n");
4038
if (!DoSep || (Plate == 0) || (Plate == 1) || (Plate == 2) || (Plate == 3))
4041
PutStream("0 0 0 0 cmyk st\n");
4046
void PSLib::putColorNoDraw(const QString& colorName, double shade, bool gcr)
4048
ScColor& color(colorsToUse[colorName]);
4049
if (((color.isSpotColor()) || (color.isRegistrationColor())) && (useSpotColors))
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");
4056
PutStream("0 0 0 0 cmyk\n");
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");
4065
PutStream("0 0 0 0 cmyk\n");
4069
void PSLib::GetBleeds(Page* page, double& left, double& right)
4071
MarginStruct values;
4072
m_Doc->getBleeds(page, Options.bleeds, values);
4074
right = values.Right;
4077
void PSLib::GetBleeds(Page* page, double& left, double& right, double& bottom, double& top)
4079
MarginStruct values;
4080
m_Doc->getBleeds(page, Options.bleeds, values);
4082
right = values.Right;
4083
bottom = values.Bottom;
4087
void PSLib::SetClipPath(FPointArray *c, bool poly)
4089
FPoint np, np1, np2, np3;
4093
for (uint poi=0; poi<c->size()-3; poi += 4)
4095
if (c->point(poi).x() > 900000)
4105
PS_moveto(np.x(), -np.y());
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());
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()); */
4124
const QString& PSLib::errorMessage(void)
4126
return ErrorMessage;
4129
void PSLib::cancelRequested()