summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-07-23 14:24:31 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-07-24 09:30:13 +0200
commita6d01758da37af1d6bab9c14197134ce410d9408 (patch)
tree2b84641f469ad0c4b3e188f890f22ad4ab5bf66a /sw
parent80bab179b259de2d963384444b7eac4579dea06d (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>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/layout/paintfrm.cxx39
1 files changed, 26 insertions, 13 deletions
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index d26dca733edb..4d874a1e6202 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2534,6 +2534,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;
@@ -2732,19 +2754,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 );