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