Commit 14586553 authored by C. Boemann's avatar C. Boemann
Browse files

Support various cases where paragrah borders should not be merged (differnt horiz extent

or flagged to not merge)
parent 3b2c506f
......@@ -32,10 +32,11 @@ struct Edge {
class KoTextBlockBorderData::Private
{
public:
Private() : refCount(0) {}
Private() : refCount(0), mergeWithNext(true) {}
Edge edges[4];
QAtomicInt refCount;
bool mergeWithNext;
};
KoTextBlockBorderData::KoTextBlockBorderData(const QRectF &paragRect)
......@@ -53,10 +54,17 @@ KoTextBlockBorderData::~KoTextBlockBorderData()
KoTextBlockBorderData::KoTextBlockBorderData(const KoTextBlockBorderData &other)
: d(new Private())
{
d->mergeWithNext = other.d->mergeWithNext;
for (int i = Top; i <= Right; i++)
d->edges[i] = other.d->edges[i];
}
void KoTextBlockBorderData::setMergeWithNext(bool merge)
{
d->mergeWithNext = merge;
}
bool KoTextBlockBorderData::hasBorders() const
{
for (int i = Top; i <= Right; i++)
......@@ -71,6 +79,9 @@ bool KoTextBlockBorderData::operator==(const KoTextBlockBorderData &border) cons
}
bool KoTextBlockBorderData::equals(const KoTextBlockBorderData &border) const
{
if (!d->mergeWithNext) {
return false;
}
for (int i = Top; i <= Right; i++) {
if (d->edges[i].outerPen != border.d->edges[i].outerPen)
return false;
......
......@@ -89,6 +89,11 @@ public:
KoParagraphStyle::Property width, KoParagraphStyle::Property color,
KoParagraphStyle::Property space, KoParagraphStyle::Property innerWidth);
/**
* Set if this border should possibly be merged with the next.
*/
void setMergeWithNext(bool merge);
/**
* @return true if there has been at least one border set.
*/
......
......@@ -1945,6 +1945,7 @@ void KoTextLayoutArea::handleBordersAndSpacing(KoTextBlockData *blockData, QText
border.setEdge(border.Bottom, format, KoParagraphStyle::BottomBorderStyle,
KoParagraphStyle::BottomBorderWidth, KoParagraphStyle::BottomBorderColor,
KoParagraphStyle::BottomBorderSpacing, KoParagraphStyle::BottomInnerBorderWidth);
border.setMergeWithNext(formatStyle.joinBorder());
if (border.hasBorders()) {
if (blockData == 0) {
......
......@@ -199,10 +199,12 @@ void KoTextLayoutArea::paint(QPainter *painter, const KoTextDocumentLayout::Pain
// Check and update border drawing code
if (lastBorder == 0) {
lastBorderRect = br;
} else if (lastBorder && lastBorder != border) {
} else if (lastBorder != border
|| lastBorderRect.width() != br.width()
|| lastBorderRect.x() != br.x()) {
lastBorder->paint(*painter, lastBorderRect);
lastBorderRect = br;
} else if (lastBorder == border) {
} else {
lastBorderRect = lastBorderRect.united(br);
}
lastBorder = border;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment