summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-08-21 08:33:14 +0200
committerMiklos Vajna <vmiklos@collabora.com>2023-08-21 09:36:32 +0200
commit08aea5526c75ff4c5385e960bd940f10ffa19cd5 (patch)
tree885fd886ca662fb32019bb13adeb5331452bb57b /sw/source
parent242bb3fdda5be165bd00701518df47cc1276438f (diff)
tdf#156351 sw floattable: fix missing bottom border in master table
The problem was that the bugdoc has a split floating table, and the bottom of the table on the first page was missing its border. The borders on the second page were correct. This happens because the cell itself has no bottom border and the layout did not extra effort to mirror the top table margin at the buttom, like Word does. Fix the problem similar to commit 53798fef2cc0b5b0b9706081a4af5ceca964a41b (Related: tdf#156351 sw floattable: fix missing top border in follow table, 2023-08-18), so we add a bottom border for master tables at a layout level, similar how a top border was already added for follow tables. Given that this kind of worked already in the past (just top borders, just the 1 row case), do this unconditionally; but if needed this could be limited to the "Word table cell" case. Change-Id: Iafdcd90226fdc425be597d36ad97fb69dca5a89a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155884 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/layout/paintfrm.cxx80
1 files changed, 79 insertions, 1 deletions
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 51dabd080b01..cf9edb359c98 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2400,6 +2400,9 @@ class SwTabFramePainter
void InsertFollowTopBorder(const SwFrame& rFrame, const SvxBoxItem& rBoxItem,
bool bWordTableCell, SwTwips nTop, SwTwips nLeft, SwTwips nRight,
bool bTopIsOuter);
+ void InsertMasterBottomBorder(const SwFrame& rFrame, const SvxBoxItem& rBoxItem,
+ bool bWordTableCell, SwTwips nBottom, SwTwips nLeft, SwTwips nRight,
+ bool bBottomIsOuter);
void HandleFrame(const SwLayoutFrame& rFrame, const SwRect& rPaintArea);
void FindStylesForLine( Point&,
@@ -2894,7 +2897,7 @@ void SwTabFramePainter::InsertFollowTopBorder(const SwFrame& rFrame, const SvxBo
// This is then a first row in a follow table, without repeated headlines.
auto pLastRow = dynamic_cast<const SwRowFrame*>(mrTabFrame.GetLastLower());
- if (!pLastRow && pLastRow == pThisRow)
+ if (!pLastRow || pLastRow == pThisRow)
{
return;
}
@@ -2930,6 +2933,79 @@ void SwTabFramePainter::InsertFollowTopBorder(const SwFrame& rFrame, const SvxBo
Insert(aFollowTop, true);
}
+void SwTabFramePainter::InsertMasterBottomBorder(const SwFrame& rFrame, const SvxBoxItem& rBoxItem,
+ bool bWordTableCell, SwTwips nBottom, SwTwips nLeft,
+ SwTwips nRight, bool bBottomIsOuter)
+{
+ // Figure out which cell to copy.
+ int nCol = 0;
+ const SwFrame* pCell = &rFrame;
+ while (pCell)
+ {
+ if (!pCell->GetPrev())
+ {
+ break;
+ }
+
+ ++nCol;
+ pCell = pCell->GetPrev();
+ }
+
+ auto pThisRow = dynamic_cast<const SwRowFrame*>(rFrame.GetUpper());
+ if (!pThisRow || pThisRow->GetUpper() != &mrTabFrame)
+ {
+ return;
+ }
+
+ if (mrTabFrame.IsFollow() || !mrTabFrame.GetFollow())
+ {
+ return;
+ }
+
+ // This is a master table that is split.
+ if (pThisRow->GetNext() || rBoxItem.GetTop() || rBoxItem.GetBottom())
+ {
+ return;
+ }
+
+ // This is then a last row in a master table.
+ auto pFirstRow = dynamic_cast<const SwRowFrame*>(mrTabFrame.GetLower());
+ if (!pFirstRow || pFirstRow == pThisRow)
+ {
+ return;
+ }
+
+ const SwFrame* pFirstCell = pFirstRow->GetLower();
+ for (int i = 0; i < nCol; ++i)
+ {
+ if (!pFirstCell)
+ {
+ break;
+ }
+
+ pFirstCell = pFirstCell->GetNext();
+ }
+ if (!pFirstCell)
+ {
+ return;
+ }
+
+ SwBorderAttrAccess aAccess(SwFrame::GetCache(), pFirstCell);
+ const SwBorderAttrs& rAttrs = *aAccess.Get();
+ const SvxBoxItem& rFirstBoxItem = rAttrs.GetBox();
+ if (!rFirstBoxItem.GetTop())
+ {
+ return;
+ }
+
+ // The matching (same column) row in the first row has a top border for us.
+ svx::frame::Style aMasterT(rFirstBoxItem.GetTop(), 1.0);
+ aMasterT.SetWordTableCell(bWordTableCell);
+ SwLineEntry aMasterBottom(nBottom, nLeft, nRight, bBottomIsOuter, aMasterT);
+ aMasterT.SetRefMode(svx::frame::RefMode::Begin);
+ Insert(aMasterBottom, true);
+}
+
void SwTabFramePainter::Insert(const SwFrame& rFrame, const SvxBoxItem& rBoxItem, const SwRect& rPaintArea)
{
// build 4 line entries for the 4 borders:
@@ -3020,6 +3096,8 @@ void SwTabFramePainter::Insert(const SwFrame& rFrame, const SvxBoxItem& rBoxItem
Insert( aTop, true );
Insert( aBottom, true );
+ InsertMasterBottomBorder(rFrame, rBoxItem, bWordTableCell, nBottom, nLeft, nRight,
+ bBottomIsOuter);
InsertFollowTopBorder(rFrame, rBoxItem, bWordTableCell, nTop, nLeft, nRight, bTopIsOuter);
}