From 077a1102b9cd3bed37a485c03cdfa6a8dd75df26 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Thu, 8 Dec 2016 19:56:07 +0300 Subject: [PATCH] tdf#90317 debug and forced workaround One thing I couldn't figure out is why a working version of the file (with one less paragraph on page 1) automatically jumps to page3 at the section break, while ANSTO_reduced.docx stays on page2 at the section break, even though it is one paragraph longer. It seemed to be pointing towards something in calcmove, something to do with valid/invalid status. Anyway, this should give a hardened developer a good headstart on identifying the heart of this problem. The layout cache guesses that 25 paragraphs will fit on a single page. Avoiding all of the bLongTab guessing fixes the problem and does a "make check" OK. Change-Id: I94df2a181a68b84483e212b5b25c36c1b0beaf6f --- sw/source/core/layout/flowfrm.cxx | 1 + sw/source/core/layout/layact.cxx | 4 ++++ sw/source/core/layout/laycache.cxx | 8 +++++++- sw/source/core/layout/pagechg.cxx | 2 ++ writerfilter/source/dmapper/PropertyMap.cxx | 1 + 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 772d4cc..a1f1bb6 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -2029,6 +2029,7 @@ bool SwFlowFrame::MoveBwd( bool &rbReformat ) bool bCheckPageDescs = false; bool bCheckPageDescOfNextPage = false; +SAL_WARN_IF(pOldPage && pOldPage->GetPageDesc(),"DEBUG","::MoveBwd isPageBreak["<GetPhyPageNum()<<"] pOldPage["<GetPageDesc()->GetName()<<"]"); if ( pFootnote ) { // If the footnote already sits on the same page/column as the reference, diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 152410b..ba9dd11 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -452,8 +452,12 @@ void SwLayAction::InternalAction(OutputDevice* pRenderContext) IDocumentLayoutAccess& rLayoutAccess = m_pRoot->GetFormat()->getIDocumentLayoutAccess(); bool bNoLoop = pPage && SwLayouter::StartLoopControl( m_pRoot->GetFormat()->GetDoc(), pPage ); sal_uInt16 nPercentPageNum = 0; + int DEBUGcounter = 0; while ( (pPage && !IsInterrupt()) || m_nCheckPageNum != USHRT_MAX ) { +SAL_WARN("DEBUG","{"<<++DEBUGcounter<<"}::InternalAction calls IsShortcut, page#["<GetPhyPageNum()<<"] checkPageNum["< nMaxParaPerPage || mbBreakAfter; mbBreakAfter = rBrk.GetBreak() == SvxBreak::PageAfter || rBrk.GetBreak() == SvxBreak::PageBoth; +SAL_WARN("DEBUG","::CheckInsertPage pDesc["<GetPhyPageNum()<<"]"); +SAL_WARN_IF(pDesc,"DEBUG"," PageDesc["<GetName()<<"]"); if ( !bBrk ) bBrk = rBrk.GetBreak() == SvxBreak::PageBefore || rBrk.GetBreak() == SvxBreak::PageBoth; @@ -619,9 +621,11 @@ bool SwLayHelper::CheckInsertPage() { bNextPageOdd = !bNextPageOdd; bInsertEmpty = true; +SAL_WARN_IF(oPgNum,"DEBUG"," Inserting an empty page to force to PgNum["<GetPageDesc(); +SAL_WARN_IF(pDesc,"DEBUG"," *** InsertNewPage["<GetName()<<"] page#["<GetPhyPageNum()<<"] Upper["<GetUpper()<<"] Odd["<GetNext()<<"] bEnd["<GetUpper(), bNextPageOdd, bNextPageFirst, bInsertEmpty, false, rpPage->GetNext() ); if ( bEnd ) @@ -674,6 +678,7 @@ bool SwLayHelper::CheckInsert( sal_uLong nNodeIndex ) pLow = pLow->GetNext(); } while ( pLow ); nParagraphCnt += nRows; + if( !pImpl && nParagraphCnt > nMaxParaPerPage + 10 ) { // OD 09.04.2003 #108698# - improve heuristics: @@ -704,6 +709,7 @@ bool SwLayHelper::CheckInsert( sal_uLong nNodeIndex ) } else ++nParagraphCnt; +SAL_WARN("DEBUG","["<GetAttrSet()->GetPageDesc().GetPageDesc()<<"] page.hasPageDesc["<<(bool)rpPage->GetPageDesc()<<"]"); if( bFirst && pImpl && nIndex < pImpl->size() && pImpl->GetBreakIndex( nIndex ) == nNodeIndex && ( pImpl->GetBreakOfst( nIndex ) < COMPLETE_STRING || @@ -764,7 +770,7 @@ bool SwLayHelper::CheckInsert( sal_uLong nNodeIndex ) { nRepeat = static_cast(rpFrame)-> GetTable()->GetRowsToRepeat(); - bSplit = nOfst < nRows && nRowCount + nRepeat < nOfst; + bSplit = nOfst < nRows && nRowCount + nRepeat < nOfst && false; //DEBUG - setting to false avoids the bug. bLongTab = bLongTab && bSplit; } if( bSplit ) diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index 8405280..b5510b2 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -749,11 +749,13 @@ SwPageDesc *SwPageFrame::FindPageDesc() pRet = GetPrev() ? static_cast(GetPrev())->GetPageDesc()->GetFollow() : nullptr; +SAL_WARN_IF(!pRet,"DEBUG","::FindPageFrm has not found pageDesc - returning the default one"); //4. if ( !pRet ) pRet = &GetFormat()->GetDoc()->GetPageDesc( 0 ); OSL_ENSURE( pRet, "could not find page descriptor." ); +SAL_WARN_IF(pRet,"DEBUG","::FindPageFrm returning["<GetName()<<"]"); return pRet; } diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 03198f3..a5484e0 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1175,6 +1175,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) const bool bTreatAsContinuous = m_nBreakType == -1 && m_nColumnCount > 0 && (m_bIsFirstSection || m_sFollowPageStyleName.isEmpty() || (m_sFirstPageStyleName.isEmpty() && m_bTitlePage)); +SAL_WARN("DEBUG","::CloseSectionGroup breaktype["<(NS_ooxml::LN_Value_ST_SectionMark_continuous) || bTreatAsContinuous) { //todo: insert a section or access the already inserted section -- 2.7.4