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