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