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