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