summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-08-13 18:39:08 +0200
committerMiklos Vajna <vmiklos@suse.cz>2014-04-23 22:14:48 +0200
commit12096fd0f11e2d1280096352b71de70fb66f9892 (patch)
tree9dc78950c09f0106502a1fb0ceeb0d6760f6a4fe
parentfc66848b84b6a7744956231094d3e18965c763fe (diff)
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 (cherry picked from commit 91c8008051c0bb7905a6acd822d022e144f2941f) Conflicts: sw/inc/doc.hxx sw/source/core/doc/doc.cxx Change-Id: Ic4013545692f267aab39e084415d5d794bb5a4ca Reviewed-on: https://gerrit.libreoffice.org/5392 Reviewed-by: Tor Lillqvist <tml@iki.fi> Tested-by: Tor Lillqvist <tml@iki.fi> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/inc/doc.hxx5
-rw-r--r--sw/source/core/doc/doc.cxx17
2 files changed, 12 insertions, 10 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index ed168699ce83..cdd8dae6b065 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -2074,12 +2074,11 @@ 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
*
* returns false when there is no more to calculate
*/
- bool IncrementalDocStatCalculate(long nTextNodes = 250);
+ bool IncrementalDocStatCalculate(long nChars);
/// 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 b71288c1a1ea..ad191619a800 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1684,22 +1684,25 @@ void SwDoc::CalculatePagePairsForProspectPrinting(
}
// returns true while there is more to do
-bool SwDoc::IncrementalDocStatCalculate( long nTextNodes )
+bool SwDoc::IncrementalDocStatCalculate(long nChars)
{
pDocStat->Reset();
pDocStat->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(pDocStat->nChar);
SwTxtNode *pTxt = static_cast< SwTxtNode * >( pNd );
if( pTxt->CountWords( *pDocStat, 0, pTxt->GetTxt().Len() ) )
- nTextNodes--;
+ {
+ nChars -= (pDocStat->nChar - nOldChars);
+ }
break;
}
case ND_TABLENODE: ++pDocStat->nTbl; break;
@@ -1771,13 +1774,13 @@ bool SwDoc::IncrementalDocStatCalculate( long nTextNodes )
SwFieldType *pType = GetSysFldType(RES_DOCSTATFLD);
pType->UpdateFlds();
- return nTextNodes <= 0;
+ return nChars <= 0;
}
IMPL_LINK( SwDoc, DoIdleStatsUpdate, Timer *, pTimer )
{
(void)pTimer;
- if( IncrementalDocStatCalculate( 1000 ) )
+ if (IncrementalDocStatCalculate(32000))
aStatsUpdateTimer.Start();
SwView* pView = GetDocShell() ? GetDocShell()->GetView() : NULL;
@@ -1792,10 +1795,10 @@ void SwDoc::UpdateDocStat( bool bCompleteAsync )
{
if (!bCompleteAsync)
{
- while (IncrementalDocStatCalculate()) {}
+ while (IncrementalDocStatCalculate(5000)) {}
aStatsUpdateTimer.Stop();
}
- else if (IncrementalDocStatCalculate())
+ else if (IncrementalDocStatCalculate(5000))
aStatsUpdateTimer.Start();
}
}