summaryrefslogtreecommitdiffstats
path: root/sw/source/core/layout/pagechg.cxx
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2016-08-10 11:29:16 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2016-08-29 13:13:16 +0200
commit0599989164b77f6c3368b3a2feedc8861107e37b (patch)
tree591660331e30a28b57319ec13d6828f504178e21 /sw/source/core/layout/pagechg.cxx
parentFlush the page break for correct layouting (diff)
downloadcore-0599989164b77f6c3368b3a2feedc8861107e37b.tar.gz
core-0599989164b77f6c3368b3a2feedc8861107e37b.zip
Don't oscillate empty pages in CheckPageDescs
For the first case of dropping "wrong" empty pages,look ahead and pre-validate the next page, if it needs this empty page, to prevent case three for the next page. This prevents destruction and re-insert of the empty page. Change-Id: I475aa98a2693f814afcc41bd4bc73f04e742c105
Diffstat (limited to 'sw/source/core/layout/pagechg.cxx')
-rw-r--r--sw/source/core/layout/pagechg.cxx27
1 files changed, 27 insertions, 0 deletions
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 3142e33f6b9b..28477e959b28 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1028,6 +1028,33 @@ void SwFrame::CheckPageDescs( SwPageFrame *pStart, bool bNotifyFields, SwPageFra
if ( bIsEmpty && ( pFormatWish || //1.
( !bWantOdd && !pPrevPage ) ) )
{
+ // Check all cases for the next page, so we don't oscillate empty pages
+ // Skip case 1 and 2, as we require a non-empty next page to save the empty page
+ // Case 3 is the one we actually want to predict and skip
+ // We can skip the empty check of case 3, as we just work on an existing next page
+ bool bNextWantOdd;
+ SwPageDesc *pNextDesc;
+ if ( pNextPage && !pNextPage->IsEmptyPage() && //3.
+ pNextPage->OnRightPage() == (bNextWantOdd = pNextPage->WannaRightPage()) &&
+ pNextPage->GetPageDesc() == (pNextDesc = pNextPage->FindPageDesc()) ) //4.
+ {
+ bool bNextFirst = pNextPage->OnFirstPage();
+ SwFrameFormat *pNextFormatWish = (bNextWantOdd) ? //5.
+ pNextDesc->GetRightFormat(bNextFirst) : pNextDesc->GetLeftFormat(bNextFirst);
+ if ( !pNextFormatWish ) // 6.
+ pNextFormatWish = bNextWantOdd ? pNextDesc->GetLeftFormat() : pNextDesc->GetRightFormat();
+ if ( pNextFormatWish && pNextPage->GetFormat() == pNextFormatWish )
+ {
+ SAL_INFO( "sw.swpagefrm", "CheckPageDescs phys: " << pPage->GetPhyPageNum()
+ << " c: 1+3 - skip next page of p: " << pPage );
+ if (pPage->GetPageDesc() != pPrevPage->GetPageDesc())
+ pPage->SetPageDesc( pPrevPage->GetPageDesc(), 0 );
+ // We can skip the next page, as all checks were already done!
+ pPage = static_cast<SwPageFrame*>(pNextPage->GetNext());
+ continue;
+ }
+ }
+
pPage->Cut();
bool bUpdatePrev = false;
if (ppPrev && *ppPrev == pPage)