Kaydet (Commit) 3d1bb76e authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#112109 sw: split section frames inside table cells, ignore nested tables

Commit f8a76d21 (tdf#108524 sw: split
section frames inside table cells, non-split text frames, 2017-07-06)
added support for moving text frame masters to a next page inside
section-in-table frames. But the code in SwFrame::GetNextSctLeaf()
responsible for this is not up to nested tables, so don't try to split
sections in this case.

Otherwise we'll end up with frames which are marked as "in table", but
don't actually have have table frame parents, so we crash in
SwFrame::IsFootnoteAllowed() which assumes being in a table means a
table frame parent.

Change-Id: Iff19a4eda21a4dbfb9562dea7af8ec6767d47873
Reviewed-on: https://gerrit.libreoffice.org/41748Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 98552e46
This diff is collapsed.
......@@ -265,6 +265,7 @@ public:
void testTableInSection();
void testTableInNestedSection();
void testTableInSectionInTable();
void testSectionInTableInTable();
void testLinesMoveBackwardsInSectionInTable();
#endif
void testLinesInSectionInTable();
......@@ -417,6 +418,7 @@ public:
CPPUNIT_TEST(testTableInSection);
CPPUNIT_TEST(testTableInNestedSection);
CPPUNIT_TEST(testTableInSectionInTable);
CPPUNIT_TEST(testSectionInTableInTable);
CPPUNIT_TEST(testLinesMoveBackwardsInSectionInTable);
#endif
CPPUNIT_TEST(testLinesInSectionInTable);
......@@ -5154,6 +5156,14 @@ void SwUiWriterTest::testTableInSectionInTable()
// This crashed the layout.
createDoc("i95698.odt");
}
void SwUiWriterTest::testSectionInTableInTable()
{
// The document has a nested table, containing a multi-line section at a
// page boundary.
// This crashed the layout later in SwFrame::IsFootnoteAllowed().
createDoc("tdf112109.fodt");
}
#endif
void SwUiWriterTest::testParagraphOfTextRange()
......
......@@ -590,7 +590,7 @@ namespace
}
/// Checks if pFrame is in a table, which itself is in a section.
bool IsInTableInSection(const SwFrame* pFrame)
bool IsFrameInTableInSection(const SwFrame* pFrame)
{
if (!pFrame->IsInTab())
return false;
......@@ -598,6 +598,26 @@ namespace
// The frame is in a table, see if the table is in a section.
return pFrame->FindTabFrame()->IsInSct();
}
/// Checks if pFrame is in a table, which itself is in a table.
bool IsFrameInTableInTable(const SwFrame* pFrame)
{
if (!pFrame->IsInTab())
return false;
// The frame is in a table, see if the inner table is in an outer
// table.
bool bNested = false;
if (const SwFrame* pUpper = pFrame->FindTabFrame()->GetUpper())
bNested = pUpper->IsInTab();
return bNested;
}
/// Checks if pFrame has a parent that can contain a split section frame.
bool CanContainSplitSection(const SwFrame* pFrame)
{
return !IsFrameInTableInSection(pFrame) && !IsFrameInTableInTable(pFrame);
}
}
void SwSectionFrame::MoveContentAndDelete( SwSectionFrame* pDel, bool bSave )
......@@ -1452,7 +1472,7 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage )
return static_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame*>(GetUpper()->GetUpper()->GetNext())->Lower());
// Inside a table-in-section, or sections of headers/footers, there can be only
// one column shift be made, one of the above shortcuts should have applied!
if( IsInTableInSection(GetUpper()) || FindFooterOrHeader() )
if( !CanContainSplitSection(GetUpper()) || FindFooterOrHeader() )
return nullptr;
SwSectionFrame *pSect = FindSctFrame();
......@@ -1515,7 +1535,7 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage )
SwLayoutFrame *pLayLeaf;
SwLayoutFrame* pCellLeaf = nullptr;
if (IsInTab() && !IsInTableInSection(this))
if (IsInTab() && CanContainSplitSection(this))
{
// We are in a table (which is itself not in a section), see if there
// is a follow cell frame created already.
......@@ -1535,7 +1555,7 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage )
SwContentFrame* pTmpCnt = static_cast<SwTabFrame*>(this)->FindLastContent();
pLayLeaf = pTmpCnt ? pTmpCnt->GetUpper() : nullptr;
}
else if (pCellLeaf && !IsInTableInSection(this))
else if (pCellLeaf && CanContainSplitSection(this))
{
// This frame is in a table-not-in-section, its follow should be
// inserted under the follow of the frame's cell.
......@@ -1727,7 +1747,7 @@ SwLayoutFrame *SwFrame::GetPrevSctLeaf()
SwFlowFrame::SetMoveBwdJump( true );
SwSectionFrame *pSect = FindSctFrame();
if (!pCol && pSect && IsInTab() && !IsInTableInSection(this))
if (!pCol && pSect && IsInTab() && CanContainSplitSection(this))
{
// We don't have a previous section yet, and we're in a
// section-in-table.
......@@ -2172,8 +2192,8 @@ bool SwSectionFrame::MoveAllowed( const SwFrame* pFrame) const
return false;
// Now it has to be examined whether there is a layout sheet wherein
// a section Follow can be created
if( IsInTableInSection(this) || ( !IsInDocBody() && FindFooterOrHeader() ) )
return false; // It doesn't work in table-in-sections/headers/footers
if( !CanContainSplitSection(this) || ( !IsInDocBody() && FindFooterOrHeader() ) )
return false; // It doesn't work in table-in-sections/nested tables/headers/footers
if( IsInFly() ) // In column based or chained frames
return nullptr != const_cast<SwFrame*>(static_cast<SwFrame const *>(GetUpper()))->GetNextLeaf( MAKEPAGE_NONE );
return true;
......
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