[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - sw/source

Oliver Specht oliver.specht at cib.de
Mon Jan 9 14:48:26 UTC 2017


 sw/source/core/doc/DocumentStateManager.cxx      |    4 ++--
 sw/source/core/doc/DocumentStatisticsManager.cxx |   13 ++++++++-----
 sw/source/core/inc/DocumentStatisticsManager.hxx |    4 ++--
 3 files changed, 12 insertions(+), 9 deletions(-)

New commits:
commit 33cc1bf84df83d31d1963d0d9a51f8d7413e3117
Author: Oliver Specht <oliver.specht at cib.de>
Date:   Tue Mar 29 10:17:57 2016 +0200

    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 at libreoffice.org>
    Reviewed-by: Oliver Specht <oliver.specht at cib.de>
    (cherry picked from commit 49152948ddfb1a457ab2fc149fcede57dc2c255b)
    Reviewed-on: https://gerrit.libreoffice.org/32884
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sw/source/core/doc/DocumentStateManager.cxx b/sw/source/core/doc/DocumentStateManager.cxx
index 80869a6..5375da9 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 d5c24dd..81ed9f4 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 b35aaf5..97ad4c1 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
 };
 


More information about the Libreoffice-commits mailing list