summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2016-08-10 11:06:33 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2016-08-29 13:13:16 +0200
commit0b5352f67e9c684e59c4f8653ed7fcdd9ae5aa05 (patch)
tree9fbdb591cc8a03961324fae6cf118ff6c06c224b
parentf075c30ed6b7820a7723cf18049c2ec2384c5dab (diff)
Use InsertPage in AssertFlyPages
AssertFlyPages used its own code to insert pages. It had two flaws: 1. It used the SwPageDesc of the previous page, unaware of changed page description of a new page, which would later be fixed by CheckPageDescs, eventually requiring re-layout. 2. The Code has an of-by-one error when setting the initial bOdd, which would also insert wrong / inverse left and right pages. So this changes AssertFlyPages to use InsertPage, which has a little more overhead for inserts, but prevents later expensive corrections, especially when CheckPageDescs() inserts or removes "early" pages, which need to evaluate and move all page bound flys. Change-Id: I8806cebb26db60602d8438f117e0416e07228b3b
-rw-r--r--sw/source/core/layout/pagechg.cxx28
1 files changed, 4 insertions, 24 deletions
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index b679cc6d2cf3..3142e33f6b9b 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1422,29 +1422,9 @@ void SwRootFrame::AssertFlyPages()
if ( nMaxPg > pPage->GetPhyPageNum() )
{
- // Continue pages based on the rules of the PageDesc after the last page.
- bool bOdd = (pPage->GetPhyPageNum() % 2) != 0;
- SwPageDesc *pDesc = pPage->GetPageDesc();
- SwFrame *pSibling = pPage->GetNext();
- for ( sal_uInt16 i = pPage->GetPhyPageNum(); i < nMaxPg; ++i )
- {
- if ( !(bOdd ? pDesc->GetRightFormat() : pDesc->GetLeftFormat()) )
- {
- // Insert empty page (but Flys will be stored in the next page)
- pPage = new SwPageFrame( pDoc->GetEmptyPageFormat(), this, pDesc );
- pPage->Paste( this, pSibling );
- pPage->PreparePage( false );
- bOdd = !bOdd;
- ++i;
- }
- pPage = new
- SwPageFrame( (bOdd ? pDesc->GetRightFormat() :
- pDesc->GetLeftFormat()), this, pDesc );
- pPage->Paste( this, pSibling );
- pPage->PreparePage( false );
- bOdd = !bOdd;
- pDesc = pDesc->GetFollow();
- }
+ for ( sal_uInt16 i = pPage->GetPhyPageNum(); i < nMaxPg; ++i )
+ pPage = InsertPage( pPage, false );
+
// If the endnote pages are now corrupt, destroy them.
if ( !pDoc->GetFootnoteIdxs().empty() )
{
@@ -1455,7 +1435,7 @@ void SwRootFrame::AssertFlyPages()
if ( pPage )
{
SwPageDesc *pTmpDesc = pPage->FindPageDesc();
- bOdd = pPage->OnRightPage();
+ bool bOdd = pPage->OnRightPage();
if ( pPage->GetFormat() !=
(bOdd ? pTmpDesc->GetRightFormat() : pTmpDesc->GetLeftFormat()) )
RemoveFootnotes( pPage, false, true );