sw/inc/doc.hxx                |    1 +
 sw/source/core/doc/docfld.cxx |   14 ++++++++++++++
 sw/source/ui/uiview/view.cxx  |   13 ++++++++-----
 3 files changed, 23 insertions(+), 5 deletions(-)

New commits:
commit 30f84257b34eb956027c21934ec9fa63cb25fcf4
Author: Caolán McNamara <caol...@redhat.com>
Date:   Mon May 14 16:07:05 2012 +0100

    Resolves: fdo#49897 add+use SwDoc::containsUpdatableFields
    
    Change-Id: I03ab6367a40ddc5748a499c4e2c7f108a3ef8a08
    Signed-off-by: Michael Meeks <michael.me...@suse.com>

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 29be2a7..7943925 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -841,6 +841,7 @@ public:
        @return pointer to field at the given position or NULL in case no field 
is found
     */
     static SwTxtFld* GetTxtFld(const SwPosition& rPos);
+    bool containsUpdatableFields();
 
     /** IDocumentContentOperations
     */
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 019e160..b7c6549 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -415,6 +415,20 @@ void SwDoc::UpdateRefFlds( SfxPoolItem* pHt )
             pFldType->ModifyNotification( 0, pHt );
 }
 
+//For simplicity assume that all field types have updatable contents so
+//optimization currently only available when no fields exist.
+bool SwDoc::containsUpdatableFields()
+{
+    for (sal_uInt16 i = 0; i < pFldTypes->Count(); ++i)
+    {
+        SwFieldType* pFldType = (*pFldTypes)[i];
+        SwIterator<SwFmtFld,SwFieldType> aIter(*pFldType);
+        if (aIter.First())
+            return true;
+    }
+    return false;
+}
+
 void SwDoc::UpdateTblFlds( SfxPoolItem* pHt )
 {
     OSL_ENSURE( !pHt || RES_TABLEFML_UPDATE  == pHt->Which(),
diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx
index e291c19..b387b34 100644
--- a/sw/source/ui/uiview/view.cxx
+++ b/sw/source/ui/uiview/view.cxx
@@ -966,11 +966,14 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* 
pOldSh )
 
     if( pWrtShell->GetDoc()->IsUpdateExpFld() )
     {
-        SET_CURR_SHELL( pWrtShell );
-        pWrtShell->StartAction();
-        pWrtShell->CalcLayout();
-        pWrtShell->GetDoc()->UpdateFlds(NULL, false);
-        pWrtShell->EndAction();
+        if (pWrtShell->GetDoc()->containsUpdatableFields())
+        {
+            SET_CURR_SHELL( pWrtShell );
+            pWrtShell->StartAction();
+            pWrtShell->CalcLayout();
+            pWrtShell->GetDoc()->UpdateFlds(NULL, false);
+            pWrtShell->EndAction();
+        }
         pWrtShell->GetDoc()->SetUpdateExpFldStat( sal_False );
     }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to