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