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