diff options
author | Valentin Kettner <vakevk+libreoffice@gmail.com> | 2014-07-31 12:14:23 +0200 |
---|---|---|
committer | Valentin Kettner <vakevk+libreoffice@gmail.com> | 2014-08-12 23:26:37 +0200 |
commit | 9cc617afcde381dfe0164570771ee8c255bdbfbe (patch) | |
tree | 633ee8df704893b41978ac057651042e43749d7f /sw | |
parent | 9d43f6d2c48373811290c82aba190a39c29512cc (diff) |
Refactored IDocumentStatistics our of SwDoc.
Into the new class DocumentStatisticsManager.
Change-Id: I281232dc09dbd79c2faf3c2a78ae49625bbe88ee
Diffstat (limited to 'sw')
24 files changed, 397 insertions, 241 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index 98b9338e11b8..6fec65f5c024 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -197,6 +197,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/core/doc/DocumentContentOperationsManager \ sw/source/core/doc/DocumentRedlineManager \ sw/source/core/doc/DocumentFieldsManager \ + sw/source/core/doc/DocumentStatisticsManager \ sw/source/core/doc/extinput \ sw/source/core/doc/fmtcol \ sw/source/core/doc/ftnidx \ diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 6aa5ba3aa97d..60278c036fcc 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -23,7 +23,6 @@ #include <IInterface.hxx> #include <IDocumentMarkAccess.hxx> #include <IDocumentStylePoolAccess.hxx> -#include <IDocumentStatistics.hxx> #include <IDocumentState.hxx> #include <IDocumentLayoutAccess.hxx> #include <IDocumentExternalData.hxx> @@ -191,6 +190,7 @@ class IDocumentListsAccess; class IDocumentOutlineNodes; class IDocumentContentOperations; class IDocumentRedlineAccess; +class IDocumentStatistics; class _SetGetExpFlds; namespace sw { namespace mark { @@ -212,6 +212,7 @@ namespace sw { class DocumentContentOperationsManager; class DocumentRedlineManager; class DocumentFieldsManager; + class DocumentStatisticsManager; } namespace com { namespace sun { namespace star { @@ -250,7 +251,6 @@ void StartGrammarChecking( SwDoc &rDoc ); class SW_DLLPUBLIC SwDoc : public IInterface, public IDocumentStylePoolAccess, - public IDocumentStatistics, public IDocumentState, public IDocumentLayoutAccess, public IDocumentExternalData @@ -269,7 +269,6 @@ class SW_DLLPUBLIC SwDoc : Timer should not be members of the model */ Timer maOLEModifiedTimer; //< Timer for update modified OLE-Objecs - Timer maStatsUpdateTimer; //< Timer for asynchronous stats calculation SwDBData maDBData; //< database descriptor OUString msTOIAutoMarkURL; //< URL of table of index AutoMark file boost::ptr_vector< boost::nullable<OUString> > maPatternNms; // Array for names of document-templates @@ -292,6 +291,7 @@ class SW_DLLPUBLIC SwDoc : const ::boost::scoped_ptr< ::sw::DocumentOutlineNodesManager > m_pDocumentOutlineNodesManager; const ::boost::scoped_ptr< ::sw::DocumentContentOperationsManager > m_pDocumentContentOperationsManager; const ::boost::scoped_ptr< ::sw::DocumentFieldsManager > m_pDocumentFieldsManager; + const ::boost::scoped_ptr< ::sw::DocumentStatisticsManager > m_pDocumentStatisticsManager; // Pointer SwFrmFmt *mpDfltFrmFmt; //< Default formats. @@ -324,7 +324,6 @@ class SW_DLLPUBLIC SwDoc : SwEndNoteInfo *mpEndNoteInfo; SwLineNumberInfo*mpLineNumberInfo; SwFtnIdxs *mpFtnIdxs; - SwDocStat *mpDocStat; //< Statistics information. SwDocShell *mpDocShell; //< Ptr to SfxDocShell of Doc. SfxObjectShellLock mxTmpDocShell; //< A temporary shell that is used to copy OLE-Nodes @@ -566,11 +565,11 @@ public: virtual void SetLineNumberInfo(const SwLineNumberInfo& rInfo); // IDocumentStatistics - virtual void DocInfoChgd() SAL_OVERRIDE; - virtual const SwDocStat &GetDocStat() const SAL_OVERRIDE; - virtual const SwDocStat &GetUpdatedDocStat(bool bCompleteAsync = false, bool bFields = true) SAL_OVERRIDE; - virtual void SetDocStat(const SwDocStat& rStat) SAL_OVERRIDE; - virtual void UpdateDocStat(bool bCompleteAsync = false, bool bFields = true) SAL_OVERRIDE; + IDocumentStatistics const & getIDocumentStatistics() const; + IDocumentStatistics & getIDocumentStatistics(); + + ::sw::DocumentStatisticsManager const & GetDocumentStatisticsManager() const; + ::sw::DocumentStatisticsManager & GetDocumentStatisticsManager(); // IDocumentState virtual void SetModified() SAL_OVERRIDE; @@ -1690,16 +1689,6 @@ private: // Copies master footer to left / first one, if necessary - used by ChgPageDesc(). void CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft, bool bFirst); - /** continue computing a chunk of document statistics - * \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 nChars, bool bFields = true); - - // Our own 'StatsUpdateTimer' calls the following method - DECL_LINK( DoIdleStatsUpdate, Timer * ); }; // This method is called in Dtor of SwDoc and deletes cache of ContourObjects. diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index b3464af03e89..24bc114fcb8b 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -34,6 +34,7 @@ #include "doc.hxx" #include <IDocumentRedlineAccess.hxx> #include <IDocumentFieldsAccess.hxx> +#include <IDocumentStatistics.hxx> #include "docsh.hxx" #include "docstat.hxx" #include "docufld.hxx" @@ -183,7 +184,7 @@ void SwDocTest::testFileNameFields() //motivation void SwDocTest::testDocStat() { - CPPUNIT_ASSERT_MESSAGE("Expected initial 0 count", m_pDoc->GetDocStat().nChar == 0); + CPPUNIT_ASSERT_MESSAGE("Expected initial 0 count", m_pDoc->getIDocumentStatistics().GetDocStat().nChar == 0); SwNodeIndex aIdx(m_pDoc->GetNodes().GetEndOfContent(), -1); SwPaM aPaM(aIdx); @@ -191,14 +192,14 @@ void SwDocTest::testDocStat() OUString sText("Hello World"); m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sText); - CPPUNIT_ASSERT_MESSAGE("Should still be non-updated 0 count", m_pDoc->GetDocStat().nChar == 0); + CPPUNIT_ASSERT_MESSAGE("Should still be non-updated 0 count", m_pDoc->getIDocumentStatistics().GetDocStat().nChar == 0); - SwDocStat aDocStat = m_pDoc->GetUpdatedDocStat(); + SwDocStat aDocStat = m_pDoc->getIDocumentStatistics().GetUpdatedDocStat( false, true ); sal_uLong nLen = static_cast<sal_uLong>(sText.getLength()); CPPUNIT_ASSERT_MESSAGE("Should now have updated count", aDocStat.nChar == nLen); - CPPUNIT_ASSERT_MESSAGE("And cache is updated too", m_pDoc->GetDocStat().nChar == nLen); + CPPUNIT_ASSERT_MESSAGE("And cache is updated too", m_pDoc->getIDocumentStatistics().GetDocStat().nChar == nLen); } //For UI character counts we should follow UAX#29 and display the user @@ -789,7 +790,7 @@ void SwDocTest::testSwScanner() //See https://bugs.libreoffice.org/show_bug.cgi?id=40599 void SwDocTest::testGraphicAnchorDeletion() { - CPPUNIT_ASSERT_MESSAGE("Expected initial 0 count", m_pDoc->GetDocStat().nChar == 0); + CPPUNIT_ASSERT_MESSAGE("Expected initial 0 count", m_pDoc->getIDocumentStatistics().GetDocStat().nChar == 0); SwNodeIndex aIdx(m_pDoc->GetNodes().GetEndOfContent(), -1); SwPaM aPaM(aIdx); diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx index 5b95e33a17b4..65d8dafbdf54 100644 --- a/sw/source/core/bastyp/calc.cxx +++ b/sw/source/core/bastyp/calc.cxx @@ -33,6 +33,7 @@ #include <docstat.hxx> #include <doc.hxx> #include <IDocumentFieldsAccess.hxx> +#include <IDocumentStatistics.hxx> #include <editeng/langitem.hxx> #include <editeng/scripttypeitem.hxx> #include <editeng/unolingu.hxx> @@ -323,7 +324,7 @@ SwCalc::SwCalc( SwDoc& rD ) #error Did you adjust all hash values? #endif - const SwDocStat& rDocStat = rDoc.GetDocStat(); + const SwDocStat& rDocStat = rDoc.getIDocumentStatistics().GetDocStat(); SwSbxValue nVal; OUString sTmpStr; diff --git a/sw/source/core/doc/DocumentStatisticsManager.cxx b/sw/source/core/doc/DocumentStatisticsManager.cxx new file mode 100644 index 000000000000..e2571a8bd7da --- /dev/null +++ b/sw/source/core/doc/DocumentStatisticsManager.cxx @@ -0,0 +1,246 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include <DocumentStatisticsManager.hxx> +#include <doc.hxx> +#include <fldbas.hxx> +#include <docsh.hxx> +#include <IDocumentFieldsAccess.hxx> +#include <view.hxx> +#include <ndtxt.hxx> +#include <switerator.hxx> +#include <fmtfld.hxx> +#include <rootfrm.hxx> +#include <docufld.hxx> +#include <docstat.hxx> +#include <vector> +#include <viewsh.hxx> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> + +using namespace ::com::sun::star; + +namespace +{ + class LockAllViews + { + std::vector<SwViewShell*> m_aViewWasUnLocked; + SwViewShell* m_pViewShell; + public: + LockAllViews(SwViewShell *pViewShell) + : m_pViewShell(pViewShell) + { + if (!m_pViewShell) + return; + SwViewShell *pSh = m_pViewShell; + do + { + if (!pSh->IsViewLocked()) + { + m_aViewWasUnLocked.push_back(pSh); + pSh->LockView(true); + } + pSh = (SwViewShell*)pSh->GetNext(); + } while (pSh != m_pViewShell); + } + ~LockAllViews() + { + for (std::vector<SwViewShell*>::iterator aI = m_aViewWasUnLocked.begin(); aI != m_aViewWasUnLocked.end(); ++aI) + { + SwViewShell *pSh = *aI; + pSh->LockView(false); + } + } + }; +} + +namespace sw +{ + +DocumentStatisticsManager::DocumentStatisticsManager( SwDoc& i_rSwdoc ) : m_rSwdoc( i_rSwdoc ), + mpDocStat( new SwDocStat ) +{ + maStatsUpdateTimer.SetTimeout( 100 ); + maStatsUpdateTimer.SetTimeoutHdl( LINK( this, DocumentStatisticsManager, DoIdleStatsUpdate ) ); +} + +void DocumentStatisticsManager::DocInfoChgd( ) +{ + m_rSwdoc.getIDocumentFieldsAccess().GetSysFldType( RES_DOCINFOFLD )->UpdateFlds(); + m_rSwdoc.getIDocumentFieldsAccess().GetSysFldType( RES_TEMPLNAMEFLD )->UpdateFlds(); + m_rSwdoc.SetModified(); +} + +const SwDocStat& DocumentStatisticsManager::GetDocStat() const +{ + return *mpDocStat; +} + +SwDocStat& DocumentStatisticsManager::GetDocStat() +{ + return *mpDocStat; +} + +const SwDocStat& DocumentStatisticsManager::GetUpdatedDocStat( bool bCompleteAsync, bool bFields ) +{ + if( mpDocStat->bModified ) + { + UpdateDocStat( bCompleteAsync, bFields ); + } + return *mpDocStat; +} + +void DocumentStatisticsManager::SetDocStat( const SwDocStat& rStat ) +{ + *mpDocStat = rStat; +} + +void DocumentStatisticsManager::UpdateDocStat( bool bCompleteAsync, bool bFields ) +{ + if( mpDocStat->bModified ) + { + if (!bCompleteAsync) + { + while (IncrementalDocStatCalculate( + ::std::numeric_limits<long>::max(), bFields)) {} + maStatsUpdateTimer.Stop(); + } + else if (IncrementalDocStatCalculate(5000, bFields)) + maStatsUpdateTimer.Start(); + } +} + +// returns true while there is more to do +bool DocumentStatisticsManager::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 = m_rSwdoc.GetNodes().Count(); i > 0 && nChars > 0; ) + { + switch( ( pNd = m_rSwdoc.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())) + { + nChars -= (mpDocStat->nChar - nOldChars); + } + break; + } + case ND_TABLENODE: ++mpDocStat->nTbl; break; + case ND_GRFNODE: ++mpDocStat->nGrf; break; + case ND_OLENODE: ++mpDocStat->nOLE; break; + case ND_SECTIONNODE: break; + } + } + + // #i93174#: notes contain paragraphs that are not nodes + { + SwFieldType * const pPostits( m_rSwdoc.getIDocumentFieldsAccess().GetSysFldType(RES_POSTITFLD) ); + SwIterator<SwFmtFld,SwFieldType> aIter( *pPostits ); + for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() ) + { + if (pFmtFld->IsFldInDoc()) + { + SwPostItField const * const pField( + static_cast<SwPostItField const*>(pFmtFld->GetField())); + mpDocStat->nAllPara += pField->GetNumberOfParagraphs(); + } + } + } + + mpDocStat->nPage = m_rSwdoc.GetCurrentLayout() ? m_rSwdoc.GetCurrentLayout()->GetPageNum() : 0; + mpDocStat->bModified = false; + + com::sun::star::uno::Sequence < com::sun::star::beans::NamedValue > aStat( mpDocStat->nPage ? 8 : 7); + sal_Int32 n=0; + aStat[n].Name = "TableCount"; + aStat[n++].Value <<= (sal_Int32)mpDocStat->nTbl; + aStat[n].Name = "ImageCount"; + aStat[n++].Value <<= (sal_Int32)mpDocStat->nGrf; + aStat[n].Name = "ObjectCount"; + aStat[n++].Value <<= (sal_Int32)mpDocStat->nOLE; + if ( mpDocStat->nPage ) + { + aStat[n].Name = "PageCount"; + aStat[n++].Value <<= (sal_Int32)mpDocStat->nPage; + } + aStat[n].Name = "ParagraphCount"; + aStat[n++].Value <<= (sal_Int32)mpDocStat->nPara; + aStat[n].Name = "WordCount"; + aStat[n++].Value <<= (sal_Int32)mpDocStat->nWord; + aStat[n].Name = "CharacterCount"; + aStat[n++].Value <<= (sal_Int32)mpDocStat->nChar; + aStat[n].Name = "NonWhitespaceCharacterCount"; + aStat[n++].Value <<= (sal_Int32)mpDocStat->nCharExcludingSpaces; + + // For e.g. autotext documents there is no pSwgInfo (#i79945) + SwDocShell* pObjShell(m_rSwdoc.GetDocShell()); + if (pObjShell) + { + const uno::Reference<document::XDocumentPropertiesSupplier> xDPS( + pObjShell->GetModel(), uno::UNO_QUERY_THROW); + const uno::Reference<document::XDocumentProperties> xDocProps( + xDPS->getDocumentProperties()); + // #i96786#: do not set modified flag when updating statistics + const bool bDocWasModified( m_rSwdoc.IsModified() ); + const ModifyBlocker_Impl b(pObjShell); + // rhbz#1081176: don't jump to cursor pos because of (temporary) + // activation of modified flag triggering move to input position + LockAllViews aViewGuard((SwViewShell*)pObjShell->GetWrtShell()); + xDocProps->setDocumentStatistics(aStat); + if (!bDocWasModified) + { + m_rSwdoc.ResetModified(); + } + } + + // optionally update stat. fields + if (bFields) + { + SwFieldType *pType = m_rSwdoc.getIDocumentFieldsAccess().GetSysFldType(RES_DOCSTATFLD); + pType->UpdateFlds(); + } + + return nChars <= 0; +} + +IMPL_LINK( DocumentStatisticsManager, DoIdleStatsUpdate, Timer *, pTimer ) +{ + (void)pTimer; + if (IncrementalDocStatCalculate(32000)) + maStatsUpdateTimer.Start(); + + SwView* pView = m_rSwdoc.GetDocShell() ? m_rSwdoc.GetDocShell()->GetView() : NULL; + if( pView ) + pView->UpdateDocStats(); + return 0; +} + +DocumentStatisticsManager::~DocumentStatisticsManager() +{ + maStatsUpdateTimer.Stop(); + delete mpDocStat; +} + +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 3e5a3209bdcf..aea02b0c1061 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -30,6 +30,7 @@ #include <DocumentContentOperationsManager.hxx> #include <DocumentRedlineManager.hxx> #include <DocumentFieldsManager.hxx> +#include <DocumentStatisticsManager.hxx> #include <UndoManager.hxx> #include <hintids.hxx> #include <tools/shl.hxx> @@ -406,6 +407,27 @@ IDocumentFieldsAccess & SwDoc::getIDocumentFieldsAccess() return *m_pDocumentFieldsManager; } +//IDocumentStatistics +IDocumentStatistics const & SwDoc::getIDocumentStatistics() const +{ + return *m_pDocumentStatisticsManager; +} + +IDocumentStatistics & SwDoc::getIDocumentStatistics() +{ + return *m_pDocumentStatisticsManager; +} + +::sw::DocumentStatisticsManager const & SwDoc::GetDocumentStatisticsManager() const +{ + return *m_pDocumentStatisticsManager; +} + +::sw::DocumentStatisticsManager & SwDoc::GetDocumentStatisticsManager() +{ + return *m_pDocumentStatisticsManager; +} + /* Implementations the next Interface here */ /* @@ -422,27 +444,6 @@ void SwDoc::ChgDBData(const SwDBData& rNewData) getIDocumentFieldsAccess().GetSysFldType(RES_DBNAMEFLD)->UpdateFlds(); } - - -void SwDoc::SetDocStat( const SwDocStat& rStat ) -{ - *mpDocStat = rStat; -} - -const SwDocStat& SwDoc::GetDocStat() const -{ - return *mpDocStat; -} - -const SwDocStat& SwDoc::GetUpdatedDocStat( bool bCompleteAsync, bool bFields ) -{ - if( mpDocStat->bModified ) - { - UpdateDocStat( bCompleteAsync, bFields ); - } - return *mpDocStat; -} - struct _PostItFld : public _SetGetExpFld { _PostItFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld, const SwIndex* pIdx = 0 ) @@ -955,174 +956,6 @@ void SwDoc::CalculatePagePairsForProspectPrinting( // thus we are done here. } -namespace -{ - class LockAllViews - { - std::vector<SwViewShell*> m_aViewWasUnLocked; - SwViewShell* m_pViewShell; - public: - LockAllViews(SwViewShell *pViewShell) - : m_pViewShell(pViewShell) - { - if (!m_pViewShell) - return; - SwViewShell *pSh = m_pViewShell; - do - { - if (!pSh->IsViewLocked()) - { - m_aViewWasUnLocked.push_back(pSh); - pSh->LockView(true); - } - pSh = (SwViewShell*)pSh->GetNext(); - } while (pSh != m_pViewShell); - } - ~LockAllViews() - { - for (std::vector<SwViewShell*>::iterator aI = m_aViewWasUnLocked.begin(); aI != m_aViewWasUnLocked.end(); ++aI) - { - SwViewShell *pSh = *aI; - pSh->LockView(false); - } - } - }; -} - -// returns true while there is more to do -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 && 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())) - { - nChars -= (mpDocStat->nChar - nOldChars); - } - break; - } - case ND_TABLENODE: ++mpDocStat->nTbl; break; - case ND_GRFNODE: ++mpDocStat->nGrf; break; - case ND_OLENODE: ++mpDocStat->nOLE; break; - case ND_SECTIONNODE: break; - } - } - - // #i93174#: notes contain paragraphs that are not nodes - { - SwFieldType * const pPostits( getIDocumentFieldsAccess().GetSysFldType(RES_POSTITFLD) ); - SwIterator<SwFmtFld,SwFieldType> aIter( *pPostits ); - for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() ) - { - if (pFmtFld->IsFldInDoc()) - { - SwPostItField const * const pField( - static_cast<SwPostItField const*>(pFmtFld->GetField())); - mpDocStat->nAllPara += pField->GetNumberOfParagraphs(); - } - } - } - - mpDocStat->nPage = GetCurrentLayout() ? GetCurrentLayout()->GetPageNum() : 0; - mpDocStat->bModified = false; - - com::sun::star::uno::Sequence < com::sun::star::beans::NamedValue > aStat( mpDocStat->nPage ? 8 : 7); - sal_Int32 n=0; - aStat[n].Name = "TableCount"; - aStat[n++].Value <<= (sal_Int32)mpDocStat->nTbl; - aStat[n].Name = "ImageCount"; - aStat[n++].Value <<= (sal_Int32)mpDocStat->nGrf; - aStat[n].Name = "ObjectCount"; - aStat[n++].Value <<= (sal_Int32)mpDocStat->nOLE; - if ( mpDocStat->nPage ) - { - aStat[n].Name = "PageCount"; - aStat[n++].Value <<= (sal_Int32)mpDocStat->nPage; - } - aStat[n].Name = "ParagraphCount"; - aStat[n++].Value <<= (sal_Int32)mpDocStat->nPara; - aStat[n].Name = "WordCount"; - aStat[n++].Value <<= (sal_Int32)mpDocStat->nWord; - aStat[n].Name = "CharacterCount"; - aStat[n++].Value <<= (sal_Int32)mpDocStat->nChar; - aStat[n].Name = "NonWhitespaceCharacterCount"; - aStat[n++].Value <<= (sal_Int32)mpDocStat->nCharExcludingSpaces; - - // For e.g. autotext documents there is no pSwgInfo (#i79945) - SwDocShell* pObjShell(GetDocShell()); - if (pObjShell) - { - const uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - pObjShell->GetModel(), uno::UNO_QUERY_THROW); - const uno::Reference<document::XDocumentProperties> xDocProps( - xDPS->getDocumentProperties()); - // #i96786#: do not set modified flag when updating statistics - const bool bDocWasModified( IsModified() ); - const ModifyBlocker_Impl b(pObjShell); - // rhbz#1081176: don't jump to cursor pos because of (temporary) - // activation of modified flag triggering move to input position - LockAllViews aViewGuard((SwViewShell*)pObjShell->GetWrtShell()); - xDocProps->setDocumentStatistics(aStat); - if (!bDocWasModified) - { - ResetModified(); - } - } - - // optionally update stat. fields - if (bFields) - { - SwFieldType *pType = getIDocumentFieldsAccess().GetSysFldType(RES_DOCSTATFLD); - pType->UpdateFlds(); - } - - return nChars <= 0; -} - -IMPL_LINK( SwDoc, DoIdleStatsUpdate, Timer *, pTimer ) -{ - (void)pTimer; - if (IncrementalDocStatCalculate(32000)) - maStatsUpdateTimer.Start(); - - SwView* pView = GetDocShell() ? GetDocShell()->GetView() : NULL; - if( pView ) - pView->UpdateDocStats(); - return 0; -} - -void SwDoc::UpdateDocStat( bool bCompleteAsync, bool bFields ) -{ - if( mpDocStat->bModified ) - { - if (!bCompleteAsync) - { - while (IncrementalDocStatCalculate( - ::std::numeric_limits<long>::max(), bFields)) {} - maStatsUpdateTimer.Stop(); - } - else if (IncrementalDocStatCalculate(5000, bFields)) - maStatsUpdateTimer.Start(); - } -} - -void SwDoc::DocInfoChgd( ) -{ - getIDocumentFieldsAccess().GetSysFldType( RES_DOCINFOFLD )->UpdateFlds(); - getIDocumentFieldsAccess().GetSysFldType( RES_TEMPLNAMEFLD )->UpdateFlds(); - SetModified(); -} - /// @return the reference in the doc for the name const SwFmtRefMark* SwDoc::GetRefMark( const OUString& rName ) const { @@ -1257,7 +1090,7 @@ void SwDoc::SetModified() // Bit 1: -> new state sal_IntPtr nCall = mbModified ? 3 : 2; mbModified = true; - mpDocStat->bModified = true; + GetDocumentStatisticsManager().GetDocStat().bModified = true; if( maOle2Link.IsSet() ) { mbInCallModified = true; diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 444e46ccd2d3..197b82f4be72 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -99,6 +99,7 @@ #include <DocumentContentOperationsManager.hxx> #include <DocumentRedlineManager.hxx> #include <DocumentFieldsManager.hxx> +#include <DocumentStatisticsManager.hxx> #include <unochart.hxx> #include <fldbas.hxx> @@ -213,6 +214,7 @@ SwDoc::SwDoc() m_pDocumentOutlineNodesManager( new ::sw::DocumentOutlineNodesManager( *this ) ), m_pDocumentContentOperationsManager( new ::sw::DocumentContentOperationsManager( *this ) ), m_pDocumentFieldsManager( new ::sw::DocumentFieldsManager( *this ) ), + m_pDocumentStatisticsManager( new ::sw::DocumentStatisticsManager( *this ) ), mpDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ), mpEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, mpDfltFrmFmt ) ), mpColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, mpDfltFrmFmt ) ), @@ -235,7 +237,6 @@ SwDoc::SwDoc() mpEndNoteInfo( new SwEndNoteInfo ), mpLineNumberInfo( new SwLineNumberInfo ), mpFtnIdxs( new SwFtnIdxs ), - mpDocStat( new SwDocStat ), mpDocShell( 0 ), mpACEWord( 0 ), mpURLStateChgd( 0 ), @@ -340,9 +341,6 @@ SwDoc::SwDoc() maOLEModifiedTimer.SetTimeout( 1000 ); maOLEModifiedTimer.SetTimeoutHdl( LINK( this, SwDoc, DoUpdateModifiedOLE )); - maStatsUpdateTimer.SetTimeout( 100 ); - maStatsUpdateTimer.SetTimeoutHdl( LINK( this, SwDoc, DoIdleStatsUpdate ) ); - #if HAVE_FEATURE_DBCONNECTIVITY // Create DBManager mpDBManager = new SwDBManager; @@ -447,7 +445,6 @@ SwDoc::~SwDoc() SetDefault(aCharFmt); getIDocumentTimerAccess().StopIdling(); // stop idle timer - maStatsUpdateTimer.Stop(); delete mpUnoCallBack, mpUnoCallBack = 0; delete mpURLStateChgd; @@ -620,7 +617,6 @@ SwDoc::~SwDoc() delete mpLineNumberInfo; delete mpFtnIdxs; delete mpTOXTypes; - delete mpDocStat; delete mpEmptyPageFmt; delete mpColumnContFmt; delete mpDfltCharFmt; diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index be5174f694dc..c4267f04ebba 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -34,6 +34,7 @@ #include <IDocumentSettingAccess.hxx> #include <IDocumentLinksAdministration.hxx> #include <IDocumentFieldsAccess.hxx> +#include <IDocumentStatistics.hxx> #include <docary.hxx> #include <editsh.hxx> #include <frame.hxx> @@ -430,14 +431,14 @@ OUString SwEditShell::GetCurWord() void SwEditShell::UpdateDocStat( ) { StartAllAction(); - GetDoc()->UpdateDocStat( ); + GetDoc()->getIDocumentStatistics().UpdateDocStat( false, true ); EndAllAction(); } const SwDocStat& SwEditShell::GetUpdatedDocStat() { StartAllAction(); - const SwDocStat &rRet = GetDoc()->GetUpdatedDocStat(); + const SwDocStat &rRet = GetDoc()->getIDocumentStatistics().GetUpdatedDocStat( false, true ); EndAllAction(); return rRet; } diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 8551b87326c8..053836bdc33b 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -73,6 +73,7 @@ #include <fmtpdsc.hxx> #include <doc.hxx> #include <IDocumentFieldsAccess.hxx> +#include <IDocumentStatistics.hxx> #include <rootfrm.hxx> #include <pagefrm.hxx> #include <cntfrm.hxx> @@ -731,7 +732,7 @@ SwDocStatFieldType::SwDocStatFieldType(SwDoc* pDocument) OUString SwDocStatFieldType::Expand(sal_uInt16 nSubType, sal_uInt32 nFmt) const { sal_uInt32 nVal = 0; - const SwDocStat& rDStat = pDoc->GetDocStat(); + const SwDocStat& rDStat = pDoc->getIDocumentStatistics().GetDocStat(); switch( nSubType ) { case DS_TBL: nVal = rDStat.nTbl; break; diff --git a/sw/source/core/inc/DocumentStatisticsManager.hxx b/sw/source/core/inc/DocumentStatisticsManager.hxx new file mode 100644 index 000000000000..07408b800d5a --- /dev/null +++ b/sw/source/core/inc/DocumentStatisticsManager.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTSTATISTICSMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTSTATISTICSMANAGER_HXX + +#include <IDocumentStatistics.hxx> +#include <boost/utility.hpp> +#include <vcl/timer.hxx> + +class SwDoc; +struct SwDocStat; +class Timer; + +namespace sw { + +class DocumentStatisticsManager : public IDocumentStatistics, + public ::boost::noncopyable +{ + +public: + + DocumentStatisticsManager( SwDoc& i_rSwdoc ); + + void DocInfoChgd() SAL_OVERRIDE; + const SwDocStat &GetDocStat() const SAL_OVERRIDE; + SwDocStat & GetDocStat(); //Non const version of the above, not part of the interface. + const SwDocStat &GetUpdatedDocStat(bool bCompleteAsync = false, bool bFields = true) SAL_OVERRIDE; + void SetDocStat(const SwDocStat& rStat) SAL_OVERRIDE; + void UpdateDocStat(bool bCompleteAsync = false, bool bFields = true) SAL_OVERRIDE; + + virtual ~DocumentStatisticsManager(); + +private: + + SwDoc& m_rSwdoc; + + + /** continue computing a chunk of document statistics + * \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 nChars, bool bFields = true); + + // Our own 'StatsUpdateTimer' calls the following method + DECL_LINK( DoIdleStatsUpdate, Timer * ); + + + SwDocStat *mpDocStat; //< Statistics information. + Timer maStatsUpdateTimer; //< Timer for asynchronous stats calculation +}; + +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 023f64f12908..34d10fb32605 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -32,6 +32,7 @@ #include "layouter.hxx" #include "docstat.hxx" #include "swevent.hxx" +#include <IDocumentStatistics.hxx> #include <sfx2/event.hxx> diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx index 6d405a1cd064..c6f6957219b4 100644 --- a/sw/source/core/layout/laycache.cxx +++ b/sw/source/core/layout/laycache.cxx @@ -19,6 +19,7 @@ #include <editeng/formatbreakitem.hxx> #include <doc.hxx> +#include <IDocumentStatistics.hxx> #include <docstat.hxx> #include <docary.hxx> #include <fmtpdsc.hxx> @@ -526,10 +527,10 @@ sal_uLong SwLayHelper::CalcPageCount() } else { - nPgCount = pDoc->GetDocStat().nPage; + nPgCount = pDoc->getIDocumentStatistics().GetDocStat().nPage; if ( nPgCount <= 10 ) // no page insertion for less than 10 pages nPgCount = 0; - sal_uLong nNdCount = pDoc->GetDocStat().nPara; + sal_uLong nNdCount = pDoc->getIDocumentStatistics().GetDocStat().nPara; if ( nNdCount <= 1 ) { //Estimates the number of paragraphs. diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 51c367f7aec7..a39031957329 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -29,6 +29,7 @@ #include <cmdid.h> #include <doc.hxx> #include <IDocumentFieldsAccess.hxx> +#include <IDocumentStatistics.hxx> #include <hints.hxx> #include <fmtfld.hxx> #include <txtfld.hxx> @@ -2888,7 +2889,7 @@ void SAL_CALL SwXTextFieldTypes::refresh() throw (uno::RuntimeException, std::ex if (!IsValid()) throw uno::RuntimeException(); UnoActionContext aContext(GetDoc()); - GetDoc()->UpdateDocStat(); + GetDoc()->getIDocumentStatistics().UpdateDocStat( false, true ); GetDoc()->getIDocumentFieldsAccess().UpdateFlds(0, false); } // call refresh listeners (without SolarMutex locked) diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index dbc7d88ad86c..0f7c1688ea65 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -2535,7 +2535,7 @@ const IDocumentLayoutAccess* SwViewShell::getIDocumentLayoutAccess() const { ret IDocumentLayoutAccess* SwViewShell::getIDocumentLayoutAccess() { return mpDoc; } IDocumentContentOperations* SwViewShell::getIDocumentContentOperations() { return &mpDoc->getIDocumentContentOperations(); } IDocumentStylePoolAccess* SwViewShell::getIDocumentStylePoolAccess() { return mpDoc; } -const IDocumentStatistics* SwViewShell::getIDocumentStatistics() const { return mpDoc; } +const IDocumentStatistics* SwViewShell::getIDocumentStatistics() const { return &mpDoc->getIDocumentStatistics(); } IDocumentUndoRedo & SwViewShell::GetIDocumentUndoRedo() { return mpDoc->GetIDocumentUndoRedo(); } diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 4c8a6f1daf71..931d6d2ab19e 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -82,6 +82,7 @@ #include <IDocumentLinksAdministration.hxx> #include <IDocumentRedlineAccess.hxx> #include <IDocumentFieldsAccess.hxx> +#include <IDocumentStatistics.hxx> #include <pam.hxx> #include <ndtxt.hxx> #include <mdiexp.hxx> @@ -850,7 +851,7 @@ if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( false ).nNode.GetIndex() ) if( bUpdateDocStat ) { - pDoc->UpdateDocStat(); + pDoc->getIDocumentStatistics().UpdateDocStat( false, true ); } } diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 6b10c89528df..a6bb254d97b1 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -58,6 +58,7 @@ #include <doc.hxx> #include <IDocumentSettingAccess.hxx> #include <IDocumentDrawModelAccess.hxx> +#include <IDocumentStatistics.hxx> #include <viewopt.hxx> #include <docary.hxx> #include <pam.hxx> @@ -339,7 +340,7 @@ static void WriteDop( WW8Export& rWrt ) // DocStat-Felder benoetigt!) rDop.fWCFtnEdn = true; // because they are included in StarWriter - const SwDocStat& rDStat = rWrt.pDoc->GetDocStat(); + const SwDocStat& rDStat = rWrt.pDoc->getIDocumentStatistics().GetDocStat(); rDop.cWords = rDStat.nWord; rDop.cCh = rDStat.nChar; rDop.cPg = static_cast< sal_Int16 >(rDStat.nPage); diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index c6f6bba39d80..b99aade790a3 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -39,6 +39,7 @@ #include <pam.hxx> #include <doc.hxx> #include <IDocumentRedlineAccess.hxx> +#include <IDocumentStatistics.hxx> #include <docstat.hxx> #include <docsh.hxx> @@ -373,7 +374,7 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >& } } - if( pDoc->GetCurrentViewShell() && pDoc->GetDocStat().nPage > 1 && + if( pDoc->GetCurrentViewShell() && pDoc->getIDocumentStatistics().GetDocStat().nPage > 1 && !(bOrganizerMode || bBlock || bErr) ) { try diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index 90de156fb866..1db021a0800d 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -62,6 +62,8 @@ #include <IDocumentSettingAccess.hxx> #include <IDocumentDrawModelAccess.hxx> #include <IDocumentRedlineAccess.hxx> +#include <IDocumentStatistics.hxx> + #include <pausethreadstarting.hxx> #include <drawdoc.hxx> @@ -197,7 +199,7 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass ) { // Update doc stat, so that correct values are exported and // the progress works correctly. - pDoc->UpdateDocStat(); + pDoc->getIDocumentStatistics().UpdateDocStat( false, true ); } if( bShowProgress ) { @@ -223,7 +225,7 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass ) nRef += pDoc->GetTxtFmtColls()->size() - 1; nRef *= 2; // for the above styles, xmloff will increment by 2! // #i93174#: count all paragraphs for the progress bar - nRef += pDoc->GetUpdatedDocStat().nAllPara; // 1: only content, no autostyle + nRef += pDoc->getIDocumentStatistics().GetUpdatedDocStat( false, true ).nAllPara; // 1: only content, no autostyle pProgress->SetReference( nRef ); pProgress->SetValue( 0 ); } diff --git a/sw/source/filter/xml/xmlmeta.cxx b/sw/source/filter/xml/xmlmeta.cxx index 8ffb42f0f918..77e48f829774 100644 --- a/sw/source/filter/xml/xmlmeta.cxx +++ b/sw/source/filter/xml/xmlmeta.cxx @@ -30,6 +30,7 @@ #include "docstat.hxx" #include "docsh.hxx" #include <doc.hxx> +#include <IDocumentStatistics.hxx> #include "xmlimp.hxx" #include "xmlexp.hxx" @@ -113,7 +114,7 @@ void SwXMLImport::SetStatistics( SvXMLImport::SetStatistics(i_rStats); SwDoc *pDoc = SwImport::GetDocFromXMLImport( *this ); - SwDocStat aDocStat( pDoc->GetDocStat() ); + SwDocStat aDocStat( pDoc->getIDocumentStatistics().GetDocStat() ); sal_uInt32 nTokens = 0; @@ -139,7 +140,7 @@ void SwXMLImport::SetStatistics( } if( nTokens ) - pDoc->SetDocStat( aDocStat ); + pDoc->getIDocumentStatistics().SetDocStat( aDocStat ); // set progress bar reference to #paragraphs. If not available, // use #pages*10, or guesstimate 250 paragraphs. Additionally diff --git a/sw/source/ui/dialog/docstdlg.cxx b/sw/source/ui/dialog/docstdlg.cxx index 1a70b77ed2c2..66a2362d46a5 100644 --- a/sw/source/ui/dialog/docstdlg.cxx +++ b/sw/source/ui/dialog/docstdlg.cxx @@ -31,6 +31,7 @@ #include <modcfg.hxx> #include <fldmgr.hxx> #include <fldbas.hxx> +#include <IDocumentStatistics.hxx> #include <unotools/localedatawrapper.hxx> #include <vcl/settings.hxx> @@ -117,7 +118,7 @@ void SwDocStatPage::Update() SwWait aWait( *pSh->GetDoc()->GetDocShell(), true ); pSh->StartAction(); - aDocStat = pSh->GetDoc()->GetUpdatedDocStat(); + aDocStat = pSh->GetDoc()->getIDocumentStatistics().GetUpdatedDocStat( false, true ); pSh->EndAction(); SetData(aDocStat); diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index bf762a47bc10..6c87f8cc63e5 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -74,6 +74,7 @@ #include <IDocumentDeviceAccess.hxx> #include <IDocumentDrawModelAccess.hxx> #include <IDocumentRedlineAccess.hxx> +#include <IDocumentStatistics.hxx> #include <docstat.hxx> #include <pagedesc.hxx> #include <pview.hxx> @@ -606,7 +607,7 @@ bool SwDocShell::ConvertTo( SfxMedium& rMedium ) } // #i76360# Update document statistics - mpDoc->UpdateDocStat(); + mpDoc->getIDocumentStatistics().UpdateDocStat( false, true ); CalcLayoutForOLEObjects(); // format for OLE objets // #i62875# diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index 00b845ac1e27..038f327aa1dd 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -78,6 +78,7 @@ #include <IDocumentDeviceAccess.hxx> #include <IDocumentLinksAdministration.hxx> #include <IDocumentFieldsAccess.hxx> +#include <IDocumentStatistics.hxx> #include <pagedesc.hxx> #include <shellio.hxx> #include <pview.hxx> @@ -199,7 +200,7 @@ void SwDocShell::DoFlushDocInfo() mpWrtShell->StartAllAction(); } - mpDoc->DocInfoChgd(); + mpDoc->getIDocumentStatistics().DocInfoChgd(); if ( mpWrtShell ) { mpWrtShell->EndAllAction(); @@ -286,7 +287,7 @@ void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) // #i41679# const bool bIsDocModified = mpDoc->IsModified(); - mpDoc->DocInfoChgd( ); + mpDoc->getIDocumentStatistics().DocInfoChgd( ); // #i41679# if ( !bIsDocModified ) diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index e41205f4e52b..4fbf93c8a0e4 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -81,6 +81,7 @@ #include <IDocumentUndoRedo.hxx> #include <IDocumentSettingAccess.hxx> #include <IDocumentDrawModelAccess.hxx> +#include <IDocumentStatistics.hxx> #include <wrtsh.hxx> #include <viewopt.hxx> #include <basesh.hxx> @@ -1345,7 +1346,7 @@ void SwView::StateStatusLine(SfxItemSet &rSet) SwDocStat documentStats; { rShell.CountWords(selectionStats); - documentStats = rShell.GetDoc()->GetUpdatedDocStat( true /* complete-async */, false /* don't update fields */ ); + documentStats = rShell.GetDoc()->getIDocumentStatistics().GetUpdatedDocStat( true /* complete-async */, false /* don't update fields */ ); } OUString wordCount(SW_RES(selectionStats.nWord ? diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 893ee043614a..26ffb72c2efb 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -101,6 +101,7 @@ #include <IDocumentLinksAdministration.hxx> #include <IDocumentRedlineAccess.hxx> #include <IDocumentFieldsAccess.hxx> +#include <IDocumentStatistics.hxx> #include <editeng/forbiddencharacterstable.hxx> #include <svl/zforlist.hxx> #include <drawdoc.hxx> @@ -2015,7 +2016,7 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName) case WID_DOC_PARA_COUNT : case WID_DOC_WORD_COUNT : { - const SwDocStat& rStat(pDocShell->GetDoc()->GetUpdatedDocStat()); + const SwDocStat& rStat(pDocShell->GetDoc()->getIDocumentStatistics().GetUpdatedDocStat( false, true )); sal_Int32 nValue; switch(pEntry->nWID) { |