[Libreoffice-commits] .: sw/inc sw/qa sw/source

Caolán McNamara caolan at kemper.freedesktop.org
Tue Aug 23 08:26:54 PDT 2011


 sw/inc/IDocumentStatistics.hxx      |    4 ++
 sw/inc/doc.hxx                      |    3 +-
 sw/inc/editsh.hxx                   |    3 +-
 sw/qa/core/swdoc-test.cxx           |    4 --
 sw/source/core/doc/doc.cxx          |   54 ++++++++++++++++++++----------------
 sw/source/core/edit/editsh.cxx      |   14 +++++++--
 sw/source/core/unocore/unofield.cxx |    3 --
 sw/source/filter/html/swhtml.cxx    |    3 --
 sw/source/filter/xml/xmlexp.cxx     |   11 +------
 sw/source/ui/app/docsh.cxx          |    3 --
 sw/source/ui/dialog/docstdlg.cxx    |    3 --
 sw/source/ui/shells/annotsh.cxx     |    4 +-
 sw/source/ui/shells/basesh.cxx      |    3 --
 sw/source/ui/shells/drawsh.cxx      |    4 +-
 sw/source/ui/shells/drwtxtex.cxx    |    4 +-
 sw/source/ui/shells/frmsh.cxx       |    4 +-
 sw/source/ui/shells/textsh1.cxx     |    4 +-
 sw/source/ui/uno/unotxdoc.cxx       |   10 ++----
 18 files changed, 71 insertions(+), 67 deletions(-)

New commits:
commit b9ee88198634b43639fc00547751f3fbfbdebfae
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date:   Tue Aug 23 16:25:52 2011 +0100

    Remove unecessary parameter to IDocumentStatistics::UpdateDocStat

diff --git a/sw/inc/IDocumentStatistics.hxx b/sw/inc/IDocumentStatistics.hxx
index 152d382..8bdebba 100644
--- a/sw/inc/IDocumentStatistics.hxx
+++ b/sw/inc/IDocumentStatistics.hxx
@@ -46,9 +46,11 @@
     */
     virtual const SwDocStat &GetDocStat() const = 0;
 
+    virtual const SwDocStat &GetUpdatedDocStat() = 0;
+
     virtual void SetDocStat(const SwDocStat& rStat) = 0;
 
-    virtual void UpdateDocStat(SwDocStat& rStat) = 0;
+    virtual void UpdateDocStat() = 0;
 
 protected:
     virtual ~IDocumentStatistics() {};
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 9e8f3a9..ead098d 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -899,8 +899,9 @@ public:
     */
     virtual void DocInfoChgd();
     virtual const SwDocStat &GetDocStat() const;
+    virtual const SwDocStat &GetUpdatedDocStat();
     virtual void SetDocStat(const SwDocStat& rStat);
-    virtual void UpdateDocStat(SwDocStat& rStat);
+    virtual void UpdateDocStat();
 
     /** IDocumentState
     */
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 14ea40e..ab77265 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -374,7 +374,8 @@ public:
     void SetUndoNoResetModified();
 
     // Document - Statistics
-    void UpdateDocStat( SwDocStat& rStat );
+    void UpdateDocStat();
+    const SwDocStat &GetUpdatedDocStat();
 
     void    Insert(const SwTOXMark& rMark);
 
diff --git a/sw/qa/core/swdoc-test.cxx b/sw/qa/core/swdoc-test.cxx
index 41b82c9..2e53d26 100644
--- a/sw/qa/core/swdoc-test.cxx
+++ b/sw/qa/core/swdoc-test.cxx
@@ -187,9 +187,7 @@ void SwDocTest::testDocStat()
 
     CPPUNIT_ASSERT_MESSAGE("Should still be non-updated 0 count", m_pDoc->GetDocStat().nChar == 0);
 
-    SwDocStat aDocStat = m_pDoc->GetDocStat();
-    m_pDoc->UpdateDocStat(aDocStat);
-
+    SwDocStat aDocStat = m_pDoc->GetUpdatedDocStat();
     sal_uLong nLen = static_cast<sal_uLong>(sText.getLength());
 
     CPPUNIT_ASSERT_MESSAGE("Should now have updated count", aDocStat.nChar == nLen);
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 8b1c82f..34d7a96 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1073,6 +1073,15 @@ const SwDocStat& SwDoc::GetDocStat() const
     return *pDocStat;
 }
 
+const SwDocStat& SwDoc::GetUpdatedDocStat()
+{
+    if (pDocStat->bModified)
+    {
+        UpdateDocStat();
+    }
+    return *pDocStat;
+}
+
 struct _PostItFld : public _SetGetExpFld
 {
     _PostItFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld,  const SwIndex* pIdx = 0 )
@@ -1707,14 +1716,14 @@ void SwDoc::CalculatePagePairsForProspectPrinting(
 }
 
 /*************************************************************************
- *            void UpdateDocStat( const SwDocStat& rStat );
+ *            void UpdateDocStat();
  *************************************************************************/
-void SwDoc::UpdateDocStat( SwDocStat& rStat )
+void SwDoc::UpdateDocStat()
 {
-    if( rStat.bModified )
+    if( pDocStat->bModified )
     {
-        rStat.Reset();
-        rStat.nPara = 0;        // Default ist auf 1 !!
+        pDocStat->Reset();
+        pDocStat->nPara = 0;        // Default ist auf 1 !!
         SwNode* pNd;
 
         for( sal_uLong i = GetNodes().Count(); i; )
@@ -1722,11 +1731,11 @@ void SwDoc::UpdateDocStat( SwDocStat& rStat )
             switch( ( pNd = GetNodes()[ --i ])->GetNodeType() )
             {
             case ND_TEXTNODE:
-                ((SwTxtNode*)pNd)->CountWords( rStat, 0, ((SwTxtNode*)pNd)->GetTxt().Len() );
+                ((SwTxtNode*)pNd)->CountWords( *pDocStat, 0, ((SwTxtNode*)pNd)->GetTxt().Len() );
                 break;
-            case ND_TABLENODE:      ++rStat.nTbl;   break;
-            case ND_GRFNODE:        ++rStat.nGrf;   break;
-            case ND_OLENODE:        ++rStat.nOLE;   break;
+            case ND_TABLENODE:      ++pDocStat->nTbl;   break;
+            case ND_GRFNODE:        ++pDocStat->nGrf;   break;
+            case ND_OLENODE:        ++pDocStat->nOLE;   break;
             case ND_SECTIONNODE:    break;
             }
         }
@@ -1741,36 +1750,35 @@ void SwDoc::UpdateDocStat( SwDocStat& rStat )
                 {
                     SwPostItField const * const pField(
                         static_cast<SwPostItField const*>(pFmtFld->GetFld()));
-                    rStat.nAllPara += pField->GetNumberOfParagraphs();
+                    pDocStat->nAllPara += pField->GetNumberOfParagraphs();
                 }
             }
         }
 
-        rStat.nPage     = GetCurrentLayout() ? GetCurrentLayout()->GetPageNum() : 0;    //swmod 080218
-        rStat.bModified = sal_False;
-        SetDocStat( rStat );
+        pDocStat->nPage     = GetCurrentLayout() ? GetCurrentLayout()->GetPageNum() : 0;    //swmod 080218
+        pDocStat->bModified = sal_False;
 
-        com::sun::star::uno::Sequence < com::sun::star::beans::NamedValue > aStat( rStat.nPage ? 8 : 7);
+        com::sun::star::uno::Sequence < com::sun::star::beans::NamedValue > aStat( pDocStat->nPage ? 8 : 7);
         sal_Int32 n=0;
         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TableCount"));
-        aStat[n++].Value <<= (sal_Int32)rStat.nTbl;
+        aStat[n++].Value <<= (sal_Int32)pDocStat->nTbl;
         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageCount"));
-        aStat[n++].Value <<= (sal_Int32)rStat.nGrf;
+        aStat[n++].Value <<= (sal_Int32)pDocStat->nGrf;
         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ObjectCount"));
-        aStat[n++].Value <<= (sal_Int32)rStat.nOLE;
-        if ( rStat.nPage )
+        aStat[n++].Value <<= (sal_Int32)pDocStat->nOLE;
+        if ( pDocStat->nPage )
         {
             aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PageCount"));
-            aStat[n++].Value <<= (sal_Int32)rStat.nPage;
+            aStat[n++].Value <<= (sal_Int32)pDocStat->nPage;
         }
         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParagraphCount"));
-        aStat[n++].Value <<= (sal_Int32)rStat.nPara;
+        aStat[n++].Value <<= (sal_Int32)pDocStat->nPara;
         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WordCount"));
-        aStat[n++].Value <<= (sal_Int32)rStat.nWord;
+        aStat[n++].Value <<= (sal_Int32)pDocStat->nWord;
         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharacterCount"));
-        aStat[n++].Value <<= (sal_Int32)rStat.nChar;
+        aStat[n++].Value <<= (sal_Int32)pDocStat->nChar;
         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NonWhitespaceCharacterCount"));
-        aStat[n++].Value <<= (sal_Int32)rStat.nCharExcludingSpaces;
+        aStat[n++].Value <<= (sal_Int32)pDocStat->nCharExcludingSpaces;
 
         // For e.g. autotext documents there is no pSwgInfo (#i79945)
         SfxObjectShell * const pObjShell( GetDocShell() );
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index 7968ef4..e1a1a8a 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -489,17 +489,25 @@ String SwEditShell::GetCurWord()
 }
 
 /****************************************************************************
- *           void SwEditShell::UpdateDocStat( SwDocStat& rStat )
+ *           void SwEditShell::UpdateDocStat()
  ****************************************************************************/
 
 
-void SwEditShell::UpdateDocStat( SwDocStat& rStat )
+void SwEditShell::UpdateDocStat( )
 {
     StartAllAction();
-    GetDoc()->UpdateDocStat( rStat );
+    GetDoc()->UpdateDocStat( );
     EndAllAction();
 }
 
+const SwDocStat& SwEditShell::GetUpdatedDocStat()
+{
+    StartAllAction();
+    const SwDocStat &rRet = GetDoc()->GetUpdatedDocStat();
+    EndAllAction();
+    return rRet;
+}
+
 // OPT: eddocinl.cxx
 
 
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 5ffd6f3..4206c76 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -2662,8 +2662,7 @@ void SwXTextFieldTypes::refresh(void)  throw( uno::RuntimeException )
     if(!IsValid())
         throw uno::RuntimeException();
     UnoActionContext aContext(GetDoc());
-    SwDocStat aDocStat;
-    GetDoc()->UpdateDocStat(aDocStat);
+    GetDoc()->UpdateDocStat();
     GetDoc()->UpdateFlds(0, sal_False);
 
     // call refresh listeners
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 45c7f95..9a8d77a 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -869,8 +869,7 @@ if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( sal_False ).nNode.GetIndex() )
 
         if( bUpdateDocStat )
         {
-            SwDocStat aStat( pDoc->GetDocStat() );
-            pDoc->UpdateDocStat( aStat );
+            pDoc->UpdateDocStat();
         }
     }
 
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 5f8fd91..569a410 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -279,13 +279,11 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
 
     SetExtended( bExtended );
 
-    SwDocStat aDocStat( pDoc->GetDocStat() );
     if( (getExportFlags() & EXPORT_META) != 0 )
     {
         // Update doc stat, so that correct values are exported and
         // the progress works correctly.
-        if( aDocStat.bModified )
-            pDoc->UpdateDocStat( aDocStat );
+        pDoc->UpdateDocStat();
 
         SfxObjectShell* pObjSh = pDoc->GetDocShell();
         if( pObjSh )
@@ -305,11 +303,6 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
             // - page styles: 2 (TODO: not now!) + 2 for each paragraph
             // - paragraph: 2 (1 for automatic styles and one for content)
 
-            // If required, update doc stat, so that
-            // the progress works correctly.
-            if( aDocStat.bModified )
-                pDoc->UpdateDocStat( aDocStat );
-
             // count each item once, and then multiply by two to reach the
             // figures given above
             // The styles in pDoc also count the default style that never
@@ -320,7 +313,7 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
             nRef += pDoc->GetTxtFmtColls()->Count() - 1;
             nRef *= 2; // for the above styles, xmloff will increment by 2!
             // #i93174#: count all paragraphs for the progress bar
-            nRef += aDocStat.nAllPara; // 1: only content, no autostyle
+            nRef += pDoc->GetUpdatedDocStat().nAllPara; // 1: only content, no autostyle
             pProgress->SetReference( nRef );
             pProgress->SetValue( 0 );
         }
diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx
index 0b3bec5..793b912 100644
--- a/sw/source/ui/app/docsh.cxx
+++ b/sw/source/ui/app/docsh.cxx
@@ -606,8 +606,7 @@ sal_Bool SwDocShell::ConvertTo( SfxMedium& rMedium )
     }
 
     // #i76360# Update document statistics
-    SwDocStat aDocStat( pDoc->GetDocStat() );;
-    pDoc->UpdateDocStat( aDocStat );
+    pDoc->UpdateDocStat();
 
     CalcLayoutForOLEObjects();  // format for OLE objets
     // #i62875#
diff --git a/sw/source/ui/dialog/docstdlg.cxx b/sw/source/ui/dialog/docstdlg.cxx
index 2b199b4..5dafb36 100644
--- a/sw/source/ui/dialog/docstdlg.cxx
+++ b/sw/source/ui/dialog/docstdlg.cxx
@@ -149,8 +149,7 @@ void SwDocStatPage::Update()
 
     SwWait aWait( *pSh->GetDoc()->GetDocShell(), sal_True );
     pSh->StartAction();
-    aDocStat = pSh->GetDoc()->GetDocStat();
-    pSh->GetDoc()->UpdateDocStat( aDocStat );
+    aDocStat = pSh->GetDoc()->GetUpdatedDocStat();
     pSh->EndAction();
 
     SetData(aDocStat);
diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx
index 1753f9b..8b03568 100644
--- a/sw/source/ui/shells/annotsh.cxx
+++ b/sw/source/ui/shells/annotsh.cxx
@@ -412,12 +412,12 @@ void SwAnnotationShell::Exec( SfxRequest &rReq )
         {
             SwWrtShell &rSh = rView.GetWrtShell();
             SwDocStat aCurr;
-            SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
+            SwDocStat aDocStat;
             {
                 SwWait aWait( *rView.GetDocShell(), sal_True );
                 rSh.StartAction();
                 rSh.CountWords( aCurr );
-                rSh.UpdateDocStat( aDocStat );
+                aDocStat = rSh.GetUpdatedDocStat();
                 rSh.EndAction();
             }
 
diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx
index 6bb2f67..4659fac 100644
--- a/sw/source/ui/shells/basesh.cxx
+++ b/sw/source/ui/shells/basesh.cxx
@@ -603,8 +603,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
             break;
         case FN_UPDATE_FIELDS:
             {
-                SwDocStat aDocStat;
-                rSh.UpdateDocStat(aDocStat);
+                rSh.UpdateDocStat();
                 rSh.EndAllTblBoxEdit();
                 rSh.ViewShell::UpdateFlds(sal_True);
 
diff --git a/sw/source/ui/shells/drawsh.cxx b/sw/source/ui/shells/drawsh.cxx
index dcf352b..3ee2bdb 100644
--- a/sw/source/ui/shells/drawsh.cxx
+++ b/sw/source/ui/shells/drawsh.cxx
@@ -233,12 +233,12 @@ void SwDrawShell::Execute(SfxRequest &rReq)
         case FN_WORDCOUNT_DIALOG:
         {
             SwDocStat aCurr;
-            SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
+            SwDocStat aDocStat;
             {
                 SwWait aWait( *GetView().GetDocShell(), sal_True );
                 rSh.StartAction();
                 rSh.CountWords( aCurr );
-                rSh.UpdateDocStat( aDocStat );
+                aDocStat = rSh.GetUpdatedDocStat();
                 rSh.EndAction();
             }
 
diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx
index 0deab44..47a6b1a 100644
--- a/sw/source/ui/shells/drwtxtex.cxx
+++ b/sw/source/ui/shells/drwtxtex.cxx
@@ -347,12 +347,12 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
         case FN_WORDCOUNT_DIALOG:
         {
             SwDocStat aCurr;
-            SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
+            SwDocStat aDocStat;
             {
                 SwWait aWait( *GetView().GetDocShell(), sal_True );
                 rSh.StartAction();
                 rSh.CountWords( aCurr );
-                rSh.UpdateDocStat( aDocStat );
+                aDocStat = rSh.GetUpdatedDocStat();
                 rSh.EndAction();
             }
 
diff --git a/sw/source/ui/shells/frmsh.cxx b/sw/source/ui/shells/frmsh.cxx
index 9763e08..ce35e49 100644
--- a/sw/source/ui/shells/frmsh.cxx
+++ b/sw/source/ui/shells/frmsh.cxx
@@ -419,12 +419,12 @@ void SwFrameShell::Execute(SfxRequest &rReq)
         case FN_WORDCOUNT_DIALOG:
         {
             SwDocStat aCurr;
-            SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
+            SwDocStat aDocStat;
             {
                 SwWait aWait( *GetView().GetDocShell(), sal_True );
                 rSh.StartAction();
                 rSh.CountWords( aCurr );
-                rSh.UpdateDocStat( aDocStat );
+                aDocStat = rSh.GetUpdatedDocStat();
                 rSh.EndAction();
             }
 
diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx
index a7ff278..493485b 100644
--- a/sw/source/ui/shells/textsh1.cxx
+++ b/sw/source/ui/shells/textsh1.cxx
@@ -1280,12 +1280,12 @@ void SwTextShell::Execute(SfxRequest &rReq)
     {
         SwWrtShell &rSh = GetShell();
         SwDocStat aCurr;
-        SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
+        SwDocStat aDocStat;
         {
             SwWait aWait( *GetView().GetDocShell(), sal_True );
             rSh.StartAction();
             rSh.CountWords( aCurr );
-            rSh.UpdateDocStat( aDocStat );
+            aDocStat = rSh.GetUpdatedDocStat();
             rSh.EndAction();
         }
 
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index 418dbf0..67fa51f 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -2020,15 +2020,13 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
         case  WID_DOC_PARA_COUNT     :
         case  WID_DOC_WORD_COUNT     :
         {
-            SwDocStat aStat(pDocShell->GetDoc()->GetDocStat());
-            if(aStat.bModified)
-                pDocShell->GetDoc()->UpdateDocStat( aStat );
+            const SwDocStat& rStat(pDocShell->GetDoc()->GetUpdatedDocStat());
             sal_Int32 nValue;
             switch(pEntry->nWID)
             {
-                case  WID_DOC_CHAR_COUNT     :nValue = aStat.nChar;break;
-                case  WID_DOC_PARA_COUNT     :nValue = aStat.nPara;break;
-                case  WID_DOC_WORD_COUNT     :nValue = aStat.nWord;break;
+                case  WID_DOC_CHAR_COUNT     :nValue = rStat.nChar;break;
+                case  WID_DOC_PARA_COUNT     :nValue = rStat.nPara;break;
+                case  WID_DOC_WORD_COUNT     :nValue = rStat.nWord;break;
             }
             aAny <<= nValue;
         }


More information about the Libreoffice-commits mailing list