diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-05-20 00:59:29 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-05-21 13:25:20 -0400 |
commit | c28aadc7fcb1858acc2e59a875e0a4c9071681ed (patch) | |
tree | be02133f96d41e07f678967c83422f11e52172c4 /sc/source | |
parent | 1b243b14e9715b7b7da6359b5b752ee6d8278731 (diff) |
cp#1000072: Stop the external doc shell timer while mass-updating.
To prevent collision with the timer wanting to purge the doc cache
while updating external links.
Also, show progress bar, and make the timer interval and the document
cache life span longer.
Change-Id: I325984c8fa68425a2621cf8f9c016463291afc89
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/documen8.cxx | 56 | ||||
-rw-r--r-- | sc/source/ui/docshell/externalrefmgr.cxx | 30 |
2 files changed, 63 insertions, 23 deletions
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index 316738ab16cb..4563b02364c3 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -780,6 +780,9 @@ bool ScDocument::IsInLinkUpdate() const void ScDocument::UpdateExternalRefLinks(Window* pWin) { + if (!pExternalRefMgr.get()) + return; + sfx2::LinkManager* pMgr = GetDocLinkManager().getLinkManager(bAutoCalc); if (!pMgr) return; @@ -788,33 +791,48 @@ void ScDocument::UpdateExternalRefLinks(Window* pWin) sal_uInt16 nCount = rLinks.size(); bool bAny = false; + + // Collect all the external ref links first. + std::vector<ScExternalRefLink*> aRefLinks; for (sal_uInt16 i = 0; i < nCount; ++i) { ::sfx2::SvBaseLink* pBase = *rLinks[i]; ScExternalRefLink* pRefLink = dynamic_cast<ScExternalRefLink*>(pBase); if (pRefLink) + aRefLinks.push_back(pRefLink); + } + + pExternalRefMgr->enableDocTimer(false); + ScProgress aProgress(GetDocumentShell(), "Updating external links", aRefLinks.size()); + for (size_t i = 0, n = aRefLinks.size(); i < n; ++i) + { + aProgress.SetState(i); + + ScExternalRefLink* pRefLink = aRefLinks[i]; + if (pRefLink->Update()) { - if (pRefLink->Update()) - bAny = true; - else - { - // Update failed. Notify the user. - - OUString aFile; - pMgr->GetDisplayNames(pRefLink, NULL, &aFile, NULL, NULL); - // Decode encoded URL for display friendliness. - INetURLObject aUrl(aFile,INetURLObject::WAS_ENCODED); - aFile = aUrl.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS); - - OUStringBuffer aBuf; - aBuf.append(OUString(ScResId(SCSTR_EXTDOC_NOT_LOADED))); - aBuf.appendAscii("\n\n"); - aBuf.append(aFile); - ErrorBox aBox(pWin, WB_OK, aBuf.makeStringAndClear()); - aBox.Execute(); - } + bAny = true; + continue; } + + // Update failed. Notify the user. + + OUString aFile; + pMgr->GetDisplayNames(pRefLink, NULL, &aFile, NULL, NULL); + // Decode encoded URL for display friendliness. + INetURLObject aUrl(aFile,INetURLObject::WAS_ENCODED); + aFile = aUrl.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS); + + OUStringBuffer aBuf; + aBuf.append(OUString(ScResId(SCSTR_EXTDOC_NOT_LOADED))); + aBuf.appendAscii("\n\n"); + aBuf.append(aFile); + ErrorBox aBox(pWin, WB_OK, aBuf.makeStringAndClear()); + aBox.Execute(); } + + pExternalRefMgr->enableDocTimer(true); + if (bAny) { TrackFormulas(); diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 549549a64c42..ded749f222d4 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -71,8 +71,8 @@ using ::std::list; using ::std::unary_function; using namespace formula; -#define SRCDOC_LIFE_SPAN 6000 // 1 minute (in 100th of a sec) -#define SRCDOC_SCAN_INTERVAL 1000*5 // every 5 seconds (in msec) +#define SRCDOC_LIFE_SPAN 30000 // 5 minutes (in 100th of a sec) +#define SRCDOC_SCAN_INTERVAL 1000*30 // every 30 seconds (in msec) namespace { @@ -1537,7 +1537,8 @@ static ScTokenArray* lcl_fillEmptyMatrix(const ScRange& rRange) ScExternalRefManager::ScExternalRefManager(ScDocument* pDoc) : mpDoc(pDoc), mbInReferenceMarking(false), - mbUserInteractionEnabled(true) + mbUserInteractionEnabled(true), + mbDocTimerEnabled(true) { maSrcDocTimer.SetTimeoutHdl( LINK(this, ScExternalRefManager, TimeOutHdl) ); maSrcDocTimer.SetTimeout(SRCDOC_SCAN_INTERVAL); @@ -2009,6 +2010,27 @@ void ScExternalRefManager::insertRefCell(sal_uInt16 nFileId, const ScAddress& rC itr->second.insert(pCell); } +void ScExternalRefManager::enableDocTimer( bool bEnable ) +{ + if (mbDocTimerEnabled == bEnable) + return; + + mbDocTimerEnabled = bEnable; + if (mbDocTimerEnabled) + { + if (!maDocShells.empty()) + { + DocShellMap::iterator it = maDocShells.begin(), itEnd = maDocShells.end(); + for (; it != itEnd; ++it) + it->second.maLastAccess = Time(Time::SYSTEM); + + maSrcDocTimer.Start(); + } + } + else + maSrcDocTimer.Stop(); +} + void ScExternalRefManager::fillCellFormat(sal_uLong nFmtIndex, ScExternalRefCache::CellFormat* pFmt) const { if (!pFmt) @@ -2331,7 +2353,7 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, OUSt ScDocument* ScExternalRefManager::cacheNewDocShell( sal_uInt16 nFileId, SrcShell& rSrcShell ) { - if (maDocShells.empty()) + if (mbDocTimerEnabled && maDocShells.empty()) // If this is the first source document insertion, start up the timer. maSrcDocTimer.Start(); |