Kaydet (Commit) 02e80d2e authored tarafından Michael Stahl's avatar Michael Stahl

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.

Change-Id: Ia8519f6673db0f3a1ecaa68038896cac39609129
üst 8f8edfe7
...@@ -2533,6 +2533,28 @@ void SwTabFrmPainter::PaintLines( OutputDevice& rDev, const SwRect& rRect ) cons ...@@ -2533,6 +2533,28 @@ void SwTabFrmPainter::PaintLines( OutputDevice& rDev, const SwRect& rRect ) cons
aPaintEnd.Y() = aUpperAligned._Bottom(); 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 aPaintStart.X() -= nTwipXCorr; // nHalfPixelSzW - 2 to assure that we do not leave the pixel
aPaintEnd.X() -= nTwipXCorr; aPaintEnd.X() -= nTwipXCorr;
aPaintStart.Y() -= nTwipYCorr; aPaintStart.Y() -= nTwipYCorr;
...@@ -2726,19 +2748,10 @@ void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem ) ...@@ -2726,19 +2748,10 @@ void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem )
aR.MirrorSelf(); aR.MirrorSelf();
aB.MirrorSelf(); aB.MirrorSelf();
const SwTwips nHalfBottomWidth = aB.GetWidth() / 2; const SwTwips nLeft = aBorderRect._Left();
const SwTwips nHalfTopWidth = (bBottomAsTop) const SwTwips nRight = aBorderRect._Right();
? nHalfBottomWidth : aT.GetWidth() / 2; const SwTwips nTop = aBorderRect._Top();
const SwTwips nBottom = aBorderRect._Bottom();
// 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);
aL.SetRefMode( svx::frame::REFMODE_CENTERED ); aL.SetRefMode( svx::frame::REFMODE_CENTERED );
aR.SetRefMode( svx::frame::REFMODE_CENTERED ); aR.SetRefMode( svx::frame::REFMODE_CENTERED );
......
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