[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - sw/inc sw/source
Michael Stahl
mstahl at redhat.com
Wed Aug 14 02:04:49 PDT 2013
sw/inc/doc.hxx | 5 ++---
sw/source/core/doc/doc.cxx | 17 ++++++++++-------
2 files changed, 12 insertions(+), 10 deletions(-)
New commits:
commit a0e98a12f8979286f2418606cfa4f75fcbc63b6e
Author: Michael Stahl <mstahl at redhat.com>
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
(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 at iki.fi>
Tested-by: Tor Lillqvist <tml at iki.fi>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 53fc219..7f5488c 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -2070,12 +2070,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 b71288c..ad19161 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();
}
}
More information about the Libreoffice-commits
mailing list