Rev 115 | Rev 135 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | paul | 1 | /*************************************************************************** |
2 | scribusview.cpp - description |
||
3 | ------------------- |
||
4 | begin : Fre Apr 6 21:47:55 CEST 2001 |
||
5 | copyright : (C) 2001 by Franz Schmid |
||
6 | email : Franz.Schmid@altmuehlnet.de |
||
7 | ***************************************************************************/ |
||
8 | |||
9 | /*************************************************************************** |
||
10 | * * |
||
11 | * This program is free software; you can redistribute it and/or modify * |
||
12 | * it under the terms of the GNU General Public License as published by * |
||
13 | * the Free Software Foundation; either version 2 of the License, or * |
||
14 | * (at your option) any later version. * |
||
15 | * * |
||
16 | ***************************************************************************/ |
||
17 | |||
18 | #include "scribusview.h" |
||
19 | #include "scribusview.moc" |
||
128 | Franz | 20 | |
21 | #if (_MSC_VER >= 1200) |
||
22 | #include "win-config.h" |
||
23 | #else |
||
24 | #include "config.h" |
||
25 | #endif |
||
26 | |||
3 | paul | 27 | #include "pageback.h" |
28 | #include <qcolor.h> |
||
29 | #include <qfont.h> |
||
30 | #include <qfontmetrics.h> |
||
31 | #include <qpixmap.h> |
||
32 | #include <qpointarray.h> |
||
33 | #include <qstringlist.h> |
||
34 | #include <qimage.h> |
||
35 | #include <qcstring.h> |
||
68 | Franz | 36 | |
3 | paul | 37 | extern void Level2Layer(ScribusDoc *doc, struct Layer *ll, int Level); |
80 | Franz | 38 | extern double Cwidth(ScribusDoc *doc, QString name, QString ch, int Siz, QString ch2 = " "); |
3 | paul | 39 | |
40 | ScribusView::ScribusView(QWidget *parent, ScribusDoc *doc, preV *prefs) |
||
41 | : QScrollView(parent, "s", WRepaintNoErase | WNorthWestGravity) |
||
42 | { |
||
43 | Ready = false; |
||
44 | Doc = doc; |
||
45 | Doc->PageC = 0; |
||
46 | Prefs = prefs; |
||
47 | setHScrollBarMode(QScrollView::AlwaysOn); |
||
48 | setVScrollBarMode(QScrollView::AlwaysOn); |
||
49 | setMargins(25, 25, 0, 0); |
||
50 | setResizePolicy(Manual); |
||
51 | enableClipper(true); |
||
52 | viewport()->setBackgroundMode(PaletteBackground); |
||
53 | QFont fo = QFont(font()); |
||
54 | fo.setPointSize(10); |
||
68 | Franz | 55 | LE = new MSpinBox( this, 2 ); |
3 | paul | 56 | LE->setFont(fo); |
68 | Franz | 57 | LE->setSuffix( tr( " %" ) ); |
58 | LE->setMaxValue( 320000 ); |
||
59 | LE->setMinValue( 1000 ); |
||
60 | LE->setValue( 10000 ); |
||
61 | LE->setDecimals( 1000 ); |
||
3 | paul | 62 | LE->setFocusPolicy(QWidget::ClickFocus); |
63 | SB1 = new QPushButton(this); |
||
64 | SB1->setPixmap(loadIcon("Klein.xpm")); |
||
65 | SB1->setFocusPolicy(QWidget::NoFocus); |
||
66 | SB2 = new QPushButton(this); |
||
67 | SB2->setFocusPolicy(QWidget::NoFocus); |
||
68 | SB2->setPixmap(loadIcon("Gross.xpm")); |
||
69 | LA = new QPushButton(this); |
||
70 | LA->setFont(fo); |
||
71 | Seitmen = new QPopupMenu(this); |
||
72 | Seitmen->setFont(fo); |
||
115 | Franz | 73 | LA->setText( tr("Page %1").arg(1)); |
3 | paul | 74 | LA->setPopup(Seitmen); |
75 | LA->setFocusPolicy(QWidget::NoFocus); |
||
76 | LY = new QPushButton(this); |
||
77 | LY->setFont(fo); |
||
78 | Laymen = new QPopupMenu(this); |
||
79 | Laymen->setFont(fo); |
||
112 | Franz | 80 | LY->setText( tr("Layer")+" 0"); |
3 | paul | 81 | LY->setPopup(Laymen); |
82 | LY->setFocusPolicy(QWidget::NoFocus); |
||
83 | HR = new Hruler(this, Doc); |
||
84 | VR = new Vruler(this, Doc); |
||
85 | UN = new QToolButton(this); |
||
86 | Unitmen = new QPopupMenu(this); |
||
87 | Unitmen->insertItem("pt"); |
||
88 | Unitmen->insertItem("mm"); |
||
89 | Unitmen->insertItem("in"); |
||
90 | Unitmen->insertItem("p"); |
||
91 | UN->setPopup(Unitmen); |
||
92 | UN->setFocusPolicy(QWidget::NoFocus); |
||
93 | UN->setPopupDelay(10); |
||
94 | switch (doc->Einheit) |
||
95 | { |
||
96 | case 0: |
||
97 | UN->setText("pt"); |
||
98 | break; |
||
99 | case 1: |
||
100 | UN->setText("mm"); |
||
101 | break; |
||
102 | case 2: |
||
103 | UN->setText("in"); |
||
104 | break; |
||
105 | case 3: |
||
106 | UN->setText("p"); |
||
107 | break; |
||
108 | } |
||
109 | Pages.clear(); |
||
110 | MasterPages.clear(); |
||
111 | DocPages.clear(); |
||
112 | Ready = true; |
||
113 | connect(SB1, SIGNAL(clicked()), this, SLOT(slotZoomOut())); |
||
114 | connect(SB2, SIGNAL(clicked()), this, SLOT(slotZoomIn())); |
||
68 | Franz | 115 | connect(LE, SIGNAL(valueChanged(int)), this, SLOT(Zval())); |
3 | paul | 116 | connect(Seitmen, SIGNAL(activated(int)), this, SLOT(GotoPa(int))); |
117 | connect(Laymen, SIGNAL(activated(int)), this, SLOT(GotoLa(int))); |
||
118 | connect(Unitmen, SIGNAL(activated(int)), this, SLOT(ChgUnit(int))); |
||
119 | connect(this, SIGNAL(contentsMoving(int, int)), this, SLOT(setRulerPos(int, int))); |
||
120 | } |
||
121 | |||
122 | /** Waagrechter Scrollbalken */ |
||
123 | void ScribusView::setHBarGeometry(QScrollBar &bar, int x, int y, int w, int h) |
||
124 | { |
||
125 | bar.setGeometry(x+270, y, w-270, h); |
||
126 | if (Ready) |
||
127 | { |
||
77 | Franz | 128 | QFontMetrics fom(LE->font()); |
3 | paul | 129 | LE->setGeometry(x, y, 60, h); |
77 | Franz | 130 | if (fom.height() > LE->ed->height()) |
131 | { |
||
78 | Franz | 132 | QFont ff = LE->font(); |
77 | Franz | 133 | do |
134 | { |
||
135 | int si = LE->font().pointSize(); |
||
136 | ff.setPointSize(si-1); |
||
137 | LE->setFont(ff); |
||
138 | fom = QFontMetrics(LE->font()); |
||
139 | } |
||
140 | while (fom.height() > LE->ed->height()); |
||
78 | Franz | 141 | LA->setFont(ff); |
142 | LY->setFont(ff); |
||
83 | Franz | 143 | HR->setFont(ff); |
144 | VR->setFont(ff); |
||
77 | Franz | 145 | } |
146 | QRect forec = fom.boundingRect("3200.00 %"); |
||
147 | int sadj = forec.width() - LE->ed->width(); |
||
148 | LE->setGeometry(x, y, 60+sadj, h); |
||
149 | SB1->setGeometry(x+60+sadj, y, 15, h); |
||
150 | SB2->setGeometry(x+75+sadj, y, 15, h); |
||
151 | LA->setGeometry(x+90+sadj, y, 70, h); |
||
152 | LY->setGeometry(x+160+sadj, y, 110, h); |
||
3 | paul | 153 | HR->setGeometry(25, 1, w-24, 25); |
154 | } |
||
155 | } |
||
156 | |||
157 | /** Senkrechter Scrollbalken */ |
||
158 | void ScribusView::setVBarGeometry(QScrollBar &bar, int x, int y, int w, int h) |
||
159 | { |
||
160 | bar.setGeometry(x, y, w, h); |
||
161 | if (Ready) |
||
162 | { |
||
163 | VR->setGeometry(1, 25, 25, h-24); |
||
164 | UN->setGeometry(1, 1, 25, 25); |
||
165 | } |
||
166 | } |
||
167 | |||
168 | void ScribusView::setRulerPos(int x, int y) |
||
169 | { |
||
170 | HR->offs = x-static_cast<int>(10*Doc->Scale)-2; |
||
171 | HR->repX = false; |
||
172 | HR->repaint(); |
||
173 | VR->offs = y-static_cast<int>(10*Doc->Scale)-2; |
||
174 | VR->repaint(); |
||
175 | } |
||
176 | |||
177 | void ScribusView::Zval() |
||
178 | { |
||
80 | Franz | 179 | Doc->Scale = static_cast<double>(LE->value()) / 10000.0 * Prefs->DisScale; |
68 | Franz | 180 | slotDoZoom(); |
3 | paul | 181 | setFocus(); |
182 | } |
||
183 | |||
184 | /** Fügt eine Seite hinzu */ |
||
185 | Page* ScribusView::addPage(int nr) |
||
186 | { |
||
187 | int z; |
||
80 | Franz | 188 | double s = Doc->Scale; |
3 | paul | 189 | QWidget* feh = new PageBack(viewport()); |
190 | feh->resize(static_cast<int>((Doc->PageB+5)*s), static_cast<int>((Doc->PageH+5)*s)); |
||
191 | Page* fe = new Page(feh, 0, 0, static_cast<int>(Doc->PageB*s), static_cast<int>(Doc->PageH*s), Doc, this); |
||
192 | Doc->ActPage = fe; |
||
193 | fe->Margins.Top = Doc->PageM.Top; |
||
194 | fe->Margins.Bottom = Doc->PageM.Bottom; |
||
195 | addChild(feh, static_cast<int>(10*s), static_cast<int>(Doc->PageC*((Doc->PageH+30)*s)+10*s)); |
||
196 | feh->show(); |
||
197 | Doc->PageC++; |
||
198 | Pages.insert(nr, fe); |
||
199 | reformPages(); |
||
200 | if ((Doc->PageAT) && (!Doc->loading)) |
||
201 | { |
||
202 | if (Doc->PageSp > 1) |
||
203 | { |
||
204 | int a; |
||
80 | Franz | 205 | double bsp = (Doc->PageB-fe->Margins.Right-fe->Margins.Left-(Doc->PageSp-1)*Doc->PageSpa)/Doc->PageSp; |
206 | double anf = fe->Margins.Left; |
||
3 | paul | 207 | for (a = 0; a < Doc->PageSp; a++) |
208 | { |
||
209 | z = fe->PaintText(anf, |
||
210 | fe->Margins.Top, |
||
211 | bsp, |
||
212 | Doc->PageH-fe->Margins.Bottom-fe->Margins.Top, |
||
213 | 1, Doc->Dpen); |
||
214 | anf += bsp + Doc->PageSpa; |
||
215 | fe->Items.at(z)->isAutoText = true; |
||
216 | fe->Items.at(z)->BackBox = Doc->LastAuto; |
||
217 | if (Doc->LastAuto != 0) |
||
218 | Doc->LastAuto->NextBox = fe->Items.at(z); |
||
219 | else |
||
220 | Doc->FirstAuto = fe->Items.at(z); |
||
221 | Doc->LastAuto = fe->Items.at(z); |
||
222 | fe->SetRectFrame(fe->Items.at(z)); |
||
223 | } |
||
224 | } |
||
225 | else |
||
226 | { |
||
227 | z = fe->PaintText(fe->Margins.Left, |
||
228 | fe->Margins.Top, |
||
229 | Doc->PageB-fe->Margins.Right-fe->Margins.Left, |
||
230 | Doc->PageH-fe->Margins.Bottom-fe->Margins.Top, |
||
231 | 1, Doc->Dpen); |
||
232 | fe->Items.at(z)->isAutoText = true; |
||
233 | fe->Items.at(z)->BackBox = Doc->LastAuto; |
||
234 | if (Doc->LastAuto != 0) |
||
235 | Doc->LastAuto->NextBox = fe->Items.at(z); |
||
236 | else |
||
237 | Doc->FirstAuto = fe->Items.at(z); |
||
238 | Doc->LastAuto = fe->Items.at(z); |
||
239 | fe->SetRectFrame(fe->Items.at(z)); |
||
240 | } |
||
241 | Doc->FirstAuto->Dirty = true; |
||
242 | } |
||
115 | Franz | 243 | LA->setText( tr("Page %1").arg(nr+1)); |
3 | paul | 244 | fe->setMouseTracking(true); |
245 | connect(fe, SIGNAL(Hrule(int)), HR, SLOT(Draw(int))); |
||
246 | connect(fe, SIGNAL(Vrule(int)), VR, SLOT(Draw(int))); |
||
247 | connect(fe, SIGNAL(PgCh(int)), this, SLOT(setMenTxt(int))); |
||
248 | connect(fe, SIGNAL(ZoomIn()), this, SLOT(slotZoomIn2())); |
||
249 | connect(fe, SIGNAL(ZoomOut()), this, SLOT(slotZoomOut2())); |
||
250 | connect(fe, SIGNAL(ZoomAbs()), this, SLOT(slotDoZoom())); |
||
251 | connect(fe, SIGNAL(AbsPosi(int, int)), this, SLOT(SetCPo(int, int))); |
||
252 | connect(fe, SIGNAL(AbsPosi2(int, int)), this, SLOT(SetCCPo(int, int))); |
||
80 | Franz | 253 | return fe; |
3 | paul | 254 | } |
255 | |||
256 | /** Löscht eine Seite */ |
||
257 | void ScribusView::delPage(int Nr) |
||
258 | { |
||
259 | if (Doc->PageC == 1) |
||
260 | { return; } |
||
261 | if (Doc->PageC < Nr-1) |
||
262 | { return; } |
||
263 | removeChild(Pages.at(Nr)->parentWidget()); |
||
264 | delete Pages.at(Nr)->parentWidget(); |
||
265 | Pages.remove(Nr); |
||
108 | Franz | 266 | Doc->UnDoValid = false; |
3 | paul | 267 | Doc->PageC -= 1; |
268 | Doc->ActPage = Pages.at(0); |
||
115 | Franz | 269 | LA->setText( tr("Page %1").arg(1)); |
3 | paul | 270 | } |
271 | |||
272 | void ScribusView::movePage(int from, int to, int ziel, int art) |
||
273 | { |
||
274 | QPtrList<Page> Buf; |
||
275 | int a; |
||
276 | uint b; |
||
277 | int zz = ziel; |
||
278 | Buf.clear(); |
||
279 | for (a = from; a < to; a++) |
||
280 | { |
||
281 | Buf.append(Pages.at(from)); |
||
282 | Pages.remove(from); |
||
283 | if (a <= zz) |
||
80 | Franz | 284 | zz--; |
3 | paul | 285 | } |
286 | switch (art) |
||
287 | { |
||
288 | case 0: |
||
289 | for (b = 0; b < Buf.count(); b++) |
||
290 | { |
||
291 | Pages.insert(zz, Buf.at(b)); |
||
292 | zz++; |
||
293 | } |
||
294 | break; |
||
295 | case 1: |
||
296 | for (b = 0; b < Buf.count(); b++) |
||
297 | { |
||
298 | zz++; |
||
299 | Pages.insert(zz, Buf.at(b)); |
||
300 | } |
||
301 | break; |
||
302 | case 2: |
||
303 | for (b = 0; b < Buf.count(); b++) |
||
304 | { |
||
305 | Pages.append(Buf.at(b)); |
||
306 | } |
||
307 | break; |
||
308 | } |
||
309 | reformPages(); |
||
310 | } |
||
311 | |||
312 | void ScribusView::reformPages() |
||
80 | Franz | 313 | { |
3 | paul | 314 | uint a; |
315 | Page* Seite; |
||
316 | QWidget* PSeite = Doc->ActPage->parentWidget(); |
||
317 | for (a=0; a < Pages.count(); a++) |
||
318 | { |
||
319 | Seite = Pages.at(a); |
||
320 | Seite->PageNr = a; |
||
321 | PSeite = Seite->parentWidget(); |
||
322 | if (Doc->PageFP) |
||
323 | { |
||
324 | if (Doc->MasterP) |
||
325 | { |
||
326 | if (Seite->LeftPg) |
||
327 | { |
||
328 | Seite->Margins.Left = Doc->PageM.Right; |
||
329 | Seite->Margins.Right = Doc->PageM.Left; |
||
330 | } |
||
331 | else |
||
332 | { |
||
333 | Seite->Margins.Right = Doc->PageM.Right; |
||
334 | Seite->Margins.Left = Doc->PageM.Left; |
||
335 | } |
||
336 | } |
||
337 | else |
||
80 | Franz | 338 | { |
3 | paul | 339 | if (a % 2 == 0) |
340 | { |
||
341 | if (Doc->FirstPageLeft) |
||
342 | { |
||
343 | Seite->Margins.Left = Doc->PageM.Right; |
||
344 | Seite->Margins.Right = Doc->PageM.Left; |
||
345 | } |
||
346 | else |
||
347 | { |
||
348 | Seite->Margins.Right = Doc->PageM.Right; |
||
349 | Seite->Margins.Left = Doc->PageM.Left; |
||
350 | } |
||
351 | } |
||
352 | else |
||
353 | { |
||
354 | if (Doc->FirstPageLeft) |
||
355 | { |
||
356 | Seite->Margins.Right = Doc->PageM.Right; |
||
357 | Seite->Margins.Left = Doc->PageM.Left; |
||
358 | } |
||
359 | else |
||
360 | { |
||
361 | Seite->Margins.Left = Doc->PageM.Right; |
||
362 | Seite->Margins.Right = Doc->PageM.Left; |
||
363 | } |
||
364 | } |
||
365 | } |
||
366 | } |
||
367 | else |
||
368 | { |
||
369 | Seite->Margins.Right = Doc->PageM.Right; |
||
370 | Seite->Margins.Left = Doc->PageM.Left; |
||
371 | } |
||
372 | Seite->Margins.Top = Doc->PageM.Top; |
||
373 | Seite->Margins.Bottom = Doc->PageM.Bottom; |
||
374 | if (Doc->MasterP) |
||
375 | addChild(PSeite, static_cast<int>(10*Doc->Scale), static_cast<int>((Doc->PageC-1)*(PSeite->height()+25*Doc->Scale)+10*Doc->Scale)); |
||
376 | else |
||
377 | { |
||
45 | Franz | 378 | if ((Doc->PageFP) && (Doc->PagesSbS)) |
3 | paul | 379 | { |
380 | if (a % 2 == 0) |
||
381 | { |
||
382 | if (Doc->FirstPageLeft) |
||
383 | addChild(PSeite, static_cast<int>(10*Doc->Scale), |
||
384 | static_cast<int>(a/2 * (PSeite->height()+25*Doc->Scale)+10*Doc->Scale)); |
||
385 | else |
||
386 | addChild(PSeite, static_cast<int>(PSeite->width()+35*Doc->Scale), |
||
387 | static_cast<int>((a+1)/2 * (PSeite->height()+25*Doc->Scale)+10*Doc->Scale)); |
||
388 | } |
||
389 | else |
||
390 | { |
||
391 | if (Doc->FirstPageLeft) |
||
392 | addChild(PSeite, static_cast<int>(PSeite->width()+35*Doc->Scale), |
||
393 | static_cast<int>(a/2 * (PSeite->height()+25*Doc->Scale)+10*Doc->Scale)); |
||
394 | else |
||
395 | addChild(PSeite, static_cast<int>(10*Doc->Scale), |
||
396 | static_cast<int>((a+1)/2 * (PSeite->height()+25*Doc->Scale)+10*Doc->Scale)); |
||
397 | } |
||
398 | } |
||
399 | else |
||
400 | addChild(PSeite, static_cast<int>(10*Doc->Scale), static_cast<int>(a*(PSeite->height()+25*Doc->Scale)+10*Doc->Scale)); |
||
401 | } |
||
402 | } |
||
403 | PSeite = Doc->ActPage->parentWidget(); |
||
45 | Franz | 404 | if ((Doc->PageFP) && (Doc->PagesSbS)) |
3 | paul | 405 | { |
406 | if (Doc->FirstPageLeft) |
||
407 | resizeContents(static_cast<int>(PSeite->width()*2+60*Doc->Scale), |
||
408 | static_cast<int>(((Doc->PageC-1)/2 + 1) * (PSeite->height()+25*Doc->Scale)+30)); |
||
409 | else |
||
410 | resizeContents(static_cast<int>(PSeite->width()*2+60*Doc->Scale), |
||
411 | static_cast<int>((Doc->PageC/2 + 1) * (PSeite->height()+25*Doc->Scale)+30)); |
||
412 | setContentsPos(childX(Doc->ActPage->parentWidget())-static_cast<int>(10*Doc->Scale), |
||
413 | childY(Doc->ActPage->parentWidget())-static_cast<int>(10*Doc->Scale)); |
||
414 | } |
||
415 | else |
||
416 | { |
||
417 | resizeContents(static_cast<int>(PSeite->width()+30*Doc->Scale), static_cast<int>(Doc->PageC * (PSeite->height()+25*Doc->Scale)+30)); |
||
418 | setContentsPos(0, childY(Doc->ActPage->parentWidget())-static_cast<int>(10*Doc->Scale)); |
||
419 | } |
||
420 | setRulerPos(contentsX(), contentsY()); |
||
421 | PaMenu(); |
||
422 | setMenTxt(Doc->ActPage->PageNr); |
||
80 | Franz | 423 | } |
3 | paul | 424 | |
425 | void ScribusView::setMenTxt(int Seite) |
||
426 | { |
||
115 | Franz | 427 | LA->setText( tr("Page %1").arg(Seite+1)); |
3 | paul | 428 | } |
429 | |||
430 | void ScribusView::setLayMenTxt(int l) |
||
431 | { |
||
432 | LY->setText(Doc->Layers[l].Name); |
||
433 | } |
||
434 | |||
11 | Franz | 435 | /** Fuehrt die Vergroesserung/Verkleinerung aus */ |
3 | paul | 436 | void ScribusView::slotDoZoom() |
80 | Franz | 437 | { |
3 | paul | 438 | uint a; |
439 | Page* Seite; |
||
440 | QWidget* PSeite = Doc->ActPage->parentWidget(); |
||
441 | if (Doc->Scale > 32) |
||
442 | Doc->Scale = 32; |
||
443 | if (Pages.count() != 0) |
||
444 | { |
||
445 | for (a=0; a < Pages.count(); a++) |
||
446 | { |
||
447 | Seite = Pages.at(a); |
||
448 | PSeite = Seite->parentWidget(); |
||
449 | Seite->resize(static_cast<int>(Doc->PageB*Doc->Scale), static_cast<int>(Doc->PageH*Doc->Scale)); |
||
450 | PSeite->resize(static_cast<int>((Doc->PageB+5)*Doc->Scale), static_cast<int>((Doc->PageH+5)*Doc->Scale)); |
||
451 | if (Doc->MasterP) |
||
452 | addChild(PSeite, static_cast<int>(10*Doc->Scale), static_cast<int>((Doc->PageC-1)*(PSeite->height()+25*Doc->Scale)+10*Doc->Scale)); |
||
453 | else |
||
454 | { |
||
45 | Franz | 455 | if ((Doc->PageFP) && (Doc->PagesSbS)) |
3 | paul | 456 | { |
457 | if (a % 2 == 0) |
||
458 | { |
||
459 | if (Doc->FirstPageLeft) |
||
460 | addChild(PSeite, static_cast<int>(10*Doc->Scale), |
||
461 | static_cast<int>(a/2 * (PSeite->height()+25*Doc->Scale)+10*Doc->Scale)); |
||
462 | else |
||
463 | addChild(PSeite, static_cast<int>(PSeite->width()+35*Doc->Scale), |
||
464 | static_cast<int>((a+1)/2 * (PSeite->height()+25*Doc->Scale)+10*Doc->Scale)); |
||
465 | } |
||
466 | else |
||
467 | { |
||
468 | if (Doc->FirstPageLeft) |
||
469 | addChild(PSeite, static_cast<int>(PSeite->width()+35*Doc->Scale), |
||
470 | static_cast<int>(a/2 * (PSeite->height()+25*Doc->Scale)+10*Doc->Scale)); |
||
471 | else |
||
472 | addChild(PSeite, static_cast<int>(10*Doc->Scale), |
||
473 | static_cast<int>((a+1)/2 * (PSeite->height()+25*Doc->Scale)+10*Doc->Scale)); |
||
474 | } |
||
475 | } |
||
476 | else |
||
477 | addChild(PSeite, static_cast<int>(10*Doc->Scale), static_cast<int>(a*(PSeite->height()+25*Doc->Scale)+10*Doc->Scale)); |
||
478 | } |
||
479 | } |
||
45 | Franz | 480 | if ((Doc->PageFP) && (Doc->PagesSbS)) |
3 | paul | 481 | { |
482 | if (Doc->FirstPageLeft) |
||
483 | resizeContents(static_cast<int>(PSeite->width()*2+60*Doc->Scale), |
||
484 | static_cast<int>(((Doc->PageC-1)/2 + 1) * (PSeite->height()+25*Doc->Scale)+30)); |
||
485 | else |
||
486 | resizeContents(static_cast<int>(PSeite->width()*2+60*Doc->Scale), |
||
487 | static_cast<int>((Doc->PageC/2 + 1) * (PSeite->height()+25*Doc->Scale)+30)); |
||
488 | setContentsPos(childX(Doc->ActPage->parentWidget())-static_cast<int>(10*Doc->Scale), |
||
489 | childY(Doc->ActPage->parentWidget())-static_cast<int>(10*Doc->Scale)); |
||
490 | } |
||
491 | else |
||
492 | { |
||
493 | resizeContents(static_cast<int>(PSeite->width()+30*Doc->Scale), static_cast<int>(Doc->PageC * (PSeite->height()+25*Doc->Scale)+30)); |
||
494 | setContentsPos(0, childY(Doc->ActPage->parentWidget())-static_cast<int>(10*Doc->Scale)); |
||
495 | } |
||
68 | Franz | 496 | disconnect(LE, SIGNAL(valueChanged(int)), this, SLOT(Zval())); |
497 | LE->setValue(qRound(Doc->Scale/Prefs->DisScale*10000)); |
||
498 | connect(LE, SIGNAL(valueChanged(int)), this, SLOT(Zval())); |
||
3 | paul | 499 | setRulerPos(contentsX(), contentsY()); |
500 | if (Doc->ActPage->SelItem.count() != 0) |
||
501 | { |
||
502 | PageItem *b = Doc->ActPage->SelItem.at(0); |
||
503 | SetCCPo(static_cast<int>(b->Xpos + b->Width/2), static_cast<int>(b->Ypos + b->Height/2)); |
||
504 | } |
||
505 | } |
||
506 | } |
||
507 | |||
508 | void ScribusView::SetCCPo(int x, int y) |
||
509 | { |
||
510 | center(static_cast<int>(childX(Doc->ActPage->parentWidget())+x*Doc->Scale), static_cast<int>(childY(Doc->ActPage->parentWidget())+y*Doc->Scale)); |
||
80 | Franz | 511 | setRulerPos(contentsX(), contentsY()); |
3 | paul | 512 | } |
513 | |||
514 | void ScribusView::SetCPo(int x, int y) |
||
515 | { |
||
516 | setContentsPos(static_cast<int>(childX(Doc->ActPage->parentWidget())+x*Doc->Scale), static_cast<int>(childY(Doc->ActPage->parentWidget())+y*Doc->Scale)); |
||
80 | Franz | 517 | setRulerPos(contentsX(), contentsY()); |
3 | paul | 518 | } |
519 | |||
520 | void ScribusView::PaMenu() |
||
521 | { |
||
522 | uint a; |
||
523 | Seitmen->clear(); |
||
524 | if (Pages.count() != 0) |
||
525 | { |
||
526 | for (a=0; a < Pages.count(); a++) |
||
527 | { |
||
115 | Franz | 528 | Seitmen->insertItem( tr("Page %1").arg(a+1)); |
3 | paul | 529 | } |
530 | } |
||
531 | } |
||
532 | |||
533 | void ScribusView::LaMenu() |
||
534 | { |
||
535 | uint a; |
||
536 | Laymen->clear(); |
||
537 | if (Doc->Layers.count() != 0) |
||
538 | { |
||
539 | for (a=0; a < Doc->Layers.count(); a++) |
||
540 | { |
||
541 | Laymen->insertItem(Doc->Layers[a].Name); |
||
542 | } |
||
543 | } |
||
544 | } |
||
545 | |||
546 | void ScribusView::GotoLa(int l) |
||
547 | { |
||
548 | int d = Laymen->indexOf(l); |
||
549 | Doc->ActiveLayer = d; |
||
550 | LY->setText(Doc->Layers[d].Name); |
||
551 | emit changeLA(d); |
||
552 | } |
||
553 | |||
554 | void ScribusView::GotoPa(int Seite) |
||
555 | { |
||
556 | int d = Seitmen->indexOf(Seite); |
||
557 | GotoPage(d); |
||
558 | } |
||
559 | |||
560 | void ScribusView::ChgUnit(int art) |
||
561 | { |
||
562 | int d = Unitmen->indexOf(art); |
||
563 | emit changeUN(d); |
||
564 | } |
||
565 | |||
566 | void ScribusView::GotoPage(int Seite) |
||
567 | { |
||
568 | Doc->ActPage = Pages.at(Seite); |
||
569 | setContentsPos(static_cast<int>(childX(Doc->ActPage->parentWidget())-10*Doc->Scale), static_cast<int>(childY(Doc->ActPage->parentWidget())-10*Doc->Scale)); |
||
115 | Franz | 570 | LA->setText( tr("Page %1").arg(Seite+1)); |
3 | paul | 571 | } |
572 | |||
573 | /** Vergrößert die Ansicht */ |
||
574 | void ScribusView::slotZoomIn() |
||
575 | { |
||
576 | Doc->Scale *= 2; |
||
577 | if (Doc->Scale > 32) |
||
578 | Doc->Scale = 32; |
||
579 | slotDoZoom(); |
||
580 | } |
||
581 | |||
582 | /** Verkleinert die Ansicht */ |
||
583 | void ScribusView::slotZoomOut() |
||
584 | { |
||
585 | Doc->Scale /= 2; |
||
586 | slotDoZoom(); |
||
587 | } |
||
588 | |||
589 | /** Vergrößert die Ansicht */ |
||
590 | void ScribusView::slotZoomIn2() |
||
591 | { |
||
80 | Franz | 592 | Doc->Scale += static_cast<double>(Doc->MagStep)/100; |
593 | if (Doc->Scale > static_cast<double>(Doc->MagMax)/100) |
||
594 | Doc->Scale = static_cast<double>(Doc->MagMax)/100; |
||
3 | paul | 595 | slotDoZoom(); |
596 | } |
||
597 | |||
598 | /** Verkleinert die Ansicht */ |
||
599 | void ScribusView::slotZoomOut2() |
||
600 | { |
||
80 | Franz | 601 | Doc->Scale -= static_cast<double>(Doc->MagStep)/100; |
602 | if (Doc->Scale < static_cast<double>(Doc->MagMin)/100) |
||
603 | Doc->Scale = static_cast<double>(Doc->MagMin)/100; |
||
3 | paul | 604 | slotDoZoom(); |
605 | } |
||
606 | |||
607 | void ScribusView::DrawNew() |
||
80 | Franz | 608 | { |
3 | paul | 609 | uint a; |
610 | Page *b = Doc->ActPage; |
||
611 | if (Pages.count() != 0) |
||
612 | { |
||
613 | for (a=0; a < Pages.count(); a++) |
||
614 | { |
||
615 | Doc->ActPage = Pages.at(a); |
||
616 | Pages.at(a)->setEraseColor(Doc->papColor); |
||
617 | Pages.at(a)->update(); |
||
618 | } |
||
619 | } |
||
620 | HR->repX = false; |
||
621 | HR->repaint(); |
||
622 | VR->repaint(); |
||
623 | Doc->ActPage = b; |
||
68 | Franz | 624 | disconnect(LE, SIGNAL(valueChanged(int)), this, SLOT(Zval())); |
625 | LE->setValue(qRound(Doc->Scale/Prefs->DisScale*10000)); |
||
626 | connect(LE, SIGNAL(valueChanged(int)), this, SLOT(Zval())); |
||
3 | paul | 627 | } |
628 | |||
629 | int ScribusView::CountElements() |
||
630 | { |
||
631 | int cc = 0; |
||
632 | for (uint a=0; a < Pages.count(); a++) |
||
633 | cc += Pages.at(a)->Items.count(); |
||
634 | return cc; |
||
635 | } |
||
636 | |||
108 | Franz | 637 | void ScribusView::RecalcTextPos() |
638 | { |
||
639 | Doc->RePos = true; |
||
640 | QPixmap pgPix(10, 10); |
||
641 | QRect rd = QRect(0,0,9,9); |
||
642 | ScPainter *painter = new ScPainter(&pgPix, pgPix.width(), pgPix.height()); |
||
643 | for (uint az=0; az<MasterPages.count(); az++) |
||
644 | { |
||
645 | for (uint azz=0; azz<MasterPages.at(az)->Items.count(); ++azz) |
||
646 | { |
||
647 | PageItem *ite = MasterPages.at(az)->Items.at(azz); |
||
648 | if (ite->PType == 4) |
||
649 | ite->DrawObj(painter, rd); |
||
650 | } |
||
651 | } |
||
652 | for (uint az=0; az<Pages.count(); az++) |
||
653 | { |
||
654 | for (uint azz=0; azz<Pages.at(az)->Items.count(); ++azz) |
||
655 | { |
||
656 | PageItem *ite = Pages.at(az)->Items.at(azz); |
||
657 | if (ite->PType == 4) |
||
658 | ite->DrawObj(painter, rd); |
||
659 | } |
||
660 | } |
||
661 | delete painter; |
||
662 | Doc->RePos = false; |
||
663 | } |
||
664 | |||
3 | paul | 665 | void ScribusView::RecalcPictures(ProfilesL *Pr, QProgressBar *dia) |
80 | Franz | 666 | { |
3 | paul | 667 | uint a, i; |
668 | Page *b = Doc->ActPage; |
||
669 | PageItem* it; |
||
670 | int counter; |
||
671 | if (dia != NULL) |
||
672 | counter = dia->progress(); |
||
673 | else |
||
674 | counter = 0; |
||
675 | if (Pages.count() != 0) |
||
676 | { |
||
677 | for (a=0; a < Pages.count(); a++) |
||
678 | { |
||
679 | Doc->ActPage = Pages.at(a); |
||
680 | for (i=0; i < Pages.at(a)->Items.count(); i++) |
||
681 | { |
||
682 | it = Pages.at(a)->Items.at(i); |
||
68 | Franz | 683 | /* if (it->GrType != 0) |
684 | Pages.at(a)->UpdateGradient(it); */ |
||
3 | paul | 685 | if ((it->PType == 2) && (it->PicAvail)) |
686 | { |
||
687 | if (Pr->contains(it->IProfile)) |
||
688 | Pages.at(a)->LoadPict(it->Pfile, i); |
||
689 | else |
||
690 | { |
||
691 | it->IProfile = Doc->CMSSettings.DefaultInputProfile; |
||
692 | Pages.at(a)->LoadPict(it->Pfile, i); |
||
693 | } |
||
694 | it->Sizing = true; |
||
695 | Pages.at(a)->AdjustPreview(it); |
||
696 | it->Sizing = false; |
||
697 | } |
||
698 | counter++; |
||
699 | if (dia != NULL) |
||
700 | dia->setProgress(counter); |
||
701 | } |
||
702 | } |
||
703 | } |
||
704 | Doc->ActPage = b; |
||
705 | } |
||
706 | |||
707 | void ScribusView::ShowTemplate(int nr) |
||
708 | { |
||
709 | for (uint a=0; a<Pages.count(); a++) |
||
710 | { |
||
711 | Pages.at(a)->parentWidget()->hide(); |
||
712 | } |
||
713 | if (!Doc->MasterP) |
||
714 | { |
||
715 | DocPages = Pages; |
||
716 | Pages = MasterPages; |
||
717 | } |
||
718 | Doc->PageC = 1; |
||
719 | Doc->MasterP = true; |
||
720 | Doc->ActPage = Pages.at(nr); |
||
721 | Pages.at(nr)->parentWidget()->show(); |
||
722 | LA->setEnabled(false); |
||
723 | reformPages(); |
||
724 | slotDoZoom(); |
||
725 | } |
||
726 | |||
727 | void ScribusView::HideTemplate() |
||
728 | { |
||
729 | for (uint a=0; a<Pages.count(); a++) |
||
730 | { |
||
731 | Pages.at(a)->Deselect(true); |
||
732 | Pages.at(a)->parentWidget()->hide(); |
||
733 | } |
||
734 | MasterPages = Pages; |
||
735 | Doc->PageC = DocPages.count(); |
||
736 | Pages = DocPages; |
||
737 | Doc->MasterP = false; |
||
738 | Doc->ActPage = Pages.at(0); |
||
739 | for (uint a=0; a<Pages.count(); a++) |
||
740 | { |
||
741 | Pages.at(a)->parentWidget()->show(); |
||
742 | } |
||
743 | LA->setEnabled(true); |
||
744 | reformPages(); |
||
745 | GotoPage(0); |
||
746 | slotDoZoom(); |
||
747 | } |
||
748 | |||
749 | QPixmap ScribusView::MPageToPixmap(QString name, int maxGr) |
||
750 | { |
||
751 | QPixmap pm = QPixmap(static_cast<int>(Doc->PageB), static_cast<int>(Doc->PageH)); |
||
68 | Franz | 752 | ScPainter *painter = new ScPainter(&pm, pm.width(), pm.height()); |
80 | Franz | 753 | double sca = Doc->Scale; |
3 | paul | 754 | bool frs = Doc->ShFrames; |
755 | int Lnr; |
||
756 | struct Layer ll; |
||
757 | ll.Drucken = false; |
||
758 | ll.LNr = 0; |
||
759 | Doc->ShFrames = false; |
||
760 | Doc->Scale = 1; |
||
761 | PageItem *b; |
||
762 | PageItem *bb; |
||
763 | PageItem *nb; |
||
764 | Lnr = 0; |
||
765 | Page* Mp = MasterPages.at(MasterNames[name]); |
||
766 | QWidget* Opa; |
||
767 | Page* Opa2; |
||
768 | if (Mp->Items.count() != 0) |
||
769 | { |
||
770 | Lnr = 0; |
||
771 | for (uint la = 0; la < Doc->Layers.count(); la++) |
||
772 | { |
||
773 | Level2Layer(Doc, &ll, Lnr); |
||
774 | if (ll.Drucken) |
||
775 | { |
||
776 | for (uint a = 0; a < Mp->Items.count(); a++) |
||
777 | { |
||
778 | b = Mp->Items.at(a); |
||
779 | if (b->LayerNr != ll.LNr) |
||
780 | continue; |
||
781 | Opa = b->Parent; |
||
782 | Opa2 = b->OwnPage; |
||
783 | b->Parent = Mp; |
||
784 | b->OwnPage = Mp; |
||
785 | nb = b->NextBox; |
||
786 | bb = b->BackBox; |
||
787 | b->NextBox = 0; |
||
788 | b->BackBox = 0; |
||
68 | Franz | 789 | b->DrawObj(painter, QRect(0, 0, static_cast<int>(Doc->PageB), static_cast<int>(Doc->PageH))); |
3 | paul | 790 | b->NextBox = nb; |
791 | b->BackBox = bb; |
||
792 | b->Parent = Opa; |
||
793 | b->OwnPage = Opa2; |
||
794 | } |
||
795 | } |
||
796 | Lnr++; |
||
797 | } |
||
798 | } |
||
68 | Franz | 799 | painter->end(); |
3 | paul | 800 | Doc->ShFrames = frs; |
801 | Doc->Scale = sca; |
||
802 | QImage im2; |
||
803 | QImage im = pm.convertToImage(); |
||
80 | Franz | 804 | double sx = im.width() / static_cast<double>(maxGr); |
805 | double sy = im.height() / static_cast<double>(maxGr); |
||
3 | paul | 806 | if (sy < sx) |
807 | im2 = im.smoothScale(static_cast<int>(im.width() / sx), static_cast<int>(im.height() / sx)); |
||
808 | else |
||
809 | im2 = im.smoothScale(static_cast<int>(im.width() / sy), static_cast<int>(im.height() / sy)); |
||
810 | pm.convertFromImage(im2); |
||
811 | QPainter p; |
||
812 | p.begin(&pm); |
||
813 | p.setBrush(NoBrush); |
||
814 | p.setPen(black); |
||
815 | p.drawRect(0, 0, pm.width(), pm.height()); |
||
816 | p.end(); |
||
817 | im2.detach(); |
||
68 | Franz | 818 | delete painter; |
3 | paul | 819 | return pm; |
820 | } |
||
821 | |||
822 | QPixmap ScribusView::PageToPixmap(int Nr, int maxGr) |
||
823 | { |
||
824 | QPixmap pm = QPixmap(static_cast<int>(Doc->PageB), static_cast<int>(Doc->PageH)); |
||
68 | Franz | 825 | ScPainter *painter = new ScPainter(&pm, pm.width(), pm.height()); |
80 | Franz | 826 | double sca = Doc->Scale; |
3 | paul | 827 | bool frs = Doc->ShFrames; |
828 | int Lnr; |
||
829 | struct Layer ll; |
||
830 | ll.Drucken = false; |
||
831 | ll.LNr = 0; |
||
832 | Doc->ShFrames = false; |
||
833 | Doc->Scale = 1; |
||
834 | PageItem *b; |
||
835 | PageItem *bb; |
||
836 | PageItem *nb; |
||
837 | Lnr = 0; |
||
838 | if (Pages.at(Nr)->MPageNam != "") |
||
839 | { |
||
840 | Page* Mp = MasterPages.at(MasterNames[Pages.at(Nr)->MPageNam]); |
||
841 | QWidget* Opa; |
||
842 | Page* Opa2; |
||
843 | if (Mp->Items.count() != 0) |
||
844 | { |
||
845 | Lnr = 0; |
||
846 | for (uint la = 0; la < Doc->Layers.count(); la++) |
||
847 | { |
||
848 | Level2Layer(Doc, &ll, Lnr); |
||
849 | if (ll.Drucken) |
||
850 | { |
||
851 | for (uint a = 0; a < Mp->Items.count(); a++) |
||
852 | { |
||
853 | b = Mp->Items.at(a); |
||
854 | if (b->LayerNr != ll.LNr) |
||
855 | continue; |
||
856 | Opa = b->Parent; |
||
857 | Opa2 = b->OwnPage; |
||
858 | b->Parent = Pages.at(Nr); |
||
859 | b->OwnPage = Pages.at(Nr); |
||
860 | nb = b->NextBox; |
||
861 | bb = b->BackBox; |
||
862 | b->NextBox = 0; |
||
863 | b->BackBox = 0; |
||
68 | Franz | 864 | b->DrawObj(painter, QRect(0, 0, static_cast<int>(Doc->PageB), static_cast<int>(Doc->PageH))); |
3 | paul | 865 | b->NextBox = nb; |
866 | b->BackBox = bb; |
||
867 | b->Parent = Opa; |
||
868 | b->OwnPage = Opa2; |
||
869 | } |
||
870 | } |
||
871 | Lnr++; |
||
872 | } |
||
873 | } |
||
874 | } |
||
875 | Lnr = 0; |
||
876 | ll.Drucken = false; |
||
877 | ll.LNr = 0; |
||
878 | for (uint la2 = 0; la2 < Doc->Layers.count(); la2++) |
||
879 | { |
||
880 | Level2Layer(Doc, &ll, Lnr); |
||
881 | if (ll.Drucken) |
||
882 | { |
||
883 | for (uint a = 0; a < Pages.at(Nr)->Items.count(); a++) |
||
884 | { |
||
885 | b = Pages.at(Nr)->Items.at(a); |
||
886 | if (b->LayerNr != ll.LNr) |
||
887 | continue; |
||
888 | if (b->isPrintable) |
||
889 | { |
||
890 | if ((b->isAnnotation) && (b->AnType != 11)) |
||
891 | continue; |
||
892 | nb = b->NextBox; |
||
893 | bb = b->BackBox; |
||
894 | b->NextBox = 0; |
||
895 | b->BackBox = 0; |
||
68 | Franz | 896 | b->DrawObj(painter, QRect(0, 0, static_cast<int>(Doc->PageB), static_cast<int>(Doc->PageH))); |
3 | paul | 897 | b->NextBox = nb; |
898 | b->BackBox = bb; |
||
899 | } |
||
900 | } |
||
901 | } |
||
902 | Lnr++; |
||
903 | } |
||
68 | Franz | 904 | painter->end(); |
3 | paul | 905 | Doc->ShFrames = frs; |
906 | Doc->Scale = sca; |
||
907 | QImage im2; |
||
908 | QImage im = pm.convertToImage(); |
||
80 | Franz | 909 | double sx = im.width() / static_cast<double>(maxGr); |
910 | double sy = im.height() / static_cast<double>(maxGr); |
||
3 | paul | 911 | if (sy < sx) |
912 | im2 = im.smoothScale(static_cast<int>(im.width() / sx), static_cast<int>(im.height() / sx)); |
||
913 | else |
||
914 | im2 = im.smoothScale(static_cast<int>(im.width() / sy), static_cast<int>(im.height() / sy)); |
||
915 | pm.convertFromImage(im2); |
||
916 | QPainter p; |
||
917 | p.begin(&pm); |
||
918 | p.setBrush(NoBrush); |
||
919 | p.setPen(black); |
||
920 | p.drawRect(0, 0, pm.width(), pm.height()); |
||
921 | p.end(); |
||
922 | im2.detach(); |
||
68 | Franz | 923 | delete painter; |
3 | paul | 924 | return pm; |
925 | } |
||
926 | |||
927 | void ScribusView::CreatePS(PSLib *p, uint von, uint bis, int step, bool sep, QString SepNam, bool farb, bool Hm, bool Vm, bool Ic) |
||
928 | { |
||
929 | uint a; |
||
930 | int sepac; |
||
80 | Franz | 931 | double wideR; |
3 | paul | 932 | bool multiPath = false; |
108 | Franz | 933 | RecalcTextPos(); |
3 | paul | 934 | p->PS_set_Info("Author", Doc->DocAutor); |
935 | p->PS_set_Info("Title", Doc->DocTitel); |
||
936 | if (!farb) |
||
937 | p->PS_setGray(); |
||
938 | p->PS_begin_doc(Doc->PageOri, Doc->PageB, Doc->PageH, abs(bis-von)); |
||
939 | a = von; |
||
940 | sepac = 0; |
||
941 | for (uint ap = 0; ap < MasterPages.count(); ++ap) |
||
942 | { |
||
943 | if (MasterPages.at(ap)->Items.count() != 0) |
||
944 | { |
||
945 | if ((!sep) && (farb)) |
||
946 | { |
||
947 | for (uint api = 0; api < MasterPages.at(ap)->Items.count(); ++api) |
||
948 | { |
||
949 | PageItem *it = MasterPages.at(ap)->Items.at(api); |
||
950 | if ((it->PType == 2) && (it->PicAvail) && (it->Pfile != "") && (it->isPrintable)) |
||
20 | Franz | 951 | p->PS_ImageData(it->InvPict, it->Pfile, it->AnName, it->IProfile, it->UseEmbedded, Ic); |
3 | paul | 952 | } |
80 | Franz | 953 | } |
3 | paul | 954 | p->PS_TemplateStart(MasterPages.at(ap)->PageNam, Doc->PageB, Doc->PageH); |
955 | ProcessPage(p, MasterPages.at(ap), ap+1, sep, farb, Ic); |
||
956 | p->PS_TemplateEnd(); |
||
957 | } |
||
958 | } |
||
959 | while (a != bis) |
||
960 | { |
||
961 | p->PS_begin_page(Doc->PageB, Doc->PageH, &Pages.at(a)->Margins); |
||
962 | if (Hm) |
||
963 | { |
||
964 | p->PS_translate(Doc->PageB, 0); |
||
965 | p->PS_scale(-1, 1); |
||
966 | } |
||
967 | if (Vm) |
||
968 | { |
||
969 | p->PS_translate(0, Doc->PageH); |
||
970 | p->PS_scale(1, -1); |
||
971 | } |
||
972 | if (sep) |
||
973 | { |
||
974 | if (SepNam == "Black") |
||
975 | p->PS_plate(0); |
||
976 | if (SepNam == "Cyan") |
||
977 | p->PS_plate(1); |
||
978 | if (SepNam == "Magenta") |
||
979 | p->PS_plate(2); |
||
980 | if (SepNam == "Yellow") |
||
981 | p->PS_plate(3); |
||
982 | if (SepNam == tr("All")) |
||
983 | p->PS_plate(sepac); |
||
984 | } |
||
985 | if (Pages.at(a)->MPageNam != "") |
||
986 | { |
||
987 | int h, s, v, k, tsz; |
||
988 | QCString chxc; |
||
989 | QString chx; |
||
990 | struct Pti *hl; |
||
991 | int Lnr = 0; |
||
992 | struct Layer ll; |
||
993 | ll.Drucken = false; |
||
994 | ll.LNr = 0; |
||
995 | Page* mPage = MasterPages.at(MasterNames[Pages.at(a)->MPageNam]); |
||
996 | if (mPage->Items.count() != 0) |
||
997 | { |
||
998 | p->PS_UseTemplate(Pages.at(a)->MPageNam); |
||
999 | for (uint lam = 0; lam < Doc->Layers.count(); ++lam) |
||
1000 | { |
||
1001 | Level2Layer(Doc, &ll, Lnr); |
||
1002 | if (ll.Drucken) |
||
1003 | { |
||
1004 | for (uint am = 0; am < mPage->Items.count(); ++am) |
||
1005 | { |
||
1006 | PageItem *ite = mPage->Items.at(am); |
||
1007 | if (ite->Segments.count() != 0) |
||
1008 | multiPath = true; |
||
1009 | else |
||
1010 | multiPath = false; |
||
1011 | if ((ite->LayerNr != ll.LNr) || (!ite->isPrintable)) |
||
1012 | continue; |
||
1013 | if ((ite->PType == 2) && ((sep) || (!farb))) |
||
1014 | { |
||
1015 | p->PS_save(); |
||
1016 | p->PS_translate(ite->Xpos, Doc->PageH - ite->Ypos); |
||
1017 | if (ite->Rot != 0) |
||
1018 | p->PS_rotate(-ite->Rot); |
||
1019 | if (ite->Pcolor != "None") |
||
1020 | { |
||
1021 | SetFarbe(ite->Pcolor, ite->Shade, &h, &s, &v, &k); |
||
1022 | p->PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
68 | Franz | 1023 | SetClipPath(p, &ite->PoLine); |
3 | paul | 1024 | p->PS_closepath(); |
1025 | p->PS_fill(multiPath); |
||
1026 | } |
||
1027 | else |
||
1028 | p->PS_setcmykcolor_dummy(); |
||
68 | Franz | 1029 | SetClipPath(p, &ite->PoLine); |
3 | paul | 1030 | p->PS_closepath(); |
1031 | p->PS_clip(multiPath); |
||
9 | Franz | 1032 | p->PS_save(); |
3 | paul | 1033 | if ((ite->flippedH % 2) != 0) |
1034 | { |
||
1035 | p->PS_translate(ite->Width, 0); |
||
1036 | p->PS_scale(-1, 1); |
||
1037 | } |
||
1038 | if ((ite->flippedV % 2) != 0) |
||
1039 | { |
||
1040 | p->PS_translate(0, -ite->Height); |
||
1041 | p->PS_scale(1, -1); |
||
1042 | } |
||
1043 | if ((ite->PicAvail) && (ite->Pfile != "")) |
||
1044 | { |
||
1045 | p->PS_translate(0, -ite->BBoxH*ite->LocalScY); |
||
20 | Franz | 1046 | p->PS_image(ite->InvPict, -ite->BBoxX+ite->LocalX, -ite->LocalY, ite->Pfile, ite->LocalScX, ite->LocalScY, ite->IProfile, ite->UseEmbedded, Ic); |
3 | paul | 1047 | } |
1048 | p->PS_restore(); |
||
27 | Franz | 1049 | if ((ite->Pcolor2 != "None") || (ite->NamedLStyle != "")) |
9 | Franz | 1050 | { |
27 | Franz | 1051 | if (ite->NamedLStyle == "") |
1052 | { |
||
68 | Franz | 1053 | SetClipPath(p, &ite->PoLine); |
27 | Franz | 1054 | p->PS_closepath(); |
1055 | p->PS_stroke(); |
||
1056 | } |
||
1057 | else |
||
1058 | { |
||
1059 | multiLine ml = Doc->MLineStyles[ite->NamedLStyle]; |
||
34 | Franz | 1060 | for (int it = ml.size()-1; it > -1; it--) |
27 | Franz | 1061 | { |
1062 | SetFarbe(ml[it].Color, ml[it].Shade, &h, &s, &v, &k); |
||
1063 | p->PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1064 | p->PS_setlinewidth(ml[it].Width); |
||
1065 | p->PS_setdash(static_cast<PenStyle>(ml[it].Dash), static_cast<PenCapStyle>(ml[it].LineEnd), static_cast<PenJoinStyle>(ml[it].LineJoin)); |
||
68 | Franz | 1066 | SetClipPath(p, &ite->PoLine); |
27 | Franz | 1067 | p->PS_closepath(); |
1068 | p->PS_stroke(); |
||
1069 | } |
||
1070 | } |
||
9 | Franz | 1071 | } |
1072 | p->PS_restore(); |
||
3 | paul | 1073 | } |
1074 | if (ite->PType == 4) |
||
1075 | { |
||
1076 | p->PS_save(); |
||
1077 | if (ite->Pcolor != "None") |
||
1078 | { |
||
1079 | SetFarbe(ite->Pcolor, ite->Shade, &h, &s, &v, &k); |
||
1080 | p->PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1081 | } |
||
1082 | p->PS_translate(ite->Xpos, Doc->PageH - ite->Ypos); |
||
80 | Franz | 1083 | if (ite->Rot != 0) |
3 | paul | 1084 | p->PS_rotate(-ite->Rot); |
1085 | if ((ite->Pcolor != "None") || (ite->GrType != 0)) |
||
1086 | { |
||
68 | Franz | 1087 | SetClipPath(p, &ite->PoLine); |
3 | paul | 1088 | p->PS_closepath(); |
27 | Franz | 1089 | p->PS_fill(multiPath); |
3 | paul | 1090 | } |
1091 | if ((ite->flippedH % 2) != 0) |
||
1092 | { |
||
1093 | p->PS_translate(ite->Width, 0); |
||
1094 | p->PS_scale(-1, 1); |
||
1095 | } |
||
1096 | if ((ite->flippedV % 2) != 0) |
||
1097 | { |
||
1098 | p->PS_translate(0, -ite->Height); |
||
1099 | p->PS_scale(1, -1); |
||
1100 | } |
||
1101 | for (uint d = 0; d < ite->MaxChars; ++d) |
||
1102 | { |
||
1103 | hl = ite->Ptext.at(d); |
||
1104 | if ((hl->ch == QChar(13)) || (hl->ch == QChar(10))) // || (hl->ch == QChar(32))) |
||
1105 | continue; |
||
1106 | if (hl->yp == 0) |
||
1107 | break; |
||
1108 | tsz = hl->csize; |
||
1109 | chx = hl->ch; |
||
55 | Franz | 1110 | if (hl->ch == QChar(29)) |
1111 | chx = " "; |
||
3 | paul | 1112 | if (hl->ch == QChar(30)) |
1113 | { |
||
1114 | if (Doc->MasterP) |
||
1115 | chx = "#"; |
||
1116 | else |
||
1117 | { |
||
1118 | uint zae = 0; |
||
1119 | while (ite->Ptext.at(d+zae)->ch == QChar(30)) |
||
1120 | { |
||
1121 | zae++; |
||
1122 | if (d+zae == ite->MaxChars) |
||
1123 | break; |
||
1124 | } |
||
1125 | QString out="%1"; |
||
1126 | chx = out.arg(a+Doc->FirstPnum, zae).right(zae).left(1); |
||
1127 | } |
||
1128 | } |
||
1129 | if (hl->cstyle & 64) |
||
1130 | { |
||
1131 | if (chx.upper() != chx) |
||
1132 | { |
||
1133 | tsz = hl->csize * Doc->VKapit / 100; |
||
1134 | chx = chx.upper(); |
||
1135 | } |
||
1136 | } |
||
1137 | if (hl->cstyle & 1) |
||
1138 | tsz = hl->csize * Doc->VHochSc / 100; |
||
1139 | if (hl->cstyle & 2) |
||
1140 | tsz = hl->csize * Doc->VHochSc / 100; |
||
68 | Franz | 1141 | if (((*Doc->AllFonts)[hl->cfont]->isOTF) || ((*Doc->AllFonts)[hl->cfont]->Subset)) |
3 | paul | 1142 | { |
68 | Franz | 1143 | uint chr = chx[0].unicode(); |
1144 | if (((*Doc->AllFonts)[hl->cfont]->CharWidth.contains(chr)) && (chr != 32)) |
||
1145 | { |
||
1146 | p->PS_save(); |
||
1147 | if (ite->Reverse) |
||
1148 | { |
||
111 | Franz | 1149 | p->PS_translate(hl->xp, (hl->yp - (tsz / 10.0)) * -1); |
68 | Franz | 1150 | p->PS_scale(-1, 1); |
1151 | if (d < ite->MaxChars-1) |
||
1152 | { |
||
1153 | QString ctx = ite->Ptext.at(d+1)->ch; |
||
1154 | if (ctx == QChar(29)) |
||
1155 | ctx = " "; |
||
1156 | wideR = -Cwidth(Doc, hl->cfont, chx, tsz, ctx) * (hl->cscale / 100.0); |
||
1157 | } |
||
1158 | else |
||
1159 | wideR = -Cwidth(Doc, hl->cfont, chx, tsz) * (hl->cscale / 100.0); |
||
1160 | p->PS_translate(wideR, 0); |
||
1161 | } |
||
1162 | else |
||
111 | Franz | 1163 | p->PS_translate(hl->xp, (hl->yp - (tsz / 10.0)) * -1); |
68 | Franz | 1164 | if (hl->cscale != 100) |
1165 | p->PS_scale(hl->cscale / 100.0, 1); |
||
1166 | if (hl->ccolor != "None") |
||
1167 | { |
||
1168 | SetFarbe(hl->ccolor, hl->cshade, &h, &s, &v, &k); |
||
1169 | p->PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
111 | Franz | 1170 | p->PS_showSub(chr, (*Doc->AllFonts)[hl->cfont]->RealName(), tsz / 10.0, false); |
68 | Franz | 1171 | } |
1172 | p->PS_restore(); |
||
1173 | } |
||
3 | paul | 1174 | } |
68 | Franz | 1175 | else |
3 | paul | 1176 | { |
111 | Franz | 1177 | p->PS_selectfont(hl->cfont, tsz / 10.0); |
68 | Franz | 1178 | if (hl->ccolor != "None") |
1179 | { |
||
1180 | SetFarbe(hl->ccolor, hl->cshade, &h, &s, &v, &k); |
||
1181 | p->PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1182 | } |
||
1183 | p->PS_save(); |
||
3 | paul | 1184 | if (ite->Reverse) |
1185 | { |
||
1186 | int chs = hl->csize; |
||
68 | Franz | 1187 | ite->SetZeichAttr(hl, &chs, &chx); |
3 | paul | 1188 | p->PS_translate(hl->xp, -hl->yp); |
1189 | p->PS_scale(-1, 1); |
||
1190 | if (d < ite->MaxChars-1) |
||
55 | Franz | 1191 | { |
1192 | QString ctx = ite->Ptext.at(d+1)->ch; |
||
1193 | if (ctx == QChar(29)) |
||
1194 | ctx = " "; |
||
68 | Franz | 1195 | wideR = -Cwidth(Doc, hl->cfont, chx, chs, ctx) * (hl->cscale / 100.0); |
1196 | p->PS_translate(wideR, 0); |
||
55 | Franz | 1197 | } |
3 | paul | 1198 | else |
68 | Franz | 1199 | { |
1200 | wideR = -Cwidth(Doc, hl->cfont, chx, chs) * (hl->cscale / 100.0); |
||
1201 | p->PS_translate(wideR, 0); |
||
1202 | } |
||
1203 | if (hl->cscale != 100) |
||
1204 | p->PS_scale(hl->cscale / 100.0, 1); |
||
3 | paul | 1205 | p->PS_show_xyG(hl->cfont, chx, 0, 0); |
1206 | } |
||
1207 | else |
||
68 | Franz | 1208 | { |
1209 | p->PS_translate(hl->xp, -hl->yp); |
||
1210 | if (hl->cscale != 100) |
||
1211 | p->PS_scale(hl->cscale / 100.0, 1); |
||
1212 | p->PS_show_xyG(hl->cfont, chx, 0, 0); |
||
1213 | } |
||
1214 | p->PS_restore(); |
||
3 | paul | 1215 | } |
68 | Franz | 1216 | if ((hl->cstyle & 4) && (chx != QChar(13))) |
3 | paul | 1217 | { |
68 | Franz | 1218 | uint chr = chx[0].unicode(); |
1219 | if ((*Doc->AllFonts)[hl->cfont]->CharWidth.contains(chr)) |
||
3 | paul | 1220 | { |
68 | Franz | 1221 | FPointArray gly = (*Doc->AllFonts)[hl->cfont]->GlyphArray[chr].Outlines.copy(); |
1222 | QWMatrix chma; |
||
111 | Franz | 1223 | chma.scale(tsz / 100.0, tsz / 100.0); |
68 | Franz | 1224 | gly.map(chma); |
1225 | chma = QWMatrix(); |
||
1226 | chma.scale(hl->cscale / 100.0, 1); |
||
1227 | gly.map(chma); |
||
3 | paul | 1228 | if (ite->Reverse) |
1229 | { |
||
68 | Franz | 1230 | chma = QWMatrix(); |
1231 | chma.scale(-1, 1); |
||
1232 | chma.translate(wideR, 0); |
||
1233 | gly.map(chma); |
||
1234 | } |
||
1235 | if (hl->cstroke != "None") |
||
1236 | { |
||
3 | paul | 1237 | p->PS_save(); |
111 | Franz | 1238 | p->PS_setlinewidth(QMAX((*Doc->AllFonts)[hl->cfont]->strokeWidth / 2 * (tsz / 10.0), 1)); |
68 | Franz | 1239 | p->PS_setdash(SolidLine, FlatCap, MiterJoin); |
1240 | p->PS_translate(hl->xp, (hl->yp - tsz) * -1); |
||
1241 | SetFarbe(hl->cstroke, hl->cshade2, &h, &s, &v, &k); |
||
1242 | p->PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1243 | SetClipPath(p, &gly); |
||
1244 | p->PS_closepath(); |
||
1245 | p->PS_stroke(); |
||
3 | paul | 1246 | p->PS_restore(); |
1247 | } |
||
1248 | } |
||
68 | Franz | 1249 | } |
1250 | if (hl->cstyle & 16) |
||
1251 | { |
||
80 | Franz | 1252 | double Ulen = Cwidth(Doc, hl->cfont, chx, hl->csize) * (hl->cscale / 100.0); |
111 | Franz | 1253 | double Upos = (*Doc->AllFonts)[hl->cfont]->strikeout_pos * (tsz / 10.0); |
68 | Franz | 1254 | if (hl->ccolor != "None") |
3 | paul | 1255 | { |
68 | Franz | 1256 | p->PS_setdash(SolidLine, FlatCap, MiterJoin); |
1257 | SetFarbe(hl->ccolor, hl->cshade, &h, &s, &v, &k); |
||
1258 | p->PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1259 | } |
||
111 | Franz | 1260 | p->PS_setlinewidth((*Doc->AllFonts)[hl->cfont]->strokeWidth * (tsz / 10.0)); |
68 | Franz | 1261 | p->PS_moveto(hl->xp, -hl->yp+Upos); |
1262 | p->PS_lineto(hl->xp+Ulen, -hl->yp+Upos); |
||
1263 | p->PS_stroke(); |
||
1264 | } |
||
1265 | if ((hl->cstyle & 128) && (((ite->Ptext.at(QMIN(d+1, ite->Ptext.count()-1))->yp != hl->yp) && (ite->Ptext.at(QMIN(d+1, ite->Ptext.count()-1))->ch != QChar(13))) || ((ite->NextBox != 0) && (d == ite->Ptext.count()-1)))) |
||
1266 | { |
||
1267 | int chs = hl->csize; |
||
1268 | ite->SetZeichAttr(hl, &chs, &chx); |
||
80 | Franz | 1269 | double wide = Cwidth(Doc, hl->cfont, chx, chs); |
75 | Franz | 1270 | chx = "-"; |
1271 | uint chr = chx[0].unicode(); |
||
1272 | if ((*Doc->AllFonts)[hl->cfont]->CharWidth.contains(chr)) |
||
1273 | { |
||
1274 | FPointArray gly = (*Doc->AllFonts)[hl->cfont]->GlyphArray[chr].Outlines.copy(); |
||
1275 | QWMatrix chma; |
||
111 | Franz | 1276 | chma.scale(tsz / 100.0, tsz / 100.0); |
75 | Franz | 1277 | gly.map(chma); |
1278 | chma = QWMatrix(); |
||
1279 | chma.scale(hl->cscale / 100.0, 1); |
||
1280 | gly.map(chma); |
||
1281 | if (hl->ccolor != "None") |
||
1282 | { |
||
1283 | p->PS_save(); |
||
111 | Franz | 1284 | p->PS_translate(hl->xp+wide, (hl->yp - (tsz / 10.0)) * -1); |
75 | Franz | 1285 | SetFarbe(hl->ccolor, hl->cshade, &h, &s, &v, &k); |
1286 | p->PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1287 | SetClipPath(p, &gly); |
||
1288 | p->PS_closepath(); |
||
1289 | p->PS_fill(true); |
||
1290 | p->PS_restore(); |
||
1291 | } |
||
1292 | } |
||
68 | Franz | 1293 | } |
1294 | if ((hl->cstyle & 8) && (chx != QChar(13))) |
||
1295 | { |
||
1296 | int chs = hl->csize; |
||
1297 | ite->SetZeichAttr(hl, &chs, &chx); |
||
80 | Franz | 1298 | double csi = chs / 10.0; |
1299 | double wid = Cwidth(Doc, hl->cfont, chx, chs) * (hl->cscale / 100.0); |
||
111 | Franz | 1300 | QPixmap pgPix(static_cast<int>(wid), static_cast<int>(hl->csize / 10.0)); |
1301 | ScPainter *painter = new ScPainter(&pgPix, static_cast<int>(wid), static_cast<int>(hl->csize / 10.0)); |
||
68 | Franz | 1302 | QString psSt = "1 -1 scale\n"; |
1303 | uint chr = chx[0].unicode(); |
||
1304 | if ((*Doc->AllFonts)[hl->cfont]->CharWidth.contains(chr)) |
||
1305 | { |
||
1306 | FPointArray gly = (*Doc->AllFonts)[hl->cfont]->GlyphArray[chr].Outlines.copy(); |
||
111 | Franz | 1307 | double st = (*Doc->AllFonts)[hl->cfont]->underline_pos * csi; |
1308 | painter->setLineWidth(QMAX((*Doc->AllFonts)[hl->cfont]->strokeWidth * csi, 1)); |
||
68 | Franz | 1309 | if (gly.size() < 4) |
1310 | { |
||
1311 | gly.resize(0); |
||
1312 | gly.addPoint(FPoint(0,0)); |
||
1313 | gly.addPoint(FPoint(0,0)); |
||
1314 | gly.addPoint(FPoint(1,0)); |
||
1315 | gly.addPoint(FPoint(1,0)); |
||
1316 | } |
||
1317 | QWMatrix chma; |
||
111 | Franz | 1318 | chma.scale(csi / 10.0, csi / 10.0); |
68 | Franz | 1319 | gly.map(chma); |
1320 | chma = QWMatrix(); |
||
1321 | chma.scale(hl->cscale / 100.0, 1); |
||
1322 | gly.map(chma); |
||
1323 | painter->setupPolygon(&gly); |
||
111 | Franz | 1324 | painter->drawUnderline(FPoint(0-hl->cextra, csi-st), FPoint(wid, csi-st), true, &psSt); |
68 | Franz | 1325 | p->PS_save(); |
3 | paul | 1326 | if (ite->Reverse) |
1327 | { |
||
68 | Franz | 1328 | p->PS_translate(hl->xp, (hl->yp - st) * -1); |
3 | paul | 1329 | p->PS_scale(-1, 1); |
68 | Franz | 1330 | p->PS_translate(-wid, 0); |
3 | paul | 1331 | } |
1332 | else |
||
68 | Franz | 1333 | p->PS_translate(hl->xp, (hl->yp - st) * -1); |
1334 | if (hl->ccolor != "None") |
||
1335 | { |
||
1336 | SetFarbe(hl->ccolor, hl->cshade, &h, &s, &v, &k); |
||
1337 | p->PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1338 | } |
||
1339 | p->PS_insert(psSt+"closepath\n"); |
||
1340 | p->PS_fill(true); |
||
1341 | p->PS_restore(); |
||
1342 | painter->end(); |
||
1343 | delete painter; |
||
3 | paul | 1344 | } |
1345 | } |
||
68 | Franz | 1346 | } |
1347 | if ((ite->Pcolor2 != "None") || (ite->NamedLStyle != "")) |
||
1348 | { |
||
1349 | SetFarbe(ite->Pcolor2, ite->Shade2, &h, &s, &v, &k); |
||
1350 | p->PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1351 | p->PS_setlinewidth(ite->Pwidth); |
||
1352 | p->PS_setdash(ite->PLineArt, ite->PLineEnd, ite->PLineJoin); |
||
1353 | if (ite->NamedLStyle == "") |
||
3 | paul | 1354 | { |
68 | Franz | 1355 | SetClipPath(p, &ite->PoLine); |
1356 | p->PS_closepath(); |
||
1357 | p->PS_stroke(); |
||
3 | paul | 1358 | } |
68 | Franz | 1359 | else |
1360 | { |
||
1361 | multiLine ml = Doc->MLineStyles[ite->NamedLStyle]; |
||
1362 | for (int it = ml.size()-1; it > -1; it--) |
||
1363 | { |
||
1364 | SetFarbe(ml[it].Color, ml[it].Shade, &h, &s, &v, &k); |
||
1365 | p->PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1366 | p->PS_setlinewidth(ml[it].Width); |
||
1367 | p->PS_setdash(static_cast<PenStyle>(ml[it].Dash), static_cast<PenCapStyle>(ml[it].LineEnd), static_cast<PenJoinStyle>(ml[it].LineJoin)); |
||
1368 | SetClipPath(p, &ite->PoLine); |
||
1369 | p->PS_closepath(); |
||
1370 | p->PS_stroke(); |
||
1371 | } |
||
1372 | } |
||
3 | paul | 1373 | } |
1374 | p->PS_restore(); |
||
1375 | } |
||
1376 | } |
||
1377 | } |
||
1378 | Lnr++; |
||
1379 | } |
||
1380 | } |
||
1381 | } |
||
1382 | ProcessPage(p, Pages.at(a), a+1, sep, farb, Ic); |
||
1383 | p->PS_end_page(); |
||
1384 | if (sep) |
||
1385 | { |
||
1386 | if (SepNam != tr("All")) |
||
1387 | a += step; |
||
1388 | else |
||
1389 | { |
||
1390 | if (sepac == 3) |
||
1391 | { |
||
1392 | a += step; |
||
1393 | sepac = 0; |
||
1394 | } |
||
1395 | else |
||
1396 | sepac++; |
||
1397 | } |
||
1398 | } |
||
1399 | else |
||
1400 | a += step; |
||
1401 | } |
||
1402 | p->PS_close(); |
||
1403 | } |
||
1404 | |||
1405 | void ScribusView::ProcessPage(PSLib *p, Page* a, uint PNr, bool sep, bool farb, bool ic) |
||
1406 | { |
||
1407 | uint b, d; |
||
1408 | int h, s, v, k, tsz; |
||
80 | Franz | 1409 | double wideR; |
3 | paul | 1410 | QCString chxc; |
68 | Franz | 1411 | QString chx, chglyph, tmp; |
3 | paul | 1412 | PageItem *c; |
1413 | struct Pti *hl; |
||
1414 | bool multiPath = false; |
||
1415 | int Lnr = 0; |
||
1416 | struct Layer ll; |
||
1417 | ll.Drucken = false; |
||
1418 | ll.LNr = 0; |
||
1419 | for (uint la = 0; la < Doc->Layers.count(); ++la) |
||
1420 | { |
||
1421 | Level2Layer(Doc, &ll, Lnr); |
||
1422 | if (ll.Drucken) |
||
1423 | { |
||
1424 | for (b = 0; b < a->Items.count(); ++b) |
||
1425 | { |
||
1426 | c = a->Items.at(b); |
||
1427 | if (c->Segments.count() != 0) |
||
1428 | multiPath = true; |
||
1429 | else |
||
1430 | multiPath = false; |
||
1431 | if (c->LayerNr != ll.LNr) |
||
1432 | continue; |
||
1433 | if ((a->PageNam != "") && (c->PType == 4)) |
||
1434 | continue; |
||
1435 | if ((a->PageNam != "") && (c->PType == 2) && ((sep) || (!farb))) |
||
1436 | continue; |
||
1437 | if (c->isPrintable) |
||
1438 | { |
||
1439 | p->PS_save(); |
||
1440 | if (c->Pcolor != "None") |
||
1441 | { |
||
1442 | SetFarbe(c->Pcolor, c->Shade, &h, &s, &v, &k); |
||
1443 | p->PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1444 | } |
||
1445 | if (c->Pcolor2 != "None") |
||
1446 | { |
||
1447 | SetFarbe(c->Pcolor2, c->Shade2, &h, &s, &v, &k); |
||
1448 | p->PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1449 | } |
||
1450 | p->PS_setlinewidth(c->Pwidth); |
||
1451 | p->PS_setdash(c->PLineArt, c->PLineEnd, c->PLineJoin); |
||
1452 | p->PS_translate(c->Xpos, Doc->PageH - c->Ypos); |
||
1453 | if (c->Rot != 0) |
||
1454 | p->PS_rotate(-c->Rot); |
||
1455 | switch (c->PType) |
||
1456 | { |
||
1457 | case 2: |
||
27 | Franz | 1458 | if ((c->Pcolor != "None") || (c->GrType != 0)) |
3 | paul | 1459 | { |
68 | Franz | 1460 | SetClipPath(p, &c->PoLine); |
3 | paul | 1461 | p->PS_closepath(); |
27 | Franz | 1462 | if ((c->GrType != 0) && (a->PageNam == "")) |
1463 | { |
||
1464 | SetFarbe(c->GrColor2, c->GrShade2, &h, &s, &v, &k); |
||
1465 | p->PS_GradientCol1(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1466 | SetFarbe(c->GrColor, c->GrShade, &h, &s, &v, &k); |
||
1467 | p->PS_GradientCol2(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1468 | switch (c->GrType) |
||
1469 | { |
||
1470 | case 1: |
||
1471 | case 2: |
||
1472 | case 3: |
||
1473 | case 4: |
||
1474 | p->PS_LinGradient(c->Width, -c->Height, c->PType, c->GrType, multiPath); |
||
1475 | break; |
||
1476 | case 5: |
||
1477 | p->PS_RadGradient(c->Width, -c->Height, c->PType, multiPath); |
||
1478 | break; |
||
1479 | default: |
||
1480 | break; |
||
1481 | } |
||
1482 | } |
||
1483 | else |
||
1484 | p->PS_fill(multiPath); |
||
3 | paul | 1485 | } |
27 | Franz | 1486 | p->PS_save(); |
68 | Franz | 1487 | SetClipPath(p, &c->PoLine); |
3 | paul | 1488 | p->PS_closepath(); |
1489 | p->PS_clip(multiPath); |
||
1490 | if ((c->flippedH % 2) != 0) |
||
1491 | { |
||
1492 | p->PS_translate(c->Width, 0); |
||
1493 | p->PS_scale(-1, 1); |
||
1494 | } |
||
1495 | if ((c->flippedV % 2) != 0) |
||
1496 | { |
||
1497 | p->PS_translate(0, -c->Height); |
||
1498 | p->PS_scale(1, -1); |
||
1499 | } |
||
1500 | if ((c->PicAvail) && (c->Pfile != "")) |
||
1501 | { |
||
1502 | p->PS_translate(0, -c->BBoxH*c->LocalScY); |
||
1503 | if (a->PageNam != "") |
||
20 | Franz | 1504 | p->PS_image(c->InvPict, -c->BBoxX+c->LocalX, -c->LocalY, c->Pfile, c->LocalScX, c->LocalScY, c->IProfile, c->UseEmbedded, ic, c->AnName); |
3 | paul | 1505 | else |
20 | Franz | 1506 | p->PS_image(c->InvPict, -c->BBoxX+c->LocalX, -c->LocalY, c->Pfile, c->LocalScX, c->LocalScY, c->IProfile, c->UseEmbedded, ic); |
9 | Franz | 1507 | } |
1508 | p->PS_restore(); |
||
27 | Franz | 1509 | if ((c->Pcolor2 != "None") || (c->NamedLStyle != "")) |
9 | Franz | 1510 | { |
27 | Franz | 1511 | if (c->NamedLStyle == "") |
1512 | { |
||
68 | Franz | 1513 | SetClipPath(p, &c->PoLine); |
27 | Franz | 1514 | p->PS_closepath(); |
1515 | p->PS_stroke(); |
||
1516 | } |
||
1517 | else |
||
1518 | { |
||
1519 | multiLine ml = Doc->MLineStyles[c->NamedLStyle]; |
||
34 | Franz | 1520 | for (int it = ml.size()-1; it > -1; it--) |
27 | Franz | 1521 | { |
1522 | SetFarbe(ml[it].Color, ml[it].Shade, &h, &s, &v, &k); |
||
1523 | p->PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1524 | p->PS_setlinewidth(ml[it].Width); |
||
1525 | p->PS_setdash(static_cast<PenStyle>(ml[it].Dash), static_cast<PenCapStyle>(ml[it].LineEnd), static_cast<PenJoinStyle>(ml[it].LineJoin)); |
||
68 | Franz | 1526 | SetClipPath(p, &c->PoLine); |
27 | Franz | 1527 | p->PS_closepath(); |
1528 | p->PS_stroke(); |
||
1529 | } |
||
1530 | } |
||
80 | Franz | 1531 | } |
3 | paul | 1532 | break; |
1533 | case 4: |
||
1534 | if (c->isBookmark) |
||
1535 | { |
||
1536 | QString bm = ""; |
||
1537 | QString cc; |
||
1538 | for (d = 0; d < c->Ptext.count(); ++d) |
||
1539 | { |
||
1540 | if ((c->Ptext.at(d)->ch == QChar(13)) || (c->Ptext.at(d)->ch == QChar(10))) |
||
1541 | break; |
||
55 | Franz | 1542 | bm += "\\"+cc.setNum(QMAX(c->Ptext.at(d)->ch.at(0).unicode(), 32), 8); |
3 | paul | 1543 | } |
1544 | p->PDF_Bookmark(bm, a->PageNr+1); |
||
1545 | } |
||
1546 | if (c->isAnnotation) |
||
1547 | { |
||
1548 | QString bm = ""; |
||
1549 | QString cc; |
||
1550 | for (d = 0; d < c->Ptext.count(); ++d) |
||
1551 | { |
||
55 | Franz | 1552 | bm += "\\"+cc.setNum(QMAX(c->Ptext.at(d)->ch.at(0).unicode(), 32), 8); |
3 | paul | 1553 | } |
1554 | p->PDF_Annotation(bm, 0, 0, c->Width, -c->Height); |
||
1555 | break; |
||
1556 | } |
||
1557 | if ((c->Pcolor != "None") || (c->GrType != 0)) |
||
1558 | { |
||
68 | Franz | 1559 | SetClipPath(p, &c->PoLine); |
3 | paul | 1560 | p->PS_closepath(); |
1561 | if ((c->GrType != 0) && (a->PageNam == "")) |
||
1562 | { |
||
1563 | SetFarbe(c->GrColor2, c->GrShade2, &h, &s, &v, &k); |
||
1564 | p->PS_GradientCol1(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1565 | SetFarbe(c->GrColor, c->GrShade, &h, &s, &v, &k); |
||
1566 | p->PS_GradientCol2(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1567 | switch (c->GrType) |
||
1568 | { |
||
1569 | case 1: |
||
1570 | case 2: |
||
1571 | case 3: |
||
1572 | case 4: |
||
1573 | p->PS_LinGradient(c->Width, -c->Height, c->PType, c->GrType, multiPath); |
||
1574 | break; |
||
1575 | case 5: |
||
1576 | p->PS_RadGradient(c->Width, -c->Height, c->PType, multiPath); |
||
1577 | break; |
||
1578 | default: |
||
1579 | break; |
||
1580 | } |
||
1581 | } |
||
1582 | else |
||
1583 | p->PS_fill(multiPath); |
||
1584 | } |
||
1585 | if ((c->flippedH % 2) != 0) |
||
1586 | { |
||
1587 | p->PS_translate(c->Width, 0); |
||
1588 | p->PS_scale(-1, 1); |
||
1589 | } |
||
1590 | if ((c->flippedV % 2) != 0) |
||
1591 | { |
||
1592 | p->PS_translate(0, -c->Height); |
||
1593 | p->PS_scale(1, -1); |
||
1594 | } |
||
1595 | for (d = 0; d < c->MaxChars; ++d) |
||
1596 | { |
||
1597 | hl = c->Ptext.at(d); |
||
55 | Franz | 1598 | if ((hl->ch == QChar(13)) || (hl->ch == QChar(10))) |
3 | paul | 1599 | continue; |
1600 | if (hl->yp == 0) |
||
1601 | break; |
||
1602 | tsz = hl->csize; |
||
1603 | chx = hl->ch; |
||
55 | Franz | 1604 | if (hl->ch == QChar(29)) |
1605 | chx = " "; |
||
3 | paul | 1606 | if (hl->ch == QChar(30)) |
1607 | { |
||
1608 | if (Doc->MasterP) |
||
1609 | chx = "#"; |
||
1610 | else |
||
1611 | { |
||
1612 | uint zae = 0; |
||
1613 | while (c->Ptext.at(d+zae)->ch == QChar(30)) |
||
1614 | { |
||
1615 | zae++; |
||
1616 | if (d+zae == c->MaxChars) |
||
1617 | break; |
||
1618 | } |
||
1619 | QString out="%1"; |
||
1620 | chx = out.arg(PNr-1+Doc->FirstPnum, zae).right(zae).left(1); |
||
1621 | } |
||
1622 | } |
||
1623 | if (hl->cstyle & 64) |
||
1624 | { |
||
1625 | if (chx.upper() != chx) |
||
1626 | { |
||
1627 | tsz = hl->csize * Doc->VKapit / 100; |
||
1628 | chx = chx.upper(); |
||
1629 | } |
||
1630 | } |
||
1631 | if (hl->cstyle & 1) |
||
1632 | tsz = hl->csize * Doc->VHochSc / 100; |
||
1633 | if (hl->cstyle & 2) |
||
1634 | tsz = hl->csize * Doc->VHochSc / 100; |
||
111 | Franz | 1635 | if (((*Doc->AllFonts)[hl->cfont]->isOTF) || ((*Doc->AllFonts)[hl->cfont]->Subset)) |
3 | paul | 1636 | { |
68 | Franz | 1637 | uint chr = chx[0].unicode(); |
1638 | if (((*Doc->AllFonts)[hl->cfont]->CharWidth.contains(chr)) && (chr != 32)) |
||
1639 | { |
||
1640 | p->PS_save(); |
||
1641 | if (c->Reverse) |
||
1642 | { |
||
111 | Franz | 1643 | p->PS_translate(hl->xp, (hl->yp - (tsz / 10.0)) * -1); |
68 | Franz | 1644 | p->PS_scale(-1, 1); |
1645 | if (d < c->MaxChars-1) |
||
1646 | { |
||
1647 | QString ctx = c->Ptext.at(d+1)->ch; |
||
1648 | if (ctx == QChar(29)) |
||
1649 | ctx = " "; |
||
1650 | wideR = -Cwidth(Doc, hl->cfont, chx, tsz, ctx) * (hl->cscale / 100.0); |
||
1651 | } |
||
1652 | else |
||
1653 | wideR = -Cwidth(Doc, hl->cfont, chx, tsz) * (hl->cscale / 100.0); |
||
1654 | p->PS_translate(wideR, 0); |
||
1655 | } |
||
1656 | else |
||
111 | Franz | 1657 | p->PS_translate(hl->xp, (hl->yp - (tsz / 10.0)) * -1); |
68 | Franz | 1658 | if (hl->cscale != 100) |
1659 | p->PS_scale(hl->cscale / 100.0, 1); |
||
1660 | if (hl->ccolor != "None") |
||
1661 | { |
||
1662 | SetFarbe(hl->ccolor, hl->cshade, &h, &s, &v, &k); |
||
1663 | p->PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
111 | Franz | 1664 | p->PS_showSub(chr, (*Doc->AllFonts)[hl->cfont]->RealName(), tsz / 10.0, false); |
68 | Franz | 1665 | } |
1666 | p->PS_restore(); |
||
1667 | } |
||
3 | paul | 1668 | } |
68 | Franz | 1669 | else |
3 | paul | 1670 | { |
111 | Franz | 1671 | p->PS_selectfont(hl->cfont, tsz / 10.0); |
68 | Franz | 1672 | if (hl->ccolor != "None") |
1673 | { |
||
1674 | SetFarbe(hl->ccolor, hl->cshade, &h, &s, &v, &k); |
||
1675 | p->PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0); |
||
1676 | } |
||
1677 | p->PS_save(); |
||
3 | paul | 1678 | if (c->Reverse) |
1679 | { |
||
1680 | int chs = hl->csize; |
||
68 | Franz | 1681 | c->SetZeichAttr(hl, &chs, &chx); |
3 | paul | 1682 | p->PS_translate(hl->xp, -hl->yp); |
1683 | p->PS_scale(-1, 1); |
||
1684 | if (d < c->MaxChars-1) |
||
55 | Franz | 1685 | { |
1686 | QString ctx = c->Ptext.at(d+1)->ch; |
||
1687 | if (ctx == QChar(29)) |
||
1688 | ctx = " "; |
||
68 | Franz | 1689 | wideR = -Cwidth(Doc, hl->cfont, chx, chs, ctx) * (hl->cscale / 100.0); |
1690 | p->PS_translate(wideR, 0); |
||
55 | Franz | 1691 | } |
3 | paul | 1692 | else |
68 | Franz | 1693 | { |
1694 | wideR = -Cwidth(Doc, hl->cfont, chx, chs) * (hl->cscale / 100.0); |
||
1695 | p->PS_translate(wideR, 0); |
||
1696 | } |
||
1697 | if (hl->cscale != 100) |
||
1698 | p->PS_scale(hl->cscale / 100.0, 1); |
||
3 | paul | 1699 | p->PS_show_xyG(hl->cfont, chx, 0, 0); |
1700 | } |
||
1701 | else |
||
68 | Franz | 1702 | { |
1703 | p->PS_translate(hl->xp, -hl->yp); |
||
1704 | if (hl->cscale != 100) |
||
1705 | p->PS_scale(hl->cscale / 100.0, 1); |
||
1706 | p->PS_show_xyG(hl->cfont, chx, 0, 0); |
||
1707 | } |
||
1708 | p->PS_restore(); |
||
3 | paul | 1709 | } |
68 | Franz | 1710 | if ((hl->cstyle & 4) && (chx != QChar(13))) |
3 | paul | 1711 | { |
68 | Franz | 1712 | uint chr = chx[0].unicode(); |
1713 | if ((*Doc |