sw/inc/doc.hxx | 5 ++--- sw/source/core/doc/doc.cxx | 17 ++++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-)
New commits: commit 5837861da958eeef66c5167e75ea388cb7053ea7 Author: Michael Stahl <[email protected]> Date: Tue Aug 13 18:39:08 2013 +0200 fdo#58040: sw: fine tune async word count - count characters instead of paragraphs to better account for large or small paragraphs - start out with a relatively small value (5k chars) on the first run to quickly show something to the user Change-Id: Ic4013545692f267aab39e084415d5d794bb5a4ca (cherry picked from commit 91c8008051c0bb7905a6acd822d022e144f2941f) Reviewed-on: https://gerrit.libreoffice.org/5391 Reviewed-by: Tor Lillqvist <[email protected]> Tested-by: Tor Lillqvist <[email protected]> diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 98a0c30..12ab476 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -2085,13 +2085,12 @@ private: void CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft); /** continue computing a chunk of document statistics - * \param nTextNodes number of paragraphs to calculate before - * exiting + * \param nChars number of characters to count before exiting * \param bFields if stat. fields should be updated * * returns false when there is no more to calculate */ - bool IncrementalDocStatCalculate(long nTextNodes = 250, bool bFields = true); + bool IncrementalDocStatCalculate(long nChars, bool bFields = true); /// Our own 'StatsUpdateTimer' calls the following method DECL_LINK( DoIdleStatsUpdate, Timer * ); diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index f52766d..1993018 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1644,22 +1644,25 @@ void SwDoc::CalculatePagePairsForProspectPrinting( } // returns true while there is more to do -bool SwDoc::IncrementalDocStatCalculate( long nTextNodes, bool bFields ) +bool SwDoc::IncrementalDocStatCalculate(long nChars, bool bFields) { mpDocStat->Reset(); mpDocStat->nPara = 0; // default is 1! SwNode* pNd; // This is the inner loop - at least while the paras are dirty. - for( sal_uLong i = GetNodes().Count(); i > 0 && nTextNodes > 0; ) + for( sal_uLong i = GetNodes().Count(); i > 0 && nChars > 0; ) { switch( ( pNd = GetNodes()[ --i ])->GetNodeType() ) { case ND_TEXTNODE: { + long const nOldChars(mpDocStat->nChar); SwTxtNode *pTxt = static_cast< SwTxtNode * >( pNd ); if (pTxt->CountWords(*mpDocStat, 0, pTxt->GetTxt().getLength())) - nTextNodes--; + { + nChars -= (mpDocStat->nChar - nOldChars); + } break; } case ND_TABLENODE: ++mpDocStat->nTbl; break; @@ -1734,13 +1737,13 @@ bool SwDoc::IncrementalDocStatCalculate( long nTextNodes, bool bFields ) pType->UpdateFlds(); } - return nTextNodes <= 0; + return nChars <= 0; } IMPL_LINK( SwDoc, DoIdleStatsUpdate, Timer *, pTimer ) { (void)pTimer; - if( IncrementalDocStatCalculate( 1000 ) ) + if (IncrementalDocStatCalculate(32000)) maStatsUpdateTimer.Start(); SwView* pView = GetDocShell() ? GetDocShell()->GetView() : NULL; @@ -1755,10 +1758,10 @@ void SwDoc::UpdateDocStat( bool bCompleteAsync, bool bFields ) { if (!bCompleteAsync) { - while (IncrementalDocStatCalculate(250, bFields)) {} + while (IncrementalDocStatCalculate(5000, bFields)) {} maStatsUpdateTimer.Stop(); } - else if (IncrementalDocStatCalculate(250, bFields)) + else if (IncrementalDocStatCalculate(5000, bFields)) maStatsUpdateTimer.Start(); } } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
