diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-07-23 14:24:31 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-07-24 09:35:49 +0200 |
commit | 7a63ee0c8a7c7a0aec98597e4001558c4e129d29 (patch) | |
tree | 2a3b6c6e8e21eac9e94331df9e982e81771e0e9f | |
parent | 85938bedc9aaee91e20794c94aa8d7665273b21f (diff) |
fdo#39812: Writer: fix collapsing merged table border painting:
Create a table with a merged cell like in the screenshot in the
bug, with a SAL_DEBUG in SwTabFrmPainter::PaintLines the following
lines are painted:
debug: paint start
1 debug: start: 2749,1488 end: 12387,1488
2 debug: start: 2749,1945 end: 7567,1945
3 debug: start: 7567,1945 end: 12387,1945
4 debug: start: 2749,2015 end: 12387,2015
5 debug: start: 2749,2542 end: 7567,2542
6 debug: start: 7567,2542 end: 12387,2542
7 debug: start: 2749,1488 end: 2749,1945
8 debug: start: 2749,1945 end: 2749,2015
9 debug: start: 2749,2015 end: 2749,2542
A debug: start: 7567,1945 end: 7567,2542
B debug: start: 12387,1488 end: 12387,1945
C debug: start: 12387,1945 end: 12387,2015
D debug: start: 12387,2015 end: 12387,2542
debug: paint end
*11111*11111*
7 B
7 B
*22222*33333*
8 A C
*44444*44444*
9 A D
9 A D
*55555*66666*
The problem is obviously that the Y coordinates of the lines 2, 3
and 4 differ; they should be on the same Y position.
The problem here is that logically horizontal lines must be painted
not centered but "below" the line, and It turns out that
SwTabFrmPainter::Insert cannot correct the positions properly to
do that, because it only looks at borders in a single cell.
When using the UI to set the borders, we get (for innner table borders)
only a bottom border in the cells, but no top borders, so the
top position of the logically vertical borders needs to be corrected
with the width of the bottom border of the cell _above_; a symmetric
correction of the bottom position to the top border of the cell below
is also necessary.
Fortunately if we just leave the positons alone in Insert then
TabFrmPainter will eliminate duplicate lines with equal positions
and so it's only necessary to correct the positions when actually
painting the line in wTabFrmPainter::PaintLines,
where we have the neighboring lines available.
(cherry picked from commit 02e80d2e431a57ad775a674eb3cfcd6cec53e09f)
Change-Id: Ia8519f6673db0f3a1ecaa68038896cac39609129
Signed-off-by: Miklos Vajna <vmiklos@suse.cz>
-rwxr-xr-x | sw/source/core/layout/paintfrm.cxx | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 0bcf3fae5dd7..34434e592083 100755 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -2530,6 +2530,28 @@ void SwTabFrmPainter::PaintLines( OutputDevice& rDev, const SwRect& rRect ) cons aPaintEnd.Y() = aUpperAligned._Bottom(); } + // logically vertical lines are painted centered on the line, + // logically horizontal lines are painted "below" the line + bool const isBelow((mrTabFrm.IsVertical()) ? !bHori : bHori); + double const offsetStart = (isBelow) + ? aStyles[0].GetWidth() / 2.0 + : std::max<double>(aStyles[1].GetWidth(), + aStyles[3].GetWidth()) / 2.0; + double const offsetEnd = (isBelow) + ? aStyles[0].GetWidth() / 2.0 + : std::max<double>(aStyles[4].GetWidth(), + aStyles[6].GetWidth()) / 2.0; + if (mrTabFrm.IsVertical()) + { + aPaintStart.X() -= static_cast<long>(offsetStart + 0.5); + aPaintEnd.X() -= static_cast<long>(offsetEnd + 0.5); + } + else + { + aPaintStart.Y() += static_cast<long>(offsetStart + 0.5); + aPaintEnd.Y() += static_cast<long>(offsetEnd + 0.5); + } + aPaintStart.X() -= nTwipXCorr; // nHalfPixelSzW - 2 to assure that we do not leave the pixel aPaintEnd.X() -= nTwipXCorr; aPaintStart.Y() -= nTwipYCorr; @@ -2728,19 +2750,10 @@ void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem ) aR.MirrorSelf(); aB.MirrorSelf(); - const SwTwips nHalfBottomWidth = aB.GetWidth() / 2; - const SwTwips nHalfTopWidth = (bBottomAsTop) - ? nHalfBottomWidth : aT.GetWidth() / 2; - - // these are positions of the lines - const SwTwips nLeft = - aBorderRect._Left() - ((bVert) ? nHalfBottomWidth : 0); - const SwTwips nRight = - aBorderRect._Right() - ((bVert) ? nHalfTopWidth : 0); - const SwTwips nTop = - aBorderRect._Top() + ((bVert) ? 0 : nHalfTopWidth); - const SwTwips nBottom = - aBorderRect._Bottom()+ ((bVert) ? 0 : nHalfBottomWidth); + const SwTwips nLeft = aBorderRect._Left(); + const SwTwips nRight = aBorderRect._Right(); + const SwTwips nTop = aBorderRect._Top(); + const SwTwips nBottom = aBorderRect._Bottom(); aL.SetRefMode( svx::frame::REFMODE_CENTERED ); aR.SetRefMode( svx::frame::REFMODE_CENTERED ); |