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

tdf#113445 sw: avoid hitting loop control with a dozen of in-table sections

The bugdoc has an (outer) table containing a single cell, which has an
(inner) table with 12 cells, all content is inside sections, one section
/ cell.

This relatively simple setup can already hit the loop control in
lcl_RecalcRow(), as the SwLayNotify dtor always does invalidation in an
async way, so the loop control's counter is incremented after each and
every table cell.

Instead of increasing the max tolerance in lcl_RecalcRow() (one can
easily construct a document where the bug is still there even if the max
is set to 100 instead of the current 10 iterations), just calculate the
lower synchronously.

Change-Id: Ifbffe13e5f2f237e1578bdd3e17d4d8b7c34806d
Reviewed-on: https://gerrit.libreoffice.org/43848Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst aded98ce
This diff is collapsed.
......@@ -276,6 +276,7 @@ public:
void testTdf112741();
void testTdf112860();
void testTdf113287();
void testTdf113445();
#endif
void testLinesInSectionInTable();
void testParagraphOfTextRange();
......@@ -440,6 +441,7 @@ public:
CPPUNIT_TEST(testTdf112741);
CPPUNIT_TEST(testTdf112860);
CPPUNIT_TEST(testTdf113287);
CPPUNIT_TEST(testTdf113445);
#endif
CPPUNIT_TEST(testLinesInSectionInTable);
CPPUNIT_TEST(testParagraphOfTextRange);
......@@ -5342,6 +5344,41 @@ void SwUiWriterTest::testTdf113287()
CPPUNIT_ASSERT_GREATER(nCellTop, nSectionTop);
}
void SwUiWriterTest::testTdf113445()
{
// Force multiple-page view.
SwDoc* pDoc = createDoc("tdf113445.fodt");
SwDocShell* pDocShell = pDoc->GetDocShell();
SwView* pView = pDocShell->GetView();
pView->SetViewLayout(/*nColumns=*/2, /*bBookMode=*/false);
calcLayout();
xmlDocPtr pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "//page", 2);
sal_uInt32 nPage1Left = getXPath(pXmlDoc, "//page[1]/infos/bounds", "left").toUInt32();
sal_uInt32 nPage2Left = getXPath(pXmlDoc, "//page[2]/infos/bounds", "left").toUInt32();
// Make sure that page 2 is on the right hand side of page 1, not below it.
CPPUNIT_ASSERT_GREATER(nPage1Left, nPage2Left);
// Insert a new paragaph at the start of the document.
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
pWrtShell->SttDoc();
pWrtShell->SplitNode();
discardDumpedLayout();
pXmlDoc = parseLayoutDump();
// Make sure that Table2:C5 and Table2:D5 has its section frame inside the cell frame.
sal_uInt32 nCell3Top = getXPath(pXmlDoc, "//page[2]/body/tab/row/cell/tab/row[4]/cell[3]/infos/bounds", "top").toUInt32();
sal_uInt32 nSection3Top = getXPath(pXmlDoc, "//page[2]/body/tab/row/cell/tab/row[4]/cell[3]/section/infos/bounds", "top").toUInt32();
CPPUNIT_ASSERT_GREATER(nCell3Top, nSection3Top);
sal_uInt32 nCell4Top = getXPath(pXmlDoc, "//page[2]/body/tab/row/cell/tab/row[4]/cell[4]/infos/bounds", "top").toUInt32();
sal_uInt32 nSection4Top = getXPath(pXmlDoc, "//page[2]/body/tab/row/cell/tab/row[4]/cell[4]/section/infos/bounds", "top").toUInt32();
CPPUNIT_ASSERT_GREATER(nCell4Top, nSection4Top);
// Also check if the two cells in the same row have the same top position.
// This was 4818, expected only 1672.
CPPUNIT_ASSERT_EQUAL(nCell3Top, nCell4Top);
}
void SwUiWriterTest::testTableInSectionInTable()
{
// The document has a table, containing a section, containing a nested
......
......@@ -708,7 +708,7 @@ void SwSectionFrame::MoveContentAndDelete( SwSectionFrame* pDel, bool bSave )
}
}
void SwSectionFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/)
void SwSectionFrame::MakeAll(vcl::RenderContext* pRenderContext)
{
if ( IsJoinLocked() || IsColLocked() || StackHack::IsLocked() || StackHack::Count() > 50 )
return;
......@@ -775,6 +775,19 @@ void SwSectionFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/)
mbValidSize = false;
SwLayoutFrame::MakeAll(getRootFrame()->GetCurrShell()->GetOut());
if (IsInTab())
{
// In case the section is in a table, then calculate the lower right
// now. Just setting the valid size flag of the lower to false may not
// be enough, as lcl_RecalcRow() can call
// SwFrame::ValidateThisAndAllLowers(), and then we don't attempt
// calculating the proper position of the lower.
SwFrame* pLower = Lower();
if (pLower && !pLower->GetValidPosFlag())
pLower->Calc(pRenderContext);
}
UnlockJoin();
if( m_pSection && IsSuperfluous() )
DelEmpty( false );
......
......@@ -1560,11 +1560,9 @@ static void lcl_RecalcRow( SwRowFrame& rRow, long nBottom )
{
if ( ++nLoopControlRuns_2 > nLoopControlMax )
{
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE( 0 != nLoopControlStage_2, "LoopControl_2 in lcl_RecalcRow: Stage 1!" );
OSL_ENSURE( 1 != nLoopControlStage_2, "LoopControl_2 in lcl_RecalcRow: Stage 2!!" );
OSL_ENSURE( 2 > nLoopControlStage_2, "LoopControl_2 in lcl_RecalcRow: Stage 3!!!" );
#endif
SAL_WARN_IF(nLoopControlStage_2 == 0, "sw.layout", "LoopControl_2 in lcl_RecalcRow: Stage 1!");
SAL_WARN_IF(nLoopControlStage_2 == 1, "sw.layout", "LoopControl_2 in lcl_RecalcRow: Stage 2!!");
SAL_WARN_IF(nLoopControlStage_2 >= 2, "sw.layout", "LoopControl_2 in lcl_RecalcRow: Stage 3!!!");
rRow.ValidateThisAndAllLowers( nLoopControlStage_2++ );
nLoopControlRuns_2 = 0;
if( nLoopControlStage_2 > 2 )
......@@ -1608,11 +1606,9 @@ static void lcl_RecalcRow( SwRowFrame& rRow, long nBottom )
{
if ( ++nLoopControlRuns_1 > nLoopControlMax )
{
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE( 0 != nLoopControlStage_1, "LoopControl_1 in lcl_RecalcRow: Stage 1!" );
OSL_ENSURE( 1 != nLoopControlStage_1, "LoopControl_1 in lcl_RecalcRow: Stage 2!!" );
OSL_ENSURE( 2 > nLoopControlStage_1, "LoopControl_1 in lcl_RecalcRow: Stage 3!!!" );
#endif
SAL_WARN_IF(nLoopControlStage_1 == 0, "sw.layout", "LoopControl_1 in lcl_RecalcRow: Stage 1!");
SAL_WARN_IF(nLoopControlStage_1 == 1, "sw.layout", "LoopControl_1 in lcl_RecalcRow: Stage 2!!");
SAL_WARN_IF(nLoopControlStage_1 >= 2, "sw.layout", "LoopControl_1 in lcl_RecalcRow: Stage 3!!!");
rRow.ValidateThisAndAllLowers( nLoopControlStage_1++ );
nLoopControlRuns_1 = 0;
if( nLoopControlStage_1 > 2 )
......
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