sw/Library_sw.mk | 1 sw/inc/doc.hxx | 19 ++----- sw/source/core/attr/format.cxx | 3 - sw/source/core/doc/DocumentTimerManager.cxx | 71 ++++++++++++++++++++++++++++ sw/source/core/doc/doc.cxx | 38 +++++++++----- sw/source/core/doc/docchart.cxx | 9 --- sw/source/core/doc/doclay.cxx | 32 ------------ sw/source/core/doc/docnew.cxx | 10 +-- sw/source/core/inc/DocumentTimerManager.hxx | 64 +++++++++++++++++++++++++ sw/source/core/inc/docfld.hxx | 3 - sw/source/core/inc/rootfrm.hxx | 5 + sw/source/core/layout/frmtool.cxx | 5 + 12 files changed, 179 insertions(+), 81 deletions(-)
New commits: commit 68fdc42941f669546afc06819c965d93c4f7adbd Author: Valentin Kettner <[email protected]> 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..8b9ff6b 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,10 @@ 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 + DECL_LINK( DoIdleJobs, Timer * ); + 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..b7d3816 --- /dev/null +++ b/sw/source/core/doc/DocumentTimerManager.cxx @@ -0,0 +1,71 @@ +/* -*- 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 <tools/link.hxx> +#include <doc.hxx> + +namespace sw +{ + +DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : mbStartIdleTimer( false ), + mIdleBlockCount( 0 ) +{ + maIdleTimer.SetTimeout( 600 ); + maIdleTimer.SetTimeoutHdl( LINK( &i_rSwdoc, SwDoc, 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(); +} + +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..dda5fdc 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -1765,38 +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 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..0754af6 --- /dev/null +++ b/sw/source/core/inc/DocumentTimerManager.hxx @@ -0,0 +1,64 @@ +/* -*- 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> + +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; + + virtual ~DocumentTimerManager(); + +private: + + 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 ); } commit 6fee585e20fac80dbd53ff4d29d576652055779a Author: Valentin Kettner <[email protected]> Date: Tue Jun 10 15:26:48 2014 +0200 Removed unneeded includes in docchart.cxx . Change-Id: Ic9343f985654e37a3427215fc4e9972e76267e8a diff --git a/sw/source/core/doc/docchart.cxx b/sw/source/core/doc/docchart.cxx index 7bdd7ad..4e294de 100644 --- a/sw/source/core/doc/docchart.cxx +++ b/sw/source/core/doc/docchart.cxx @@ -17,10 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <com/sun/star/frame/XModel.hpp> - -#include <com/sun/star/chart2/XChartDocument.hpp> - #include <float.h> #include <hintids.hxx> #include <vcl/window.hxx> @@ -31,7 +27,6 @@ #include <swtable.hxx> #include <ndtxt.hxx> #include <calc.hxx> -#include <frmfmt.hxx> #include <cellfml.hxx> #include <viewsh.hxx> #include <ndole.hxx> @@ -41,13 +36,9 @@ #include <tblsel.hxx> #include <cellatr.hxx> #include <osl/mutex.hxx> -#include <vcl/svapp.hxx> #include <unochart.hxx> -using namespace com::sun::star; -using namespace com::sun::star::uno; - void SwTable::UpdateCharts() const { GetFrmFmt()->GetDoc()->UpdateCharts( GetFrmFmt()->GetName() ); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
