summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Specht <oliver.specht@cib.de>2016-03-29 10:17:57 +0200
committerAshod Nakashian <ashnakash@gmail.com>2017-01-09 14:47:58 +0000
commit33cc1bf84df83d31d1963d0d9a51f8d7413e3117 (patch)
tree530e05dc8d1b16f88121f1a4d7b91aa64cf9e5c3
parent3d24da12c271c2a5aa60325bc33b733f17397207 (diff)
tdf#94570: document statistic of none odf files fixed
The fix allows first time calculation of the document statistic. Change-Id: I54d2f208fa75e6c3502c27678b85a9995d4daec5 Reviewed-on: https://gerrit.libreoffice.org/23589 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Oliver Specht <oliver.specht@cib.de> (cherry picked from commit 49152948ddfb1a457ab2fc149fcede57dc2c255b) Reviewed-on: https://gerrit.libreoffice.org/32884 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r--sw/source/core/doc/DocumentStateManager.cxx4
-rw-r--r--sw/source/core/doc/DocumentStatisticsManager.cxx13
-rw-r--r--sw/source/core/inc/DocumentStatisticsManager.hxx4
3 files changed, 12 insertions, 9 deletions
diff --git a/sw/source/core/doc/DocumentStateManager.cxx b/sw/source/core/doc/DocumentStateManager.cxx
index 80869a6a68ad..5375da9a632a 100644
--- a/sw/source/core/doc/DocumentStateManager.cxx
+++ b/sw/source/core/doc/DocumentStateManager.cxx
@@ -41,7 +41,7 @@ void DocumentStateManager::SetModified()
{
m_rDoc.GetDocumentLayoutManager().ClearSwLayouterEntries();
mbModified = true;
- m_rDoc.GetDocumentStatisticsManager().GetDocStat().bModified = true;
+ m_rDoc.GetDocumentStatisticsManager().SetDocStatModified( true );
if( m_rDoc.GetOle2Link().IsSet() )
{
mbInCallModified = true;
@@ -60,7 +60,7 @@ void DocumentStateManager::ResetModified()
// Bit 1: -> new state
bool bOldModified = mbModified;
mbModified = false;
- m_rDoc.GetDocumentStatisticsManager().GetDocStat().bModified = false;
+ m_rDoc.GetDocumentStatisticsManager().SetDocStatModified( false );
m_rDoc.GetIDocumentUndoRedo().SetUndoNoModifiedPosition();
if( bOldModified && m_rDoc.GetOle2Link().IsSet() )
{
diff --git a/sw/source/core/doc/DocumentStatisticsManager.cxx b/sw/source/core/doc/DocumentStatisticsManager.cxx
index d5c24dd5a8c9..81ed9f4481f2 100644
--- a/sw/source/core/doc/DocumentStatisticsManager.cxx
+++ b/sw/source/core/doc/DocumentStatisticsManager.cxx
@@ -70,7 +70,8 @@ namespace sw
{
DocumentStatisticsManager::DocumentStatisticsManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ),
- mpDocStat( new SwDocStat )
+ mpDocStat( new SwDocStat ),
+ mbInitialized( false )
{
maStatsUpdateTimer.SetTimeout( 1 );
maStatsUpdateTimer.SetPriority( SchedulerPriority::LOWEST );
@@ -92,14 +93,14 @@ const SwDocStat& DocumentStatisticsManager::GetDocStat() const
return *mpDocStat;
}
-SwDocStat& DocumentStatisticsManager::GetDocStat()
+void DocumentStatisticsManager::SetDocStatModified(bool bSet)
{
- return *mpDocStat;
+ mpDocStat->bModified = bSet;
}
const SwDocStat& DocumentStatisticsManager::GetUpdatedDocStat( bool bCompleteAsync, bool bFields )
{
- if( mpDocStat->bModified )
+ if( mpDocStat->bModified || !mbInitialized)
{
UpdateDocStat( bCompleteAsync, bFields );
}
@@ -109,11 +110,12 @@ const SwDocStat& DocumentStatisticsManager::GetUpdatedDocStat( bool bCompleteAsy
void DocumentStatisticsManager::SetDocStat( const SwDocStat& rStat )
{
*mpDocStat = rStat;
+ mbInitialized = true;
}
void DocumentStatisticsManager::UpdateDocStat( bool bCompleteAsync, bool bFields )
{
- if( mpDocStat->bModified )
+ if( mpDocStat->bModified || !mbInitialized)
{
if (!bCompleteAsync)
{
@@ -131,6 +133,7 @@ void DocumentStatisticsManager::UpdateDocStat( bool bCompleteAsync, bool bFields
// returns true while there is more to do
bool DocumentStatisticsManager::IncrementalDocStatCalculate(long nChars, bool bFields)
{
+ mbInitialized = true;
mpDocStat->Reset();
mpDocStat->nPara = 0; // default is 1!
diff --git a/sw/source/core/inc/DocumentStatisticsManager.hxx b/sw/source/core/inc/DocumentStatisticsManager.hxx
index b35aaf5729c1..97ad4c12a5e9 100644
--- a/sw/source/core/inc/DocumentStatisticsManager.hxx
+++ b/sw/source/core/inc/DocumentStatisticsManager.hxx
@@ -39,11 +39,10 @@ public:
void DocInfoChgd(bool isEnableSetModified) override;
const SwDocStat &GetDocStat() const override;
- SwDocStat & GetDocStat(); //Non const version of the above, not part of the interface.
+ void SetDocStatModified(bool bSet);
const SwDocStat &GetUpdatedDocStat(bool bCompleteAsync = false, bool bFields = true) override;
void SetDocStat(const SwDocStat& rStat) override;
void UpdateDocStat(bool bCompleteAsync = false, bool bFields = true) override;
-
virtual ~DocumentStatisticsManager();
private:
@@ -64,6 +63,7 @@ private:
SwDocStat *mpDocStat; //< Statistics information.
+ bool mbInitialized; // allow first time update
Timer maStatsUpdateTimer; //< Timer for asynchronous stats calculation
};