[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/words-table-cell-borders] libs: Get rid of most
From: Pierre Ducroquet <pinaraf () pinaraf ! info>
Date: 2011-07-31 23:56:07
Message-ID: 20110731235607.62451A60C4 () git ! kde ! org
[Download RAW message or body]
Git commit cf2bdda442fa4797cf3cf17e8673c9c77fca618e by Pierre Ducroquet.
Committed on 01/08/2011 at 01:55.
Pushed by ducroquet into branch 'words-table-cell-borders'.
Get rid of most KoTableBorderStyle code, with a few TODO left
M +2 -630 libs/kotext/styles/KoTableBorderStyle.cpp
M +4 -3 libs/kotext/styles/KoTableCellStyle_p.h
M +4 -4 libs/kotext/KoTextEditor.cpp
M +286 -46 libs/kotext/styles/KoTableCellStyle.cpp
A +140 -0 libs/textlayout/KoTextLayoutCellHelper.h [License: LGPL (v2+)]
A +474 -0 libs/textlayout/KoTextLayoutCellHelper.cpp [License: LGPL (v2+)]
M +1 -0 libs/textlayout/CMakeLists.txt
D +0 -45 libs/kotext/styles/KoTableBorderStyle_p.h
M +50 -1 libs/kotext/styles/KoTableCellStyle.h
M +18 -13 libs/textlayout/KoTextLayoutTableArea.cpp
M +12 -12 libs/kotext/opendocument/tests/TestLoading.cpp
M +24 -24 libs/kotext/styles/tests/TestTableCellStyle.cpp
M +9 -150 libs/kotext/styles/KoTableBorderStyle.h
M +12 -12 libs/kotext/KoTextDebug.cpp
http://commits.kde.org/calligra/cf2bdda442fa4797cf3cf17e8673c9c77fca618e
diff --git a/libs/kotext/KoTextDebug.cpp b/libs/kotext/KoTextDebug.cpp
index 3d65b66..45df678 100644
--- a/libs/kotext/KoTextDebug.cpp
+++ b/libs/kotext/KoTextDebug.cpp
@@ -860,7 +860,7 @@ QString KoTextDebug::tableCellAttributes(const \
QTextTableCellFormat &tableCellFo key = "right-padding";
value = QString::number(properties[id].toDouble());
break;
- case KoTableCellStyle::TopBorderOuterPen: {
+ case KoTableBorderStyle::TopBorderOuterPen: {
key = "top-border-outer";
QPen pen = qvariant_cast<QPen>(properties[id]);
if (pen.style() == Qt::NoPen) {
@@ -894,11 +894,11 @@ QString KoTextDebug::tableCellAttributes(const \
QTextTableCellFormat &tableCellFo }
break;
}
- case KoTableCellStyle::TopBorderSpacing:
+ case KoTableBorderStyle::TopBorderSpacing:
key = "top-border-spacing";
value = QString::number(properties[id].toDouble());
break;
- case KoTableCellStyle::TopBorderInnerPen: {
+ case KoTableBorderStyle::TopBorderInnerPen: {
key = "top-border-inner";
QPen pen = qvariant_cast<QPen>(properties[id]);
if (pen.style() == Qt::NoPen) {
@@ -932,7 +932,7 @@ QString KoTextDebug::tableCellAttributes(const \
QTextTableCellFormat &tableCellFo }
break;
}
- case KoTableCellStyle::LeftBorderOuterPen: {
+ case KoTableBorderStyle::LeftBorderOuterPen: {
key = "left-border-outer";
QPen pen = qvariant_cast<QPen>(properties[id]);
if (pen.style() == Qt::NoPen) {
@@ -966,11 +966,11 @@ QString KoTextDebug::tableCellAttributes(const \
QTextTableCellFormat &tableCellFo }
break;
}
- case KoTableCellStyle::LeftBorderSpacing:
+ case KoTableBorderStyle::LeftBorderSpacing:
key = "left-border-spacing";
value = QString::number(properties[id].toDouble());
break;
- case KoTableCellStyle::LeftBorderInnerPen: {
+ case KoTableBorderStyle::LeftBorderInnerPen: {
key = "left-border-inner";
QPen pen = qvariant_cast<QPen>(properties[id]);
if (pen.style() == Qt::NoPen) {
@@ -1004,7 +1004,7 @@ QString KoTextDebug::tableCellAttributes(const \
QTextTableCellFormat &tableCellFo }
break;
}
- case KoTableCellStyle::BottomBorderOuterPen: {
+ case KoTableBorderStyle::BottomBorderOuterPen: {
key = "bottom-border-outer";
QPen pen = qvariant_cast<QPen>(properties[id]);
if (pen.style() == Qt::NoPen) {
@@ -1038,11 +1038,11 @@ QString KoTextDebug::tableCellAttributes(const \
QTextTableCellFormat &tableCellFo }
break;
}
- case KoTableCellStyle::BottomBorderSpacing:
+ case KoTableBorderStyle::BottomBorderSpacing:
key = "bottom-border-spacing";
value = QString::number(properties[id].toDouble());
break;
- case KoTableCellStyle::BottomBorderInnerPen: {
+ case KoTableBorderStyle::BottomBorderInnerPen: {
key = "bottom-border-inner";
QPen pen = qvariant_cast<QPen>(properties[id]);
if (pen.style() == Qt::NoPen) {
@@ -1076,7 +1076,7 @@ QString KoTextDebug::tableCellAttributes(const \
QTextTableCellFormat &tableCellFo }
break;
}
- case KoTableCellStyle::RightBorderOuterPen: {
+ case KoTableBorderStyle::RightBorderOuterPen: {
key = "right-border-outer";
QPen pen = qvariant_cast<QPen>(properties[id]);
if (pen.style() == Qt::NoPen) {
@@ -1110,11 +1110,11 @@ QString KoTextDebug::tableCellAttributes(const \
QTextTableCellFormat &tableCellFo }
break;
}
- case KoTableCellStyle::RightBorderSpacing:
+ case KoTableBorderStyle::RightBorderSpacing:
key = "right-border-spacing";
value = QString::number(properties[id].toDouble());
break;
- case KoTableCellStyle::RightBorderInnerPen: {
+ case KoTableBorderStyle::RightBorderInnerPen: {
key = "right-border-inner";
QPen pen = qvariant_cast<QPen>(properties[id]);
if (pen.style() == Qt::NoPen) {
diff --git a/libs/kotext/KoTextEditor.cpp b/libs/kotext/KoTextEditor.cpp
index 4588b12..2fe72f0 100644
--- a/libs/kotext/KoTextEditor.cpp
+++ b/libs/kotext/KoTextEditor.cpp
@@ -980,10 +980,10 @@ void KoTextEditor::insertTable(int rows, int columns)
QTextTableCell cell = table->cellAt(row, col);
QTextTableCellFormat format;
KoTableCellStyle cellStyle;
- cellStyle.setEdge(KoTableCellStyle::Top, KoBorder::BorderSolid, 2, \
QColor(Qt::black));
- cellStyle.setEdge(KoTableCellStyle::Left, KoBorder::BorderSolid, 2, \
QColor(Qt::black));
- cellStyle.setEdge(KoTableCellStyle::Bottom, KoBorder::BorderSolid, 2, \
QColor(Qt::black));
- cellStyle.setEdge(KoTableCellStyle::Right, KoBorder::BorderSolid, 2, \
QColor(Qt::black)); + cellStyle.setEdge(KoTableBorderStyle::Top, \
KoBorder::BorderSolid, 2, QColor(Qt::black)); + \
cellStyle.setEdge(KoTableBorderStyle::Left, KoBorder::BorderSolid, 2, \
QColor(Qt::black)); + cellStyle.setEdge(KoTableBorderStyle::Bottom, \
KoBorder::BorderSolid, 2, QColor(Qt::black)); + \
cellStyle.setEdge(KoTableBorderStyle::Right, KoBorder::BorderSolid, 2, \
QColor(Qt::black)); cellStyle.setPadding(5);
cellStyle.applyStyle(format);
diff --git a/libs/kotext/opendocument/tests/TestLoading.cpp \
b/libs/kotext/opendocument/tests/TestLoading.cpp index c36deda..222fb81 100644
--- a/libs/kotext/opendocument/tests/TestLoading.cpp
+++ b/libs/kotext/opendocument/tests/TestLoading.cpp
@@ -397,10 +397,10 @@ bool TestLoading::compareTableCellFormats(QTextTableCellFormat \
&actualFormat, QT QString key, value;
switch (id) {
// double properties
- case KoTableCellStyle::LeftBorderSpacing:
- case KoTableCellStyle::RightBorderSpacing:
- case KoTableCellStyle::TopBorderSpacing:
- case KoTableCellStyle::BottomBorderSpacing:
+ case KoTableBorderStyle::LeftBorderSpacing:
+ case KoTableBorderStyle::RightBorderSpacing:
+ case KoTableBorderStyle::TopBorderSpacing:
+ case KoTableBorderStyle::BottomBorderSpacing:
if (abs(actualProperty[id].toDouble() - expectedProperty[id].toDouble()) \
> 1e-10) { qDebug() << "Cell Border Spacing Mismatch";
qDebug() << "Expected Spacing: " << expectedProperty[id].toDouble();
@@ -414,14 +414,14 @@ bool TestLoading::compareTableCellFormats(QTextTableCellFormat \
&actualFormat, QT match = false;
break;
// pen properties
- case KoTableCellStyle::LeftBorderOuterPen:
- case KoTableCellStyle::LeftBorderInnerPen:
- case KoTableCellStyle::RightBorderOuterPen:
- case KoTableCellStyle::RightBorderInnerPen:
- case KoTableCellStyle::TopBorderOuterPen:
- case KoTableCellStyle::TopBorderInnerPen:
- case KoTableCellStyle::BottomBorderOuterPen:
- case KoTableCellStyle::BottomBorderInnerPen: {
+ case KoTableBorderStyle::LeftBorderOuterPen:
+ case KoTableBorderStyle::LeftBorderInnerPen:
+ case KoTableBorderStyle::RightBorderOuterPen:
+ case KoTableBorderStyle::RightBorderInnerPen:
+ case KoTableBorderStyle::TopBorderOuterPen:
+ case KoTableBorderStyle::TopBorderInnerPen:
+ case KoTableBorderStyle::BottomBorderOuterPen:
+ case KoTableBorderStyle::BottomBorderInnerPen: {
QPen actualPen = qvariant_cast<QPen>(actualProperty[id]);
QPen expectedPen = qvariant_cast<QPen>(expectedProperty[id]);
if (actualPen != expectedPen) {
diff --git a/libs/kotext/styles/KoTableBorderStyle.cpp \
b/libs/kotext/styles/KoTableBorderStyle.cpp index 0f6e21f..528a4ab 100644
--- a/libs/kotext/styles/KoTableBorderStyle.cpp
+++ b/libs/kotext/styles/KoTableBorderStyle.cpp
@@ -21,11 +21,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "KoTableBorderStyle.h"
-
-#include "KoTableBorderStyle_p.h"
-
-#include <QPainter>
-
+/*
KoTableBorderStylePrivate::KoTableBorderStylePrivate()
{
edges[KoTableBorderStyle::Top].spacing = 0;
@@ -116,628 +112,4 @@ KoTableBorderStyle::~KoTableBorderStyle()
{
delete d_ptr;
}
-
-
-bool KoTableBorderStyle::isDrawn(KoBorder::BorderStyle style) const
-{
- if (style == KoBorder::BorderWave)
- return true;
- if (style == KoBorder::BorderDoubleWave)
- return true;
- if (style == KoBorder::BorderSlash)
- return true;
- return false;
-}
-
-
-void KoTableBorderStyle::drawHorizontalWave(KoBorder::BorderStyle style, QPainter \
&painter, qreal x, qreal w, qreal t) const
-{
- QPen pen = painter.pen();
- const qreal linewidth = pen.width();
- const qreal penwidth = linewidth/6;
- pen.setWidth(penwidth);
- painter.setPen(pen);
- if (style == KoBorder::BorderSlash) {
- for (qreal sx=x; sx<x+w-linewidth; sx+=linewidth*0.5) {
- painter.drawLine(QLineF(sx, t-penwidth*2, sx+linewidth, t+penwidth*2));
- }
- } else {
- for (qreal sx=x; sx<x+w-2*linewidth; sx+=linewidth) {
- painter.drawLine(QLineF(sx, t-penwidth*2, sx+linewidth, t+penwidth*2));
- sx+=linewidth;
- painter.drawLine(QLineF(sx, t+penwidth*2, sx+linewidth, t-penwidth*2));
- }
- }
-}
-
-
-void KoTableBorderStyle::drawVerticalWave(KoBorder::BorderStyle style, QPainter \
&painter, qreal y, qreal h, qreal t) const
-{
- QPen pen = painter.pen();
- const qreal linewidth = pen.width();
- const qreal penwidth = linewidth/6;
- pen.setWidth(penwidth);
- painter.setPen(pen);
- if (style == KoBorder::BorderSlash) {
- for (qreal sy=y; sy<y+h-linewidth; sy+=linewidth*0.5) {
- painter.drawLine(QLineF(t-penwidth*2, sy, t+penwidth*2, sy+linewidth));
- }
- } else {
- for (qreal sy=y; sy<y+h-2*linewidth; sy+=linewidth) {
- painter.drawLine(QLineF(t-penwidth*2, sy, t+penwidth*2, sy+linewidth));
- sy+=linewidth;
- painter.drawLine(QLineF(t+penwidth*2, sy, t-penwidth*2, sy+linewidth));
- }
- }
-}
-
-void KoTableBorderStyle::setEdge(Side side, KoBorder::BorderStyle style, qreal \
width, QColor color)
-{
- Q_D(KoTableBorderStyle);
-
- KoTableBorderStylePrivate::Edge edge;
- qreal innerWidth = 0;
- qreal middleWidth = 0;
- qreal space = 0;
- switch (style) {
- case KoBorder::BorderNone:
- width = 0.0;
- break;
- case KoBorder::BorderDouble:
- innerWidth = space = width/4; //some nice default look
- width -= (space + innerWidth);
- edge.outerPen.setStyle(Qt::SolidLine);
- break;
- case KoBorder::BorderDotted:
- edge.outerPen.setStyle(Qt::DotLine);
- break;
- case KoBorder::BorderDashed:
- edge.outerPen.setStyle(Qt::DashLine);
- break;
- case KoBorder::BorderDashedLong: {
- QVector<qreal> dashes;
- dashes << 6 << 6;
- edge.outerPen.setDashPattern(dashes);
- break;
- }
- case KoBorder::BorderTriple:
- innerWidth = middleWidth = space = width/6;
- width -= (space + innerWidth);
- edge.outerPen.setStyle(Qt::SolidLine);
- break;
- case KoBorder::BorderDashDot:
- edge.outerPen.setStyle(Qt::DashDotLine);
- break;
- case KoBorder::BorderDashDotDot:
- edge.outerPen.setStyle(Qt::DashDotDotLine);
- break;
- case KoBorder::BorderWave:
- edge.outerPen.setStyle(Qt::SolidLine);
- break;
- case KoBorder::BorderSlash:
- edge.outerPen.setStyle(Qt::SolidLine);
- break;
- case KoBorder::BorderDoubleWave:
- innerWidth = space = width/4; //some nice default look
- width -= (space + innerWidth);
- edge.outerPen.setStyle(Qt::SolidLine);
- break;
- default:
- edge.outerPen.setStyle(Qt::SolidLine);
- break;
- }
- edge.outerPen.setColor(color);
- edge.outerPen.setJoinStyle(Qt::MiterJoin);
- edge.outerPen.setCapStyle(Qt::FlatCap);
- edge.outerPen.setWidthF(width);
-
- edge.spacing = space;
- edge.innerPen = edge.outerPen;
- edge.innerPen.setWidthF(innerWidth);
- QPen middlePen;
- middlePen = edge.outerPen;
- middlePen.setWidthF(middleWidth);
-
- d->edges[side] = edge;
- d->borderstyle[side] = style;
-}
-
-void KoTableBorderStyle::setEdgeDoubleBorderValues(Side side, qreal innerWidth, \
qreal space)
-{
- Q_D(KoTableBorderStyle);
-
- qreal totalWidth = d->edges[side].outerPen.widthF() + d->edges[side].spacing + \
d->edges[side].innerPen.widthF();
- if (d->edges[side].innerPen.widthF() > 0.0) {
- d->edges[side].outerPen.setWidthF(totalWidth - innerWidth - space);
- d->edges[side].spacing = space;
- d->edges[side].innerPen.setWidthF(innerWidth);
- }
-}
-
-bool KoTableBorderStyle::hasBorders() const
-{
- Q_D(const KoTableBorderStyle);
-
- for (int i = Top; i <= BottomLeftToTopRight; i++)
- if (d->edges[i].outerPen.widthF() > 0.0)
- return true;
- return false;
-}
-
-void KoTableBorderStyle::paintBorders(QPainter &painter, const QRectF &bounds, \
QVector<QLineF> *accumulatedBlankBorders) const
-{
- Q_D(const KoTableBorderStyle);
-
- QRectF innerBounds = bounds;
-
- // outer lines
- QPen topOuterPen = d->edges[Top].outerPen;
- QPen bottomOuterPen = d->edges[Bottom].outerPen;
- QPen leftOuterPen = d->edges[Left].outerPen;
- QPen rightOuterPen = d->edges[Right].outerPen;
-
- if (topOuterPen.widthF() > 0) {
- painter.setPen(topOuterPen);
- const qreal t = bounds.top() + topOuterPen.widthF() / 2.0;
- innerBounds.setTop(bounds.top() + d->edges[Top].spacing + \
topOuterPen.widthF());
- painter.drawLine(QLineF(bounds.left(), t, bounds.right(), t));
- } else if (accumulatedBlankBorders) {
- // No border but we'd like to draw one for user convenience when on screen
- accumulatedBlankBorders->append(QLineF(bounds.left() + leftOuterPen.widthF() \
+ d->edges[Left].spacing,
- bounds.top() + topOuterPen.widthF() + \
d->edges[Top].spacing,
- bounds.right() - \
rightOuterPen.widthF() - d->edges[Right].spacing,
- bounds.top() + topOuterPen.widthF() + \
d->edges[Top].spacing));
- }
-
- if (bottomOuterPen.widthF() > 0) {
- painter.setPen(bottomOuterPen);
- const qreal b = bounds.bottom() - bottomOuterPen.widthF() / 2.0;
- innerBounds.setBottom(bounds.bottom() - d->edges[Bottom].spacing - \
bottomOuterPen.widthF());
- painter.drawLine(QLineF(bounds.left(), b, bounds.right(), b));
- } else if (accumulatedBlankBorders) {
- // No border but we'd like to draw one for user convenience when on screen
- accumulatedBlankBorders->append(QLineF(bounds.left() + leftOuterPen.widthF() \
+ d->edges[Left].spacing,
- bounds.bottom() - \
bottomOuterPen.widthF() - d->edges[Bottom].spacing,
- bounds.right() - \
rightOuterPen.widthF() - d->edges[Right].spacing,
- bounds.bottom() - \
bottomOuterPen.widthF() - d->edges[Bottom].spacing));
- }
-
- if (leftOuterPen.widthF() > 0) {
- painter.setPen(leftOuterPen);
- const qreal l = bounds.left() + leftOuterPen.widthF() / 2.0;
- innerBounds.setLeft(bounds.left() + d->edges[Left].spacing + \
leftOuterPen.widthF());
- painter.drawLine(QLineF(l, bounds.top() + d->edges[Top].outerPen.widthF(), \
l, bounds.bottom() - d->edges[Bottom].outerPen.widthF()));
- } else if (accumulatedBlankBorders) {
- // No border but we'd like to draw one for user convenience when on screen
- accumulatedBlankBorders->append(QLineF(bounds.left() + leftOuterPen.widthF() \
+ d->edges[Left].spacing,
- bounds.top() + topOuterPen.widthF() + \
d->edges[Top].spacing,
- bounds.left() + leftOuterPen.widthF() \
+ d->edges[Left].spacing,
- bounds.bottom() - \
bottomOuterPen.widthF() - d->edges[Bottom].spacing));
- }
-
- if (d->edges[Right].outerPen.widthF() > 0) {
- painter.setPen(rightOuterPen);
- const qreal r = bounds.right() - rightOuterPen.widthF() / 2.0;
- innerBounds.setRight(bounds.right() - d->edges[Right].spacing - \
rightOuterPen.widthF());
- painter.drawLine(QLineF(r, bounds.top() + d->edges[Top].outerPen.widthF(), \
r, bounds.bottom() - bottomOuterPen.widthF()));
- } else if (accumulatedBlankBorders) {
- // No border but we'd like to draw one for user convenience when on screen
- accumulatedBlankBorders->append(QLineF(bounds.right() - \
rightOuterPen.widthF() - d->edges[Right].spacing,
- bounds.top() + topOuterPen.widthF() + \
d->edges[Top].spacing,
- bounds.right() - \
rightOuterPen.widthF() - d->edges[Right].spacing,
- bounds.bottom() - \
bottomOuterPen.widthF() - d->edges[Bottom].spacing));
- }
-
- paintDiagonalBorders(painter, bounds);
-
- // inner lines
- if (d->edges[Top].innerPen.widthF() > 0) {
- QPen pen = d->edges[Top].innerPen;
- painter.setPen(pen);
- const qreal t = innerBounds.top() + pen.widthF() / 2.0;
- painter.drawLine(QLineF(innerBounds.left(), t, innerBounds.right(), t));
- }
- if (d->edges[Bottom].innerPen.widthF() > 0) {
- QPen pen = d->edges[Bottom].innerPen;
- painter.setPen(pen);
- const qreal b = innerBounds.bottom() - pen.widthF() / 2.0;
- painter.drawLine(QLineF(innerBounds.left(), b, innerBounds.right(), b));
- }
- if (d->edges[Left].innerPen.widthF() > 0) {
- QPen pen = d->edges[Left].innerPen;
- painter.setPen(pen);
- const qreal l = innerBounds.left() + pen.widthF() / 2.0;
- painter.drawLine(QLineF(l, innerBounds.top() + \
d->edges[Top].innerPen.widthF(), l, innerBounds.bottom() - \
d->edges[Bottom].innerPen.widthF()));
- }
- if (d->edges[Right].innerPen.widthF() > 0) {
- QPen pen = d->edges[Right].innerPen;
- painter.setPen(pen);
- const qreal r = innerBounds.right() - pen.widthF() / 2.0;
- painter.drawLine(QLineF(r, innerBounds.top() + \
d->edges[Top].innerPen.widthF(), r, innerBounds.bottom() - \
d->edges[Bottom].innerPen.widthF()));
- }
-}
-
-void KoTableBorderStyle::paintDiagonalBorders(QPainter &painter, const QRectF \
&bounds) const
-{
- Q_D(const KoTableBorderStyle);
-
- if (d->edges[TopLeftToBottomRight].outerPen.widthF() > 0) {
- QPen diagonalPen = d->edges[TopLeftToBottomRight].outerPen;
- painter.setPen(diagonalPen);
-
- QPen topPen = d->edges[Top].outerPen;
- const qreal top = bounds.top() + topPen.widthF() / 2.0;
- QPen leftPen = d->edges[Left].outerPen;
- const qreal left = bounds.left() + leftPen.widthF() / 2.0;
- QPen bottomPen = d->edges[Bottom].outerPen;
- const qreal bottom = bounds.bottom() - bottomPen.widthF() / 2.0;
- QPen rightPen = d->edges[Right].outerPen;
- const qreal right = bounds.right() - rightPen.widthF() / 2.0;
-
- painter.drawLine(QLineF(left, top, right, bottom));
- }
- if (d->edges[BottomLeftToTopRight].outerPen.widthF() > 0) {
- QPen pen = d->edges[BottomLeftToTopRight].outerPen;
- painter.setPen(pen);
-
- QPen topPen = d->edges[Top].outerPen;
- const qreal top = bounds.top() + topPen.widthF() / 2.0;
- QPen leftPen = d->edges[Left].outerPen;
- const qreal left = bounds.left() + leftPen.widthF() / 2.0;
- QPen bottomPen = d->edges[Bottom].outerPen;
- const qreal bottom = bounds.bottom() - bottomPen.widthF() / 2.0;
- QPen rightPen = d->edges[Right].outerPen;
- const qreal right = bounds.right() - rightPen.widthF() / 2.0;
-
- painter.drawLine(QLineF(left, bottom, right, top));
- }
-}
-
-void KoTableBorderStyle::drawTopHorizontalBorder(QPainter &painter, qreal x, qreal \
y, qreal w, QVector<QLineF> *accumulatedBlankBorders) const
-{
- Q_D(const KoTableBorderStyle);
-
- qreal t=y;
- if (d->edges[Top].outerPen.widthF() > 0) {
- QPen pen = d->edges[Top].outerPen;
-
- painter.setPen(pen);
- t += pen.widthF() / 2.0;
- if(isDrawn(d->borderstyle[Top])) {
- drawHorizontalWave(d->borderstyle[Top], painter,x,w,t);
- } else {
- painter.drawLine(QLineF(x, t, x+w, t));
- }
- t = y + d->edges[Top].spacing + pen.widthF();
- } else if (accumulatedBlankBorders) {
- // No border but we'd like to draw one for user convenience when on screen
- accumulatedBlankBorders->append(QLineF(x, t, x+w, t));
- }
-
- // inner line
- if (d->edges[Top].innerPen.widthF() > 0) {
- QPen pen = d->edges[Top].innerPen;
- painter.setPen(pen);
- t += pen.widthF() / 2.0;
- if(isDrawn(d->borderstyle[Top])) {
- drawHorizontalWave(d->borderstyle[Top], painter,x,w,t);
- } else {
- painter.drawLine(QLineF(x, t, x+w, t));
- }
- }
-}
-
-void KoTableBorderStyle::drawSharedHorizontalBorder(QPainter &painter, const \
KoTableBorderStyle &styleBelow, qreal x, qreal y, qreal w, QVector<QLineF> \
*accumulatedBlankBorders) const
-{
- Q_D(const KoTableBorderStyle);
- const KoTableBorderStylePrivate *styleBelowD = static_cast<const \
KoTableBorderStylePrivate*>(styleBelow.d_func());
-
- bool paintThis = true;
- if (d->borderstyle[Bottom] == KoBorder::BorderNone) {
- if (styleBelowD->borderstyle[Top] == KoBorder::BorderNone) {
- if (accumulatedBlankBorders) {
- accumulatedBlankBorders->append(QLineF(x, y, x+w, y));
- }
- return;
- }
- paintThis = false;
- }
- else {
- if (styleBelowD->borderstyle[Top] != KoBorder::BorderNone) {
- qreal thisWidth = d->edges[Bottom].outerPen.widthF() + \
d->edges[Bottom].spacing + d->edges[Bottom].innerPen.widthF();
- qreal thatWidth = styleBelowD->edges[Top].outerPen.widthF() + \
styleBelowD->edges[Top].spacing
- + styleBelowD->edges[Top].innerPen.widthF();
- paintThis = thisWidth >= thatWidth;
- }
- }
-
- const KoTableBorderStylePrivate::Edge &edge = paintThis ? d->edges[Bottom]: \
styleBelowD->edges[Top];
- const KoBorder::BorderStyle borderStyle = paintThis ? d->borderstyle[Bottom]: \
d->borderstyle[Top];
- qreal t=y;
-
- if (edge.outerPen.widthF() > 0) {
- QPen pen = edge.outerPen;
- const qreal linewidth = pen.widthF();
-
- painter.setPen(pen);
- t += linewidth / 2.0;
- if(isDrawn(borderStyle)) {
- drawHorizontalWave(borderStyle, painter,x,w,t);
- } else {
- painter.drawLine(QLineF(x, t, x+w, t));
- }
- t = y + edge.spacing + linewidth;
- }
- // inner line
- if (edge.innerPen.widthF() > 0) {
- QPen pen = edge.innerPen;
- painter.setPen(pen);
- t += pen.widthF() / 2.0;
- if(isDrawn(borderStyle)) {
- drawHorizontalWave(borderStyle, painter,x,w,t);
- } else {
- painter.drawLine(QLineF(x, t, x+w, t));
- }
- }
-}
-
-void KoTableBorderStyle::drawBottomHorizontalBorder(QPainter &painter, qreal x, \
qreal y, qreal w, QVector<QLineF> *accumulatedBlankBorders) const
-{
- Q_D(const KoTableBorderStyle);
-
- qreal t=y;
- if (d->edges[Bottom].outerPen.widthF() > 0) {
- QPen pen = d->edges[Bottom].outerPen;
-
- painter.setPen(pen);
- t += pen.widthF() / 2.0;
- if(isDrawn(d->borderstyle[Bottom])) {
- drawHorizontalWave(d->borderstyle[Bottom], painter,x,w,t);
- } else {
- painter.drawLine(QLineF(x, t, x+w, t));
- }
- t = y - d->edges[Bottom].spacing - pen.widthF();
- } else if (accumulatedBlankBorders) {
- // No border but we'd like to draw one for user convenience when on screen
- accumulatedBlankBorders->append(QLineF(x, t, x+w, t));
-
- }
-
- // inner line
- if (d->edges[Bottom].innerPen.widthF() > 0) {
- QPen pen = d->edges[Bottom].innerPen;
- painter.setPen(pen);
- t -= pen.widthF() / 2.0;
- if(isDrawn(d->borderstyle[Bottom])) {
- drawHorizontalWave(d->borderstyle[Bottom], painter,x,w,t);
- } else {
- painter.drawLine(QLineF(x, t, x+w, t));
- }
- }
-}
-
-void KoTableBorderStyle::drawLeftmostVerticalBorder(QPainter &painter, qreal x, \
qreal y, qreal h, QVector<QLineF> *accumulatedBlankBorders) const
-{
- Q_D(const KoTableBorderStyle);
-
- qreal thisWidth = d->edges[Left].outerPen.widthF() + d->edges[Left].spacing + \
d->edges[Left].innerPen.widthF();
- qreal l = x - thisWidth / 2.0;
-
- if (d->edges[Left].outerPen.widthF() > 0) {
- QPen pen = d->edges[Left].outerPen;
-
- painter.setPen(pen);
- l += pen.widthF() / 2.0;
- if(isDrawn(d->borderstyle[Left])) {
- drawVerticalWave(d->borderstyle[Left], painter,y,h,l);
- } else {
- painter.drawLine(QLineF(l, y, l, y+h));
- }
- l += d->edges[Left].spacing + pen.widthF() / 2.0;
- } else if (accumulatedBlankBorders) {
- // No border but we'd like to draw one for user convenience when on screen
- accumulatedBlankBorders->append(QLineF(l, y, l, y+h));
-
- }
-
- // inner line
- if (d->edges[Left].innerPen.widthF() > 0) {
- QPen pen = d->edges[Left].innerPen;
- painter.setPen(pen);
- l += pen.widthF() / 2.0;
- if(isDrawn(d->borderstyle[Left])) {
- drawVerticalWave(d->borderstyle[Left], painter,y,h,l);
- } else {
- painter.drawLine(QLineF(l, y, l, y+h));
- }
- }
-}
-
-void KoTableBorderStyle::drawSharedVerticalBorder(QPainter &painter, const \
KoTableBorderStyle &styleRight, qreal x, qreal y, qreal h, QVector<QLineF> \
*accumulatedBlankBorders) const
-{
- Q_D(const KoTableBorderStyle);
- const KoTableBorderStylePrivate *styleRightD = static_cast<const \
KoTableBorderStylePrivate*>(styleRight.d_func());
-
- // First determine which style "wins" by comparing total width
- qreal thisWidth = d->edges[Right].outerPen.widthF() + d->edges[Right].spacing + \
d->edges[Right].innerPen.widthF();
- qreal thatWidth = styleRightD->edges[Left].outerPen.widthF() + \
styleRightD->edges[Left].spacing
- + styleRightD->edges[Left].innerPen.widthF();
-
- qreal l=x;
-
- if(thisWidth >= thatWidth) {
- // left style wins
- l -= thisWidth / 2.0;
- if (d->edges[Right].outerPen.widthF() > 0) {
- QPen pen = d->edges[Right].outerPen;
-
- painter.setPen(pen);
- l += pen.widthF() / 2.0;
- if(isDrawn(d->borderstyle[Right])) {
- drawVerticalWave(d->borderstyle[Right], painter,y,h,l);
- } else {
- painter.drawLine(QLineF(l, y, l, y+h));
- }
- l += d->edges[Right].spacing + pen.widthF() / 2.0;
- } else if (accumulatedBlankBorders) {
- // No border but we'd like to draw one for user convenience when on \
screen
- accumulatedBlankBorders->append(QLineF(l, y, l, y+h));
-
- }
-
- // inner line
- if (d->edges[Right].innerPen.widthF() > 0) {
- QPen pen = d->edges[Right].innerPen;
- painter.setPen(pen);
- l += pen.widthF() / 2.0;
- if(isDrawn(d->borderstyle[Right])) {
- drawVerticalWave(d->borderstyle[Right], painter,y,h,l);
- } else {
- painter.drawLine(QLineF(l, y, l, y+h));
- }
- }
- } else {
- // right style wins
- l -= thatWidth/2.0;
- if (styleRightD->edges[Left].outerPen.widthF() > 0) {
- QPen pen = styleRightD->edges[Left].outerPen;
-
- painter.setPen(pen);
- l += pen.widthF() / 2.0;
- if(isDrawn(d->borderstyle[Left])) {
- drawVerticalWave(d->borderstyle[Left], painter,y,h,l);
- } else {
- painter.drawLine(QLineF(l, y, l, y+h));
- }
- l += styleRightD->edges[Left].spacing + pen.widthF() / 2.0;
- }
- // inner line
- if (styleRightD->edges[Left].innerPen.widthF() > 0) {
- QPen pen = styleRightD->edges[Left].innerPen;
- painter.setPen(pen);
- l += pen.widthF() / 2.0;
- if(isDrawn(d->borderstyle[Left])) {
- drawVerticalWave(d->borderstyle[Left], painter,y,h,l);
- } else {
- painter.drawLine(QLineF(l, y, l, y+h));
- }
- }
- }
-}
-
-void KoTableBorderStyle::drawRightmostVerticalBorder(QPainter &painter, qreal x, \
qreal y, qreal h, QVector<QLineF> *accumulatedBlankBorders) const
-{
- Q_D(const KoTableBorderStyle);
-
- qreal thisWidth = d->edges[Right].outerPen.widthF() + d->edges[Right].spacing + \
d->edges[Right].innerPen.widthF();
- qreal l = x - thisWidth / 2.0;
-
- if (d->edges[Right].outerPen.widthF() > 0) {
- QPen pen = d->edges[Right].outerPen;
-
- painter.setPen(pen);
- l += pen.widthF() / 2.0;
- if(isDrawn(d->borderstyle[Right])) {
- drawVerticalWave(d->borderstyle[Right], painter,y,h,l);
- } else {
- painter.drawLine(QLineF(l, y, l, y+h));
- }
- l += d->edges[Right].spacing - pen.widthF() / 2.0;
- } else if (accumulatedBlankBorders) {
- // No border but we'd like to draw one for user convenience when on screen
- accumulatedBlankBorders->append(QLineF(l, y, l, y+h));
-
- }
-
- // inner line
- if (d->edges[Right].innerPen.widthF() > 0) {
- QPen pen = d->edges[Right].innerPen;
- painter.setPen(pen);
- l += pen.widthF() / 2.0;
- if(isDrawn(d->borderstyle[Right])) {
- drawVerticalWave(d->borderstyle[Right], painter,y,h,l);
- } else {
- painter.drawLine(QLineF(l, y, l, y+h));
- }
- }
-}
-
-qreal KoTableBorderStyle::leftBorderWidth() const
-{
- Q_D(const KoTableBorderStyle);
-
- const KoTableBorderStylePrivate::Edge &edge = d->edges[Left];
- return edge.spacing + edge.innerPen.widthF() + edge.outerPen.widthF();
-}
-
-qreal KoTableBorderStyle::rightBorderWidth() const
-{
- Q_D(const KoTableBorderStyle);
-
- const KoTableBorderStylePrivate::Edge &edge = d->edges[Right];
- return edge.spacing + edge.innerPen.widthF() + edge.outerPen.widthF();
-}
-
-qreal KoTableBorderStyle::topBorderWidth() const
-{
- Q_D(const KoTableBorderStyle);
-
- const KoTableBorderStylePrivate::Edge &edge = d->edges[Top];
- return edge.spacing + edge.innerPen.widthF() + edge.outerPen.widthF();
-}
-
-qreal KoTableBorderStyle::bottomBorderWidth() const
-{
- Q_D(const KoTableBorderStyle);
-
- const KoTableBorderStylePrivate::Edge &edge = d->edges[Bottom];
- return edge.spacing + edge.innerPen.widthF() + edge.outerPen.widthF();
-}
-
-qreal KoTableBorderStyle::leftInnerBorderWidth() const
-{
- Q_D(const KoTableBorderStyle);
- return d->edges[Left].innerPen.widthF();
-}
-
-qreal KoTableBorderStyle::rightInnerBorderWidth() const
-{
- Q_D(const KoTableBorderStyle);
- return d->edges[Right].innerPen.widthF();
-}
-
-qreal KoTableBorderStyle::topInnerBorderWidth() const
-{
- Q_D(const KoTableBorderStyle);
- return d->edges[Top].innerPen.widthF();
-}
-
-qreal KoTableBorderStyle::bottomInnerBorderWidth() const
-{
- Q_D(const KoTableBorderStyle);
- return d->edges[Bottom].innerPen.widthF();
-}
-
-qreal KoTableBorderStyle::leftOuterBorderWidth() const
-{
- Q_D(const KoTableBorderStyle);
- return d->edges[Left].outerPen.widthF();
-}
-
-qreal KoTableBorderStyle::rightOuterBorderWidth() const
-{
- Q_D(const KoTableBorderStyle);
- return d->edges[Right].outerPen.widthF();
-}
-
-qreal KoTableBorderStyle::topOuterBorderWidth() const
-{
- Q_D(const KoTableBorderStyle);
- return d->edges[Top].outerPen.widthF();
-}
-
-qreal KoTableBorderStyle::bottomOuterBorderWidth() const
-{
- Q_D(const KoTableBorderStyle);
- return d->edges[Bottom].outerPen.widthF();
-}
+*/
\ No newline at end of file
diff --git a/libs/kotext/styles/KoTableBorderStyle.h \
b/libs/kotext/styles/KoTableBorderStyle.h index d9cbe79..b8a6512 100644
--- a/libs/kotext/styles/KoTableBorderStyle.h
+++ b/libs/kotext/styles/KoTableBorderStyle.h
@@ -68,161 +68,20 @@ public:
TopLeftToBottomRight, ///< References the border from top, left corner to \
bottom, right corner of cell
BottomLeftToTopRight ///< References the border from bottom, left corner to \
top, right corner of cell };
+
+ struct Edge {
+ Edge() : innerPen(), outerPen(), spacing(0.0) { }
- /// Constructor
- KoTableBorderStyle(QObject *parent = 0);
- /// Creates a KoTableBorderStyle with the given table cell format, and \a parent
- KoTableBorderStyle(const QTextTableCellFormat &tableCellFormat, QObject *parent \
= 0);
- /// Destructor
- ~KoTableBorderStyle();
-
- /// returns if the borderstyle needs to be specially drawn
- bool isDrawn(KoBorder::BorderStyle style) const;
-
- /// draws a horizontal wave line
- void drawHorizontalWave(KoBorder::BorderStyle style, QPainter &painter, qreal x, \
qreal w, qreal t) const;
-
- /// draws a vertical wave line
- void drawVerticalWave(KoBorder::BorderStyle style, QPainter &painter, qreal y, \
qreal h, qreal t) const;
-
- /**
- * Set the properties of an edge.
- *
- * @param side defines which edge this is for.
- * @param style the border style for this side.
- * @param totalWidth the thickness of the border. Sum of outerwidth, spacing and \
innerwidth for double borders
- * @param color the color of the border line(s).
- */
- void setEdge(Side side, KoBorder::BorderStyle style, qreal totalWidth, QColor \
color);
-
- /**
- * Set the properties of a double border.
- * Note: you need to set the edge first or that would overwrite these values.
- *
- * The values will not be set if the border doesn't have a double style
- *
- * @param side defines which edge this is for.
- * @param space the amount of spacing between the outer border and the inner \
border in case of style being double
- * @param innerWidth the thickness of the inner border line in case of style \
being double
- */
- void setEdgeDoubleBorderValues(Side side, qreal innerWidth, qreal space);
-
- /**
- * Check if the border data has any borders.
- *
- * @return true if there has been at least one border set.
- */
- bool hasBorders() const;
-
- /**
- * Paint the borders.
- *
- * @painter the painter to draw with.
- * @bounds the bounding rectangle to draw.
- * @blanks a painterpath where blank borders should be added to.
- */
- void paintBorders(QPainter &painter, const QRectF &bounds, QVector<QLineF> \
*blanks) const;
-
- /**
- * Paint the diagonal borders.
- *
- * @painter the painter to draw with.
- * @bounds the bounding rectangle to draw.
- */
- void paintDiagonalBorders(QPainter &painter, const QRectF &bounds) const;
-
- /**
- * Paint the top border.
- *
- * @painter the painter to draw with.
- * @x the x position.
- * @y the y position.
- * @w the width.
- * @blanks a painterpath where blank borders should be added to.
- */
- void drawTopHorizontalBorder(QPainter &painter, qreal x, qreal y, qreal w, \
QVector<QLineF> *blanks = 0) const;
-
- /**
- * Paint the border that is shared.
- * It only draws the thickest and it always draws it below the y position.
- *
- * @painter the painter to draw with.
- * @x the x position.
- * @y the y position.
- * @w the width.
- * @blanks a painterpath where blank borders should be added to.
- */
- void drawSharedHorizontalBorder(QPainter &painter, const KoTableBorderStyle \
&styleBelow, qreal x, qreal y, qreal w, QVector<QLineF> *blanks = 0) \
const;
-
- /**
- * Paint the bottom border.
- *
- * @painter the painter to draw with.
- * @x the x position.
- * @y the y position.
- * @w the width.
- * @blanks a painterpath where blank borders should be added to.
- */
- void drawBottomHorizontalBorder(QPainter &painter, qreal x, qreal y, qreal w, \
QVector<QLineF> *blanks = 0) const;
-
- /**
- * Paint the leftmost border.
- *
- * @painter the painter to draw with.
- * @x the x position.
- * @y the y position.
- * @h the height.
- * @blanks a painterpath where blank borders should be added to.
- */
- void drawLeftmostVerticalBorder(QPainter &painter, qreal x, qreal y, qreal h, \
QVector<QLineF> *blanks = 0) const;
-
- /**
- * Paint the border that is shared.
- * It only draws the thickest and it always draws it below the y position.
- *
- * @painter the painter to draw with.
- * @x the x position.
- * @y the y position.
- * @h the height.
- * @blanks a painterpath where blank borders should be added to.
- */
- void drawSharedVerticalBorder(QPainter &painter, const KoTableBorderStyle \
&styleRight, qreal x, qreal y, qreal h, QVector<QLineF> *blanks = 0) \
const;
-
- /**
- * Paint the rightmost border.
- *
- * @painter the painter to draw with.
- * @x the x position.
- * @y the y position.
- * @h the height.
- * @blanks a painterpath where blank borders should be added to.
- */
- void drawRightmostVerticalBorder(QPainter &painter, qreal x, qreal y, qreal h, \
QVector<QLineF> *blanks = 0) const;
-
- qreal leftBorderWidth() const;
- qreal rightBorderWidth() const;
- qreal topBorderWidth() const;
- qreal bottomBorderWidth() const;
-
- qreal leftInnerBorderWidth() const;
- qreal rightInnerBorderWidth() const;
- qreal topInnerBorderWidth() const;
- qreal bottomInnerBorderWidth() const;
-
- qreal leftOuterBorderWidth() const;
- qreal rightOuterBorderWidth() const;
- qreal topOuterBorderWidth() const;
- qreal bottomOuterBorderWidth() const;
+ QPen innerPen;
+ QPen outerPen;
+ qreal spacing;
+ };
protected:
- KoTableBorderStyle(KoTableBorderStylePrivate &dd, const QTextTableCellFormat \
&format, QObject *parent);
- KoTableBorderStyle(KoTableBorderStylePrivate &dd, QObject *parent);
- KoTableBorderStylePrivate *d_ptr;
-
private:
- void init(const QTextTableCellFormat &format);
+ //void init(const QTextTableCellFormat &format);
- Q_DECLARE_PRIVATE(KoTableBorderStyle)
+ //Q_DECLARE_PRIVATE(KoTableBorderStyle)
};
#endif // KOTABLEBORDERSTYLE_H
diff --git a/libs/kotext/styles/KoTableBorderStyle_p.h \
b/libs/kotext/styles/KoTableBorderStyle_p.h deleted file mode 100644
index 31d3961..0000000
--- a/libs/kotext/styles/KoTableBorderStyle_p.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* This file is part of the KDE project
- * Copyright (C) 2006-2010 Thomas Zander <zander@kde.org>
- * Copyright (C) 2008,2010 Thorsten Zachmann <zachmann@kde.org>
- * Copyright (C) 2008 Girish Ramakrishnan <girish@forwardbias.in>
- * Copyright (C) 2009 KO GmbH <cbo@kogmbh.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#ifndef KOTABLEBORDERSTYLE_P_H
-#define KOTABLEBORDERSTYLE_P_H
-
-#include "KoTableBorderStyle.h"
-
-class KoTableBorderStylePrivate
-{
-public:
- struct Edge {
- Edge() : innerPen(), outerPen(), spacing(0.0) { }
-
- QPen innerPen;
- QPen outerPen;
- qreal spacing;
- };
-
- KoTableBorderStylePrivate();
- virtual ~KoTableBorderStylePrivate();
-
- Edge edges[6];
- KoBorder::BorderStyle borderstyle[6];
-};
-
-#endif // KOTABLEBORDERSTYLE_P_H
diff --git a/libs/kotext/styles/KoTableCellStyle.cpp \
b/libs/kotext/styles/KoTableCellStyle.cpp index 938f066..7b9f227 100644
--- a/libs/kotext/styles/KoTableCellStyle.cpp
+++ b/libs/kotext/styles/KoTableCellStyle.cpp
@@ -85,14 +85,14 @@ void KoTableCellStylePrivate::setProperty(int key, const QVariant \
&value) }
KoTableCellStyle::KoTableCellStyle(QObject *parent)
- : KoTableBorderStyle(*new KoTableCellStylePrivate(), parent)
+ : QObject(parent)
{
Q_D(KoTableCellStyle);
d->charStyle = new KoCharacterStyle(this);
}
KoTableCellStyle::KoTableCellStyle(const QTextTableCellFormat &format, QObject \
*parent)
- : KoTableBorderStyle(*new KoTableCellStylePrivate(), format, parent)
+ : QObject(parent)
{
Q_D(KoTableCellStyle);
d->stylesPrivate = format.properties();
@@ -113,10 +113,10 @@ QRectF KoTableCellStyle::contentRect(const QRectF \
&boundingRect) const {
Q_D(const KoTableCellStyle);
return boundingRect.adjusted(
- d->edges[Left].outerPen.widthF() + d->edges[Left].spacing + \
d->edges[Left].innerPen.widthF() + \
propertyDouble(QTextFormat::TableCellLeftPadding),
- d->edges[Top].outerPen.widthF() + d->edges[Top].spacing + \
d->edges[Top].innerPen.widthF() + \
propertyDouble(QTextFormat::TableCellTopPadding),
- - d->edges[Right].outerPen.widthF() - d->edges[Right].spacing - \
d->edges[Right].innerPen.widthF() - \
propertyDouble(QTextFormat::TableCellRightPadding),
- - d->edges[Bottom].outerPen.widthF() - d->edges[Bottom].spacing - \
d->edges[Bottom].innerPen.widthF() - \
propertyDouble(QTextFormat::TableCellBottomPadding) + \
d->edges[KoTableBorderStyle::Left].outerPen.widthF() + \
d->edges[KoTableBorderStyle::Left].spacing + \
d->edges[KoTableBorderStyle::Left].innerPen.widthF() + \
propertyDouble(QTextFormat::TableCellLeftPadding), + \
d->edges[KoTableBorderStyle::Top].outerPen.widthF() + \
d->edges[KoTableBorderStyle::Top].spacing + \
d->edges[KoTableBorderStyle::Top].innerPen.widthF() + \
propertyDouble(QTextFormat::TableCellTopPadding), + - \
d->edges[KoTableBorderStyle::Right].outerPen.widthF() - \
d->edges[KoTableBorderStyle::Right].spacing - \
d->edges[KoTableBorderStyle::Right].innerPen.widthF() - \
propertyDouble(QTextFormat::TableCellRightPadding), + - \
d->edges[KoTableBorderStyle::Bottom].outerPen.widthF() - \
d->edges[KoTableBorderStyle::Bottom].spacing - \
d->edges[KoTableBorderStyle::Bottom].innerPen.widthF() - \
propertyDouble(QTextFormat::TableCellBottomPadding) );
}
@@ -124,10 +124,10 @@ QRectF KoTableCellStyle::boundingRect(const QRectF \
&contentRect) const {
Q_D(const KoTableCellStyle);
return contentRect.adjusted(
- - d->edges[Left].outerPen.widthF() - d->edges[Left].spacing - \
d->edges[Left].innerPen.widthF() - \
propertyDouble(QTextFormat::TableCellLeftPadding),
- - d->edges[Top].outerPen.widthF() - d->edges[Top].spacing - \
d->edges[Top].innerPen.widthF() - \
propertyDouble(QTextFormat::TableCellTopPadding),
- d->edges[Right].outerPen.widthF() + d->edges[Right].spacing + \
d->edges[Right].innerPen.widthF() + \
propertyDouble(QTextFormat::TableCellRightPadding),
- d->edges[Bottom].outerPen.widthF() + d->edges[Bottom].spacing + \
d->edges[Bottom].innerPen.widthF() + \
propertyDouble(QTextFormat::TableCellBottomPadding) + - \
d->edges[KoTableBorderStyle::Left].outerPen.widthF() - \
d->edges[KoTableBorderStyle::Left].spacing - \
d->edges[KoTableBorderStyle::Left].innerPen.widthF() - \
propertyDouble(QTextFormat::TableCellLeftPadding), + - \
d->edges[KoTableBorderStyle::Top].outerPen.widthF() - \
d->edges[KoTableBorderStyle::Top].spacing - \
d->edges[KoTableBorderStyle::Top].innerPen.widthF() - \
propertyDouble(QTextFormat::TableCellTopPadding), + \
d->edges[KoTableBorderStyle::Right].outerPen.widthF() + \
d->edges[KoTableBorderStyle::Right].spacing + \
d->edges[KoTableBorderStyle::Right].innerPen.widthF() + \
propertyDouble(QTextFormat::TableCellRightPadding), + \
d->edges[KoTableBorderStyle::Bottom].outerPen.widthF() + \
d->edges[KoTableBorderStyle::Bottom].spacing + \
d->edges[KoTableBorderStyle::Bottom].innerPen.widthF() + \
propertyDouble(QTextFormat::TableCellBottomPadding) );
}
@@ -255,6 +255,14 @@ qreal KoTableCellStyle::propertyDouble(int key) const
return variant.toDouble();
}
+QPen KoTableCellStyle::propertyPen(int key) const
+{
+ const QVariant prop = value(key);
+ if (prop.userType() != QVariant::Pen)
+ return QPen(Qt::NoPen);
+ return qvariant_cast<QPen>(prop);
+}
+
int KoTableCellStyle::propertyInt(int key) const
{
QVariant variant = value(key);
@@ -295,30 +303,30 @@ void KoTableCellStyle::applyStyle(QTextTableCellFormat &format) \
const format.setProperty(keys[i], variant);
}
- format.setProperty(TopBorderOuterPen, d->edges[Top].outerPen);
- format.setProperty(TopBorderSpacing, d->edges[Top].spacing);
- format.setProperty(TopBorderInnerPen, d->edges[Top].innerPen);
- format.setProperty(TopBorderStyle, d->borderstyle[Top]);
- format.setProperty(LeftBorderOuterPen, d->edges[Left].outerPen);
- format.setProperty(LeftBorderSpacing, d->edges[Left].spacing);
- format.setProperty(LeftBorderInnerPen, d->edges[Left].innerPen);
- format.setProperty(LeftBorderStyle, d->borderstyle[Left]);
- format.setProperty(BottomBorderOuterPen, d->edges[Bottom].outerPen);
- format.setProperty(BottomBorderSpacing, d->edges[Bottom].spacing);
- format.setProperty(BottomBorderInnerPen, d->edges[Bottom].innerPen);
- format.setProperty(BottomBorderStyle, d->borderstyle[Bottom]);
- format.setProperty(RightBorderOuterPen, d->edges[Right].outerPen);
- format.setProperty(RightBorderSpacing, d->edges[Right].spacing);
- format.setProperty(RightBorderInnerPen, d->edges[Right].innerPen);
- format.setProperty(RightBorderStyle, d->borderstyle[Right]);
- format.setProperty(TopLeftToBottomRightBorderOuterPen, \
d->edges[TopLeftToBottomRight].outerPen);
- format.setProperty(TopLeftToBottomRightBorderSpacing, \
d->edges[TopLeftToBottomRight].spacing);
- format.setProperty(TopLeftToBottomRightBorderInnerPen, \
d->edges[TopLeftToBottomRight].innerPen);
- format.setProperty(TopLeftToBottomRightBorderStyle, \
d->borderstyle[TopLeftToBottomRight]);
- format.setProperty(BottomLeftToTopRightBorderOuterPen, \
d->edges[BottomLeftToTopRight].outerPen);
- format.setProperty(BottomLeftToTopRightBorderSpacing, \
d->edges[BottomLeftToTopRight].spacing);
- format.setProperty(BottomLeftToTopRightBorderInnerPen, \
d->edges[BottomLeftToTopRight].innerPen);
- format.setProperty(BottomLeftToTopRightBorderStyle, \
d->borderstyle[BottomLeftToTopRight]); + \
format.setProperty(KoTableBorderStyle::TopBorderOuterPen, \
d->edges[KoTableBorderStyle::Top].outerPen); + \
format.setProperty(KoTableBorderStyle::TopBorderSpacing, \
d->edges[KoTableBorderStyle::Top].spacing); + \
format.setProperty(KoTableBorderStyle::TopBorderInnerPen, \
d->edges[KoTableBorderStyle::Top].innerPen); + \
format.setProperty(KoTableBorderStyle::TopBorderStyle, \
d->borderstyle[KoTableBorderStyle::Top]); + \
format.setProperty(KoTableBorderStyle::LeftBorderOuterPen, \
d->edges[KoTableBorderStyle::Left].outerPen); + \
format.setProperty(KoTableBorderStyle::LeftBorderSpacing, \
d->edges[KoTableBorderStyle::Left].spacing); + \
format.setProperty(KoTableBorderStyle::LeftBorderInnerPen, \
d->edges[KoTableBorderStyle::Left].innerPen); + \
format.setProperty(KoTableBorderStyle::LeftBorderStyle, \
d->borderstyle[KoTableBorderStyle::Left]); + \
format.setProperty(KoTableBorderStyle::BottomBorderOuterPen, \
d->edges[KoTableBorderStyle::Bottom].outerPen); + \
format.setProperty(KoTableBorderStyle::BottomBorderSpacing, \
d->edges[KoTableBorderStyle::Bottom].spacing); + \
format.setProperty(KoTableBorderStyle::BottomBorderInnerPen, \
d->edges[KoTableBorderStyle::Bottom].innerPen); + \
format.setProperty(KoTableBorderStyle::BottomBorderStyle, \
d->borderstyle[KoTableBorderStyle::Bottom]); + \
format.setProperty(KoTableBorderStyle::RightBorderOuterPen, \
d->edges[KoTableBorderStyle::Right].outerPen); + \
format.setProperty(KoTableBorderStyle::RightBorderSpacing, \
d->edges[KoTableBorderStyle::Right].spacing); + \
format.setProperty(KoTableBorderStyle::RightBorderInnerPen, \
d->edges[KoTableBorderStyle::Right].innerPen); + \
format.setProperty(KoTableBorderStyle::RightBorderStyle, \
d->borderstyle[KoTableBorderStyle::Right]); + \
format.setProperty(KoTableBorderStyle::TopLeftToBottomRightBorderOuterPen, \
d->edges[KoTableBorderStyle::TopLeftToBottomRight].outerPen); + \
format.setProperty(KoTableBorderStyle::TopLeftToBottomRightBorderSpacing, \
d->edges[KoTableBorderStyle::TopLeftToBottomRight].spacing); + \
format.setProperty(KoTableBorderStyle::TopLeftToBottomRightBorderInnerPen, \
d->edges[KoTableBorderStyle::TopLeftToBottomRight].innerPen); + \
format.setProperty(KoTableBorderStyle::TopLeftToBottomRightBorderStyle, \
d->borderstyle[KoTableBorderStyle::TopLeftToBottomRight]); + \
format.setProperty(KoTableBorderStyle::BottomLeftToTopRightBorderOuterPen, \
d->edges[KoTableBorderStyle::BottomLeftToTopRight].outerPen); + \
format.setProperty(KoTableBorderStyle::BottomLeftToTopRightBorderSpacing, \
d->edges[KoTableBorderStyle::BottomLeftToTopRight].spacing); + \
format.setProperty(KoTableBorderStyle::BottomLeftToTopRightBorderInnerPen, \
d->edges[KoTableBorderStyle::BottomLeftToTopRight].innerPen); + \
format.setProperty(KoTableBorderStyle::BottomLeftToTopRightBorderStyle, \
d->borderstyle[KoTableBorderStyle::BottomLeftToTopRight]); }
void KoTableCellStyle::setBackground(const QBrush &brush)
@@ -596,7 +604,7 @@ void KoTableCellStyle::loadOdfProperties(KoShapeLoadingContext \
&context, KoStyle
style = styleStack.property(KoXmlNS::calligra, "specialborder", "left");
}
if (!border.isEmpty() && border != "none" && border != "hidden") {
- setEdge(Left, KoBorder::odfBorderStyle(style), \
KoUnit::parseValue(border.section(' ', 0, 0), 1.0),QColor(border.section(' ', 2, \
2))); + setEdge(KoTableBorderStyle::Left, KoBorder::odfBorderStyle(style), \
KoUnit::parseValue(border.section(' ', 0, 0), 1.0),QColor(border.section(' ', 2, \
2))); }
}
if (styleStack.hasProperty(KoXmlNS::fo, "border", "top")) {
@@ -606,7 +614,7 @@ void KoTableCellStyle::loadOdfProperties(KoShapeLoadingContext \
&context, KoStyle
style = styleStack.property(KoXmlNS::calligra, "specialborder", "top");
}
if (!border.isEmpty() && border != "none" && border != "hidden") {
- setEdge(Top, KoBorder::odfBorderStyle(style), \
KoUnit::parseValue(border.section(' ', 0, 0), 1.0),QColor(border.section(' ', 2, \
2))); + setEdge(KoTableBorderStyle::Top, KoBorder::odfBorderStyle(style), \
KoUnit::parseValue(border.section(' ', 0, 0), 1.0),QColor(border.section(' ', 2, \
2))); }
}
@@ -617,7 +625,7 @@ void KoTableCellStyle::loadOdfProperties(KoShapeLoadingContext \
&context, KoStyle
style = styleStack.property(KoXmlNS::calligra, "specialborder", \
"right"); }
if (!border.isEmpty() && border != "none" && border != "hidden") {
- setEdge(Right, KoBorder::odfBorderStyle(style), \
KoUnit::parseValue(border.section(' ', 0, 0), 1.0),QColor(border.section(' ', 2, \
2))); + setEdge(KoTableBorderStyle::Right, \
KoBorder::odfBorderStyle(style), KoUnit::parseValue(border.section(' ', 0, 0), \
1.0),QColor(border.section(' ', 2, 2))); }
}
if (styleStack.hasProperty(KoXmlNS::fo, "border", "bottom")) {
@@ -627,7 +635,7 @@ void KoTableCellStyle::loadOdfProperties(KoShapeLoadingContext \
&context, KoStyle
style = styleStack.property(KoXmlNS::calligra, "specialborder", \
"bottom"); }
if (!border.isEmpty() && border != "none" && border != "hidden") {
- setEdge(Bottom, KoBorder::odfBorderStyle(style), \
KoUnit::parseValue(border.section(' ', 0, 0), 1.0),QColor(border.section(' ', 2, \
2))); + setEdge(KoTableBorderStyle::Bottom, \
KoBorder::odfBorderStyle(style), KoUnit::parseValue(border.section(' ', 0, 0), \
1.0),QColor(border.section(' ', 2, 2))); }
}
if (styleStack.hasProperty(KoXmlNS::style, "diagonal-tl-br")) {
@@ -636,7 +644,7 @@ void KoTableCellStyle::loadOdfProperties(KoShapeLoadingContext \
&context, KoStyle
if (styleStack.hasProperty(KoXmlNS::calligra, "specialborder", "tl-br")) {
style = styleStack.property(KoXmlNS::calligra, "specialborder", \
"tl-br"); }
- setEdge(TopLeftToBottomRight, KoBorder::odfBorderStyle(style), \
KoUnit::parseValue(border.section(' ', 0, 0), 1.0),QColor(border.section(' ', 2, \
2))); + setEdge(KoTableBorderStyle::TopLeftToBottomRight, \
KoBorder::odfBorderStyle(style), KoUnit::parseValue(border.section(' ', 0, 0), \
1.0),QColor(border.section(' ', 2, 2))); }
if (styleStack.hasProperty(KoXmlNS::style, "diagonal-bl-tr")) {
QString border = styleStack.property(KoXmlNS::style, "diagonal-bl-tr");
@@ -644,49 +652,49 @@ void KoTableCellStyle::loadOdfProperties(KoShapeLoadingContext \
&context, KoStyle
if (styleStack.hasProperty(KoXmlNS::calligra, "specialborder", "bl-tr")) {
style = styleStack.property(KoXmlNS::calligra, "specialborder", \
"bl-tr"); }
- setEdge(BottomLeftToTopRight, KoBorder::odfBorderStyle(style), \
KoUnit::parseValue(border.section(' ', 0, 0), 1.0),QColor(border.section(' ', 2, \
2))); + setEdge(KoTableBorderStyle::BottomLeftToTopRight, \
KoBorder::odfBorderStyle(style), KoUnit::parseValue(border.section(' ', 0, 0), \
1.0),QColor(border.section(' ', 2, 2))); }
if (styleStack.hasProperty(KoXmlNS::style, "border-line-width", "left")) {
QString borderLineWidth = styleStack.property(KoXmlNS::style, \
"border-line-width", "left");
if (!borderLineWidth.isEmpty() && borderLineWidth != "none" && \
borderLineWidth != "hidden") {
QStringList blw = borderLineWidth.split(' ', QString::SkipEmptyParts);
- setEdgeDoubleBorderValues(Left, KoUnit::parseValue(blw[0], 1.0), \
KoUnit::parseValue(blw[1], 0.1)); + \
setEdgeDoubleBorderValues(KoTableBorderStyle::Left, KoUnit::parseValue(blw[0], 1.0), \
KoUnit::parseValue(blw[1], 0.1)); }
}
if (styleStack.hasProperty(KoXmlNS::style, "border-line-width", "top")) {
QString borderLineWidth = styleStack.property(KoXmlNS::style, \
"border-line-width", "top");
if (!borderLineWidth.isEmpty() && borderLineWidth != "none" && \
borderLineWidth != "hidden") {
QStringList blw = borderLineWidth.split(' ', QString::SkipEmptyParts);
- setEdgeDoubleBorderValues(Top, KoUnit::parseValue(blw[0], 1.0), \
KoUnit::parseValue(blw[1], 0.1)); + \
setEdgeDoubleBorderValues(KoTableBorderStyle::Top, KoUnit::parseValue(blw[0], 1.0), \
KoUnit::parseValue(blw[1], 0.1)); }
}
if (styleStack.hasProperty(KoXmlNS::style, "border-line-width", "right")) {
QString borderLineWidth = styleStack.property(KoXmlNS::style, \
"border-line-width", "right");
if (!borderLineWidth.isEmpty() && borderLineWidth != "none" && \
borderLineWidth != "hidden") {
QStringList blw = borderLineWidth.split(' ', QString::SkipEmptyParts);
- setEdgeDoubleBorderValues(Right, KoUnit::parseValue(blw[0], 1.0), \
KoUnit::parseValue(blw[1], 0.1)); + \
setEdgeDoubleBorderValues(KoTableBorderStyle::Right, KoUnit::parseValue(blw[0], 1.0), \
KoUnit::parseValue(blw[1], 0.1)); }
}
if (styleStack.hasProperty(KoXmlNS::style, "border-line-width", "bottom")) {
QString borderLineWidth = styleStack.property(KoXmlNS::style, \
"border-line-width", "bottom");
if (!borderLineWidth.isEmpty() && borderLineWidth != "none" && \
borderLineWidth != "hidden") {
QStringList blw = borderLineWidth.split(' ', QString::SkipEmptyParts);
- setEdgeDoubleBorderValues(Bottom, KoUnit::parseValue(blw[0], 1.0), \
KoUnit::parseValue(blw[1], 0.1)); + \
setEdgeDoubleBorderValues(KoTableBorderStyle::Bottom, KoUnit::parseValue(blw[0], \
1.0), KoUnit::parseValue(blw[1], 0.1)); }
}
if (styleStack.hasProperty(KoXmlNS::style, "diagonal-tl-br-widths")) {
QString borderLineWidth = styleStack.property(KoXmlNS::style, \
"diagonal-tl-br-widths");
if (!borderLineWidth.isEmpty() && borderLineWidth != "none" && \
borderLineWidth != "hidden") {
QStringList blw = borderLineWidth.split(' ', QString::SkipEmptyParts);
- setEdgeDoubleBorderValues(TopLeftToBottomRight, \
KoUnit::parseValue(blw[0], 1.0), KoUnit::parseValue(blw[1], 0.1)); + \
setEdgeDoubleBorderValues(KoTableBorderStyle::TopLeftToBottomRight, \
KoUnit::parseValue(blw[0], 1.0), KoUnit::parseValue(blw[1], 0.1)); }
}
if (styleStack.hasProperty(KoXmlNS::style, "diagonal-bl-tr-widths")) {
QString borderLineWidth = styleStack.property(KoXmlNS::style, \
"diagonal-bl-tr-widths");
if (!borderLineWidth.isEmpty() && borderLineWidth != "none" && \
borderLineWidth != "hidden") {
QStringList blw = borderLineWidth.split(' ', QString::SkipEmptyParts);
- setEdgeDoubleBorderValues(BottomLeftToTopRight, \
KoUnit::parseValue(blw[0], 1.0), KoUnit::parseValue(blw[1], 0.1)); + \
setEdgeDoubleBorderValues(KoTableBorderStyle::BottomLeftToTopRight, \
KoUnit::parseValue(blw[0], 1.0), KoUnit::parseValue(blw[1], 0.1)); }
}
@@ -1034,4 +1042,236 @@ void KoTableCellStyle::saveOdf(KoGenStyle &style)
*/
}
+void KoTableCellStyle::setEdge(KoTableBorderStyle::Side side, KoBorder::BorderStyle \
style, qreal width, QColor color) +{
+ Q_D(KoTableCellStyle);
+
+ KoTableBorderStyle::Edge edge;
+ qreal innerWidth = 0;
+ qreal middleWidth = 0;
+ qreal space = 0;
+ switch (style) {
+ case KoBorder::BorderNone:
+ width = 0.0;
+ break;
+ case KoBorder::BorderDouble:
+ innerWidth = space = width/4; //some nice default look
+ width -= (space + innerWidth);
+ edge.outerPen.setStyle(Qt::SolidLine);
+ break;
+ case KoBorder::BorderDotted:
+ edge.outerPen.setStyle(Qt::DotLine);
+ break;
+ case KoBorder::BorderDashed:
+ edge.outerPen.setStyle(Qt::DashLine);
+ break;
+ case KoBorder::BorderDashedLong: {
+ QVector<qreal> dashes;
+ dashes << 6 << 6;
+ edge.outerPen.setDashPattern(dashes);
+ break;
+ }
+ case KoBorder::BorderTriple:
+ innerWidth = middleWidth = space = width/6;
+ width -= (space + innerWidth);
+ edge.outerPen.setStyle(Qt::SolidLine);
+ break;
+ case KoBorder::BorderDashDot:
+ edge.outerPen.setStyle(Qt::DashDotLine);
+ break;
+ case KoBorder::BorderDashDotDot:
+ edge.outerPen.setStyle(Qt::DashDotDotLine);
+ break;
+ case KoBorder::BorderWave:
+ edge.outerPen.setStyle(Qt::SolidLine);
+ break;
+ case KoBorder::BorderSlash:
+ edge.outerPen.setStyle(Qt::SolidLine);
+ break;
+ case KoBorder::BorderDoubleWave:
+ innerWidth = space = width/4; //some nice default look
+ width -= (space + innerWidth);
+ edge.outerPen.setStyle(Qt::SolidLine);
+ break;
+ default:
+ edge.outerPen.setStyle(Qt::SolidLine);
+ break;
+ }
+ edge.outerPen.setColor(color);
+ edge.outerPen.setJoinStyle(Qt::MiterJoin);
+ edge.outerPen.setCapStyle(Qt::FlatCap);
+ edge.outerPen.setWidthF(width);
+
+ edge.spacing = space;
+ edge.innerPen = edge.outerPen;
+ edge.innerPen.setWidthF(innerWidth);
+ QPen middlePen;
+ middlePen = edge.outerPen;
+ middlePen.setWidthF(middleWidth);
+
+ d->edges[side] = edge;
+ d->borderstyle[side] = style;
+}
+
+void KoTableCellStyle::setEdgeDoubleBorderValues(KoTableBorderStyle::Side side, \
qreal innerWidth, qreal space) +{
+ Q_D(KoTableCellStyle);
+
+ qreal totalWidth = d->edges[side].outerPen.widthF() + d->edges[side].spacing + \
d->edges[side].innerPen.widthF(); + if (d->edges[side].innerPen.widthF() > 0.0) {
+ d->edges[side].outerPen.setWidthF(totalWidth - innerWidth - space);
+ d->edges[side].spacing = space;
+ d->edges[side].innerPen.setWidthF(innerWidth);
+ }
+}
+
+bool KoTableCellStyle::hasBorders() const
+{
+ Q_D(const KoTableCellStyle);
+
+ for (int i = KoTableBorderStyle::Top; i <= \
KoTableBorderStyle::BottomLeftToTopRight; i++) + if \
(d->edges[i].outerPen.widthF() > 0.0) + return true;
+ return false;
+}
+
+qreal KoTableCellStyle::leftBorderWidth() const
+{
+ Q_D(const KoTableCellStyle);
+
+ const KoTableBorderStyle::Edge &edge = d->edges[KoTableBorderStyle::Left];
+ return edge.spacing + edge.innerPen.widthF() + edge.outerPen.widthF();
+}
+
+qreal KoTableCellStyle::rightBorderWidth() const
+{
+ Q_D(const KoTableCellStyle);
+
+ const KoTableBorderStyle::Edge &edge = d->edges[KoTableBorderStyle::Right];
+ return edge.spacing + edge.innerPen.widthF() + edge.outerPen.widthF();
+}
+
+qreal KoTableCellStyle::topBorderWidth() const
+{
+ Q_D(const KoTableCellStyle);
+
+ const KoTableBorderStyle::Edge &edge = d->edges[KoTableBorderStyle::Top];
+ return edge.spacing + edge.innerPen.widthF() + edge.outerPen.widthF();
+}
+
+qreal KoTableCellStyle::bottomBorderWidth() const
+{
+ Q_D(const KoTableCellStyle);
+
+ const KoTableBorderStyle::Edge &edge = d->edges[KoTableBorderStyle::Bottom];
+ return edge.spacing + edge.innerPen.widthF() + edge.outerPen.widthF();
+}
+
+qreal KoTableCellStyle::leftInnerBorderWidth() const
+{
+ Q_D(const KoTableCellStyle);
+ return d->edges[KoTableBorderStyle::Left].innerPen.widthF();
+}
+
+qreal KoTableCellStyle::rightInnerBorderWidth() const
+{
+ Q_D(const KoTableCellStyle);
+ return d->edges[KoTableBorderStyle::Right].innerPen.widthF();
+}
+
+qreal KoTableCellStyle::topInnerBorderWidth() const
+{
+ Q_D(const KoTableCellStyle);
+ return d->edges[KoTableBorderStyle::Top].innerPen.widthF();
+}
+
+qreal KoTableCellStyle::bottomInnerBorderWidth() const
+{
+ Q_D(const KoTableCellStyle);
+ return d->edges[KoTableBorderStyle::Bottom].innerPen.widthF();
+}
+
+qreal KoTableCellStyle::leftOuterBorderWidth() const
+{
+ Q_D(const KoTableCellStyle);
+ return d->edges[KoTableBorderStyle::Left].outerPen.widthF();
+}
+
+qreal KoTableCellStyle::rightOuterBorderWidth() const
+{
+ Q_D(const KoTableCellStyle);
+ return d->edges[KoTableBorderStyle::Right].outerPen.widthF();
+}
+
+qreal KoTableCellStyle::topOuterBorderWidth() const
+{
+ Q_D(const KoTableCellStyle);
+ return d->edges[KoTableBorderStyle::Top].outerPen.widthF();
+}
+
+qreal KoTableCellStyle::bottomOuterBorderWidth() const
+{
+ Q_D(const KoTableCellStyle);
+ return d->edges[KoTableBorderStyle::Bottom].outerPen.widthF();
+}
+
+KoTableBorderStyle::Edge KoTableCellStyle::getEdge(KoTableBorderStyle::Side side) \
const +{
+ KoTableBorderStyle::Edge result;
+ switch (side)
+ {
+ case KoTableBorderStyle::Top:
+ result.outerPen = propertyPen(KoTableBorderStyle::TopBorderOuterPen);
+ result.spacing = propertyDouble(KoTableBorderStyle::TopBorderSpacing);
+ result.innerPen = propertyPen(KoTableBorderStyle::TopBorderInnerPen);
+ break;
+ case KoTableBorderStyle::Left:
+ result.outerPen = propertyPen(KoTableBorderStyle::LeftBorderOuterPen);
+ result.spacing = propertyDouble(KoTableBorderStyle::LeftBorderSpacing);
+ result.innerPen = propertyPen(KoTableBorderStyle::LeftBorderInnerPen);
+ break;
+ case KoTableBorderStyle::Bottom:
+ result.outerPen = propertyPen(KoTableBorderStyle::BottomBorderOuterPen);
+ result.spacing = \
propertyDouble(KoTableBorderStyle::BottomBorderSpacing); + result.innerPen \
= propertyPen(KoTableBorderStyle::BottomBorderInnerPen); + break;
+ case KoTableBorderStyle::Right:
+ result.outerPen = propertyPen(KoTableBorderStyle::RightBorderOuterPen);
+ result.spacing = propertyDouble(KoTableBorderStyle::RightBorderSpacing);
+ result.innerPen = propertyPen(KoTableBorderStyle::RightBorderInnerPen);
+ break;
+ case KoTableBorderStyle::TopLeftToBottomRight:
+ result.outerPen = \
propertyPen(KoTableBorderStyle::TopLeftToBottomRightBorderOuterPen); + \
result.spacing = propertyDouble(KoTableBorderStyle::TopLeftToBottomRightBorderSpacing);
+ result.innerPen = \
propertyPen(KoTableBorderStyle::TopLeftToBottomRightBorderInnerPen); + \
break; + case KoTableBorderStyle::BottomLeftToTopRight:
+ result.outerPen = \
propertyPen(KoTableBorderStyle::BottomLeftToTopRightBorderOuterPen); + \
result.spacing = propertyDouble(KoTableBorderStyle::BottomLeftToTopRightBorderSpacing);
+ result.innerPen = \
propertyPen(KoTableBorderStyle::BottomLeftToTopRightBorderInnerPen); + \
break; + }
+ return result;
+}
+
+KoBorder::BorderStyle KoTableCellStyle::getBorderStyle(KoTableBorderStyle::Side \
side) const +{
+ switch (side)
+ {
+ case KoTableBorderStyle::Top:
+ return KoBorder::BorderStyle(propertyInt(KoTableBorderStyle::TopBorderStyle));
+ case KoTableBorderStyle::Left:
+ return KoBorder::BorderStyle(propertyInt(KoTableBorderStyle::LeftBorderStyle));
+ case KoTableBorderStyle::Bottom:
+ return KoBorder::BorderStyle(propertyInt(KoTableBorderStyle::BottomBorderStyle));
+ case KoTableBorderStyle::Right:
+ return KoBorder::BorderStyle(propertyInt(KoTableBorderStyle::RightBorderStyle));
+ case KoTableBorderStyle::TopLeftToBottomRight:
+ return KoBorder::BorderStyle(propertyInt(KoTableBorderStyle::TopLeftToBottomRightBorderStyle));
+ case KoTableBorderStyle::BottomLeftToTopRight:
+ return KoBorder::BorderStyle(propertyInt(KoTableBorderStyle::BottomLeftToTopRightBorderStyle));
+ }
+ return KoBorder::BorderNone;
+}
+
#include <KoTableCellStyle.moc>
diff --git a/libs/kotext/styles/KoTableCellStyle.h \
b/libs/kotext/styles/KoTableCellStyle.h index 29fca26..0836c6a 100644
--- a/libs/kotext/styles/KoTableCellStyle.h
+++ b/libs/kotext/styles/KoTableCellStyle.h
@@ -53,7 +53,7 @@ class KoShapeLoadingContext;
* a specific KoTableCellStyle.
* @see KoStyleManager
*/
-class KOTEXT_EXPORT KoTableCellStyle : public KoTableBorderStyle
+class KOTEXT_EXPORT KoTableCellStyle : public QObject
{
Q_OBJECT
public:
@@ -279,7 +279,55 @@ public:
* @returns a QVariant which holds the property value.
*/
QVariant value(int key) const;
+
+
+ /**
+ * Set the properties of an edge.
+ *
+ * @param side defines which edge this is for.
+ * @param style the border style for this side.
+ * @param totalWidth the thickness of the border. Sum of outerwidth, spacing and \
innerwidth for double borders + * @param color the color of the border line(s).
+ */
+ void setEdge(KoTableBorderStyle::Side side, KoBorder::BorderStyle style, qreal \
totalWidth, QColor color); +
+ /**
+ * Set the properties of a double border.
+ * Note: you need to set the edge first or that would overwrite these values.
+ *
+ * The values will not be set if the border doesn't have a double style
+ *
+ * @param side defines which edge this is for.
+ * @param space the amount of spacing between the outer border and the inner \
border in case of style being double + * @param innerWidth the thickness of the \
inner border line in case of style being double + */
+ void setEdgeDoubleBorderValues(KoTableBorderStyle::Side side, qreal innerWidth, \
qreal space); +
+ /**
+ * Check if the border data has any borders.
+ *
+ * @return true if there has been at least one border set.
+ */
+ bool hasBorders() const;
+
+ qreal leftBorderWidth() const;
+ qreal rightBorderWidth() const;
+ qreal topBorderWidth() const;
+ qreal bottomBorderWidth() const;
+
+ qreal leftInnerBorderWidth() const;
+ qreal rightInnerBorderWidth() const;
+ qreal topInnerBorderWidth() const;
+ qreal bottomInnerBorderWidth() const;
+
+ qreal leftOuterBorderWidth() const;
+ qreal rightOuterBorderWidth() const;
+ qreal topOuterBorderWidth() const;
+ qreal bottomOuterBorderWidth() const;
+
+ KoTableBorderStyle::Edge getEdge(KoTableBorderStyle::Side side) const;
+ KoBorder::BorderStyle getBorderStyle(KoTableBorderStyle::Side side) const;
signals:
void nameChanged(const QString &newName);
@@ -290,6 +338,7 @@ private:
*/
void loadOdfProperties(KoShapeLoadingContext &context, KoStyleStack \
&styleStack); qreal propertyDouble(int key) const;
+ QPen propertyPen(int key) const;
int propertyInt(int key) const;
bool propertyBoolean(int key) const;
QColor propertyColor(int key) const;
diff --git a/libs/kotext/styles/KoTableCellStyle_p.h \
b/libs/kotext/styles/KoTableCellStyle_p.h index 3935c81..f716846 100644
--- a/libs/kotext/styles/KoTableCellStyle_p.h
+++ b/libs/kotext/styles/KoTableCellStyle_p.h
@@ -22,9 +22,7 @@
#ifndef KOTABLECELLSTYLE_P_H
#define KOTABLECELLSTYLE_P_H
-#include "KoTableBorderStyle_p.h"
-
-class KoTableCellStylePrivate : public KoTableBorderStylePrivate
+class KoTableCellStylePrivate
{
public:
KoTableCellStylePrivate();
@@ -37,6 +35,9 @@ public:
KoTableCellStyle *parentStyle;
int next;
StylePrivate stylesPrivate;
+
+ KoTableBorderStyle::Edge edges[6];
+ KoBorder::BorderStyle borderstyle[6];
};
#endif // KOTABLECELLSTYLE_P_H
diff --git a/libs/kotext/styles/tests/TestTableCellStyle.cpp \
b/libs/kotext/styles/tests/TestTableCellStyle.cpp index e752e23..9da63aa 100644
--- a/libs/kotext/styles/tests/TestTableCellStyle.cpp
+++ b/libs/kotext/styles/tests/TestTableCellStyle.cpp
@@ -10,28 +10,28 @@ void TestTableCellStyle::testPen()
{
// Test basic functionality of the table cell style (roundtripping to format).
QTextTableCellFormat format1;
- format1.setProperty(KoTableCellStyle::TopBorderOuterPen, QPen(Qt::red, 5.0));
- format1.setProperty(KoTableCellStyle::TopBorderInnerPen, QPen(Qt::red, 7.0));
- format1.setProperty(KoTableCellStyle::LeftBorderOuterPen, QPen(Qt::red, 8.0));
- format1.setProperty(KoTableCellStyle::LeftBorderInnerPen, QPen(Qt::red, 10.0));
- format1.setProperty(KoTableCellStyle::BottomBorderOuterPen, QPen(Qt::red, \
11.0));
- format1.setProperty(KoTableCellStyle::BottomBorderInnerPen, QPen(Qt::red, \
13.0));
- format1.setProperty(KoTableCellStyle::RightBorderOuterPen, QPen(Qt::red, 14.0));
- format1.setProperty(KoTableCellStyle::RightBorderInnerPen, QPen(Qt::red, 16.0));
+ format1.setProperty(KoTableBorderStyle::TopBorderOuterPen, QPen(Qt::red, 5.0));
+ format1.setProperty(KoTableBorderStyle::TopBorderInnerPen, QPen(Qt::red, 7.0));
+ format1.setProperty(KoTableBorderStyle::LeftBorderOuterPen, QPen(Qt::red, 8.0));
+ format1.setProperty(KoTableBorderStyle::LeftBorderInnerPen, QPen(Qt::red, \
10.0)); + format1.setProperty(KoTableBorderStyle::BottomBorderOuterPen, \
QPen(Qt::red, 11.0)); + \
format1.setProperty(KoTableBorderStyle::BottomBorderInnerPen, QPen(Qt::red, 13.0)); + \
format1.setProperty(KoTableBorderStyle::RightBorderOuterPen, QPen(Qt::red, 14.0)); + \
format1.setProperty(KoTableBorderStyle::RightBorderInnerPen, QPen(Qt::red, 16.0));
KoTableCellStyle *style = new KoTableCellStyle(format1);
QVERIFY(style);
QTextTableCellFormat format2;
style->applyStyle(format2);
- QCOMPARE(format2.penProperty(KoTableCellStyle::TopBorderOuterPen), QPen(Qt::red, \
5.0));
- QCOMPARE(format2.penProperty(KoTableCellStyle::TopBorderInnerPen), QPen(Qt::red, \
7.0));
- QCOMPARE(format2.penProperty(KoTableCellStyle::LeftBorderOuterPen), \
QPen(Qt::red, 8.0));
- QCOMPARE(format2.penProperty(KoTableCellStyle::LeftBorderInnerPen), \
QPen(Qt::red, 10.0));
- QCOMPARE(format2.penProperty(KoTableCellStyle::BottomBorderOuterPen), \
QPen(Qt::red, 11.0));
- QCOMPARE(format2.penProperty(KoTableCellStyle::BottomBorderInnerPen), \
QPen(Qt::red, 13.0));
- QCOMPARE(format2.penProperty(KoTableCellStyle::RightBorderOuterPen), \
QPen(Qt::red, 14.0));
- QCOMPARE(format2.penProperty(KoTableCellStyle::RightBorderInnerPen), \
QPen(Qt::red, 16.0)); + \
QCOMPARE(format2.penProperty(KoTableBorderStyle::TopBorderOuterPen), QPen(Qt::red, \
5.0)); + QCOMPARE(format2.penProperty(KoTableBorderStyle::TopBorderInnerPen), \
QPen(Qt::red, 7.0)); + \
QCOMPARE(format2.penProperty(KoTableBorderStyle::LeftBorderOuterPen), QPen(Qt::red, \
8.0)); + QCOMPARE(format2.penProperty(KoTableBorderStyle::LeftBorderInnerPen), \
QPen(Qt::red, 10.0)); + \
QCOMPARE(format2.penProperty(KoTableBorderStyle::BottomBorderOuterPen), QPen(Qt::red, \
11.0)); + QCOMPARE(format2.penProperty(KoTableBorderStyle::BottomBorderInnerPen), \
QPen(Qt::red, 13.0)); + \
QCOMPARE(format2.penProperty(KoTableBorderStyle::RightBorderOuterPen), QPen(Qt::red, \
14.0)); + QCOMPARE(format2.penProperty(KoTableBorderStyle::RightBorderInnerPen), \
QPen(Qt::red, 16.0)); }
void TestTableCellStyle::testPadding()
@@ -62,20 +62,20 @@ void TestTableCellStyle::testSpacing()
{
// Test basic functionality of the table cell style (roundtripping to format).
QTextTableCellFormat format1;
- format1.setProperty(KoTableCellStyle::LeftBorderSpacing, 9.0);
- format1.setProperty(KoTableCellStyle::RightBorderSpacing, 15.0);
- format1.setProperty(KoTableCellStyle::TopBorderSpacing, 6.0);
- format1.setProperty(KoTableCellStyle::BottomBorderSpacing, 12.0);
+ format1.setProperty(KoTableBorderStyle::LeftBorderSpacing, 9.0);
+ format1.setProperty(KoTableBorderStyle::RightBorderSpacing, 15.0);
+ format1.setProperty(KoTableBorderStyle::TopBorderSpacing, 6.0);
+ format1.setProperty(KoTableBorderStyle::BottomBorderSpacing, 12.0);
KoTableCellStyle *style = new KoTableCellStyle(format1);
QVERIFY(style);
QTextTableCellFormat format2;
style->applyStyle(format2);
- QCOMPARE(format2.doubleProperty(KoTableCellStyle::LeftBorderSpacing), 9.0);
- QCOMPARE(format2.doubleProperty(KoTableCellStyle::RightBorderSpacing), 15.0);
- QCOMPARE(format2.doubleProperty(KoTableCellStyle::TopBorderSpacing), 6.0);
- QCOMPARE(format2.doubleProperty(KoTableCellStyle::BottomBorderSpacing), 12.0);
+ QCOMPARE(format2.doubleProperty(KoTableBorderStyle::LeftBorderSpacing), 9.0);
+ QCOMPARE(format2.doubleProperty(KoTableBorderStyle::RightBorderSpacing), 15.0);
+ QCOMPARE(format2.doubleProperty(KoTableBorderStyle::TopBorderSpacing), 6.0);
+ QCOMPARE(format2.doubleProperty(KoTableBorderStyle::BottomBorderSpacing), 12.0);
QRectF rect(0.0, 0.0, 100.0, 100.0);
QCOMPARE(style->contentRect(rect), QRectF(9.0, 6.0, 76.0, 82.0));
diff --git a/libs/textlayout/CMakeLists.txt b/libs/textlayout/CMakeLists.txt
index a364ac5..012c46e 100644
--- a/libs/textlayout/CMakeLists.txt
+++ b/libs/textlayout/CMakeLists.txt
@@ -4,6 +4,7 @@ add_subdirectory( tests )
########### next target ###############
set(textlayout_LIB_SRCS
+ KoTextLayoutCellHelper.cpp
KoTextLayoutArea.cpp
KoTextLayoutArea_paint.cpp
KoTextLayoutEndNotesArea.cpp
diff --git a/libs/textlayout/KoTextLayoutCellHelper.cpp \
b/libs/textlayout/KoTextLayoutCellHelper.cpp new file mode 100644
index 0000000..976ba83
--- /dev/null
+++ b/libs/textlayout/KoTextLayoutCellHelper.cpp
@@ -0,0 +1,474 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2006-2010 Thomas Zander <zander@kde.org>
+ * Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
+ * Copyright (C) 2008 Roopesh Chander <roop@forwardbias.in>
+ * Copyright (C) 2008 Girish Ramakrishnan <girish@forwardbias.in>
+ * Copyright (C) 2009 KO GmbH <cbo@kogmbh.com>
+ * Copyright (C) 2011 Pierre Ducroquet <pinaraf@pinaraf.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "KoTextLayoutCellHelper.h"
+#include <KoTableBorderStyle.h>
+#include <QPainter>
+
+KoTextLayoutCellHelper::KoTextLayoutCellHelper(const KoTableCellStyle &cellStyle, \
QObject *parent) + : QObject(parent), m_cellStyle(cellStyle)
+{
+
+}
+
+bool KoTextLayoutCellHelper::isDrawn(KoBorder::BorderStyle style) const
+{
+ if (style == KoBorder::BorderWave)
+ return true;
+ if (style == KoBorder::BorderDoubleWave)
+ return true;
+ if (style == KoBorder::BorderSlash)
+ return true;
+ return false;
+}
+
+void KoTextLayoutCellHelper::drawHorizontalWave(KoBorder::BorderStyle style, \
QPainter &painter, qreal x, qreal w, qreal t) const +{
+ QPen pen = painter.pen();
+ const qreal linewidth = pen.width();
+ const qreal penwidth = linewidth/6;
+ pen.setWidth(penwidth);
+ painter.setPen(pen);
+ if (style == KoBorder::BorderSlash) {
+ for (qreal sx=x; sx<x+w-linewidth; sx+=linewidth*0.5) {
+ painter.drawLine(QLineF(sx, t-penwidth*2, sx+linewidth, t+penwidth*2));
+ }
+ } else {
+ for (qreal sx=x; sx<x+w-2*linewidth; sx+=linewidth) {
+ painter.drawLine(QLineF(sx, t-penwidth*2, sx+linewidth, t+penwidth*2));
+ sx+=linewidth;
+ painter.drawLine(QLineF(sx, t+penwidth*2, sx+linewidth, t-penwidth*2));
+ }
+ }
+}
+
+void KoTextLayoutCellHelper::drawVerticalWave(KoBorder::BorderStyle style, QPainter \
&painter, qreal y, qreal h, qreal t) const +{
+ QPen pen = painter.pen();
+ const qreal linewidth = pen.width();
+ const qreal penwidth = linewidth/6;
+ pen.setWidth(penwidth);
+ painter.setPen(pen);
+ if (style == KoBorder::BorderSlash) {
+ for (qreal sy=y; sy<y+h-linewidth; sy+=linewidth*0.5) {
+ painter.drawLine(QLineF(t-penwidth*2, sy, t+penwidth*2, sy+linewidth));
+ }
+ } else {
+ for (qreal sy=y; sy<y+h-2*linewidth; sy+=linewidth) {
+ painter.drawLine(QLineF(t-penwidth*2, sy, t+penwidth*2, sy+linewidth));
+ sy+=linewidth;
+ painter.drawLine(QLineF(t+penwidth*2, sy, t-penwidth*2, sy+linewidth));
+ }
+ }
+}
+
+
+void KoTextLayoutCellHelper::paintBorders(QPainter &painter, const QRectF &bounds, \
QVector<QLineF> *accumulatedBlankBorders) const +{
+ QRectF innerBounds = bounds;
+
+ // outer lines
+ QPen topOuterPen = m_cellStyle.getEdge(KoTableBorderStyle::Top).outerPen;
+ QPen bottomOuterPen = m_cellStyle.getEdge(KoTableBorderStyle::Bottom).outerPen;
+ QPen leftOuterPen = m_cellStyle.getEdge(KoTableBorderStyle::Left).outerPen;
+ QPen rightOuterPen = m_cellStyle.getEdge(KoTableBorderStyle::Right).outerPen;
+
+ if (topOuterPen.widthF() > 0) {
+ painter.setPen(topOuterPen);
+ const qreal t = bounds.top() + topOuterPen.widthF() / 2.0;
+ innerBounds.setTop(bounds.top() + \
m_cellStyle.getEdge(KoTableBorderStyle::Top).spacing + topOuterPen.widthF()); + \
painter.drawLine(QLineF(bounds.left(), t, bounds.right(), t)); + } else if \
(accumulatedBlankBorders) { + // No border but we'd like to draw one for user \
convenience when on screen + \
accumulatedBlankBorders->append(QLineF(bounds.left() + leftOuterPen.widthF() + \
m_cellStyle.getEdge(KoTableBorderStyle::Left).spacing, + \
bounds.top() + topOuterPen.widthF() + \
m_cellStyle.getEdge(KoTableBorderStyle::Top).spacing, + \
bounds.right() - rightOuterPen.widthF() - \
m_cellStyle.getEdge(KoTableBorderStyle::Right).spacing, + \
bounds.top() + topOuterPen.widthF() + \
m_cellStyle.getEdge(KoTableBorderStyle::Top).spacing)); + }
+
+ if (bottomOuterPen.widthF() > 0) {
+ painter.setPen(bottomOuterPen);
+ const qreal b = bounds.bottom() - bottomOuterPen.widthF() / 2.0;
+ innerBounds.setBottom(bounds.bottom() - \
m_cellStyle.getEdge(KoTableBorderStyle::Bottom).spacing - bottomOuterPen.widthF()); + \
painter.drawLine(QLineF(bounds.left(), b, bounds.right(), b)); + } else if \
(accumulatedBlankBorders) { + // No border but we'd like to draw one for user \
convenience when on screen + \
accumulatedBlankBorders->append(QLineF(bounds.left() + leftOuterPen.widthF() + \
m_cellStyle.getEdge(KoTableBorderStyle::Left).spacing, + \
bounds.bottom() - bottomOuterPen.widthF() - \
m_cellStyle.getEdge(KoTableBorderStyle::Bottom).spacing, + \
bounds.right() - rightOuterPen.widthF() - \
m_cellStyle.getEdge(KoTableBorderStyle::Right).spacing, + \
bounds.bottom() - bottomOuterPen.widthF() - \
m_cellStyle.getEdge(KoTableBorderStyle::Bottom).spacing)); + }
+
+ if (leftOuterPen.widthF() > 0) {
+ painter.setPen(leftOuterPen);
+ const qreal l = bounds.left() + leftOuterPen.widthF() / 2.0;
+ innerBounds.setLeft(bounds.left() + \
m_cellStyle.getEdge(KoTableBorderStyle::Left).spacing + leftOuterPen.widthF()); + \
painter.drawLine(QLineF(l, bounds.top() + \
m_cellStyle.getEdge(KoTableBorderStyle::Top).outerPen.widthF(), l, bounds.bottom() - \
m_cellStyle.getEdge(KoTableBorderStyle::Bottom).outerPen.widthF())); + } else if \
(accumulatedBlankBorders) { + // No border but we'd like to draw one for user \
convenience when on screen + \
accumulatedBlankBorders->append(QLineF(bounds.left() + leftOuterPen.widthF() + \
m_cellStyle.getEdge(KoTableBorderStyle::Left).spacing, + \
bounds.top() + topOuterPen.widthF() + \
m_cellStyle.getEdge(KoTableBorderStyle::Top).spacing, + \
bounds.left() + leftOuterPen.widthF() + \
m_cellStyle.getEdge(KoTableBorderStyle::Left).spacing, + \
bounds.bottom() - bottomOuterPen.widthF() - \
m_cellStyle.getEdge(KoTableBorderStyle::Bottom).spacing)); + }
+
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Right).outerPen.widthF() > 0) {
+ painter.setPen(rightOuterPen);
+ const qreal r = bounds.right() - rightOuterPen.widthF() / 2.0;
+ innerBounds.setRight(bounds.right() - \
m_cellStyle.getEdge(KoTableBorderStyle::Right).spacing - rightOuterPen.widthF()); + \
painter.drawLine(QLineF(r, bounds.top() + \
m_cellStyle.getEdge(KoTableBorderStyle::Top).outerPen.widthF(), r, bounds.bottom() - \
bottomOuterPen.widthF())); + } else if (accumulatedBlankBorders) {
+ // No border but we'd like to draw one for user convenience when on screen
+ accumulatedBlankBorders->append(QLineF(bounds.right() - \
rightOuterPen.widthF() - m_cellStyle.getEdge(KoTableBorderStyle::Right).spacing, + \
bounds.top() + topOuterPen.widthF() + \
m_cellStyle.getEdge(KoTableBorderStyle::Top).spacing, + \
bounds.right() - rightOuterPen.widthF() - \
m_cellStyle.getEdge(KoTableBorderStyle::Right).spacing, + \
bounds.bottom() - bottomOuterPen.widthF() - \
m_cellStyle.getEdge(KoTableBorderStyle::Bottom).spacing)); + }
+
+ paintDiagonalBorders(painter, bounds);
+
+ // inner lines
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Top).innerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Top).innerPen;
+ painter.setPen(pen);
+ const qreal t = innerBounds.top() + pen.widthF() / 2.0;
+ painter.drawLine(QLineF(innerBounds.left(), t, innerBounds.right(), t));
+ }
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Bottom).innerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Bottom).innerPen;
+ painter.setPen(pen);
+ const qreal b = innerBounds.bottom() - pen.widthF() / 2.0;
+ painter.drawLine(QLineF(innerBounds.left(), b, innerBounds.right(), b));
+ }
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Left).innerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Left).innerPen;
+ painter.setPen(pen);
+ const qreal l = innerBounds.left() + pen.widthF() / 2.0;
+ painter.drawLine(QLineF(l, innerBounds.top() + \
m_cellStyle.getEdge(KoTableBorderStyle::Top).innerPen.widthF(), l, \
innerBounds.bottom() - \
m_cellStyle.getEdge(KoTableBorderStyle::Bottom).innerPen.widthF())); + }
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Right).innerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Right).innerPen;
+ painter.setPen(pen);
+ const qreal r = innerBounds.right() - pen.widthF() / 2.0;
+ painter.drawLine(QLineF(r, innerBounds.top() + \
m_cellStyle.getEdge(KoTableBorderStyle::Top).innerPen.widthF(), r, \
innerBounds.bottom() - \
m_cellStyle.getEdge(KoTableBorderStyle::Bottom).innerPen.widthF())); + }
+}
+
+void KoTextLayoutCellHelper::paintDiagonalBorders(QPainter &painter, const QRectF \
&bounds) const +{
+ if (m_cellStyle.getEdge(KoTableBorderStyle::TopLeftToBottomRight).outerPen.widthF() \
> 0) { + QPen diagonalPen = \
> m_cellStyle.getEdge(KoTableBorderStyle::TopLeftToBottomRight).outerPen;
+ painter.setPen(diagonalPen);
+
+ QPen topPen = m_cellStyle.getEdge(KoTableBorderStyle::Top).outerPen;
+ const qreal top = bounds.top() + topPen.widthF() / 2.0;
+ QPen leftPen = m_cellStyle.getEdge(KoTableBorderStyle::Left).outerPen;
+ const qreal left = bounds.left() + leftPen.widthF() / 2.0;
+ QPen bottomPen = m_cellStyle.getEdge(KoTableBorderStyle::Bottom).outerPen;
+ const qreal bottom = bounds.bottom() - bottomPen.widthF() / 2.0;
+ QPen rightPen = m_cellStyle.getEdge(KoTableBorderStyle::Right).outerPen;
+ const qreal right = bounds.right() - rightPen.widthF() / 2.0;
+
+ painter.drawLine(QLineF(left, top, right, bottom));
+ }
+ if (m_cellStyle.getEdge(KoTableBorderStyle::BottomLeftToTopRight).outerPen.widthF() \
> 0) { + QPen pen = \
> m_cellStyle.getEdge(KoTableBorderStyle::BottomLeftToTopRight).outerPen;
+ painter.setPen(pen);
+
+ QPen topPen = m_cellStyle.getEdge(KoTableBorderStyle::Top).outerPen;
+ const qreal top = bounds.top() + topPen.widthF() / 2.0;
+ QPen leftPen = m_cellStyle.getEdge(KoTableBorderStyle::Left).outerPen;
+ const qreal left = bounds.left() + leftPen.widthF() / 2.0;
+ QPen bottomPen = m_cellStyle.getEdge(KoTableBorderStyle::Bottom).outerPen;
+ const qreal bottom = bounds.bottom() - bottomPen.widthF() / 2.0;
+ QPen rightPen = m_cellStyle.getEdge(KoTableBorderStyle::Right).outerPen;
+ const qreal right = bounds.right() - rightPen.widthF() / 2.0;
+
+ painter.drawLine(QLineF(left, bottom, right, top));
+ }
+}
+
+void KoTextLayoutCellHelper::drawTopHorizontalBorder(QPainter &painter, qreal x, \
qreal y, qreal w, QVector<QLineF> *accumulatedBlankBorders) const +{
+ qreal t=y;
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Top).outerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Top).outerPen;
+
+ painter.setPen(pen);
+ t += pen.widthF() / 2.0;
+ if(isDrawn(m_cellStyle.getBorderStyle(KoTableBorderStyle::Top))) {
+ drawHorizontalWave(m_cellStyle.getBorderStyle(KoTableBorderStyle::Top), \
painter,x,w,t); + } else {
+ painter.drawLine(QLineF(x, t, x+w, t));
+ }
+ t = y + m_cellStyle.getEdge(KoTableBorderStyle::Top).spacing + pen.widthF();
+ } else if (accumulatedBlankBorders) {
+ // No border but we'd like to draw one for user convenience when on screen
+ accumulatedBlankBorders->append(QLineF(x, t, x+w, t));
+ }
+
+ // inner line
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Top).innerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Top).innerPen;
+ painter.setPen(pen);
+ t += pen.widthF() / 2.0;
+ if(isDrawn(m_cellStyle.getBorderStyle(KoTableBorderStyle::Top))) {
+ drawHorizontalWave(m_cellStyle.getBorderStyle(KoTableBorderStyle::Top), \
painter,x,w,t); + } else {
+ painter.drawLine(QLineF(x, t, x+w, t));
+ }
+ }
+}
+
+void KoTextLayoutCellHelper::drawSharedHorizontalBorder(QPainter &painter, const \
KoTableCellStyle &styleBelow, qreal x, qreal y, qreal w, QVector<QLineF> \
*accumulatedBlankBorders) const +{
+ Q_ASSERT(false);
+#if 0
+ const KoTableBorderStylePrivate *styleBelowD = static_cast<const \
KoTableBorderStylePrivate*>(styleBelow.d_func()); +
+ bool paintThis = true;
+ if (m_cellStyle.getBorderStyle(KoTableBorderStyle::Bottom) == \
KoBorder::BorderNone) { + if \
(styleBelowD->borderstyle[KoTableBorderStyle::Top] == KoBorder::BorderNone) { + \
if (accumulatedBlankBorders) { + \
accumulatedBlankBorders->append(QLineF(x, y, x+w, y)); + }
+ return;
+ }
+ paintThis = false;
+ }
+ else {
+ if (styleBelowD->borderstyle[KoTableBorderStyle::Top] != \
KoBorder::BorderNone) { + qreal thisWidth = \
m_cellStyle.getEdge(KoTableBorderStyle::Bottom).outerPen.widthF() + \
m_cellStyle.getEdge(KoTableBorderStyle::Bottom).spacing + \
m_cellStyle.getEdge(KoTableBorderStyle::Bottom).innerPen.widthF(); + qreal \
thatWidth = styleBelowD->edges[KoTableBorderStyle::Top].outerPen.widthF() + \
styleBelowD->edges[KoTableBorderStyle::Top].spacing + + \
styleBelowD->edges[KoTableBorderStyle::Top].innerPen.widthF(); + paintThis \
= thisWidth >= thatWidth; + }
+ }
+
+ const KoTableBorderStyle::Edge &edge = paintThis ? \
m_cellStyle.getEdge(KoTableBorderStyle::Bottom): \
styleBelowD->edges[KoTableBorderStyle::Top]; + const KoBorder::BorderStyle \
borderStyle = paintThis ? m_cellStyle.getBorderStyle(KoTableBorderStyle::Bottom): \
m_cellStyle.getBorderStyle(KoTableBorderStyle::Top); + qreal t=y;
+
+ if (edge.outerPen.widthF() > 0) {
+ QPen pen = edge.outerPen;
+ const qreal linewidth = pen.widthF();
+
+ painter.setPen(pen);
+ t += linewidth / 2.0;
+ if(isDrawn(borderStyle)) {
+ drawHorizontalWave(borderStyle, painter,x,w,t);
+ } else {
+ painter.drawLine(QLineF(x, t, x+w, t));
+ }
+ t = y + edge.spacing + linewidth;
+ }
+ // inner line
+ if (edge.innerPen.widthF() > 0) {
+ QPen pen = edge.innerPen;
+ painter.setPen(pen);
+ t += pen.widthF() / 2.0;
+ if(isDrawn(borderStyle)) {
+ drawHorizontalWave(borderStyle, painter,x,w,t);
+ } else {
+ painter.drawLine(QLineF(x, t, x+w, t));
+ }
+ }
+#endif
+}
+
+void KoTextLayoutCellHelper::drawBottomHorizontalBorder(QPainter &painter, qreal x, \
qreal y, qreal w, QVector<QLineF> *accumulatedBlankBorders) const +{
+ qreal t=y;
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Bottom).outerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Bottom).outerPen;
+
+ painter.setPen(pen);
+ t += pen.widthF() / 2.0;
+ if(isDrawn(m_cellStyle.getBorderStyle(KoTableBorderStyle::Bottom))) {
+ drawHorizontalWave(m_cellStyle.getBorderStyle(KoTableBorderStyle::Bottom), \
painter,x,w,t); + } else {
+ painter.drawLine(QLineF(x, t, x+w, t));
+ }
+ t = y - m_cellStyle.getEdge(KoTableBorderStyle::Bottom).spacing - \
pen.widthF(); + } else if (accumulatedBlankBorders) {
+ // No border but we'd like to draw one for user convenience when on screen
+ accumulatedBlankBorders->append(QLineF(x, t, x+w, t));
+
+ }
+
+ // inner line
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Bottom).innerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Bottom).innerPen;
+ painter.setPen(pen);
+ t -= pen.widthF() / 2.0;
+ if(isDrawn(m_cellStyle.getBorderStyle(KoTableBorderStyle::Bottom))) {
+ drawHorizontalWave(m_cellStyle.getBorderStyle(KoTableBorderStyle::Bottom), \
painter,x,w,t); + } else {
+ painter.drawLine(QLineF(x, t, x+w, t));
+ }
+ }
+}
+
+void KoTextLayoutCellHelper::drawLeftmostVerticalBorder(QPainter &painter, qreal x, \
qreal y, qreal h, QVector<QLineF> *accumulatedBlankBorders) const +{
+ qreal thisWidth = \
m_cellStyle.getEdge(KoTableBorderStyle::Left).outerPen.widthF() + \
m_cellStyle.getEdge(KoTableBorderStyle::Left).spacing + \
m_cellStyle.getEdge(KoTableBorderStyle::Left).innerPen.widthF(); + qreal l = x - \
thisWidth / 2.0; +
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Left).outerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Left).outerPen;
+
+ painter.setPen(pen);
+ l += pen.widthF() / 2.0;
+ if(isDrawn(m_cellStyle.getBorderStyle(KoTableBorderStyle::Left))) {
+ drawVerticalWave(m_cellStyle.getBorderStyle(KoTableBorderStyle::Left), \
painter,y,h,l); + } else {
+ painter.drawLine(QLineF(l, y, l, y+h));
+ }
+ l += m_cellStyle.getEdge(KoTableBorderStyle::Left).spacing + pen.widthF() / \
2.0; + } else if (accumulatedBlankBorders) {
+ // No border but we'd like to draw one for user convenience when on screen
+ accumulatedBlankBorders->append(QLineF(l, y, l, y+h));
+
+ }
+
+ // inner line
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Left).innerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Left).innerPen;
+ painter.setPen(pen);
+ l += pen.widthF() / 2.0;
+ if(isDrawn(m_cellStyle.getBorderStyle(KoTableBorderStyle::Left))) {
+ drawVerticalWave(m_cellStyle.getBorderStyle(KoTableBorderStyle::Left), \
painter,y,h,l); + } else {
+ painter.drawLine(QLineF(l, y, l, y+h));
+ }
+ }
+}
+
+void KoTextLayoutCellHelper::drawSharedVerticalBorder(QPainter &painter, const \
KoTableCellStyle &styleRight, qreal x, qreal y, qreal h, QVector<QLineF> \
*accumulatedBlankBorders) const +{
+ Q_ASSERT(false);
+#if 0
+ const KoTableBorderStylePrivate *styleRightD = static_cast<const \
KoTableBorderStylePrivate*>(styleRight.d_func()); +
+ // First determine which style "wins" by comparing total width
+ qreal thisWidth = \
m_cellStyle.getEdge(KoTableBorderStyle::Right).outerPen.widthF() + \
m_cellStyle.getEdge(KoTableBorderStyle::Right).spacing + \
m_cellStyle.getEdge(KoTableBorderStyle::Right).innerPen.widthF(); + qreal \
thatWidth = styleRightD->edges[KoTableBorderStyle::Left].outerPen.widthF() + \
styleRightD->edges[KoTableBorderStyle::Left].spacing + \
+ styleRightD->edges[KoTableBorderStyle::Left].innerPen.widthF(); +
+ qreal l=x;
+
+ if(thisWidth >= thatWidth) {
+ // left style wins
+ l -= thisWidth / 2.0;
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Right).outerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Right).outerPen;
+
+ painter.setPen(pen);
+ l += pen.widthF() / 2.0;
+ if(isDrawn(m_cellStyle.getBorderStyle(KoTableBorderStyle::Right))) {
+ drawVerticalWave(m_cellStyle.getBorderStyle(KoTableBorderStyle::Right), \
painter,y,h,l); + } else {
+ painter.drawLine(QLineF(l, y, l, y+h));
+ }
+ l += m_cellStyle.getEdge(KoTableBorderStyle::Right).spacing + \
pen.widthF() / 2.0; + } else if (accumulatedBlankBorders) {
+ // No border but we'd like to draw one for user convenience when on \
screen + accumulatedBlankBorders->append(QLineF(l, y, l, y+h));
+
+ }
+
+ // inner line
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Right).innerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Right).innerPen;
+ painter.setPen(pen);
+ l += pen.widthF() / 2.0;
+ if(isDrawn(m_cellStyle.getBorderStyle(KoTableBorderStyle::Right))) {
+ drawVerticalWave(m_cellStyle.getBorderStyle(KoTableBorderStyle::Right), \
painter,y,h,l); + } else {
+ painter.drawLine(QLineF(l, y, l, y+h));
+ }
+ }
+ } else {
+ // right style wins
+ l -= thatWidth/2.0;
+ if (styleRightD->edges[KoTableBorderStyle::Left].outerPen.widthF() > 0) {
+ QPen pen = styleRightD->edges[KoTableBorderStyle::Left].outerPen;
+
+ painter.setPen(pen);
+ l += pen.widthF() / 2.0;
+ if(isDrawn(m_cellStyle.getBorderStyle(KoTableBorderStyle::Left))) {
+ drawVerticalWave(m_cellStyle.getBorderStyle(KoTableBorderStyle::Left), \
painter,y,h,l); + } else {
+ painter.drawLine(QLineF(l, y, l, y+h));
+ }
+ l += styleRightD->edges[KoTableBorderStyle::Left].spacing + pen.widthF() \
/ 2.0; + }
+ // inner line
+ if (styleRightD->edges[KoTableBorderStyle::Left].innerPen.widthF() > 0) {
+ QPen pen = styleRightD->edges[KoTableBorderStyle::Left].innerPen;
+ painter.setPen(pen);
+ l += pen.widthF() / 2.0;
+ if(isDrawn(m_cellStyle.getBorderStyle(KoTableBorderStyle::Left))) {
+ drawVerticalWave(m_cellStyle.getBorderStyle(KoTableBorderStyle::Left), \
painter,y,h,l); + } else {
+ painter.drawLine(QLineF(l, y, l, y+h));
+ }
+ }
+ }
+#endif
+}
+
+void KoTextLayoutCellHelper::drawRightmostVerticalBorder(QPainter &painter, qreal x, \
qreal y, qreal h, QVector<QLineF> *accumulatedBlankBorders) const +{
+ qreal thisWidth = \
m_cellStyle.getEdge(KoTableBorderStyle::Right).outerPen.widthF() + \
m_cellStyle.getEdge(KoTableBorderStyle::Right).spacing + \
m_cellStyle.getEdge(KoTableBorderStyle::Right).innerPen.widthF(); + qreal l = x - \
thisWidth / 2.0; +
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Right).outerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Right).outerPen;
+
+ painter.setPen(pen);
+ l += pen.widthF() / 2.0;
+ if(isDrawn(m_cellStyle.getBorderStyle(KoTableBorderStyle::Right))) {
+ drawVerticalWave(m_cellStyle.getBorderStyle(KoTableBorderStyle::Right), \
painter,y,h,l); + } else {
+ painter.drawLine(QLineF(l, y, l, y+h));
+ }
+ l += m_cellStyle.getEdge(KoTableBorderStyle::Right).spacing - pen.widthF() / \
2.0; + } else if (accumulatedBlankBorders) {
+ // No border but we'd like to draw one for user convenience when on screen
+ accumulatedBlankBorders->append(QLineF(l, y, l, y+h));
+ }
+
+ // inner line
+ if (m_cellStyle.getEdge(KoTableBorderStyle::Right).innerPen.widthF() > 0) {
+ QPen pen = m_cellStyle.getEdge(KoTableBorderStyle::Right).innerPen;
+ painter.setPen(pen);
+ l += pen.widthF() / 2.0;
+ if(isDrawn(m_cellStyle.getBorderStyle(KoTableBorderStyle::Right))) {
+ drawVerticalWave(m_cellStyle.getBorderStyle(KoTableBorderStyle::Right), \
painter,y,h,l); + } else {
+ painter.drawLine(QLineF(l, y, l, y+h));
+ }
+ }
+}
diff --git a/libs/textlayout/KoTextLayoutCellHelper.h \
b/libs/textlayout/KoTextLayoutCellHelper.h new file mode 100644
index 0000000..d66bbbc
--- /dev/null
+++ b/libs/textlayout/KoTextLayoutCellHelper.h
@@ -0,0 +1,140 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2006-2010 Thomas Zander <zander@kde.org>
+ * Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
+ * Copyright (C) 2008 Roopesh Chander <roop@forwardbias.in>
+ * Copyright (C) 2008 Girish Ramakrishnan <girish@forwardbias.in>
+ * Copyright (C) 2009 KO GmbH <cbo@kogmbh.com>
+ * Copyright (C) 2011 Pierre Ducroquet <pinaraf@pinaraf.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KOTEXTLAYOUTCELLHELPER_H
+#define KOTEXTLAYOUTCELLHELPER_H
+
+#include <QObject>
+#include <KoBorder.h>
+#include <KoTableCellStyle.h>
+
+class KoTableBorderStyle;
+class QPainter;
+
+class KoTextLayoutCellHelper : public QObject
+{
+ Q_OBJECT
+public:
+ KoTextLayoutCellHelper(const KoTableCellStyle &cellStyle, QObject *parent = 0);
+
+
+ /// returns if the borderstyle needs to be specially drawn
+ bool isDrawn(KoBorder::BorderStyle style) const;
+
+ /// draws a horizontal wave line
+ void drawHorizontalWave(KoBorder::BorderStyle style, QPainter &painter, qreal x, \
qreal w, qreal t) const; +
+ /// draws a vertical wave line
+ void drawVerticalWave(KoBorder::BorderStyle style, QPainter &painter, qreal y, \
qreal h, qreal t) const; +
+ /**
+ * Paint the borders.
+ *
+ * @painter the painter to draw with.
+ * @bounds the bounding rectangle to draw.
+ * @blanks a painterpath where blank borders should be added to.
+ */
+ void paintBorders(QPainter &painter, const QRectF &bounds, QVector<QLineF> \
*blanks) const; +
+ /**
+ * Paint the diagonal borders.
+ *
+ * @painter the painter to draw with.
+ * @bounds the bounding rectangle to draw.
+ */
+ void paintDiagonalBorders(QPainter &painter, const QRectF &bounds) const;
+
+ /**
+ * Paint the top border.
+ *
+ * @painter the painter to draw with.
+ * @x the x position.
+ * @y the y position.
+ * @w the width.
+ * @blanks a painterpath where blank borders should be added to.
+ */
+ void drawTopHorizontalBorder(QPainter &painter, qreal x, qreal y, qreal w, \
QVector<QLineF> *blanks = 0) const; +
+ /**
+ * Paint the border that is shared.
+ * It only draws the thickest and it always draws it below the y position.
+ *
+ * @painter the painter to draw with.
+ * @x the x position.
+ * @y the y position.
+ * @w the width.
+ * @blanks a painterpath where blank borders should be added to.
+ */
+ void drawSharedHorizontalBorder(QPainter &painter, const KoTableCellStyle \
&styleBelow, qreal x, qreal y, qreal w, QVector<QLineF> *blanks = 0) const; +
+ /**
+ * Paint the bottom border.
+ *
+ * @painter the painter to draw with.
+ * @x the x position.
+ * @y the y position.
+ * @w the width.
+ * @blanks a painterpath where blank borders should be added to.
+ */
+ void drawBottomHorizontalBorder(QPainter &painter, qreal x, qreal y, qreal w, \
QVector<QLineF> *blanks = 0) const; +
+ /**
+ * Paint the leftmost border.
+ *
+ * @painter the painter to draw with.
+ * @x the x position.
+ * @y the y position.
+ * @h the height.
+ * @blanks a painterpath where blank borders should be added to.
+ */
+ void drawLeftmostVerticalBorder(QPainter &painter, qreal x, qreal y, qreal h, \
QVector<QLineF> *blanks = 0) const; +
+ /**
+ * Paint the border that is shared.
+ * It only draws the thickest and it always draws it below the y position.
+ *
+ * @painter the painter to draw with.
+ * @x the x position.
+ * @y the y position.
+ * @h the height.
+ * @blanks a painterpath where blank borders should be added to.
+ */
+ void drawSharedVerticalBorder(QPainter &painter, const KoTableCellStyle \
&styleRight, qreal x, qreal y, qreal h, QVector<QLineF> *blanks = 0) const; +
+ /**
+ * Paint the rightmost border.
+ *
+ * @painter the painter to draw with.
+ * @x the x position.
+ * @y the y position.
+ * @h the height.
+ * @blanks a painterpath where blank borders should be added to.
+ */
+ void drawRightmostVerticalBorder(QPainter &painter, qreal x, qreal y, qreal h, \
QVector<QLineF> *blanks = 0) const; +
+private:
+ const KoTableCellStyle &m_cellStyle;
+};
+
+#endif // KOTEXTLAYOUTCELLHELPER_H
diff --git a/libs/textlayout/KoTextLayoutTableArea.cpp \
b/libs/textlayout/KoTextLayoutTableArea.cpp index d0c8e4b..6bdd79b 100644
--- a/libs/textlayout/KoTextLayoutTableArea.cpp
+++ b/libs/textlayout/KoTextLayoutTableArea.cpp
@@ -20,6 +20,7 @@
#include "KoTextLayoutTableArea.h"
+#include "KoTextLayoutCellHelper.h"
#include "TableIterator.h"
#include "KoTextLayoutArea.h"
#include "KoPointedAt.h"
@@ -798,14 +799,15 @@ void KoTextLayoutTableArea::paintCellBorders(QPainter *painter, \
const KoTextDocu
// This is an actual cell we want to draw, and not a covered one.
QTextTableCellFormat tfm(tableCell.format().toTableCellFormat());
- KoTableBorderStyle cellStyle(tfm);
+ KoTableCellStyle cellStyle(tfm);
+ KoTextLayoutCellHelper cellStyleHelper(cellStyle);
QRectF bRect = cellBoundingRect(tableCell);
if (d->collapsing) {
// First the horizontal borders
if (row == 0) {
- cellStyle.drawTopHorizontalBorder(*painter, bRect.x(), bRect.y(), \
bRect.width(), accuBlankBorders); + \
cellStyleHelper.drawTopHorizontalBorder(*painter, bRect.x(), bRect.y(), \
bRect.width(), accuBlankBorders); }
if (topRow) {
// in collapsing mode we need to also paint the top border of the area
@@ -816,14 +818,15 @@ void KoTextLayoutTableArea::paintCellBorders(QPainter *painter, \
const KoTextDocu QRectF aboveBRect = cellBoundingRect(tableCellAbove);
qreal x = qMax(bRect.x(), aboveBRect.x());
qreal x2 = qMin(bRect.right(), aboveBRect.right());
- KoTableBorderStyle cellAboveStyle(aboveTfm);
- cellAboveStyle.drawSharedHorizontalBorder(*painter, cellStyle, x, \
bRect.y(), x2 - x, accuBlankBorders); + KoTableCellStyle \
cellAboveStyle(aboveTfm); + KoTextLayoutCellHelper \
cellAboveStyleHelper(cellAboveStyle); + \
cellAboveStyleHelper.drawSharedHorizontalBorder(*painter, cellStyle, x, bRect.y(), x2 \
- x, accuBlankBorders);
c = tableCellAbove.column() + tableCellAbove.columnSpan();
}
}
if (row + tableCell.rowSpan() == d->table->rows()) {
// we hit the bottom of the table so just draw the bottom border
- cellStyle.drawBottomHorizontalBorder(*painter, bRect.x(), \
bRect.bottom(), bRect.width(), accuBlankBorders); + \
cellStyleHelper.drawBottomHorizontalBorder(*painter, bRect.x(), bRect.bottom(), \
bRect.width(), accuBlankBorders); } else {
int c = column;
while (c < column + tableCell.columnSpan()) {
@@ -833,38 +836,40 @@ void KoTextLayoutTableArea::paintCellBorders(QPainter *painter, \
const KoTextDocu QRectF belowBRect = cellBoundingRect(tableCellBelow);
qreal x = qMax(bRect.x(), belowBRect.x());
qreal x2 = qMin(bRect.right(), belowBRect.right());
- KoTableBorderStyle cellBelowStyle(belowTfm);
- cellStyle.drawSharedHorizontalBorder(*painter, cellBelowStyle, x, \
bRect.bottom(), x2 - x, accuBlankBorders); + KoTableCellStyle \
cellBelowStyle(belowTfm); + KoTextLayoutCellHelper \
cellBelowStyleHelper(cellBelowStyle); + \
cellStyleHelper.drawSharedHorizontalBorder(*painter, cellBelowStyle, x, \
bRect.bottom(), x2 - x, accuBlankBorders);
c = tableCellBelow.column() + tableCellBelow.columnSpan();
}
}
// And then the same treatment for vertical borders
if (column == 0) {
- cellStyle.drawLeftmostVerticalBorder(*painter, bRect.x(), bRect.y(), \
bRect.height() + cellStyle.bottomOuterBorderWidth(), accuBlankBorders); + \
cellStyleHelper.drawLeftmostVerticalBorder(*painter, bRect.x(), bRect.y(), \
bRect.height() + cellStyle.bottomOuterBorderWidth(), accuBlankBorders); }
if (column + tableCell.columnSpan() == d->table->columns()) {
// we hit the rightmost edge of the table so draw the rightmost border
- cellStyle.drawRightmostVerticalBorder(*painter, bRect.right(), \
bRect.y(), bRect.height() + cellStyle.bottomOuterBorderWidth(), accuBlankBorders); + \
cellStyleHelper.drawRightmostVerticalBorder(*painter, bRect.right(), bRect.y(), \
bRect.height() + cellStyle.bottomOuterBorderWidth(), accuBlankBorders); } else {
// we have cells to the right so draw sharedborders
int r = row;
while (r < row + tableCell.rowSpan()) {
QTextTableCell tableCellRight = d->table->cellAt(r, column + \
tableCell.columnSpan());
QTextTableCellFormat \
rightTfm(tableCellRight.format().toTableCellFormat());
- KoTableBorderStyle cellBelowRight(rightTfm);
+ KoTableCellStyle cellBelowRight(rightTfm);
+ KoTextLayoutCellHelper cellBelowRightHelper(cellBelowRight);
QRectF rightBRect = cellBoundingRect(tableCellRight);
qreal y = qMax(bRect.y(), rightBRect.y());
qreal y2 = qMin(bRect.bottom() + cellStyle.bottomOuterBorderWidth(), \
rightBRect.bottom() + cellBelowRight.bottomOuterBorderWidth());
- cellStyle.drawSharedVerticalBorder(*painter, cellBelowRight, \
bRect.right(), y, y2-y, accuBlankBorders); + \
cellBelowRightHelper.drawSharedVerticalBorder(*painter, cellBelowRight, \
bRect.right(), y, y2-y, accuBlankBorders); r = tableCellRight.row() + \
rightTfm.tableCellRowSpan(); }
}
// Paint diagonal borders for current cell
- cellStyle.paintDiagonalBorders(*painter, bRect);
+ cellStyleHelper.paintDiagonalBorders(*painter, bRect);
} else { // separating border model
- cellStyle.paintBorders(*painter, bRect, accuBlankBorders);
+ cellStyleHelper.paintBorders(*painter, bRect, accuBlankBorders);
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic