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