1 /* This file is part of the KDE project
2 * Copyright (C) 2006-2010 Thomas Zander <zander@kde.org>
3 * Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
4 * Copyright (C) 2008 Roopesh Chander <roop@forwardbias.in>
5 * Copyright (C) 2008 Girish Ramakrishnan <girish@forwardbias.in>
6 * Copyright (C) 2009 KO GmbH <cbo@kogmbh.com>
7 * Copyright (C) 2011 Pierre Ducroquet <pinaraf@pinaraf.info>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
18 *
19 * You should have received a copy of the GNU Library General Public License
20 * along with this library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23 */
24
25 #include "KoTextLayoutCellHelper.h"
26
27 #include <KoTableCellStyle.h>
28 #include <QPainter>
29
KoTextLayoutCellHelper(const KoTableCellStyle & cellStyle,QObject * parent)30 KoTextLayoutCellHelper::KoTextLayoutCellHelper(const KoTableCellStyle &cellStyle, QObject *parent)
31 : QObject(parent), m_cellStyle(cellStyle)
32 {
33
34 }
35
isSpeciallyDrawn(KoBorder::BorderStyle style)36 bool isSpeciallyDrawn(KoBorder::BorderStyle style)
37 {
38 if (style == KoBorder::BorderWave)
39 return true;
40 if (style == KoBorder::BorderDoubleWave)
41 return true;
42 if (style == KoBorder::BorderSlash)
43 return true;
44 return false;
45 }
46
drawHorizontalWave(KoBorder::BorderStyle style,QPainter & painter,qreal x,qreal w,qreal t) const47 void KoTextLayoutCellHelper::drawHorizontalWave(KoBorder::BorderStyle style, QPainter &painter, qreal x, qreal w, qreal t) const
48 {
49 QPen pen = painter.pen();
50 const qreal linewidth = pen.widthF();
51 const qreal penwidth = linewidth/6;
52 pen.setWidth(penwidth);
53 painter.setPen(pen);
54 if (style == KoBorder::BorderSlash) {
55 for (qreal sx=x; sx<x+w-linewidth; sx+=linewidth*0.5) {
56 painter.drawLine(QLineF(sx, t-penwidth*2, sx+linewidth, t+penwidth*2));
57 }
58 } else {
59 for (qreal sx=x; sx<x+w-2*linewidth; sx+=linewidth) {
60 painter.drawLine(QLineF(sx, t-penwidth*2, sx+linewidth, t+penwidth*2));
61 sx+=linewidth;
62 painter.drawLine(QLineF(sx, t+penwidth*2, sx+linewidth, t-penwidth*2));
63 }
64 }
65 }
66
drawVerticalWave(KoBorder::BorderStyle style,QPainter & painter,qreal y,qreal h,qreal t) const67 void KoTextLayoutCellHelper::drawVerticalWave(KoBorder::BorderStyle style, QPainter &painter, qreal y, qreal h, qreal t) const
68 {
69 QPen pen = painter.pen();
70 const qreal linewidth = pen.width();
71 const qreal penwidth = linewidth/6;
72 pen.setWidth(penwidth);
73 painter.setPen(pen);
74 if (style == KoBorder::BorderSlash) {
75 for (qreal sy=y; sy<y+h-linewidth; sy+=linewidth*0.5) {
76 painter.drawLine(QLineF(t-penwidth*2, sy, t+penwidth*2, sy+linewidth));
77 }
78 } else {
79 for (qreal sy=y; sy<y+h-2*linewidth; sy+=linewidth) {
80 painter.drawLine(QLineF(t-penwidth*2, sy, t+penwidth*2, sy+linewidth));
81 sy+=linewidth;
82 painter.drawLine(QLineF(t+penwidth*2, sy, t-penwidth*2, sy+linewidth));
83 }
84 }
85 }
86
87
paintBorders(QPainter & painter,const QRectF & bounds,QVector<QLineF> * accumulatedBlankBorders) const88 void KoTextLayoutCellHelper::paintBorders(QPainter &painter, const QRectF &bounds, QVector<QLineF> *accumulatedBlankBorders) const
89 {
90 QRectF innerBounds = bounds;
91
92 // outer lines
93 QPen topOuterPen = m_cellStyle.getEdge(KoBorder::TopBorder).outerPen;
94 QPen bottomOuterPen = m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen;
95 QPen leftOuterPen = m_cellStyle.getEdge(KoBorder::LeftBorder).outerPen;
96 QPen rightOuterPen = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen;
97
98 if (topOuterPen.widthF() > 0) {
99 painter.setPen(topOuterPen);
100 const qreal t = bounds.top() + topOuterPen.widthF() / 2.0;
101 innerBounds.setTop(bounds.top() + m_cellStyle.getEdge(KoBorder::TopBorder).spacing + topOuterPen.widthF());
102 painter.drawLine(QLineF(bounds.left(), t, bounds.right(), t));
103 } else if (accumulatedBlankBorders) {
104 // No border but we'd like to draw one for user convenience when on screen
105 accumulatedBlankBorders->append(QLineF(bounds.left() + leftOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::LeftBorder).spacing,
106 bounds.top() + topOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::TopBorder).spacing,
107 bounds.right() - rightOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::RightBorder).spacing,
108 bounds.top() + topOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::TopBorder).spacing));
109 }
110
111 if (bottomOuterPen.widthF() > 0) {
112 painter.setPen(bottomOuterPen);
113 const qreal b = bounds.bottom() - bottomOuterPen.widthF() / 2.0;
114 innerBounds.setBottom(bounds.bottom() - m_cellStyle.getEdge(KoBorder::BottomBorder).spacing - bottomOuterPen.widthF());
115 painter.drawLine(QLineF(bounds.left(), b, bounds.right(), b));
116 } else if (accumulatedBlankBorders) {
117 // No border but we'd like to draw one for user convenience when on screen
118 accumulatedBlankBorders->append(QLineF(bounds.left() + leftOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::LeftBorder).spacing,
119 bounds.bottom() - bottomOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::BottomBorder).spacing,
120 bounds.right() - rightOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::RightBorder).spacing,
121 bounds.bottom() - bottomOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::BottomBorder).spacing));
122 }
123
124 if (leftOuterPen.widthF() > 0) {
125 painter.setPen(leftOuterPen);
126 const qreal l = bounds.left() + leftOuterPen.widthF() / 2.0;
127 innerBounds.setLeft(bounds.left() + m_cellStyle.getEdge(KoBorder::LeftBorder).spacing + leftOuterPen.widthF());
128 painter.drawLine(QLineF(l, bounds.top() + m_cellStyle.getEdge(KoBorder::TopBorder).outerPen.widthF(), l, bounds.bottom() - m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen.widthF()));
129 } else if (accumulatedBlankBorders) {
130 // No border but we'd like to draw one for user convenience when on screen
131 accumulatedBlankBorders->append(QLineF(bounds.left() + leftOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::LeftBorder).spacing,
132 bounds.top() + topOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::TopBorder).spacing,
133 bounds.left() + leftOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::LeftBorder).spacing,
134 bounds.bottom() - bottomOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::BottomBorder).spacing));
135 }
136
137 if (m_cellStyle.getEdge(KoBorder::RightBorder).outerPen.widthF() > 0) {
138 painter.setPen(rightOuterPen);
139 const qreal r = bounds.right() - rightOuterPen.widthF() / 2.0;
140 innerBounds.setRight(bounds.right() - m_cellStyle.getEdge(KoBorder::RightBorder).spacing - rightOuterPen.widthF());
141 painter.drawLine(QLineF(r, bounds.top() + m_cellStyle.getEdge(KoBorder::TopBorder).outerPen.widthF(), r, bounds.bottom() - bottomOuterPen.widthF()));
142 } else if (accumulatedBlankBorders) {
143 // No border but we'd like to draw one for user convenience when on screen
144 accumulatedBlankBorders->append(QLineF(bounds.right() - rightOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::RightBorder).spacing,
145 bounds.top() + topOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::TopBorder).spacing,
146 bounds.right() - rightOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::RightBorder).spacing,
147 bounds.bottom() - bottomOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::BottomBorder).spacing));
148 }
149
150 paintDiagonalBorders(painter, bounds);
151
152 // inner lines
153 if (m_cellStyle.getEdge(KoBorder::TopBorder).innerPen.widthF() > 0) {
154 QPen pen = m_cellStyle.getEdge(KoBorder::TopBorder).innerPen;
155 painter.setPen(pen);
156 const qreal t = innerBounds.top() + pen.widthF() / 2.0;
157 painter.drawLine(QLineF(innerBounds.left(), t, innerBounds.right(), t));
158 }
159 if (m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen.widthF() > 0) {
160 QPen pen = m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen;
161 painter.setPen(pen);
162 const qreal b = innerBounds.bottom() - pen.widthF() / 2.0;
163 painter.drawLine(QLineF(innerBounds.left(), b, innerBounds.right(), b));
164 }
165 if (m_cellStyle.getEdge(KoBorder::LeftBorder).innerPen.widthF() > 0) {
166 QPen pen = m_cellStyle.getEdge(KoBorder::LeftBorder).innerPen;
167 painter.setPen(pen);
168 const qreal l = innerBounds.left() + pen.widthF() / 2.0;
169 painter.drawLine(QLineF(l, innerBounds.top() + m_cellStyle.getEdge(KoBorder::TopBorder).innerPen.widthF(), l, innerBounds.bottom() - m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen.widthF()));
170 }
171 if (m_cellStyle.getEdge(KoBorder::RightBorder).innerPen.widthF() > 0) {
172 QPen pen = m_cellStyle.getEdge(KoBorder::RightBorder).innerPen;
173 painter.setPen(pen);
174 const qreal r = innerBounds.right() - pen.widthF() / 2.0;
175 painter.drawLine(QLineF(r, innerBounds.top() + m_cellStyle.getEdge(KoBorder::TopBorder).innerPen.widthF(), r, innerBounds.bottom() - m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen.widthF()));
176 }
177 }
178
paintDiagonalBorders(QPainter & painter,const QRectF & bounds) const179 void KoTextLayoutCellHelper::paintDiagonalBorders(QPainter &painter, const QRectF &bounds) const
180 {
181 if (m_cellStyle.getEdge(KoBorder::TlbrBorder).outerPen.widthF() > 0) {
182 QPen diagonalPen = m_cellStyle.getEdge(KoBorder::TlbrBorder).outerPen;
183 painter.setPen(diagonalPen);
184
185 QPen topPen = m_cellStyle.getEdge(KoBorder::TopBorder).outerPen;
186 const qreal top = bounds.top() + topPen.widthF() / 2.0;
187 QPen leftPen = m_cellStyle.getEdge(KoBorder::LeftBorder).outerPen;
188 const qreal left = bounds.left() + leftPen.widthF() / 2.0;
189 QPen bottomPen = m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen;
190 const qreal bottom = bounds.bottom() - bottomPen.widthF() / 2.0;
191 QPen rightPen = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen;
192 const qreal right = bounds.right() - rightPen.widthF() / 2.0;
193
194 painter.drawLine(QLineF(left, top, right, bottom));
195 }
196 if (m_cellStyle.getEdge(KoBorder::BltrBorder).outerPen.widthF() > 0) {
197 QPen pen = m_cellStyle.getEdge(KoBorder::BltrBorder).outerPen;
198 painter.setPen(pen);
199
200 QPen topPen = m_cellStyle.getEdge(KoBorder::TopBorder).outerPen;
201 const qreal top = bounds.top() + topPen.widthF() / 2.0;
202 QPen leftPen = m_cellStyle.getEdge(KoBorder::LeftBorder).outerPen;
203 const qreal left = bounds.left() + leftPen.widthF() / 2.0;
204 QPen bottomPen = m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen;
205 const qreal bottom = bounds.bottom() - bottomPen.widthF() / 2.0;
206 QPen rightPen = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen;
207 const qreal right = bounds.right() - rightPen.widthF() / 2.0;
208
209 painter.drawLine(QLineF(left, bottom, right, top));
210 }
211 }
212
drawTopHorizontalBorder(QPainter & painter,qreal x,qreal y,qreal w,QVector<QLineF> * accumulatedBlankBorders) const213 void KoTextLayoutCellHelper::drawTopHorizontalBorder(QPainter &painter, qreal x, qreal y, qreal w, QVector<QLineF> *accumulatedBlankBorders) const
214 {
215 qreal t=y;
216 if (m_cellStyle.getEdge(KoBorder::TopBorder).outerPen.widthF() > 0) {
217 QPen pen = m_cellStyle.getEdge(KoBorder::TopBorder).outerPen;
218
219 painter.setPen(pen);
220 t += pen.widthF() / 2.0;
221 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::TopBorder))) {
222 drawHorizontalWave(m_cellStyle.getBorderStyle(KoBorder::TopBorder), painter,x,w,t);
223 } else {
224 painter.drawLine(QLineF(x, t, x+w, t));
225 }
226 t = y + m_cellStyle.getEdge(KoBorder::TopBorder).spacing + pen.widthF();
227 } else if (accumulatedBlankBorders) {
228 // No border but we'd like to draw one for user convenience when on screen
229 accumulatedBlankBorders->append(QLineF(x, t, x+w, t));
230 }
231
232 // inner line
233 if (m_cellStyle.getEdge(KoBorder::TopBorder).innerPen.widthF() > 0) {
234 QPen pen = m_cellStyle.getEdge(KoBorder::TopBorder).innerPen;
235 painter.setPen(pen);
236 t += pen.widthF() / 2.0;
237 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::TopBorder))) {
238 drawHorizontalWave(m_cellStyle.getBorderStyle(KoBorder::TopBorder), painter,x,w,t);
239 } else {
240 painter.drawLine(QLineF(x, t, x+w, t));
241 }
242 }
243 }
244
drawSharedHorizontalBorder(QPainter & painter,const KoTableCellStyle & styleBelow,qreal x,qreal y,qreal w,QVector<QLineF> * accumulatedBlankBorders) const245 void KoTextLayoutCellHelper::drawSharedHorizontalBorder(QPainter &painter, const KoTableCellStyle &styleBelow, qreal x, qreal y, qreal w, QVector<QLineF> *accumulatedBlankBorders) const
246 {
247 bool paintThis = true;
248 if (m_cellStyle.getBorderStyle(KoBorder::BottomBorder) == KoBorder::BorderNone) {
249 if (styleBelow.getBorderStyle(KoBorder::TopBorder) == KoBorder::BorderNone) {
250 if (accumulatedBlankBorders) {
251 accumulatedBlankBorders->append(QLineF(x, y, x+w, y));
252 }
253 return;
254 }
255 paintThis = false;
256 }
257 else {
258 if (styleBelow.getBorderStyle(KoBorder::TopBorder) != KoBorder::BorderNone) {
259 qreal thisWidth = m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen.widthF() + m_cellStyle.getEdge(KoBorder::BottomBorder).spacing + m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen.widthF();
260 qreal thatWidth = styleBelow.getEdge(KoBorder::TopBorder).outerPen.widthF() + styleBelow.getEdge(KoBorder::TopBorder).spacing
261 + styleBelow.getEdge(KoBorder::TopBorder).innerPen.widthF();
262 paintThis = thisWidth >= thatWidth;
263 }
264 }
265
266 const KoBorder::BorderData &edge = paintThis ? m_cellStyle.getEdge(KoBorder::BottomBorder) : styleBelow.getEdge(KoBorder::TopBorder);
267 const KoBorder::BorderStyle borderStyle = paintThis ? m_cellStyle.getBorderStyle(KoBorder::BottomBorder): styleBelow.getBorderStyle(KoBorder::TopBorder);
268 qreal t=y;
269
270 if (edge.outerPen.widthF() > 0) {
271 QPen pen = edge.outerPen;
272 const qreal linewidth = pen.widthF();
273
274 painter.setPen(pen);
275 t += linewidth / 2.0;
276 if(isSpeciallyDrawn(borderStyle)) {
277 drawHorizontalWave(borderStyle, painter,x,w,t);
278 } else {
279 painter.drawLine(QLineF(x, t, x+w, t));
280 }
281 t = y + edge.spacing + linewidth;
282 }
283 // inner line
284 if (edge.innerPen.widthF() > 0) {
285 QPen pen = edge.innerPen;
286 painter.setPen(pen);
287 t += pen.widthF() / 2.0;
288 if(isSpeciallyDrawn(borderStyle)) {
289 drawHorizontalWave(borderStyle, painter,x,w,t);
290 } else {
291 painter.drawLine(QLineF(x, t, x+w, t));
292 }
293 }
294 }
295
drawBottomHorizontalBorder(QPainter & painter,qreal x,qreal y,qreal w,QVector<QLineF> * accumulatedBlankBorders) const296 void KoTextLayoutCellHelper::drawBottomHorizontalBorder(QPainter &painter, qreal x, qreal y, qreal w, QVector<QLineF> *accumulatedBlankBorders) const
297 {
298 qreal t=y;
299 if (m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen.widthF() > 0) {
300 QPen pen = m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen;
301
302 painter.setPen(pen);
303 t += pen.widthF() / 2.0;
304 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::BottomBorder))) {
305 drawHorizontalWave(m_cellStyle.getBorderStyle(KoBorder::BottomBorder), painter,x,w,t);
306 } else {
307 painter.drawLine(QLineF(x, t, x+w, t));
308 }
309 t = y + m_cellStyle.getEdge(KoBorder::BottomBorder).spacing + pen.widthF();
310 } else if (accumulatedBlankBorders) {
311 // No border but we'd like to draw one for user convenience when on screen
312 accumulatedBlankBorders->append(QLineF(x, t, x+w, t));
313
314 }
315
316 // inner line
317 if (m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen.widthF() > 0) {
318 QPen pen = m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen;
319 painter.setPen(pen);
320 t += pen.widthF() / 2.0;
321 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::BottomBorder))) {
322 drawHorizontalWave(m_cellStyle.getBorderStyle(KoBorder::BottomBorder), painter,x,w,t);
323 } else {
324 painter.drawLine(QLineF(x, t, x+w, t));
325 }
326 }
327 }
328
drawLeftmostVerticalBorder(QPainter & painter,qreal x,qreal y,qreal h,QVector<QLineF> * accumulatedBlankBorders) const329 void KoTextLayoutCellHelper::drawLeftmostVerticalBorder(QPainter &painter, qreal x, qreal y, qreal h, QVector<QLineF> *accumulatedBlankBorders) const
330 {
331 qreal thisWidth = m_cellStyle.getEdge(KoBorder::LeftBorder).outerPen.widthF() + m_cellStyle.getEdge(KoBorder::LeftBorder).spacing + m_cellStyle.getEdge(KoBorder::LeftBorder).innerPen.widthF();
332 qreal l = x - thisWidth / 2.0;
333
334 if (m_cellStyle.getEdge(KoBorder::LeftBorder).outerPen.widthF() > 0) {
335 QPen pen = m_cellStyle.getEdge(KoBorder::LeftBorder).outerPen;
336
337 painter.setPen(pen);
338 l += pen.widthF() / 2.0;
339 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::LeftBorder))) {
340 drawVerticalWave(m_cellStyle.getBorderStyle(KoBorder::LeftBorder), painter,y,h,l);
341 } else {
342 painter.drawLine(QLineF(l, y, l, y+h));
343 }
344 l += m_cellStyle.getEdge(KoBorder::LeftBorder).spacing + pen.widthF() / 2.0;
345 } else if (accumulatedBlankBorders) {
346 // No border but we'd like to draw one for user convenience when on screen
347 accumulatedBlankBorders->append(QLineF(l, y, l, y+h));
348
349 }
350
351 // inner line
352 if (m_cellStyle.getEdge(KoBorder::LeftBorder).innerPen.widthF() > 0) {
353 QPen pen = m_cellStyle.getEdge(KoBorder::LeftBorder).innerPen;
354 painter.setPen(pen);
355 l += pen.widthF() / 2.0;
356 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::LeftBorder))) {
357 drawVerticalWave(m_cellStyle.getBorderStyle(KoBorder::LeftBorder), painter,y,h,l);
358 } else {
359 painter.drawLine(QLineF(l, y, l, y+h));
360 }
361 }
362 }
363
drawSharedVerticalBorder(QPainter & painter,const KoTableCellStyle & styleRight,qreal x,qreal y,qreal h,QVector<QLineF> * accumulatedBlankBorders) const364 void KoTextLayoutCellHelper::drawSharedVerticalBorder(QPainter &painter, const KoTableCellStyle &styleRight, qreal x, qreal y, qreal h, QVector<QLineF> *accumulatedBlankBorders) const
365 {
366 // First determine which style "wins" by comparing total width
367 qreal thisWidth = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen.widthF() + m_cellStyle.getEdge(KoBorder::RightBorder).spacing + m_cellStyle.getEdge(KoBorder::RightBorder).innerPen.widthF();
368 qreal thatWidth = styleRight.getEdge(KoBorder::LeftBorder).outerPen.widthF() + styleRight.getEdge(KoBorder::LeftBorder).spacing
369 + styleRight.getEdge(KoBorder::LeftBorder).innerPen.widthF();
370
371 qreal l=x;
372
373 if(thisWidth >= thatWidth) {
374 // left style wins
375 l -= thisWidth / 2.0;
376 if (m_cellStyle.getEdge(KoBorder::RightBorder).outerPen.widthF() > 0) {
377 QPen pen = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen;
378
379 painter.setPen(pen);
380 l += pen.widthF() / 2.0;
381 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::RightBorder))) {
382 drawVerticalWave(m_cellStyle.getBorderStyle(KoBorder::RightBorder), painter,y,h,l);
383 } else {
384 painter.drawLine(QLineF(l, y, l, y+h));
385 }
386 l += m_cellStyle.getEdge(KoBorder::RightBorder).spacing + pen.widthF() / 2.0;
387 } else if (accumulatedBlankBorders) {
388 // No border but we'd like to draw one for user convenience when on screen
389 accumulatedBlankBorders->append(QLineF(l, y, l, y+h));
390
391 }
392
393 // inner line
394 if (m_cellStyle.getEdge(KoBorder::RightBorder).innerPen.widthF() > 0) {
395 QPen pen = m_cellStyle.getEdge(KoBorder::RightBorder).innerPen;
396 painter.setPen(pen);
397 l += pen.widthF() / 2.0;
398 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::RightBorder))) {
399 drawVerticalWave(m_cellStyle.getBorderStyle(KoBorder::RightBorder), painter,y,h,l);
400 } else {
401 painter.drawLine(QLineF(l, y, l, y+h));
402 }
403 }
404 } else {
405 // right style wins
406 l -= thatWidth/2.0;
407 if (styleRight.getEdge(KoBorder::LeftBorder).outerPen.widthF() > 0) {
408 QPen pen = styleRight.getEdge(KoBorder::LeftBorder).outerPen;
409
410 painter.setPen(pen);
411 l += pen.widthF() / 2.0;
412 if(isSpeciallyDrawn(styleRight.getBorderStyle(KoBorder::LeftBorder))) {
413 drawVerticalWave(styleRight.getBorderStyle(KoBorder::LeftBorder), painter,y,h,l);
414 } else {
415 painter.drawLine(QLineF(l, y, l, y+h));
416 }
417 l += styleRight.getEdge(KoBorder::LeftBorder).spacing + pen.widthF() / 2.0;
418 }
419 // inner line
420 if (styleRight.getEdge(KoBorder::LeftBorder).innerPen.widthF() > 0) {
421 QPen pen = styleRight.getEdge(KoBorder::LeftBorder).innerPen;
422 painter.setPen(pen);
423 l += pen.widthF() / 2.0;
424 if(isSpeciallyDrawn(styleRight.getBorderStyle(KoBorder::LeftBorder))) {
425 drawVerticalWave(styleRight.getBorderStyle(KoBorder::LeftBorder), painter,y,h,l);
426 } else {
427 painter.drawLine(QLineF(l, y, l, y+h));
428 }
429 }
430 }
431 }
432
drawRightmostVerticalBorder(QPainter & painter,qreal x,qreal y,qreal h,QVector<QLineF> * accumulatedBlankBorders) const433 void KoTextLayoutCellHelper::drawRightmostVerticalBorder(QPainter &painter, qreal x, qreal y, qreal h, QVector<QLineF> *accumulatedBlankBorders) const
434 {
435 qreal thisWidth = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen.widthF() + m_cellStyle.getEdge(KoBorder::RightBorder).spacing + m_cellStyle.getEdge(KoBorder::RightBorder).innerPen.widthF();
436 qreal l = x - thisWidth / 2.0;
437
438 if (m_cellStyle.getEdge(KoBorder::RightBorder).outerPen.widthF() > 0) {
439 QPen pen = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen;
440
441 painter.setPen(pen);
442 l += pen.widthF() / 2.0;
443 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::RightBorder))) {
444 drawVerticalWave(m_cellStyle.getBorderStyle(KoBorder::RightBorder), painter,y,h,l);
445 } else {
446 painter.drawLine(QLineF(l, y, l, y+h));
447 }
448 l += m_cellStyle.getEdge(KoBorder::RightBorder).spacing + pen.widthF() / 2.0;
449 } else if (accumulatedBlankBorders) {
450 // No border but we'd like to draw one for user convenience when on screen
451 accumulatedBlankBorders->append(QLineF(l, y, l, y+h));
452 }
453
454 // inner line
455 if (m_cellStyle.getEdge(KoBorder::RightBorder).innerPen.widthF() > 0) {
456 QPen pen = m_cellStyle.getEdge(KoBorder::RightBorder).innerPen;
457 painter.setPen(pen);
458 l += pen.widthF() / 2.0;
459 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::RightBorder))) {
460 drawVerticalWave(m_cellStyle.getBorderStyle(KoBorder::RightBorder), painter,y,h,l);
461 } else {
462 painter.drawLine(QLineF(l, y, l, y+h));
463 }
464 }
465 }
466