summaryrefslogtreecommitdiff
path: root/sw/source/core/layout/tabfrm.cxx
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2015-11-27 19:03:40 +0300
committerJustin Luth <justin_luth@sil.org>2016-01-18 04:30:59 +0000
commit0d127baed75929e744d5b6249f510012cfbc0e88 (patch)
tree428628b43ebaa4fdb40e6077aac0964ae9e195b4 /sw/source/core/layout/tabfrm.cxx
parent57997db73725583a84dbac36bcc9c1b2829948f9 (diff)
tdf#91083 - .doc: emulate table keep-with-next paragraph
connect table with the following paragraph. Move forward to a new page together with the following paragraph if necessary. Most of the added code allows the table to split if all of the kept items do not fit on one page - allowing the emulated table to match the layout of kept tables. The only difference with .doc occurs when the table itself is larger than one page. In that case it ALWAYS starts a new page. Although it does not match .odt, it DOES match how MSWord handles that .doc. Change-Id: Ic6f495c0dc5cd4e9f8029a8cec9e31b4fab4b20f Reviewed-on: https://gerrit.libreoffice.org/20233 Reviewed-by: Justin Luth <justin_luth@sil.org> Tested-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw/source/core/layout/tabfrm.cxx')
-rw-r--r--sw/source/core/layout/tabfrm.cxx31
1 files changed, 20 insertions, 11 deletions
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index a45a1f4059d0..0e2fed891fb0 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -1765,7 +1765,8 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
const SwBorderAttrs *pAttrs = pAccess->Get();
// The beloved keep attribute
- const bool bKeep = IsKeep( pAttrs->GetAttrSet() );
+ const bool bEmulateTableKeep = AreAllRowsKeepWithNext( GetFirstNonHeadlineRow() );
+ const bool bKeep = IsKeep( pAttrs->GetAttrSet(), bEmulateTableKeep );
// All rows should keep together
const bool bDontSplit = !IsFollow() &&
@@ -1845,8 +1846,9 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
while ( !mbValidPos || !mbValidSize || !mbValidPrtArea )
{
const bool bMoveable = IsMoveable();
- if (bMoveable)
- if ( CheckMoveFwd( bMakePage, bKeep && KEEPTAB, bMovedBwd ) )
+ if (bMoveable &&
+ !(bMovedFwd && bEmulateTableKeep) )
+ if ( CheckMoveFwd( bMakePage, bKeep && KEEPTAB, bMovedBwd, bEmulateTableKeep ) )
{
bMovedFwd = true;
m_bCalcLowers = true;
@@ -2222,19 +2224,25 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
AreAllRowsKeepWithNext( pFirstNonHeadlineRow ) ) &&
!pIndPrev &&
!bDontSplit;
+ const bool bEmulateTableKeepFwdMoveAllowed = IsKeepFwdMoveAllowed(bEmulateTableKeep);
if ( pFirstNonHeadlineRow && nUnSplitted > 0 &&
- ( !bTableRowKeep || pFirstNonHeadlineRow->GetNext() || !pFirstNonHeadlineRow->ShouldRowKeepWithNext() || bAllowSplitOfRow ) &&
- ( !bDontSplit || !pIndPrev ) )
+ ( !bEmulateTableKeepFwdMoveAllowed ||
+ ( ( !bTableRowKeep || pFirstNonHeadlineRow->GetNext() ||
+ !pFirstNonHeadlineRow->ShouldRowKeepWithNext() || bAllowSplitOfRow
+ ) && ( !bDontSplit || !pIndPrev )
+ ) ) )
{
// #i29438#
- // Special DoNotSplit case:
+ // Special DoNotSplit cases:
+ // We better avoid splitting if the table keeps with next paragraph and can move fwd still.
// We better avoid splitting of a row frame if we are inside a columned
// section which has a height of 0, because this is not growable and thus
// all kinds of unexpected things could happen.
- if ( IsInSct() &&
- (FindSctFrame())->Lower()->IsColumnFrame() &&
- 0 == (GetUpper()->Frame().*fnRect->fnGetHeight)() )
+ if ( !bEmulateTableKeepFwdMoveAllowed ||
+ ( IsInSct() && (FindSctFrame())->Lower()->IsColumnFrame() &&
+ 0 == (GetUpper()->Frame().*fnRect->fnGetHeight)()
+ ) )
{
bTryToSplit = false;
}
@@ -2303,7 +2311,8 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
// Some more checks if we want to call the split algorithm or not:
// The repeating lines / keeping lines still fit into the upper or
// if we do not have an (in)direct Prev, we split anyway.
- if( (*fnRect->fnYDiff)(nDeadLine, nBreakLine) >=0 || !pIndPrev )
+ if( (*fnRect->fnYDiff)(nDeadLine, nBreakLine) >=0
+ || !pIndPrev || !bEmulateTableKeepFwdMoveAllowed )
{
aNotify.SetLowersComplete( false );
bSplit = true;
@@ -2320,7 +2329,7 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
--nThrowAwayValidLayoutLimit;
}
- const bool bSplitError = !Split( nDeadLine, bTryToSplit, ( bTableRowKeep && !bAllowSplitOfRow ) );
+ const bool bSplitError = !Split( nDeadLine, bTryToSplit, ( bTableRowKeep && !(bAllowSplitOfRow || !bEmulateTableKeepFwdMoveAllowed) ) );
if( !bTryToSplit && !bSplitError && nUnSplitted > 0 )
{
--nUnSplitted;