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