diff options
-rw-r--r-- | sw/inc/doc.hxx | 5 | ||||
-rw-r--r-- | sw/source/core/doc/doc.cxx | 17 |
2 files changed, 12 insertions, 10 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 89f6c05a0038..3e2369053ed7 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -2080,13 +2080,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 5fe4cb6afac5..66755073d02c 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1648,22 +1648,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; @@ -1738,13 +1741,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; @@ -1759,10 +1762,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(); } } |