[Libreoffice-commits] core.git: Branch 'feature/refactor-god-objects' - sw/inc sw/Library_sw.mk sw/source

Valentin Kettner vakevk+libreoffice at gmail.com
Tue Jun 10 15:16:02 PDT 2014


Rebased ref, commits from common ancestor:
commit 78321f0dabbbbbcbc124d22d28c791a535a06333
Author: Valentin Kettner <vakevk+libreoffice at gmail.com>
Date:   Tue Jun 10 20:57:05 2014 +0200

    Refactored IDocumentTimerAccess in SwDoc into DocumentTimerManager.
    
    Change-Id: Idb39ef2cdc34e0c0e7853de0a656f579ca3528da

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index df08692..dceca91 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -189,6 +189,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/core/doc/DocumentSettingManager \
     sw/source/core/doc/DocumentDrawModelManager \
     sw/source/core/doc/DocumentChartDataProviderManager \
+    sw/source/core/doc/DocumentTimerManager \
     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 ad58225..237a515 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -31,7 +31,6 @@
 #include <IDocumentStatistics.hxx>
 #include <IDocumentState.hxx>
 #include <IDocumentLayoutAccess.hxx>
-#include <IDocumentTimerAccess.hxx>
 #include <IDocumentOutlineNodes.hxx>
 #include <IDocumentListItems.hxx>
 
@@ -204,6 +203,7 @@ namespace sw {
     class DocumentDeviceManager;
     class DocumentDrawModelManager;
     class DocumentChartDataProviderManager;
+    class DocumentTimerManager;
 }
 
 namespace com { namespace sun { namespace star {
@@ -250,7 +250,6 @@ class SW_DLLPUBLIC SwDoc :
     public IDocumentStatistics,
     public IDocumentState,
     public IDocumentLayoutAccess,
-    public IDocumentTimerAccess,
     public IDocumentListItems,
     public IDocumentOutlineNodes,
     public IDocumentListsAccess,
@@ -268,7 +267,6 @@ class SW_DLLPUBLIC SwDoc :
     /* @@@MAINTAINABILITY-HORROR@@@
        Timer should not be members of the model
     */
-    Timer       maIdleTimer;             //< Own IdleTimer
     Timer       maOLEModifiedTimer;      //< Timer for update modified OLE-Objecs
     Timer       maStatsUpdateTimer;      //< Timer for asynchronous stats calculation
     SwDBData    maDBData;                //< database descriptor
@@ -286,6 +284,7 @@ class SW_DLLPUBLIC SwDoc :
     const ::boost::scoped_ptr< ::sw::DocumentSettingManager > m_pDocumentSettingManager;
     const ::boost::scoped_ptr< ::sw::DocumentChartDataProviderManager > m_pDocumentChartDataProviderManager;
     ::boost::scoped_ptr< ::sw::DocumentDeviceManager > m_pDeviceAccess;
+    const ::boost::scoped_ptr< ::sw::DocumentTimerManager > m_pDocumentTimerManager;
 
     // Pointer
     SwFrmFmt        *mpDfltFrmFmt;       //< Default formats.
@@ -392,7 +391,6 @@ private:
     sal_uInt32  mnRsidRoot;          //< session ID when the document was created
 
     sal_Int32   mReferenceCount;
-    sal_Int32   mIdleBlockCount;
     sal_Int8    mnLockExpFld;        //< If != 0 UpdateExpFlds() has no effect!
 
     bool mbGlossDoc              : 1;    //< TRUE: glossary document.
@@ -437,8 +435,6 @@ private:
     //       Thus, certain adjustment needed during formatting for these kind of anchored objects.
     bool mbContainsAtPageObjWithContentAnchor : 1;
 
-    bool mbStartIdleTimer;                    //< idle timer mode start/stop
-
     static SwAutoCompleteWord *mpACmpltWords;  //< List of all words for AutoComplete
 
     // private methods
@@ -510,8 +506,6 @@ private:
     bool _SelectNextRubyChars( SwPaM& rPam, SwRubyListEntry& rRubyEntry,
                                 sal_uInt16 nMode );
 
-    // Our own 'IdleTimer' calls the following method
-    DECL_LINK( DoIdleJobs, Timer * );
     // CharTimer calls this method.
     void DoUpdateAllCharts();
     DECL_LINK( DoUpdateModifiedOLE, Timer * );
@@ -776,11 +770,9 @@ public:
     void ClearSwLayouterEntries();
 
     // IDocumentTimerAccess
-    virtual void StartIdling() SAL_OVERRIDE;
-    virtual void StopIdling() SAL_OVERRIDE;
-    virtual void BlockIdling() SAL_OVERRIDE;
-    virtual void UnblockIdling() SAL_OVERRIDE;
-    virtual void StartBackgroundJobs() SAL_OVERRIDE;
+    // Our own 'IdleTimer' calls the following method
+    IDocumentTimerAccess const & getIDocumentTimerAccess() const;
+    IDocumentTimerAccess & getIDocumentTimerAccess();
 
     // IDocumentChartDataProviderAccess
     IDocumentChartDataProviderAccess const & getIDocumentChartDataProviderAccess() const;
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index 6996523..99de194 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -19,6 +19,7 @@
 
 #include <doc.hxx>
 #include <DocumentSettingManager.hxx> //For SwFmt::getIDocumentSettingAccess()
+#include <IDocumentTimerAccess.hxx>
 #include <fmtcolfunc.hxx>
 #include <frame.hxx>
 #include <format.hxx>
@@ -759,7 +760,7 @@ const IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() const { ret
 IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() { return & GetDoc()->getIDocumentDrawModelAccess(); }
 const IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() const { return GetDoc(); }
 IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() { return GetDoc(); }
-IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return GetDoc(); }
+IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return & GetDoc()->getIDocumentTimerAccess(); }
 IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return GetDoc(); }
 IDocumentChartDataProviderAccess* SwFmt::getIDocumentChartDataProviderAccess() { return & GetDoc()->getIDocumentChartDataProviderAccess(); }
 
diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx
new file mode 100644
index 0000000..d99f3da
--- /dev/null
+++ b/sw/source/core/doc/DocumentTimerManager.cxx
@@ -0,0 +1,175 @@
+/* -*- 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 <DocumentTimerManager.hxx>
+
+#include <doc.hxx>
+#include <DocumentSettingManager.hxx>
+#include <rootfrm.hxx>
+#include <viewsh.hxx>
+#include <unotools/lingucfg.hxx>
+#include <unotools/linguprops.hxx>
+#include <set>
+#include <fldupde.hxx>
+#include <sfx2/progress.hxx>
+#include <viewopt.hxx>
+#include <docsh.hxx>
+#include <docfld.hxx>
+#include <fldbas.hxx>
+#include <rtl/logfile.hxx>
+
+namespace sw
+{
+
+DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rSwdoc( i_rSwdoc ),
+                                                                mbStartIdleTimer( false ),
+                                                                mIdleBlockCount( 0 )
+{
+    maIdleTimer.SetTimeout( 600 );
+    maIdleTimer.SetTimeoutHdl( LINK( this, DocumentTimerManager, DoIdleJobs) );
+}
+
+void DocumentTimerManager::StartIdling()
+{
+    mbStartIdleTimer = true;
+    if( !mIdleBlockCount )
+        maIdleTimer.Start();
+}
+
+void DocumentTimerManager::StopIdling()
+{
+    mbStartIdleTimer = false;
+    maIdleTimer.Stop();
+}
+
+void DocumentTimerManager::BlockIdling()
+{
+    maIdleTimer.Stop();
+    ++mIdleBlockCount;
+}
+
+void DocumentTimerManager::UnblockIdling()
+{
+    --mIdleBlockCount;
+    if( !mIdleBlockCount && mbStartIdleTimer && !maIdleTimer.IsActive() )
+        maIdleTimer.Start();
+}
+
+void DocumentTimerManager::StartBackgroundJobs() {
+    // Trigger DoIdleJobs(), asynchronously.
+    maIdleTimer.Start();
+}
+
+IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer *, pTimer )
+{
+#ifdef TIMELOG
+    static ::rtl::Logfile* pModLogFile = 0;
+    if( !pModLogFile )
+        pModLogFile = new ::rtl::Logfile( "First DoIdleJobs" );
+#endif
+
+    SwRootFrm* pTmpRoot = m_rSwdoc.GetCurrentLayout();
+    if( pTmpRoot &&
+        !SfxProgress::GetActiveProgress( m_rSwdoc.GetDocShell() ) )
+    {
+        SwViewShell *pSh, *pStartSh;
+        pSh = pStartSh = m_rSwdoc.GetCurrentViewShell();
+        do {
+            if( pSh->ActionPend() )
+            {
+                pTimer->Start();
+                return 0;
+            }
+            pSh = (SwViewShell*)pSh->GetNext();
+        } while( pSh != pStartSh );
+
+        if( pTmpRoot->IsNeedGrammarCheck() )
+        {
+            bool bIsOnlineSpell = pSh->GetViewOptions()->IsOnlineSpell();
+            bool bIsAutoGrammar = false;
+            SvtLinguConfig().GetProperty( OUString(
+                        UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar;
+
+            if (bIsOnlineSpell && bIsAutoGrammar)
+                StartGrammarChecking( m_rSwdoc );
+        }
+        std::set<SwRootFrm*> aAllLayouts = m_rSwdoc.GetAllLayouts();
+        std::set<SwRootFrm*>::iterator pLayIter = aAllLayouts.begin();
+        for ( ;pLayIter != aAllLayouts.end();++pLayIter )
+        {
+            if ((*pLayIter)->IsIdleFormat())
+            {
+                (*pLayIter)->GetCurrShell()->LayoutIdle();
+
+                // Defer the remaining work.
+                pTimer->Start();
+                return 0;
+            }
+        }
+
+        SwFldUpdateFlags nFldUpdFlag = m_rSwdoc.GetDocumentSettingManager().getFieldUpdateFlags(true);
+        if( ( AUTOUPD_FIELD_ONLY == nFldUpdFlag
+                    || AUTOUPD_FIELD_AND_CHARTS == nFldUpdFlag ) &&
+                m_rSwdoc.GetUpdtFlds().IsFieldsDirty()
+                // If we switch the field name the Fields are not updated.
+                // So the "backgorund update" should always be carried out
+                /* && !pStartSh->GetViewOptions()->IsFldName()*/ )
+        {
+            if ( m_rSwdoc.GetUpdtFlds().IsInUpdateFlds() ||
+                 m_rSwdoc.IsExpFldsLocked() )
+            {
+                pTimer->Start();
+                return 0;
+            }
+
+            //  Action brackets!
+            m_rSwdoc.GetUpdtFlds().SetInUpdateFlds( true );
+
+            pTmpRoot->StartAllAction();
+
+            // no jump on update of fields #i85168#
+            const bool bOldLockView = pStartSh->IsViewLocked();
+            pStartSh->LockView( true );
+
+            m_rSwdoc.GetSysFldType( RES_CHAPTERFLD )->ModifyNotification( 0, 0 );    // ChapterField
+            m_rSwdoc.UpdateExpFlds( 0, false );      // Updates ExpressionFields
+            m_rSwdoc.UpdateTblFlds(NULL);                // Tables
+            m_rSwdoc.UpdateRefFlds(NULL);                // References
+
+            pTmpRoot->EndAllAction();
+
+            pStartSh->LockView( bOldLockView );
+
+            m_rSwdoc.GetUpdtFlds().SetInUpdateFlds( false );
+            m_rSwdoc.GetUpdtFlds().SetFieldsDirty( false );
+        }
+    }
+#ifdef TIMELOG
+    if( pModLogFile && 1 != (long)pModLogFile )
+        delete pModLogFile, ((long&)pModLogFile) = 1;
+#endif
+    return 0;
+}
+
+DocumentTimerManager::~DocumentTimerManager() {}
+
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 96634d4..c074acc 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -20,6 +20,9 @@
 #include <doc.hxx>
 #include <DocumentSettingManager.hxx>
 #include <DocumentDrawModelManager.hxx>
+#include <DocumentTimerManager.hxx>
+#include <DocumentDeviceManager.hxx>
+#include <DocumentChartDataProviderManager.hxx>
 #include <UndoManager.hxx>
 #include <hintids.hxx>
 
@@ -109,9 +112,6 @@
 #include <txtfrm.hxx>
 #include <attrhint.hxx>
 #include <view.hxx>
-#include <DocumentDeviceManager.hxx>
-#include <DocumentSettingManager.hxx>
-#include <DocumentChartDataProviderManager.hxx>
 
 #include <wdocsh.hxx>
 #include <prtopt.hxx>
@@ -219,17 +219,6 @@ IDocumentSettingAccess & SwDoc::getIDocumentSettingAccess()
     return *m_pDocumentSettingManager;
 }
 
-/* IDocumentChartDataProviderAccess */
-IDocumentChartDataProviderAccess const & SwDoc::getIDocumentChartDataProviderAccess() const
-{
-    return *m_pDocumentChartDataProviderManager;
-}
-
-IDocumentChartDataProviderAccess & SwDoc::getIDocumentChartDataProviderAccess()
-{
-    return *m_pDocumentChartDataProviderManager;
-}
-
 sal_uInt32 SwDoc::getRsid() const
 {
     return mnRsid;
@@ -262,6 +251,16 @@ void SwDoc::setRsidRoot( sal_uInt32 nVal )
     mnRsidRoot = nVal;
 }
 
+/* IDocumentChartDataProviderAccess */
+IDocumentChartDataProviderAccess const & SwDoc::getIDocumentChartDataProviderAccess() const
+{
+    return *m_pDocumentChartDataProviderManager;
+}
+
+IDocumentChartDataProviderAccess & SwDoc::getIDocumentChartDataProviderAccess()
+{
+    return *m_pDocumentChartDataProviderManager;
+}
 
 // IDocumentDeviceAccess
 IDocumentDeviceAccess const & SwDoc::getIDocumentDeviceAccess() const
@@ -274,6 +273,17 @@ IDocumentDeviceAccess & SwDoc::getIDocumentDeviceAccess()
     return *m_pDeviceAccess;
 }
 
+//IDocumentTimerAccess
+IDocumentTimerAccess const & SwDoc::getIDocumentTimerAccess() const
+{
+    return *m_pDocumentTimerManager;
+}
+
+IDocumentTimerAccess & SwDoc::getIDocumentTimerAccess()
+{
+    return *m_pDocumentTimerManager;
+}
+
 
 /* Implementations the next Interface here */
 
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 942ac12..ec409fd 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -1765,129 +1765,6 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel(
     return pNewFmt;
 }
 
-// IDocumentTimerAccess methods
-void SwDoc::StartIdling()
-{
-    mbStartIdleTimer = true;
-    if( !mIdleBlockCount )
-        maIdleTimer.Start();
-}
-
-void SwDoc::StopIdling()
-{
-    mbStartIdleTimer = false;
-    maIdleTimer.Stop();
-}
-
-void SwDoc::BlockIdling()
-{
-    maIdleTimer.Stop();
-    ++mIdleBlockCount;
-}
-
-void SwDoc::UnblockIdling()
-{
-    --mIdleBlockCount;
-    if( !mIdleBlockCount && mbStartIdleTimer && !maIdleTimer.IsActive() )
-        maIdleTimer.Start();
-}
-
-void SwDoc::StartBackgroundJobs() {
-    // Trigger DoIdleJobs(), asynchronously.
-    maIdleTimer.Start();
-}
-
-IMPL_LINK( SwDoc, DoIdleJobs, Timer *, pTimer )
-{
-#ifdef TIMELOG
-    static ::rtl::Logfile* pModLogFile = 0;
-    if( !pModLogFile )
-        pModLogFile = new ::rtl::Logfile( "First DoIdleJobs" );
-#endif
-
-    SwRootFrm* pTmpRoot = GetCurrentLayout();
-    if( pTmpRoot &&
-        !SfxProgress::GetActiveProgress( mpDocShell ) )
-    {
-        SwViewShell *pSh, *pStartSh;
-        pSh = pStartSh = GetCurrentViewShell();
-        do {
-            if( pSh->ActionPend() )
-            {
-                pTimer->Start();
-                return 0;
-            }
-            pSh = (SwViewShell*)pSh->GetNext();
-        } while( pSh != pStartSh );
-
-        if( pTmpRoot->IsNeedGrammarCheck() )
-        {
-            bool bIsOnlineSpell = pSh->GetViewOptions()->IsOnlineSpell();
-            bool bIsAutoGrammar = false;
-            SvtLinguConfig().GetProperty( OUString(
-                        UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar;
-
-            if (bIsOnlineSpell && bIsAutoGrammar)
-                StartGrammarChecking( *this );
-        }
-        std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
-        std::set<SwRootFrm*>::iterator pLayIter = aAllLayouts.begin();
-        for ( ;pLayIter != aAllLayouts.end();++pLayIter )
-        {
-            if ((*pLayIter)->IsIdleFormat())
-            {
-                (*pLayIter)->GetCurrShell()->LayoutIdle();
-
-                // Defer the remaining work.
-                pTimer->Start();
-                return 0;
-            }
-        }
-
-        SwFldUpdateFlags nFldUpdFlag = GetDocumentSettingManager().getFieldUpdateFlags(true);
-        if( ( AUTOUPD_FIELD_ONLY == nFldUpdFlag
-                    || AUTOUPD_FIELD_AND_CHARTS == nFldUpdFlag ) &&
-                GetUpdtFlds().IsFieldsDirty()
-                // If we switch the field name the Fields are not updated.
-                // So the "backgorund update" should always be carried out
-                /* && !pStartSh->GetViewOptions()->IsFldName()*/ )
-        {
-            if ( GetUpdtFlds().IsInUpdateFlds() ||
-                 IsExpFldsLocked() )
-            {
-                pTimer->Start();
-                return 0;
-            }
-
-            //  Action brackets!
-            GetUpdtFlds().SetInUpdateFlds( true );
-
-            pTmpRoot->StartAllAction();
-
-            // no jump on update of fields #i85168#
-            const bool bOldLockView = pStartSh->IsViewLocked();
-            pStartSh->LockView( true );
-
-            GetSysFldType( RES_CHAPTERFLD )->ModifyNotification( 0, 0 );    // ChapterField
-            UpdateExpFlds( 0, false );      // Updates ExpressionFields
-            UpdateTblFlds(NULL);                // Tables
-            UpdateRefFlds(NULL);                // References
-
-            pTmpRoot->EndAllAction();
-
-            pStartSh->LockView( bOldLockView );
-
-            GetUpdtFlds().SetInUpdateFlds( false );
-            GetUpdtFlds().SetFieldsDirty( false );
-        }
-    }
-#ifdef TIMELOG
-    if( pModLogFile && 1 != (long)pModLogFile )
-        delete pModLogFile, ((long&)pModLogFile) = 1;
-#endif
-    return 0;
-}
-
 IMPL_STATIC_LINK( SwDoc, BackgroundDone, SvxBrushItem*, EMPTYARG )
 {
     SwViewShell *pSh, *pStartSh;
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 6c61afc..57a45e4 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -91,6 +91,7 @@
 #include <DocumentSettingManager.hxx>
 #include <DocumentDrawModelManager.hxx>
 #include <DocumentChartDataProviderManager.hxx>
+#include <DocumentTimerManager.hxx>
 #include <unochart.hxx>
 #include <fldbas.hxx>
 
@@ -195,6 +196,7 @@ SwDoc::SwDoc()
     m_pDocumentSettingManager(new ::sw::DocumentSettingManager(*this)),
     m_pDocumentChartDataProviderManager( new sw::DocumentChartDataProviderManager( *this ) ),
     m_pDeviceAccess( new ::sw::DocumentDeviceManager( *this ) ),
+    m_pDocumentTimerManager( new ::sw::DocumentTimerManager( *this ) ),
     mpDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
     mpEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, mpDfltFrmFmt ) ),
     mpColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, mpDfltFrmFmt ) ),
@@ -244,7 +246,6 @@ SwDoc::SwDoc()
     mnAutoFmtRedlnCommentNo( 0 ),
     meRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)),
     mReferenceCount(0),
-    mIdleBlockCount(0),
     mnLockExpFld( 0 ),
     mbGlossDoc(false),
     mbModified(false),
@@ -277,7 +278,6 @@ SwDoc::SwDoc()
 #endif
     mbContainsAtPageObjWithContentAnchor(false), //#i119292#, fdo#37024
 
-    mbStartIdleTimer(false),
     mbReadOnly(false),
     meDocType(DOCTYPE_NATIVE)
 {
@@ -323,10 +323,6 @@ SwDoc::SwDoc()
     new SwTxtNode( SwNodeIndex( GetNodes().GetEndOfContent() ),
                     GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
 
-    // set the own IdleTimer
-    maIdleTimer.SetTimeout( 600 );
-    maIdleTimer.SetTimeoutHdl( LINK(this, SwDoc, DoIdleJobs) );
-
     maOLEModifiedTimer.SetTimeout( 1000 );
     maOLEModifiedTimer.SetTimeoutHdl( LINK( this, SwDoc, DoUpdateModifiedOLE ));
 
@@ -440,7 +436,7 @@ SwDoc::~SwDoc()
     SwFmtCharFmt aCharFmt(NULL);
     SetDefault(aCharFmt);
 
-    StopIdling();   // stop idle timer
+    getIDocumentTimerAccess().StopIdling();   // stop idle timer
     maStatsUpdateTimer.Stop();
 
     delete mpUnoCallBack, mpUnoCallBack = 0;
diff --git a/sw/source/core/inc/DocumentTimerManager.hxx b/sw/source/core/inc/DocumentTimerManager.hxx
new file mode 100644
index 0000000..6bd7fcd
--- /dev/null
+++ b/sw/source/core/inc/DocumentTimerManager.hxx
@@ -0,0 +1,70 @@
+/* -*- 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_DOCUMENTTIMERMANAGER_HXX
+#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTTIMERMANAGER_HX
+
+#include <IDocumentTimerAccess.hxx>
+#include <boost/utility.hpp>
+
+#include <vcl/timer.hxx>
+#include <sal/types.h>
+#include <tools/link.hxx>
+
+class SwDoc;
+
+namespace sw
+{
+
+class DocumentTimerManager : public IDocumentTimerAccess,
+                             public ::boost::noncopyable
+{
+public:
+
+    DocumentTimerManager( SwDoc& i_rSwdoc );
+
+    void StartIdling() SAL_OVERRIDE;
+
+    void StopIdling() SAL_OVERRIDE;
+
+    void BlockIdling() SAL_OVERRIDE;
+
+    void UnblockIdling() SAL_OVERRIDE;
+
+    void StartBackgroundJobs() SAL_OVERRIDE;
+
+    // Our own 'IdleTimer' calls the following method
+    DECL_LINK( DoIdleJobs, Timer * );
+
+    virtual ~DocumentTimerManager();
+
+private:
+
+     SwDoc& m_rSwdoc;
+
+     bool mbStartIdleTimer; //< idle timer mode start/stop
+     sal_Int32 mIdleBlockCount;
+     Timer maIdleTimer;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/docfld.hxx b/sw/source/core/inc/docfld.hxx
index 009e36f..ed8b479 100644
--- a/sw/source/core/inc/docfld.hxx
+++ b/sw/source/core/inc/docfld.hxx
@@ -22,6 +22,7 @@
 
 #include <calc.hxx>
 #include <doc.hxx>
+#include <IDocumentTimerAccess.hxx>
 #include <o3tl/sorted_vector.hxx>
 
 class SwTxtFld;
@@ -175,7 +176,7 @@ public:
 
         if (b)
         {
-            pDocument->StartBackgroundJobs();
+            pDocument->getIDocumentTimerAccess().StartBackgroundJobs();
         }
     }
 
diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index 78a95e5..fa4acdb 100644
--- a/sw/source/core/inc/rootfrm.hxx
+++ b/sw/source/core/inc/rootfrm.hxx
@@ -22,6 +22,7 @@
 #include "layfrm.hxx"
 #include <viewsh.hxx>
 #include <doc.hxx>
+#include <IDocumentTimerAccess.hxx>
 
 class SwCntntFrm;
 class SwViewShell;
@@ -211,7 +212,7 @@ public:
         // May be NULL if called from SfxBaseModel::dispose
         // (this happens in the build test 'rtfexport').
         if (lcl_pCurrShell != NULL)
-            lcl_pCurrShell->GetDoc()->StartBackgroundJobs();
+            lcl_pCurrShell->GetDoc()->getIDocumentTimerAccess().StartBackgroundJobs();
     }
     bool IsIdleFormat()  const { return bIdleFormat; }
     void ResetIdleFormat()     { bIdleFormat = false; }
@@ -227,7 +228,7 @@ public:
             // May be NULL if called from SfxBaseModel::dispose
             // (this happens in the build test 'rtfexport').
             if (lcl_pCurrShell != NULL)
-                lcl_pCurrShell->GetDoc()->StartBackgroundJobs();
+                lcl_pCurrShell->GetDoc()->getIDocumentTimerAccess().StartBackgroundJobs();
         }
     }
 
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 37f6dda..5206f7c 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -61,6 +61,7 @@
 #include <objectformatter.hxx>
 #include <switerator.hxx>
 #include <DocumentSettingManager.hxx>
+#include <IDocumentTimerAccess.hxx>
 
 // ftnfrm.cxx:
 void sw_RemoveFtns( SwFtnBossFrm* pBoss, bool bPageOnly, bool bEndNotes );
@@ -1162,7 +1163,7 @@ void _InsertCnt( SwLayoutFrm *pLay, SwDoc *pDoc,
                              sal_uLong nIndex, bool bPages, sal_uLong nEndIndex,
                              SwFrm *pPrv )
 {
-    pDoc->BlockIdling();
+    pDoc->getIDocumentTimerAccess().BlockIdling();
     SwRootFrm* pLayout = pLay->getRootFrm();
     const bool bOldCallbackActionEnabled = pLayout ? pLayout->IsCallbackActionEnabled() : sal_False;
     if( bOldCallbackActionEnabled )
@@ -1547,7 +1548,7 @@ void _InsertCnt( SwLayoutFrm *pLay, SwDoc *pDoc,
         }
     }
 
-    pDoc->UnblockIdling();
+    pDoc->getIDocumentTimerAccess().UnblockIdling();
     if( bOldCallbackActionEnabled )
         pLayout->SetCallbackActionEnabled( bOldCallbackActionEnabled );
 }


More information about the Libreoffice-commits mailing list