diff options
-rw-r--r-- | sw/qa/extras/layout/data/tox-update-wrong-pages.odt | bin | 0 -> 18234 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 34 | ||||
-rw-r--r-- | sw/source/core/inc/frmtool.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/layout/flowfrm.cxx | 20 | ||||
-rw-r--r-- | sw/source/core/layout/sectfrm.cxx | 3 |
5 files changed, 57 insertions, 1 deletions
diff --git a/sw/qa/extras/layout/data/tox-update-wrong-pages.odt b/sw/qa/extras/layout/data/tox-update-wrong-pages.odt Binary files differnew file mode 100644 index 000000000000..40ceb7ac4bd2 --- /dev/null +++ b/sw/qa/extras/layout/data/tox-update-wrong-pages.odt diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index b4101e9f033e..59db7359bafe 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -5092,6 +5092,40 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf54465_ColumnsWithFootnoteDoNotOccupy assertXPath(pXmlDoc, "/root/page", 1); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf155324) +{ + createSwDoc("tox-update-wrong-pages.odt"); + + dispatchCommand(mxComponent, ".uno:UpdateAllIndexes", {}); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + + // the problem was that the first entry was on page 7, 2nd on page 9 etc. + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", "Foo"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", "5"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", "bar"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", "7"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", "Three"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", "7"); + + // check first content page has the footnotes + assertXPath(pXmlDoc, "/root/page[5]/body/txt[1]/SwParaPortion/SwLineLayout", "portion", "Foo"); + assertXPath(pXmlDoc, "/root/page[4]/ftncont", 0); + assertXPath(pXmlDoc, "/root/page[5]/ftncont/ftn", 5); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 0aaa4d2c05c3..5cabab690b61 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -158,6 +158,7 @@ SwTwips CalcRowRstHeight( SwLayoutFrame *pRow ); tools::Long CalcHeightWithFlys( const SwFrame *pFrame ); namespace sw { + bool HasPageBreakBefore(SwPageFrame const& rPage); bool IsRightPageByNumber(SwRootFrame const& rLayout, sal_uInt16 nPageNum); class FlyCreationSuppressor { diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 370ad84b88ff..1b9ecf1cf03c 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -880,6 +880,26 @@ SwLayoutFrame *SwFrame::GetLeaf( MakePageType eMakePage, bool bFwd ) return bFwd ? GetNextLeaf( eMakePage ) : GetPrevLeaf(); } +namespace sw { + +bool HasPageBreakBefore(SwPageFrame const& rPage) +{ + SwFrame const* pFlow(rPage.FindFirstBodyContent()); + if (!pFlow) + { + return false; + } + while (pFlow->GetUpper()->IsInTab()) + { + pFlow = pFlow->GetUpper()->FindTabFrame(); + } + return pFlow->GetPageDescItem().GetPageDesc() + || pFlow->GetBreakItem().GetBreak() == SvxBreak::PageBefore + || pFlow->GetBreakItem().GetBreak() == SvxBreak::PageBoth; +}; + +} // namespace sw + bool SwFrame::WrongPageDesc( SwPageFrame* pNew ) { // Now it's getting a bit complicated: diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index b9249de5c340..b6890aec917b 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -1756,7 +1756,8 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage ) // case pLayLeaf points to our section's cell's follow, which is // fine to be on the same page. New page creation is handled when // creating / moving the cell frame. - if( WrongPageDesc( pNxtPg ) && !bLayLeafTableAllowed ) + // It doesn't make sense to move to a page that starts with break? + if ((WrongPageDesc(pNxtPg) || HasPageBreakBefore(*pNxtPg)) && !bLayLeafTableAllowed) { if( bWrongPage ) break; // there's a column between me and my right page |