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