Rev 3627 | Rev 3724 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3614 | cbradney | 1 | /*************************************************************************** |
2 | pageitem.cpp - description |
||
3 | ------------------- |
||
4 | begin : Sat Apr 7 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 "pageitem_textframe.h" |
||
19 | #include "pageitem_textframe.moc" |
||
20 | #include <qpainter.h> |
||
21 | #include <qpen.h> |
||
22 | #include <qfont.h> |
||
23 | #include <qregion.h> |
||
24 | #include <qpoint.h> |
||
25 | #include <qfileinfo.h> |
||
26 | #include <qdrawutil.h> |
||
27 | #include <qbitmap.h> |
||
28 | #include <qregexp.h> |
||
29 | #include <qmessagebox.h> |
||
30 | #include <cmath> |
||
31 | #include <cassert> |
||
32 | |||
33 | #include "mpalette.h" |
||
34 | #include "page.h" |
||
35 | #include "pageitem.h" |
||
36 | #include "prefsmanager.h" |
||
37 | #include "scpaths.h" |
||
38 | #include "scribus.h" |
||
39 | #include "scribusstructs.h" |
||
40 | #include "scribusdoc.h" |
||
41 | |||
42 | #include "undomanager.h" |
||
43 | #include "undostate.h" |
||
44 | #include "scconfig.h" |
||
45 | |||
46 | #include <ft2build.h> |
||
47 | #include FT_GLYPH_H |
||
48 | |||
49 | #include "scfontmetrics.h" |
||
50 | #include "util.h" |
||
51 | |||
52 | using namespace std; |
||
53 | |||
54 | PageItem_TextFrame::PageItem_TextFrame(ScribusDoc *pa, double x, double y, double w, double h, double w2, QString fill, QString outline) |
||
55 | : PageItem(pa, PageItem::TextFrame, x, y, w, h, w2, fill, outline) |
||
56 | { |
||
57 | } |
||
58 | |||
59 | void PageItem_TextFrame::DrawObj_Item(ScPainter *p, QRect e, double sc) |
||
60 | { |
||
61 | switch (itemType()) |
||
62 | { |
||
63 | case TextFrame: |
||
64 | { |
||
65 | QPainter pp, pf2; |
||
66 | PageItem *nextItem; |
||
67 | QPoint pt1, pt2; |
||
68 | FPoint ColBound; |
||
69 | QRegion cm; |
||
70 | uint a, nrc, nrc2, startLin; |
||
71 | int absa, aSpa, chs, chsd, CurrCol; |
||
72 | uint BuPos, LastSP, MaxText; |
||
73 | double oldCurY, LastXp, EndX, OFs, OFs2, wide, lineCorr, ColWidth, kernVal, RTabX; |
||
74 | QString chx, chx2, chx3; |
||
75 | struct ScText *hl; |
||
76 | struct ZZ *Zli; |
||
77 | struct ZZ *Zli2; |
||
78 | |||
79 | bool outs = false; |
||
80 | bool fBorder = false; |
||
81 | bool RTab = false; |
||
82 | bool goNoRoom = false; |
||
83 | bool goNextColumn = false; |
||
84 | uint StartRT, StartRT2; |
||
85 | int TabCode = 0; |
||
86 | int HyphenCount = 0; |
||
87 | QValueList<TabRecord> tTabValues; |
||
88 | bool DropCmode = false; |
||
89 | bool AbsHasDrop = false; |
||
90 | double desc, asce, maxDY, firstDes, desc2, maxDX, tabDist; |
||
91 | int DropLines; |
||
92 | bool StartOfCol = true; |
||
93 | tTabValues.clear(); |
||
94 | |||
95 | for (int xxx=0; xxx<5; ++xxx) |
||
96 | { |
||
97 | Doc->docParagraphStyles[xxx].LineSpaMode = LineSpMode; |
||
98 | if (LineSpMode == 2) |
||
99 | Doc->docParagraphStyles[xxx].BaseAdj = true; |
||
100 | else |
||
101 | Doc->docParagraphStyles[xxx].BaseAdj = false; |
||
102 | Doc->docParagraphStyles[xxx].LineSpa = LineSp; |
||
103 | Doc->docParagraphStyles[xxx].FontSize = ISize; |
||
104 | Doc->docParagraphStyles[xxx].Indent = 0; |
||
105 | Doc->docParagraphStyles[xxx].First = 0; |
||
106 | Doc->docParagraphStyles[xxx].gapBefore = 0; |
||
107 | Doc->docParagraphStyles[xxx].gapAfter = 0; |
||
108 | Doc->docParagraphStyles[xxx].textAlignment = xxx; |
||
109 | } |
||
110 | |||
111 | QPtrList<ZZ> LiList; |
||
112 | LiList.setAutoDelete(true); |
||
113 | QRect e2 = QRect(qRound(e.x() / sc + Doc->minCanvasCoordinate.x()), qRound(e.y() / sc + Doc->minCanvasCoordinate.y()), qRound(e.width() / sc), qRound(e.height() / sc)); |
||
114 | p->save(); |
||
115 | pf2.begin(ScApp->view->viewport()); |
||
116 | pf2.translate(Xpos, Ypos); |
||
117 | pf2.rotate(Rot); |
||
118 | if ((fillColor() != "None") || (GrType != 0)) |
||
119 | { |
||
120 | p->setupPolygon(&PoLine); |
||
121 | p->fillPath(); |
||
122 | } |
||
123 | if (lineColor() != "None") |
||
124 | lineCorr = Pwidth / 2.0; |
||
125 | else |
||
126 | lineCorr = 0; |
||
127 | if ((isAnnotation) && (AnType == 2) && (!Pfile.isEmpty()) && (PicAvail) && (PicArt) && (AnUseIcons)) |
||
128 | { |
||
129 | p->setupPolygon(&PoLine); |
||
130 | p->setClipPath(); |
||
131 | p->save(); |
||
132 | p->scale(LocalScX, LocalScY); |
||
133 | p->translate(static_cast<int>(LocalX*LocalScX), static_cast<int>(LocalY*LocalScY)); |
||
134 | if (!pixm.isNull()) |
||
135 | p->drawImage(&pixm); |
||
136 | p->restore(); |
||
137 | } |
||
138 | if ((itemText.count() != 0) && (Dirty)) |
||
139 | { |
||
140 | if (imageFlippedH()) |
||
141 | { |
||
142 | p->translate(Width * sc, 0); |
||
143 | p->scale(-1, 1); |
||
144 | } |
||
145 | if (imageFlippedV()) |
||
146 | { |
||
147 | p->translate(0, Height * sc); |
||
148 | p->scale(1, -1); |
||
149 | } |
||
150 | struct ZZ Zli3; |
||
151 | CurrCol = 0; |
||
152 | ColWidth = (Width - (ColGap * (Cols - 1)) - Extra - RExtra - 2*lineCorr) / Cols; |
||
153 | ColBound = FPoint((ColWidth + ColGap) * CurrCol+Extra + lineCorr, ColWidth * (CurrCol+1) + ColGap * CurrCol + Extra+lineCorr); |
||
154 | ColBound = FPoint(ColBound.x(), ColBound.y()+RExtra+lineCorr); |
||
155 | tabDist = ColBound.x(); |
||
156 | uint tabCc = 0; |
||
157 | for (a = 0; a < itemText.count(); ++a) |
||
158 | { |
||
159 | if (a >= MaxChars) |
||
160 | break; |
||
161 | hl = itemText.at(a); |
||
162 | if (hl->cab < 5) |
||
163 | tTabValues = TabValues; |
||
164 | else |
||
165 | tTabValues = Doc->docParagraphStyles[hl->cab].TabValues; |
||
166 | if (hl->cstyle & 16384) |
||
167 | tabCc = 0; |
||
168 | chx = hl->ch; |
||
169 | if (hl->yp == 0) |
||
170 | continue; |
||
171 | if (hl->ch == QChar(30)) |
||
172 | chx = ExpandToken(a); |
||
173 | if (hl->ccolor != "None") |
||
174 | { |
||
175 | QColor tmp; |
||
176 | SetFarbe(&tmp, hl->ccolor, hl->cshade); |
||
177 | p->setBrush(tmp); |
||
178 | } |
||
179 | if (hl->cstroke != "None") |
||
180 | { |
||
181 | QColor tmp; |
||
182 | SetFarbe(&tmp, hl->cstroke, hl->cshade2); |
||
183 | p->setPen(tmp, 1, SolidLine, FlatCap, MiterJoin); |
||
184 | } |
||
185 | chs = hl->csize; |
||
186 | if (hl->cstyle & 2048) |
||
187 | { |
||
188 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
189 | chs = qRound(10 * ((Doc->typographicSettings.valueBaseGrid * (Doc->docParagraphStyles[hl->cab].DropLin-1)+(hl->cfont->numAscent * (Doc->docParagraphStyles[hl->cab].FontSize / 10.0))) / (RealCHeight(Doc, hl->cfont, chx, 10)))); |
||
190 | else |
||
191 | { |
||
192 | if (Doc->docParagraphStyles[hl->cab].LineSpaMode == 0) |
||
193 | chs = qRound(10 * ((Doc->docParagraphStyles[hl->cab].LineSpa * (Doc->docParagraphStyles[hl->cab].DropLin-1)+(hl->cfont->numAscent * (Doc->docParagraphStyles[hl->cab].FontSize / 10.0))) / (RealCHeight(Doc, hl->cfont, chx, 10)))); |
||
194 | else |
||
195 | { |
||
196 | double currasce = RealFHeight(Doc, hl->cfont, Doc->docParagraphStyles[hl->cab].FontSize); |
||
197 | chs = qRound(10 * ((currasce * (Doc->docParagraphStyles[hl->cab].DropLin-1)+(hl->cfont->numAscent * (Doc->docParagraphStyles[hl->cab].FontSize / 10.0))) / RealCHeight(Doc, hl->cfont, chx, 10))); |
||
198 | } |
||
199 | } |
||
200 | } |
||
201 | oldCurY = SetZeichAttr(hl, &chs, &chx); |
||
202 | if ((chx == QChar(9)) && (tTabValues.count() != 0) && (tabCc < tTabValues.count()) && (!tTabValues[tabCc].tabFillChar.isNull())) |
||
203 | { |
||
3668 | cbradney | 204 | QString tabFillCharQStr(tTabValues[tabCc].tabFillChar); |
205 | double wt = Cwidth(Doc, hl->cfont, tabFillCharQStr, chs); |
||
3614 | cbradney | 206 | int coun = static_cast<int>((hl->xp - tabDist) / wt); |
207 | double sPos = hl->xp - (hl->xp - tabDist) + 1; |
||
208 | desc = hl->cfont->numDescender * (-chs / 10.0); |
||
209 | asce = hl->cfont->numAscent * (chs / 10.0); |
||
3668 | cbradney | 210 | Zli3.Zeich = tabFillCharQStr; |
3614 | cbradney | 211 | Zli3.Farb = hl->ccolor; |
212 | Zli3.Farb2 = hl->cstroke; |
||
213 | Zli3.shade = hl->cshade; |
||
214 | Zli3.shade2 = hl->cshade2; |
||
215 | Zli3.yco = hl->yp; |
||
216 | Zli3.Sele = hl->cselect; |
||
217 | Zli3.Siz = chs; |
||
218 | Zli3.realSiz = hl->csize; |
||
219 | Zli3.Style = hl->cstyle; |
||
220 | Zli3.ZFo = hl->cfont; |
||
221 | Zli3.wide = wt; |
||
222 | Zli3.kern = 0; |
||
223 | Zli3.scale = 1000; |
||
224 | Zli3.scalev = 1000; |
||
225 | Zli3.shadowX = hl->cshadowx; |
||
226 | Zli3.shadowY = hl->cshadowy; |
||
227 | Zli3.outline = hl->coutline; |
||
228 | Zli3.base = hl->cbase; |
||
229 | Zli3.underpos = hl->cunderpos; |
||
230 | Zli3.underwidth = hl->cunderwidth; |
||
231 | Zli3.strikepos = hl->cstrikepos; |
||
232 | Zli3.strikewidth = hl->cstrikewidth; |
||
233 | for (int cx = 0; cx < coun; ++cx) |
||
234 | { |
||
235 | Zli3.xco = sPos + wt * cx; |
||
236 | if (e2.intersects(pf2.xForm(QRect(qRound(Zli3.xco),qRound(Zli3.yco-asce), qRound(Zli3.wide+1), qRound(asce+desc))))) |
||
237 | DrawZeichenS(p, &Zli3); |
||
238 | } |
||
239 | } |
||
240 | if (chx == QChar(9)) |
||
241 | tabCc++; |
||
242 | Zli3.Zeich = chx; |
||
243 | Zli3.Farb = hl->ccolor; |
||
244 | Zli3.Farb2 = hl->cstroke; |
||
245 | Zli3.shade = hl->cshade; |
||
246 | Zli3.shade2 = hl->cshade2; |
||
247 | Zli3.xco = hl->xp; |
||
248 | Zli3.yco = hl->yp; |
||
249 | Zli3.Sele = hl->cselect; |
||
250 | Zli3.Siz = chs; |
||
251 | Zli3.realSiz = hl->csize; |
||
252 | Zli3.Style = hl->cstyle; |
||
253 | Zli3.ZFo = hl->cfont; |
||
254 | if ((hl->ch == QChar(25)) && (hl->cembedded != 0)) |
||
255 | Zli3.wide = (hl->cembedded->gWidth + hl->cembedded->Pwidth) * (hl->cscale / 1000.0); |
||
256 | else |
||
257 | Zli3.wide = Cwidth(Doc, hl->cfont, chx, hl->csize) * (hl->cscale / 1000.0); |
||
258 | if (hl->cstyle & 16384) |
||
259 | Zli3.kern = 0; |
||
260 | else |
||
261 | Zli3.kern = chs * hl->cextra / 10000.0; |
||
262 | Zli3.scale = hl->cscale; |
||
263 | Zli3.scalev = hl->cscalev; |
||
264 | Zli3.base = hl->cbase; |
||
265 | Zli3.shadowX = hl->cshadowx; |
||
266 | Zli3.shadowY = hl->cshadowy; |
||
267 | Zli3.outline = hl->coutline; |
||
268 | Zli3.underpos = hl->cunderpos; |
||
269 | Zli3.underwidth = hl->cunderwidth; |
||
270 | Zli3.strikepos = hl->cstrikepos; |
||
271 | Zli3.strikewidth = hl->cstrikewidth; |
||
272 | Zli3.embedded = hl->cembedded; |
||
273 | if (!Doc->RePos) |
||
274 | { |
||
275 | double xcoZli = Zli3.xco; |
||
276 | desc = Zli3.ZFo->numDescender * (-Zli3.Siz / 10.0); |
||
277 | asce = Zli3.ZFo->numAscent * (Zli3.Siz / 10.0); |
||
278 | if ((((Zli3.Sele) && (Select)) || (((NextBox != 0) || (BackBox != 0)) && (Zli3.Sele))) && (Doc->appMode == modeEdit)) |
||
279 | { |
||
280 | wide = Zli3.wide; |
||
281 | p->setFillMode(1); |
||
282 | p->setBrush(darkBlue); |
||
283 | p->setLineWidth(0); |
||
284 | if ((a > 0) && (Zli3.Zeich == QChar(9))) |
||
285 | { |
||
286 | xcoZli = itemText.at(a-1)->xp+Cwidth(Doc, itemText.at(a-1)->cfont, itemText.at(a-1)->ch, itemText.at(a-1)->csize); |
||
287 | wide = Zli3.xco - xcoZli + Zli3.wide; |
||
288 | } |
||
289 | if (!Doc->RePos) |
||
290 | p->drawRect(xcoZli, qRound(Zli3.yco-asce * (Zli3.scalev / 1000.0)), wide+1, qRound((asce+desc) * (Zli3.scalev / 1000.0))); |
||
291 | p->setBrush(white); |
||
292 | } |
||
293 | if (Zli3.Farb2 != "None") |
||
294 | { |
||
295 | QColor tmp; |
||
296 | SetFarbe(&tmp, Zli3.Farb2, Zli3.shade2); |
||
297 | p->setPen(tmp, 1, SolidLine, FlatCap, MiterJoin); |
||
298 | } |
||
299 | if (((chx == QChar(13)) || (chx == QChar(28))) && (Doc->guidesSettings.showControls)) |
||
300 | { |
||
301 | if (e2.intersects(pf2.xForm(QRect(qRound(Zli3.xco+Zli3.wide),qRound(Zli3.yco-asce), qRound(Zli3.wide+1), qRound(asce+desc))))) |
||
302 | { |
||
303 | FPointArray points; |
||
304 | QWMatrix chma, chma2, chma4, chma5; |
||
305 | double ytrans, xtrans; |
||
306 | if (chx == QChar(13)) |
||
307 | { |
||
308 | points = Doc->symReturn.copy(); |
||
309 | if (a > 0) |
||
310 | ytrans = itemText.at(a-1)->yp-((Zli3.Siz / 10.0) * 0.8); |
||
311 | else |
||
312 | ytrans = Zli3.yco-Doc->docParagraphStyles[hl->cab].LineSpa-((Zli3.Siz / 10.0) * 0.8); |
||
313 | } |
||
314 | else |
||
315 | { |
||
316 | points = Doc->symNewLine.copy(); |
||
317 | if (a > 0) |
||
318 | ytrans = itemText.at(a-1)->yp-((Zli3.Siz / 10.0) * 0.4); |
||
319 | else |
||
320 | ytrans = Zli3.yco-Doc->docParagraphStyles[hl->cab].LineSpa-((Zli3.Siz / 10.0) * 0.4); |
||
321 | } |
||
322 | if (hl->cstyle & 16384) |
||
323 | xtrans = Zli3.xco; |
||
324 | else |
||
325 | { |
||
326 | if (a > 0) |
||
327 | xtrans = itemText.at(a-1)->xp+ Cwidth(Doc, itemText.at(a-1)->cfont, itemText.at(a-1)->ch, itemText.at(a-1)->csize); |
||
328 | else |
||
329 | xtrans = Zli3.xco; |
||
330 | } |
||
331 | chma4.translate(xtrans, ytrans); |
||
332 | chma.scale(Zli3.Siz / 100.0, Zli3.Siz / 100.0); |
||
333 | chma2.scale(Zli3.scale / 1000.0, Zli3.scalev / 1000.0); |
||
334 | chma5.scale(p->zoomFactor(), p->zoomFactor()); |
||
335 | points.map(chma * chma2 * chma4 * chma5); |
||
336 | p->setupTextPolygon(&points); |
||
337 | p->setFillMode(1); |
||
338 | p->fillPath(); |
||
339 | } |
||
340 | } |
||
341 | if (e2.intersects(pf2.xForm(QRect(qRound(Zli3.xco),qRound(Zli3.yco-asce), qRound(Zli3.wide+1), qRound(asce+desc))))) |
||
342 | { |
||
343 | if (Zli3.Zeich == QChar(25)) |
||
344 | DrawObj_Embedded(p, e, &Zli3); |
||
345 | else |
||
346 | DrawZeichenS(p, &Zli3); |
||
347 | } |
||
348 | if (hl->cstyle & 8192) |
||
349 | { |
||
350 | Zli3.Zeich = "-"; |
||
351 | Zli3.xco = Zli3.xco + Zli3.wide; |
||
352 | if (e2.intersects(pf2.xForm(QRect(qRound(Zli3.xco),qRound(Zli3.yco-asce), qRound(Zli3.wide+1), qRound(asce+desc))))) |
||
353 | DrawZeichenS(p, &Zli3); |
||
354 | } |
||
355 | } |
||
356 | tabDist = Zli3.xco+Zli3.wide; |
||
357 | } |
||
358 | if (itemText.count() > MaxChars) |
||
359 | { |
||
360 | if (!Doc->RePos) |
||
361 | { |
||
362 | double scp1 = 1 / QMAX(ScApp->view->getScale(), 1); |
||
363 | double scp16 = 16 * scp1; |
||
364 | double scp14 = 14 * scp1; |
||
365 | double scp3 = 3 * scp1; |
||
366 | double scpwidth16 = Width - scp16; |
||
367 | double scpheight16 = Height - scp16; |
||
368 | double scpwidth3 = Width - scp3; |
||
369 | double scpheight3 = Height - scp3; |
||
370 | p->setBrush(white); |
||
371 | p->setPen(black, scp1, SolidLine, FlatCap, MiterJoin); |
||
372 | p->drawRect(scpwidth16, scpheight16, scp14, scp14); |
||
373 | p->drawLine(FPoint(scpwidth16, scpheight16), FPoint(scpwidth3, scpheight3)); |
||
374 | p->drawLine(FPoint(scpwidth16, scpheight3), FPoint(scpwidth3, scpheight16)); |
||
375 | } |
||
376 | } |
||
377 | Dirty = false; |
||
378 | Redrawn = true; |
||
379 | pf2.end(); |
||
380 | p->restore(); |
||
381 | break; |
||
382 | } |
||
383 | if ((itemText.count() != 0) || (NextBox != 0)) |
||
384 | { |
||
385 | if (NextBox != 0) |
||
386 | { |
||
387 | nextItem = NextBox; |
||
388 | while (nextItem != 0) |
||
389 | { |
||
390 | a = nextItem->itemText.count(); |
||
391 | for (uint s=0; s<a; ++s) |
||
392 | { |
||
393 | itemText.append(nextItem->itemText.take(0)); |
||
394 | } |
||
395 | nextItem->MaxChars = 0; |
||
396 | nextItem = nextItem->NextBox; |
||
397 | } |
||
398 | nextItem = NextBox; |
||
399 | } |
||
400 | Doc->docParagraphStyles[0].LineSpa = LineSp; |
||
401 | QRegion cl = QRegion(pf2.xForm(Clip)); |
||
402 | int LayerLev = Doc->layerLevelFromNumber(LayerNr); |
||
3668 | cbradney | 403 | uint docItemsCount=Doc->Items.count(); |
3614 | cbradney | 404 | if (!isEmbedded) |
405 | { |
||
406 | if (!OnMasterPage.isEmpty()) |
||
407 | { |
||
408 | Page* Mp = Doc->MasterPages.at(Doc->MasterNames[OnMasterPage]); |
||
409 | Page* Dp = Doc->Pages.at(savedOwnPage); |
||
410 | for (a = 0; a < Doc->MasterItems.count(); ++a) |
||
411 | { |
||
412 | PageItem* docItem = Doc->MasterItems.at(a); |
||
413 | int LayerLevItem = Doc->layerLevelFromNumber(docItem->LayerNr); |
||
414 | if (((docItem->ItemNr > ItemNr) && (docItem->LayerNr == LayerNr)) || (LayerLevItem > LayerLev)) |
||
415 | { |
||
416 | if (docItem->textFlowsAroundFrame()) |
||
417 | { |
||
418 | pp.begin(ScApp->view->viewport()); |
||
419 | pp.translate(docItem->Xpos - Mp->xOffset() + Dp->xOffset(), docItem->Ypos - Mp->yOffset() + Dp->yOffset()); |
||
420 | pp.rotate(docItem->Rot); |
||
421 | if (docItem->textFlowUsesBoundingBox()) |
||
422 | { |
||
423 | QPointArray tcli; |
||
424 | tcli.resize(4); |
||
425 | tcli.setPoint(0, QPoint(0,0)); |
||
426 | tcli.setPoint(1, QPoint(qRound(docItem->Width), 0)); |
||
427 | tcli.setPoint(2, QPoint(qRound(docItem->Width), qRound(docItem->Height))); |
||
428 | tcli.setPoint(3, QPoint(0, qRound(docItem->Height))); |
||
429 | cm = QRegion(pp.xForm(tcli)); |
||
430 | } |
||
431 | else |
||
432 | { |
||
433 | if ((docItem->textFlowUsesContourLine()) && (docItem->ContourLine.size() != 0)) |
||
434 | { |
||
435 | QValueList<uint> Segs; |
||
436 | QPointArray Clip2 = FlattenPath(docItem->ContourLine, Segs); |
||
437 | cm = QRegion(pp.xForm(Clip2)); |
||
438 | } |
||
439 | else |
||
440 | cm = QRegion(pp.xForm(docItem->Clip)); |
||
441 | } |
||
442 | pp.end(); |
||
443 | cl = cl.subtract(cm); |
||
444 | } |
||
445 | } |
||
446 | } |
||
3668 | cbradney | 447 | for (a = 0; a < docItemsCount; ++a) |
3614 | cbradney | 448 | { |
449 | PageItem* docItem = Doc->Items.at(a); |
||
450 | if (docItem->textFlowsAroundFrame()) |
||
451 | { |
||
452 | pp.begin(ScApp->view->viewport()); |
||
453 | pp.translate(docItem->Xpos, docItem->Ypos); |
||
454 | pp.rotate(docItem->Rot); |
||
455 | if (docItem->textFlowUsesBoundingBox()) |
||
456 | { |
||
457 | QPointArray tcli; |
||
458 | tcli.resize(4); |
||
459 | tcli.setPoint(0, QPoint(0,0)); |
||
460 | tcli.setPoint(1, QPoint(qRound(docItem->Width), 0)); |
||
461 | tcli.setPoint(2, QPoint(qRound(docItem->Width), qRound(docItem->Height))); |
||
462 | tcli.setPoint(3, QPoint(0, qRound(docItem->Height))); |
||
463 | cm = QRegion(pp.xForm(tcli)); |
||
464 | } |
||
465 | else |
||
466 | { |
||
467 | if ((docItem->textFlowUsesContourLine()) && (docItem->ContourLine.size() != 0)) |
||
468 | { |
||
469 | QValueList<uint> Segs; |
||
470 | QPointArray Clip2 = FlattenPath(docItem->ContourLine, Segs); |
||
471 | cm = QRegion(pp.xForm(Clip2)); |
||
472 | } |
||
473 | else |
||
474 | cm = QRegion(pp.xForm(docItem->Clip)); |
||
475 | } |
||
476 | pp.end(); |
||
477 | cl = cl.subtract(cm); |
||
478 | } |
||
479 | } |
||
480 | } |
||
3668 | cbradney | 481 | for (a = 0; a < docItemsCount; ++a) |
3614 | cbradney | 482 | { |
483 | PageItem* docItem = Doc->Items.at(a); |
||
484 | int LayerLevItem = Doc->layerLevelFromNumber(docItem->LayerNr); |
||
485 | if (((docItem->ItemNr > ItemNr) && (docItem->LayerNr == LayerNr)) || (LayerLevItem > LayerLev)) |
||
486 | { |
||
487 | if (docItem->textFlowsAroundFrame()) |
||
488 | { |
||
489 | pp.begin(ScApp->view->viewport()); |
||
490 | pp.translate(docItem->Xpos, docItem->Ypos); |
||
491 | pp.rotate(docItem->Rot); |
||
492 | if (docItem->textFlowUsesBoundingBox()) |
||
493 | { |
||
494 | QPointArray tcli; |
||
495 | tcli.resize(4); |
||
496 | tcli.setPoint(0, QPoint(0,0)); |
||
497 | tcli.setPoint(1, QPoint(qRound(docItem->Width), 0)); |
||
498 | tcli.setPoint(2, QPoint(qRound(docItem->Width), qRound(docItem->Height))); |
||
499 | tcli.setPoint(3, QPoint(0, qRound(docItem->Height))); |
||
500 | cm = QRegion(pp.xForm(tcli)); |
||
501 | } |
||
502 | else |
||
503 | { |
||
504 | if ((docItem->textFlowUsesContourLine()) && (docItem->ContourLine.size() != 0)) |
||
505 | { |
||
506 | QValueList<uint> Segs; |
||
507 | QPointArray Clip2 = FlattenPath(docItem->ContourLine, Segs); |
||
508 | cm = QRegion(pp.xForm(Clip2)); |
||
509 | } |
||
510 | else |
||
511 | cm = QRegion(pp.xForm(docItem->Clip)); |
||
512 | } |
||
513 | pp.end(); |
||
514 | cl = cl.subtract(cm); |
||
515 | } |
||
516 | } |
||
517 | } |
||
518 | } |
||
519 | if (imageFlippedH()) |
||
520 | { |
||
521 | p->translate(Width * sc, 0); |
||
522 | p->scale(-1, 1); |
||
523 | pf2.translate(Width, 0); |
||
524 | pf2.scale(-1, 1); |
||
525 | } |
||
526 | if (imageFlippedV()) |
||
527 | { |
||
528 | p->translate(0, Height * sc); |
||
529 | p->scale(1, -1); |
||
530 | pf2.translate(0, Height); |
||
531 | pf2.scale(1, -1); |
||
532 | } |
||
533 | CurrCol = 0; |
||
534 | ColWidth = (Width - (ColGap * (Cols - 1)) - Extra - RExtra - 2*lineCorr) / Cols; |
||
535 | ColBound = FPoint((ColWidth + ColGap) * CurrCol+Extra + lineCorr, ColWidth * (CurrCol+1) + ColGap * CurrCol + Extra+lineCorr); |
||
536 | ColBound = FPoint(ColBound.x(), ColBound.y()+RExtra+lineCorr); |
||
537 | CurX = ColBound.x(); |
||
538 | if (itemText.count() > 0) |
||
539 | { |
||
540 | hl = itemText.at(0); |
||
541 | if (Doc->docParagraphStyles[hl->cab].Drop) |
||
542 | { |
||
543 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
544 | chs = qRound(Doc->typographicSettings.valueBaseGrid * Doc->docParagraphStyles[hl->cab].DropLin * 10); |
||
545 | else |
||
546 | chs = qRound(Doc->docParagraphStyles[hl->cab].LineSpa * Doc->docParagraphStyles[hl->cab].DropLin * 10); |
||
547 | } |
||
548 | else |
||
549 | chs = hl->csize; |
||
550 | desc2 = -hl->cfont->numDescender * (chs / 10.0); |
||
551 | CurY = TExtra+lineCorr; |
||
552 | } |
||
553 | else |
||
554 | { |
||
555 | desc2 = -(*Doc->AllFonts)[IFont]->numDescender * (ISize / 10.0); |
||
556 | CurY = Doc->docParagraphStyles[0].LineSpa+TExtra+lineCorr-desc2; |
||
557 | } |
||
558 | firstDes = desc2; |
||
559 | LiList.clear(); |
||
560 | BuPos = 0; |
||
561 | LastSP = 0; |
||
562 | LastXp = 0; |
||
563 | outs = false; |
||
564 | OFs = 0; |
||
565 | OFs2 = 0; |
||
566 | aSpa = 0; |
||
567 | absa = 0; |
||
568 | MaxChars = 0; |
||
569 | tabDist = 0; |
||
570 | MaxText = itemText.count(); |
||
571 | StartOfCol = true; |
||
572 | for (a = 0; a < MaxText; ++a) |
||
573 | { |
||
574 | hl = itemText.at(a); |
||
575 | chx = hl->ch; |
||
576 | if (hl->ch == QChar(30)) |
||
577 | chx = ExpandToken(a); |
||
578 | absa = hl->cab; |
||
579 | if (Doc->docParagraphStyles[absa].LineSpaMode == 1) |
||
580 | Doc->docParagraphStyles[absa].LineSpa = RealFHeight(Doc, hl->cfont, hl->csize); |
||
581 | if (a == 0) |
||
582 | { |
||
583 | if (BackBox != 0) |
||
584 | { |
||
585 | nextItem = BackBox; |
||
586 | while (nextItem != 0) |
||
587 | { |
||
3668 | cbradney | 588 | uint nextItemTextCount=nextItem->itemText.count(); |
589 | if (nextItemTextCount != 0) |
||
3614 | cbradney | 590 | { |
3668 | cbradney | 591 | if (nextItem->itemText.at(nextItemTextCount-1)->ch == QChar(13)) |
3614 | cbradney | 592 | { |
593 | CurY += Doc->docParagraphStyles[absa].gapBefore; |
||
594 | if (chx != QChar(13)) |
||
3668 | cbradney | 595 | { |
3614 | cbradney | 596 | DropCmode = Doc->docParagraphStyles[absa].Drop; |
3668 | cbradney | 597 | if (DropCmode) |
598 | DropLines = Doc->docParagraphStyles[absa].DropLin; |
||
599 | } |
||
3614 | cbradney | 600 | else |
601 | DropCmode = false; |
||
602 | break; |
||
603 | } |
||
604 | else |
||
605 | break; |
||
606 | } |
||
607 | nextItem = nextItem->BackBox; |
||
608 | } |
||
609 | } |
||
610 | else |
||
611 | { |
||
612 | if (chx != QChar(13)) |
||
3668 | cbradney | 613 | { |
3614 | cbradney | 614 | DropCmode = Doc->docParagraphStyles[absa].Drop; |
3668 | cbradney | 615 | if (DropCmode) |
616 | DropLines = Doc->docParagraphStyles[absa].DropLin; |
||
617 | } |
||
3614 | cbradney | 618 | else |
619 | DropCmode = false; |
||
620 | CurY += Doc->docParagraphStyles[absa].gapBefore; |
||
621 | } |
||
622 | } |
||
623 | hl->cstyle &= 0xF7FF; // 2047; |
||
624 | hl->cstyle &= 8191; |
||
625 | if (((Doc->docParagraphStyles[absa].textAlignment == 3) || (Doc->docParagraphStyles[absa].textAlignment == 4)) && (LiList.count() == 0) && (hl->ch == " ")) |
||
626 | { |
||
627 | hl->cstyle |= 4096; |
||
628 | continue; |
||
629 | } |
||
630 | else |
||
631 | hl->cstyle &= 0xEFFF; // 4095; |
||
632 | if (LiList.count() == 0) |
||
633 | { |
||
634 | if (((a > 0) && (itemText.at(a-1)->ch == QChar(13))) || ((a == 0) && (BackBox == 0)) && (!StartOfCol)) |
||
635 | { |
||
636 | CurY += Doc->docParagraphStyles[absa].gapBefore; |
||
637 | if (chx != QChar(13)) |
||
638 | DropCmode = Doc->docParagraphStyles[absa].Drop; |
||
639 | else |
||
640 | DropCmode = false; |
||
641 | if (DropCmode) |
||
642 | { |
||
643 | DropLines = Doc->docParagraphStyles[absa].DropLin; |
||
644 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
645 | CurY += Doc->typographicSettings.valueBaseGrid * (DropLines-1); |
||
646 | else |
||
647 | { |
||
648 | if (Doc->docParagraphStyles[absa].LineSpaMode == 0) |
||
649 | CurY += Doc->docParagraphStyles[absa].LineSpa * (DropLines-1); |
||
650 | else |
||
651 | CurY += RealFHeight(Doc, hl->cfont, Doc->docParagraphStyles[absa].FontSize) * (DropLines-1); |
||
652 | } |
||
653 | } |
||
654 | } |
||
655 | } |
||
656 | if (DropCmode) |
||
657 | { |
||
658 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
659 | { |
||
660 | chsd = qRound(10 * ((Doc->typographicSettings.valueBaseGrid * (DropLines-1)+(hl->cfont->numAscent * (Doc->docParagraphStyles[hl->cab].FontSize / 10.0))) / (RealCHeight(Doc, hl->cfont, chx, 10)))); |
||
661 | chs = qRound(10 * ((Doc->typographicSettings.valueBaseGrid * (DropLines-1)+(hl->cfont->numAscent * (Doc->docParagraphStyles[hl->cab].FontSize / 10.0))) / RealCAscent(Doc, hl->cfont, chx, 10))); |
||
662 | } |
||
663 | else |
||
664 | { |
||
665 | if (Doc->docParagraphStyles[absa].LineSpaMode == 0) |
||
666 | { |
||
667 | chsd = qRound(10 * ((Doc->docParagraphStyles[absa].LineSpa * (DropLines-1)+(hl->cfont->numAscent * (Doc->docParagraphStyles[hl->cab].FontSize / 10.0))) / (RealCHeight(Doc, hl->cfont, chx, 10)))); |
||
668 | chs = qRound(10 * ((Doc->docParagraphStyles[absa].LineSpa * (DropLines-1)+(hl->cfont->numAscent * (Doc->docParagraphStyles[hl->cab].FontSize / 10.0))) / RealCAscent(Doc, hl->cfont, chx, 10))); |
||
669 | } |
||
670 | else |
||
671 | { |
||
672 | double currasce = RealFHeight(Doc, hl->cfont, Doc->docParagraphStyles[hl->cab].FontSize); |
||
673 | chsd = qRound(10 * ((currasce * (DropLines-1)+(hl->cfont->numAscent * (Doc->docParagraphStyles[hl->cab].FontSize / 10.0))) / (RealCHeight(Doc, hl->cfont, chx, 10)))); |
||
674 | chs = qRound(10 * ((currasce * (DropLines-1)+(hl->cfont->numAscent * (Doc->docParagraphStyles[hl->cab].FontSize / 10.0))) / RealCAscent(Doc, hl->cfont, chx, 10))); |
||
675 | } |
||
676 | } |
||
677 | hl->cstyle |= 2048; |
||
678 | } |
||
679 | else |
||
680 | { |
||
681 | if ((hl->ch == QChar(25)) && (hl->cembedded != 0)) |
||
682 | chs = qRound((hl->cembedded->gHeight + hl->cembedded->Pwidth) * 10); |
||
683 | else |
||
684 | chs = hl->csize; |
||
685 | } |
||
686 | oldCurY = SetZeichAttr(hl, &chs, &chx); |
||
687 | if (chx == QChar(29)) |
||
688 | chx2 = " "; |
||
689 | else if (chx == QChar(24)) |
||
690 | chx2 = "-"; |
||
691 | else |
||
692 | chx2 = chx; |
||
693 | if ((hl->ch == QChar(25)) && (hl->cembedded != 0)) |
||
694 | wide = hl->cembedded->gWidth + hl->cembedded->Pwidth; |
||
695 | else |
||
696 | { |
||
697 | if (a < MaxText-1) |
||
698 | { |
||
699 | if (itemText.at(a+1)->ch == QChar(29)) |
||
700 | chx3 = " "; |
||
701 | else if (itemText.at(a+1)->ch == QChar(24)) |
||
702 | chx3 = "-"; |
||
703 | else |
||
704 | chx3 = itemText.at(a+1)->ch; |
||
705 | wide = Cwidth(Doc, hl->cfont, chx2, chs, chx3); |
||
706 | } |
||
707 | else |
||
708 | wide = Cwidth(Doc, hl->cfont, chx2, chs); |
||
709 | } |
||
710 | if (DropCmode) |
||
711 | { |
||
712 | if ((hl->ch == QChar(25)) && (hl->cembedded != 0)) |
||
713 | { |
||
714 | wide = hl->cembedded->gWidth + hl->cembedded->Pwidth; |
||
715 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
716 | asce = Doc->typographicSettings.valueBaseGrid * DropLines; |
||
717 | else |
||
718 | { |
||
719 | if (Doc->docParagraphStyles[absa].LineSpaMode == 0) |
||
720 | asce = Doc->docParagraphStyles[absa].LineSpa * DropLines; |
||
721 | else |
||
722 | asce = RealFHeight(Doc, hl->cfont, Doc->docParagraphStyles[absa].FontSize) * DropLines; |
||
723 | } |
||
724 | hl->cscalev = qRound(asce / (hl->cembedded->gHeight + hl->cembedded->Pwidth) * 1000.0); |
||
725 | hl->cscale = hl->cscalev; |
||
726 | } |
||
727 | else |
||
728 | { |
||
729 | wide = RealCWidth(Doc, hl->cfont, chx2, chsd); |
||
730 | asce = RealCHeight(Doc, hl->cfont, chx2, chsd); |
||
731 | } |
||
732 | desc2 = 0; |
||
733 | desc = 0; |
||
734 | } |
||
735 | else |
||
736 | { |
||
737 | if ((hl->ch == QChar(25)) && (hl->cembedded != 0)) |
||
738 | { |
||
739 | asce = hl->cfont->numAscent * (hl->csize / 10.0); |
||
740 | desc2 = 0; |
||
741 | desc = 0; |
||
742 | } |
||
743 | else |
||
744 | { |
||
745 | desc2 = -hl->cfont->numDescender * (hl->csize / 10.0); |
||
746 | desc = -hl->cfont->numDescender * (hl->csize / 10.0); |
||
747 | asce = hl->cfont->numAscent * (hl->csize / 10.0); |
||
748 | } |
||
749 | } |
||
750 | wide = wide * (hl->cscale / 1000.0); |
||
751 | fBorder = false; |
||
752 | if (CurY+BExtra+lineCorr > Height) |
||
753 | { |
||
754 | StartOfCol = true; |
||
755 | CurrCol++; |
||
756 | if (CurrCol < Cols) |
||
757 | { |
||
758 | ColWidth = (Width - (ColGap * (Cols - 1)) - Extra - RExtra - 2*lineCorr) / Cols; |
||
759 | ColBound = FPoint((ColWidth + ColGap) * CurrCol + Extra+lineCorr, ColWidth * (CurrCol+1) + ColGap * CurrCol + Extra+lineCorr); |
||
760 | CurX = ColBound.x(); |
||
761 | ColBound = FPoint(ColBound.x(), ColBound.y()+RExtra+lineCorr); |
||
762 | CurY = asce+TExtra+lineCorr+1; |
||
763 | if (((a > 0) && (itemText.at(a-1)->ch == QChar(13))) || ((a == 0) && (BackBox == 0))) |
||
764 | { |
||
765 | if (chx != QChar(13)) |
||
766 | DropCmode = Doc->docParagraphStyles[hl->cab].Drop; |
||
767 | else |
||
768 | DropCmode = false; |
||
769 | if (DropCmode) |
||
770 | { |
||
771 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
772 | desc2 = -hl->cfont->numDescender * Doc->typographicSettings.valueBaseGrid * Doc->docParagraphStyles[hl->cab].DropLin; |
||
773 | else |
||
774 | desc2 = -hl->cfont->numDescender * Doc->docParagraphStyles[hl->cab].LineSpa * Doc->docParagraphStyles[hl->cab].DropLin; |
||
775 | } |
||
776 | if (DropCmode) |
||
777 | DropLines = Doc->docParagraphStyles[hl->cab].DropLin; |
||
778 | } |
||
779 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
780 | { |
||
781 | double by = Ypos; |
||
782 | if (OwnPage != -1) |
||
783 | by = Ypos - Doc->Pages.at(OwnPage)->yOffset(); |
||
784 | int ol1 = qRound((by + CurY - Doc->typographicSettings.offsetBaseGrid) * 10000.0); |
||
785 | int ol2 = static_cast<int>(ol1 / Doc->typographicSettings.valueBaseGrid); |
||
786 | CurY = ceil( ol2 / 10000.0 ) * Doc->typographicSettings.valueBaseGrid + Doc->typographicSettings.offsetBaseGrid - by; |
||
787 | } |
||
788 | } |
||
789 | else |
||
790 | { |
||
791 | nrc = a; |
||
792 | goto NoRoom; |
||
793 | } |
||
794 | } |
||
795 | if (LiList.isEmpty()) |
||
796 | { |
||
797 | startLin = a; |
||
798 | double TopOffset = asce; |
||
799 | double BotOffset = desc2; |
||
800 | goNoRoom = false; |
||
801 | if (StartOfCol) |
||
802 | { |
||
803 | CurY = asce+TExtra+lineCorr+1; |
||
804 | // if (((a > 0) && (itemText.at(a-1)->ch == QChar(13))) || ((a == 0) && (BackBox == 0))) |
||
805 | // CurY += Doc->docParagraphStyles[hl->cab].gapBefore; |
||
806 | } |
||
807 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
808 | { |
||
809 | double by = Ypos; |
||
810 | if (OwnPage != -1) |
||
811 | by = Ypos - Doc->Pages.at(OwnPage)->yOffset(); |
||
812 | int ol1 = qRound((by + CurY - Doc->typographicSettings.offsetBaseGrid) * 10000.0); |
||
813 | int ol2 = static_cast<int>(ol1 / Doc->typographicSettings.valueBaseGrid); |
||
814 | CurY = ceil( ol2 / 10000.0 ) * Doc->typographicSettings.valueBaseGrid + Doc->typographicSettings.offsetBaseGrid - by; |
||
815 | } |
||
816 | if (CurY-TopOffset < 0.0) |
||
817 | CurY = TopOffset+1; |
||
818 | pt1 = QPoint(static_cast<int>(ceil(CurX)), static_cast<int>(CurY+BotOffset)); |
||
819 | pt2 = QPoint(static_cast<int>(ceil(CurX)), static_cast<int>(ceil(CurY-TopOffset))); |
||
820 | while ((!cl.contains(pf2.xForm(pt1))) || (!cl.contains(pf2.xForm(pt2)))) |
||
821 | { |
||
822 | fBorder = true; |
||
823 | CurX++; |
||
824 | if (CurX+RExtra+lineCorr > ColBound.y()) |
||
825 | { |
||
826 | fBorder = false; |
||
827 | if (StartOfCol) |
||
828 | { |
||
829 | CurX = ColBound.x(); |
||
830 | CurY++; |
||
831 | } |
||
832 | else |
||
833 | { |
||
834 | CurY += Doc->docParagraphStyles[hl->cab].LineSpa; |
||
835 | CurX = ColBound.x(); |
||
836 | } |
||
837 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
838 | { |
||
839 | double by = Ypos; |
||
840 | if (OwnPage != -1) |
||
841 | by = Ypos - Doc->Pages.at(OwnPage)->yOffset(); |
||
842 | int ol1 = qRound((by + CurY - Doc->typographicSettings.offsetBaseGrid) * 10000.0); |
||
843 | int ol2 = static_cast<int>(ol1 / Doc->typographicSettings.valueBaseGrid); |
||
844 | CurY = ceil( ol2 / 10000.0 ) * Doc->typographicSettings.valueBaseGrid + Doc->typographicSettings.offsetBaseGrid - by; |
||
845 | } |
||
846 | if (CurY+BExtra+lineCorr > Height) |
||
847 | { |
||
848 | StartOfCol = true; |
||
849 | fBorder = false; |
||
850 | CurrCol++; |
||
851 | if (CurrCol < Cols) |
||
852 | { |
||
853 | ColWidth = (Width - (ColGap * (Cols - 1)) - Extra - RExtra - 2*lineCorr) / Cols; |
||
854 | ColBound = FPoint((ColWidth + ColGap) * CurrCol + Extra+lineCorr, ColWidth * (CurrCol+1) + ColGap * CurrCol + Extra+lineCorr); |
||
855 | CurX = ColBound.x(); |
||
856 | ColBound = FPoint(ColBound.x(), ColBound.y()+RExtra+lineCorr); |
||
857 | CurY = asce+TExtra+lineCorr+1; |
||
858 | if (((a > 0) && (itemText.at(a-1)->ch == QChar(13))) || ((a == 0) && (BackBox == 0))) |
||
859 | { |
||
860 | if (chx != QChar(13)) |
||
861 | DropCmode = Doc->docParagraphStyles[hl->cab].Drop; |
||
862 | else |
||
863 | DropCmode = false; |
||
864 | if (DropCmode) |
||
865 | { |
||
866 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
867 | desc2 = -hl->cfont->numDescender * Doc->typographicSettings.valueBaseGrid * Doc->docParagraphStyles[hl->cab].DropLin; |
||
868 | else |
||
869 | desc2 = -hl->cfont->numDescender * Doc->docParagraphStyles[hl->cab].LineSpa * Doc->docParagraphStyles[hl->cab].DropLin; |
||
870 | } |
||
871 | if (DropCmode) |
||
872 | DropLines = Doc->docParagraphStyles[hl->cab].DropLin; |
||
873 | } |
||
874 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
875 | { |
||
876 | double by = Ypos; |
||
877 | if (OwnPage != -1) |
||
878 | by = Ypos - Doc->Pages.at(OwnPage)->yOffset(); |
||
879 | int ol1 = qRound((by + CurY - Doc->typographicSettings.offsetBaseGrid) * 10000.0); |
||
880 | int ol2 = static_cast<int>(ol1 / Doc->typographicSettings.valueBaseGrid); |
||
881 | CurY = ceil( ol2 / 10000.0 ) * Doc->typographicSettings.valueBaseGrid + Doc->typographicSettings.offsetBaseGrid - by; |
||
882 | } |
||
883 | } |
||
884 | else |
||
885 | { |
||
886 | nrc = a; |
||
887 | goto NoRoom; |
||
888 | } |
||
889 | } |
||
890 | } |
||
891 | pt1 = QPoint(static_cast<int>(ceil(CurX)), static_cast<int>(CurY+BotOffset)); |
||
892 | pt2 = QPoint(static_cast<int>(ceil(CurX)), static_cast<int>(ceil(CurY-TopOffset))); |
||
893 | } |
||
894 | if ((fBorder) && (!AbsHasDrop)) |
||
895 | CurX += Extra; |
||
896 | if (a > 0) |
||
897 | { |
||
898 | if (itemText.at(a-1)->ch == QChar(13)) |
||
899 | CurX += Doc->docParagraphStyles[hl->cab].First; |
||
900 | } |
||
901 | else |
||
902 | { |
||
903 | if (BackBox == 0) |
||
904 | CurX += Doc->docParagraphStyles[hl->cab].First; |
||
905 | else |
||
906 | { |
||
907 | if (BackBox->itemText.count() != 0) |
||
908 | { |
||
909 | if (BackBox->itemText.at(BackBox->itemText.count()-1)->ch == QChar(13)) |
||
910 | CurX += Doc->docParagraphStyles[hl->cab].First; |
||
911 | } |
||
912 | else |
||
913 | CurX += Doc->docParagraphStyles[hl->cab].First; |
||
914 | } |
||
915 | } |
||
916 | if (!AbsHasDrop) |
||
917 | CurX += Doc->docParagraphStyles[hl->cab].Indent; |
||
918 | fBorder = false; |
||
919 | } |
||
920 | if (RTab) |
||
921 | { |
||
922 | if (((hl->ch == ".") && (TabCode == 2)) || ((hl->ch == ",") && (TabCode == 3)) || (hl->ch == QChar(9))) |
||
923 | { |
||
924 | RTab = false; |
||
925 | TabCode = 0; |
||
926 | } |
||
927 | } |
||
928 | if (hl->ch == QChar(9)) |
||
929 | { |
||
930 | wide = 1; |
||
931 | if (RTab) |
||
932 | RTab = false; |
||
933 | else |
||
934 | { |
||
935 | RTabX = CurX+wide; |
||
936 | if (hl->cab < 5) |
||
937 | tTabValues = TabValues; |
||
938 | else |
||
939 | tTabValues = Doc->docParagraphStyles[hl->cab].TabValues; |
||
940 | if (tTabValues.isEmpty()) |
||
941 | { |
||
942 | if ((CurX - ColBound.x()) != 0) |
||
943 | { |
||
944 | if (CurX == ColBound.x() + ceil((CurX-ColBound.x()) / Doc->toolSettings.dTabWidth) * Doc->toolSettings.dTabWidth) |
||
945 | CurX += Doc->toolSettings.dTabWidth; |
||
946 | else |
||
947 | CurX = ColBound.x() + ceil((CurX-ColBound.x()) / Doc->toolSettings.dTabWidth) * Doc->toolSettings.dTabWidth; |
||
948 | } |
||
949 | else |
||
950 | CurX = ColBound.x() + Doc->toolSettings.dTabWidth; |
||
951 | TabCode = 0; |
||
952 | RTab = false; |
||
953 | } |
||
954 | else |
||
955 | { |
||
956 | double tCurX = CurX - ColBound.x(); |
||
957 | double oCurX = tCurX + wide; |
||
958 | for (int yg = static_cast<int>(tTabValues.count()-1); yg > -1; yg--) |
||
959 | { |
||
960 | if (oCurX < tTabValues[yg].tabPosition) |
||
961 | { |
||
962 | tCurX = tTabValues[yg].tabPosition; |
||
963 | TabCode = static_cast<int>(tTabValues[yg].tabType); |
||
964 | } |
||
965 | } |
||
966 | if (TabCode == 0) |
||
967 | RTab = false; |
||
968 | else |
||
969 | RTab = true; |
||
970 | if (tCurX == oCurX-wide) |
||
971 | CurX = ColBound.x() + ceil((CurX-ColBound.x()) / Doc->toolSettings.dTabWidth) * Doc->toolSettings.dTabWidth; |
||
972 | else |
||
973 | CurX = ColBound.x() + tCurX; |
||
974 | } |
||
975 | CurX -= 1; |
||
976 | StartRT = LiList.count(); |
||
977 | StartRT2 = a; |
||
978 | } |
||
979 | } |
||
980 | hl->yp = CurY + oldCurY; |
||
981 | if (DropCmode) |
||
982 | hl->yp -= RealCHeight(Doc, hl->cfont, chx2, chsd) - RealCAscent(Doc, hl->cfont, chx2, chsd); |
||
983 | if (LiList.count() == 0) |
||
984 | { |
||
985 | itemText.at(a)->cstyle |= 16384; |
||
986 | kernVal = 0; |
||
987 | } |
||
988 | else |
||
989 | { |
||
990 | kernVal = chs * hl->cextra / 10000.0; |
||
991 | itemText.at(a)->cstyle &= 16383; |
||
992 | } |
||
993 | if (!RTab) |
||
994 | { |
||
995 | hl->xp = QMAX(CurX+kernVal, ColBound.x()); |
||
996 | CurX += wide+kernVal; |
||
997 | CurX = QMAX(CurX, ColBound.x()); |
||
998 | } |
||
999 | else |
||
1000 | { |
||
1001 | CurX = QMAX(CurX, ColBound.x()); |
||
1002 | hl->xp = CurX; |
||
1003 | } |
||
1004 | if ((TabCode == 4) && (RTab)) |
||
1005 | { |
||
1006 | CurX += (wide+kernVal) / 2; |
||
1007 | CurX = QMAX(CurX, ColBound.x()); |
||
1008 | } |
||
1009 | if (((hl->cstyle & 128) || (hl->ch == "-")) && ((HyphenCount < Doc->HyCount) || (Doc->HyCount == 0))) |
||
1010 | { |
||
1011 | if (hl->cstyle & 128) |
||
1012 | { |
||
1013 | pt1 = QPoint(qRound(ceil(CurX+RExtra+Cwidth(Doc, hl->cfont, "-", hl->csize) * (hl->cscale / 1000.0))), qRound(CurY+desc)); |
||
1014 | pt2 = QPoint(qRound(ceil(CurX+RExtra+Cwidth(Doc, hl->cfont, "-", hl->csize) * (hl->cscale / 1000.0))), qRound(ceil(CurY-asce))); |
||
1015 | } |
||
1016 | else |
||
1017 | { |
||
1018 | pt1 = QPoint(qRound(ceil(CurX+RExtra)), qRound(CurY+desc)); |
||
1019 | pt2 = QPoint(qRound(ceil(CurX+RExtra)), qRound(ceil(CurY-asce))); |
||
1020 | } |
||
1021 | } |
||
1022 | else |
||
1023 | { |
||
1024 | pt1 = QPoint(qRound(ceil(CurX+RExtra)), qRound(CurY+desc)); |
||
1025 | pt2 = QPoint(qRound(ceil(CurX+RExtra)), qRound(ceil(CurY-asce))); |
||
1026 | } |
||
1027 | if ((!cl.contains(pf2.xForm(pt1))) || (!cl.contains(pf2.xForm(pt2))) || (CurX+RExtra+lineCorr > ColBound.y())) |
||
1028 | outs = true; |
||
1029 | if (CurY > (Height - BExtra - lineCorr)) |
||
1030 | outs = true; |
||
1031 | if ((hl->ch == QChar(27)) && (a < itemText.count()-1)) |
||
1032 | goNoRoom = true; |
||
1033 | if ((hl->ch == QChar(26)) && (Cols > 1)) |
||
1034 | goNextColumn = true; |
||
1035 | Zli = new ZZ; |
||
1036 | Zli->Zeich = chx; |
||
1037 | Zli->Farb = hl->ccolor; |
||
1038 | Zli->shade = hl->cshade; |
||
1039 | Zli->Farb2 = hl->cstroke; |
||
1040 | Zli->shade2 = hl->cshade2; |
||
1041 | Zli->xco = hl->xp; |
||
1042 | Zli->yco = hl->yp; |
||
1043 | Zli->Sele = hl->cselect; |
||
1044 | if (DropCmode) |
||
1045 | { |
||
1046 | Zli->Siz = chsd; |
||
1047 | Zli->realSiz = Doc->docParagraphStyles[hl->cab].FontSize; |
||
1048 | } |
||
1049 | else |
||
1050 | { |
||
1051 | Zli->Siz = chs; |
||
1052 | Zli->realSiz = hl->csize; |
||
1053 | } |
||
1054 | Zli->Style = hl->cstyle; |
||
1055 | Zli->ZFo = hl->cfont; |
||
1056 | Zli->wide = wide; |
||
1057 | Zli->kern = kernVal; |
||
1058 | Zli->scale = hl->cscale; |
||
1059 | Zli->scalev = hl->cscalev; |
||
1060 | Zli->base = hl->cbase; |
||
1061 | Zli->shadowX = hl->cshadowx; |
||
1062 | Zli->shadowY = hl->cshadowy; |
||
1063 | Zli->outline = hl->coutline; |
||
1064 | Zli->underpos = hl->cunderpos; |
||
1065 | Zli->underwidth = hl->cunderwidth; |
||
1066 | Zli->strikepos = hl->cstrikepos; |
||
1067 | Zli->strikewidth = hl->cstrikewidth; |
||
1068 | Zli->embedded = hl->cembedded; |
||
1069 | if (((hl->ch == " ") || (hl->ch == QChar(9))) && (!outs)) |
||
1070 | { |
||
1071 | if (a > 0) |
||
1072 | { |
||
1073 | if (itemText.at(a-1)->ch != " ") |
||
1074 | { |
||
1075 | LastXp = hl->xp; |
||
1076 | LastSP = BuPos; |
||
1077 | } |
||
1078 | } |
||
1079 | else |
||
1080 | { |
||
1081 | LastXp = hl->xp; |
||
1082 | LastSP = BuPos; |
||
1083 | } |
||
1084 | } |
||
1085 | if (((hl->cstyle & 128) || (hl->ch == "-")) && (!outs)) |
||
1086 | { |
||
1087 | if ((HyphenCount < Doc->HyCount) || (Doc->HyCount == 0)) |
||
1088 | { |
||
1089 | if (hl->ch == "-") |
||
1090 | LastXp = CurX; |
||
1091 | else |
||
1092 | LastXp = CurX + Cwidth(Doc, hl->cfont, "-", hl->csize) * (hl->cscale / 1000.0); |
||
1093 | LastSP = BuPos; |
||
1094 | } |
||
1095 | } |
||
1096 | LiList.append(Zli); |
||
1097 | if (RTab) |
||
1098 | { |
||
1099 | uint rtx2 = 0; |
||
1100 | double cen = 1; |
||
1101 | if (TabCode == 4) |
||
1102 | cen = 2; |
||
1103 | for (uint rtx = StartRT; rtx < LiList.count(); ++rtx) |
||
1104 | { |
||
1105 | LiList.at(rtx)->xco = QMAX(LiList.at(rtx)->xco-(wide+kernVal) / cen, 0.0); |
||
1106 | itemText.at(StartRT2+rtx2)->xp = QMAX(itemText.at(StartRT2+rtx2)->xp-(wide+kernVal) / cen, 0.0); |
||
1107 | if (itemText.at(StartRT2+rtx2)->xp < RTabX) |
||
1108 | { |
||
1109 | RTab = false; |
||
1110 | TabCode = 0; |
||
1111 | } |
||
1112 | rtx2++; |
||
1113 | } |
||
1114 | } |
||
1115 | BuPos++; |
||
1116 | if (DropCmode) |
||
1117 | { |
||
1118 | DropCmode = false; |
||
1119 | AbsHasDrop = true; |
||
1120 | maxDY = CurY; |
||
1121 | CurX += Doc->docParagraphStyles[hl->cab].DropDist; |
||
1122 | CurX = QMAX(CurX, ColBound.x()); |
||
1123 | maxDX = CurX; |
||
1124 | QPointArray tcli; |
||
1125 | tcli.resize(4); |
||
1126 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
1127 | { |
||
1128 | CurY -= Doc->typographicSettings.valueBaseGrid * (DropLines-1); |
||
1129 | double by = Ypos; |
||
1130 | if (OwnPage != -1) |
||
1131 | by = Ypos - Doc->Pages.at(OwnPage)->yOffset(); |
||
1132 | int ol1 = qRound((by + CurY - Doc->typographicSettings.offsetBaseGrid) * 10000.0); |
||
1133 | int ol2 = static_cast<int>(ol1 / Doc->typographicSettings.valueBaseGrid); |
||
1134 | CurY = ceil( ol2 / 10000.0 ) * Doc->typographicSettings.valueBaseGrid + Doc->typographicSettings.offsetBaseGrid - by; |
||
1135 | tcli.setPoint(0, QPoint(qRound(hl->xp), qRound(maxDY-DropLines*Doc->typographicSettings.valueBaseGrid))); |
||
1136 | tcli.setPoint(1, QPoint(qRound(maxDX), qRound(maxDY-DropLines*Doc->typographicSettings.valueBaseGrid))); |
||
1137 | } |
||
1138 | else |
||
1139 | { |
||
1140 | if (Doc->docParagraphStyles[absa].LineSpaMode == 0) |
||
1141 | { |
||
1142 | CurY -= Doc->docParagraphStyles[absa].LineSpa * (DropLines-1); |
||
1143 | tcli.setPoint(0, QPoint(qRound(hl->xp), qRound(maxDY-DropLines*Doc->docParagraphStyles[absa].LineSpa))); |
||
1144 | tcli.setPoint(1, QPoint(qRound(maxDX), qRound(maxDY-DropLines*Doc->docParagraphStyles[absa].LineSpa))); |
||
1145 | } |
||
1146 | else |
||
1147 | { |
||
1148 | double currasce = RealFHeight(Doc, hl->cfont, Doc->docParagraphStyles[hl->cab].FontSize); |
||
1149 | CurY -= currasce * (DropLines-1); |
||
1150 | tcli.setPoint(0, QPoint(qRound(hl->xp), qRound(maxDY-DropLines*currasce))); |
||
1151 | tcli.setPoint(1, QPoint(qRound(maxDX), qRound(maxDY-DropLines*currasce))); |
||
1152 | } |
||
1153 | } |
||
1154 | tcli.setPoint(2, QPoint(qRound(maxDX), qRound(maxDY))); |
||
1155 | tcli.setPoint(3, QPoint(qRound(hl->xp), qRound(maxDY))); |
||
1156 | cm = QRegion(pf2.xForm(tcli)); |
||
1157 | cl = cl.subtract(cm); |
||
1158 | } |
||
1159 | if ((hl->ch == QChar(13)) || (hl->ch == QChar(28)) || (hl->ch == QChar(27)) || ((hl->ch == QChar(26)) && (Cols > 1)) || (outs)) |
||
1160 | { |
||
1161 | RTab = false; |
||
1162 | TabCode = 0; |
||
1163 | if ((hl->ch == QChar(13)) || (hl->ch == QChar(28)) || (hl->ch == QChar(27)) || ((hl->ch == QChar(26)) && (Cols > 1))) |
||
1164 | { |
||
1165 | if (Doc->docParagraphStyles[absa].textAlignment != 0) |
||
1166 | { |
||
1167 | EndX = CurX; |
||
1168 | do |
||
1169 | { |
||
1170 | pt1 = QPoint(qRound(EndX+RExtra), static_cast<int>(CurY+desc)); |
||
1171 | pt2 = QPoint(qRound(EndX+RExtra), static_cast<int>(ceil(CurY-asce))); |
||
1172 | EndX++; |
||
1173 | } |
||
1174 | while ((cl.contains(pf2.xForm(pt1))) && (cl.contains(pf2.xForm(pt2))) && (EndX+RExtra+lineCorr < ColBound.y())); |
||
1175 | if (Doc->docParagraphStyles[absa].textAlignment == 2) |
||
1176 | OFs = EndX - CurX; |
||
1177 | if (Doc->docParagraphStyles[absa].textAlignment == 1) |
||
1178 | OFs = (EndX - CurX) / 2; |
||
1179 | if (Doc->docParagraphStyles[absa].textAlignment == 3) |
||
1180 | OFs = 0; |
||
1181 | if (Doc->docParagraphStyles[absa].textAlignment == 4) |
||
1182 | { |
||
1183 | aSpa = 0; |
||
1184 | for (uint sof = 0; sof<LiList.count(); ++sof) |
||
1185 | { |
||
1186 | if ((LiList.at(sof)->Zeich == QChar(32)) || (LiList.at(sof)->Zeich == QChar(29))) |
||
1187 | aSpa++; |
||
1188 | } |
||
1189 | if (aSpa != 0) |
||
1190 | OFs2 = (EndX - CurX) / aSpa; |
||
1191 | else |
||
1192 | OFs2 = 0; |
||
1193 | OFs = 0; |
||
1194 | for (uint yof = 0; yof < LiList.count(); ++yof) |
||
1195 | { |
||
1196 | LiList.at(yof)->xco += OFs; |
||
1197 | if ((LiList.at(yof)->Zeich == QChar(32)) || (LiList.at(yof)->Zeich == QChar(29))) |
||
1198 | OFs += OFs2; |
||
1199 | } |
||
1200 | } |
||
1201 | else |
||
1202 | { |
||
1203 | for (uint xof = 0; xof<LiList.count(); ++xof) |
||
1204 | { |
||
1205 | LiList.at(xof)->xco += OFs; |
||
1206 | } |
||
1207 | } |
||
1208 | CurX = EndX; |
||
1209 | } |
||
1210 | } |
||
1211 | else |
||
1212 | { |
||
1213 | if (LastSP != 0) // Hier koenen auch andere Trennungen eingebaut werden |
||
1214 | { |
||
1215 | a -= BuPos - LastSP; |
||
1216 | a++; |
||
1217 | if (itemText.at(a)->cstyle & 128) |
||
1218 | { |
||
1219 | HyphenCount++; |
||
1220 | itemText.at(a)->cstyle |= 8192; |
||
1221 | Zli = new ZZ; |
||
1222 | Zli->Zeich = "-"; |
||
1223 | Zli->Farb = itemText.at(a)->ccolor; |
||
1224 | Zli->Farb2 = itemText.at(a)->cstroke; |
||
1225 | Zli->shade = itemText.at(a)->cshade; |
||
1226 | Zli->shade2 = itemText.at(a)->cshade2; |
||
1227 | Zli->xco = LastXp - Cwidth(Doc, itemText.at(a)->cfont, "-", itemText.at(a)->csize) * (itemText.at(a)->cscale / 1000.0); |
||
1228 | Zli->yco = itemText.at(a)->yp; |
||
1229 | Zli->Sele = itemText.at(a)->cselect; |
||
1230 | Zli->Siz = itemText.at(a)->csize; |
||
1231 | Zli->realSiz = itemText.at(a)->csize; |
||
1232 | Zli->Style = itemText.at(a)->cstyle; |
||
1233 | Zli->ZFo = itemText.at(a)->cfont; |
||
1234 | Zli->wide = Cwidth(Doc, itemText.at(a)->cfont, "-", itemText.at(a)->csize) * (itemText.at(a)->cscale / 1000.0); |
||
1235 | Zli->kern = itemText.at(a)->csize * itemText.at(a)->cextra / 10000.0; |
||
1236 | Zli->scale = itemText.at(a)->cscale; |
||
1237 | Zli->scalev = itemText.at(a)->cscalev; |
||
1238 | Zli->base = itemText.at(a)->cbase; |
||
1239 | Zli->shadowX = itemText.at(a)->cshadowx; |
||
1240 | Zli->shadowY = itemText.at(a)->cshadowy; |
||
1241 | Zli->outline = itemText.at(a)->coutline; |
||
1242 | Zli->underpos = itemText.at(a)->cunderpos; |
||
1243 | Zli->underwidth = itemText.at(a)->cunderwidth; |
||
1244 | Zli->strikepos = itemText.at(a)->cstrikepos; |
||
1245 | Zli->strikewidth = itemText.at(a)->cstrikewidth; |
||
1246 | Zli->embedded = 0; |
||
1247 | LiList.insert(LastSP+1, Zli); |
||
1248 | LastSP += 1; |
||
1249 | } |
||
1250 | else |
||
1251 | { |
||
1252 | HyphenCount = 0; |
||
1253 | hl->cstyle &= 8191; |
||
1254 | } |
||
1255 | BuPos = LastSP+1; |
||
1256 | if (Doc->docParagraphStyles[absa].textAlignment != 0) |
||
1257 | { |
||
1258 | EndX = LastXp; |
||
1259 | do |
||
1260 | { |
||
1261 | pt1 = QPoint(qRound(EndX+RExtra), static_cast<int>(CurY+desc)); |
||
1262 | pt2 = QPoint(qRound(EndX+RExtra), static_cast<int>(ceil(CurY-asce))); |
||
1263 | EndX++; |
||
1264 | } |
||
1265 | while ((cl.contains(pf2.xForm(pt1))) && (cl.contains(pf2.xForm(pt2))) && (EndX+RExtra+lineCorr < ColBound.y())); |
||
1266 | if (Doc->docParagraphStyles[absa].textAlignment == 2) |
||
1267 | OFs = EndX - LastXp; |
||
1268 | if (Doc->docParagraphStyles[absa].textAlignment == 1) |
||
1269 | OFs = (EndX - LastXp) / 2; |
||
1270 | if ((Doc->docParagraphStyles[absa].textAlignment == 3) || (Doc->docParagraphStyles[absa].textAlignment == 4)) |
||
1271 | { |
||
1272 | aSpa = 0; |
||
1273 | for (uint sof = 0; sof<BuPos-1; ++sof) |
||
1274 | { |
||
1275 | if ((LiList.at(sof)->Zeich == QChar(32)) || (LiList.at(sof)->Zeich == QChar(29))) |
||
1276 | aSpa++; |
||
1277 | } |
||
1278 | if (aSpa > 1) |
||
1279 | OFs2 = (EndX - LastXp) / aSpa; |
||
1280 | else |
||
1281 | { |
||
1282 | if (aSpa == 0) |
||
1283 | OFs2 = 0; |
||
1284 | else |
||
1285 | OFs2 = (EndX - LastXp); |
||
1286 | } |
||
1287 | OFs = 0; |
||
1288 | for (uint yof = 0; yof < LiList.count(); ++yof) |
||
1289 | { |
||
1290 | LiList.at(yof)->xco += OFs; |
||
1291 | if ((LiList.at(yof)->Zeich == QChar(32)) || (LiList.at(yof)->Zeich == QChar(29))) |
||
1292 | OFs += OFs2; |
||
1293 | } |
||
1294 | } |
||
1295 | else |
||
1296 | { |
||
1297 | for (uint xof = 0; xof<LiList.count(); ++xof) |
||
1298 | { |
||
1299 | LiList.at(xof)->xco += OFs; |
||
1300 | } |
||
1301 | } |
||
1302 | CurX = EndX; |
||
1303 | } |
||
1304 | } |
||
1305 | else |
||
1306 | { |
||
1307 | a--; |
||
1308 | BuPos--; |
||
1309 | } |
||
1310 | } |
||
1311 | uint BuPos3 = BuPos; |
||
1312 | if ((outs) || (hl->ch == QChar(13)) || (hl->ch == QChar(28)) || (hl->ch == QChar(27)) || ((hl->ch == QChar(26)) && (Cols > 1))) |
||
1313 | { |
||
1314 | if ((outs) && (CurX+RExtra+lineCorr < ColBound.y())) |
||
1315 | { |
||
1316 | if (((hl->ch == QChar(13)) || (hl->ch == QChar(28))) && (AbsHasDrop)) |
||
1317 | { |
||
1318 | AbsHasDrop = false; |
||
1319 | if (CurY < maxDY) |
||
1320 | CurY = maxDY; |
||
1321 | } |
||
1322 | bool fromOut = true; |
||
1323 | double BotOffset = desc+BExtra+lineCorr; |
||
1324 | pt1 = QPoint(qRound(CurX+RExtra), static_cast<int>(CurY+BotOffset)); |
||
1325 | pt2 = QPoint(qRound(CurX+RExtra), static_cast<int>(ceil(CurY-asce))); |
||
1326 | while (CurX+RExtra+lineCorr < ColBound.y()) |
||
1327 | { |
||
1328 | CurX++; |
||
1329 | if (CurX+RExtra+lineCorr > ColBound.y()) |
||
1330 | { |
||
1331 | fromOut = false; |
||
1332 | if (Doc->docParagraphStyles[absa].BaseAdj) |
||
1333 | CurY += Doc->typographicSettings.valueBaseGrid; |
||
1334 | else |
||
1335 | CurY += Doc->docParagraphStyles[absa].LineSpa; |
||
1336 | if ((CurY+desc+BExtra+lineCorr > Height) && (CurrCol+1 == Cols)) |
||
1337 | { |
||
1338 | goNoRoom = true; |
||
1339 | break; |
||
1340 | } |
||
1341 | if (AbsHasDrop) |
||
1342 | { |
||
1343 | if ((CurY > maxDY) && (CurY - asce > maxDY)) |
||
1344 | { |
||
1345 | AbsHasDrop = false; |
||
1346 | CurX = ColBound.x(); |
||
1347 | } |
||
1348 | else |
||
1349 | CurX = maxDX; |
||
1350 | } |
||
1351 | else |
||
1352 | CurX = ColBound.x(); |
||
1353 | if ((hl->ch == QChar(13)) || (hl->ch == QChar(28)) || (hl->ch == QChar(27)) || (hl->ch == QChar(26))) |
||
1354 | { |
||
1355 | if (hl->ch == QChar(13)) |
||
1356 | CurY += Doc->docParagraphStyles[hl->cab].gapAfter; |
||
1357 | if (BuPos3 > 0) |
||
1358 | BuPos3 -= 1; |
||
1359 | HyphenCount = 0; |
||
1360 | } |
||
1361 | break; |
||
1362 | } |
||
1363 | pt1 = QPoint(qRound(CurX+RExtra), static_cast<int>(CurY+BotOffset)); |
||
1364 | pt2 = QPoint(qRound(CurX+RExtra), static_cast<int>(ceil(CurY-asce))); |
||
1365 | if ((cl.contains(pf2.xForm(pt1))) && (cl.contains(pf2.xForm(pt2)))) |
||
1366 | break; |
||
1367 | } |
||
1368 | if (fromOut) |
||
1369 | { |
||
1370 | if ((CurY+desc+BExtra+lineCorr > Height) && (CurrCol+1 == Cols)) |
||
1371 | { |
||
1372 | goNoRoom = true; |
||
1373 | break; |
||
1374 | } |
||
1375 | CurX--; |
||
1376 | CurX = QMAX(CurX, ColBound.x()); |
||
1377 | } |
||
1378 | } |
||
1379 | else |
||
1380 | { |
||
1381 | if (((hl->ch == QChar(13)) || (hl->ch == QChar(28))) && (AbsHasDrop)) |
||
1382 | { |
||
1383 | AbsHasDrop = false; |
||
1384 | if (CurY < maxDY) |
||
1385 | CurY = maxDY; |
||
1386 | } |
||
1387 | if (Doc->docParagraphStyles[hl->cab].BaseAdj) |
||
1388 | CurY += Doc->typographicSettings.valueBaseGrid; |
||
1389 | else |
||
1390 | { |
||
1391 | if (a < MaxText-1) |
||
1392 | CurY += Doc->docParagraphStyles[itemText.at(a+1)->cab].LineSpa; |
||
1393 | else |
||
1394 | CurY += Doc->docParagraphStyles[hl->cab].LineSpa; |
||
1395 | } |
||
1396 | if (AbsHasDrop) |
||
1397 | { |
||
1398 | if ((CurY > maxDY) && (CurY - asce > maxDY)) |
||
1399 | { |
||
1400 | AbsHasDrop = false; |
||
1401 | CurX = ColBound.x(); |
||
1402 | } |
||
1403 | else |
||
1404 | CurX = maxDX; |
||
1405 | } |
||
1406 | else |
||
1407 | CurX = ColBound.x(); |
||
1408 | if ((hl->ch == QChar(13)) || (hl->ch == QChar(28)) || (hl->ch == QChar(27)) || (hl->ch == QChar(26))) |
||
1409 | { |
||
1410 | if (hl->ch == QChar(13)) |
||
1411 | CurY += Doc->docParagraphStyles[hl->cab].gapAfter; |
||
1412 | if (BuPos3 > 0) |
||
1413 | BuPos3 -= 1; |
||
1414 | HyphenCount = 0; |
||
1415 | } |
||
1416 | } |
||
1417 | } |
||
1418 | hl->xp = CurX; |
||
1419 | hl->yp = CurY; |
||
1420 | LiList.at(LiList.count()-1)->xco = hl->xp; |
||
1421 | LiList.at(LiList.count()-1)->yco = hl->yp; |
||
1422 | if (LiList.count() != 0) |
||
1423 | { |
||
1424 | if ((!AbsHasDrop) && (StartOfCol) && (!Doc->docParagraphStyles[hl->cab].BaseAdj)) |
||
1425 | { |
||
1426 | Zli2 = LiList.at(0); |
||
1427 | double firstasce = Zli2->ZFo->numAscent * (Zli2->realSiz / 10.0); |
||
1428 | double currasce; |
||
1429 | if ((Zli2->Zeich == QChar(13)) || (Zli2->Zeich == QChar(28))) |
||
1430 | currasce = Zli2->ZFo->numAscent * (Zli2->realSiz / 10.0); |
||
1431 | else if ((Zli2->Zeich == QChar(25)) && (Zli2->embedded != 0)) |
||
1432 | currasce = QMAX(currasce, (Zli2->embedded->gHeight + Zli2->embedded->Pwidth) * (Zli2->scalev / 1000.0)); |
||
1433 | else |
||
1434 | currasce = RealCAscent(Doc, Zli2->ZFo, Zli2->Zeich, Zli2->realSiz); |
||
1435 | for (uint zc = 0; zc < LiList.count(); ++zc) |
||
1436 | { |
||
1437 | Zli2 = LiList.at(zc); |
||
1438 | if ((Zli2->Zeich == QChar(9)) || (Zli2->Zeich == QChar(10)) |
||
1439 | || (Zli2->Zeich == QChar(13)) || (Zli2->Zeich == QChar(24)) |
||
1440 | || (Zli2->Zeich == QChar(26)) || (Zli2->Zeich == QChar(27)) |
||
1441 | || (Zli2->Zeich == QChar(28)) || (Zli2->Zeich == QChar(29))) |
||
1442 | continue; |
||
1443 | if ((Zli2->Zeich == QChar(25)) && (Zli2->embedded != 0)) |
||
1444 | currasce = QMAX(currasce, (Zli2->embedded->gHeight + Zli2->embedded->Pwidth) * (Zli2->scalev / 1000.0)); |
||
1445 | else |
||
1446 | currasce = QMAX(currasce, RealCAscent(Doc, Zli2->ZFo, Zli2->Zeich, Zli2->realSiz)); |
||
1447 | } |
||
1448 | double adj = firstasce - currasce; |
||
1449 | for (uint zc = 0; zc < LiList.count(); ++zc) |
||
1450 | { |
||
1451 | LiList.at(zc)->yco -= adj; |
||
1452 | } |
||
1453 | CurY -= adj; |
||
1454 | } |
||
1455 | if ((!StartOfCol) && (!Doc->docParagraphStyles[hl->cab].BaseAdj) && (Doc->docParagraphStyles[hl->cab].LineSpaMode == 1)) |
||
1456 | { |
||
1457 | Zli2 = LiList.at(0); |
||
1458 | double firstasce = Doc->docParagraphStyles[hl->cab].LineSpa; |
||
1459 | double currasce; |
||
1460 | if ((Zli2->Zeich == QChar(25)) && (Zli2->embedded != 0)) |
||
1461 | currasce = QMAX(currasce, (Zli2->embedded->gHeight + Zli2->embedded->Pwidth) * (Zli2->scalev / 1000.0)); |
||
1462 | else |
||
1463 | currasce = RealFHeight(Doc, Zli2->ZFo, Zli2->realSiz); |
||
1464 | for (uint zc = 0; zc < LiList.count(); ++zc) |
||
1465 | { |
||
1466 | Zli2 = LiList.at(zc); |
||
1467 | if ((Zli2->Zeich == QChar(9)) || (Zli2->Zeich == QChar(10)) |
||
1468 | || (Zli2->Zeich == QChar(13)) || (Zli2->Zeich == QChar(24)) |
||
1469 | || (Zli2->Zeich == QChar(26)) || (Zli2->Zeich == QChar(27)) |
||
1470 | || (Zli2->Zeich == QChar(28)) || (Zli2->Zeich == QChar(29))) |
||
1471 | continue; |
||
1472 | if ((Zli2->Zeich == QChar(25)) && (Zli2->embedded != 0)) |
||
1473 | currasce = QMAX(currasce, (Zli2->embedded->gHeight + Zli2->embedded->Pwidth) * (Zli2->scalev / 1000.0)); |
||
1474 | else |
||
1475 | currasce = QMAX(currasce, RealFHeight(Doc, Zli2->ZFo, Zli2->realSiz)); |
||
1476 | } |
||
1477 | double adj = firstasce - currasce; |
||
1478 | for (uint zc = 0; zc < LiList.count(); ++zc) |
||
1479 | { |
||
1480 | LiList.at(zc)->yco -= adj; |
||
1481 | } |
||
1482 | CurY -= adj; |
||
1483 | } |
||
1484 | } |
||
1485 | StartOfCol = false; |
||
1486 | tabDist = ColBound.x(); |
||
1487 | uint tabCc = 0; |
||
1488 | uint loopC = BuPos3; |
||
1489 | if (Doc->guidesSettings.showControls) |
||
1490 | loopC++; |
||
1491 | for (uint zc = 0; zc<loopC; ++zc) |
||
1492 | { |
||
1493 | double wide2 = 0; |
||
1494 | Zli2 = LiList.at(zc); |
||
1495 | double xcoZli = Zli2->xco; |
||
1496 | itemText.at(startLin+zc)->xp = Zli2->xco; |
||
1497 | itemText.at(startLin+zc)->yp = Zli2->yco; |
||
1498 | if (itemText.at(startLin+zc)->cab < 5) |
||
1499 | tTabValues = TabValues; |
||
1500 | else |
||
1501 | tTabValues = Doc->docParagraphStyles[itemText.at(startLin+zc)->cab].TabValues; |
||
1502 | if (Zli2->Farb != "None") |
||
1503 | { |
||
1504 | QColor tmp; |
||
1505 | SetFarbe(&tmp, Zli2->Farb, Zli2->shade); |
||
1506 | p->setBrush(tmp); |
||
1507 | } |
||
1508 | desc = Zli2->ZFo->numDescender * (-Zli2->Siz / 10.0); |
||
1509 | asce = Zli2->ZFo->numAscent * (Zli2->Siz / 10.0); |
||
1510 | if ((((Zli2->Sele) && (Select)) || (((NextBox != 0) || (BackBox != 0)) && (Zli2->Sele))) && (Doc->appMode == modeEdit)) |
||
1511 | { |
||
1512 | wide = Zli2->wide; |
||
1513 | p->setFillMode(1); |
||
1514 | p->setBrush(darkBlue); |
||
1515 | p->setLineWidth(0); |
||
1516 | if ((zc > 0) && (Zli2->Zeich == QChar(9))) |
||
1517 | { |
||
1518 | wide2 = LiList.at(zc-1)->wide; |
||
1519 | xcoZli = LiList.at(zc-1)->xco+wide2; |
||
1520 | wide = Zli2->xco - xcoZli + Zli2->wide; |
||
1521 | } |
||
1522 | if (!Doc->RePos) |
||
1523 | p->drawRect(xcoZli, qRound(Zli2->yco-asce * (Zli2->scalev / 1000.0)), wide+1, qRound((asce+desc) * (Zli2->scalev / 1000.0))); |
||
1524 | p->setBrush(white); |
||
1525 | } |
||
1526 | if (Zli2->Farb2 != "None") |
||
1527 | { |
||
1528 | QColor tmp; |
||
1529 | SetFarbe(&tmp, Zli2->Farb2, Zli2->shade2); |
||
1530 | p->setPen(tmp, 1, SolidLine, FlatCap, MiterJoin); |
||
1531 | } |
||
1532 | if (!Doc->RePos) |
||
1533 | { |
||
1534 | if ((Zli2->Zeich == QChar(9)) && (tTabValues.count() != 0) && (tabCc < tTabValues.count()) && (!tTabValues[tabCc].tabFillChar.isNull())) |
||
1535 | { |
||
3668 | cbradney | 1536 | QString tabFillCharQStr(tTabValues[tabCc].tabFillChar); |
1537 | double wt = Cwidth(Doc, Zli2->ZFo, tabFillCharQStr, Zli2->Siz); |
||
3614 | cbradney | 1538 | int coun = static_cast<int>((Zli2->xco - tabDist) / wt); |
1539 | double sPos = Zli2->xco - (Zli2->xco - tabDist) + 1; |
||
1540 | Zli = new ZZ; |
||
3668 | cbradney | 1541 | Zli->Zeich = tabFillCharQStr; |
3614 | cbradney | 1542 | Zli->Farb = Zli2->Farb; |
1543 | Zli->Farb2 = Zli2->Farb2; |
||
1544 | Zli->shade = Zli2->shade; |
||
1545 | Zli->shade2 = Zli2->shade2; |
||
1546 | Zli->yco = Zli2->yco; |
||
1547 | Zli->Sele = Zli2->Sele; |
||
1548 | Zli->Siz = Zli2->Siz; |
||
1549 | Zli->realSiz = Zli2->realSiz; |
||
1550 | Zli->Style = Zli2->Style; |
||
1551 | Zli->ZFo = Zli2->ZFo; |
||
1552 | Zli->wide = wt; |
||
1553 | Zli->kern = 0; |
||
1554 | Zli->scale = 1000; |
||
1555 | Zli->scalev = 1000; |
||
1556 | Zli->base = Zli2->base; |
||
1557 | Zli->shadowX = Zli2->shadowX; |
||
1558 | Zli->shadowY = Zli2->shadowY; |
||
1559 | Zli->outline = Zli2->outline; |
||
1560 | Zli->underpos = Zli2->underpos; |
||
1561 | Zli->underwidth = Zli2->underwidth; |
||
1562 | Zli->strikepos = Zli2->strikepos; |
||
1563 | Zli->strikewidth = Zli2->strikewidth; |
||
1564 | Zli->embedded = 0; |
||
1565 | for (int cx = 0; cx < coun; ++cx) |
||
1566 | { |
||
1567 | Zli->xco = sPos + wt * cx; |
||
1568 | if (e2.intersects(pf2.xForm(QRect(qRound(Zli->xco),qRound(Zli->yco-asce), qRound(Zli->wide+1), qRound(asce+desc))))) |
||
1569 | DrawZeichenS(p, Zli); |
||
1570 | } |
||
1571 | delete Zli; |
||
1572 | } |
||
1573 | if (Zli2->Zeich == QChar(9)) |
||
1574 | tabCc++; |
||
1575 | if (((Zli2->Zeich == QChar(13)) || (Zli2->Zeich == QChar(28))) && (Doc->guidesSettings.showControls) && (LiList.count() != 0)) |
||
1576 | { |
||
1577 | if (e2.intersects(pf2.xForm(QRect(qRound(Zli2->xco+Zli2->wide),qRound(Zli2->yco-asce), qRound(Zli2->wide+1), qRound(asce+desc))))) |
||
1578 | { |
||
1579 | FPointArray points; |
||
1580 | QWMatrix chma, chma2, chma4, chma5; |
||
1581 | double ytrans, xtrans; |
||
1582 | if (Zli2->Zeich == QChar(13)) |
||
1583 | { |
||
1584 | points = Doc->symReturn.copy(); |
||
1585 | if (zc > 0) |
||
1586 | ytrans = LiList.at(zc-1)->yco-((Zli2->Siz / 10.0) * 0.8); |
||
1587 | else |
||
1588 | ytrans = Zli2->yco-Doc->docParagraphStyles[itemText.at(startLin+zc)->cab].LineSpa-((Zli2->Siz / 10.0) * 0.8); |
||
1589 | } |
||
1590 | else |
||
1591 | { |
||
1592 | points = Doc->symNewLine.copy(); |
||
1593 | if (zc > 0) |
||
1594 | ytrans = LiList.at(zc-1)->yco-((Zli2->Siz / 10.0) * 0.4); |
||
1595 | else |
||
1596 | ytrans = Zli2->yco-Doc->docParagraphStyles[itemText.at(startLin+zc)->cab].LineSpa-((Zli2->Siz / 10.0) * 0.4); |
||
1597 | } |
||
1598 | if (zc > 0) |
||
1599 | xtrans = LiList.at(zc-1)->xco + Cwidth(Doc, LiList.at(zc-1)->ZFo, LiList.at(zc-1)->Zeich, LiList.at(zc-1)->Siz); |
||
1600 | else |
||
1601 | { |
||
1602 | if (startLin > 0) |
||
1603 | xtrans = itemText.at(startLin-1)->xp + Cwidth(Doc, itemText.at(startLin-1)->cfont, itemText.at(startLin-1)->ch, itemText.at(startLin-1)->csize); |
||
1604 | else |
||
1605 | xtrans = Zli2->xco; |
||
1606 | } |
||
1607 | chma4.translate(xtrans, ytrans); |
||
1608 | chma.scale(Zli2->Siz / 100.0, Zli2->Siz / 100.0); |
||
1609 | chma2.scale(Zli2->scale / 1000.0, Zli2->scalev / 1000.0); |
||
1610 | chma5.scale(p->zoomFactor(), p->zoomFactor()); |
||
1611 | points.map(chma * chma2 * chma4 * chma5); |
||
1612 | p->setupTextPolygon(&points); |
||
1613 | p->setFillMode(1); |
||
1614 | p->fillPath(); |
||
1615 | } |
||
1616 | } |
||
1617 | if ((Doc->guidesSettings.showControls) && (zc == BuPos3)) |
||
1618 | break; |
||
1619 | if (e2.intersects(pf2.xForm(QRect(qRound(Zli2->xco),qRound(Zli2->yco-asce), qRound(Zli2->wide+1), qRound(asce+desc))))) |
||
1620 | { |
||
1621 | if (Zli2->Zeich == QChar(25)) |
||
1622 | DrawObj_Embedded(p, e, Zli2); |
||
1623 | else |
||
1624 | DrawZeichenS(p, Zli2); |
||
1625 | } |
||
1626 | } |
||
1627 | tabDist = Zli2->xco+Zli2->wide; |
||
1628 | } |
||
1629 |   |