diff options
author | Jan-Marek Glogowski <jan-marek.glogowski@extern.cib.de> | 2019-08-06 17:09:51 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-08-13 16:53:33 +0200 |
commit | 383032c50a3e3354f04200ce984a47ab9d2c5c67 (patch) | |
tree | 57e9d15d4b917fc38745b01e4394d492839d4e2d /sw/source/core/layout | |
parent | 66063914e39f232efe2271d52e51a3458455d8b4 (diff) |
tdf#123583 use TaskStopwatch for Writer Idle loop
I don't see much of a point in the extra CheckIdleEnd() function.
We already check IsInterrupt() almost everywhere, so move that
check in there.
An other strange thing is the Idle job, which should just be
interrupted by keyboard events (using SetInputType(, which this
patch removes). Unlucky for me this code was there in the initial
import. I can just say that othing obvious breaks...
Change-Id: Ia5955d1eaf2ab612f2c4b63b0e458ed92507b75c
Reviewed-on: https://gerrit.libreoffice.org/77040
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'sw/source/core/layout')
-rw-r--r-- | sw/source/core/layout/layact.cxx | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 2adde3af3022..04201e1c6f5e 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -88,13 +88,6 @@ void SwLayAction::CheckWaitCursor() } } -// Time over already? -inline void SwLayAction::CheckIdleEnd() -{ - if ( !IsInput() ) - m_bInput = bool(GetInputType()) && Application::AnyInput( GetInputType() ); -} - void SwLayAction::SetStatBar( bool bNew ) { if ( bNew ) @@ -252,13 +245,13 @@ void SwLayAction::PaintContent( const SwContentFrame *pCnt, } } -SwLayAction::SwLayAction( SwRootFrame *pRt, SwViewShellImp *pI ) : - m_pRoot( pRt ), +SwLayAction::SwLayAction(SwRootFrame *pRt, SwViewShellImp *pI, TaskStopwatch* pWatch) + : m_pRoot(pRt), m_pImp( pI ), + m_pWatch(pWatch), m_pOptTab( nullptr ), m_nPreInvaPage( USHRT_MAX ), m_nStartTicks( std::clock() ), - m_nInputType( VclInputFlags::NONE ), m_nEndPage( USHRT_MAX ), m_nCheckPageNum( USHRT_MAX ), m_pCurPage( nullptr ), @@ -267,7 +260,7 @@ SwLayAction::SwLayAction( SwRootFrame *pRt, SwViewShellImp *pI ) : { m_bPaintExtraData = ::IsExtraData( m_pImp->GetShell()->GetDoc() ); m_bPaint = m_bComplete = m_bWaitAllowed = m_bCheckPages = true; - m_bInput = m_bAgain = m_bNextCycle = m_bCalcLayout = m_bIdle = m_bReschedule = + m_bInterrupt = m_bAgain = m_bNextCycle = m_bCalcLayout = m_bReschedule = m_bUpdateExpFields = m_bBrowseActionStop = m_bActionInProgress = false; // init new flag <mbFormatContentOnInterrupt>. mbFormatContentOnInterrupt = false; @@ -282,14 +275,18 @@ SwLayAction::~SwLayAction() m_pImp->m_pLayAction = nullptr; // unregister } +bool SwLayAction::IsInterrupt() +{ + return m_bInterrupt || (m_pWatch && m_pWatch->exceededRuntime()); +} + void SwLayAction::Reset() { m_pOptTab = nullptr; m_nStartTicks = std::clock(); - m_nInputType = VclInputFlags::NONE; m_nEndPage = m_nPreInvaPage = m_nCheckPageNum = USHRT_MAX; m_bPaint = m_bComplete = m_bWaitAllowed = m_bCheckPages = true; - m_bInput = m_bAgain = m_bNextCycle = m_bCalcLayout = m_bIdle = m_bReschedule = + m_bInterrupt = m_bAgain = m_bNextCycle = m_bCalcLayout = m_bReschedule = m_bUpdateExpFields = m_bBrowseActionStop = false; m_pCurPage = nullptr; } @@ -449,7 +446,7 @@ 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; - while ( (pPage && !IsInterrupt()) || m_nCheckPageNum != USHRT_MAX ) + while ((!IsInterrupt() && pPage) || (m_nCheckPageNum != USHRT_MAX)) { if (!pPage && m_nCheckPageNum != USHRT_MAX) { @@ -569,7 +566,7 @@ void SwLayAction::InternalAction(OutputDevice* pRenderContext) pPage->InvalidateFlyLayout(); pPage->InvalidateFlyContent(); if ( IsBrowseActionStop() ) - m_bInput = true; + m_bInterrupt = true; } } if( bNoLoop ) @@ -587,7 +584,8 @@ void SwLayAction::InternalAction(OutputDevice* pRenderContext) pPage->ValidateFlyLayout(); pPage->ValidateFlyContent(); } - if ( !IsInterrupt() ) + + if (!IsInterrupt()) { SetNextCycle( false ); @@ -628,8 +626,8 @@ void SwLayAction::InternalAction(OutputDevice* pRenderContext) if( bNoLoop ) rLayoutAccess.GetLayouter()->LoopControl( pPage ); } - CheckIdleEnd(); } + if ( !pPage && !IsInterrupt() && (m_pRoot->IsSuperfluous() || m_pRoot->IsAssertFlyPages()) ) { @@ -655,6 +653,7 @@ void SwLayAction::InternalAction(OutputDevice* pRenderContext) pPage = static_cast<SwPageFrame*>(pPage->GetNext()); } } + if ( IsInterrupt() && pPage ) { // If we have input, we don't want to format content anymore, but @@ -683,7 +682,7 @@ void SwLayAction::InternalAction(OutputDevice* pRenderContext) pPg = pPg ? static_cast<SwPageFrame*>(pPg->GetPrev()) : pPage; // set flag for interrupt content formatting - mbFormatContentOnInterrupt = IsInput(); + mbFormatContentOnInterrupt = IsInterrupt(); long nBottom = rVis.Bottom(); // #i42586# - format current page, if idle action is active // This is an optimization for the case that the interrupt is created by @@ -777,7 +776,6 @@ void SwLayAction::InternalAction(OutputDevice* pRenderContext) bool SwLayAction::TurboAction_( const SwContentFrame *pCnt ) { - const SwPageFrame *pPage = nullptr; if ( !pCnt->isFrameAreaDefinitionValid() || pCnt->IsCompletePaint() || pCnt->IsRetouche() ) { @@ -838,10 +836,7 @@ bool SwLayAction::TurboAction() if ( m_pRoot->GetTurbo() ) { if ( !TurboAction_( m_pRoot->GetTurbo() ) ) - { - CheckIdleEnd(); bRet = false; - } m_pRoot->ResetTurbo(); } else @@ -1660,7 +1655,6 @@ bool SwLayAction::FormatContent( const SwPageFrame *pPage ) // paragraph has been processed. if (!pTab || !bInValid) { - CheckIdleEnd(); // consider interrupt formatting. if ( ( IsInterrupt() && !mbFormatContentOnInterrupt ) || ( !bBrowse && pPage->IsInvalidLayout() ) || @@ -1753,7 +1747,6 @@ bool SwLayAction::FormatContent( const SwPageFrame *pPage ) PaintContent( pContent, pPage, pContent->getFrameArea(), pContent->getFrameArea().Bottom()); if ( IsIdle() ) { - CheckIdleEnd(); // consider interrupt formatting. if ( IsInterrupt() && !mbFormatContentOnInterrupt ) return false; @@ -1849,7 +1842,6 @@ void SwLayAction::FormatFlyContent( const SwFlyFrame *pFly ) // If there's input, we interrupt processing. if ( !pFly->IsFlyInContentFrame() ) { - CheckIdleEnd(); // consider interrupt formatting. if ( IsInterrupt() && !mbFormatContentOnInterrupt ) return; @@ -1859,6 +1851,11 @@ void SwLayAction::FormatFlyContent( const SwFlyFrame *pFly ) CheckWaitCursor(); } +bool SwLayIdle::IsInterrupt() +{ + return m_aWatch.exceededRuntime(); +} + bool SwLayIdle::DoIdleJob_( const SwContentFrame *pCnt, IdleJobType eJob ) { OSL_ENSURE( pCnt->IsTextFrame(), "NoText neighbour of Text" ); @@ -1942,7 +1939,7 @@ bool SwLayIdle::DoIdleJob_( const SwContentFrame *pCnt, IdleJobType eJob ) bPageValid = bPageValid && (SwTextNode::WrongState::TODO != pTextNode->GetWrongDirty()); if ( aRepaint.HasArea() ) pImp->GetShell()->InvalidateWindows( aRepaint ); - if (Application::AnyInput(VCL_INPUT_ANY & VclInputFlags(~VclInputFlags::TIMER))) + if (IsInterrupt()) return true; break; } @@ -1950,7 +1947,7 @@ bool SwLayIdle::DoIdleJob_( const SwContentFrame *pCnt, IdleJobType eJob ) const_cast<SwTextFrame*>(pTextFrame)->CollectAutoCmplWrds(*pTextNode, nPos); // note: bPageValid remains true here even if the cursor // position is skipped, so no PENDING state needed currently - if (Application::AnyInput(VCL_INPUT_ANY & VclInputFlags(~VclInputFlags::TIMER))) + if (IsInterrupt()) return true; break; case WORD_COUNT : @@ -1958,7 +1955,7 @@ bool SwLayIdle::DoIdleJob_( const SwContentFrame *pCnt, IdleJobType eJob ) const sal_Int32 nEnd = pTextNode->GetText().getLength(); SwDocStat aStat; pTextNode->CountWords( aStat, 0, nEnd ); - if ( Application::AnyInput() ) + if (IsInterrupt()) return true; break; } @@ -1973,7 +1970,7 @@ bool SwLayIdle::DoIdleJob_( const SwContentFrame *pCnt, IdleJobType eJob ) // handle smarttag problems gracefully and provide diagnostics TOOLS_WARN_EXCEPTION( "sw.core", "SMART_TAGS"); } - if (Application::AnyInput(VCL_INPUT_ANY & VclInputFlags(~VclInputFlags::TIMER))) + if (IsInterrupt()) return true; break; } @@ -2165,9 +2162,7 @@ SwLayIdle::SwLayIdle( SwRootFrame *pRt, SwViewShellImp *pI ) : bool bInterrupt(false); { - SwLayAction aAction( pRoot, pImp ); - aAction.SetInputType( VCL_INPUT_ANY ); - aAction.SetIdle( true ); + SwLayAction aAction(pRoot, pImp, &m_aWatch); aAction.SetWaitAllowed( false ); aAction.Action(pImp->GetShell()->GetOut()); bInterrupt = aAction.IsInterrupt(); |