Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi

This patch remove unnecessary parameter SwDocStat& rStat to the method
IDocumentStatistics::UpdateDocStat and also limit copy of SwDocStat during
file saving and statistic dialog.


I will look in the next weeks if it's possible to simplify the code and, if
it's useful, I will limit the memories allocations.

Thanks

-- 
Arnaud Versini
From a43d92e0ae4f42651473ff003d6536c1af7d17cb Mon Sep 17 00:00:00 2001
From: Arnaud Versini <arnaud.versini@gmail.com>
Date: Wed, 17 Aug 2011 20:27:25 +0200
Subject: [PATCH] Remove unecessary parameter to
 IDocumentStatistics::UpdateDocStat()

---
 sw/inc/IDocumentStatistics.hxx      |    2 +-
 sw/inc/doc.hxx                      |    2 +-
 sw/inc/editsh.hxx                   |    2 +-
 sw/source/core/doc/doc.cxx          |   45 +++++++++++++++++------------------
 sw/source/core/edit/editsh.cxx      |    6 ++--
 sw/source/core/unocore/unofield.cxx |    3 +-
 sw/source/filter/html/swhtml.cxx    |    3 +-
 sw/source/filter/xml/xmlexp.cxx     |    6 ++--
 sw/source/ui/app/docsh.cxx          |    3 +-
 sw/source/ui/dialog/docstdlg.cxx    |    2 +-
 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       |    2 +-
 17 files changed, 47 insertions(+), 52 deletions(-)

diff --git a/sw/inc/IDocumentStatistics.hxx b/sw/inc/IDocumentStatistics.hxx
index 152d382..f19ba55 100644
--- a/sw/inc/IDocumentStatistics.hxx
+++ b/sw/inc/IDocumentStatistics.hxx
@@ -48,7 +48,7 @@
 
     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..b86e4c9 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -900,7 +900,7 @@ public:
     virtual void DocInfoChgd();
     virtual const SwDocStat &GetDocStat() const;
     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..6666efb 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -374,7 +374,7 @@ public:
     void SetUndoNoResetModified();
 
     // Document - Statistics
-    void UpdateDocStat( SwDocStat& rStat );
+    void UpdateDocStat();
 
     void    Insert(const SwTOXMark& rMark);
 
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 8b1c82f..dac52ea 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1707,14 +1707,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 +1722,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 +1741,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..d13c8af 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -489,14 +489,14 @@ 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();
 }
 
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..1f3bb56 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -279,13 +279,13 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
 
     SetExtended( bExtended );
 
-    SwDocStat aDocStat( pDoc->GetDocStat() );
+    const 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 )
@@ -308,7 +308,7 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
             // If required, update doc stat, so that
             // the progress works correctly.
             if( aDocStat.bModified )
-                pDoc->UpdateDocStat( aDocStat );
+                pDoc->UpdateDocStat();
 
             // count each item once, and then multiply by two to reach the
             // figures given above
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..0c050a3 100644
--- a/sw/source/ui/dialog/docstdlg.cxx
+++ b/sw/source/ui/dialog/docstdlg.cxx
@@ -150,7 +150,7 @@ void SwDocStatPage::Update()
     SwWait aWait( *pSh->GetDoc()->GetDocShell(), sal_True );
     pSh->StartAction();
     aDocStat = pSh->GetDoc()->GetDocStat();
-    pSh->GetDoc()->UpdateDocStat( aDocStat );
+    pSh->GetDoc()->UpdateDocStat();
     pSh->EndAction();
 
     SetData(aDocStat);
diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx
index 1753f9b..ed2b054 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() );
+            const SwDocStat& aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
             {
                 SwWait aWait( *rView.GetDocShell(), sal_True );
                 rSh.StartAction();
                 rSh.CountWords( aCurr );
-                rSh.UpdateDocStat( aDocStat );
+                rSh.UpdateDocStat();
                 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..a4565d8 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() );
+            const SwDocStat& aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
             {
                 SwWait aWait( *GetView().GetDocShell(), sal_True );
                 rSh.StartAction();
                 rSh.CountWords( aCurr );
-                rSh.UpdateDocStat( aDocStat );
+                rSh.UpdateDocStat();
                 rSh.EndAction();
             }
 
diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx
index 0deab44..c514f40 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() );
+            const SwDocStat& aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
             {
                 SwWait aWait( *GetView().GetDocShell(), sal_True );
                 rSh.StartAction();
                 rSh.CountWords( aCurr );
-                rSh.UpdateDocStat( aDocStat );
+                rSh.UpdateDocStat();
                 rSh.EndAction();
             }
 
diff --git a/sw/source/ui/shells/frmsh.cxx b/sw/source/ui/shells/frmsh.cxx
index 9763e08..489466a 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() );
+            const SwDocStat& aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
             {
                 SwWait aWait( *GetView().GetDocShell(), sal_True );
                 rSh.StartAction();
                 rSh.CountWords( aCurr );
-                rSh.UpdateDocStat( aDocStat );
+                rSh.UpdateDocStat();
                 rSh.EndAction();
             }
 
diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx
index a7ff278..058c7c8 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() );
+        const SwDocStat& aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
         {
             SwWait aWait( *GetView().GetDocShell(), sal_True );
             rSh.StartAction();
             rSh.CountWords( aCurr );
-            rSh.UpdateDocStat( aDocStat );
+            rSh.UpdateDocStat();
             rSh.EndAction();
         }
 
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index 418dbf0..754a021 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -2022,7 +2022,7 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
         {
             SwDocStat aStat(pDocShell->GetDoc()->GetDocStat());
             if(aStat.bModified)
-                pDocShell->GetDoc()->UpdateDocStat( aStat );
+                pDocShell->GetDoc()->UpdateDocStat();
             sal_Int32 nValue;
             switch(pEntry->nWID)
             {
-- 
1.7.5.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.