Warning, file /office/calligra/libs/textlayout/KoTextLayoutCellHelper.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2006-2010 Thomas Zander <zander@kde.org> 0003 * Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org> 0004 * Copyright (C) 2008 Roopesh Chander <roop@forwardbias.in> 0005 * Copyright (C) 2008 Girish Ramakrishnan <girish@forwardbias.in> 0006 * Copyright (C) 2009 KO GmbH <cbo@kogmbh.com> 0007 * Copyright (C) 2011 Pierre Ducroquet <pinaraf@pinaraf.info> 0008 * 0009 * This library is free software; you can redistribute it and/or 0010 * modify it under the terms of the GNU Library General Public 0011 * License as published by the Free Software Foundation; either 0012 * version 2 of the License, or (at your option) any later version. 0013 * 0014 * This library is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0017 * Library General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Library General Public License 0020 * along with this library; see the file COPYING.LIB. If not, write to 0021 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0022 * Boston, MA 02110-1301, USA. 0023 */ 0024 0025 #include "KoTextLayoutCellHelper.h" 0026 0027 #include <KoTableCellStyle.h> 0028 #include <QPainter> 0029 0030 KoTextLayoutCellHelper::KoTextLayoutCellHelper(const KoTableCellStyle &cellStyle, QObject *parent) 0031 : QObject(parent), m_cellStyle(cellStyle) 0032 { 0033 0034 } 0035 0036 bool isSpeciallyDrawn(KoBorder::BorderStyle style) 0037 { 0038 if (style == KoBorder::BorderWave) 0039 return true; 0040 if (style == KoBorder::BorderDoubleWave) 0041 return true; 0042 if (style == KoBorder::BorderSlash) 0043 return true; 0044 return false; 0045 } 0046 0047 void KoTextLayoutCellHelper::drawHorizontalWave(KoBorder::BorderStyle style, QPainter &painter, qreal x, qreal w, qreal t) const 0048 { 0049 QPen pen = painter.pen(); 0050 const qreal linewidth = pen.widthF(); 0051 const qreal penwidth = linewidth/6; 0052 pen.setWidth(penwidth); 0053 painter.setPen(pen); 0054 if (style == KoBorder::BorderSlash) { 0055 for (qreal sx=x; sx<x+w-linewidth; sx+=linewidth*0.5) { 0056 painter.drawLine(QLineF(sx, t-penwidth*2, sx+linewidth, t+penwidth*2)); 0057 } 0058 } else { 0059 for (qreal sx=x; sx<x+w-2*linewidth; sx+=linewidth) { 0060 painter.drawLine(QLineF(sx, t-penwidth*2, sx+linewidth, t+penwidth*2)); 0061 sx+=linewidth; 0062 painter.drawLine(QLineF(sx, t+penwidth*2, sx+linewidth, t-penwidth*2)); 0063 } 0064 } 0065 } 0066 0067 void KoTextLayoutCellHelper::drawVerticalWave(KoBorder::BorderStyle style, QPainter &painter, qreal y, qreal h, qreal t) const 0068 { 0069 QPen pen = painter.pen(); 0070 const qreal linewidth = pen.width(); 0071 const qreal penwidth = linewidth/6; 0072 pen.setWidth(penwidth); 0073 painter.setPen(pen); 0074 if (style == KoBorder::BorderSlash) { 0075 for (qreal sy=y; sy<y+h-linewidth; sy+=linewidth*0.5) { 0076 painter.drawLine(QLineF(t-penwidth*2, sy, t+penwidth*2, sy+linewidth)); 0077 } 0078 } else { 0079 for (qreal sy=y; sy<y+h-2*linewidth; sy+=linewidth) { 0080 painter.drawLine(QLineF(t-penwidth*2, sy, t+penwidth*2, sy+linewidth)); 0081 sy+=linewidth; 0082 painter.drawLine(QLineF(t+penwidth*2, sy, t-penwidth*2, sy+linewidth)); 0083 } 0084 } 0085 } 0086 0087 0088 void KoTextLayoutCellHelper::paintBorders(QPainter &painter, const QRectF &bounds, QVector<QLineF> *accumulatedBlankBorders) const 0089 { 0090 QRectF innerBounds = bounds; 0091 0092 // outer lines 0093 QPen topOuterPen = m_cellStyle.getEdge(KoBorder::TopBorder).outerPen; 0094 QPen bottomOuterPen = m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen; 0095 QPen leftOuterPen = m_cellStyle.getEdge(KoBorder::LeftBorder).outerPen; 0096 QPen rightOuterPen = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen; 0097 0098 if (topOuterPen.widthF() > 0) { 0099 painter.setPen(topOuterPen); 0100 const qreal t = bounds.top() + topOuterPen.widthF() / 2.0; 0101 innerBounds.setTop(bounds.top() + m_cellStyle.getEdge(KoBorder::TopBorder).spacing + topOuterPen.widthF()); 0102 painter.drawLine(QLineF(bounds.left(), t, bounds.right(), t)); 0103 } else if (accumulatedBlankBorders) { 0104 // No border but we'd like to draw one for user convenience when on screen 0105 accumulatedBlankBorders->append(QLineF(bounds.left() + leftOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::LeftBorder).spacing, 0106 bounds.top() + topOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::TopBorder).spacing, 0107 bounds.right() - rightOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::RightBorder).spacing, 0108 bounds.top() + topOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::TopBorder).spacing)); 0109 } 0110 0111 if (bottomOuterPen.widthF() > 0) { 0112 painter.setPen(bottomOuterPen); 0113 const qreal b = bounds.bottom() - bottomOuterPen.widthF() / 2.0; 0114 innerBounds.setBottom(bounds.bottom() - m_cellStyle.getEdge(KoBorder::BottomBorder).spacing - bottomOuterPen.widthF()); 0115 painter.drawLine(QLineF(bounds.left(), b, bounds.right(), b)); 0116 } else if (accumulatedBlankBorders) { 0117 // No border but we'd like to draw one for user convenience when on screen 0118 accumulatedBlankBorders->append(QLineF(bounds.left() + leftOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::LeftBorder).spacing, 0119 bounds.bottom() - bottomOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::BottomBorder).spacing, 0120 bounds.right() - rightOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::RightBorder).spacing, 0121 bounds.bottom() - bottomOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::BottomBorder).spacing)); 0122 } 0123 0124 if (leftOuterPen.widthF() > 0) { 0125 painter.setPen(leftOuterPen); 0126 const qreal l = bounds.left() + leftOuterPen.widthF() / 2.0; 0127 innerBounds.setLeft(bounds.left() + m_cellStyle.getEdge(KoBorder::LeftBorder).spacing + leftOuterPen.widthF()); 0128 painter.drawLine(QLineF(l, bounds.top() + m_cellStyle.getEdge(KoBorder::TopBorder).outerPen.widthF(), l, bounds.bottom() - m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen.widthF())); 0129 } else if (accumulatedBlankBorders) { 0130 // No border but we'd like to draw one for user convenience when on screen 0131 accumulatedBlankBorders->append(QLineF(bounds.left() + leftOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::LeftBorder).spacing, 0132 bounds.top() + topOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::TopBorder).spacing, 0133 bounds.left() + leftOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::LeftBorder).spacing, 0134 bounds.bottom() - bottomOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::BottomBorder).spacing)); 0135 } 0136 0137 if (m_cellStyle.getEdge(KoBorder::RightBorder).outerPen.widthF() > 0) { 0138 painter.setPen(rightOuterPen); 0139 const qreal r = bounds.right() - rightOuterPen.widthF() / 2.0; 0140 innerBounds.setRight(bounds.right() - m_cellStyle.getEdge(KoBorder::RightBorder).spacing - rightOuterPen.widthF()); 0141 painter.drawLine(QLineF(r, bounds.top() + m_cellStyle.getEdge(KoBorder::TopBorder).outerPen.widthF(), r, bounds.bottom() - bottomOuterPen.widthF())); 0142 } else if (accumulatedBlankBorders) { 0143 // No border but we'd like to draw one for user convenience when on screen 0144 accumulatedBlankBorders->append(QLineF(bounds.right() - rightOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::RightBorder).spacing, 0145 bounds.top() + topOuterPen.widthF() + m_cellStyle.getEdge(KoBorder::TopBorder).spacing, 0146 bounds.right() - rightOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::RightBorder).spacing, 0147 bounds.bottom() - bottomOuterPen.widthF() - m_cellStyle.getEdge(KoBorder::BottomBorder).spacing)); 0148 } 0149 0150 paintDiagonalBorders(painter, bounds); 0151 0152 // inner lines 0153 if (m_cellStyle.getEdge(KoBorder::TopBorder).innerPen.widthF() > 0) { 0154 QPen pen = m_cellStyle.getEdge(KoBorder::TopBorder).innerPen; 0155 painter.setPen(pen); 0156 const qreal t = innerBounds.top() + pen.widthF() / 2.0; 0157 painter.drawLine(QLineF(innerBounds.left(), t, innerBounds.right(), t)); 0158 } 0159 if (m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen.widthF() > 0) { 0160 QPen pen = m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen; 0161 painter.setPen(pen); 0162 const qreal b = innerBounds.bottom() - pen.widthF() / 2.0; 0163 painter.drawLine(QLineF(innerBounds.left(), b, innerBounds.right(), b)); 0164 } 0165 if (m_cellStyle.getEdge(KoBorder::LeftBorder).innerPen.widthF() > 0) { 0166 QPen pen = m_cellStyle.getEdge(KoBorder::LeftBorder).innerPen; 0167 painter.setPen(pen); 0168 const qreal l = innerBounds.left() + pen.widthF() / 2.0; 0169 painter.drawLine(QLineF(l, innerBounds.top() + m_cellStyle.getEdge(KoBorder::TopBorder).innerPen.widthF(), l, innerBounds.bottom() - m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen.widthF())); 0170 } 0171 if (m_cellStyle.getEdge(KoBorder::RightBorder).innerPen.widthF() > 0) { 0172 QPen pen = m_cellStyle.getEdge(KoBorder::RightBorder).innerPen; 0173 painter.setPen(pen); 0174 const qreal r = innerBounds.right() - pen.widthF() / 2.0; 0175 painter.drawLine(QLineF(r, innerBounds.top() + m_cellStyle.getEdge(KoBorder::TopBorder).innerPen.widthF(), r, innerBounds.bottom() - m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen.widthF())); 0176 } 0177 } 0178 0179 void KoTextLayoutCellHelper::paintDiagonalBorders(QPainter &painter, const QRectF &bounds) const 0180 { 0181 if (m_cellStyle.getEdge(KoBorder::TlbrBorder).outerPen.widthF() > 0) { 0182 QPen diagonalPen = m_cellStyle.getEdge(KoBorder::TlbrBorder).outerPen; 0183 painter.setPen(diagonalPen); 0184 0185 QPen topPen = m_cellStyle.getEdge(KoBorder::TopBorder).outerPen; 0186 const qreal top = bounds.top() + topPen.widthF() / 2.0; 0187 QPen leftPen = m_cellStyle.getEdge(KoBorder::LeftBorder).outerPen; 0188 const qreal left = bounds.left() + leftPen.widthF() / 2.0; 0189 QPen bottomPen = m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen; 0190 const qreal bottom = bounds.bottom() - bottomPen.widthF() / 2.0; 0191 QPen rightPen = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen; 0192 const qreal right = bounds.right() - rightPen.widthF() / 2.0; 0193 0194 painter.drawLine(QLineF(left, top, right, bottom)); 0195 } 0196 if (m_cellStyle.getEdge(KoBorder::BltrBorder).outerPen.widthF() > 0) { 0197 QPen pen = m_cellStyle.getEdge(KoBorder::BltrBorder).outerPen; 0198 painter.setPen(pen); 0199 0200 QPen topPen = m_cellStyle.getEdge(KoBorder::TopBorder).outerPen; 0201 const qreal top = bounds.top() + topPen.widthF() / 2.0; 0202 QPen leftPen = m_cellStyle.getEdge(KoBorder::LeftBorder).outerPen; 0203 const qreal left = bounds.left() + leftPen.widthF() / 2.0; 0204 QPen bottomPen = m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen; 0205 const qreal bottom = bounds.bottom() - bottomPen.widthF() / 2.0; 0206 QPen rightPen = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen; 0207 const qreal right = bounds.right() - rightPen.widthF() / 2.0; 0208 0209 painter.drawLine(QLineF(left, bottom, right, top)); 0210 } 0211 } 0212 0213 void KoTextLayoutCellHelper::drawTopHorizontalBorder(QPainter &painter, qreal x, qreal y, qreal w, QVector<QLineF> *accumulatedBlankBorders) const 0214 { 0215 qreal t=y; 0216 if (m_cellStyle.getEdge(KoBorder::TopBorder).outerPen.widthF() > 0) { 0217 QPen pen = m_cellStyle.getEdge(KoBorder::TopBorder).outerPen; 0218 0219 painter.setPen(pen); 0220 t += pen.widthF() / 2.0; 0221 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::TopBorder))) { 0222 drawHorizontalWave(m_cellStyle.getBorderStyle(KoBorder::TopBorder), painter,x,w,t); 0223 } else { 0224 painter.drawLine(QLineF(x, t, x+w, t)); 0225 } 0226 t = y + m_cellStyle.getEdge(KoBorder::TopBorder).spacing + pen.widthF(); 0227 } else if (accumulatedBlankBorders) { 0228 // No border but we'd like to draw one for user convenience when on screen 0229 accumulatedBlankBorders->append(QLineF(x, t, x+w, t)); 0230 } 0231 0232 // inner line 0233 if (m_cellStyle.getEdge(KoBorder::TopBorder).innerPen.widthF() > 0) { 0234 QPen pen = m_cellStyle.getEdge(KoBorder::TopBorder).innerPen; 0235 painter.setPen(pen); 0236 t += pen.widthF() / 2.0; 0237 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::TopBorder))) { 0238 drawHorizontalWave(m_cellStyle.getBorderStyle(KoBorder::TopBorder), painter,x,w,t); 0239 } else { 0240 painter.drawLine(QLineF(x, t, x+w, t)); 0241 } 0242 } 0243 } 0244 0245 void KoTextLayoutCellHelper::drawSharedHorizontalBorder(QPainter &painter, const KoTableCellStyle &styleBelow, qreal x, qreal y, qreal w, QVector<QLineF> *accumulatedBlankBorders) const 0246 { 0247 bool paintThis = true; 0248 if (m_cellStyle.getBorderStyle(KoBorder::BottomBorder) == KoBorder::BorderNone) { 0249 if (styleBelow.getBorderStyle(KoBorder::TopBorder) == KoBorder::BorderNone) { 0250 if (accumulatedBlankBorders) { 0251 accumulatedBlankBorders->append(QLineF(x, y, x+w, y)); 0252 } 0253 return; 0254 } 0255 paintThis = false; 0256 } 0257 else { 0258 if (styleBelow.getBorderStyle(KoBorder::TopBorder) != KoBorder::BorderNone) { 0259 qreal thisWidth = m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen.widthF() + m_cellStyle.getEdge(KoBorder::BottomBorder).spacing + m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen.widthF(); 0260 qreal thatWidth = styleBelow.getEdge(KoBorder::TopBorder).outerPen.widthF() + styleBelow.getEdge(KoBorder::TopBorder).spacing 0261 + styleBelow.getEdge(KoBorder::TopBorder).innerPen.widthF(); 0262 paintThis = thisWidth >= thatWidth; 0263 } 0264 } 0265 0266 const KoBorder::BorderData &edge = paintThis ? m_cellStyle.getEdge(KoBorder::BottomBorder) : styleBelow.getEdge(KoBorder::TopBorder); 0267 const KoBorder::BorderStyle borderStyle = paintThis ? m_cellStyle.getBorderStyle(KoBorder::BottomBorder): styleBelow.getBorderStyle(KoBorder::TopBorder); 0268 qreal t=y; 0269 0270 if (edge.outerPen.widthF() > 0) { 0271 QPen pen = edge.outerPen; 0272 const qreal linewidth = pen.widthF(); 0273 0274 painter.setPen(pen); 0275 t += linewidth / 2.0; 0276 if(isSpeciallyDrawn(borderStyle)) { 0277 drawHorizontalWave(borderStyle, painter,x,w,t); 0278 } else { 0279 painter.drawLine(QLineF(x, t, x+w, t)); 0280 } 0281 t = y + edge.spacing + linewidth; 0282 } 0283 // inner line 0284 if (edge.innerPen.widthF() > 0) { 0285 QPen pen = edge.innerPen; 0286 painter.setPen(pen); 0287 t += pen.widthF() / 2.0; 0288 if(isSpeciallyDrawn(borderStyle)) { 0289 drawHorizontalWave(borderStyle, painter,x,w,t); 0290 } else { 0291 painter.drawLine(QLineF(x, t, x+w, t)); 0292 } 0293 } 0294 } 0295 0296 void KoTextLayoutCellHelper::drawBottomHorizontalBorder(QPainter &painter, qreal x, qreal y, qreal w, QVector<QLineF> *accumulatedBlankBorders) const 0297 { 0298 qreal t=y; 0299 if (m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen.widthF() > 0) { 0300 QPen pen = m_cellStyle.getEdge(KoBorder::BottomBorder).outerPen; 0301 0302 painter.setPen(pen); 0303 t += pen.widthF() / 2.0; 0304 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::BottomBorder))) { 0305 drawHorizontalWave(m_cellStyle.getBorderStyle(KoBorder::BottomBorder), painter,x,w,t); 0306 } else { 0307 painter.drawLine(QLineF(x, t, x+w, t)); 0308 } 0309 t = y + m_cellStyle.getEdge(KoBorder::BottomBorder).spacing + pen.widthF(); 0310 } else if (accumulatedBlankBorders) { 0311 // No border but we'd like to draw one for user convenience when on screen 0312 accumulatedBlankBorders->append(QLineF(x, t, x+w, t)); 0313 0314 } 0315 0316 // inner line 0317 if (m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen.widthF() > 0) { 0318 QPen pen = m_cellStyle.getEdge(KoBorder::BottomBorder).innerPen; 0319 painter.setPen(pen); 0320 t += pen.widthF() / 2.0; 0321 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::BottomBorder))) { 0322 drawHorizontalWave(m_cellStyle.getBorderStyle(KoBorder::BottomBorder), painter,x,w,t); 0323 } else { 0324 painter.drawLine(QLineF(x, t, x+w, t)); 0325 } 0326 } 0327 } 0328 0329 void KoTextLayoutCellHelper::drawLeftmostVerticalBorder(QPainter &painter, qreal x, qreal y, qreal h, QVector<QLineF> *accumulatedBlankBorders) const 0330 { 0331 qreal thisWidth = m_cellStyle.getEdge(KoBorder::LeftBorder).outerPen.widthF() + m_cellStyle.getEdge(KoBorder::LeftBorder).spacing + m_cellStyle.getEdge(KoBorder::LeftBorder).innerPen.widthF(); 0332 qreal l = x - thisWidth / 2.0; 0333 0334 if (m_cellStyle.getEdge(KoBorder::LeftBorder).outerPen.widthF() > 0) { 0335 QPen pen = m_cellStyle.getEdge(KoBorder::LeftBorder).outerPen; 0336 0337 painter.setPen(pen); 0338 l += pen.widthF() / 2.0; 0339 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::LeftBorder))) { 0340 drawVerticalWave(m_cellStyle.getBorderStyle(KoBorder::LeftBorder), painter,y,h,l); 0341 } else { 0342 painter.drawLine(QLineF(l, y, l, y+h)); 0343 } 0344 l += m_cellStyle.getEdge(KoBorder::LeftBorder).spacing + pen.widthF() / 2.0; 0345 } else if (accumulatedBlankBorders) { 0346 // No border but we'd like to draw one for user convenience when on screen 0347 accumulatedBlankBorders->append(QLineF(l, y, l, y+h)); 0348 0349 } 0350 0351 // inner line 0352 if (m_cellStyle.getEdge(KoBorder::LeftBorder).innerPen.widthF() > 0) { 0353 QPen pen = m_cellStyle.getEdge(KoBorder::LeftBorder).innerPen; 0354 painter.setPen(pen); 0355 l += pen.widthF() / 2.0; 0356 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::LeftBorder))) { 0357 drawVerticalWave(m_cellStyle.getBorderStyle(KoBorder::LeftBorder), painter,y,h,l); 0358 } else { 0359 painter.drawLine(QLineF(l, y, l, y+h)); 0360 } 0361 } 0362 } 0363 0364 void KoTextLayoutCellHelper::drawSharedVerticalBorder(QPainter &painter, const KoTableCellStyle &styleRight, qreal x, qreal y, qreal h, QVector<QLineF> *accumulatedBlankBorders) const 0365 { 0366 // First determine which style "wins" by comparing total width 0367 qreal thisWidth = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen.widthF() + m_cellStyle.getEdge(KoBorder::RightBorder).spacing + m_cellStyle.getEdge(KoBorder::RightBorder).innerPen.widthF(); 0368 qreal thatWidth = styleRight.getEdge(KoBorder::LeftBorder).outerPen.widthF() + styleRight.getEdge(KoBorder::LeftBorder).spacing 0369 + styleRight.getEdge(KoBorder::LeftBorder).innerPen.widthF(); 0370 0371 qreal l=x; 0372 0373 if(thisWidth >= thatWidth) { 0374 // left style wins 0375 l -= thisWidth / 2.0; 0376 if (m_cellStyle.getEdge(KoBorder::RightBorder).outerPen.widthF() > 0) { 0377 QPen pen = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen; 0378 0379 painter.setPen(pen); 0380 l += pen.widthF() / 2.0; 0381 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::RightBorder))) { 0382 drawVerticalWave(m_cellStyle.getBorderStyle(KoBorder::RightBorder), painter,y,h,l); 0383 } else { 0384 painter.drawLine(QLineF(l, y, l, y+h)); 0385 } 0386 l += m_cellStyle.getEdge(KoBorder::RightBorder).spacing + pen.widthF() / 2.0; 0387 } else if (accumulatedBlankBorders) { 0388 // No border but we'd like to draw one for user convenience when on screen 0389 accumulatedBlankBorders->append(QLineF(l, y, l, y+h)); 0390 0391 } 0392 0393 // inner line 0394 if (m_cellStyle.getEdge(KoBorder::RightBorder).innerPen.widthF() > 0) { 0395 QPen pen = m_cellStyle.getEdge(KoBorder::RightBorder).innerPen; 0396 painter.setPen(pen); 0397 l += pen.widthF() / 2.0; 0398 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::RightBorder))) { 0399 drawVerticalWave(m_cellStyle.getBorderStyle(KoBorder::RightBorder), painter,y,h,l); 0400 } else { 0401 painter.drawLine(QLineF(l, y, l, y+h)); 0402 } 0403 } 0404 } else { 0405 // right style wins 0406 l -= thatWidth/2.0; 0407 if (styleRight.getEdge(KoBorder::LeftBorder).outerPen.widthF() > 0) { 0408 QPen pen = styleRight.getEdge(KoBorder::LeftBorder).outerPen; 0409 0410 painter.setPen(pen); 0411 l += pen.widthF() / 2.0; 0412 if(isSpeciallyDrawn(styleRight.getBorderStyle(KoBorder::LeftBorder))) { 0413 drawVerticalWave(styleRight.getBorderStyle(KoBorder::LeftBorder), painter,y,h,l); 0414 } else { 0415 painter.drawLine(QLineF(l, y, l, y+h)); 0416 } 0417 l += styleRight.getEdge(KoBorder::LeftBorder).spacing + pen.widthF() / 2.0; 0418 } 0419 // inner line 0420 if (styleRight.getEdge(KoBorder::LeftBorder).innerPen.widthF() > 0) { 0421 QPen pen = styleRight.getEdge(KoBorder::LeftBorder).innerPen; 0422 painter.setPen(pen); 0423 l += pen.widthF() / 2.0; 0424 if(isSpeciallyDrawn(styleRight.getBorderStyle(KoBorder::LeftBorder))) { 0425 drawVerticalWave(styleRight.getBorderStyle(KoBorder::LeftBorder), painter,y,h,l); 0426 } else { 0427 painter.drawLine(QLineF(l, y, l, y+h)); 0428 } 0429 } 0430 } 0431 } 0432 0433 void KoTextLayoutCellHelper::drawRightmostVerticalBorder(QPainter &painter, qreal x, qreal y, qreal h, QVector<QLineF> *accumulatedBlankBorders) const 0434 { 0435 qreal thisWidth = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen.widthF() + m_cellStyle.getEdge(KoBorder::RightBorder).spacing + m_cellStyle.getEdge(KoBorder::RightBorder).innerPen.widthF(); 0436 qreal l = x - thisWidth / 2.0; 0437 0438 if (m_cellStyle.getEdge(KoBorder::RightBorder).outerPen.widthF() > 0) { 0439 QPen pen = m_cellStyle.getEdge(KoBorder::RightBorder).outerPen; 0440 0441 painter.setPen(pen); 0442 l += pen.widthF() / 2.0; 0443 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::RightBorder))) { 0444 drawVerticalWave(m_cellStyle.getBorderStyle(KoBorder::RightBorder), painter,y,h,l); 0445 } else { 0446 painter.drawLine(QLineF(l, y, l, y+h)); 0447 } 0448 l += m_cellStyle.getEdge(KoBorder::RightBorder).spacing + pen.widthF() / 2.0; 0449 } else if (accumulatedBlankBorders) { 0450 // No border but we'd like to draw one for user convenience when on screen 0451 accumulatedBlankBorders->append(QLineF(l, y, l, y+h)); 0452 } 0453 0454 // inner line 0455 if (m_cellStyle.getEdge(KoBorder::RightBorder).innerPen.widthF() > 0) { 0456 QPen pen = m_cellStyle.getEdge(KoBorder::RightBorder).innerPen; 0457 painter.setPen(pen); 0458 l += pen.widthF() / 2.0; 0459 if(isSpeciallyDrawn(m_cellStyle.getBorderStyle(KoBorder::RightBorder))) { 0460 drawVerticalWave(m_cellStyle.getBorderStyle(KoBorder::RightBorder), painter,y,h,l); 0461 } else { 0462 painter.drawLine(QLineF(l, y, l, y+h)); 0463 } 0464 } 0465 }