Rev 9620 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
3136 | fschmid | 7 | /*************************************************************************** |
8 | pslib.cpp - description |
||
9 | ------------------- |
||
10 | begin : Sat May 26 2001 |
||
11 | copyright : (C) 2001 by Franz Schmid |
||
12 | email : Franz.Schmid@altmuehlnet.de |
||
13 | ***************************************************************************/ |
||
14 | |||
15 | /*************************************************************************** |
||
16 | * * |
||
17 | * This program is free software; you can redistribute it and/or modify * |
||
18 | * it under the terms of the GNU General Public License as published by * |
||
19 | * the Free Software Foundation; either version 2 of the License, or * |
||
20 | * (at your option) any later version. * |
||
21 | * * |
||
22 | ***************************************************************************/ |
||
4037 | cbradney | 23 | |
24 | #include "pslib.h" |
||
25 | #include "pslib.moc" |
||
26 | |||
3136 | fschmid | 27 | #include <qfileinfo.h> |
28 | #include <qimage.h> |
||
29 | #include <qcolor.h> |
||
30 | #include <qcstring.h> |
||
31 | #include <qfontinfo.h> |
||
32 | #include <cstdlib> |
||
33 | #include <qregexp.h> |
||
6388 | fschmid | 34 | #include <qbuffer.h> |
6451 | fschmid | 35 | #include <qptrstack.h> |
3136 | fschmid | 36 | |
4037 | cbradney | 37 | #include "commonstrings.h" |
3136 | fschmid | 38 | #include "scconfig.h" |
39 | #include "pluginapi.h" |
||
3939 | cbradney | 40 | #include "prefsmanager.h" |
3136 | fschmid | 41 | #include "scribusdoc.h" |
4037 | cbradney | 42 | #include "scribus.h" |
5243 | cbradney | 43 | #include "scribuscore.h" |
3136 | fschmid | 44 | #include "scfonts.h" |
3934 | cbradney | 45 | #include "selection.h" |
3136 | fschmid | 46 | #include <cmath> |
47 | #include "util.h" |
||
4037 | cbradney | 48 | #include "multiprogressdialog.h" |
49 | #include "scribusapp.h" |
||
6388 | fschmid | 50 | #include "scpattern.h" |
7478 | jghali | 51 | #include "sccolorengine.h" |
3136 | fschmid | 52 | |
5184 | avox | 53 | #include "text/nlsconfig.h" |
54 | |||
6954 | fschmid | 55 | PSLib::PSLib(PrintOptions &options, bool psart, SCFonts &AllFonts, QMap<QString, QMap<uint, FPointArray> > DocFonts, ColorList DocColors, bool pdf, bool spot) |
3136 | fschmid | 56 | { |
6954 | fschmid | 57 | Options = options; |
5243 | cbradney | 58 | usingGUI=ScCore->usingGUI(); |
4044 | cbradney | 59 | abortExport=false; |
3136 | fschmid | 60 | QString tmp, tmp2, tmp3, tmp4, CHset; |
61 | QStringList wt; |
||
62 | Seiten = 0; |
||
63 | User = ""; |
||
64 | Creator = "Scribus" + QString(VERSION); |
||
65 | Titel = ""; |
||
66 | FillColor = "0.0 0.0 0.0 0.0"; |
||
67 | StrokeColor = "0.0 0.0 0.0 0.0"; |
||
68 | Header = psart ? "%!PS-Adobe-3.0\n" : "%!PS-Adobe-3.0 EPSF-3.0\n"; |
||
69 | BBox = ""; |
||
70 | BBoxH = ""; |
||
71 | Art = psart; |
||
72 | isPDF = pdf; |
||
73 | UsedFonts.clear(); |
||
74 | Fonts = ""; |
||
75 | FontDesc = ""; |
||
76 | GraySc = false; |
||
77 | DoSep = false; |
||
4046 | fschmid | 78 | abortExport = false; |
3136 | fschmid | 79 | useSpotColors = spot; |
80 | CompAvail = true; |
||
81 | GrayCalc = "/setcmykcolor {exch 0.11 mul add exch 0.59 mul add exch 0.3 mul add\n"; |
||
82 | GrayCalc += " dup 1 gt {pop 1} if 1 exch sub oldsetgray} bind def\n"; |
||
83 | GrayCalc += "/setrgbcolor {0.11 mul exch 0.59 mul add exch 0.3 mul add\n"; |
||
84 | GrayCalc += " oldsetgray} bind def\n"; |
||
6748 | fschmid | 85 | Farben = ""; |
86 | FNamen = ""; |
||
9618 | jghali | 87 | CMYKColor cmykValues; |
3136 | fschmid | 88 | ColorList::Iterator itf; |
89 | int c, m, y, k; |
||
90 | bool erst = true; |
||
91 | colorsToUse = DocColors; |
||
92 | spotMap.clear(); |
||
93 | colorDesc = ""; |
||
94 | for (itf = DocColors.begin(); itf != DocColors.end(); ++itf) |
||
95 | { |
||
96 | if (((DocColors[itf.key()].isSpotColor()) || (DocColors[itf.key()].isRegistrationColor())) && (useSpotColors)) |
||
97 | { |
||
9618 | jghali | 98 | ScColorEngine::getCMYKValues(DocColors[itf.key()], DocColors.document(), cmykValues); |
99 | cmykValues.getValues(c, m, y, k); |
||
3136 | fschmid | 100 | colorDesc += "/Spot"+PSEncode(itf.key())+" { [ /Separation ("; |
101 | if (DocColors[itf.key()].isRegistrationColor()) |
||
102 | colorDesc += "All"; |
||
103 | else |
||
104 | colorDesc += itf.key(); |
||
105 | colorDesc += ")\n"; |
||
106 | colorDesc += "/DeviceCMYK\n{\ndup "+ToStr(static_cast<double>(c) / 255)+"\nmul exch dup "; |
||
107 | colorDesc += ToStr(static_cast<double>(m) / 255)+"\nmul exch dup "; |
||
108 | colorDesc += ToStr(static_cast<double>(y) / 255)+"\nmul exch "; |
||
109 | colorDesc += ToStr(static_cast<double>(k) / 255)+" mul }] setcolorspace setcolor} bind def\n"; |
||
110 | spotMap.insert(itf.key(), "Spot"+PSEncode(itf.key())); |
||
111 | } |
||
112 | if ((itf.key() != "Cyan") && (itf.key() != "Magenta") && (itf.key() != "Yellow") && (itf.key() != "Black") && DocColors[itf.key()].isSpotColor()) |
||
113 | { |
||
9618 | jghali | 114 | ScColorEngine::getCMYKValues(DocColors[itf.key()], DocColors.document(), cmykValues); |
115 | cmykValues.getValues(c, m, y, k); |
||
3136 | fschmid | 116 | if (!erst) |
117 | { |
||
118 | Farben += "%%+ "; |
||
119 | FNamen += "%%+ "; |
||
120 | } |
||
121 | Farben += ToStr(static_cast<double>(c) / 255) + " " + ToStr(static_cast<double>(m) / 255) + " "; |
||
122 | Farben += ToStr(static_cast<double>(y) / 255) + " " + ToStr(static_cast<double>(k) / 255) + " (" + itf.key() + ")\n"; |
||
123 | FNamen += "(" + itf.key() + ")\n"; |
||
124 | erst = false; |
||
125 | } |
||
126 | } |
||
5387 | avox | 127 | QMap<QString, QMap<uint, FPointArray> >::Iterator it; |
3136 | fschmid | 128 | int a = 0; |
129 | for (it = DocFonts.begin(); it != DocFonts.end(); ++it) |
||
130 | { |
||
131 | /* Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed */ |
||
5980 | avox | 132 | ScFace::FontType type = AllFonts[it.key()].type(); |
3136 | fschmid | 133 | |
5980 | avox | 134 | if ((type == ScFace::TTF) || (AllFonts[it.key()].isOTF()) || (AllFonts[it.key()].subset())) |
3136 | fschmid | 135 | { |
5387 | avox | 136 | QMap<uint, FPointArray>& RealGlyphs(it.data()); |
5980 | avox | 137 | FontDesc += "/"+AllFonts[it.key()].psName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+ |
5387 | avox | 138 | " "+IToStr(RealGlyphs.count()+1)+" dict def\n"; |
5980 | avox | 139 | FontDesc += AllFonts[it.key()].psName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+" begin\n"; |
3136 | fschmid | 140 | QMap<uint,FPointArray>::Iterator ig; |
5390 | avox | 141 | for (ig = RealGlyphs.begin(); ig != RealGlyphs.end(); ++ig) |
3136 | fschmid | 142 | { |
143 | FontDesc += "/G"+IToStr(ig.key())+" { newpath\n"; |
||
144 | FPoint np, np1, np2; |
||
145 | bool nPath = true; |
||
146 | if (ig.data().size() > 3) |
||
147 | { |
||
148 | for (uint poi = 0; poi < ig.data().size()-3; poi += 4) |
||
149 | { |
||
150 | if (ig.data().point(poi).x() > 900000) |
||
151 | { |
||
152 | FontDesc += "cl\n"; |
||
153 | nPath = true; |
||
154 | continue; |
||
155 | } |
||
156 | if (nPath) |
||
157 | { |
||
158 | np = ig.data().point(poi); |
||
159 | FontDesc += ToStr(np.x()) + " " + ToStr(-np.y()) + " m\n"; |
||
160 | nPath = false; |
||
161 | } |
||
162 | np = ig.data().point(poi+1); |
||
163 | np1 = ig.data().point(poi+3); |
||
164 | np2 = ig.data().point(poi+2); |
||
165 | FontDesc += ToStr(np.x()) + " " + ToStr(-np.y()) + " " + |
||
166 | ToStr(np1.x()) + " " + ToStr(-np1.y()) + " " + |
||
167 | ToStr(np2.x()) + " " + ToStr(-np2.y()) + " cu\n"; |
||
168 | } |
||
169 | } |
||
170 | FontDesc += "cl\n} bind def\n"; |
||
171 | } |
||
172 | FontDesc += "end\n"; |
||
173 | } |
||
174 | else |
||
175 | { |
||
176 | UsedFonts.insert(it.key(), "/Fo"+IToStr(a)); |
||
5980 | avox | 177 | Fonts += "/Fo"+IToStr(a)+" /"+AllFonts[it.key()].psName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+" findfont definefont pop\n"; |
178 | if (AllFonts[it.key()].embedPs()) |
||
3136 | fschmid | 179 | { |
180 | QString tmp; |
||
5980 | avox | 181 | if(AllFonts[it.key()].EmbedFont(tmp)) |
3136 | fschmid | 182 | { |
5980 | avox | 183 | FontDesc += "%%BeginFont: " + AllFonts[it.key()].psName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ) + "\n"; |
3136 | fschmid | 184 | FontDesc += tmp + "\n%%EndFont\n"; |
185 | } |
||
186 | } |
||
187 | GListe gl; |
||
5980 | avox | 188 | AllFonts[it.key()].glyphNames(gl); |
3136 | fschmid | 189 | GlyphsOfFont.insert(it.key(), gl); |
190 | a++; |
||
191 | } |
||
192 | } |
||
193 | Prolog = "%%BeginProlog\n"; |
||
194 | Prolog += "/Scribusdict 100 dict def\n"; |
||
195 | Prolog += "Scribusdict begin\n"; |
||
196 | Prolog += "/sp {showpage} bind def\n"; |
||
197 | Prolog += "/oldsetgray /setgray load def\n"; |
||
198 | Prolog += "/cmyk {setcmykcolor} def\n"; |
||
199 | Prolog += "/m {moveto} bind def\n"; |
||
200 | Prolog += "/l {lineto} bind def\n"; |
||
201 | Prolog += "/li {lineto} bind def\n"; |
||
202 | Prolog += "/cu {curveto} bind def\n"; |
||
203 | Prolog += "/cl {closepath} bind def\n"; |
||
204 | Prolog += "/gs {gsave} bind def\n"; |
||
205 | Prolog += "/gr {grestore} bind def\n"; |
||
206 | Prolog += "/tr {translate} bind def\n"; |
||
207 | Prolog += "/ro {rotate} bind def\n"; |
||
208 | Prolog += "/sh {show} bind def\n"; |
||
209 | Prolog += "/shg {setcmykcolor moveto glyphshow} def\n"; |
||
3555 | fschmid | 210 | Prolog += "/shgsp {moveto glyphshow} def\n"; |
3136 | fschmid | 211 | Prolog += "/sc {scale} bind def\n"; |
212 | Prolog += "/se {selectfont} bind def\n"; |
||
213 | Prolog += "/sf {setfont} bind def\n"; |
||
214 | Prolog += "/sw {setlinewidth} bind def\n"; |
||
215 | Prolog += "/f {findfont} bind def\n"; |
||
216 | Prolog += "/fi {fill} bind def\n"; |
||
217 | Prolog += "/st {stroke} bind def\n"; |
||
218 | Prolog += "/shgf {gs dup scale begin cvx exec fill end gr} bind def\n"; |
||
219 | Prolog += "/shgs {gs dup 1 exch div currentlinewidth mul sw dup scale\n"; |
||
220 | Prolog += " begin cvx exec st end gr} bind def\n"; |
||
221 | Prolog += "/bEPS {\n"; |
||
222 | Prolog += " /b4_Inc_state save def\n"; |
||
223 | Prolog += " /dict_count countdictstack def\n"; |
||
224 | Prolog += " /op_count count 1 sub def\n"; |
||
225 | Prolog += " userdict begin\n"; |
||
226 | Prolog += " /showpage { } def\n"; |
||
227 | Prolog += " 0 setgray 0 setlinecap\n"; |
||
228 | Prolog += " 1 setlinewidth 0 setlinejoin\n"; |
||
229 | Prolog += " 10 setmiterlimit [ ] 0 setdash newpath\n"; |
||
230 | Prolog += " /languagelevel where\n"; |
||
231 | Prolog += " {pop languagelevel\n"; |
||
232 | Prolog += " 1 ne\n"; |
||
233 | Prolog += " {false setstrokeadjust false setoverprint\n"; |
||
234 | Prolog += " } if } if } bind def\n"; |
||
235 | Prolog += "/eEPS { count op_count sub {pop} repeat\n"; |
||
236 | Prolog += " countdictstack dict_count sub {end} repeat\n"; |
||
237 | Prolog += " b4_Inc_state restore } bind def\n"; |
||
238 | Prolog += " end\n"; |
||
6954 | fschmid | 239 | if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks)) |
240 | 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"; |
||
3136 | fschmid | 241 | Prolog += "%%EndProlog\n"; |
242 | } |
||
243 | |||
244 | void PSLib::PutSeite(QString c) |
||
245 | { |
||
6388 | fschmid | 246 | spoolStream.writeRawBytes(c, c.length()); |
3136 | fschmid | 247 | } |
248 | |||
5234 | fschmid | 249 | void PSLib::PutSeite(QByteArray& array, bool hexEnc) |
250 | { |
||
251 | if(hexEnc) |
||
252 | { |
||
253 | int length = 0; |
||
5308 | fschmid | 254 | for (uint i = 0; i < array.size(); i++) |
5234 | fschmid | 255 | { |
256 | length++; |
||
6388 | fschmid | 257 | spoolStream << toHex(array[i]); |
5234 | fschmid | 258 | if ( length > 40 ) |
259 | { |
||
6388 | fschmid | 260 | spoolStream << "\n"; |
5234 | fschmid | 261 | length = 0; |
262 | } |
||
263 | } |
||
264 | } |
||
265 | else |
||
6388 | fschmid | 266 | spoolStream.writeRawBytes(array, array.size()); |
5234 | fschmid | 267 | } |
268 | |||
269 | void PSLib::PutSeite(const char* array, int length, bool hexEnc) |
||
270 | { |
||
271 | if(hexEnc) |
||
272 | { |
||
273 | int len = 0; |
||
274 | for (int i = 0; i < length; i++) |
||
275 | { |
||
276 | len++; |
||
6388 | fschmid | 277 | spoolStream << toHex(array[i]); |
5234 | fschmid | 278 | if ( len > 40 ) |
279 | { |
||
6388 | fschmid | 280 | spoolStream << "\n"; |
5234 | fschmid | 281 | len = 0; |
282 | } |
||
283 | } |
||
284 | } |
||
285 | else |
||
6388 | fschmid | 286 | spoolStream.writeRawBytes(array, length); |
5234 | fschmid | 287 | } |
288 | |||
3136 | fschmid | 289 | void PSLib::PutDoc(QString c) |
290 | { |
||
6388 | fschmid | 291 | spoolStream.writeRawBytes(c, c.length()); |
3136 | fschmid | 292 | } |
293 | |||
5234 | fschmid | 294 | void PSLib::PutDoc(QByteArray& array, bool hexEnc) |
295 | { |
||
296 | if(hexEnc) |
||
297 | { |
||
298 | int length = 0; |
||
5387 | avox | 299 | for (uint i = 0; i < array.size(); i++) |
5234 | fschmid | 300 | { |
301 | length++; |
||
6388 | fschmid | 302 | spoolStream << toHex(array[i]); |
5234 | fschmid | 303 | if ( length > 40 ) |
304 | { |
||
6388 | fschmid | 305 | spoolStream << "\n"; |
5234 | fschmid | 306 | length = 0; |
307 | } |
||
308 | } |
||
309 | } |
||
310 | else |
||
6388 | fschmid | 311 | spoolStream.writeRawBytes(array, array.size()); |
5234 | fschmid | 312 | } |
313 | |||
314 | void PSLib::PutDoc(const char* array, int length, bool hexEnc) |
||
315 | { |
||
316 | if(hexEnc) |
||
317 | { |
||
318 | int len = 0; |
||
319 | for (int i = 0; i < length; i++) |
||
320 | { |
||
321 | len++; |
||
6388 | fschmid | 322 | spoolStream << toHex(array[i]); |
5234 | fschmid | 323 | if ( len > 40 ) |
324 | { |
||
6388 | fschmid | 325 | spoolStream << "\n"; |
5234 | fschmid | 326 | len = 0; |
327 | } |
||
328 | } |
||
329 | } |
||
330 | else |
||
6388 | fschmid | 331 | spoolStream.writeRawBytes(array, length); |
5234 | fschmid | 332 | } |
333 | |||
3136 | fschmid | 334 | QString PSLib::ToStr(double c) |
335 | { |
||
336 | QString cc; |
||
337 | return cc.setNum(c); |
||
338 | } |
||
339 | |||
340 | QString PSLib::IToStr(int c) |
||
341 | { |
||
342 | QString cc; |
||
343 | return cc.setNum(c); |
||
344 | } |
||
345 | |||
346 | void PSLib::PS_set_Info(QString art, QString was) |
||
347 | { |
||
348 | if (art == "Author") |
||
349 | User = was; |
||
350 | if (art == "Creator") |
||
351 | Creator = was; |
||
352 | if (art == "Title") |
||
353 | Titel = was; |
||
354 | } |
||
355 | |||
356 | bool PSLib::PS_set_file(QString fn) |
||
357 | { |
||
358 | Spool.setName(fn); |
||
9632 | avox | 359 | if (Spool.exists()) |
360 | Spool.remove(); |
||
6388 | fschmid | 361 | bool ret = Spool.open(IO_WriteOnly); |
362 | spoolStream.setDevice(&Spool); |
||
363 | return ret; |
||
3136 | fschmid | 364 | } |
365 | |||
6388 | fschmid | 366 | void 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, bool over) |
3136 | fschmid | 367 | { |
6388 | fschmid | 368 | m_Doc = doc; |
3136 | fschmid | 369 | PutDoc(Header); |
370 | PutDoc("%%For: " + User + "\n"); |
||
371 | PutDoc("%%Title: " + Titel + "\n"); |
||
372 | PutDoc("%%Creator: " + Creator + "\n"); |
||
373 | PutDoc("%%Pages: " + IToStr(numpage) + "\n"); |
||
374 | BBox = "%%BoundingBox: " + IToStr(qRound(x)) + " " + IToStr(qRound(y)) + " " + IToStr(qRound(breite)) + " " + IToStr(qRound(hoehe)) + "\n"; |
||
375 | BBoxH = "%%HiResBoundingBox: " + ToStr(x) + " " + ToStr(y) + " " + ToStr(breite) + " " + ToStr(hoehe) + "\n"; |
||
8447 | fschmid | 376 | // if (!Art) |
377 | // { |
||
3136 | fschmid | 378 | PutDoc(BBox); |
379 | PutDoc(BBoxH); |
||
8447 | fschmid | 380 | // } |
6748 | fschmid | 381 | if (!FNamen.isEmpty()) |
382 | PutDoc("%%DocumentCustomColors: "+FNamen); |
||
383 | if (!Farben.isEmpty()) |
||
384 | PutDoc("%%CMYKCustomColor: "+Farben); |
||
3136 | fschmid | 385 | PutDoc("%%LanguageLevel: 3\n"); |
386 | PutDoc("%%EndComments\n"); |
||
387 | PutDoc(Prolog); |
||
388 | PutDoc("%%BeginSetup\n"); |
||
389 | PutDoc("/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse\n"); |
||
390 | if (!FontDesc.isEmpty()) |
||
391 | PutDoc(FontDesc); |
||
392 | if ((!colorDesc.isEmpty()) && (!sep)) |
||
393 | PutDoc(colorDesc); |
||
394 | PutDoc("Scribusdict begin\n"); |
||
395 | PutDoc(Fonts); |
||
396 | if (GraySc) |
||
397 | PutDoc(GrayCalc); |
||
5308 | fschmid | 398 | if (over) |
5316 | fschmid | 399 | { |
5308 | fschmid | 400 | PutDoc("true setoverprint\n"); |
5316 | fschmid | 401 | PutDoc("true setoverprintmode\n"); |
402 | } |
||
6400 | fschmid | 403 | QStringList patterns = m_Doc->getUsedPatterns(); |
404 | for (uint c = 0; c < patterns.count(); ++c) |
||
6388 | fschmid | 405 | { |
6400 | fschmid | 406 | ScPattern pa = m_Doc->docPatterns[patterns[c]]; |
6388 | fschmid | 407 | for (uint em = 0; em < pa.items.count(); ++em) |
408 | { |
||
409 | PageItem* item = pa.items.at(em); |
||
410 | if ((item->asImageFrame()) && (item->PicAvail) && (!item->Pfile.isEmpty()) && (item->printEnabled()) && (!sep) && (farb)) |
||
411 | PS_ImageData(item, item->Pfile, item->itemName(), item->IProfile, item->UseEmbedded, ic); |
||
412 | } |
||
6400 | fschmid | 413 | PutDoc("/Pattern"+patterns[c]+" 8 dict def\n"); |
414 | PutDoc("Pattern"+patterns[c]+" begin\n"); |
||
6388 | fschmid | 415 | PutDoc("/PatternType 1 def\n"); |
416 | PutDoc("/PaintType 1 def\n"); |
||
6391 | fschmid | 417 | PutDoc("/TilingType 1 def\n"); |
9112 | fschmid | 418 | PutDoc("/BBox [ 0 0 "+ToStr(pa.width)+" "+ToStr(pa.height)+"] def\n"); |
6388 | fschmid | 419 | PutDoc("/XStep "+ToStr(pa.width)+" def\n"); |
420 | PutDoc("/YStep "+ToStr(pa.height)+" def\n"); |
||
421 | PutDoc("/PaintProc {\n"); |
||
422 | QIODevice *spStream = spoolStream.device(); |
||
423 | QByteArray buf; |
||
424 | QBuffer b(buf); |
||
425 | b.open( IO_WriteOnly ); |
||
426 | spoolStream.setDevice(&b); |
||
6501 | fschmid | 427 | QPtrStack<PageItem> groupStack; |
6388 | fschmid | 428 | for (uint em = 0; em < pa.items.count(); ++em) |
429 | { |
||
430 | PageItem* item = pa.items.at(em); |
||
6501 | fschmid | 431 | if (item->isGroupControl) |
432 | { |
||
433 | PS_save(); |
||
434 | FPointArray cl = item->PoLine.copy(); |
||
435 | QWMatrix mm; |
||
9112 | fschmid | 436 | mm.translate(item->gXpos, item->gYpos - pa.height); |
7981 | fschmid | 437 | mm.rotate(item->rotation()); |
6501 | fschmid | 438 | cl.map( mm ); |
439 | SetClipPath(&cl); |
||
440 | PS_closepath(); |
||
441 | PS_clip(true); |
||
442 | groupStack.push(item->groupsLastItem); |
||
443 | continue; |
||
444 | } |
||
6388 | fschmid | 445 | PS_save(); |
9112 | fschmid | 446 | PS_translate(item->gXpos, pa.height - item->gYpos); |
6388 | fschmid | 447 | ProcessItem(m_Doc, m_Doc->Pages->at(0), item, 0, sep, farb, ic, gcr, false, true, true); |
448 | PS_restore(); |
||
6501 | fschmid | 449 | if (groupStack.count() != 0) |
450 | { |
||
451 | while (item == groupStack.top()) |
||
452 | { |
||
453 | PS_restore(); |
||
454 | groupStack.pop(); |
||
455 | } |
||
456 | } |
||
6388 | fschmid | 457 | } |
458 | spoolStream.setDevice(spStream); |
||
459 | PutDoc(buf); |
||
460 | PutDoc("} def\n"); |
||
461 | PutDoc("end\n"); |
||
462 | } |
||
3136 | fschmid | 463 | PutDoc("%%EndSetup\n"); |
464 | Prolog = ""; |
||
465 | FontDesc = ""; |
||
466 | } |
||
467 | |||
468 | QString PSLib::PSEncode(QString in) |
||
469 | { |
||
3622 | avox | 470 | static QRegExp badchars("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"); |
3136 | fschmid | 471 | QString tmp = ""; |
3622 | avox | 472 | tmp = in.simplifyWhiteSpace().replace( badchars, "_" ); |
3136 | fschmid | 473 | return tmp; |
474 | } |
||
475 | |||
476 | void PSLib::PS_TemplateStart(QString Name) |
||
477 | { |
||
478 | PutDoc("/"+PSEncode(Name)+"\n{\n"); |
||
479 | } |
||
480 | |||
481 | void PSLib::PS_UseTemplate(QString Name) |
||
482 | { |
||
483 | PutDoc(PSEncode(Name)+"\n"); |
||
484 | } |
||
485 | |||
486 | void PSLib::PS_TemplateEnd() |
||
487 | { |
||
488 | PutDoc("} bind def\n"); |
||
489 | } |
||
490 | |||
7316 | jghali | 491 | void PSLib::PS_begin_page(Page* pg, MarginStruct* Ma, bool Clipping) |
3136 | fschmid | 492 | { |
6954 | fschmid | 493 | double bleedRight = 0.0; |
494 | double bleedLeft = 0.0; |
||
495 | double markOffs = 0.0; |
||
496 | if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks)) |
||
497 | markOffs = 20.0 + Options.markOffset; |
||
7251 | fschmid | 498 | if (m_Doc->pageSets[m_Doc->currentPageLayout].Columns == 1) |
3136 | fschmid | 499 | { |
7225 | cbradney | 500 | bleedRight = Options.bleeds.Right; |
501 | bleedLeft = Options.bleeds.Left; |
||
3136 | fschmid | 502 | } |
6954 | fschmid | 503 | else |
504 | { |
||
7251 | fschmid | 505 | if (m_Doc->locationOfPage(pg->pageNr()) == LeftPage) |
506 | { |
||
507 | bleedRight = Options.bleeds.Right; |
||
508 | bleedLeft = Options.bleeds.Left; |
||
509 | } |
||
510 | else if (m_Doc->locationOfPage(pg->pageNr()) == RightPage) |
||
511 | { |
||
512 | bleedRight = Options.bleeds.Left; |
||
513 | bleedLeft = Options.bleeds.Right; |
||
514 | } |
||
515 | else |
||
516 | { |
||
517 | bleedRight = Options.bleeds.Left; |
||
518 | bleedLeft = Options.bleeds.Left; |
||
519 | } |
||
6954 | fschmid | 520 | } |
521 | double maxBoxX = pg->width()+bleedLeft+bleedRight+markOffs*2.0; |
||
7225 | cbradney | 522 | double maxBoxY = pg->height()+Options.bleeds.Bottom+Options.bleeds.Top+markOffs*2.0; |
3136 | fschmid | 523 | Seiten++; |
6748 | fschmid | 524 | PutSeite("%%Page: " + IToStr(Seiten) + " " + IToStr(Seiten) + "\n"); |
525 | PutSeite("%%PageOrientation: "); |
||
526 | // when creating EPS files determine the orientation from the bounding box |
||
527 | if (!Art) |
||
528 | { |
||
529 | if ((pg->width() - Ma->Left - Ma->Right) <= (pg->height() - Ma->Bottom - Ma->Top)) |
||
530 | PutSeite("Portrait\n"); |
||
531 | else |
||
532 | PutSeite("Landscape\n"); |
||
533 | } |
||
534 | else |
||
535 | { |
||
536 | if (pg->PageOri == 0) |
||
537 | PutSeite("Portrait\n"); |
||
538 | else |
||
539 | PutSeite("Landscape\n"); |
||
540 | } |
||
9027 | fschmid | 541 | PutSeite("%%PageBoundingBox: 0 0 "+IToStr(qRound(maxBoxX))+" "+IToStr(qRound(maxBoxY))+"\n"); |
7225 | cbradney | 542 | PutSeite("%%PageCropBox: "+ToStr(bleedLeft+markOffs)+" "+ToStr(Options.bleeds.Bottom+markOffs)+" "+ToStr(maxBoxX-bleedRight-markOffs*2.0)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs*2.0)+"\n"); |
6748 | fschmid | 543 | PutSeite("save\n"); |
3136 | fschmid | 544 | if (Clipping) |
545 | PutSeite(PDev); |
||
546 | PutSeite("/DeviceCMYK setcolorspace\n"); |
||
6954 | fschmid | 547 | if ((Art) && (Options.setDevParam)) |
548 | { |
||
549 | PutSeite("<< /PageSize [ "+ToStr(maxBoxX)+" "+ToStr(maxBoxY)+" ]\n"); |
||
550 | PutSeite(">> setpagedevice\n"); |
||
551 | } |
||
7225 | cbradney | 552 | PutSeite(ToStr(bleedLeft+markOffs)+" "+ToStr(Options.bleeds.Bottom+markOffs)+" tr\n"); |
6954 | fschmid | 553 | ActPage = pg; |
554 | if (Clipping) |
||
555 | { |
||
556 | PDev = ToStr(Ma->Left) + " " + ToStr(Ma->Bottom) + " m\n"; |
||
557 | PDev += ToStr(pg->width() - Ma->Right) + " " + ToStr(Ma->Bottom) + " li\n"; |
||
558 | PDev += ToStr(pg->width() - Ma->Right) + " " + ToStr(pg->height() - Ma->Top) + " li\n"; |
||
559 | PDev += ToStr(Ma->Left) + " " + ToStr(pg->height() - Ma->Top) + " li cl clip newpath\n"; |
||
560 | } |
||
3136 | fschmid | 561 | } |
562 | |||
563 | void PSLib::PS_end_page() |
||
564 | { |
||
6954 | fschmid | 565 | PutSeite("%%PageTrailer\nrestore\n"); |
566 | double markOffs = 0.0; |
||
567 | if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks)) |
||
568 | markOffs = 20.0 + Options.markOffset; |
||
569 | double bleedRight; |
||
570 | double bleedLeft; |
||
7251 | fschmid | 571 | if (m_Doc->pageSets[m_Doc->currentPageLayout].Columns == 1) |
6954 | fschmid | 572 | { |
7225 | cbradney | 573 | bleedRight = Options.bleeds.Right; |
574 | bleedLeft = Options.bleeds.Left; |
||
6954 | fschmid | 575 | } |
576 | else |
||
577 | { |
||
7251 | fschmid | 578 | if (m_Doc->locationOfPage(ActPage->pageNr()) == LeftPage) |
579 | { |
||
580 | bleedRight = Options.bleeds.Right; |
||
581 | bleedLeft = Options.bleeds.Left; |
||
582 | } |
||
583 | else if (m_Doc->locationOfPage(ActPage->pageNr()) == RightPage) |
||
584 | { |
||
585 | bleedRight = Options.bleeds.Left; |
||
586 | bleedLeft = Options.bleeds.Right; |
||
587 | } |
||
588 | else |
||
589 | { |
||
590 | bleedRight = Options.bleeds.Left; |
||
591 | bleedLeft = Options.bleeds.Left; |
||
592 | } |
||
6954 | fschmid | 593 | } |
594 | double maxBoxX = ActPage->width()+bleedLeft+bleedRight+markOffs*2.0; |
||
7225 | cbradney | 595 | double maxBoxY = ActPage->height()+Options.bleeds.Bottom+Options.bleeds.Top+markOffs*2.0; |
6954 | fschmid | 596 | if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks)) |
597 | { |
||
598 | PutSeite("gs\n"); |
||
599 | PS_setlinewidth(0.5); |
||
600 | PutSeite("[] 0 setdash\n"); |
||
601 | PutSeite("0 setlinecap\n"); |
||
602 | PutSeite("0 setlinejoin\n"); |
||
603 | PutSeite("1 rb\n"); |
||
604 | if (Options.cropMarks) |
||
605 | { |
||
606 | // Bottom Left |
||
7225 | cbradney | 607 | PutSeite("0 "+ToStr(markOffs+Options.bleeds.Bottom)+" m\n"); |
608 | PutSeite(ToStr(20.0)+" "+ToStr(markOffs+Options.bleeds.Bottom)+" li\n"); |
||
6954 | fschmid | 609 | PutSeite("st\n"); |
610 | PutSeite(ToStr(markOffs+bleedLeft)+" 0 m\n"); |
||
611 | PutSeite(ToStr(markOffs+bleedLeft)+" 20 li\n"); |
||
612 | PutSeite("st\n"); |
||
613 | // Top Left |
||
7225 | cbradney | 614 | PutSeite("0 "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" m\n"); |
615 | PutSeite(ToStr(20.0)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" li\n"); |
||
6954 | fschmid | 616 | PutSeite("st\n"); |
617 | PutSeite(ToStr(markOffs+bleedLeft)+" "+ToStr(maxBoxY)+" m\n"); |
||
618 | PutSeite(ToStr(markOffs+bleedLeft)+" "+ToStr(maxBoxY-20.0)+" li\n"); |
||
619 | PutSeite("st\n"); |
||
620 | // Bottom Right |
||
7225 | cbradney | 621 | PutSeite(ToStr(maxBoxX)+" "+ToStr(markOffs+Options.bleeds.Bottom)+" m\n"); |
622 | PutSeite(ToStr(maxBoxX-20.0)+" "+ToStr(markOffs+Options.bleeds.Bottom)+" li\n"); |
||
6954 | fschmid | 623 | PutSeite("st\n"); |
624 | PutSeite(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(0.0)+" m\n"); |
||
625 | PutSeite(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(20.0)+" li\n"); |
||
626 | PutSeite("st\n"); |
||
627 | // Top Right |
||
7225 | cbradney | 628 | PutSeite(ToStr(maxBoxX)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" m\n"); |
629 | PutSeite(ToStr(maxBoxX-20.0)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" li\n"); |
||
6954 | fschmid | 630 | PutSeite("st\n"); |
631 | PutSeite(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(maxBoxY)+" m\n"); |
||
632 | PutSeite(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(maxBoxY-20.0)+" li\n"); |
||
633 | PutSeite("st\n"); |
||
634 | } |
||
635 | if (Options.bleedMarks) |
||
636 | { |
||
8903 | fschmid | 637 | PutSeite("gs\n"); |
638 | PutSeite("[3 1 1 1] 0 setdash\n"); |
||
6954 | fschmid | 639 | // Bottom Left |
640 | PutSeite("0 "+ToStr(markOffs)+" m\n"); |
||
641 | PutSeite(ToStr(20.0)+" "+ToStr(markOffs)+" li\n"); |
||
642 | PutSeite("st\n"); |
||
643 | PutSeite(ToStr(markOffs)+" 0 m\n"); |
||
644 | PutSeite(ToStr(markOffs)+" 20 l\n"); |
||
645 | PutSeite("st\n"); |
||
646 | // Top Left |
||
647 | PutSeite("0 "+ToStr(maxBoxY-markOffs)+" m\n"); |
||
648 | PutSeite(ToStr(20.0)+" "+ToStr(maxBoxY-markOffs)+" li\n"); |
||
649 | PutSeite("st\n"); |
||
650 | PutSeite(ToStr(markOffs)+" "+ToStr(maxBoxY)+" m\n"); |
||
651 | PutSeite(ToStr(markOffs)+" "+ToStr(maxBoxY-20.0)+" li\n"); |
||
652 | PutSeite("st\n"); |
||
653 | // Bottom Right |
||
654 | PutSeite(ToStr(maxBoxX)+" "+ToStr(markOffs)+" m\n"); |
||
655 | PutSeite(ToStr(maxBoxX-20.0)+" "+ToStr(markOffs)+" li\n"); |
||
656 | PutSeite("st\n"); |
||
657 | PutSeite(ToStr(maxBoxX-markOffs)+" "+ToStr(0.0)+" m\n"); |
||
658 | PutSeite(ToStr(maxBoxX-markOffs)+" "+ToStr(20.0)+" li\n"); |
||
659 | PutSeite("st\n"); |
||
660 | // Top Right |
||
661 | PutSeite(ToStr(maxBoxX)+" "+ToStr(maxBoxY-markOffs)+" m\n"); |
||
662 | PutSeite(ToStr(maxBoxX-20.0)+" "+ToStr(maxBoxY-markOffs)+" li\n"); |
||
663 | PutSeite("st\n"); |
||
664 | PutSeite(ToStr(maxBoxX-markOffs)+" "+ToStr(maxBoxY)+" m\n"); |
||
665 | PutSeite(ToStr(maxBoxX-markOffs)+" "+ToStr(maxBoxY-20.0)+" li\n"); |
||
666 | PutSeite("st\n"); |
||
8903 | fschmid | 667 | PutSeite("gr\n"); |
6954 | fschmid | 668 | } |
669 | if (Options.registrationMarks) |
||
670 | { |
||
671 | 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"; |
||
672 | 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"; |
||
673 | 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"; |
||
674 | PutSeite("gs\n"); |
||
675 | PutSeite(ToStr(maxBoxX / 2.0 - 7.0)+" 3 tr\n"); |
||
676 | PutSeite(regCross); |
||
677 | PutSeite("gr\n"); |
||
678 | PutSeite("gs\n"); |
||
679 | PutSeite("3 "+ToStr(maxBoxY / 2.0 + 7.0)+" tr\n"); |
||
680 | PutSeite(regCross); |
||
681 | PutSeite("gr\n"); |
||
682 | PutSeite("gs\n"); |
||
683 | PutSeite(ToStr(maxBoxX / 2.0 - 7.0)+" "+ToStr(maxBoxY - 17.0)+" tr\n"); |
||
684 | PutSeite(regCross); |
||
685 | PutSeite("gr\n"); |
||
686 | PutSeite("gs\n"); |
||
687 | PutSeite(ToStr(maxBoxX - 17.0)+" "+ToStr(maxBoxY / 2.0 + 7.0)+" tr\n"); |
||
688 | PutSeite(regCross); |
||
689 | PutSeite("gr\n"); |
||
690 | } |
||
691 | if (Options.colorMarks) |
||
692 | { |
||
693 | double startX = markOffs+bleedLeft+6.0; |
||
694 | double startY = maxBoxY - 18.0; |
||
695 | PutSeite("0 0 0 1 cmyk\n"); |
||
696 | double col = 1.0; |
||
697 | for (int bl = 0; bl < 11; bl++) |
||
698 | { |
||
699 | PutSeite("0 0 0 "+ToStr(col)+" cmyk\n"); |
||
700 | PutSeite(ToStr(startX+bl*14.0)+" "+ToStr(startY)+" 14 14 rectfill\n"); |
||
701 | PutSeite("0 0 0 1 cmyk\n"); |
||
702 | PutSeite(ToStr(startX+bl*14.0)+" "+ToStr(startY)+" 14 14 rectstroke\n"); |
||
703 | col -= 0.1; |
||
704 | } |
||
705 | startX = maxBoxX-bleedRight-markOffs-20.0; |
||
706 | PutSeite("0 0 0 0.5 cmyk\n"); |
||
707 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n"); |
||
708 | PutSeite("0 0 0 1 cmyk\n"); |
||
709 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n"); |
||
710 | startX -= 14.0; |
||
711 | PutSeite("0 0 0.5 0 cmyk\n"); |
||
712 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n"); |
||
713 | PutSeite("0 0 0 1 cmyk\n"); |
||
714 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n"); |
||
715 | startX -= 14.0; |
||
716 | PutSeite("0 0.5 0 0 cmyk\n"); |
||
717 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n"); |
||
718 | PutSeite("0 0 0 1 cmyk\n"); |
||
719 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n"); |
||
720 | startX -= 14.0; |
||
721 | PutSeite("0.5 0 0 0 cmyk\n"); |
||
722 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n"); |
||
723 | PutSeite("0 0 0 1 cmyk\n"); |
||
724 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n"); |
||
725 | startX -= 14.0; |
||
726 | PutSeite("1 1 0 0 cmyk\n"); |
||
727 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n"); |
||
728 | PutSeite("0 0 0 1 cmyk\n"); |
||
729 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n"); |
||
730 | startX -= 14.0; |
||
731 | PutSeite("1 0 1 0 cmyk\n"); |
||
732 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n"); |
||
733 | PutSeite("0 0 0 1 cmyk\n"); |
||
734 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n"); |
||
735 | startX -= 14.0; |
||
736 | PutSeite("0 1 1 0 cmyk\n"); |
||
737 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n"); |
||
738 | PutSeite("0 0 0 1 cmyk\n"); |
||
739 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n"); |
||
740 | startX -= 14.0; |
||
741 | PutSeite("0 0 0 1 cmyk\n"); |
||
742 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n"); |
||
743 | PutSeite("0 0 0 1 cmyk\n"); |
||
744 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n"); |
||
745 | startX -= 14.0; |
||
746 | PutSeite("0 0 1 0 cmyk\n"); |
||
747 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n"); |
||
748 | PutSeite("0 0 0 1 cmyk\n"); |
||
749 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n"); |
||
750 | startX -= 14.0; |
||
751 | PutSeite("0 1 0 0 cmyk\n"); |
||
752 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n"); |
||
753 | PutSeite("0 0 0 1 cmyk\n"); |
||
754 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n"); |
||
755 | startX -= 14.0; |
||
756 | PutSeite("1 0 0 0 cmyk\n"); |
||
757 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n"); |
||
758 | PutSeite("0 0 0 1 cmyk\n"); |
||
759 | PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n"); |
||
760 | } |
||
761 | PutSeite("gr\n"); |
||
762 | } |
||
763 | PutSeite("sp\n"); |
||
3136 | fschmid | 764 | } |
765 | |||
766 | void PSLib::PS_curve(double x1, double y1, double x2, double y2, double x3, double y3) |
||
767 | { |
||
768 | PutSeite(ToStr(x1) + " " + ToStr(y1) + " " + ToStr(x2) + " " + ToStr(y2) + " " + ToStr(x3) + " " + ToStr(y3) + " curveto\n"); |
||
769 | } |
||
770 | |||
771 | void PSLib::PS_moveto(double x, double y) |
||
772 | { |
||
773 | PutSeite(ToStr(x) + " " + ToStr(y) + " m\n"); |
||
774 | } |
||
775 | |||
776 | void PSLib::PS_lineto(double x, double y) |
||
777 | { |
||
778 | PutSeite(ToStr(x) + " " + ToStr(y) + " li\n"); |
||
779 | } |
||
780 | |||
781 | void PSLib::PS_closepath() |
||
782 | { |
||
783 | PutSeite("cl\n"); |
||
784 | } |
||
785 | |||
786 | void PSLib::PS_translate(double x, double y) |
||
787 | { |
||
788 | PutSeite(ToStr(x) + " " + ToStr(y) + " tr\n"); |
||
789 | } |
||
790 | |||
791 | void PSLib::PS_scale(double x, double y) |
||
792 | { |
||
793 | PutSeite(ToStr(x) + " " + ToStr(y) + " sc\n"); |
||
794 | } |
||
795 | |||
796 | void PSLib::PS_rotate(double x) |
||
797 | { |
||
798 | PutSeite(ToStr(x) + " ro\n"); |
||
799 | } |
||
800 | |||
801 | void PSLib::PS_clip(bool mu) |
||
802 | { |
||
803 | PutSeite( mu ? "eoclip newpath\n" : "clip newpath\n" ); |
||
804 | } |
||
805 | |||
806 | void PSLib::PS_save() |
||
807 | { |
||
808 | PutSeite("gs\n"); |
||
809 | } |
||
810 | |||
811 | void PSLib::PS_restore() |
||
812 | { |
||
813 | PutSeite("gr\n"); |
||
814 | } |
||
815 | |||
816 | void PSLib::PS_setcmykcolor_fill(double c, double m, double y, double k) |
||
817 | { |
||
818 | FillColor = ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k); |
||
819 | } |
||
820 | |||
821 | void PSLib::PS_setcmykcolor_dummy() |
||
822 | { |
||
823 | PutSeite("0 0 0 0 cmyk\n"); |
||
824 | } |
||
825 | |||
826 | void PSLib::PS_setcmykcolor_stroke(double c, double m, double y, double k) |
||
827 | { |
||
828 | StrokeColor = ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k); |
||
829 | } |
||
830 | |||
831 | void PSLib::PS_setlinewidth(double w) |
||
832 | { |
||
833 | PutSeite(ToStr(w) + " sw\n"); |
||
834 | LineW = w; |
||
835 | } |
||
836 | |||
837 | void PSLib::PS_setdash(Qt::PenStyle st, double offset, QValueList<double> dash) |
||
838 | { |
||
839 | QString Dt = ToStr(QMAX(2*LineW, 1)); |
||
840 | QString Da = ToStr(QMAX(6*LineW, 1)); |
||
841 | if (dash.count() != 0) |
||
842 | { |
||
843 | PutSeite("[ "); |
||
844 | QValueList<double>::iterator it; |
||
845 | for ( it = dash.begin(); it != dash.end(); ++it ) |
||
846 | { |
||
847 | PutSeite(IToStr(static_cast<int>(*it))+" "); |
||
848 | } |
||
849 | PutSeite("] "+IToStr(static_cast<int>(offset))+" setdash\n"); |
||
850 | } |
||
851 | else |
||
852 | { |
||
853 | switch (st) |
||
854 | { |
||
855 | case Qt::SolidLine: |
||
856 | PutSeite("[] 0 setdash\n"); |
||
857 | break; |
||
858 | case Qt::DashLine: |
||
859 | PutSeite("["+Da+" "+Dt+"] 0 setdash\n"); |
||
860 | break; |
||
861 | case Qt::DotLine: |
||
862 | PutSeite("["+Dt+"] 0 setdash\n"); |
||
863 | break; |
||
864 | case Qt::DashDotLine: |
||
865 | PutSeite("["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 setdash\n"); |
||
866 | break; |
||
867 | case Qt::DashDotDotLine: |
||
868 | PutSeite("["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 setdash\n"); |
||
869 | break; |
||
870 | default: |
||
871 | PutSeite("[] 0 setdash\n"); |
||
872 | break; |
||
873 | } |
||
874 | } |
||
875 | } |
||
6954 | fschmid | 876 | |
3136 | fschmid | 877 | void PSLib::PS_setcapjoin(Qt::PenCapStyle ca, Qt::PenJoinStyle jo) |
878 | { |
||
879 | switch (ca) |
||
880 | { |
||
881 | case Qt::FlatCap: |
||
882 | PutSeite("0 setlinecap\n"); |
||
883 | break; |
||
884 | case Qt::SquareCap: |
||
885 | PutSeite("2 setlinecap\n"); |
||
886 | break; |
||
887 | case Qt::RoundCap: |
||
888 | PutSeite("1 setlinecap\n"); |
||
889 | break; |
||
890 | default: |
||
891 | PutSeite("0 setlinecap\n"); |
||
892 | break; |
||
893 | } |
||
894 | switch (jo) |
||
895 | { |
||
896 | case Qt::MiterJoin: |
||
897 | PutSeite("0 setlinejoin\n"); |
||
898 | break; |
||
899 | case Qt::BevelJoin: |
||
900 | PutSeite("2 setlinejoin\n"); |
||
901 | break; |
||
902 | case Qt::RoundJoin: |
||
903 | PutSeite("1 setlinejoin\n"); |
||
904 | break; |
||
905 | default: |
||
906 | PutSeite("0 setlinejoin\n"); |
||
907 | break; |
||
908 | } |
||
909 | } |
||
910 | |||
911 | void PSLib::PS_selectfont(QString f, double s) |
||
912 | { |
||
913 | PutSeite(UsedFonts[f] + " " + ToStr(s) + " se\n"); |
||
914 | } |
||
915 | |||
916 | void PSLib::PS_fill() |
||
917 | { |
||
4477 | fschmid | 918 | if (fillRule) |
919 | PutSeite(FillColor + " cmyk eofill\n"); |
||
920 | else |
||
921 | PutSeite(FillColor + " cmyk fill\n"); |
||
3136 | fschmid | 922 | } |
923 | |||
924 | void PSLib::PS_fillspot(QString color, int shade) |
||
925 | { |
||
4477 | fschmid | 926 | if (fillRule) |
927 | PutSeite(ToStr(shade / 100.0)+" "+spotMap[color]+" eofill\n"); |
||
928 | else |
||
929 | PutSeite(ToStr(shade / 100.0)+" "+spotMap[color]+" fill\n"); |
||
3136 | fschmid | 930 | } |
931 | |||
932 | void PSLib::PS_strokespot(QString color, int shade) |
||
933 | { |
||
934 | PutSeite(ToStr(shade / 100.0)+" "+spotMap[color]+" st\n"); |
||
935 | } |
||
936 | |||
937 | void PSLib::PS_stroke() |
||
938 | { |
||
939 | PutSeite(StrokeColor + " cmyk st\n"); |
||
940 | } |
||
941 | |||
942 | void PSLib::PS_fill_stroke() |
||
943 | { |
||
944 | PS_save(); |
||
945 | PS_fill(); |
||
946 | PS_restore(); |
||
947 | PS_stroke(); |
||
948 | } |
||
949 | |||
950 | void PSLib::PS_newpath() |
||
951 | { |
||
952 | PutSeite("newpath\n"); |
||
953 | } |
||
954 | |||
6485 | fschmid | 955 | void PSLib::PS_MultiRadGradient(double w, double h, double x, double y, QValueList<double> Stops, QStringList Colors, QStringList colorNames, QValueList<int> colorShades) |
3136 | fschmid | 956 | { |
957 | bool first = true; |
||
6485 | fschmid | 958 | bool oneSpot1 = false; |
959 | bool oneSpot2 = false; |
||
960 | bool twoSpot = false; |
||
9618 | jghali | 961 | CMYKColor cmykValues; |
6485 | fschmid | 962 | int cc, mc, yc, kc; |
3136 | fschmid | 963 | PutSeite( "clipsave\n" ); |
964 | PutSeite("eoclip\n"); |
||
965 | for (uint c = 0; c < Colors.count()-1; ++c) |
||
966 | { |
||
6485 | fschmid | 967 | oneSpot1 = false; |
968 | oneSpot2 = false; |
||
969 | twoSpot = false; |
||
970 | QString spot1 = colorNames[c]; |
||
971 | QString spot2 = colorNames[c+1]; |
||
3136 | fschmid | 972 | PutSeite("<<\n"); |
973 | PutSeite("/ShadingType 3\n"); |
||
6485 | fschmid | 974 | if (DoSep) |
975 | PutSeite("/ColorSpace /DeviceGray\n"); |
||
976 | else |
||
977 | { |
||
978 | if (spotMap.contains(colorNames[c])) |
||
979 | oneSpot1 = true; |
||
980 | else if (spotMap.contains(colorNames[c+1])) |
||
981 | oneSpot2 = true; |
||
982 | if ((spotMap.contains(colorNames[c])) && (spotMap.contains(colorNames[c+1]))) |
||
983 | { |
||
984 | oneSpot1 = false; |
||
985 | oneSpot2 = false; |
||
986 | twoSpot = true; |
||
987 | } |
||
6691 | fschmid | 988 | if ((!oneSpot1) && (!oneSpot2) && (!twoSpot) || (!useSpotColors) || (GraySc)) |
989 | { |
||
990 | if (GraySc) |
||
991 | PutSeite("/ColorSpace /DeviceGray\n"); |
||
992 | else |
||
993 | PutSeite("/ColorSpace /DeviceCMYK\n"); |
||
994 | } |
||
6485 | fschmid | 995 | else |
996 | { |
||
997 | PutSeite("/ColorSpace [ /DeviceN ["); |
||
998 | if (oneSpot1) |
||
999 | { |
||
1000 | PutSeite(" /Cyan /Magenta /Yellow /Black ("+spot1+") ]\n"); |
||
9618 | jghali | 1001 | ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues); |
1002 | cmykValues.getValues(cc, mc, yc, kc); |
||
6485 | fschmid | 1003 | } |
1004 | else if (oneSpot2) |
||
1005 | { |
||
1006 | PutSeite(" /Cyan /Magenta /Yellow /Black ("+spot2+") ]\n"); |
||
9618 | jghali | 1007 | ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c+1]], m_Doc, cmykValues); |
1008 | cmykValues.getValues(cc, mc, yc, kc); |
||
6485 | fschmid | 1009 | } |
1010 | else if (twoSpot) |
||
1011 | { |
||
1012 | PutSeite(" ("+spot1+") ("+spot2+") ]\n"); |
||
1013 | } |
||
1014 | PutSeite("/DeviceCMYK\n"); |
||
1015 | PutSeite("{\n"); |
||
1016 | if (twoSpot) |
||
1017 | { |
||
9618 | jghali | 1018 | ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues); |
1019 | cmykValues.getValues(cc, mc, yc, kc); |
||
6485 | fschmid | 1020 | PutSeite("exch\n"); |
1021 | PutSeite("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul exch\n"); |
||
1022 | PutSeite("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul exch\n"); |
||
1023 | PutSeite("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul exch\n"); |
||
1024 | PutSeite("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul exch pop 5 -1 roll\n"); |
||
9618 | jghali | 1025 | ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c+1]], m_Doc, cmykValues); |
1026 | cmykValues.getValues(cc, mc, yc, kc); |
||
6485 | fschmid | 1027 | PutSeite("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 6 -1 roll add dup 1.0 gt {pop 1.0} if 5 1 roll\n"); |
1028 | PutSeite("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 5 -1 roll add dup 1.0 gt {pop 1.0} if 4 1 roll\n"); |
||
1029 | PutSeite("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 4 -1 roll add dup 1.0 gt {pop 1.0} if 3 1 roll\n"); |
||
1030 | PutSeite("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 3 -1 roll add dup 1.0 gt {pop 1.0} if 2 1 roll pop\n"); |
||
1031 | } |
||
1032 | else |
||
1033 | { |
||
1034 | PutSeite("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 6 -1 roll add dup 1.0 gt {pop 1.0} if 5 1 roll\n"); |
||
1035 | PutSeite("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 5 -1 roll add dup 1.0 gt {pop 1.0} if 4 1 roll\n"); |
||
1036 | PutSeite("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 4 -1 roll add dup 1.0 gt {pop 1.0} if 3 1 roll\n"); |
||
1037 | PutSeite("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 3 -1 roll add dup 1.0 gt {pop 1.0} if 2 1 roll pop\n"); |
||
1038 | } |
||
1039 | PutSeite("} ]\n"); |
||
1040 | } |
||
1041 | } |
||
3136 | fschmid | 1042 | PutSeite("/BBox [0 "+ToStr(h)+" "+ToStr(w)+" 0]\n"); |
1043 | if (Colors.count() == 2) |
||
1044 | PutDoc("/Extend [true true]\n"); |
||
1045 | else |
||
1046 | { |
||
1047 | if (first) |
||
1048 | PutSeite("/Extend [false true]\n"); |
||
1049 | else |
||
1050 | { |
||
1051 | if (c == Colors.count()-2) |
||
1052 | PutSeite("/Extend [true false]\n"); |
||
1053 | else |
||
1054 | PutSeite("/Extend [false false]\n"); |
||
1055 | } |
||
1056 | } |
||
1057 | PutSeite("/Coords ["+ToStr(x)+" "+ToStr(y)+" "+ToStr((*Stops.at(c+1)))+" "+ToStr(x)+" "+ToStr(y)+" "+ToStr((*Stops.at(c)))+"]\n"); |
||
1058 | PutSeite("/Function\n"); |
||
1059 | PutSeite("<<\n"); |
||
1060 | PutSeite("/FunctionType 2\n"); |
||
1061 | PutSeite("/Domain [0 1]\n"); |
||
1062 | if (DoSep) |
||
1063 | { |
||
1064 | int pla = Plate - 1 < 0 ? 3 : Plate - 1; |
||
1065 | QStringList cols1 = QStringList::split(" ", Colors[c+1]); |
||
1066 | QStringList cols2 = QStringList::split(" ", Colors[c]); |
||
1067 | PutSeite("/C1 ["+ToStr(1-cols1[pla].toDouble())+"]\n"); |
||
1068 | PutSeite("/C0 ["+ToStr(1-cols2[pla].toDouble())+"]\n"); |
||
1069 | } |
||
1070 | else |
||
1071 | { |
||
6485 | fschmid | 1072 | if (useSpotColors) |
1073 | { |
||
1074 | if (oneSpot1) |
||
1075 | { |
||
1076 | PutSeite("/C1 [0 0 0 0 "+ToStr(colorShades[c] / 100.0)+"]\n"); |
||
1077 | PutSeite("/C0 ["+Colors[c+1]+" 0 ]\n"); |
||
1078 | } |
||
1079 | else if (oneSpot2) |
||
1080 | { |
||
1081 | PutSeite("/C1 ["+Colors[c]+" 0 ]\n"); |
||
1082 | PutSeite("/C0 [0 0 0 0 "+ToStr(colorShades[c+1] / 100.0)+"]\n"); |
||
1083 | } |
||
1084 | else if (twoSpot) |
||
1085 | { |
||
1086 | PutSeite("/C1 ["+ToStr(colorShades[c] / 100.0)+" 0]\n"); |
||
1087 | PutSeite("/C0 [0 "+ToStr(colorShades[c+1] / 100.0)+"]\n"); |
||
1088 | } |
||
1089 | else |
||
1090 | { |
||
1091 | PutSeite("/C1 ["+Colors[c]+"]\n"); |
||
1092 | PutSeite("/C0 ["+Colors[c+1]+"]\n"); |
||
1093 | } |
||
1094 | } |
||
1095 | else |
||
1096 | { |
||
1097 | PutSeite("/C1 ["+Colors[c]+"]\n"); |
||
1098 | PutSeite("/C0 ["+Colors[c+1]+"]\n"); |
||
1099 | } |
||
3136 | fschmid | 1100 | } |
1101 | PutSeite("/N 1\n"); |
||
1102 | PutSeite(">>\n"); |
||
1103 | PutSeite(">>\n"); |
||
1104 | PutSeite("shfill\n"); |
||
1105 | first = false; |
||
1106 | } |
||
1107 | PutSeite("cliprestore\n"); |
||
1108 | } |
||
1109 | |||
6485 | fschmid | 1110 | void PSLib::PS_MultiLinGradient(double w, double h, QValueList<double> Stops, QStringList Colors, QStringList colorNames, QValueList<int> colorShades) |
3136 | fschmid | 1111 | { |
1112 | bool first = true; |
||
6485 | fschmid | 1113 | bool oneSpot1 = false; |
1114 | bool oneSpot2 = false; |
||
1115 | bool twoSpot = false; |
||
1116 | int cc, mc, yc, kc; |
||
9618 | jghali | 1117 | CMYKColor cmykValues; |
3136 | fschmid | 1118 | PutSeite( "clipsave\n" ); |
1119 | PutSeite("eoclip\n"); |
||
1120 | for (uint c = 0; c < Colors.count()-1; ++c) |
||
1121 | { |
||
6485 | fschmid | 1122 | oneSpot1 = false; |
1123 | oneSpot2 = false; |
||
1124 | twoSpot = false; |
||
1125 | QRegExp badchars("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"); |
||
1126 | QString spot1 = colorNames[c]; |
||
1127 | QString spot2 = colorNames[c+1]; |
||
3136 | fschmid | 1128 | PutSeite("<<\n"); |
1129 | PutSeite("/ShadingType 2\n"); |
||
6485 | fschmid | 1130 | if (DoSep) |
1131 | PutSeite("/ColorSpace /DeviceGray\n"); |
||
1132 | else |
||
1133 | { |
||
1134 | if (spotMap.contains(colorNames[c])) |
||
1135 | oneSpot1 = true; |
||
1136 | else if (spotMap.contains(colorNames[c+1])) |
||
1137 | oneSpot2 = true; |
||
1138 | if ((spotMap.contains(colorNames[c])) && (spotMap.contains(colorNames[c+1]))) |
||
1139 | { |
||
1140 | oneSpot1 = false; |
||
1141 | oneSpot2 = false; |
||
1142 | twoSpot = true; |
||
1143 | } |
||
6691 | fschmid | 1144 | if ((!oneSpot1) && (!oneSpot2) && (!twoSpot) || (!useSpotColors) || (GraySc)) |
1145 | { |
||
1146 | if (GraySc) |
||
1147 | PutSeite("/ColorSpace /DeviceGray\n"); |
||
1148 | else |
||
1149 | PutSeite("/ColorSpace /DeviceCMYK\n"); |
||
1150 | } |
||
6485 | fschmid | 1151 | else |
1152 | { |
||
1153 | PutSeite("/ColorSpace [ /DeviceN ["); |
||
1154 | if (oneSpot1) |
||
1155 | { |
||
1156 | PutSeite(" /Cyan /Magenta /Yellow /Black ("+spot1+") ]\n"); |
||
9618 | jghali | 1157 | ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues); |
1158 | cmykValues.getValues(cc, mc, yc, kc); |
||
6485 | fschmid | 1159 | } |
1160 | else if (oneSpot2) |
||
1161 | { |
||
1162 | PutSeite(" /Cyan /Magenta /Yellow /Black ("+spot2+") ]\n"); |
||
9618 | jghali | 1163 | ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c+1]], m_Doc, cmykValues); |
1164 | cmykValues.getValues(cc, mc, yc, kc); |
||
6485 | fschmid | 1165 | } |
1166 | else if (twoSpot) |
||
1167 | { |
||
1168 | PutSeite(" ("+spot1+") ("+spot2+") ]\n"); |
||
1169 | } |
||
1170 | PutSeite("/DeviceCMYK\n"); |
||
1171 | PutSeite("{\n"); |
||
1172 | if (twoSpot) |
||
1173 | { |
||
9618 | jghali | 1174 | ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues); |
1175 | cmykValues.getValues(cc, mc, yc, kc); |
||
6485 | fschmid | 1176 | PutSeite("exch\n"); |
1177 | PutSeite("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul exch\n"); |
||
1178 | PutSeite("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul exch\n"); |
||
1179 | PutSeite("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul exch\n"); |
||
1180 | PutSeite("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul exch pop 5 -1 roll\n"); |
||
9618 | jghali | 1181 | ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c+1]], m_Doc, cmykValues); |
1182 | cmykValues.getValues(cc, mc, yc, kc); |
||
6485 | fschmid | 1183 | PutSeite("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 6 -1 roll add dup 1.0 gt {pop 1.0} if 5 1 roll\n"); |
1184 | PutSeite("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 5 -1 roll add dup 1.0 gt {pop 1.0} if 4 1 roll\n"); |
||
1185 | PutSeite("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 4 -1 roll add dup 1.0 gt {pop 1.0} if 3 1 roll\n"); |
||
1186 | PutSeite("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 3 -1 roll add dup 1.0 gt {pop 1.0} if 2 1 roll pop\n"); |
||
1187 | } |
||
1188 | else |
||
1189 | { |
||
1190 | PutSeite("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 6 -1 roll add dup 1.0 gt {pop 1.0} if 5 1 roll\n"); |
||
1191 | PutSeite("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 5 -1 roll add dup 1.0 gt {pop 1.0} if 4 1 roll\n"); |
||
1192 | PutSeite("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 4 -1 roll add dup 1.0 gt {pop 1.0} if 3 1 roll\n"); |
||
1193 | PutSeite("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 3 -1 roll add dup 1.0 gt {pop 1.0} if 2 1 roll pop\n"); |
||
1194 | } |
||
1195 | PutSeite("} ]\n"); |
||
1196 | } |
||
1197 | } |
||
3136 | fschmid | 1198 | PutSeite("/BBox [0 "+ToStr(h)+" "+ToStr(w)+" 0]\n"); |
1199 | if (Colors.count() == 2) |
||
1200 | PutDoc("/Extend [true true]\n"); |
||
1201 | else |
||
1202 | { |
||
1203 | if (first) |
||
1204 | PutSeite("/Extend [true false]\n"); |
||
1205 | else |
||
1206 | { |
||
1207 | if (c == Colors.count()-2) |
||
1208 | PutSeite("/Extend [false true]\n"); |
||
1209 | else |
||
1210 | PutSeite("/Extend [false false]\n"); |
||
1211 | } |
||
1212 | } |
||
1213 | first = false; |
||
1214 | PutSeite("/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"); |
||
1215 | PutSeite("/Function\n"); |
||
1216 | PutSeite("<<\n"); |
||
1217 | PutSeite("/FunctionType 2\n"); |
||
1218 | PutSeite("/Domain [0 1]\n"); |
||
1219 | if (DoSep) |
||
1220 | { |
||
1221 | int pla = Plate - 1 < 0 ? 3 : Plate - 1; |
||
1222 | QStringList cols1 = QStringList::split(" ", Colors[c]); |
||
1223 | QStringList cols2 = QStringList::split(" ", Colors[c+1]); |
||
1224 | PutSeite("/C1 ["+ToStr(1-cols1[pla].toDouble())+"]\n"); |
||
1225 | PutSeite("/C0 ["+ToStr(1-cols2[pla].toDouble())+"]\n"); |
||
1226 | } |
||
1227 | else |
||
1228 | { |
||
6485 | fschmid | 1229 | if (useSpotColors) |
1230 | { |
||
1231 | if (oneSpot1) |
||
1232 | { |
||
1233 | PutSeite("/C0 [0 0 0 0 "+ToStr(colorShades[c] / 100.0)+"]\n"); |
||
1234 | PutSeite("/C1 ["+Colors[c+1]+" 0 ]\n"); |
||
1235 | } |
||
1236 | else if (oneSpot2) |
||
1237 | { |
||
1238 | PutSeite("/C0 ["+Colors[c]+" 0 ]\n"); |
||
1239 | PutSeite("/C1 [0 0 0 0 "+ToStr(colorShades[c+1] / 100.0)+"]\n"); |
||
1240 | } |
||
1241 | else if (twoSpot) |
||
1242 | { |
||
1243 | PutSeite("/C0 ["+ToStr(colorShades[c] / 100.0)+" 0]\n"); |
||
1244 | PutSeite("/C1 [0 "+ToStr(colorShades[c+1] / 100.0)+"]\n"); |
||
1245 | } |
||
1246 | else |
||
1247 | { |
||
1248 | PutSeite("/C0 ["+Colors[c]+"]\n"); |
||
1249 | PutSeite("/C1 ["+Colors[c+1]+"]\n"); |
||
1250 | } |
||
1251 | } |
||
1252 | else |
||
1253 | { |
||
1254 | PutSeite("/C0 ["+Colors[c]+"]\n"); |
||
1255 | PutSeite("/C1 ["+Colors[c+1]+"]\n"); |
||
1256 | } |
||
3136 | fschmid | 1257 | } |
1258 | PutSeite("/N 1\n"); |
||
1259 | PutSeite(">>\n"); |
||
1260 | PutSeite(">>\n"); |
||
1261 | PutSeite("shfill\n"); |
||
1262 | } |
||
1263 | PutSeite("cliprestore\n"); |
||
1264 | } |
||
1265 | |||
6163 | avox | 1266 | void PSLib::PS_show_xyG(QString font, uint glyph, double x, double y, bool spot) |
3136 | fschmid | 1267 | { |
1268 | QString Name; |
||
6163 | avox | 1269 | Name = GlyphsOfFont[font].contains(glyph) ? GlyphsOfFont[font][glyph].second : QString(".notdef"); |
3555 | fschmid | 1270 | if (spot) |
1271 | PutSeite("/"+Name+" "+ToStr(x)+" "+ToStr(y)+" shgsp\n"); |
||
1272 | else |
||
1273 | PutSeite("/"+Name+" "+ToStr(x)+" "+ToStr(y)+" "+StrokeColor+" shg\n"); |
||
3136 | fschmid | 1274 | } |
1275 | |||
1276 | void PSLib::PS_show(double x, double y) |
||
1277 | { |
||
1278 | PS_moveto(x, y); |
||
1279 | PutSeite("/hyphen glyphshow\n"); |
||
1280 | } |
||
1281 | |||
1282 | void PSLib::PS_showSub(uint chr, QString font, double size, bool stroke) |
||
1283 | { |
||
1284 | PutSeite(" (G"+IToStr(chr)+") "+font+" "+ToStr(size / 10.0)+" "); |
||
1285 | PutSeite(stroke ? "shgs\n" : "shgf\n"); |
||
1286 | } |
||
1287 | |||
1288 | void PSLib::PS_ImageData(PageItem *c, QString fn, QString Name, QString Prof, bool UseEmbedded, bool UseProf) |
||
1289 | { |
||
1290 | bool dummy; |
||
5234 | fschmid | 1291 | QCString tmp; |
3136 | fschmid | 1292 | QFileInfo fi = QFileInfo(fn); |
1293 | QString ext = fi.extension(false).lower(); |
||
6808 | fschmid | 1294 | if (ext.isEmpty()) |
1295 | ext = getImageType(fn); |
||
7420 | fschmid | 1296 | if (((ext == "eps") || (ext == "epsi")) && (c->pixm.imgInfo.type != 7)) |
3136 | fschmid | 1297 | { |
5234 | fschmid | 1298 | if (loadRawText(fn, tmp)) |
3136 | fschmid | 1299 | { |
1300 | PutSeite("currentfile 1 (%ENDEPSDATA) /SubFileDecode filter /ReusableStreamDecode filter\n"); |
||
1301 | PutSeite("%%BeginDocument: " + fi.fileName() + "\n"); |
||
5234 | fschmid | 1302 | if (getDouble(QString(tmp.mid(0, 4)), true) == 0xC5D0D3C6) |
3136 | fschmid | 1303 | { |
5234 | fschmid | 1304 | char* data = tmp.data(); |
1305 | uint startPos = getDouble(QString(tmp.mid(4, 4)), false); |
||
1306 | uint length = getDouble(QString(tmp.mid(8, 4)), false); |
||
1307 | PutSeite(data+startPos, length, false); |
||
3136 | fschmid | 1308 | } |
1309 | else |
||
5234 | fschmid | 1310 | PutSeite(tmp, false); |
1311 | PutSeite("\n%ENDEPSDATA\n"); |
||
3136 | fschmid | 1312 | PutSeite("%%EndDocument\n"); |
1313 | PutSeite("/"+PSEncode(Name)+"Bild exch def\n"); |
||
1314 | } |
||
1315 | return; |
||
1316 | } |
||
1317 | ScImage image; |
||
5234 | fschmid | 1318 | QByteArray imgArray; |
3136 | fschmid | 1319 | image.imgInfo.valid = false; |
1320 | image.imgInfo.clipPath = ""; |
||
1321 | image.imgInfo.PDSpathData.clear(); |
||
1322 | image.imgInfo.layerInfo.clear(); |
||
1323 | image.imgInfo.RequestProps = c->pixm.imgInfo.RequestProps; |
||
1324 | image.imgInfo.isRequest = c->pixm.imgInfo.isRequest; |
||
5959 | jghali | 1325 | CMSettings cms(c->doc(), Prof, c->IRender); |
1326 | image.LoadPicture(fn, cms, UseEmbedded, UseProf, ScImage::CMYKData, 300, &dummy); |
||
3136 | fschmid | 1327 | image.applyEffect(c->effectsInUse, colorsToUse, true); |
5234 | fschmid | 1328 | imgArray = image.ImageToCMYK_PS(-1, true); |
3136 | fschmid | 1329 | if (CompAvail) |
1330 | { |
||
1331 | PutSeite("currentfile /ASCIIHexDecode filter /FlateDecode filter /ReusableStreamDecode filter\n"); |
||
5234 | fschmid | 1332 | imgArray = CompressArray(&imgArray); |
3136 | fschmid | 1333 | } |
1334 | else |
||
1335 | PutSeite("currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n"); |
||
5234 | fschmid | 1336 | PutSeite(imgArray, true); |
3136 | fschmid | 1337 | PutSeite("\n>\n"); |
1338 | PutSeite("/"+PSEncode(Name)+"Bild exch def\n"); |
||
5234 | fschmid | 1339 | imgArray.resize(0); |
1340 | QByteArray maskArray; |
||
6661 | fschmid | 1341 | maskArray = image.getAlpha(fn, false, false, 300); |
6660 | fschmid | 1342 | if ((maskArray.size() > 0) && (c->pixm.imgInfo.type != 7)) |
3136 | fschmid | 1343 | { |
1344 | if (CompAvail) |
||
1345 | { |
||
1346 | PutSeite("currentfile /ASCIIHexDecode filter /FlateDecode filter /ReusableStreamDecode filter\n"); |
||
5234 | fschmid | 1347 | maskArray = CompressArray(&maskArray); |
3136 | fschmid | 1348 | } |
1349 | else |
||
1350 | PutSeite("currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n"); |
||
5234 | fschmid | 1351 | PutSeite(maskArray, true); |
3136 | fschmid | 1352 | PutSeite("\n>\n"); |
1353 | PutSeite("/"+PSEncode(Name)+"Mask exch def\n"); |
||
1354 | } |
||
1355 | } |
||
1356 | |||
1357 | void PSLib::PS_image(PageItem *c, double x, double y, QString fn, double scalex, double scaley, QString Prof, bool UseEmbedded, bool UseProf, QString Name) |
||
1358 | { |
||
1359 | bool dummy; |
||
5234 | fschmid | 1360 | QCString tmp; |
3136 | fschmid | 1361 | QFileInfo fi = QFileInfo(fn); |
1362 | QString ext = fi.extension(false).lower(); |
||
6808 | fschmid | 1363 | if (ext.isEmpty()) |
1364 | ext = getImageType(fn); |
||
7420 | fschmid | 1365 | if (((ext == "eps") || (ext == "epsi")) && (c->pixm.imgInfo.type != 7)) |
3136 | fschmid | 1366 | { |
5234 | fschmid | 1367 | if (loadRawText(fn, tmp)) |
3136 | fschmid | 1368 | { |
1369 | PutSeite("bEPS\n"); |
||
4335 | fschmid | 1370 | PutSeite(ToStr(PrefsManager::instance()->appPrefs.gs_Resolution / 72.0 * scalex) + " " + ToStr(PrefsManager::instance()->appPrefs.gs_Resolution / 72.0 * scaley) + " sc\n"); |
1371 | PutSeite(ToStr(-c->BBoxX+x * scalex) + " " + ToStr(y * scalex) + " tr\n"); |
||
3136 | fschmid | 1372 | if (!Name.isEmpty()) |
1373 | { |
||
1374 | PutSeite(PSEncode(Name)+"Bild cvx exec\n"); |
||
1375 | PutSeite(PSEncode(Name)+"Bild resetfile\n"); |
||
1376 | } |
||
1377 | else |
||
1378 | { |
||
1379 | PutSeite("%%BeginDocument: " + fi.fileName() + "\n"); |
||
5234 | fschmid | 1380 | if (getDouble(QString(tmp.mid(0, 4)), true) == 0xC5D0D3C6) |
3136 | fschmid | 1381 | { |
5234 | fschmid | 1382 | char* data = tmp.data(); |
3136 | fschmid | 1383 | uint startPos = getDouble(tmp.mid(4, 4), false); |
1384 | uint length = getDouble(tmp.mid(8, 4), false); |
||
5234 | fschmid | 1385 | PutSeite(data+startPos, length, false); |
3136 | fschmid | 1386 | } |
1387 | else |
||
5234 | fschmid | 1388 | PutSeite(tmp); |
1389 | PutSeite("\n%%EndDocument\n"); |
||
3136 | fschmid | 1390 | } |
1391 | PutSeite("eEPS\n"); |
||
1392 | } |
||
1393 | } |
||
1394 | else |
||
1395 | { |
||
1396 | ScImage image; |
||
5234 | fschmid | 1397 | QByteArray imgArray; |
3136 | fschmid | 1398 | image.imgInfo.valid = false; |
1399 | image.imgInfo.clipPath = ""; |
||
1400 | image.imgInfo.PDSpathData.clear(); |
||
1401 | image.imgInfo.layerInfo.clear(); |
||
1402 | image.imgInfo.RequestProps = c->pixm.imgInfo.RequestProps; |
||
1403 | image.imgInfo.isRequest = c->pixm.imgInfo.isRequest; |
||
5959 | jghali | 1404 | CMSettings cms(c->doc(), Prof, c->IRender); |
6660 | fschmid | 1405 | if (c->pixm.imgInfo.type == 7) |
1406 | image.LoadPicture(fn, cms, UseEmbedded, UseProf, ScImage::CMYKData, 72, &dummy); |
||
1407 | else |
||
1408 | image.LoadPicture(fn, cms, UseEmbedded, UseProf, ScImage::CMYKData, 300, &dummy); |
||
3136 | fschmid | 1409 | image.applyEffect(c->effectsInUse, colorsToUse, true); |
1410 | int w = image.width(); |
||
1411 | int h = image.height(); |
||
1412 | if (ext == "pdf") |
||
1413 | { |
||
4335 | fschmid | 1414 | scalex *= PrefsManager::instance()->appPrefs.gs_Resolution / 300.0; |
1415 | scaley *= PrefsManager::instance()->appPrefs.gs_Resolution / 300.0; |
||
3136 | fschmid | 1416 | } |
1417 | PutSeite(ToStr(x*scalex) + " " + ToStr(y*scaley) + " tr\n"); |
||
6661 | fschmid | 1418 | PutSeite(ToStr(qRound(scalex*w)) + " " + ToStr(qRound(scaley*h)) + " sc\n"); |
3136 | fschmid | 1419 | PutSeite(((!DoSep) && (!GraySc)) ? "/DeviceCMYK setcolorspace\n" : "/DeviceGray setcolorspace\n"); |
5234 | fschmid | 1420 | QByteArray maskArray; |
3136 | fschmid | 1421 | ScImage img2; |
6873 | fschmid | 1422 | img2.imgInfo.clipPath = ""; |
1423 | img2.imgInfo.PDSpathData.clear(); |
||
1424 | img2.imgInfo.layerInfo.clear(); |
||
1425 | img2.imgInfo.RequestProps = c->pixm.imgInfo.RequestProps; |
||
1426 | img2.imgInfo.isRequest = c->pixm.imgInfo.isRequest; |
||
6661 | fschmid | 1427 | if (c->pixm.imgInfo.type != 7) |
1428 | maskArray = img2.getAlpha(fn, false, false, 300); |
||
6660 | fschmid | 1429 | if ((maskArray.size() > 0) && (c->pixm.imgInfo.type != 7)) |
3136 | fschmid | 1430 | { |
1431 | if (DoSep) |
||
5234 | fschmid | 1432 | imgArray = image.ImageToCMYK_PS(Plate, true); |
3136 | fschmid | 1433 | else |
5234 | fschmid | 1434 | imgArray = GraySc ? image.ImageToCMYK_PS( -2, true) : image.ImageToCMYK_PS(-1, true); |
3136 | fschmid | 1435 | if (Name.isEmpty()) |
1436 | { |
||
1437 | if (CompAvail) |
||
1438 | { |
||
1439 | PutSeite("currentfile /ASCIIHexDecode filter /FlateDecode filter /ReusableStreamDecode filter\n"); |
||
5234 | fschmid | 1440 | imgArray = CompressArray(&imgArray); |
3136 | fschmid | 1441 | } |
1442 | else |
||
1443 | PutSeite("currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n"); |
||
5234 | fschmid | 1444 | PutSeite(imgArray, true); |
1445 | imgArray.resize(0); |
||
3136 | fschmid | 1446 | PutSeite("\n>\n"); |
1447 | PutSeite("/Bild exch def\n"); |
||
1448 | if (CompAvail) |
||
1449 | { |
||
1450 | PutSeite("currentfile /ASCIIHexDecode filter /FlateDecode filter /ReusableStreamDecode filter\n"); |
||
5234 | fschmid | 1451 | maskArray = CompressArray(&maskArray); |
3136 | fschmid | 1452 | } |
1453 | else |
||
1454 | PutSeite("currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n"); |
||
5234 | fschmid | 1455 | PutSeite(maskArray, true); |
3136 | fschmid | 1456 | PutSeite("\n>\n"); |
1457 | PutSeite("/Mask exch def\n"); |
||
1458 | } |
||
1459 | PutSeite("<<\n"); |
||
1460 | PutSeite(" /PaintType 1\n"); |
||
1461 | PutSeite(" /PatternType 1\n"); |
||
1462 | PutSeite(" /TilingType 3\n"); |
||
1463 | PutSeite(" /BBox [ 0 0 1 1 ]\n"); |
||
1464 | PutSeite(" /XStep 2\n"); |
||
1465 | PutSeite(" /YStep 2\n"); |
||
1466 | PutSeite(" /PaintProc {\n"); |
||
1467 | PutSeite(" pop\n"); |
||
1468 | PutSeite(" 1 1 1 1 setcmykcolor\n"); |
||
1469 | PutSeite(" <<\n"); |
||
1470 | PutSeite(" /ImageType 1\n"); |
||
1471 | PutSeite(" /Height " + IToStr(h) + "\n"); |
||
1472 | PutSeite(" /Width " + IToStr(w) + "\n"); |
||
1473 | PutSeite(" /ImageMatrix [" + IToStr(w) + " 0 0 " + IToStr(-h) + " 0 " + IToStr(h) |
||
1474 | +"]\n"); |
||
1475 | if (DoSep) |
||
1476 | PutSeite(" /Decode [1 0]\n"); |
||
1477 | else |
||
1478 | PutSeite( GraySc ? " /Decode [1 0]\n" : " /Decode [0 1 0 1 0 1 0 1]\n" ); |
||
1479 | PutSeite(" /BitsPerComponent 8\n"); |
||
1480 | PutSeite(" /DataSource "+PSEncode(Name)+"Bild\n"); |
||
1481 | PutSeite(" >>\n"); |
||
1482 | PutSeite(" image\n"); |
||
1483 | PutSeite(" }\n"); |
||
1484 | PutSeite(">> matrix makepattern setpattern\n"); |
||
1485 | PutSeite("<< /ImageType 1\n"); |
||
1486 | PutSeite(" /Width " + IToStr(w) + "\n"); |
||
1487 | PutSeite(" /Height " + IToStr(h) + "\n"); |
||
1488 | PutSeite(" /BitsPerComponent 1\n"); |
||
1489 | PutSeite(" /Decode [1 0]\n"); |
||
1490 | PutSeite(" /ImageMatrix [" + IToStr(w) + " 0 0 " + IToStr(-h) + " 0 " + IToStr(h) + "]\n"); |
||
1491 | PutSeite(" /DataSource "+PSEncode(Name)+"Mask\n"); |
||
1492 | PutSeite(">>\n"); |
||
1493 | PutSeite("imagemask\n"); |
||
1494 | if (!Name.isEmpty()) |
||
1495 | { |
||
1496 | PutSeite(PSEncode(Name)+"Bild resetfile\n"); |
||
1497 | PutSeite(PSEncode(Name)+"Mask resetfile\n"); |
||
1498 | } |
||
1499 | } |
||
1500 | else |
||
1501 | { |
||
1502 | PutSeite("<< /ImageType 1\n"); |
||
1503 | PutSeite(" /Width " + IToStr(w) + "\n"); |
||
1504 | PutSeite(" /Height " + IToStr(h) + "\n"); |
||
1505 | PutSeite(" /BitsPerComponent 8\n"); |
||
1506 | if (DoSep) |
||
1507 | PutSeite(" /Decode [1 0]\n"); |
||
1508 | else |
||
1509 | PutSeite( GraySc ? " /Decode [1 0]\n" : " /Decode [0 1 0 1 0 1 0 1]\n"); |
||
1510 | PutSeite(" /ImageMatrix [" + IToStr(w) + " 0 0 " + IToStr(-h) + " 0 " + IToStr(h) + |
||
1511 | "]\n"); |
||
1512 | if (!Name.isEmpty()) |
||
1513 | { |
||
1514 | PutSeite(" /DataSource "+PSEncode(Name)+"Bild >>\n"); |
||
1515 | PutSeite("image\n"); |
||
1516 | PutSeite(PSEncode(Name)+"Bild resetfile\n"); |
||
1517 | } |
||
1518 | else |
||
1519 | { |
||
1520 | PutSeite ( CompAvail ? " /DataSource currentfile /ASCIIHexDecode filter /FlateDecode filter >>\n" : |
||
1521 | " /DataSource currentfile /ASCIIHexDecode filter >>\n"); |
||
1522 | PutSeite("image\n"); |
||
1523 | if (DoSep) |
||
5234 | fschmid | 1524 | imgArray = image.ImageToCMYK_PS(Plate, true); |
3136 | fschmid | 1525 | else |
5234 | fschmid | 1526 | imgArray = GraySc ? image.ImageToCMYK_PS(-2, true) : image.ImageToCMYK_PS(-1, true); |
3136 | fschmid | 1527 | if (CompAvail) |
5234 | fschmid | 1528 | imgArray = CompressArray(&imgArray); |
1529 | PutSeite(imgArray, true); |
||
3136 | fschmid | 1530 | PutSeite("\n>\n"); |
1531 | } |
||
1532 | } |
||
1533 | } |
||
1534 | } |
||
1535 | |||
1536 | |||
1537 | void PSLib::PS_plate(int nr, QString name) |
||
1538 | { |
||
1539 | switch (nr) |
||
1540 | { |
||
1541 | case 0: |
||
1542 | PutSeite("%%PlateColor Black\n"); |
||
1543 | PutSeite("/setcmykcolor {exch pop exch pop exch pop 1 exch sub oldsetgray} bind def\n"); |
||
1544 | PutSeite("/setrgbcolor {pop pop pop 1 oldsetgray} bind def\n"); |
||
1545 | break; |
||
1546 | case 1: |
||
1547 | PutSeite("%%PlateColor Cyan\n"); |
||
1548 | PutSeite("/setcmykcolor {pop pop pop 1 exch sub oldsetgray} bind def\n"); |
||
1549 | PutSeite("/setrgbcolor {pop pop oldsetgray} bind def\n"); |
||
1550 | break; |
||
1551 | case 2: |
||
1552 | PutSeite("%%PlateColor Magenta\n"); |
||
1553 | PutSeite("/setcmykcolor {pop pop exch pop 1 exch sub oldsetgray} bind def\n"); |
||
1554 | PutSeite("/setrgbcolor {pop exch pop oldsetgray} bind def\n"); |
||
1555 | break; |
||
1556 | case 3: |
||
1557 | PutSeite("%%PlateColor Yellow\n"); |
||
1558 | PutSeite("/setcmykcolor {pop exch pop exch pop 1 exch sub oldsetgray} bind def\n"); |
||
1559 | PutSeite("/setrgbcolor {exch pop exch pop oldsetgray} bind def\n"); |
||
1560 | break; |
||
1561 | default: |
||
1562 | PutSeite("%%PlateColor "+name+"\n"); |
||
1563 | PutSeite("/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"); |
||
1564 | PutSeite("/setrgbcolor {0.11 mul exch 0.59 mul add exch 0.3 mul add oldsetgray} bind def\n"); |
||
1565 | break; |
||
1566 | } |
||
1567 | Plate = nr; |
||
1568 | currentSpot = name; |
||
1569 | DoSep = true; |
||
1570 | } |
||
1571 | |||
1572 | void PSLib::PS_setGray() |
||
1573 | { |
||
1574 | GraySc = true; |
||
1575 | } |
||
1576 | |||
1577 | void PSLib::PDF_Bookmark(QString text, uint Seite) |
||
1578 | { |
||
1579 | PutSeite("[/Title ("+text+") /Page "+IToStr(Seite)+" /View [/Fit]\n"); |
||
1580 | PutSeite("/OUT pdfmark\n"); |
||
1581 | isPDF = true; |
||
1582 | } |
||
1583 | |||
1584 | void PSLib::PDF_Annotation(QString text, double x, double y, double b, double h) |
||
1585 | { |
||
1586 | PutSeite("[ /Rect [ "+ToStr(static_cast<int>(x))+" "+ToStr(static_cast<int>(y)) |
||
1587 | +" "+ToStr(static_cast<int>(b))+" "+ToStr(static_cast<int>(h))+" ]\n"); |
||
1588 | PutSeite(" /Contents ("+text+")\n /Open false\n"); |
||
1589 | PutSeite("/ANN pdfmark\n"); |
||
1590 | isPDF = true; |
||
1591 | } |
||
1592 | |||
1593 | |||
1594 | void PSLib::PS_close() |
||
1595 | { |
||
1596 | PutDoc("%%Trailer\n"); |
||
1597 | PutDoc("end\n"); |
||
1598 | PutDoc("%%EOF\n"); |
||
1599 | Spool.close(); |
||
1600 | } |
||
1601 | |||
1602 | |||
1603 | void PSLib::PS_insert(QString i) |
||
1604 | { |
||
1605 | PutDoc(i); |
||
1606 | } |
||
1607 | |||
6954 | fschmid | 1608 | int PSLib::CreatePS(ScribusDoc* Doc, PrintOptions &options) |
3136 | fschmid | 1609 | { |
6954 | fschmid | 1610 | Options = options; |
1611 | std::vector<int> &pageNs = options.pageNumbers; |
||
1612 | bool sep = options.outputSeparations; |
||
1613 | QString SepNam = options.separationName; |
||
1614 | QStringList spots = options.allSeparations; |
||
1615 | bool farb = options.useColor; |
||
1616 | bool Hm = options.mirrorH; |
||
1617 | bool Vm = options.mirrorV; |
||
1618 | bool Ic = options.useICC; |
||
1619 | bool gcr = options.doGCR; |
||
1620 | bool doDev = options.setDevParam; |
||
1621 | bool doClip = options.doClip; |
||
1622 | bool over = options.doOverprint; |
||
6451 | fschmid | 1623 | QPtrStack<PageItem> groupStack; |
3136 | fschmid | 1624 | int sepac; |
1625 | int pagemult; |
||
5320 | fschmid | 1626 | doOverprint = over; |
3136 | fschmid | 1627 | if ((sep) && (SepNam == QObject::tr("All"))) |
1628 | pagemult = spots.count(); |
||
1629 | else |
||
3230 | fschmid | 1630 | pagemult = 1; |
3136 | fschmid | 1631 | QValueList<double> dum; |
7978 | fschmid | 1632 | double gx = 0.0; |
1633 | double gy = 0.0; |
||
1634 | double gw = 0.0; |
||
1635 | double gh = 0.0;; |
||
3136 | fschmid | 1636 | dum.clear(); |
1637 | PS_set_Info("Author", Doc->documentInfo.getAuthor()); |
||
1638 | PS_set_Info("Title", Doc->documentInfo.getTitle()); |
||
1639 | if (!farb) |
||
1640 | PS_setGray(); |
||
6671 | fschmid | 1641 | applyICC = Ic; |
1642 | if ((Doc->HasCMS) && (ScCore->haveCMS()) && (applyICC)) |
||
1643 | solidTransform = cmsCreateTransform(Doc->DocInputCMYKProf, TYPE_CMYK_16, Doc->DocPrinterProf, TYPE_CMYK_16, Doc->IntentColors, 0); |
||
1644 | else |
||
1645 | applyICC = false; |
||
4037 | cbradney | 1646 | if (usingGUI) |
1647 | { |
||
1648 | QString title=QObject::tr("Exporting PostScript File"); |
||
1649 | if (Art) |
||
1650 | title=QObject::tr("Printing File"); |
||
5781 | cbradney | 1651 | progressDialog=new MultiProgressDialog(title, CommonStrings::tr_Cancel, Doc->scMW(), "psexportprogress"); |
4037 | cbradney | 1652 | if (progressDialog==0) |
1653 | usingGUI=false; |
||
1654 | else |
||
1655 | { |
||
1656 | QStringList barNames, barTexts; |
||
1657 | barNames << "EMP" << "EP"; |
||
5370 | cbradney | 1658 | barTexts << tr("Processing Master Page:") << tr("Exporting Page:"); |
1659 | QValueList<bool> barsNumeric; |
||
1660 | barsNumeric << true << true; |
||
1661 | progressDialog->addExtraProgressBars(barNames, barTexts, barsNumeric); |
||
4037 | cbradney | 1662 | progressDialog->setOverallTotalSteps(pageNs.size()+Doc->MasterPages.count()); |
1663 | progressDialog->setTotalSteps("EMP", Doc->MasterPages.count()); |
||
1664 | progressDialog->setTotalSteps("EP", pageNs.size()); |
||
1665 | progressDialog->setOverallProgress(0); |
||
1666 | progressDialog->setProgress("EMP", 0); |
||
1667 | progressDialog->setProgress("EP", 0); |
||
1668 | progressDialog->show(); |
||
1669 | connect(progressDialog->buttonCancel, SIGNAL(clicked()), this, SLOT(cancelRequested())); |
||
1670 | ScQApp->processEvents(); |
||
1671 | } |
||
1672 | } |
||
3934 | cbradney | 1673 | //if ((!Art) && (view->SelItem.count() != 0)) |
4847 | cbradney | 1674 | uint docSelectionCount=Doc->m_Selection->count(); |
3934 | cbradney | 1675 | if ((!Art) && (docSelectionCount != 0)) |
3136 | fschmid | 1676 | { |
3394 | fschmid | 1677 | double minx = 99999.9; |
1678 | double miny = 99999.9; |
||
1679 | double maxx = -99999.9; |
||
1680 | double maxy = -99999.9; |
||
3934 | cbradney | 1681 | for (uint ep = 0; ep < docSelectionCount; ++ep) |
3394 | fschmid | 1682 | { |
3934 | cbradney | 1683 | //PageItem* currItem = view->SelItem.at(ep); |
4847 | cbradney | 1684 | PageItem* currItem = Doc->m_Selection->itemAt(ep); |
3394 | fschmid | 1685 | double lw = currItem->lineWidth() / 2.0; |
3934 | cbradney | 1686 | if (currItem->rotation() != 0) |
3394 | fschmid | 1687 | { |
1688 | FPointArray pb; |
||
1689 | pb.resize(0); |
||
3903 | cbradney | 1690 | pb.addPoint(FPoint(currItem->xPos()-lw, currItem->yPos()-lw)); |
3934 | cbradney | 1691 | pb.addPoint(FPoint(currItem->width()+lw*2.0, -lw, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0)); |
1692 | 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)); |
||
1693 | pb.addPoint(FPoint(-lw, currItem->height()+lw*2.0, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0)); |
||
3394 | fschmid | 1694 | for (uint pc = 0; pc < 4; ++pc) |
1695 | { |
||
1696 | minx = QMIN(minx, pb.point(pc).x()); |
||
1697 | miny = QMIN(miny, pb.point(pc).y()); |
||
1698 | maxx = QMAX(maxx, pb.point(pc).x()); |
||
1699 | maxy = QMAX(maxy, pb.point(pc).y()); |
||
1700 | } |
||
1701 | } |
||
1702 | else |
||
1703 | { |
||
3903 | cbradney | 1704 | minx = QMIN(minx, currItem->xPos()-lw); |
1705 | miny = QMIN(miny, currItem->yPos()-lw); |
||
3934 | cbradney | 1706 | maxx = QMAX(maxx, currItem->xPos()-lw + currItem->width()+lw*2.0); |
1707 | maxy = QMAX(maxy, currItem->yPos()-lw + currItem->height()+lw*2.0); |
||
3394 | fschmid | 1708 | } |
1709 | } |
||
1710 | gx = minx; |
||
1711 | gy = miny; |
||
1712 | gw = maxx - minx; |
||
1713 | gh = maxy - miny; |
||
3136 | fschmid | 1714 | int pgNum = pageNs[0]-1; |
3724 | cbradney | 1715 | gx -= Doc->Pages->at(pgNum)->xOffset(); |
1716 | gy -= Doc->Pages->at(pgNum)->yOffset(); |
||
6388 | fschmid | 1717 | PS_begin_doc(Doc, gx, Doc->pageHeight - (gy+gh), gx + gw, Doc->pageHeight - gy, 1*pagemult, false, sep, farb, Ic, gcr, over); |
3136 | fschmid | 1718 | } |
1719 | else |
||
4037 | cbradney | 1720 | { |
8450 | fschmid | 1721 | uint a; |
1722 | double maxWidth = 0.0; |
||
1723 | double maxHeight = 0.0; |
||
8467 | avox | 1724 | for (uint aa = 0; aa < pageNs.size(); ++aa) |
8450 | fschmid | 1725 | { |
1726 | a = pageNs[aa]-1; |
||
1727 | maxWidth = QMAX(Doc->Pages->at(a)->width(), maxWidth); |
||
1728 | maxHeight = QMAX(Doc->Pages->at(a)->height(), maxHeight); |
||
1729 | } |
||
1730 | PS_begin_doc(Doc, 0.0, 0.0, maxWidth, maxHeight, pageNs.size()*pagemult, doDev, sep, farb, Ic, gcr, over); |
||
4037 | cbradney | 1731 | } |
1732 | uint ap=0; |
||
1733 | for (; ap < Doc->MasterPages.count() && !abortExport; ++ap) |
||
3136 | fschmid | 1734 | { |
4037 | cbradney | 1735 | progressDialog->setOverallProgress(ap); |
1736 | progressDialog->setProgress("EMP", ap); |
||
1737 | ScQApp->processEvents(); |
||
3136 | fschmid | 1738 | if (Doc->MasterItems.count() != 0) |
1739 | { |
||
1740 | int Lnr = 0; |
||
1741 | struct Layer ll; |
||
1742 | ll.isPrintable = false; |
||
1743 | ll.LNr = 0; |
||
1744 | for (uint lam = 0; lam < Doc->Layers.count(); ++lam) |
||
1745 | { |
||
1746 | Level2Layer(Doc, &ll, Lnr); |
||
1747 | if (ll.isPrintable) |
||
1748 | { |
||
1749 | for (uint api = 0; api < Doc->MasterItems.count(); ++api) |
||
1750 | { |
||
1751 | QString tmps; |
||
1752 | PageItem *it = Doc->MasterItems.at(api); |
||
4698 | cbradney | 1753 | if ((it->LayerNr != ll.LNr) || (!it->printEnabled())) |
3136 | fschmid | 1754 | continue; |
7449 | fschmid | 1755 | /* int x = static_cast<int>(Doc->MasterPages.at(ap)->xOffset()); |
3200 | cbradney | 1756 | int y = static_cast<int>(Doc->MasterPages.at(ap)->yOffset()); |
1757 | int w = static_cast<int>(Doc->MasterPages.at(ap)->width()); |
||
1758 | int h = static_cast<int>(Doc->MasterPages.at(ap)->height()); |
||
4580 | cbradney | 1759 | double ilw=it->lineWidth(); |
1760 | int x2 = static_cast<int>(it->BoundingX - ilw / 2.0); |
||
1761 | int y2 = static_cast<int>(it->BoundingY - ilw / 2.0); |
||
1762 | int w2 = static_cast<int>(it->BoundingW + ilw); |
||
1763 | int h2 = static_cast<int>(it->BoundingH + ilw); |
||
3136 | fschmid | 1764 | if (!QRect(x, y, w, h).intersects(QRect(x2, y2, w2, h2))) |
7449 | fschmid | 1765 | continue; */ |
1766 | double x = Doc->MasterPages.at(ap)->xOffset(); |
||
1767 | double y = Doc->MasterPages.at(ap)->yOffset(); |
||
1768 | double w = Doc->MasterPages.at(ap)->width(); |
||
1769 | double h1 = Doc->MasterPages.at(ap)->height(); |
||
1770 | double ilw = it->lineWidth(); |
||
1771 | double x2 = it->BoundingX - ilw / 2.0; |
||
1772 | double y2 = it->BoundingY - ilw / 2.0; |
||
1773 | double w2 = it->BoundingW + ilw; |
||
1774 | double h2 = it->BoundingH + ilw; |
||
1775 | if (!( QMAX( x, x2 ) <= QMIN( x+w, x2+w2 ) && QMAX( y, y2 ) <= QMIN( y+h1, y2+h2 ))) |
||
3136 | fschmid | 1776 | continue; |
3200 | cbradney | 1777 | if ((it->OwnPage != static_cast<int>(Doc->MasterPages.at(ap)->pageNr())) && (it->OwnPage != -1)) |
3136 | fschmid | 1778 | continue; |
4698 | cbradney | 1779 | if ((it->asImageFrame()) && (it->PicAvail) && (!it->Pfile.isEmpty()) && (it->printEnabled()) && (!sep) && (farb)) |
3136 | fschmid | 1780 | PS_ImageData(it, it->Pfile, it->itemName(), it->IProfile, it->UseEmbedded, Ic); |
5685 | cbradney | 1781 | PS_TemplateStart(Doc->MasterPages.at(ap)->pageName() + tmps.setNum(it->ItemNr)); |
3136 | fschmid | 1782 | ProcessItem(Doc, Doc->MasterPages.at(ap), it, ap+1, sep, farb, Ic, gcr, true); |
1783 | PS_TemplateEnd(); |
||
1784 | } |
||
1785 | } |
||
1786 | Lnr++; |
||
1787 | } |
||
1788 | } |
||
1789 | } |
||
1790 | sepac = 0; |
||
1791 | uint aa = 0; |
||
5781 | cbradney | 1792 | uint a; |
4037 | cbradney | 1793 | while (aa < pageNs.size() && !abortExport) |
3136 | fschmid | 1794 | { |
4037 | cbradney | 1795 | progressDialog->setProgress("EP", aa); |
1796 | progressDialog->setOverallProgress(ap+aa); |
||
1797 | ScQApp->processEvents(); |
||
3136 | fschmid | 1798 | a = pageNs[aa]-1; |
3934 | cbradney | 1799 | //if ((!Art) && (view->SelItem.count() != 0)) |
4847 | cbradney | 1800 | if ((!Art) && (Doc->m_Selection->count() != 0)) |
3136 | fschmid | 1801 | { |
7316 | jghali | 1802 | MarginStruct Ma; |
3136 | fschmid | 1803 | Ma.Left = gx; |
1804 | Ma.Top = gy; |
||
3724 | cbradney | 1805 | Ma.Bottom = Doc->Pages->at(a)->height() - (gy + gh); |
1806 | Ma.Right = Doc->Pages->at(a)->width() - (gx + gw); |
||
6748 | fschmid | 1807 | PS_begin_page(Doc->Pages->at(a), &Ma, true); |
3136 | fschmid | 1808 | } |
1809 | else |
||
6748 | fschmid | 1810 | PS_begin_page(Doc->Pages->at(a), &Doc->Pages->at(a)->Margins, doClip); |
3136 | fschmid | 1811 | if (Hm) |
1812 | { |
||
3724 | cbradney | 1813 | PS_translate(Doc->Pages->at(a)->width(), 0); |
3136 | fschmid | 1814 | PS_scale(-1, 1); |
1815 | } |
||
1816 | if (Vm) |
||
1817 | { |
||
3724 | cbradney | 1818 | PS_translate(0, Doc->Pages->at(a)->height()); |
3136 | fschmid | 1819 | PS_scale(1, -1); |
1820 | } |
||
1821 | if (sep) |
||
1822 | { |
||
1823 | if (SepNam == QObject::tr("Black")) |
||
1824 | PS_plate(0); |
||
1825 | else if (SepNam == QObject::tr("Cyan")) |
||
1826 | PS_plate(1); |
||
1827 | else if (SepNam == QObject::tr("Magenta")) |
||
1828 | PS_plate(2); |
||
1829 | else if (SepNam == QObject::tr("Yellow")) |
||
1830 | PS_plate(3); |
||
1831 | else if (SepNam == QObject::tr("All")) |
||
1832 | PS_plate(sepac, spots[sepac]); |
||
1833 | else |
||
1834 | PS_plate(4, SepNam); |
||
1835 | } |
||
3724 | cbradney | 1836 | if (!Doc->Pages->at(a)->MPageNam.isEmpty()) |
3136 | fschmid | 1837 | { |
1838 | int h, s, v, k; |
||
5721 | avox | 1839 | QCString chstrc; |
1840 | QString chstr; |
||
3136 | fschmid | 1841 | int Lnr = 0; |
1842 | struct Layer ll; |
||
1843 | ll.isPrintable = false; |
||
1844 | ll.LNr = 0; |
||
3724 | cbradney | 1845 | Page* mPage = Doc->MasterPages.at(Doc->MasterNames[Doc->Pages->at(a)->MPageNam]); |
3136 | fschmid | 1846 | if (Doc->MasterItems.count() != 0) |
1847 | { |
||
1848 | for (uint lam = 0; lam < Doc->Layers.count(); ++lam) |
||
1849 | { |
||
1850 | Level2Layer(Doc, &ll, Lnr); |
||
1851 | if (ll.isPrintable) |
||
1852 | { |
||
3724 | cbradney | 1853 | for (uint am = 0; am < Doc->Pages->at(a)->FromMaster.count(); ++am) |
3136 | fschmid | 1854 | { |
1855 | QString tmps; |
||
3724 | cbradney | 1856 | PageItem *ite = Doc->Pages->at(a)->FromMaster.at(am); |
4698 | cbradney | 1857 | if ((ite->LayerNr != ll.LNr) || (!ite->printEnabled())) |
3136 | fschmid | 1858 | continue; |
6451 | fschmid | 1859 | if (ite->isGroupControl) |
1860 | { |
||
1861 | PS_save(); |
||
1862 | FPointArray cl = ite->PoLine.copy(); |
||
1863 | QWMatrix mm; |
||
7444 | fschmid | 1864 | mm.translate(ite->xPos() - mPage->xOffset(), (ite->yPos() - mPage->yOffset()) - Doc->Pages->at(a)->height()); |
7981 | fschmid | 1865 | mm.rotate(ite->rotation()); |
6451 | fschmid | 1866 | cl.map( mm ); |
1867 | SetClipPath(&cl); |
||
1868 | PS_closepath(); |
||
1869 | PS_clip(true); |
||
1870 | groupStack.push(ite->groupsLastItem); |
||
1871 | continue; |
||
1872 | } |
||
3625 | avox | 1873 | if (!(ite->asTextFrame()) && !(ite->asImageFrame())) |
3724 | cbradney | 1874 | PS_UseTemplate(Doc->Pages->at(a)->MPageNam + tmps.setNum(ite->ItemNr)); |
3625 | avox | 1875 | else if (ite->asImageFrame()) |
3136 | fschmid | 1876 | { |
1877 | PS_save(); |
||
5795 | jghali | 1878 | // JG : replace what seems mostly duplicate code by corresponding function call (#3936) |
1879 | ProcessItem(Doc, Doc->Pages->at(a), ite, a, sep, farb, Ic, gcr, false, false, true); |
||
1880 | /*if (!doOverprint) |
||
5320 | fschmid | 1881 | { |
1882 | if (ite->doOverprint) |
||
1883 | { |
||
1884 | PutSeite("true setoverprint\n"); |
||
1885 | PutSeite("true setoverprintmode\n"); |
||
1886 | } |
||
1887 | } |
||
5795 | jghali | 1888 | PS_translate(ite->xPos() - Doc->Pages->at(a)->xOffset(), Doc->Pages->at(a)->height() -(ite->yPos()) - Doc->Pages->at(a)->yOffset()); |
3934 | cbradney | 1889 | if (ite->rotation() != 0) |
1890 | PS_rotate(-ite->rotation()); |
||
4546 | subik | 1891 | if (ite->fillColor() != CommonStrings::None) |
3136 | fschmid | 1892 | { |
1893 | SetClipPath(&ite->PoLine); |
||
1894 | PS_closepath(); |
||
1895 | SetFarbe(ite->fillColor(), ite->fillShade(), &h, &s, &v, &k, gcr); |
||
1896 | PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1897 | putColor(ite->fillColor(), ite->fillShade(), true); |
||
1898 | } |
||
1899 | else |
||
1900 | PS_setcmykcolor_dummy(); |
||
1901 | if (ite->imageClip.size() != 0) |
||
1902 | SetClipPath(&ite->imageClip); |
||
1903 | else |
||
1904 | SetClipPath(&ite->PoLine); |
||
1905 | PS_closepath(); |
||
1906 | PS_clip(false); |
||
1907 | PS_save(); |
||
1908 | if (ite->imageFlippedH()) |
||
1909 | { |
||
3934 | cbradney | 1910 | PS_translate(ite->width(), 0); |
3136 | fschmid | 1911 | PS_scale(-1, 1); |
1912 | } |
||
1913 | if (ite->imageFlippedV()) |
||
1914 | { |
||
3934 | cbradney | 1915 | PS_translate(0, -ite->height()); |
3136 | fschmid | 1916 | PS_scale(1, -1); |
1917 | } |
||
1918 | if ((ite->PicAvail) && (!ite->Pfile.isEmpty())) |
||
1919 | { |
||
3985 | cbradney | 1920 | PS_translate(0, -ite->BBoxH*ite->imageYScale()); |
3136 | fschmid | 1921 | if ((!sep) && (farb)) |
5795 | jghali | 1922 | PS_image(ite, ite->imageXOffset(), -ite->imageYOffset(), ite->Pfile, ite->imageXScale(), ite->imageYScale(), ite->IProfile, ite->UseEmbedded, Ic, ite->itemName()); |
3136 | fschmid | 1923 | else |
5795 | jghali | 1924 | PS_image(ite, ite->imageXOffset(), -ite->imageYOffset(), ite->Pfile, ite->imageXScale(), ite->imageYScale(), ite->IProfile, ite->UseEmbedded, Ic); |
3136 | fschmid | 1925 | } |
1926 | PS_restore(); |
||
4546 | subik | 1927 | if (((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty())) && (!ite->isTableItem)) |
3136 | fschmid | 1928 | { |
4580 | cbradney | 1929 | if ((ite->NamedLStyle.isEmpty()) && (ite->lineWidth() != 0.0)) |
3136 | fschmid | 1930 | { |
1931 | SetFarbe(ite->lineColor(), ite->lineShade(), &h, &s, &v, &k, gcr); |
||
1932 | PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
4580 | cbradney | 1933 | PS_setlinewidth(ite->lineWidth()); |
3136 | fschmid | 1934 | PS_setcapjoin(ite->PLineEnd, ite->PLineJoin); |
1935 | PS_setdash(ite->PLineArt, ite->DashOffset, ite->DashValues); |
||
1936 | SetClipPath(&ite->PoLine); |
||
1937 | PS_closepath(); |
||
1938 | putColor(ite->lineColor(), ite->lineShade(), false); |
||
1939 | } |
||
1940 | else |
||
1941 | { |
||
1942 | multiLine ml = Doc->MLineStyles[ite->NamedLStyle]; |
||
1943 | for (int it = ml.size()-1; it > -1; it--) |
||
1944 | { |
||
1945 | SetFarbe(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr); |
||
1946 | & |