Rev 3761 | Rev 3903 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3133 | fschmid | 1 | /*************************************************************************** |
2 | pdflib.cpp - description |
||
3 | ------------------- |
||
4 | begin : Sat Jan 19 2002 |
||
5 | copyright : (C) 2002 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 | |||
18 | #include "pdflib.h" |
||
19 | #include "pdflib.moc" |
||
20 | |||
21 | #include "scconfig.h" |
||
22 | |||
23 | #include <qstring.h> |
||
24 | #include <qrect.h> |
||
25 | #include <qimage.h> |
||
26 | #include <qregexp.h> |
||
27 | #include <qdatetime.h> |
||
28 | #include <qfileinfo.h> |
||
29 | #include <qtextstream.h> |
||
30 | #include <qprogressbar.h> |
||
31 | #include <qdir.h> |
||
32 | #include <cstdlib> |
||
33 | #include <cmath> |
||
34 | #ifdef HAVE_UNISTD_H |
||
35 | #include <unistd.h> |
||
36 | #endif |
||
37 | #include "rc4.h" |
||
38 | |||
3670 | cbradney | 39 | #include "page.h" |
3133 | fschmid | 40 | #include "pageitem.h" |
41 | #include "bookmwin.h" |
||
42 | #include "scribus.h" |
||
3699 | cbradney | 43 | #include "scribusdoc.h" |
3133 | fschmid | 44 | |
45 | #include "bookpalette.h" |
||
46 | #include "scfontmetrics.h" |
||
47 | #include "util.h" |
||
48 | #include "prefsmanager.h" |
||
3252 | craig | 49 | #include "prefscontext.h" |
3133 | fschmid | 50 | #include "pdfoptions.h" |
51 | |||
52 | using namespace std; |
||
53 | |||
54 | #ifdef HAVE_CMS |
||
55 | extern bool CMSuse; |
||
56 | #endif |
||
57 | #ifdef HAVE_TIFF |
||
58 | #include <tiffio.h> |
||
59 | #endif |
||
60 | |||
3205 | craig | 61 | |
3137 | fschmid | 62 | PDFlib::PDFlib(ScribusDoc *docu) |
3133 | fschmid | 63 | { |
3137 | fschmid | 64 | doc = docu; |
3133 | fschmid | 65 | OwnerKey = QByteArray(32); |
66 | UserKey = QByteArray(32); |
||
67 | FileID = QByteArray(16); |
||
68 | EncryKey = QByteArray(5); |
||
69 | Encrypt = 0; |
||
70 | KeyLen = 5; |
||
71 | Dokument = 0; |
||
72 | Catalog.Outlines = 2; |
||
73 | Catalog.PageTree = 3; |
||
74 | Catalog.Dest = 4; |
||
75 | PageTree.Count = 0; |
||
76 | PageTree.Kids.clear(); |
||
77 | Outlines.First = 0; |
||
78 | Outlines.Last = 0; |
||
79 | Outlines.Count = 0; |
||
80 | XRef.clear(); |
||
81 | NamedDest.clear(); |
||
82 | NDnam = "LI"; |
||
83 | NDnum = 0; |
||
84 | ObjCounter = 7; |
||
85 | Seite.ObjNum = 0; |
||
86 | Seite.Thumb = 0; |
||
87 | Seite.XObjects.clear(); |
||
88 | Seite.ImgObjects.clear(); |
||
89 | Seite.FObjects.clear(); |
||
90 | Seite.AObjects.clear(); |
||
91 | Seite.FormObjects.clear(); |
||
92 | CalcFields.clear(); |
||
93 | Shadings.clear(); |
||
94 | Transpar.clear(); |
||
95 | ICCProfiles.clear(); |
||
96 | SharedImages.clear(); |
||
97 | ResNam = "RE"; |
||
98 | ResCount = 0; |
||
99 | colorsToUse.clear(); |
||
100 | spotMap.clear(); |
||
101 | spotNam = "Spot"; |
||
102 | spotCount = 0; |
||
103 | #ifdef HAVE_LIBZ |
||
104 | CompAvail = true; |
||
105 | #else |
||
106 | CompAvail = false; |
||
107 | #endif |
||
108 | KeyGen = QByteArray(32); |
||
109 | int kg_array[] = {0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, |
||
110 | 0x01, 0x08, 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80, 0x2f, 0x0c, 0xa9, 0xfe, |
||
111 | 0x64, 0x53, 0x69, 0x7a}; |
||
112 | for (int a = 0; a < 32; ++a) |
||
113 | KeyGen[a] = kg_array[a]; |
||
114 | } |
||
115 | |||
3829 | cbradney | 116 | bool PDFlib::doExport(const QString& fn, const QString& nam, int Components, std::vector<int> &pageNs, QMap<int,QPixmap> thumbs, QProgressBar *dia2) |
3133 | fschmid | 117 | { |
118 | QPixmap pm; |
||
119 | bool ret = false; |
||
120 | int progresscount=0; |
||
3137 | fschmid | 121 | if (PDF_Begin_Doc(fn, &doc->PDF_Options, PrefsManager::instance()->appPrefs.AvailFonts, doc->UsedFonts, ScApp->bookmarkPalette->BView)) |
3133 | fschmid | 122 | { |
123 | QMap<int, int> pageNsMpa; |
||
124 | for (uint a = 0; a < pageNs.size(); ++a) |
||
125 | { |
||
3724 | cbradney | 126 | pageNsMpa.insert(doc->MasterNames[doc->Pages->at(pageNs[a]-1)->MPageNam], 0); |
3133 | fschmid | 127 | } |
128 | dia2->reset(); |
||
129 | dia2->setTotalSteps(pageNsMpa.count()+pageNs.size()); |
||
130 | dia2->setProgress(0); |
||
131 | for (uint ap = 0; ap < doc->MasterPages.count(); ++ap) |
||
132 | { |
||
133 | if (doc->MasterItems.count() != 0) |
||
134 | { |
||
135 | if (pageNsMpa.contains(ap)) |
||
136 | { |
||
137 | PDF_TemplatePage(doc->MasterPages.at(ap)); |
||
138 | progresscount++; |
||
139 | } |
||
140 | } |
||
141 | dia2->setProgress(progresscount); |
||
142 | } |
||
143 | for (uint a = 0; a < pageNs.size(); ++a) |
||
144 | { |
||
145 | if (doc->PDF_Options.Thumbnails) |
||
146 | pm = thumbs[pageNs[a]]; |
||
3724 | cbradney | 147 | PDF_Begin_Page(doc->Pages->at(pageNs[a]-1), pm); |
148 | PDF_ProcessPage(doc->Pages->at(pageNs[a]-1), pageNs[a]-1); |
||
3133 | fschmid | 149 | PDF_End_Page(); |
150 | progresscount++; |
||
151 | dia2->setProgress(progresscount); |
||
152 | } |
||
153 | if (doc->PDF_Options.Version == PDFOptions::PDFVersion_X3) |
||
154 | PDF_End_Doc(ScApp->PrinterProfiles[doc->PDF_Options.PrintProf], nam, Components); |
||
155 | else |
||
156 | PDF_End_Doc(); |
||
157 | ret = true; |
||
158 | dia2->reset(); |
||
159 | } |
||
160 | return ret; |
||
161 | } |
||
162 | |||
3829 | cbradney | 163 | QString PDFlib::FToStr(const double c) |
3133 | fschmid | 164 | { |
165 | QString cc; |
||
166 | return cc.sprintf("%.5f", c); |
||
167 | } |
||
168 | |||
3829 | cbradney | 169 | QString PDFlib::IToStr(const int c) |
3133 | fschmid | 170 | { |
171 | QString cc; |
||
172 | return cc.setNum(c); |
||
173 | } |
||
174 | |||
175 | void PDFlib::PutDoc(QString in) |
||
176 | { |
||
3829 | cbradney | 177 | //QTextStream t(&Spool); //CB replaced with member t. |
178 | uint inlen=in.length(); |
||
179 | t.writeRawBytes(in.latin1(), inlen); |
||
3133 | fschmid | 180 | Spool.flush(); |
3829 | cbradney | 181 | Dokument += inlen; |
3133 | fschmid | 182 | } |
183 | |||
184 | void PDFlib::PutPage(QString in) |
||
185 | { |
||
186 | Inhalt += in; |
||
187 | } |
||
188 | |||
189 | void PDFlib::StartObj(int nr) |
||
190 | { |
||
191 | XRef.append(Dokument); |
||
192 | PutDoc(IToStr(nr)+ " 0 obj\n"); |
||
193 | } |
||
194 | |||
195 | QString PDFlib::PDFEncode(QString in) |
||
196 | { |
||
197 | QString tmp = ""; |
||
198 | QString cc; |
||
199 | for (uint d = 0; d < in.length(); ++d) |
||
200 | { |
||
201 | cc = in.at(d); |
||
202 | if ((cc == "(") || (cc == ")") || (cc == "\\")) |
||
203 | tmp += "\\"; |
||
204 | tmp += cc; |
||
205 | } |
||
206 | return tmp; |
||
207 | } |
||
208 | |||
209 | QString PDFlib::EncStream(QString *in, int ObjNum) |
||
210 | { |
||
211 | if (in->length() < 1) |
||
212 | return ""; |
||
213 | rc4_context_t rc4; |
||
214 | QString tmp = ""; |
||
215 | int dlen = 0; |
||
216 | if (Options->Encrypt) |
||
217 | { |
||
218 | tmp = *in; |
||
219 | QByteArray us(tmp.length()); |
||
220 | QByteArray ou(tmp.length()); |
||
221 | for (uint a = 0; a < tmp.length(); ++a) |
||
222 | us[a] = uchar(QChar(tmp.at(a))); |
||
223 | QByteArray data(10); |
||
224 | if (KeyLen > 5) |
||
225 | data.resize(21); |
||
226 | for (int cd = 0; cd < KeyLen; ++cd) |
||
227 | { |
||
228 | data[cd] = EncryKey[cd]; |
||
229 | dlen++; |
||
230 | } |
||
231 | data[dlen++] = ObjNum; |
||
232 | data[dlen++] = ObjNum >> 8; |
||
233 | data[dlen++] = ObjNum >> 16; |
||
234 | data[dlen++] = 0; |
||
235 | data[dlen++] = 0; |
||
236 | QByteArray step1(16); |
||
237 | step1 = ComputeMD5Sum(&data); |
||
238 | rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), QMIN(KeyLen+5, 16)); |
||
239 | rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), reinterpret_cast<uchar*>(ou.data()), tmp.length()); |
||
240 | QString uk = ""; |
||
241 | for (uint cl = 0; cl < tmp.length(); ++cl) |
||
242 | uk += QChar(ou[cl]); |
||
243 | tmp = uk; |
||
244 | } |
||
245 | else |
||
246 | tmp = *in; |
||
247 | return tmp; |
||
248 | } |
||
249 | |||
250 | QString PDFlib::EncString(QString in, int ObjNum) |
||
251 | { |
||
252 | rc4_context_t rc4; |
||
253 | QString tmp; |
||
254 | int dlen = 0; |
||
255 | if (Options->Encrypt) |
||
256 | { |
||
3366 | fschmid | 257 | if (in.length() < 3) |
258 | return "<>"; |
||
3133 | fschmid | 259 | tmp = in.mid(1, in.length()-2); |
260 | QByteArray us(tmp.length()); |
||
261 | QByteArray ou(tmp.length()); |
||
262 | for (uint a = 0; a < tmp.length(); ++a) |
||
263 | us[a] = static_cast<uchar>(QChar(tmp.at(a))); |
||
264 | QByteArray data(10); |
||
265 | if (KeyLen > 5) |
||
266 | data.resize(21); |
||
267 | for (int cd = 0; cd < KeyLen; ++cd) |
||
268 | { |
||
269 | data[cd] = EncryKey[cd]; |
||
270 | dlen++; |
||
271 | } |
||
272 | data[dlen++] = ObjNum; |
||
273 | data[dlen++] = ObjNum >> 8; |
||
274 | data[dlen++] = ObjNum >> 16; |
||
275 | data[dlen++] = 0; |
||
276 | data[dlen++] = 0; |
||
277 | QByteArray step1(16); |
||
278 | step1 = ComputeMD5Sum(&data); |
||
279 | rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), QMIN(KeyLen+5, 16)); |
||
280 | rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), reinterpret_cast<uchar*>(ou.data()), tmp.length()); |
||
281 | QString uk = ""; |
||
282 | for (uint cl = 0; cl < tmp.length(); ++cl) |
||
283 | uk += QChar(ou[cl]); |
||
284 | tmp = "<"+String2Hex(&uk, false)+">"; |
||
285 | } |
||
286 | else |
||
287 | tmp = in; |
||
288 | return tmp; |
||
289 | } |
||
290 | |||
291 | QString PDFlib::FitKey(QString pass) |
||
292 | { |
||
293 | QString pw = pass; |
||
294 | if (pw.length() < 32) |
||
295 | { |
||
296 | uint l = pw.length(); |
||
297 | for (uint a = 0; a < 32 - l; ++a) |
||
298 | pw += QChar(KeyGen[a]); |
||
299 | } |
||
300 | else |
||
301 | pw = pw.left(32); |
||
302 | return pw; |
||
303 | } |
||
304 | |||
305 | void PDFlib::CalcOwnerKey(QString Owner, QString User) |
||
306 | { |
||
307 | rc4_context_t rc4; |
||
308 | QString pw = User; |
||
309 | QString pw2; |
||
310 | pw2 = Owner; |
||
311 | if (pw2.isEmpty()) |
||
312 | pw2 = User; |
||
313 | pw = FitKey(pw); |
||
314 | pw2 = FitKey(pw2); |
||
315 | QByteArray step1(16); |
||
316 | step1 = ComputeMD5(pw2); |
||
317 | if (KeyLen > 5) |
||
318 | { |
||
319 | for (int kl = 0; kl < 50; ++kl) |
||
320 | step1 = ComputeMD5Sum(&step1); |
||
321 | } |
||
322 | QByteArray us(32); |
||
323 | QByteArray enk(16); |
||
324 | if (KeyLen > 5) |
||
325 | { |
||
326 | for (uint a2 = 0; a2 < 32; ++a2) |
||
327 | OwnerKey[a2] = static_cast<uchar>(QChar(pw.at(a2))); |
||
328 | for (int rl = 0; rl < 20; rl++) |
||
329 | { |
||
330 | for (int j = 0; j < 16; j ++) |
||
331 | enk[j] = step1[j] ^ rl; |
||
332 | rc4_init(&rc4, reinterpret_cast<uchar*>(enk.data()), 16); |
||
333 | rc4_encrypt(&rc4, reinterpret_cast<uchar*>(OwnerKey.data()), |
||
334 | reinterpret_cast<uchar*>(OwnerKey.data()), 32); |
||
335 | } |
||
336 | } |
||
337 | else |
||
338 | { |
||
339 | for (uint a = 0; a < 32; ++a) |
||
340 | us[a] = static_cast<uchar>(QChar(pw.at(a))); |
||
341 | rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), 5); |
||
342 | rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), |
||
343 | reinterpret_cast<uchar*>(OwnerKey.data()), 32); |
||
344 | } |
||
345 | } |
||
346 | |||
347 | void PDFlib::CalcUserKey(QString User, int Permission) |
||
348 | { |
||
349 | rc4_context_t rc4; |
||
350 | QString pw = User; |
||
351 | pw = FitKey(pw); |
||
352 | QByteArray step1(16); |
||
353 | QByteArray perm(4); |
||
354 | uint perm_value = static_cast<uint>(Permission); |
||
355 | perm[0] = perm_value; |
||
356 | perm[1] = perm_value >> 8; |
||
357 | perm[2] = perm_value >> 16; |
||
358 | perm[3] = perm_value >> 24; |
||
359 | for (uint a = 0; a < 32; ++a) |
||
360 | pw += QChar(OwnerKey[a]); |
||
361 | for (uint a1 = 0; a1 < 4; ++a1) |
||
362 | pw += QChar(perm[a1]); |
||
363 | for (uint a3 = 0; a3 < 16; ++a3) |
||
364 | pw += QChar(FileID[a3]); |
||
365 | step1 = ComputeMD5(pw); |
||
366 | if (KeyLen > 5) |
||
367 | { |
||
368 | for (int kl = 0; kl < 50; ++kl) |
||
369 | step1 = ComputeMD5Sum(&step1); |
||
370 | EncryKey.resize(16); |
||
371 | } |
||
372 | for (int a2 = 0; a2 < KeyLen; ++a2) |
||
373 | EncryKey[a2] = step1[a2]; |
||
374 | if (KeyLen > 5) |
||
375 | { |
||
376 | QString pr2 = ""; |
||
377 | for (int kl3 = 0; kl3 < 32; ++kl3) |
||
378 | pr2 += QChar(KeyGen[kl3]); |
||
379 | for (uint a4 = 0; a4 < 16; ++a4) |
||
380 | pr2 += QChar(FileID[a4]); |
||
381 | step1 = ComputeMD5(pr2); |
||
382 | QByteArray enk(16); |
||
383 | for (uint a3 = 0; a3 < 16; ++a3) |
||
384 | UserKey[a3] = step1[a3]; |
||
385 | for (int rl = 0; rl < 20; rl++) |
||
386 | { |
||
387 | for (int j = 0; j < 16; j ++) |
||
388 | enk[j] = EncryKey[j] ^ rl; |
||
389 | rc4_init(&rc4, reinterpret_cast<uchar*>(enk.data()), 16); |
||
390 | rc4_encrypt(&rc4, reinterpret_cast<uchar*>(UserKey.data()), reinterpret_cast<uchar*>(UserKey.data()), 16); |
||
391 | } |
||
392 | } |
||
393 | else |
||
394 | { |
||
395 | rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), 5); |
||
396 | rc4_encrypt(&rc4, reinterpret_cast<uchar*>(KeyGen.data()), reinterpret_cast<uchar*>(UserKey.data()), 32); |
||
397 | } |
||
398 | } |
||
399 | |||
3829 | cbradney | 400 | QByteArray PDFlib::ComputeMD5(const QString& in) |
3133 | fschmid | 401 | { |
3829 | cbradney | 402 | uint inlen=in.length(); |
403 | QByteArray TBytes(inlen); |
||
404 | for (uint a = 0; a < inlen; ++a) |
||
3133 | fschmid | 405 | TBytes[a] = static_cast<uchar>(QChar(in.at(a))); |
406 | return ComputeMD5Sum(&TBytes); |
||
407 | } |
||
408 | |||
3829 | cbradney | 409 | bool PDFlib::PDF_Begin_Doc(const QString& fn, PDFOptions *opts, SCFonts &AllFonts, QMap<QString,int> DocFonts, BookMView* vi) |
3133 | fschmid | 410 | { |
411 | Spool.setName(fn); |
||
412 | if (!Spool.open(IO_WriteOnly)) |
||
413 | return false; |
||
3829 | cbradney | 414 | t.setDevice(&Spool); |
3133 | fschmid | 415 | QString tmp; |
416 | QString ok = ""; |
||
417 | QString uk = ""; |
||
418 | QFileInfo fd; |
||
419 | QString fext; |
||
420 | int a; |
||
421 | Bvie = vi; |
||
422 | Options = opts; |
||
423 | BookMinUse = false; |
||
424 | UsedFontsP.clear(); |
||
425 | if ((Options->Version == 15) && (Options->useLayers)) |
||
426 | ObjCounter = 10; |
||
427 | else |
||
428 | ObjCounter = 9; |
||
429 | switch (Options->Version) |
||
430 | { |
||
431 | case 12: |
||
432 | case 13: |
||
433 | PutDoc("%PDF-1.3\n"); |
||
434 | break; |
||
435 | case 14: |
||
436 | PutDoc("%PDF-1.4\n"); |
||
437 | break; |
||
438 | case 15: |
||
439 | PutDoc("%PDF-1.5\n"); |
||
440 | break; |
||
441 | } |
||
442 | if (Options->Version == 12) |
||
443 | ObjCounter++; |
||
444 | PutDoc("%"+QString(QChar(199))+QString(QChar(236))+QString(QChar(143))+QString(QChar(162))+"\n"); |
||
445 | StartObj(1); |
||
446 | PutDoc("<<\n/Type /Catalog\n/Outlines 3 0 R\n/Pages 4 0 R\n/Dests 5 0 R\n/AcroForm 6 0 R\n/Names 7 0 R\n/Threads 8 0 R\n"); |
||
447 | if ((Options->Version == 15) && (Options->useLayers)) |
||
448 | PutDoc("/OCProperties 9 0 R\n"); |
||
449 | if (Options->Version == 12) |
||
450 | PutDoc("/OutputIntents [ "+IToStr(ObjCounter-1)+" 0 R ]\n"); |
||
451 | if (doc->currentPageLayout == doublePage) |
||
452 | { |
||
453 | PutDoc("/PageLayout "); |
||
454 | if (doc->pageSets[doc->currentPageLayout].FirstPage) |
||
455 | PutDoc("/TwoColumnLeft\n"); |
||
456 | else |
||
457 | PutDoc("/TwoColumnRight\n"); |
||
458 | } |
||
459 | if (Options->PresentMode) |
||
460 | PutDoc("/PageMode /FullScreen\n"); |
||
461 | else |
||
462 | { |
||
463 | if ((Options->Version == 15) && (Options->useLayers)) |
||
464 | PutDoc("/PageMode /UseOC\n"); |
||
465 | } |
||
466 | PutDoc("/ViewerPreferences\n<<\n/PageDirection "); |
||
467 | PutDoc( Options->Binding == 0 ? "/L2R\n" : "/R2L\n"); |
||
468 | PutDoc(" >>\n>>\nendobj\n"); |
||
3829 | cbradney | 469 | QString IDg(Datum); |
3133 | fschmid | 470 | IDg += Options->Datei; |
471 | IDg += "Scribus "+QString(VERSION); |
||
472 | IDg += "Libpdf for Scribus "+QString(VERSION); |
||
473 | IDg += doc->documentInfo.getTitle(); |
||
474 | IDg += doc->documentInfo.getAuthor(); |
||
475 | IDg += "/False"; |
||
476 | FileID = ComputeMD5(IDg); |
||
477 | if (Options->Encrypt) |
||
478 | { |
||
479 | KeyLen = Options->Version == 14 ? 16 : 5; |
||
480 | CalcOwnerKey(Options->PassOwner, Options->PassUser); |
||
481 | CalcUserKey(Options->PassUser, Options->Permissions); |
||
482 | for (uint cl2 = 0; cl2 < 32; ++cl2) |
||
483 | ok += QChar(OwnerKey[cl2]); |
||
484 | if (KeyLen > 5) |
||
485 | { |
||
486 | for (uint cl3 = 0; cl3 < 16; ++cl3) |
||
487 | uk += QChar(UserKey[cl3]); |
||
488 | for (uint cl3r = 0; cl3r < 16; ++cl3r) |
||
489 | uk += QChar(KeyGen[cl3r]); |
||
490 | } |
||
491 | else |
||
492 | { |
||
493 | for (uint cl = 0; cl < 32; ++cl) |
||
494 | uk += QChar(UserKey[cl]); |
||
495 | } |
||
496 | } |
||
497 | QDate d = QDate::currentDate(); |
||
498 | Datum = "D:"; |
||
499 | tmp.sprintf("%4d", d.year()); |
||
500 | tmp.replace(QRegExp(" "), "0"); |
||
501 | Datum += tmp; |
||
502 | tmp.sprintf("%2d", d.month()); |
||
503 | tmp.replace(QRegExp(" "), "0"); |
||
504 | Datum += tmp; |
||
505 | tmp.sprintf("%2d", d.day()); |
||
506 | tmp.replace(QRegExp(" "), "0"); |
||
507 | Datum += tmp; |
||
508 | QTime t = QTime::currentTime(); |
||
509 | tmp = t.toString(); |
||
510 | tmp.replace(QRegExp(":"), ""); |
||
511 | Datum += tmp; |
||
512 | StartObj(2); |
||
513 | PutDoc("<<\n/Creator "+EncString("(Scribus "+QString(VERSION)+")",2)+"\n"); |
||
514 | PutDoc("/Producer "+EncString("(Libpdf for Scribus "+QString(VERSION)+")",2)+"\n"); |
||
515 | PutDoc("/Title "+EncString("("+doc->documentInfo.getTitle()+")",2)+"\n"); |
||
516 | PutDoc("/Author "+EncString("("+doc->documentInfo.getAuthor()+")",2)+"\n"); |
||
517 | PutDoc("/Keywords "+EncString("("+doc->documentInfo.getKeywords()+")",2)+"\n"); |
||
518 | PutDoc("/CreationDate "+EncString("("+Datum+")",2)+"\n"); |
||
519 | PutDoc("/ModDate "+EncString("("+Datum+")",2)+"\n"); |
||
520 | if (Options->Version == 12) |
||
521 | PutDoc("/GTS_PDFXVersion (PDF/X-3:2002)\n"); |
||
522 | PutDoc("/Trapped /False\n>>\nendobj\n"); |
||
523 | for (int t = 0; t < 6; ++t) |
||
524 | XRef.append(Dokument); |
||
525 | if ((Options->Version == 15) && (Options->useLayers)) |
||
526 | XRef.append(Dokument); |
||
527 | if (Options->Version == 12) |
||
528 | XRef.append(Dokument); |
||
529 | if (Options->Encrypt) |
||
530 | { |
||
531 | StartObj(ObjCounter); |
||
532 | Encrypt = ObjCounter; |
||
533 | ObjCounter++; |
||
534 | PutDoc("<<\n/Filter /Standard\n"); |
||
535 | PutDoc( KeyLen > 5 ? "/R 3\n/V 2\n/Length 128\n" : "/R 2\n/V 1\n"); |
||
536 | PutDoc("/O <"+String2Hex(&ok)+">\n"); |
||
537 | PutDoc("/U <"+String2Hex(&uk)+">\n"); |
||
538 | PutDoc("/P "+IToStr(Options->Permissions)+"\n>>\nendobj\n"); |
||
539 | } |
||
540 | RealFonts = DocFonts; |
||
3544 | avox | 541 | QMap<QString,int> ReallyUsed; |
3133 | fschmid | 542 | ReallyUsed.clear(); |
543 | PageItem* pgit; |
||
544 | for (uint c = 0; c < doc->FrameItems.count(); ++c) |
||
545 | { |
||
546 | pgit = doc->FrameItems.at(c); |
||
547 | if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) |
||
548 | { |
||
549 | for (uint e = 0; e < pgit->itemText.count(); ++e) |
||
550 | { |
||
3544 | avox | 551 | ReallyUsed.insert(pgit->itemText.at(e)->cfont->scName(), DocFonts[pgit->itemText.at(e)->cfont->scName()]); |
3133 | fschmid | 552 | } |
553 | } |
||
554 | } |
||
555 | for (uint c = 0; c < doc->MasterItems.count(); ++c) |
||
556 | { |
||
557 | pgit = doc->MasterItems.at(c); |
||
558 | if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) |
||
559 | { |
||
560 | for (uint e = 0; e < pgit->itemText.count(); ++e) |
||
561 | { |
||
3544 | avox | 562 | ReallyUsed.insert(pgit->itemText.at(e)->cfont->scName(), DocFonts[pgit->itemText.at(e)->cfont->scName()]); |
3133 | fschmid | 563 | } |
564 | } |
||
565 | } |
||
3727 | cbradney | 566 | for (uint d = 0; d < doc->Items->count(); ++d) |
3133 | fschmid | 567 | { |
3727 | cbradney | 568 | pgit = doc->Items->at(d); |
3133 | fschmid | 569 | if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) |
570 | { |
||
571 | for (uint e = 0; e < pgit->itemText.count(); ++e) |
||
572 | { |
||
3544 | avox | 573 | ReallyUsed.insert(pgit->itemText.at(e)->cfont->scName(), DocFonts[pgit->itemText.at(e)->cfont->scName()]); |
3133 | fschmid | 574 | } |
575 | } |
||
576 | } |
||
3544 | avox | 577 | QMap<QString,int>::Iterator it; |
3133 | fschmid | 578 | a = 0; |
579 | for (it = ReallyUsed.begin(); it != ReallyUsed.end(); ++it) |
||
580 | { |
||
581 | Foi::FontFormat fformat = AllFonts[it.key()]->formatCode; |
||
582 | if ((AllFonts[it.key()]->isOTF) || (!AllFonts[it.key()]->HasNames) || (AllFonts[it.key()]->Subset) || (Options->SubsetList.contains(it.key()))) |
||
583 | { |
||
3829 | cbradney | 584 | QString fon(""); |
3133 | fschmid | 585 | QMap<uint,FPointArray>::Iterator ig; |
586 | for (ig = AllFonts[it.key()]->RealGlyphs.begin(); ig != AllFonts[it.key()]->RealGlyphs.end(); ++ig) |
||
587 | { |
||
588 | FPoint np, np1, np2; |
||
589 | bool nPath = true; |
||
590 | if (ig.data().size() > 3) |
||
591 | { |
||
592 | FPointArray gly = ig.data().copy(); |
||
593 | QWMatrix mat; |
||
594 | mat.scale(0.1, 0.1); |
||
595 | gly.map(mat); |
||
596 | for (uint poi = 0; poi < gly.size()-3; poi += 4) |
||
597 | { |
||
598 | if (gly.point(poi).x() > 900000) |
||
599 | { |
||
600 | fon += "h\n"; |
||
601 | nPath = true; |
||
602 | continue; |
||
603 | } |
||
604 | if (nPath) |
||
605 | { |
||
606 | np = gly.point(poi); |
||
607 | fon += FToStr(np.x())+" "+FToStr(-np.y())+" m\n"; |
||
608 | nPath = false; |
||
609 | } |
||
610 | np = gly.point(poi+1); |
||
611 | np1 = gly.point(poi+3); |
||
612 | np2 = gly.point(poi+2); |
||
613 | fon += FToStr(np.x()) + " " + FToStr(-np.y()) + " " + |
||
614 | FToStr(np1.x()) + " " + FToStr(-np1.y()) + " " + |
||
615 | FToStr(np2.x()) + " " + FToStr(-np2.y()) + " c\n"; |
||
616 | } |
||
617 | fon += "h f*\n"; |
||
618 | StartObj(ObjCounter); |
||
619 | ObjCounter++; |
||
620 | np = getMinClipF(&gly); |
||
621 | np1 = getMaxClipF(&gly); |
||
622 | PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n"); |
||
623 | PutDoc("/BBox [ "+FToStr(np.x())+" "+FToStr(-np.y())+" "+FToStr(np1.x())+ " "+FToStr(-np1.y())+" ]\n"); |
||
624 | PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n"); |
||
625 | PutDoc(">>\n"); |
||
626 | if ((Options->Compress) && (CompAvail)) |
||
627 | fon = CompressStr(&fon); |
||
628 | PutDoc("/Length "+IToStr(fon.length()+1)); |
||
629 | if ((Options->Compress) && (CompAvail)) |
||
630 | PutDoc("\n/Filter /FlateDecode"); |
||
631 | PutDoc(" >>\nstream\n"+EncStream(&fon, ObjCounter-1)+"\nendstream\nendobj\n"); |
||
3440 | fschmid | 632 | Seite.XObjects[AllFonts[it.key()]->RealName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+IToStr(ig.key())] = ObjCounter-1; |
3133 | fschmid | 633 | fon = ""; |
634 | } |
||
635 | } |
||
636 | AllFonts[it.key()]->RealGlyphs.clear(); |
||
637 | } |
||
638 | else |
||
639 | { |
||
640 | UsedFontsP.insert(it.key(), "/Fo"+IToStr(a)); |
||
641 | if ((fformat == Foi::PFB) && (Options->EmbedList.contains(it.key()))) |
||
642 | { |
||
3829 | cbradney | 643 | QString fon(""); |
3133 | fschmid | 644 | StartObj(ObjCounter); |
645 | QByteArray bb; |
||
646 | AllFonts[it.key()]->RawData(bb); |
||
647 | uint posi; |
||
648 | for (posi = 6; posi < bb.size(); ++posi) |
||
649 | { |
||
650 | if ((bb[posi] == static_cast<char>(0x80)) && (static_cast<int>(bb[posi+1]) == 2)) |
||
651 | break; |
||
652 | fon += QChar(bb[posi]); |
||
653 | } |
||
654 | int len1 = fon.length(); |
||
655 | uint ulen; |
||
656 | ulen = bb[posi+2] & 0xff; |
||
657 | ulen |= (bb[posi+3] << 8) & 0xff00; |
||
658 | ulen |= (bb[posi+4] << 16) & 0xff0000; |
||
659 | ulen |= (bb[posi+5] << 24) & 0xff000000; |
||
660 | if (ulen > bb.size()) |
||
661 | ulen = bb.size()-7; |
||
662 | posi += 6; |
||
663 | for (uint j = 0; j < ulen; ++j) |
||
664 | fon += QChar(bb[posi++]); |
||
665 | posi += 6; |
||
666 | int len2 = fon.length()-len1; |
||
667 | for (uint j = posi; j < bb.size(); ++j) |
||
668 | { |
||
669 | if ((bb[j] == static_cast<char>(0x80)) && (static_cast<int>(bb[j+1]) == 3)) |
||
670 | break; |
||
671 | if (bb[j] == '\r') |
||
672 | fon += "\n"; |
||
673 | else |
||
674 | fon += QChar(bb[j]); |
||
675 | } |
||
676 | int len3 = fon.length()-len2-len1; |
||
677 | if ((Options->Compress) && (CompAvail)) |
||
678 | fon = CompressStr(&fon); |
||
679 | PutDoc("<<\n/Length "+IToStr(fon.length()+1)+"\n"); |
||
680 | PutDoc("/Length1 "+IToStr(len1)+"\n"); |
||
681 | PutDoc("/Length2 "+IToStr(len2)+"\n"); |
||
682 | PutDoc("/Length3 "+IToStr(len3)+"\n"); |
||
683 | if ((Options->Compress) && (CompAvail)) |
||
684 | PutDoc("/Filter /FlateDecode\n"); |
||
685 | PutDoc(">>\nstream\n"+EncStream(&fon,ObjCounter)+"\nendstream\nendobj\n"); |
||
686 | ObjCounter++; |
||
687 | } |
||
688 | if ((fformat == Foi::PFA) && (Options->EmbedList.contains(it.key()))) |
||
689 | { |
||
3829 | cbradney | 690 | QString fon(""); |
691 | QString fon2(""); |
||
692 | QString tm(""); |
||
3133 | fschmid | 693 | uint value; |
694 | bool ok = true; |
||
695 | StartObj(ObjCounter); |
||
696 | AllFonts[it.key()]->EmbedFont(fon); |
||
697 | int len1 = fon.find("eexec")+5; |
||
698 | fon2 = fon.left(len1)+"\n"; |
||
699 | int len2 = fon.find("0000000000000000000000000"); |
||
700 | if (len2 == -1) |
||
701 | len2 = fon.length()+1; |
||
702 | int count = 0; |
||
703 | for (int xx = len1; xx < len2-1; ++xx) |
||
704 | { |
||
705 | tm = fon.at(xx); |
||
706 | if ((tm == QChar(13)) || (tm == QChar(10))) |
||
707 | continue; |
||
708 | xx++; |
||
709 | count++; |
||
710 | tm += fon.at(xx); |
||
711 | value = tm.toUInt(&ok, 16); |
||
712 | fon2 += QChar(value); |
||
713 | } |
||
714 | fon2 += fon.mid(len2); |
||
715 | if ((Options->Compress) && (CompAvail)) |
||
716 | fon2 = CompressStr(&fon2); |
||
717 | PutDoc("<<\n/Length "+IToStr(fon2.length()+1)+"\n"); |
||
718 | PutDoc("/Length1 "+IToStr(len1+1)+"\n"); |
||
719 | PutDoc("/Length2 "+IToStr(count)+"\n"); |
||
720 | PutDoc(static_cast<int>(fon.length()-len2) == -1 ? QString("/Length3 0\n") : "/Length3 "+IToStr(fon.length()-len2)+"\n"); |
||
721 | if ((Options->Compress) && (CompAvail)) |
||
722 | PutDoc("/Filter /FlateDecode\n"); |
||
723 | PutDoc(">>\nstream\n"+EncStream(&fon2, ObjCounter)+"\nendstream\nendobj\n"); |
||
724 | ObjCounter++; |
||
725 | } |
||
726 | if ((fformat == Foi::SFNT || fformat == Foi::TTCF) && (Options->EmbedList.contains(it.key()))) |
||
727 | { |
||
3829 | cbradney | 728 | QString fon(""); |
3133 | fschmid | 729 | StartObj(ObjCounter); |
730 | QByteArray bb; |
||
731 | AllFonts[it.key()]->RawData(bb); |
||
732 | //AV: += and append() dont't work because they stop at '\0' :-( |
||
733 | for (unsigned int i=0; i < bb.size(); i++) |
||
734 | fon += QChar(bb[i]); |
||
735 | int len = fon.length(); |
||
736 | if ((Options->Compress) && (CompAvail)) |
||
737 | fon = CompressStr(&fon); |
||
738 | //qDebug(QString("sfnt data: size=%1 before=%2 compressed=%3").arg(bb.size()).arg(len).arg(fon.length())); |
||
739 | PutDoc("<<\n/Length "+IToStr(fon.length()+1)+"\n"); |
||
740 | PutDoc("/Length1 "+IToStr(len)+"\n"); |
||
741 | if ((Options->Compress) && (CompAvail)) |
||
742 | PutDoc("/Filter /FlateDecode\n"); |
||
743 | PutDoc(">>\nstream\n"+EncStream(&fon, ObjCounter)+"\nendstream\nendobj\n"); |
||
744 | ObjCounter++; |
||
745 | } |
||
746 | StartObj(ObjCounter); |
||
747 | PutDoc("<<\n/Type /FontDescriptor\n"); |
||
3440 | fschmid | 748 | PutDoc("/FontName /"+AllFonts[it.key()]->RealName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n"); |
3133 | fschmid | 749 | PutDoc("/FontBBox [ "+AllFonts[it.key()]->FontBBox+" ]\n"); |
750 | PutDoc("/Flags "); |
||
3544 | avox | 751 | //FIXME: isItalic() should be queried from Foi, not from Qt -- AV |
752 | //QFontInfo fo = QFontInfo(it.data()); |
||
3133 | fschmid | 753 | int pfl = 0; |
754 | if (AllFonts[it.key()]->IsFixedPitch) |
||
755 | pfl = pfl ^ 1; |
||
3544 | avox | 756 | //if (fo.italic()) |
757 | if (AllFonts[it.key()]->ItalicAngle != "0") |
||
3133 | fschmid | 758 | pfl = pfl ^ 64; |
759 | // pfl = pfl ^ 4; |
||
760 | pfl = pfl ^ 32; |
||
761 | PutDoc(IToStr(pfl)+"\n"); |
||
762 | PutDoc("/Ascent "+AllFonts[it.key()]->Ascent+"\n"); |
||
763 | PutDoc("/Descent "+AllFonts[it.key()]->Descender+"\n"); |
||
764 | PutDoc("/CapHeight "+AllFonts[it.key()]->CapHeight+"\n"); |
||
765 | PutDoc("/ItalicAngle "+AllFonts[it.key()]->ItalicAngle+"\n"); |
||
766 | PutDoc("/StemV "+AllFonts[it.key()]->StdVW+"\n"); |
||
767 | if ((fformat == Foi::SFNT || fformat == Foi::TTCF) && (Options->EmbedList.contains(it.key()))) |
||
768 | PutDoc("/FontFile2 "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
769 | if ((fformat == Foi::PFB) && (Options->EmbedList.contains(it.key()))) |
||
770 | PutDoc("/FontFile "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
771 | if ((fformat == Foi::PFA) && (Options->EmbedList.contains(it.key()))) |
||
772 | PutDoc("/FontFile "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
773 | PutDoc(">>\nendobj\n"); |
||
774 | ObjCounter++; |
||
775 | /* if (!FT_Has_PS_Glyph_Names(AllFonts[it.key()]) |
||
776 | { |
||
777 | StartObj(ObjCounter); |
||
778 | int chCount = 31; |
||
779 | PutDoc("[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "); |
||
780 | for (int ww = 31; ww < 256; ++ww) |
||
781 | { |
||
782 | PutDoc(IToStr(static_cast<int>(AllFonts[it.key()]->CharWidth[itg.key()]* |
||
783 | 1000))+" "); |
||
784 | if (itg == gl.end()) |
||
785 | break; |
||
786 | ++itg; |
||
787 | chCount++; |
||
788 | } |
||
789 | PutDoc("]\nendobj\n"); |
||
790 | ObjCounter++; |
||
791 | // put widths object |
||
792 | // encoding dictionary w/ base encoding w/o differences |
||
793 | StartObj(ObjCounter); |
||
794 | PutDoc("<<\n/Type /Font\n/Subtype "); |
||
795 | PutDoc((fformat == Foi::SFNT || fformat == Foi::TTCF) ? "/TrueType\n" : "/Type1\n"); |
||
796 | PutDoc("/Name /Fo"+IToStr(a)+"\n"); |
||
3304 | fschmid | 797 | PutDoc("/BaseFont /"+AllFonts[it.key()]->RealName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "" )+"\n"); |
3133 | fschmid | 798 | //cf. widths: |
799 | PutDoc("/FirstChar 0\n"); |
||
800 | PutDoc("/LastChar "+IToStr(chCount-1)+"\n"); |
||
801 | PutDoc("/Widths "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
802 | PutDoc("/FontDescriptor "+IToStr(ObjCounter-2)+" 0 R\n"); |
||
803 | PutDoc(">>\nendobj\n"); |
||
804 | Seite.FObjects["Fo"+IToStr(a)] = ObjCounter; |
||
805 | ObjCounter++; |
||
806 | } |
||
807 | else */ |
||
808 | // { |
||
809 | GListeInd gl; |
||
810 | GlyIndex(AllFonts[it.key()], &gl); |
||
811 | GlyphsIdxOfFont.insert(it.key(), gl); |
||
812 | uint FontDes = ObjCounter - 1; |
||
813 | GListeInd::Iterator itg; |
||
814 | itg = gl.begin(); |
||
815 | GListeInd::Iterator itg2; |
||
816 | itg2 = gl.begin(); |
||
817 | uint Fcc = gl.count() / 224; |
||
818 | if ((gl.count() % 224) != 0) |
||
819 | Fcc += 1; |
||
820 | for (uint Fc = 0; Fc < Fcc; ++Fc) |
||
821 | { |
||
822 | StartObj(ObjCounter); |
||
823 | int chCount = 31; |
||
824 | PutDoc("[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "); |
||
825 | for (int ww = 31; ww < 256; ++ww) |
||
826 | { |
||
827 | PutDoc(IToStr(static_cast<int>(AllFonts[it.key()]->CharWidth[itg.key()]* 1000))+" "); |
||
828 | if (itg == gl.end()) |
||
829 | break; |
||
830 | ++itg; |
||
831 | chCount++; |
||
832 | } |
||
833 | PutDoc("]\nendobj\n"); |
||
834 | ObjCounter++; |
||
835 | StartObj(ObjCounter); |
||
836 | ObjCounter++; |
||
837 | PutDoc("<< /Type /Encoding\n"); |
||
838 | // PutDoc("/BaseEncoding /" + AllFonts[it.key()]->FontEnc + "\n"); |
||
839 | PutDoc("/Differences [ 32\n"); |
||
840 | int crc = 0; |
||
841 | for (int ww2 = 32; ww2 < 256; ++ww2) |
||
842 | { |
||
843 | PutDoc(itg2.data().Name+" "); |
||
844 | if (itg2 == gl.end()) |
||
845 | break; |
||
846 | ++itg2; |
||
847 | crc++; |
||
848 | if (crc > 8) |
||
849 | { |
||
850 | PutDoc("\n"); |
||
851 | crc = 0; |
||
852 | } |
||
853 | } |
||
854 | PutDoc("]\n"); |
||
855 | |||
856 | PutDoc(">>\nendobj\n"); |
||
857 | StartObj(ObjCounter); |
||
858 | PutDoc("<<\n/Type /Font\n/Subtype "); |
||
859 | PutDoc((fformat == Foi::SFNT || fformat == Foi::TTCF) ? "/TrueType\n" : "/Type1\n"); |
||
860 | PutDoc("/Name /Fo"+IToStr(a)+"S"+IToStr(Fc)+"\n"); |
||
3440 | fschmid | 861 | PutDoc("/BaseFont /"+AllFonts[it.key()]->RealName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n"); |
3133 | fschmid | 862 | PutDoc("/FirstChar 0\n"); |
863 | PutDoc("/LastChar "+IToStr(chCount-1)+"\n"); |
||
864 | PutDoc("/Widths "+IToStr(ObjCounter-2)+" 0 R\n"); |
||
865 | PutDoc("/Encoding "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
866 | PutDoc("/FontDescriptor "+IToStr(FontDes)+" 0 R\n"); |
||
867 | PutDoc(">>\nendobj\n"); |
||
868 | Seite.FObjects["Fo"+IToStr(a)+"S"+IToStr(Fc)] = ObjCounter; |
||
869 | ObjCounter++; |
||
870 | } // for(Fc) |
||
871 | // } // FT_Has_PS_Glyph_Names |
||
872 | } |
||
873 | a++; |
||
874 | } |
||
875 | if (Options->UseLPI) |
||
876 | { |
||
877 | StartObj(ObjCounter); |
||
878 | PutDoc("<<\n/Type /Halftone\n/HalftoneType 5\n"); |
||
879 | QMap<QString,LPIData>::Iterator itlp; |
||
880 | for (itlp = Options->LPISettings.begin(); itlp != Options->LPISettings.end(); ++itlp) |
||
881 | { |
||
882 | PutDoc("/"+itlp.key()+"\n<<\n/Type /Halftone\n/HalftoneType 1\n/Frequency "); |
||
883 | PutDoc(IToStr(itlp.data().Frequency)+"\n/Angle "+IToStr(itlp.data().Angle)+"\n/SpotFunction "); |
||
3829 | cbradney | 884 | QString func (""); |
3133 | fschmid | 885 | switch (itlp.data().SpotFunc) |
886 | { |
||
887 | case 0: |
||
888 | func = "/SimpleDot"; |
||
889 | break; |
||
890 | case 1: |
||
891 | func = "/Line"; |
||
892 | break; |
||
893 | case 2: |
||
894 | func = "/Round"; |
||
895 | break; |
||
896 | case 3: |
||
897 | func = "/Ellipse"; |
||
898 | break; |
||
899 | default: |
||
900 | func = "/SimpleDot"; |
||
901 | break; |
||
902 | } |
||
903 | PutDoc(func+"\n>>\n"); |
||
904 | } |
||
905 | PutDoc("/Default\n<<\n/Type /Halftone\n/HalftoneType 1\n/Frequency 50\n/Angle 45\n/SpotFunction /Round\n>>\n"); |
||
906 | PutDoc(">>\nendobj\n"); |
||
907 | ObjCounter++; |
||
908 | StartObj(ObjCounter); |
||
909 | HTName = ResNam+IToStr(ResCount); |
||
910 | Transpar[HTName] = ObjCounter; |
||
911 | PutDoc("<< /Type /ExtGState\n/HT "+IToStr(ObjCounter-1)+" 0 R\n>>\nendobj\n"); |
||
912 | ResCount++; |
||
913 | ObjCounter++; |
||
914 | } |
||
915 | #ifdef HAVE_CMS |
||
916 | if ((CMSuse) && (Options->UseProfiles)) |
||
917 | { |
||
918 | StartObj(ObjCounter); |
||
919 | ObjCounter++; |
||
920 | QString dataP; |
||
921 | struct ICCD dataD; |
||
922 | loadText(ScApp->InputProfiles[Options->SolidProf], &dataP); |
||
923 | PutDoc("<<\n"); |
||
924 | if ((Options->Compress) && (CompAvail)) |
||
925 | { |
||
926 | PutDoc("/Filter /FlateDecode\n"); |
||
927 | dataP = CompressStr(&dataP); |
||
928 | } |
||
929 | PutDoc("/Length "+IToStr(dataP.length()+1)+"\n"); |
||
930 | PutDoc("/N "+IToStr(Options->SComp)+"\n"); |
||
931 | PutDoc(">>\nstream\n"+EncStream(&dataP, ObjCounter-1)+"\nendstream\nendobj\n"); |
||
932 | StartObj(ObjCounter); |
||
933 | dataD.ResName = ResNam+IToStr(ResCount); |
||
934 | dataD.ICCArray = "[ /ICCBased "+IToStr(ObjCounter-1)+" 0 R ]"; |
||
935 | dataD.ResNum = ObjCounter; |
||
936 | ICCProfiles[Options->SolidProf] = dataD; |
||
937 | PutDoc("[ /ICCBased "+IToStr(ObjCounter-1)+" 0 R ]\n"); |
||
938 | PutDoc("endobj\n"); |
||
939 | ResCount++; |
||
940 | ObjCounter++; |
||
941 | } |
||
942 | #endif |
||
943 | if (((Options->isGrayscale == false) && (Options->UseRGB == false)) && (Options->UseSpotColors)) |
||
944 | { |
||
945 | doc->getUsedColors(colorsToUse); |
||
946 | ColorList::Iterator itf; |
||
947 | for (itf = colorsToUse.begin(); itf != colorsToUse.end(); ++itf) |
||
948 | { |
||
949 | if ((colorsToUse[itf.key()].isSpotColor()) || (colorsToUse[itf.key()].isRegistrationColor())) |
||
950 | { |
||
951 | int cc, cm, cy, ck; |
||
952 | struct SpotC spotD; |
||
953 | colorsToUse[itf.key()].getCMYK(&cc, &cm, &cy, &ck); |
||
954 | QString colorDesc = "{\ndup "+FToStr(static_cast<double>(cc) / 255)+"\nmul exch dup "; |
||
955 | colorDesc += FToStr(static_cast<double>(cm) / 255)+"\nmul exch dup "; |
||
956 | colorDesc += FToStr(static_cast<double>(cy) / 255)+"\nmul exch "; |
||
957 | colorDesc += FToStr(static_cast<double>(ck) / 255)+" mul }"; |
||
958 | StartObj(ObjCounter); |
||
959 | ObjCounter++; |
||
960 | PutDoc("<<\n/FunctionType 4\n"); |
||
961 | PutDoc("/Domain [0.0 1.0]\n"); |
||
962 | PutDoc("/Range [0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]\n"); |
||
963 | PutDoc("/Length "+IToStr(colorDesc.length()+1)+"\n"); |
||
964 | PutDoc(">>\nstream\n"+EncStream(&colorDesc, ObjCounter-1)+"\nendstream\nendobj\n"); |
||
965 | StartObj(ObjCounter); |
||
966 | PutDoc("[ /Separation /"); |
||
967 | if (colorsToUse[itf.key()].isRegistrationColor()) |
||
968 | PutDoc("All"); |
||
969 | else |
||
3440 | fschmid | 970 | PutDoc(itf.key().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ).replace("#", "_")); |
3133 | fschmid | 971 | PutDoc(" /DeviceCMYK "+IToStr(ObjCounter-1)+" 0 R ]\nendobj\n"); |
972 | spotD.ResName = spotNam+IToStr(spotCount); |
||
973 | spotD.ResNum = ObjCounter; |
||
974 | spotMap.insert(itf.key(), spotD); |
||
975 | spotCount++; |
||
976 | ObjCounter++; |
||
977 | } |
||
978 | } |
||
979 | } |
||
980 | if ((Options->Version == 15) && (Options->useLayers)) |
||
981 | { |
||
982 | struct Layer ll; |
||
983 | struct OCGInfo ocg; |
||
984 | ll.isPrintable = false; |
||
985 | ll.LNr = 0; |
||
986 | int Lnr = 0; |
||
3829 | cbradney | 987 | QString ocgNam("oc"); |
988 | uint docLayersCount=doc->Layers.count(); |
||
989 | for (uint la = 0; la < docLayersCount; ++la) |
||
3133 | fschmid | 990 | { |
3829 | cbradney | 991 | QString tmp(""); |
3133 | fschmid | 992 | Level2Layer(doc, &ll, Lnr); |
993 | ocg.Name = ocgNam+tmp.setNum(ll.LNr); |
||
994 | ocg.ObjNum = ObjCounter; |
||
995 | ocg.visible = ll.isViewable; |
||
996 | OCGEntries.insert(ll.Name, ocg); |
||
997 | StartObj(ObjCounter); |
||
998 | ObjCounter++; |
||
999 | PutDoc("<<\n"); |
||
1000 | PutDoc("/Type /OCG\n"); |
||
1001 | PutDoc("/Name ("+ll.Name+")\n"); |
||
1002 | PutDoc(">>\nendobj\n"); |
||
1003 | Lnr++; |
||
1004 | } |
||
1005 | } |
||
1006 | return true; |
||
1007 | } |
||
1008 | |||
1009 | void PDFlib::PDF_TemplatePage(Page* pag, bool ) |
||
1010 | { |
||
1011 | QString tmp; |
||
1012 | ActPageP = pag; |
||
1013 | PageItem* ite; |
||
1014 | QPtrList<PageItem> PItems; |
||
1015 | int Lnr = 0; |
||
1016 | struct Layer ll; |
||
1017 | ll.isPrintable = false; |
||
1018 | ll.LNr = 0; |
||
1019 | Inhalt = ""; |
||
1020 | Seite.AObjects.clear(); |
||
1021 | for (uint la = 0; la < doc->Layers.count(); ++la) |
||
1022 | { |
||
1023 | Level2Layer(doc, &ll, Lnr); |
||
1024 | PItems = doc->MasterItems; |
||
1025 | if (ll.isPrintable) |
||
1026 | { |
||
1027 | if ((Options->Version == 15) && (Options->useLayers)) |
||
1028 | PutPage("/OC /"+OCGEntries[ll.Name].Name+" BDC\n"); |
||
1029 | for (uint a = 0; a < PItems.count(); ++a) |
||
1030 | { |
||
1031 | Inhalt = ""; |
||
1032 | ite =PItems.at(a); |
||
1033 | if (ite->LayerNr != ll.LNr) |
||
1034 | continue; |
||
3200 | cbradney | 1035 | int x = static_cast<int>(pag->xOffset()); |
1036 | int y = static_cast<int>(pag->yOffset()); |
||
1037 | int w = static_cast<int>(pag->width()); |
||
1038 | int h1 = static_cast<int>(pag->height()); |
||
3133 | fschmid | 1039 | int x2 = static_cast<int>(ite->BoundingX - ite->Pwidth / 2.0); |
1040 | int y2 = static_cast<int>(ite->BoundingY - ite->Pwidth / 2.0); |
||
1041 | int w2 = static_cast<int>(ite->BoundingW + ite->Pwidth); |
||
1042 | int h2 = static_cast<int>(ite->BoundingH + ite->Pwidth); |
||
1043 | if (!QRect(x, y, w, h1).intersects(QRect(x2, y2, w2, h2))) |
||
1044 | continue; |
||
1045 | if (ite->ChangedMasterItem) |
||
1046 | continue; |
||
3200 | cbradney | 1047 | if ((!pag->PageNam.isEmpty()) && (ite->OwnPage != static_cast<int>(pag->pageNr())) && (ite->OwnPage != -1)) |
3133 | fschmid | 1048 | continue; |
1049 | PutPage("q\n"); |
||
1050 | if (((ite->fillTransparency() != 0) || (ite->lineTransparency() != 0)) && (Options->Version >= 14)) |
||
1051 | PutPage(PDF_Transparenz(ite)); |
||
1052 | if ((ite->isBookmark) && (Options->Bookmarks)) |
||
3200 | cbradney | 1053 | PDF_Bookmark(ite->BMnr, pag->height() - (ite->Ypos - pag->yOffset())); |
3133 | fschmid | 1054 | if (!ite->printable() || ((ite->itemType() == PageItem::TextFrame) && (!pag->PageNam.isEmpty()))) |
1055 | { |
||
1056 | PutPage("Q\n"); |
||
1057 | continue; |
||
1058 | } |
||
1059 | if (ite->fillColor() != "None") |
||
1060 | PutPage(putColor(ite->fillColor(), ite->fillShade(), true)); |
||
1061 | if (ite->lineColor() != "None") |
||
1062 | PutPage(putColor(ite->lineColor(), ite->lineShade(), false)); |
||
1063 | Inhalt += FToStr(fabs(ite->Pwidth))+" w\n"; |
||
1064 | if (ite->DashValues.count() != 0) |
||
1065 | { |
||
1066 | PutPage("[ "); |
||
1067 | QValueList<double>::iterator it; |
||
1068 | for ( it = ite->DashValues.begin(); it != ite->DashValues.end(); ++it ) |
||
1069 | { |
||
1070 | int da = static_cast<int>(*it); |
||
1071 | if (da != 0) |
||
1072 | PutPage(IToStr(da)+" "); |
||
1073 | } |
||
1074 | PutPage("] "+IToStr(static_cast<int>(ite->DashOffset))+" d\n"); |
||
1075 | } |
||
1076 | else |
||
1077 | { |
||
1078 | QString Dt = FToStr(QMAX(2*fabs(ite->Pwidth), 1)); |
||
1079 | QString Da = FToStr(QMAX(6*fabs(ite->Pwidth), 1)); |
||
1080 | switch (ite->PLineArt) |
||
1081 | { |
||
1082 | case Qt::SolidLine: |
||
1083 | PutPage("[] 0 d\n"); |
||
1084 | break; |
||
1085 | case Qt::DashLine: |
||
1086 | PutPage("["+Da+" "+Dt+"] 0 d\n"); |
||
1087 | break; |
||
1088 | case Qt::DotLine: |
||
1089 | PutPage("["+Dt+"] 0 d\n"); |
||
1090 | break; |
||
1091 | case Qt::DashDotLine: |
||
1092 | PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n"); |
||
1093 | break; |
||
1094 | case Qt::DashDotDotLine: |
||
1095 | PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n"); |
||
1096 | break; |
||
1097 | default: |
||
1098 | PutPage("[] 0 d\n"); |
||
1099 | break; |
||
1100 | } |
||
1101 | } |
||
1102 | switch (ite->PLineEnd) |
||
1103 | { |
||
1104 | case Qt::FlatCap: |
||
1105 | PutPage("0 J\n"); |
||
1106 | break; |
||
1107 | case Qt::SquareCap: |
||
1108 | PutPage("2 J\n"); |
||
1109 | break; |
||
1110 | case Qt::RoundCap: |
||
1111 | PutPage("1 J\n"); |
||
1112 | break; |
||
1113 | default: |
||
1114 | PutPage("0 J\n"); |
||
1115 | break; |
||
1116 | } |
||
1117 | switch (ite->PLineJoin) |
||
1118 | { |
||
1119 | case Qt::MiterJoin: |
||
1120 | PutPage("0 j\n"); |
||
1121 | break; |
||
1122 | case Qt::BevelJoin: |
||
1123 | PutPage("2 j\n"); |
||
1124 | break; |
||
1125 | case Qt::RoundJoin: |
||
1126 | PutPage("1 j\n"); |
||
1127 | break; |
||
1128 | default: |
||
1129 | PutPage("0 j\n"); |
||
1130 | break; |
||
1131 | } |
||
3200 | cbradney | 1132 | PutPage("1 0 0 1 "+FToStr(ite->Xpos - pag->xOffset())+" "+FToStr(pag->height() - (ite->Ypos - pag->yOffset()))+" cm\n"); |
3133 | fschmid | 1133 | if (ite->Rot != 0) |
1134 | { |
||
1135 | double sr = sin(-ite->Rot* M_PI / 180.0); |
||
1136 | double cr = cos(-ite->Rot* M_PI / 180.0); |
||
1137 | if ((cr * cr) < 0.000001) |
||
1138 | cr = 0; |
||
1139 | if ((sr * sr) < 0.000001) |
||
1140 | sr = 0; |
||
1141 | PutPage(FToStr(cr)+" "+FToStr(sr)+" "+FToStr(-sr)+" "+FToStr(cr)+" 0 0 cm\n"); |
||
1142 | } |
||
1143 | switch (ite->itemType()) |
||
1144 | { |
||
1145 | case PageItem::ImageFrame: |
||
1146 | if ((ite->fillColor() != "None") || (ite->GrType != 0)) |
||
1147 | { |
||
1148 | if (ite->GrType != 0) |
||
1149 | PutPage(PDF_Gradient(ite)); |
||
1150 | else |
||
1151 | { |
||
1152 | PutPage(SetClipPath(ite)); |
||
1153 | PutPage("h\nf*\n"); |
||
1154 | } |
||
1155 | } |
||
1156 | PutPage("q\n"); |
||
1157 | if (ite->imageClip.size() != 0) |
||
1158 | PutPage(SetClipPathImage(ite)); |
||
1159 | else |
||
1160 | PutPage(SetClipPath(ite)); |
||
1161 | PutPage("h\nW*\nn\n"); |
||
1162 | if (ite->imageFlippedH()) |
||
1163 | PutPage("-1 0 0 1 "+FToStr(ite->Width)+" 0 cm\n"); |
||
1164 | if (ite->imageFlippedV()) |
||
1165 | PutPage("1 0 0 -1 0 "+FToStr(-ite->Height)+" cm\n"); |
||
1166 | if ((ite->PicAvail) && (!ite->Pfile.isEmpty())) |
||
1167 | PutPage(PDF_Image(ite, ite->Pfile, ite->LocalScX, ite->LocalScY, ite->LocalX, -ite->LocalY, false, ite->IProfile, ite->UseEmbedded, ite->IRender)); |
||
1168 | PutPage("Q\n"); |
||
1169 | if (((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) && (!ite->isTableItem)) |
||
1170 | { |
||
1171 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1172 | { |
||
1173 | PutPage(SetClipPath(ite)); |
||
1174 | PutPage("h\nS\n"); |
||
1175 | } |
||
1176 | else |
||
1177 | { |
||
1178 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1179 | for (int it = ml.size()-1; it > -1; it--) |
||
1180 | { |
||
1181 | PutPage(setStrokeMulti(&ml[it])); |
||
1182 | PutPage(SetClipPath(ite)); |
||
1183 | PutPage("h\nS\n"); |
||
1184 | } |
||
1185 | } |
||
1186 | } |
||
1187 | break; |
||
1188 | case PageItem::TextFrame: |
||
1189 | break; |
||
1190 | case PageItem::Line: |
||
1191 | if (ite->NamedLStyle.isEmpty()) |
||
1192 | { |
||
1193 | PutPage("0 0 m\n"); |
||
1194 | PutPage(FToStr(ite->Width)+" 0 l\n"); |
||
1195 | PutPage("S\n"); |
||
1196 | } |
||
1197 | else |
||
1198 | { |
||
1199 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1200 | for (int it = ml.size()-1; it > -1; it--) |
||
1201 | { |
||
1202 | PutPage(setStrokeMulti(&ml[it])); |
||
1203 | PutPage("0 0 m\n"); |
||
1204 | PutPage(FToStr(ite->Width)+" 0 l\n"); |
||
1205 | PutPage("S\n"); |
||
1206 | } |
||
1207 | } |
||
1208 | if (ite->startArrowIndex != 0) |
||
1209 | { |
||
1210 | QWMatrix arrowTrans; |
||
1211 | FPointArray arrow = (*doc->arrowStyles.at(ite->startArrowIndex-1)).points.copy(); |
||
1212 | arrowTrans.translate(0, 0); |
||
1213 | arrowTrans.scale(ite->Pwidth, ite->Pwidth); |
||
1214 | arrowTrans.scale(-1,1); |
||
1215 | arrow.map(arrowTrans); |
||
1216 | if ((ite->lineTransparency() != 0) && (Options->Version >= 14)) |
||
1217 | { |
||
1218 | StartObj(ObjCounter); |
||
1219 | QString ShName = ResNam+IToStr(ResCount); |
||
1220 | Transpar[ShName] = ObjCounter; |
||
1221 | ResCount++; |
||
1222 | ObjCounter++; |
||
1223 | PutDoc("<< /Type /ExtGState\n"); |
||
1224 | PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1225 | PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1226 | PutDoc("/SMask /None\n/AIS false\n/OPM 1\n"); |
||
1227 | PutDoc("/BM /Normal\n>>\nendobj\n"); |
||
1228 | PutPage("/"+ShName+" gs\n"); |
||
1229 | } |
||
1230 | PutPage(putColor(ite->lineColor(), ite->lineShade(), false)); |
||
1231 | PutPage(SetClipPathArray(&arrow)); |
||
1232 | PutPage("h\nf*\n"); |
||
1233 | } |
||
1234 | if (ite->endArrowIndex != 0) |
||
1235 | { |
||
1236 | QWMatrix arrowTrans; |
||
1237 | FPointArray arrow = (*doc->arrowStyles.at(ite->endArrowIndex-1)).points.copy(); |
||
1238 | arrowTrans.translate(ite->Width, 0); |
||
1239 | arrowTrans.scale(ite->Pwidth, ite->Pwidth); |
||
1240 | arrow.map(arrowTrans); |
||
1241 | if ((ite->lineTransparency() != 0) && (Options->Version >= 14)) |
||
1242 | { |
||
1243 | StartObj(ObjCounter); |
||
1244 | QString ShName = ResNam+IToStr(ResCount); |
||
1245 | Transpar[ShName] = ObjCounter; |
||
1246 | ResCount++; |
||
1247 | ObjCounter++; |
||
1248 | PutDoc("<< /Type /ExtGState\n"); |
||
1249 | PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1250 | PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1251 | PutDoc("/SMask /None\n/AIS false\n/OPM 1\n"); |
||
1252 | PutDoc("/BM /Normal\n>>\nendobj\n"); |
||
1253 | PutPage("/"+ShName+" gs\n"); |
||
1254 | } |
||
1255 | PutPage(putColor(ite->lineColor(), ite->lineShade(), false)); |
||
1256 | PutPage(SetClipPathArray(&arrow)); |
||
1257 | PutPage("h\nf*\n"); |
||
1258 | } |
||
1259 | break; |
||
3232 | cbradney | 1260 | case PageItem::ItemType1: |
1261 | case PageItem::ItemType3: |
||
3133 | fschmid | 1262 | case PageItem::Polygon: |
1263 | if (ite->GrType != 0) |
||
1264 | PutPage(PDF_Gradient(ite)); |
||
1265 | else |
||
1266 | { |
||
1267 | if (ite->fillColor() != "None") |
||
1268 | { |
||
1269 | PutPage(SetClipPath(ite)); |
||
1270 | PutPage("h\nf*\n"); |
||
1271 | } |
||
1272 | } |
||
1273 | if ((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) |
||
1274 | { |
||
1275 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1276 | { |
||
1277 | PutPage(SetClipPath(ite)); |
||
1278 | PutPage("h\nS\n"); |
||
1279 | } |
||
1280 | else |
||
1281 | { |
||
1282 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1283 | for (int it = ml.size()-1; it > -1; it--) |
||
1284 | { |
||
1285 | PutPage(setStrokeMulti(&ml[it])); |
||
1286 | PutPage(SetClipPath(ite)); |
||
1287 | PutPage("h\nS\n"); |
||
1288 | } |
||
1289 | } |
||
1290 | } |
||
1291 | break; |
||
1292 | case PageItem::PolyLine: |
||
1293 | if ((ite->PoLine.size() > 3) && ((ite->PoLine.point(0) != ite->PoLine.point(1)) || (ite->PoLine.point(2) != ite->PoLine.point(3)))) |
||
1294 | { |
||
1295 | if (ite->GrType != 0) |
||
1296 | PutPage(PDF_Gradient(ite)); |
||
1297 | else |
||
1298 | { |
||
1299 | if (ite->fillColor() != "None") |
||
1300 | { |
||
1301 | PutPage(SetClipPath(ite)); |
||
1302 | PutPage("h\nf*\n"); |
||
1303 | } |
||
1304 | } |
||
1305 | } |
||
1306 | if ((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) |
||
1307 | { |
||
1308 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1309 | { |
||
1310 | PutPage(SetClipPath(ite, false)); |
||
1311 | PutPage("S\n"); |
||
1312 | } |
||
1313 | else |
||
1314 | { |
||
1315 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1316 | for (int it = ml.size()-1; it > -1; it--) |
||
1317 | { |
||
1318 | PutPage(setStrokeMulti(&ml[it])); |
||
1319 | PutPage(SetClipPath(ite, false)); |
||
1320 | PutPage("S\n"); |
||
1321 | } |
||
1322 | } |
||
1323 | } |
||
1324 | if (ite->startArrowIndex != 0) |
||
1325 | { |
||
1326 | FPoint Start = ite->PoLine.point(0); |
||
1327 | for (uint xx = 1; xx < ite->PoLine.size(); xx += 2) |
||
1328 | { |
||
1329 | FPoint Vector = ite->PoLine.point(xx); |
||
1330 | if ((Start.x() != Vector.x()) || (Start.y() != Vector.y())) |
||
1331 | { |
||
1332 | double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI); |
||
1333 | QWMatrix arrowTrans; |
||
1334 | FPointArray arrow = (*doc->arrowStyles.at(ite->startArrowIndex-1)).points.copy(); |
||
1335 | arrowTrans.translate(Start.x(), Start.y()); |
||
1336 | arrowTrans.rotate(r); |
||
1337 | arrowTrans.scale(ite->Pwidth, ite->Pwidth); |
||
1338 | arrow.map(arrowTrans); |
||
1339 | if ((ite->lineTransparency() != 0) && (Options->Version >= 14)) |
||
1340 | { |
||
1341 | StartObj(ObjCounter); |
||
1342 | QString ShName = ResNam+IToStr(ResCount); |
||
1343 | Transpar[ShName] = ObjCounter; |
||
1344 | ResCount++; |
||
1345 | ObjCounter++; |
||
1346 | PutDoc("<< /Type /ExtGState\n"); |
||
1347 | PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1348 | PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1349 | PutDoc("/SMask /None\n/AIS false\n/OPM 1\n"); |
||
1350 | PutDoc("/BM /Normal\n>>\nendobj\n"); |
||
1351 | PutPage("/"+ShName+" gs\n"); |
||
1352 | } |
||
1353 | PutPage(putColor(ite->lineColor(), ite->lineShade(), false)); |
||
1354 | PutPage(SetClipPathArray(&arrow)); |
||
1355 | PutPage("h\nf*\n"); |
||
1356 | break; |
||
1357 | } |
||
1358 | } |
||
1359 | } |
||
1360 | if (ite->endArrowIndex != 0) |
||
1361 | { |
||
1362 | FPoint End = ite->PoLine.point(ite->PoLine.size()-2); |
||
1363 | for (uint xx = ite->PoLine.size()-1; xx > 0; xx -= 2) |
||
1364 | { |
||
1365 | FPoint Vector = ite->PoLine.point(xx); |
||
1366 | if ((End.x() != Vector.x()) || (End.y() != Vector.y())) |
||
1367 | { |
||
1368 | double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI); |
||
1369 | QWMatrix arrowTrans; |
||
1370 | FPointArray arrow = (*doc->arrowStyles.at(ite->endArrowIndex-1)).points.copy(); |
||
1371 | arrowTrans.translate(End.x(), End.y()); |
||
1372 | arrowTrans.rotate(r); |
||
1373 | arrowTrans.scale(ite->Pwidth, ite->Pwidth); |
||
1374 | arrow.map(arrowTrans); |
||
1375 | if ((ite->lineTransparency() != 0) && (Options->Version >= 14)) |
||
1376 | { |
||
1377 | StartObj(ObjCounter); |
||
1378 | QString ShName = ResNam+IToStr(ResCount); |
||
1379 | Transpar[ShName] = ObjCounter; |
||
1380 | ResCount++; |
||
1381 | ObjCounter++; |
||
1382 | PutDoc("<< /Type /ExtGState\n"); |
||
1383 | PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1384 | PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1385 | PutDoc("/SMask /None\n/AIS false\n/OPM 1\n"); |
||
1386 | PutDoc("/BM /Normal\n>>\nendobj\n"); |
||
1387 | PutPage("/"+ShName+" gs\n"); |
||
1388 | } |
||
1389 | PutPage(putColor(ite->lineColor(), ite->lineShade(), false)); |
||
1390 | PutPage(SetClipPathArray(&arrow)); |
||
1391 | PutPage("h\nf*\n"); |
||
1392 | break; |
||
1393 | } |
||
1394 | } |
||
1395 | } |
||
1396 | break; |
||
1397 | case PageItem::PathText: |
||
1398 | if (ite->PoShow) |
||
1399 | { |
||
1400 | if (ite->PoLine.size() > 3) |
||
1401 | { |
||
1402 | PutPage("q\n"); |
||
1403 | if ((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) |
||
1404 | { |
||
1405 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1406 | { |
||
1407 | PutPage(SetClipPath(ite, false)); |
||
1408 | PutPage("S\n"); |
||
1409 | } |
||
1410 | else |
||
1411 | { |
||
1412 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1413 | for (int it = ml.size()-1; |
||
1414 | it > -1; it--) |
||
1415 | { |
||
1416 | PutPage(setStrokeMulti(&ml[it])); |
||
1417 | PutPage(SetClipPath(ite, false)); |
||
1418 | PutPage("S\n"); |
||
1419 | } |
||
1420 | } |
||
1421 | } |
||
1422 | PutPage("Q\n"); |
||
1423 | } |
||
1424 | } |
||
3200 | cbradney | 1425 | PutPage(setTextSt(ite, pag->pageNr(), pag)); |
3133 | fschmid | 1426 | break; |
1427 | } |
||
1428 | PutPage("Q\n"); |
||
1429 | StartObj(ObjCounter); |
||
1430 | ObjCounter++; |
||
1431 | PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n"); |
||
3200 | cbradney | 1432 | PutDoc("/BBox [ 0 0 "+FToStr(ActPageP->width())+" "+FToStr(ActPageP->height())+" ]\n"); |
3133 | fschmid | 1433 | PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n"); |
1434 | if (Seite.ImgObjects.count() != 0) |
||
1435 | { |
||
1436 | PutDoc("/XObject <<\n"); |
||
1437 | QMap<QString,int>::Iterator it; |
||
1438 | for (it = Seite.ImgObjects.begin(); it != Seite.ImgObjects.end(); ++it) |
||
1439 | PutDoc("/"+it.key()+" "+IToStr(it.data())+" 0 R\n"); |
||
1440 | PutDoc(">>\n"); |
||
1441 | } |
||
1442 | if (Seite.FObjects.count() != 0) |
||
1443 | { |
||
1444 | PutDoc("/Font << \n"); |
||
1445 | QMap<QString,int>::Iterator it2; |
||
1446 | for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2) |
||
1447 | PutDoc("/"+it2.key()+" "+IToStr(it2.data())+" 0 R\n"); |
||
1448 | PutDoc(">>\n"); |
||
1449 | } |
||
1450 | if (Shadings.count() != 0) |
||
1451 | { |
||
1452 | PutDoc("/Shading << \n"); |
||
1453 | QMap<QString,int>::Iterator it3; |
||
1454 | for (it3 = Shadings.begin(); it3 != Shadings.end(); ++it3) |
||
1455 | PutDoc("/"+it3.key()+" "+IToStr(it3.data())+" 0 R\n"); |
||
1456 | PutDoc(">>\n"); |
||
1457 | } |
||
1458 | if (Transpar.count() != 0) |
||
1459 | { |
||
1460 | PutDoc("/ExtGState << \n"); |
||
1461 | QMap<QString,int>::Iterator it3t; |
||
1462 | for (it3t = Transpar.begin(); it3t != Transpar.end(); ++it3t) |
||
1463 | PutDoc("/"+it3t.key()+" "+IToStr(it3t.data())+" 0 R\n"); |
||
1464 | PutDoc(">>\n"); |
||
1465 | } |
||
1466 | if ((ICCProfiles.count() != 0) || (spotMap.count() != 0)) |
||
1467 | { |
||
1468 | PutDoc("/ColorSpace << \n"); |
||
1469 | QMap<QString,ICCD>::Iterator it3c; |
||
1470 | if (ICCProfiles.count() != 0) |
||
1471 | { |
||
1472 | for (it3c = ICCProfiles.begin(); it3c != ICCProfiles.end(); ++it3c) |
||
1473 | PutDoc("/"+it3c.data().ResName+" "+IToStr(it3c.data().ResNum)+" 0 R\n"); |
||
1474 | } |
||
1475 | QMap<QString,SpotC>::Iterator it3sc; |
||
1476 | if (spotMap.count() != 0) |
||
1477 | { |
||
1478 | for (it3sc = spotMap.begin(); it3sc != spotMap.end(); ++it3sc) |
||
1479 | PutDoc("/"+it3sc.data().ResName+" "+IToStr(it3sc.data().ResNum)+" 0 R\n"); |
||
1480 | } |
||
1481 | PutDoc(">>\n"); |
||
1482 | } |
||
1483 | PutDoc(">>\n"); |
||
1484 | if ((Options->Compress) && (CompAvail)) |
||
1485 | Inhalt = CompressStr(&Inhalt); |
||
1486 | PutDoc("/Length "+IToStr(Inhalt.length()+1)); |
||
1487 | if ((Options->Compress) && (CompAvail)) |
||
1488 | PutDoc("\n/Filter /FlateDecode"); |
||
1489 | PutDoc(" >>\nstream\n"+EncStream(&Inhalt, ObjCounter-1)+"\nendstream\nendobj\n"); |
||
3440 | fschmid | 1490 | QString name = pag->PageNam.simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ) + IToStr(ite->ItemNr); |
3133 | fschmid | 1491 | Seite.XObjects[name] = ObjCounter-1; |
1492 | } |
||
1493 | if ((Options->Version == 15) && (Options->useLayers)) |
||
1494 | PutPage("EMC\n"); |
||
1495 | } |
||
1496 | Lnr++; |
||
1497 | } |
||
1498 | } |
||
1499 | |||
1500 | void PDFlib::PDF_Begin_Page(Page* pag, QPixmap pm) |
||
1501 | { |
||
1502 | QString tmp; |
||
1503 | ActPageP = pag; |
||
1504 | Inhalt = ""; |
||
1505 | Seite.AObjects.clear(); |
||
1506 | if (Options->Thumbnails) |
||
1507 | { |
||
1508 | ScImage img = pm.convertToImage(); |
||
1509 | QString im = img.ImageToTxt(); |
||
1510 | if ((Options->Compress) && (CompAvail)) |
||
1511 | im = CompressStr(&im); |
||
1512 | StartObj(ObjCounter); |
||
1513 | PutDoc("<<\n/Width "+IToStr(img.width())+"\n"); |
||
1514 | PutDoc("/Height "+IToStr(img.height())+"\n"); |
||
1515 | PutDoc("/ColorSpace /DeviceRGB\n/BitsPerComponent 8\n"); |
||
1516 | PutDoc("/Length "+IToStr(im.length()+1)+"\n"); |
||
1517 | if ((Options->Compress) && (CompAvail)) |
||
1518 | PutDoc("/Filter /FlateDecode\n"); |
||
1519 | PutDoc(">>\nstream\n"+EncStream(&im, ObjCounter)+"\nendstream\nendobj\n"); |
||
1520 | Seite.Thumb = ObjCounter; |
||
1521 | ObjCounter++; |
||
1522 | } |
||
1523 | } |
||
1524 | |||
1525 | void PDFlib::PDF_End_Page() |
||
1526 | { |
||
3200 | cbradney | 1527 | uint PgNr = ActPageP->pageNr(); |
3133 | fschmid | 1528 | Seite.ObjNum = ObjCounter; |
1529 | WritePDFStream(&Inhalt); |
||
1530 | StartObj(ObjCounter); |
||
1531 | PutDoc("<<\n/Type /Page\n/Parent 4 0 R\n"); |
||
3200 | cbradney | 1532 | PutDoc("/MediaBox [0 0 "+FToStr(ActPageP->width())+" "+FToStr(ActPageP->height())+"]\n"); |
3133 | fschmid | 1533 | PutDoc("/TrimBox ["+FToStr(Options->BleedLeft)+" "+FToStr(Options->BleedBottom)+ |
3200 | cbradney | 1534 | " "+FToStr(ActPageP->width()-Options->BleedRight)+" "+FToStr(ActPageP->height()-Options->BleedTop)+"]\n"); |
3133 | fschmid | 1535 | PutDoc("/Rotate "+IToStr(Options->RotateDeg)+"\n"); |
1536 | PutDoc("/Contents "+IToStr(Seite.ObjNum)+" 0 R\n"); |
||
1537 | if (Options->Thumbnails) |
||
1538 | PutDoc("/Thumb "+IToStr(Seite.Thumb)+" 0 R\n"); |
||
1539 | if (Seite.AObjects.count() != 0) |
||
1540 | { |
||
1541 | PutDoc("/Annots [ "); |
||
1542 | for (uint b = 0; b < Seite.AObjects.count(); ++b) |
||
1543 | PutDoc(IToStr(Seite.AObjects[b])+" 0 R "); |
||
1544 | PutDoc("]\n"); |
||
1545 | } |
||
1546 | if (Options->PresentMode) |
||
1547 | { |
||
1548 | PutDoc("/Dur "+IToStr(Options->PresentVals[PgNr].pageViewDuration)+"\n"); |
||
1549 | if (Options->PresentVals[PgNr].effectType != 0) |
||
1550 | { |
||
1551 | PutDoc("/Trans << /Type /Trans\n"); |
||
1552 | PutDoc("/D "+IToStr(Options->PresentVals[PgNr].pageEffectDuration)+"\n"); |
||
1553 | switch (Options->PresentVals[PgNr].effectType) |
||
1554 | { |
||
1555 | case 1: |
||
1556 | PutDoc("/S /Blinds\n"); |
||
1557 | PutDoc(Options->PresentVals[PgNr].Dm == 0 ? "/Dm /H\n" : "/Dm /V\n"); |
||
1558 | break; |
||
1559 | case 2: |
||
1560 | PutDoc("/S /Box\n"); |
||
1561 | PutDoc(Options->PresentVals[PgNr].M == 0 ? "/M /I\n" : "/M /O\n"); |
||
1562 | break; |
||
1563 | case 3: |
||
1564 | PutDoc("/S /Dissolve\n"); |
||
1565 | break; |
||
1566 | case 4: |
||
1567 | PutDoc("/S /Glitter\n"); |
||
1568 | PutDoc("/Di "); |
||
1569 | switch (Options->PresentVals[PgNr].Di) |
||
1570 | { |
||
1571 | case 0: |
||
1572 | PutDoc("0"); |
||
1573 | break; |
||
1574 | case 1: |
||
1575 | PutDoc("270"); |
||
1576 | break; |
||
1577 | case 4: |
||
1578 | PutDoc("315"); |
||
1579 | break; |
||
1580 | default: |
||
1581 | PutDoc("0"); |
||
1582 | break; |
||
1583 | } |
||
1584 | PutDoc("\n"); |
||
1585 | break; |
||
1586 | case 5: |
||
1587 | PutDoc("/S /Split\n"); |
||
1588 | PutDoc(Options->PresentVals[PgNr].Dm == 0 ? "/Dm /H\n" : "/Dm /V\n"); |
||
1589 | PutDoc(Options->PresentVals[PgNr].M == 0 ? "/M /I\n" : "/M /O\n"); |
||
1590 | break; |
||
1591 | case 6: |
||
1592 | PutDoc("/S /Wipe\n"); |
||
1593 | PutDoc("/Di "); |
||
1594 | switch (Options->PresentVals[PgNr].Di) |
||
1595 | { |
||
1596 | case 0: |
||
1597 | PutDoc("0"); |
||
1598 | break; |
||
1599 | case 1: |
||
1600 | PutDoc("270"); |
||
1601 | break; |
||
1602 | case 2: |
||
1603 | PutDoc("90"); |
||
1604 | break; |
||
1605 | case 3: |
||
1606 | PutDoc("180"); |
||
1607 | break; |
||
1608 | default: |
||
1609 | PutDoc("0"); |
||
1610 | break; |
||
1611 | } |
||
1612 | PutDoc("\n"); |
||
1613 | break; |
||
1614 | } |
||
1615 | PutDoc(">>\n"); |
||
1616 | } |
||
1617 | } |
||
1618 | PutDoc(">>\nendobj\n"); |
||
1619 | PageTree.Count++; |
||
1620 | PageTree.Kids.append(ObjCounter); |
||
1621 | ObjCounter++; |
||
1622 | } |
||
1623 | |||
1624 | void PDFlib::PDF_ProcessPage(Page* pag, uint PNr, bool clip) |
||
1625 | { |
||
1626 | QString tmp; |
||
1627 | ActPageP = pag; |
||
1628 | PageItem* ite; |
||
1629 | QPtrList<PageItem> PItems; |
||
1630 | int Lnr = 0; |
||
1631 | struct Layer ll; |
||
1632 | ll.isPrintable = false; |
||
1633 | ll.LNr = 0; |
||
1634 | if (Options->UseLPI) |
||
1635 | PutPage("/"+HTName+" gs\n"); |
||
1636 | if ( (Options->MirrorH) && (!pag->MPageNam.isEmpty()) ) |
||
3200 | cbradney | 1637 | PutPage("-1 0 0 1 "+FToStr(ActPageP->width())+" 0 cm\n"); |
3133 | fschmid | 1638 | if ( (Options->MirrorV) && (!pag->MPageNam.isEmpty()) ) |
3200 | cbradney | 1639 | PutPage("1 0 0 -1 0 "+FToStr(ActPageP->height())+" cm\n"); |
3133 | fschmid | 1640 | if (clip) |
1641 | { |
||
1642 | PutPage(FToStr(pag->Margins.Left) + " " + FToStr(pag->Margins.Bottom) + " m\n"); |
||
3200 | cbradney | 1643 | PutPage(FToStr(ActPageP->width() - pag->Margins.Right) + " " + FToStr(pag->Margins.Bottom) + " l\n"); |
1644 | PutPage(FToStr(ActPageP->width() - pag->Margins.Right) + " " + FToStr(ActPageP->height() - pag->Margins.Top) + " l\n"); |
||
1645 | PutPage(FToStr(pag->Margins.Left) + " " + FToStr(ActPageP->height() - pag->Margins.Top) + " l h W n\n"); |
||
3133 | fschmid | 1646 | } |
1647 | else |
||
3200 | cbradney | 1648 | PutPage("0 0 "+FToStr(ActPageP->width())+" "+FToStr(ActPageP->height())+" re W n\n"); |
3133 | fschmid | 1649 | if (!pag->MPageNam.isEmpty()) |
1650 | { |
||
3724 | cbradney | 1651 | Page* mPage = doc->MasterPages.at(doc->MasterNames[doc->Pages->at(PNr)->MPageNam]); |
3133 | fschmid | 1652 | if (doc->MasterItems.count() != 0) |
1653 | { |
||
1654 | if (!Options->MirrorH) |
||
1655 | PutPage("1 0 0 1 0 0 cm\n"); |
||
1656 | for (uint lam = 0; lam < doc->Layers.count(); ++lam) |
||
1657 | { |
||
1658 | Level2Layer(doc, &ll, Lnr); |
||
1659 | Lnr++; |
||
1660 | if (ll.isPrintable) |
||
1661 | { |
||
1662 | if ((Options->Version == 15) && (Options->useLayers)) |
||
1663 | PutPage("/OC /"+OCGEntries[ll.Name].Name+" BDC\n"); |
||
1664 | for (uint am = 0; am < pag->FromMaster.count(); ++am) |
||
1665 | { |
||
1666 | ite = pag->FromMaster.at(am); |
||
1667 | if ((ite->LayerNr != ll.LNr) || (!ite->printable())) |
||
1668 | continue; |
||
3200 | cbradney | 1669 | if ((!pag->PageNam.isEmpty()) && (ite->OwnPage != static_cast<int>(pag->pageNr())) && (ite->OwnPage != -1)) |
3133 | fschmid | 1670 | continue; |
3440 | fschmid | 1671 | QString name = "/"+pag->MPageNam.simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ) + IToStr(ite->ItemNr); |
3625 | avox | 1672 | if (! ite->asTextFrame()) |
3133 | fschmid | 1673 | PutPage(name+" Do\n"); |
1674 | else |
||
1675 | { |
||
1676 | PutPage("q\n"); |
||
1677 | if (((ite->fillTransparency() != 0) || (ite->lineTransparency() != 0)) && (Options->Version >= 14)) |
||
1678 | PutPage(PDF_Transparenz(ite)); |
||
1679 | if (ite->fillColor() != "None") |
||
1680 | PutPage(putColor(ite->fillColor(), ite->fillShade(), true)); |
||
1681 | if (ite->lineColor() != "None") |
||
1682 | PutPage(putColor(ite->lineColor(), ite->lineShade(), false)); |
||
1683 | Inhalt += FToStr(fabs(ite->Pwidth))+" w\n"; |
||
1684 | if (ite->DashValues.count() != 0) |
||
1685 | { |
||
1686 | PutPage("[ "); |
||
1687 | QValueList<double>::iterator it; |
||
1688 | for ( it = ite->DashValues.begin(); it != ite->DashValues.end(); ++it ) |
||
1689 | { |
||
1690 | int da = static_cast<int>(*it); |
||
1691 | if (da != 0) |
||
1692 | PutPage(IToStr(da)+" "); |
||
1693 | PutPage(IToStr(static_cast<int>(*it))+" "); |
||
1694 | } |
||
1695 | } |
||
1696 | else |
||
1697 | { |
||
1698 | QString Dt = FToStr(QMAX(2*fabs(ite->Pwidth), 1)); |
||
1699 | QString Da = FToStr(QMAX(6*fabs(ite->Pwidth), 1)); |
||
1700 | switch (ite->PLineArt) |
||
1701 | { |
||
1702 | case Qt::SolidLine: |
||
1703 | PutPage("[] 0 d\n"); |
||
1704 | break; |
||
1705 | case Qt::DashLine: |
||
1706 | PutPage("["+Da+" "+Dt+"] 0 d\n"); |
||
1707 | break; |
||
1708 | case Qt::DotLine: |
||
1709 | PutPage("["+Dt+"] 0 d\n"); |
||
1710 | break; |
||
1711 | case Qt::DashDotLine: |
||
1712 | PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n"); |
||
1713 | break; |
||
1714 | case Qt::DashDotDotLine: |
||
1715 | PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n"); |
||
1716 | break; |
||
1717 | default: |
||
1718 | PutPage("[] 0 d\n"); |
||
1719 | break; |
||
1720 | } |
||
1721 | } |
||
1722 | PutPage("2 J\n"); |
||
1723 | switch (ite->PLineJoin) |
||
1724 | { |
||
1725 | case Qt::MiterJoin: |
||
1726 | PutPage("0 j\n"); |
||
1727 | break; |
||
1728 | case Qt::BevelJoin: |
||
1729 | PutPage("2 j\n"); |
||
1730 | break; |
||
1731 | case Qt::RoundJoin: |
||
1732 | PutPage("1 j\n"); |
||
1733 | break; |
||
1734 | default: |
||
1735 | PutPage("0 j\n"); |
||
1736 | break; |
||
1737 | } |
||
3200 | cbradney | 1738 | PutPage("1 0 0 1 "+FToStr(ite->Xpos - mPage->xOffset())+" "+FToStr(mPage->height() - (ite->Ypos - mPage->yOffset()))+" cm\n"); |
3133 | fschmid | 1739 | if (ite->Rot != 0) |
1740 | { |
||
1741 | double sr = sin(-ite->Rot* M_PI / 180.0); |
||
1742 | double cr = cos(-ite->Rot* M_PI / 180.0); |
||
1743 | if ((cr * cr) < 0.000001) |
||
1744 | cr = 0; |
||
1745 | if ((sr * sr) < 0.000001) |
||
1746 | sr = 0; |
||
1747 | PutPage(FToStr(cr)+" "+FToStr(sr)+" "+FToStr(-sr)+" "+FToStr(cr)+" 0 0 cm\n"); |
||
1748 | } |
||
1749 | if ((ite->fillColor() != "None") || (ite->GrType != 0)) |
||
1750 | { |
||
1751 | if (ite->GrType != 0) |
||
1752 | PutPage(PDF_Gradient(ite)); |
||
1753 | else |
||
1754 | { |
||
1755 | PutPage(SetClipPath(ite)); |
||
1756 | PutPage("h\nf*\n"); |
||
1757 | } |
||
1758 | } |
||
1759 | PutPage("q\n"); |
||
1760 | if (ite->imageFlippedH()) |
||
1761 | PutPage("-1 0 0 1 "+FToStr(ite->Width)+" 0 cm\n"); |
||
1762 | if (ite->imageFlippedV()) |
||
1763 | PutPage("1 0 0 -1 0 "+FToStr(-ite->Height)+" cm\n"); |
||
1764 | PutPage(setTextSt(ite, PNr, pag)); |
||
1765 | PutPage("Q\n"); |
||
1766 | if (((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) && (!ite->isTableItem)) |
||
1767 | { |
||
1768 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1769 | { |
||
1770 | PutPage(SetClipPath(ite)); |
||
1771 | PutPage("h\nS\n"); |
||
1772 | } |
||
1773 | else |
||
1774 | { |
||
1775 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1776 | for (int it = ml.size()-1; it > -1; it--) |
||
1777 | { |
||
1778 | PutPage(setStrokeMulti(&ml[it])); |
||
1779 | PutPage(SetClipPath(ite)); |
||
1780 | PutPage("h\nS\n"); |
||
1781 | } |
||
1782 | } |
||
1783 | } |
||
1784 | PutPage("Q\n"); |
||
1785 | } |
||
1786 | } |
||
1787 | for (uint am = 0; am < pag->FromMaster.count(); ++am) |
||
1788 | { |
||
1789 | ite = pag->FromMaster.at(am); |
||
1790 | if ((ite->LayerNr != ll.LNr) || (!ite->printable())) |
||
1791 | continue; |
||
1792 | if (ite->ChangedMasterItem) |
||
1793 | continue; |
||
3200 | cbradney | 1794 | if ((!pag->PageNam.isEmpty()) && (ite->OwnPage != static_cast<int>(pag->pageNr())) && (ite->OwnPage != -1)) |
3133 | fschmid | 1795 | continue; |
1796 | if (!ite->isTableItem) |
||
1797 | continue; |
||
1798 | PutPage("q\n"); |
||
1799 | if (((ite->fillTransparency() != 0) || (ite->lineTransparency() != 0)) && (Options->Version >= 14)) |
||
1800 | PutPage(PDF_Transparenz(ite)); |
||
1801 | if (ite->fillColor() != "None") |
||
1802 | PutPage(putColor(ite->fillColor(), ite->fillShade(), true)); |
||
1803 | if (ite->lineColor() != "None") |
||
1804 | PutPage(putColor(ite->lineColor(), ite->lineShade(), false)); |
||
1805 | Inhalt += FToStr(fabs(ite->Pwidth))+" w\n"; |
||
1806 | if (ite->DashValues.count() != 0) |
||
1807 | { |
||
1808 | PutPage("[ "); |
||
1809 | QValueList<double>::iterator it; |
||
1810 | for ( it = ite->DashValues.begin(); it != ite->DashValues.end(); ++it ) |
||
1811 | { |
||
1812 | int da = static_cast<int>(*it); |
||
1813 | if (da != 0) |
||
1814 | PutPage(IToStr(da)+" "); |
||
1815 | PutPage(IToStr(static_cast<int>(*it))+" "); |
||
1816 | } |
||
1817 | } |
||
1818 | else |
||
1819 | { |
||
1820 | QString Dt = FToStr(QMAX(2*fabs(ite->Pwidth), 1)); |
||
1821 | QString Da = FToStr(QMAX(6*fabs(ite->Pwidth), 1)); |
||
1822 | switch (ite->PLineArt) |
||
1823 | { |
||
1824 | case Qt::SolidLine: |
||
1825 | PutPage("[] 0 d\n"); |
||
1826 | break; |
||
1827 | case Qt::DashLine: |
||
1828 | PutPage("["+Da+" "+Dt+"] 0 d\n"); |
||
1829 | break; |
||
1830 | case Qt::DotLine: |
||
1831 | PutPage("["+Dt+"] 0 d\n"); |
||
1832 | &nbs |