Rev 4486 | Rev 4580 | 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) |
3614 | cbradney | 137 | lineCorr = Pwidth / 2.0; |
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)) |
||
268 | Zli3.wide = (hl->cembedded->gWidth + hl->cembedded->Pwidth) * (hl->cscale / 1000.0); |
||
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)) |
||
692 | chs = qRound((hl->cembedded->gHeight + hl->cembedded->Pwidth) * 10); |
||
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)) |
||
704 | wide = hl->cembedded->gWidth + hl->cembedded->Pwidth; |
||
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 | { |
||
724 | wide = hl->cembedded->gWidth + hl->cembedded->Pwidth; |
||
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 | } |
734 | hl->cscalev = qRound(asce / (hl->cembedded->gHeight + hl->cembedded->Pwidth) * 1000.0); |
||
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; |
||
809 | if (StartOfCol) |
||
810 | { |
||
811 | CurY = asce+TExtra+lineCorr+1; |
||
812 | // if (((a > 0) && (itemText.at(a-1)->ch == QChar(13))) || ((a == 0) && (BackBox == 0))) |
||
4084 | cbradney | 813 | // CurY += m_Doc->docParagraphStyles[hl->cab].gapBefore; |
3614 | cbradney | 814 | } |
4084 | cbradney | 815 | if (m_Doc->docParagraphStyles[hl->cab].BaseAdj) |
3614 | cbradney | 816 | { |
817 | double by = Ypos; |
||
818 | if (OwnPage != -1) |
||
4084 | cbradney | 819 | by = Ypos - m_Doc->Pages->at(OwnPage)->yOffset(); |
820 | int ol1 = qRound((by + CurY - m_Doc->typographicSettings.offsetBaseGrid) * 10000.0); |
||
821 | int ol2 = static_cast<int>(ol1 / m_Doc->typographicSettings.valueBaseGrid); |
||
822 | CurY = ceil( ol2 / 10000.0 ) * m_Doc->typographicSettings.valueBaseGrid + m_Doc->typographicSettings.offsetBaseGrid - by; |
||
3614 | cbradney | 823 | } |
824 | if (CurY-TopOffset < 0.0) |
||
825 | CurY = TopOffset+1; |
||
826 | pt1 = QPoint(static_cast<int>(ceil(CurX)), static_cast<int>(CurY+BotOffset)); |
||
827 | pt2 = QPoint(static_cast<int>(ceil(CurX)), static_cast<int>(ceil(CurY-TopOffset))); |
||
828 | while ((!cl.contains(pf2.xForm(pt1))) || (!cl.contains(pf2.xForm(pt2)))) |
||
829 | { |
||
830 | fBorder = true; |
||
831 | CurX++; |
||
832 | if (CurX+RExtra+lineCorr > ColBound.y()) |
||
833 | { |
||
834 | fBorder = false; |
||
835 | if (StartOfCol) |
||
836 | { |
||
837 | CurX = ColBound.x(); |
||
838 | CurY++; |
||
839 | } |
||
840 | else |
||
841 | { |
||
4084 | cbradney | 842 | CurY += m_Doc->docParagraphStyles[hl->cab].LineSpa; |
3614 | cbradney | 843 | CurX = ColBound.x(); |
844 | } |
||
4084 | cbradney | 845 | if (m_Doc->docParagraphStyles[hl->cab].BaseAdj) |
3614 | cbradney | 846 | { |
847 | double by = Ypos; |
||
848 | if (OwnPage != -1) |
||
4084 | cbradney | 849 | by = Ypos - m_Doc->Pages->at(OwnPage)->yOffset(); |
850 | int ol1 = qRound((by + CurY - m_Doc->typographicSettings.offsetBaseGrid) * 10000.0); |
||
851 | int ol2 = static_cast<int>(ol1 / m_Doc->typographicSettings.valueBaseGrid); |
||
852 | CurY = ceil( ol2 / 10000.0 ) * m_Doc->typographicSettings.valueBaseGrid + m_Doc->typographicSettings.offsetBaseGrid - by; |
||
3614 | cbradney | 853 | } |
854 | if (CurY+BExtra+lineCorr > Height) |
||
855 | { |
||
856 | StartOfCol = true; |
||
857 | fBorder = false; |
||
858 | CurrCol++; |
||
859 | if (CurrCol < Cols) |
||
860 | { |
||
4098 | cbradney | 861 | ColWidth = columnWidth(); |
3614 | cbradney | 862 | ColBound = FPoint((ColWidth + ColGap) * CurrCol + Extra+lineCorr, ColWidth * (CurrCol+1) + ColGap * CurrCol + Extra+lineCorr); |
863 | CurX = ColBound.x(); |
||
864 | ColBound = FPoint(ColBound.x(), ColBound.y()+RExtra+lineCorr); |
||
865 | CurY = asce+TExtra+lineCorr+1; |
||
866 | if (((a > 0) && (itemText.at(a-1)->ch == QChar(13))) || ((a == 0) && (BackBox == 0))) |
||
867 | { |
||
868 | if (chx != QChar(13)) |
||
4084 | cbradney | 869 | DropCmode = m_Doc->docParagraphStyles[hl->cab].Drop; |
3614 | cbradney | 870 | else |
871 | DropCmode = false; |
||
872 | if (DropCmode) |
||
873 | { |
||
4084 | cbradney | 874 | if (m_Doc->docParagraphStyles[hl->cab].BaseAdj) |
875 | desc2 = -hl->cfont->numDescender * m_Doc->typographicSettings.valueBaseGrid * m_Doc->docParagraphStyles[hl->cab].DropLin; |
||
3614 | cbradney | 876 | else |
4084 | cbradney | 877 | desc2 = -hl->cfont->numDescender * m_Doc->docParagraphStyles[hl->cab].LineSpa * m_Doc->docParagraphStyles[hl->cab].DropLin; |
3614 | cbradney | 878 | } |
879 | if (DropCmode) |
||
4084 | cbradney | 880 | DropLines = m_Doc->docParagraphStyles[hl->cab].DropLin; |
3614 | cbradney | 881 | } |
4084 | cbradney | 882 | if (m_Doc->docParagraphStyles[hl->cab].BaseAdj) |
3614 | cbradney | 883 | { |
884 | double by = Ypos; |
||
885 | if (OwnPage != -1) |
||
4084 | cbradney | 886 | by = Ypos - m_Doc->Pages->at(OwnPage)->yOffset(); |
887 | int ol1 = qRound((by + CurY - m_Doc->typographicSettings.offsetBaseGrid) * 10000.0); |
||
888 | int ol2 = static_cast<int>(ol1 / m_Doc->typographicSettings.valueBaseGrid); |
||
889 | CurY = ceil( ol2 / 10000.0 ) * m_Doc->typographicSettings.valueBaseGrid + m_Doc->typographicSettings.offsetBaseGrid - by; |
||
3614 | cbradney | 890 | } |
891 | } |
||
892 | else |
||
893 | { |
||
894 | nrc = a; |
||
895 | goto NoRoom; |
||
896 | } |
||
897 | } |
||
898 | } |
||
899 | pt1 = QPoint(static_cast<int>(ceil(CurX)), static_cast<int>(CurY+BotOffset)); |
||
900 | pt2 = QPoint(static_cast<int>(ceil(CurX)), static_cast<int>(ceil(CurY-TopOffset))); |
||
901 | } |
||
4470 | fschmid | 902 | // if ((fBorder) && (!AbsHasDrop)) |
903 | if (!AbsHasDrop) |
||
3614 | cbradney | 904 | CurX += Extra; |
905 | if (a > 0) |
||
906 | { |
||
907 | if (itemText.at(a-1)->ch == QChar(13)) |
||
4084 | cbradney | 908 | CurX += m_Doc->docParagraphStyles[hl->cab].First; |
3614 | cbradney | 909 | } |
910 | else |
||
911 | { |
||
912 | if (BackBox == 0) |
||
4084 | cbradney | 913 | CurX += m_Doc->docParagraphStyles[hl->cab].First; |
3614 | cbradney | 914 | else |
915 | { |
||
916 | if (BackBox->itemText.count() != 0) |
||
917 | { |
||
918 | if (BackBox->itemText.at(BackBox->itemText.count()-1)->ch == QChar(13)) |
||
4084 | cbradney | 919 | CurX += m_Doc->docParagraphStyles[hl->cab].First; |
3614 | cbradney | 920 | } |
921 | else |
||
4084 | cbradney | 922 | CurX += m_Doc->docParagraphStyles[hl->cab].First; |
3614 | cbradney | 923 | } |
924 | } |
||
925 | if (!AbsHasDrop) |
||
4084 | cbradney | 926 | CurX += m_Doc->docParagraphStyles[hl->cab].Indent; |
3614 | cbradney | 927 | fBorder = false; |
928 | } |
||
929 | if (RTab) |
||
930 | { |
||
931 | if (((hl->ch == ".") && (TabCode == 2)) || ((hl->ch == ",") && (TabCode == 3)) || (hl->ch == QChar(9))) |
||
932 | { |
||
933 | RTab = false; |
||
934 | TabCode = 0; |
||
935 | } |
||
936 | } |
||
937 | if (hl->ch == QChar(9)) |
||
938 | { |
||
939 | wide = 1; |
||
940 | if (RTab) |
||
941 | RTab = false; |
||
942 | else |
||
943 | { |
||
944 | RTabX = CurX+wide; |
||
945 | if (hl->cab < 5) |
||
946 | tTabValues = TabValues; |
||
947 | else |
||
4084 | cbradney | 948 | tTabValues = m_Doc->docParagraphStyles[hl->cab].TabValues; |
3614 | cbradney | 949 | if (tTabValues.isEmpty()) |
950 | { |
||
951 | if ((CurX - ColBound.x()) != 0) |
||
952 | { |
||
4084 | cbradney | 953 | if (CurX == ColBound.x() + ceil((CurX-ColBound.x()) / m_Doc->toolSettings.dTabWidth) * m_Doc->toolSettings.dTabWidth) |
954 | CurX += m_Doc->toolSettings.dTabWidth; |
||
3614 | cbradney | 955 | else |
4084 | cbradney | 956 | CurX = ColBound.x() + ceil((CurX-ColBound.x()) / m_Doc->toolSettings.dTabWidth) * m_Doc->toolSettings.dTabWidth; |
3614 | cbradney | 957 | } |
958 | else |
||
4084 | cbradney | 959 | CurX = ColBound.x() + m_Doc->toolSettings.dTabWidth; |
3614 | cbradney | 960 | TabCode = 0; |
961 | RTab = false; |
||
962 | } |
||
963 | else |
||
964 | { |
||
965 | double tCurX = CurX - ColBound.x(); |
||
966 | double oCurX = tCurX + wide; |
||
967 | for (int yg = static_cast<int>(tTabValues.count()-1); yg > -1; yg--) |
||
968 | { |
||
969 | if (oCurX < tTabValues[yg].tabPosition) |
||
970 | { |
||
971 | tCurX = tTabValues[yg].tabPosition; |
||
972 | TabCode = static_cast<int>(tTabValues[yg].tabType); |
||
973 | } |
||
974 | } |
||
975 | if (TabCode == 0) |
||
976 | RTab = false; |
||
977 | else |
||
978 | RTab = true; |
||
979 | if (tCurX == oCurX-wide) |
||
4084 | cbradney | 980 | CurX = ColBound.x() + ceil((CurX-ColBound.x()) / m_Doc->toolSettings.dTabWidth) * m_Doc->toolSettings.dTabWidth; |
3614 | cbradney | 981 | else |
982 | CurX = ColBound.x() + tCurX; |
||
983 | } |
||
984 | CurX -= 1; |
||
985 | StartRT = LiList.count(); |
||
986 | StartRT2 = a; |
||
987 | } |
||
988 | } |
||
989 | hl->yp = CurY + oldCurY; |
||
990 | if (DropCmode) |
||
4084 | cbradney | 991 | hl->yp -= RealCHeight(m_Doc, hl->cfont, chx2, chsd) - RealCAscent(m_Doc, hl->cfont, chx2, chsd); |
3614 | cbradney | 992 | if (LiList.count() == 0) |
993 | { |
||
994 | itemText.at(a)->cstyle |= 16384; |
||
995 | kernVal = 0; |
||
996 | } |
||
997 | else |
||
998 | { |
||
999 | kernVal = chs * hl->cextra / 10000.0; |
||
1000 | itemText.at(a)->cstyle &= 16383; |
||
1001 | } |
||
1002 | if (!RTab) |
||
1003 | { |
||
1004 | hl->xp = QMAX(CurX+kernVal, ColBound.x()); |
||
1005 | CurX += wide+kernVal; |
||
1006 | CurX = QMAX(CurX, ColBound.x()); |
||
1007 | } |
||
1008 | else |
||
1009 | { |
||
1010 | CurX = QMAX(CurX, ColBound.x()); |
||
1011 | hl->xp = CurX; |
||
1012 | } |
||
1013 | if ((TabCode == 4) && (RTab)) |
||
1014 | { |
||
1015 | CurX += (wide+kernVal) / 2; |
||
1016 | CurX = QMAX(CurX, ColBound.x()); |
||
1017 | } |
||
4084 | cbradney | 1018 | if (((hl->cstyle & 128) || (hl->ch == "-")) && ((HyphenCount < m_Doc->HyCount) || (m_Doc->HyCount == 0))) |
3614 | cbradney | 1019 | { |
1020 | if (hl->cstyle & 128) |
||
1021 | { |
||
4084 | cbradney | 1022 | pt1 = QPoint(qRound(ceil(CurX+RExtra+Cwidth(m_Doc, hl->cfont, "-", hl->csize) * (hl->cscale / 1000.0))), qRound(CurY+desc)); |
1023 | pt2 = QPoint(qRound(ceil(CurX+RExtra+Cwidth(m_Doc, hl->cfont, "-", hl->csize) * (hl->cscale / 1000.0))), qRound(ceil(CurY-asce))); |
||
3614 | cbradney | 1024 | } |
1025 | else |
||
1026 | { |
||
1027 | pt1 = QPoint(qRound(ceil(CurX+RExtra)), qRound(CurY+desc)); |
||
1028 | pt2 = QPoint(qRound(ceil(CurX+RExtra)), qRound(ceil(CurY-asce))); |
||
1029 | } |
||
1030 | } |
||
1031 | else |
||
1032 | { |
||
1033 | pt1 = QPoint(qRound(ceil(CurX+RExtra)), qRound(CurY+desc)); |
||
1034 | pt2 = QPoint(qRound(ceil(CurX+RExtra)), qRound(ceil(CurY-asce))); |
||
1035 | } |
||
1036 | if ((!cl.contains(pf2.xForm(pt1))) || (!cl.contains(pf2.xForm(pt2))) || (CurX+RExtra+lineCorr > ColBound.y())) |
||
1037 | outs = true; |
||
1038 | if (CurY > (Height - BExtra - lineCorr)) |
||
1039 | outs = true; |
||
1040 | if ((hl->ch == QChar(27)) && (a < itemText.count()-1)) |
||
1041 | goNoRoom = true; |
||
1042 | if ((hl->ch == QChar(26)) && (Cols > 1)) |
||
1043 | goNextColumn = true; |
||
1044 | Zli = new ZZ; |
||
1045 | Zli->Zeich = chx; |
||
1046 | Zli->Farb = hl->ccolor; |
||
1047 | Zli->shade = hl->cshade; |
||
1048 | Zli->Farb2 = hl->cstroke; |
||
1049 | Zli->shade2 = hl->cshade2; |
||
1050 | Zli->xco = hl->xp; |
||
1051 | Zli->yco = hl->yp; |
||
1052 | Zli->Sele = hl->cselect; |
||
1053 | if (DropCmode) |
||
1054 | { |
||
1055 | Zli->Siz = chsd; |
||
4084 | cbradney | 1056 | Zli->realSiz = m_Doc->docParagraphStyles[hl->cab].FontSize; |
3614 | cbradney | 1057 | } |
1058 | else |
||
1059 | { |
||
1060 | Zli->Siz = chs; |
||
1061 | Zli->realSiz = hl->csize; |
||
1062 | } |
||
1063 | Zli->Style = hl->cstyle; |
||
1064 | Zli->ZFo = hl->cfont; |
||
1065 | Zli->wide = wide; |
||
1066 | Zli->kern = kernVal; |
||
1067 | Zli->scale = hl->cscale; |
||
1068 | Zli->scalev = hl->cscalev; |
||
1069 | Zli->base = hl->cbase; |
||
1070 | Zli->shadowX = hl->cshadowx; |
||
1071 | Zli->shadowY = hl->cshadowy; |
||
1072 | Zli->outline = hl->coutline; |
||
1073 | Zli->underpos = hl->cunderpos; |
||
1074 | Zli->underwidth = hl->cunderwidth; |
||
1075 | Zli->strikepos = hl->cstrikepos; |
||
1076 | Zli->strikewidth = hl->cstrikewidth; |
||
1077 | Zli->embedded = hl->cembedded; |
||
1078 | if (((hl->ch == " ") || (hl->ch == QChar(9))) && (!outs)) |
||
1079 | { |
||
1080 | if (a > 0) |
||
1081 | { |
||
1082 | if (itemText.at(a-1)->ch != " ") |
||
1083 | { |
||
1084 | LastXp = hl->xp; |
||
1085 | LastSP = BuPos; |
||
1086 | } |
||
1087 | } |
||
1088 | else |
||
1089 | { |
||
1090 | LastXp = hl->xp; |
||
1091 | LastSP = BuPos; |
||
1092 | } |
||
1093 | } |
||
1094 | if (((hl->cstyle & 128) || (hl->ch == "-")) && (!outs)) |
||
1095 | { |
||
4084 | cbradney | 1096 | if ((HyphenCount < m_Doc->HyCount) || (m_Doc->HyCount == 0)) |
3614 | cbradney | 1097 | { |
1098 | if (hl->ch == "-") |
||
1099 | LastXp = CurX; |
||
1100 | else |
||
4084 | cbradney | 1101 | LastXp = CurX + Cwidth(m_Doc, hl->cfont, "-", hl->csize) * (hl->cscale / 1000.0); |
3614 | cbradney | 1102 | LastSP = BuPos; |
1103 | } |
||
1104 | } |
||
1105 | LiList.append(Zli); |
||
1106 | if (RTab) |
||
1107 | { |
||
1108 | uint rtx2 = 0; |
||
1109 | double cen = 1; |
||
1110 | if (TabCode == 4) |
||
1111 | cen = 2; |
||
1112 | for (uint rtx = StartRT; rtx < LiList.count(); ++rtx) |
||
1113 | { |
||
1114 | LiList.at(rtx)->xco = QMAX(LiList.at(rtx)->xco-(wide+kernVal) / cen, 0.0); |
||
1115 | itemText.at(StartRT2+rtx2)->xp = QMAX(itemText.at(StartRT2+rtx2)->xp-(wide+kernVal) / cen, 0.0); |
||
1116 | if (itemText.at(StartRT2+rtx2)->xp < RTabX) |
||
1117 | { |
||
1118 | RTab = false; |
||
1119 | TabCode = 0; |
||
1120 | } |
||
1121 | rtx2++; |
||
1122 | } |
||
1123 | } |
||
1124 | BuPos++; |
||
1125 | if (DropCmode) |
||
1126 | { |
||
1127 | DropCmode = false; |
||
1128 | AbsHasDrop = true; |
||
1129 | maxDY = CurY; |
||
4084 | cbradney | 1130 | CurX += m_Doc->docParagraphStyles[hl->cab].DropDist; |
3614 | cbradney | 1131 | CurX = QMAX(CurX, ColBound.x()); |
1132 | maxDX = CurX; |
||
3989 | cbradney | 1133 | QPointArray tcli(4); |
4084 | cbradney | 1134 | if (m_Doc->docParagraphStyles[hl->cab].BaseAdj) |
3614 | cbradney | 1135 | { |
4084 | cbradney | 1136 | CurY -= m_Doc->typographicSettings.valueBaseGrid * (DropLines-1); |
3614 | cbradney | 1137 | double by = Ypos; |
1138 | if (OwnPage != -1) |
||
4084 | cbradney | 1139 | by = Ypos - m_Doc->Pages->at(OwnPage)->yOffset(); |
1140 | int ol1 = qRound((by + CurY - m_Doc->typographicSettings.offsetBaseGrid) * 10000.0); |
||
1141 | int ol2 = static_cast<int>(ol1 / m_Doc->typographicSettings.valueBaseGrid); |
||
1142 | CurY = ceil( ol2 / 10000.0 ) * m_Doc->typographicSettings.valueBaseGrid + m_Doc->typographicSettings.offsetBaseGrid - by; |
||
1143 | tcli.setPoint(0, QPoint(qRound(hl->xp), qRound(maxDY-DropLines*m_Doc->typographicSettings.valueBaseGrid))); |
||
1144 | tcli.setPoint(1, QPoint(qRound(maxDX), qRound(maxDY-DropLines*m_Doc->typographicSettings.valueBaseGrid))); |
||
3614 | cbradney | 1145 | } |
1146 | else |
||
1147 | { |
||
4084 | cbradney | 1148 | if (m_Doc->docParagraphStyles[absa].LineSpaMode == 0) |
3614 | cbradney | 1149 | { |
4084 | cbradney | 1150 | CurY -= m_Doc->docParagraphStyles[absa].LineSpa * (DropLines-1); |
1151 | tcli.setPoint(0, QPoint(qRound(hl->xp), qRound(maxDY-DropLines*m_Doc->docParagraphStyles[absa].LineSpa))); |
||
1152 | tcli.setPoint(1, QPoint(qRound(maxDX), qRound(maxDY-DropLines*m_Doc->docParagraphStyles[absa].LineSpa))); |
||
3614 | cbradney | 1153 | } |
1154 | else |
||
1155 | { |
||
4084 | cbradney | 1156 | double currasce = RealFHeight(m_Doc, hl->cfont, m_Doc->docParagraphStyles[hl->cab].FontSize); |
3614 | cbradney | 1157 | CurY -= currasce * (DropLines-1); |
1158 | tcli.setPoint(0, QPoint(qRound(hl->xp), qRound(maxDY-DropLines*currasce))); |
||
1159 | tcli.setPoint(1, QPoint(qRound(maxDX), qRound(maxDY-DropLines*currasce))); |
||
1160 | } |
||
1161 | } |
||
1162 | tcli.setPoint(2, QPoint(qRound(maxDX), qRound(maxDY))); |
||
1163 | tcli.setPoint(3, QPoint(qRound(hl->xp), qRound(maxDY))); |
||
1164 | cm = QRegion(pf2.xForm(tcli)); |
||
1165 | cl = cl.subtract(cm); |
||
1166 | } |
||
1167 | if ((hl->ch == QChar(13)) || (hl->ch == QChar(28)) || (hl->ch == QChar(27)) || ((hl->ch == QChar(26)) && (Cols > 1)) || (outs)) |
||
1168 | { |
||
1169 | RTab = false; |
||
1170 | TabCode = 0; |
||
1171 | if ((hl->ch == QChar(13)) || (hl->ch == QChar(28)) || (hl->ch == QChar(27)) || ((hl->ch == QChar(26)) && (Cols > 1))) |
||
1172 | { |
||
4084 | cbradney | 1173 | if (m_Doc->docParagraphStyles[absa].textAlignment != 0) |
3614 | cbradney | 1174 | { |
1175 | EndX = CurX; |
||
1176 | do |
||
1177 | { |
||
1178 | pt1 = QPoint(qRound(EndX+RExtra), static_cast<int>(CurY+desc)); |
||
1179 | pt2 = QPoint(qRound(EndX+RExtra), static_cast<int>(ceil(CurY-asce))); |
||
1180 | EndX++; |
||
1181 | } |
||
1182 | while ((cl.contains(pf2.xForm(pt1))) && (cl.contains(pf2.xForm(pt2))) && (EndX+RExtra+lineCorr < ColBound.y())); |
||
4084 | cbradney | 1183 | if (m_Doc->docParagraphStyles[absa].textAlignment == 2) |
3614 | cbradney | 1184 | OFs = EndX - CurX; |
4084 | cbradney | 1185 | if (m_Doc->docParagraphStyles[absa].textAlignment == 1) |
3614 | cbradney | 1186 | OFs = (EndX - CurX) / 2; |
4084 | cbradney | 1187 | if (m_Doc->docParagraphStyles[absa].textAlignment == 3) |
3614 | cbradney | 1188 | OFs = 0; |
4084 | cbradney | 1189 | if (m_Doc->docParagraphStyles[absa].textAlignment == 4) |
3614 | cbradney | 1190 | { |
1191 | aSpa = 0; |
||
1192 | for (uint sof = 0; sof<LiList.count(); ++sof) |
||
1193 | { |
||
1194 | if ((LiList.at(sof)->Zeich == QChar(32)) || (LiList.at(sof)->Zeich == QChar(29))) |
||
1195 | aSpa++; |
||
1196 | } |
||
1197 | if (aSpa != 0) |
||
1198 | OFs2 = (EndX - CurX) / aSpa; |
||
1199 | else |
||
1200 | OFs2 = 0; |
||
1201 | OFs = 0; |
||
1202 | for (uint yof = 0; yof < LiList.count(); ++yof) |
||
1203 | { |
||
1204 | LiList.at(yof)->xco += OFs; |
||
1205 | if ((LiList.at(yof)->Zeich == QChar(32)) || (LiList.at(yof)->Zeich == QChar(29))) |
||
1206 | OFs += OFs2; |
||
1207 | } |
||
1208 | } |
||
1209 | else |
||
1210 | { |
||
1211 | for (uint xof = 0; xof<LiList.count(); ++xof) |
||
1212 | { |
||
1213 | LiList.at(xof)->xco += OFs; |
||
1214 | } |
||
1215 | } |
||
1216 | CurX = EndX; |
||
1217 | } |
||
1218 | } |
||
1219 | else |
||
1220 | { |
||
1221 | if (LastSP != 0) // Hier koenen auch andere Trennungen eingebaut werden |
||
1222 | { |
||
1223 | a -= BuPos - LastSP; |
||
1224 | a++; |
||
1225 | if (itemText.at(a)->cstyle & 128) |
||
1226 | { |
||
1227 | HyphenCount++; |
||
1228 | itemText.at(a)->cstyle |= 8192; |
||
1229 | Zli = new ZZ; |
||
1230 | Zli->Zeich = "-"; |
||
1231 | Zli->Farb = itemText.at(a)->ccolor; |
||
1232 | Zli->Farb2 = itemText.at(a)->cstroke; |
||
1233 | Zli->shade = itemText.at(a)->cshade; |
||
1234 | Zli->shade2 = itemText.at(a)->cshade2; |
||
4084 | cbradney | 1235 | Zli->xco = LastXp - Cwidth(m_Doc, itemText.at(a)->cfont, "-", itemText.at(a)->csize) * (itemText.at(a)->cscale / 1000.0); |
3614 | cbradney | 1236 | Zli->yco = itemText.at(a)->yp; |
1237 | Zli->Sele = itemText.at(a)->cselect; |
||
1238 | Zli->Siz = itemText.at(a)->csize; |
||
1239 | Zli->realSiz = itemText.at(a)->csize; |
||
1240 | Zli->Style = itemText.at(a)->cstyle; |
||
1241 | Zli->ZFo = itemText.at(a)->cfont; |
||
4084 | cbradney | 1242 | Zli->wide = Cwidth(m_Doc, itemText.at(a)->cfont, "-", itemText.at(a)->csize) * (itemText.at(a)->cscale / 1000.0); |
3614 | cbradney | 1243 | Zli->kern = itemText.at(a)->csize * itemText.at(a)->cextra / 10000.0; |
1244 | Zli->scale = itemText.at(a)->cscale; |
||
1245 | Zli->scalev = itemText.at(a)->cscalev; |
||
1246 | Zli->base = itemText.at(a)->cbase; |
||
1247 | Zli->shadowX = itemText.at(a)->cshadowx; |
||
1248 | Zli->shadowY = itemText.at(a)->cshadowy; |
||
1249 | Zli->outline = itemText.at(a)->coutline; |
||
1250 | Zli->underpos = itemText.at(a)->cunderpos; |
||
1251 | Zli->underwidth = itemText.at(a)->cunderwidth; |
||
1252 | Zli->strikepos = itemText.at(a)->cstrikepos; |
||
1253 | Zli->strikewidth = itemText.at(a)->cstrikewidth; |
||
1254 | Zli->embedded = 0; |
||
1255 | LiList.insert(LastSP+1, Zli); |
||
1256 | LastSP += 1; |
||
1257 | } |
||
1258 | else |
||
1259 | { |
||
1260 | HyphenCount = 0; |
||
1261 | hl->cstyle &= 8191; |
||
1262 | } |
||
1263 | BuPos = LastSP+1; |
||
4084 | cbradney | 1264 | if (m_Doc->docParagraphStyles[absa].textAlignment != 0) |
3614 | cbradney | 1265 | { |
1266 | EndX = LastXp; |
||
1267 | do |
||
1268 | { |
||
1269 | pt1 = QPoint(qRound(EndX+RExtra), static_cast<int>(CurY+desc)); |
||
1270 | pt2 = QPoint(qRound(EndX+RExtra), static_cast<int>(ceil(CurY-asce))); |
||
1271 | EndX++; |
||
1272 | } |
||
1273 | while ((cl.contains(pf2.xForm(pt1))) && (cl.contains(pf2.xForm(pt2))) && (EndX+RExtra+lineCorr < ColBound.y())); |
||
4084 | cbradney | 1274 | if (m_Doc->docParagraphStyles[absa].textAlignment == 2) |
3614 | cbradney | 1275 | OFs = EndX - LastXp; |
4084 | cbradney | 1276 | if (m_Doc->docParagraphStyles[absa].textAlignment == 1) |
3614 | cbradney | 1277 | OFs = (EndX - LastXp) / 2; |
4084 | cbradney | 1278 | if ((m_Doc->docParagraphStyles[absa].textAlignment == 3) || (m_Doc->docParagraphStyles[absa].textAlignment == 4)) |
3614 | cbradney | 1279 | { |
1280 | aSpa = 0; |
||
1281 | for (uint sof = 0; sof<BuPos-1; ++sof) |
||
1282 | { |
||
1283 | if ((LiList.at(sof)->Zeich == QChar(32)) || (LiList.at(sof)->Zeich == QChar(29))) |
||
1284 | aSpa++; |
||
1285 | } |
||
1286 | if (aSpa > 1) |
||
1287 | OFs2 = (EndX - LastXp) / aSpa; |
||
1288 | else |
||
1289 | { |
||
1290 | if (aSpa == 0) |
||
1291 | OFs2 = 0; |
||
1292 | else |
||
1293 | OFs2 = (EndX - LastXp); |
||
1294 | } |
||
1295 | OFs = 0; |
||
1296 | for (uint yof = 0; yof < LiList.count(); ++yof) |
||
1297 | { |
||
1298 | LiList.at(yof)->xco += OFs; |
||
1299 | if ((LiList.at(yof)->Zeich == QChar(32)) || (LiList.at(yof)->Zeich == QChar(29))) |
||
1300 | OFs += OFs2; |
||
1301 | } |
||
1302 | } |
||
1303 | else |
||
1304 | { |
||
1305 | for (uint xof = 0; xof<LiList.count(); ++xof) |
||
1306 | { |
||
1307 | LiList.at(xof)->xco += OFs; |
||
1308 | } |
||
1309 | } |
||
1310 | CurX = EndX; |
||
1311 | } |
||
1312 | } |
||
1313 | else |
||
1314 | { |
||
1315 | a--; |
||
1316 | BuPos--; |
||
1317 | } |
||
1318 | } |
||
1319 | uint BuPos3 = BuPos; |
||
1320 | if ((outs) || (hl->ch == QChar(13)) || (hl->ch == QChar(28)) || (hl->ch == QChar(27)) || ((hl->ch == QChar(26)) && (Cols > 1))) |
||
1321 | { |
||
1322 | if ((outs) && (CurX+RExtra+lineCorr < ColBound.y())) |
||
1323 | { |
||
1324 | if (((hl->ch == QChar(13)) || (hl->ch == QChar(28))) && (AbsHasDrop)) |
||
1325 | { |
||
1326 | AbsHasDrop = false; |
||
1327 | if (CurY < maxDY) |
||
1328 | CurY = maxDY; |
||
1329 | } |
||
1330 | bool fromOut = true; |
||
1331 | double BotOffset = desc+BExtra+lineCorr; |
||
1332 | pt1 = QPoint(qRound(CurX+RExtra), static_cast<int>(CurY+BotOffset)); |
||
1333 | pt2 = QPoint(qRound(CurX+RExtra), static_cast<int>(ceil(CurY-asce))); |
||
1334 | while (CurX+RExtra+lineCorr < ColBound.y()) |
||
1335 | { |
||
1336 | CurX++; |
||
1337 | if (CurX+RExtra+lineCorr > ColBound.y()) |
||
1338 | { |
||
1339 | fromOut = false; |
||
4084 | cbradney | 1340 | if (m_Doc->docParagraphStyles[absa].BaseAdj) |
1341 | CurY += m_Doc->typographicSettings.valueBaseGrid; |
||
3614 | cbradney | 1342 | else |
4084 | cbradney | 1343 | CurY += m_Doc->docParagraphStyles[absa].LineSpa; |
3614 | cbradney | 1344 | if ((CurY+desc+BExtra+lineCorr > Height) && (CurrCol+1 == Cols)) |
1345 | { |
||
1346 | goNoRoom = true; |
||
1347 | break; |
||
1348 | } |
||
1349 | if (AbsHasDrop) |
||
1350 | { |
||
1351 | if ((CurY > maxDY) && (CurY - asce > maxDY)) |
||
1352 | { |
||
1353 | AbsHasDrop = false; |
||
1354 | CurX = ColBound.x(); |
||
1355 | } |
||
1356 | else |
||
1357 | CurX = maxDX; |
||
1358 | } |
||
1359 | else |
||
1360 | CurX = ColBound.x(); |
||
1361 | if ((hl->ch == QChar(13)) || (hl->ch == QChar(28)) || (hl->ch == QChar(27)) || (hl->ch == QChar(26))) |
||
1362 | { |
||
1363 | if (hl->ch == QChar(13)) |
||
4084 | cbradney | 1364 | CurY += m_Doc->docParagraphStyles[hl->cab].gapAfter; |
3614 | cbradney | 1365 | if (BuPos3 > 0) |
1366 | BuPos3 -= 1; |
||
1367 | HyphenCount = 0; |
||
1368 | } |
||
1369 | break; |
||
1370 | } |
||
1371 | pt1 = QPoint(qRound(CurX+RExtra), static_cast<int>(CurY+BotOffset)); |
||
1372 | pt2 = QPoint(qRound(CurX+RExtra), static_cast<int>(ceil(CurY-asce))); |
||
1373 | if ((cl.contains(pf2.xForm(pt1))) && (cl.contains(pf2.xForm(pt2)))) |
||
1374 | break; |
||
1375 | } |
||
1376 | if (fromOut) |
||
1377 | { |
||
1378 | if ((CurY+desc+BExtra+lineCorr > Height) && (CurrCol+1 == Cols)) |
||
1379 | { |
||
1380 | goNoRoom = true; |
||
1381 | break; |
||
1382 | } |
||
1383 | CurX--; |
||
1384 | CurX = QMAX(CurX, ColBound.x()); |
||
1385 | } |
||
1386 | } |
||
1387 | else |
||
1388 | { |
||
1389 | if (((hl->ch == QChar(13)) || (hl->ch == QChar(28))) && (AbsHasDrop)) |
||
1390 | { |
||
1391 | AbsHasDrop = false; |
||
1392 | if (CurY < maxDY) |
||
1393 | CurY = maxDY; |
||
1394 | } |
||
4084 | cbradney | 1395 | if (m_Doc->docParagraphStyles[hl->cab].BaseAdj) |
1396 | CurY += m_Doc->typographicSettings.valueBaseGrid; |
||
3614 | cbradney | 1397 | else |
1398 | { |
||
1399 | if (a < MaxText-1) |
||
4084 | cbradney | 1400 | CurY += m_Doc->docParagraphStyles[itemText.at(a+1)->cab].LineSpa; |
3614 | cbradney | 1401 | else |
4084 | cbradney | 1402 | CurY += m_Doc->docParagraphStyles[hl->cab].LineSpa; |
3614 | cbradney | 1403 | } |
1404 | if (AbsHasDrop) |
||
1405 | { |
||
1406 | if ((CurY > maxDY) && (CurY - asce > maxDY)) |
||
1407 | { |
||
1408 | AbsHasDrop = false; |
||
1409 | CurX = ColBound.x(); |
||
1410 | } |
||
1411 | else |
||
1412 | CurX = maxDX; |
||
1413 | } |
||
1414 | else |
||
1415 | CurX = ColBound.x(); |
||
1416 | if ((hl->ch == QChar(13)) || (hl->ch == QChar(28)) || (hl->ch == QChar(27)) || (hl->ch == QChar(26))) |
||
1417 | { |
||
1418 | if (hl->ch == QChar(13)) |
||
4084 | cbradney | 1419 | CurY += m_Doc->docParagraphStyles[hl->cab].gapAfter; |
3614 | cbradney | 1420 | if (BuPos3 > 0) |
1421 | BuPos3 -= 1; |
||
1422 | HyphenCount = 0; |
||
1423 | } |
||
1424 | } |
||
1425 | } |
||
1426 | hl->xp = CurX; |
||
1427 | hl->yp = CurY; |
||
1428 | LiList.at(LiList.count()-1)->xco = hl->xp; |
||
1429 | LiList.at(LiList.count()-1)->yco = hl->yp; |
||
1430 | if (LiList.count() != 0) |
||
1431 | { |
||
4084 | cbradney | 1432 | if ((!AbsHasDrop) && (StartOfCol) && (!m_Doc->docParagraphStyles[hl->cab].BaseAdj)) |
3614 | cbradney | 1433 | { |
1434 | Zli2 = LiList.at(0); |
||
1435 | double firstasce = Zli2->ZFo->numAscent * (Zli2->realSiz / 10.0); |
||
1436 | double currasce; |
||
1437 | if ((Zli2->Zeich == QChar(13)) || (Zli2->Zeich == QChar(28))) |
||
1438 | currasce = Zli2->ZFo->numAscent * (Zli2->realSiz / 10.0); |
||
1439 | else if ((Zli2->Zeich == QChar(25)) && (Zli2->embedded != 0)) |
||
1440 | currasce = QMAX(currasce, (Zli2->embedded->gHeight + Zli2->embedded->Pwidth) * (Zli2->scalev / 1000.0)); |
||
1441 | else |
||
4084 | cbradney | 1442 | currasce = RealCAscent(m_Doc, Zli2->ZFo, Zli2->Zeich, Zli2->realSiz); |
3614 | cbradney | 1443 | for (uint zc = 0; zc < LiList.count(); ++zc) |
1444 | { |
||
1445 | Zli2 = LiList.at(zc); |
||
1446 | if ((Zli2->Zeich == QChar(9)) || (Zli2->Zeich == QChar(10)) |
||
1447 | || (Zli2->Zeich == QChar(13)) || (Zli2->Zeich == QChar(24)) |
||
1448 | || (Zli2->Zeich == QChar(26)) || (Zli2->Zeich == QChar(27)) |
||
1449 | || (Zli2->Zeich == QChar(28)) || (Zli2->Zeich == QChar(29))) |
||
1450 | continue; |
||
1451 | if ((Zli2->Zeich == QChar(25)) && (Zli2->embedded != 0)) |
||
1452 | currasce = QMAX(currasce, (Zli2->embedded->gHeight + Zli2->embedded->Pwidth) * (Zli2->scalev / 1000.0)); |
||
1453 | else |
||
4084 | cbradney | 1454 | currasce = QMAX(currasce, RealCAscent(m_Doc, Zli2->ZFo, Zli2->Zeich, Zli2->realSiz)); |
3614 | cbradney | 1455 | } |
1456 | double adj = firstasce - currasce; |
||
1457 | for (uint zc = 0; zc < LiList.count(); ++zc) |
||
1458 | { |
||
1459 | LiList.at(zc)->yco -= adj; |
||
1460 | } |
||
1461 | CurY -= adj; |
||
1462 | } |
||
4084 | cbradney | 1463 | if ((!StartOfCol) && (!m_Doc->docParagraphStyles[hl->cab].BaseAdj) && (m_Doc->docParagraphStyles[hl->cab].LineSpaMode == 1)) |
3614 | cbradney | 1464 | { |
1465 | Zli2 = LiList.at(0); |
||
4084 | cbradney | 1466 | double firstasce = m_Doc->docParagraphStyles[hl->cab].LineSpa; |
3614 | cbradney | 1467 | double currasce; |
1468 | if ((Zli2->Zeich == QChar(25)) && (Zli2->embedded != 0)) |
||
1469 | currasce = QMAX(currasce, (Zli2->embedded->gHeight + Zli2->embedded->Pwidth) * (Zli2->scalev / 1000.0)); |
||
1470 | else |
||
4084 | cbradney | 1471 | currasce = RealFHeight(m_Doc, Zli2->ZFo, Zli2->realSiz); |
3614 | cbradney | 1472 | for (uint zc = 0; zc < LiList.count(); ++zc) |
1473 | { |
||
1474 | Zli2 = LiList.at(zc); |
||
1475 | if ((Zli2->Zeich == QChar(9)) || (Zli2->Zeich == QChar(10)) |
||
1476 | || (Zli2->Zeich == QChar(13)) || (Zli2->Zeich == QChar(24)) |
||
1477 | || (Zli2->Zeich == QChar(26)) || (Zli2->Zeich == QChar(27)) |
||
1478 | || (Zli2->Zeich == QChar(28)) || (Zli2->Zeich == QChar(29))) |
||
1479 | continue; |
||
1480 | if ((Zli2->Zeich == QChar(25)) && (Zli2->embedded != 0)) |
||
1481 | currasce = QMAX(currasce, (Zli2->embedded->gHeight + Zli2->embedded->Pwidth) * (Zli2->scalev / 1000.0)); |
||
1482 | else |
||
4084 | cbradney | 1483 | currasce = QMAX(currasce, RealFHeight(m_Doc, Zli2->ZFo, Zli2->realSiz)); |
3614 | cbradney | 1484 | } |
1485 | double adj = firstasce - currasce; |
||
1486 | for (uint zc = 0; zc < LiList.count(); ++zc) |
||
1487 | { |
||
1488 | LiList.at(zc)->yco -= adj; |
||
1489 | } |
||
1490 | CurY -= adj; |
||
1491 | } |
||
1492 | } |
||
1493 | StartOfCol = false; |
||
1494 | tabDist = ColBound.x(); |
||
1495 | uint tabCc = 0; |
||
1496 | uint loopC = BuPos3; |
||
4084 | cbradney | 1497 | if (m_Doc->guidesSettings.showControls) |
3614 | cbradney | 1498 | loopC++; |
1499 | for (uint zc = 0; zc<loopC; ++zc) |
||
1500 | { |
||
1501 | double wide2 = 0; |
||
1502 | Zli2 = LiList.at(zc); |
||
1503 | double xcoZli = Zli2->xco; |
||
1504 | itemText.at(startLin+zc)->xp = Zli2->xco; |
||
1505 | itemText.at(startLin+zc)->yp = Zli2->yco; |
||
1506 | if (itemText.at(startLin+zc)->cab < 5) |
||
1507 | tTabValues = TabValues; |
||
1508 | else |
||
4084 | cbradney | 1509 | tTabValues = m_Doc->docParagraphStyles[itemText.at(startLin+zc)->cab].TabValues; |
4546 | subik | 1510 | if (Zli2->Farb != CommonStrings::None) |
3614 | cbradney | 1511 | { |
1512 | QColor tmp; |
||
1513 | SetFarbe(&tmp, Zli2->Farb, Zli2->shade); |
||
1514 | p->setBrush(tmp); |
||
1515 | } |
||
1516 | desc = Zli2->ZFo->numDescender * (-Zli2->Siz / 10.0); |
||
1517 | asce = Zli2->ZFo->numAscent * (Zli2->Siz / 10.0); |
||
4084 | cbradney | 1518 | if ((((Zli2->Sele) && (Select)) || (((NextBox != 0) || (BackBox != 0)) && (Zli2->Sele))) && (m_Doc->appMode == modeEdit)) |
3614 | cbradney | 1519 | { |
1520 | wide = Zli2->wide; |
||
1521 | p->setFillMode(1); |
||
4486 | fschmid | 1522 | p->setBrush(qApp->palette().color(QPalette::Active, QColorGroup::Highlight)); |
1523 | // p->setBrush(darkBlue); |
||
3614 | cbradney | 1524 | p->setLineWidth(0); |
1525 | if ((zc > 0) && (Zli2->Zeich == QChar(9))) |
||
1526 | { |
||
1527 | wide2 = LiList.at(zc-1)->wide; |
||
1528 | xcoZli = LiList.at(zc-1)->xco+wide2; |
||
1529 | wide = Zli2->xco - xcoZli + Zli2->wide; |
||
1530 | } |
||
4084 | cbradney | 1531 | if (!m_Doc->RePos) |
3614 | cbradney | 1532 | p->drawRect(xcoZli, qRound(Zli2->yco-asce * (Zli2->scalev / 1000.0)), wide+1, qRound((asce+desc) * (Zli2->scalev / 1000.0))); |
4486 | fschmid | 1533 | p->setBrush(qApp->palette().color(QPalette::Active, QColorGroup::HighlightedText)); |
1534 | // p->setBrush(white); |
||
3614 | cbradney | 1535 | } |
4546 | subik | 1536 | if (Zli2->Farb2 != CommonStrings::None) |
3614 | cbradney | 1537 | { |
1538 | QColor tmp; |
||
1539 | SetFarbe(&tmp, Zli2->Farb2, Zli2->shade2); |
||
1540 | p->setPen(tmp, 1, SolidLine, FlatCap, MiterJoin); |
||
1541 | } |
||
4084 | cbradney | 1542 | if (!m_Doc->RePos) |
3614 | cbradney | 1543 | { |
1544 | if ((Zli2->Zeich == QChar(9)) && (tTabValues.count() != 0) && (tabCc < tTabValues.count()) && (!tTabValues[tabCc].tabFillChar.isNull())) |
||
1545 | { |
||
3668 | cbradney | 1546 | QString tabFillCharQStr(tTabValues[tabCc].tabFillChar); |
4084 | cbradney | 1547 |