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