diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-01-12 16:12:59 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-01-13 15:38:45 +0100 |
commit | ff5cb6cb34e42b290affc75703a93de1d24d0bc6 (patch) | |
tree | 5af1e75a535ddf6c3fee94035e27037fac8001ef /sc/source | |
parent | 8242c22f84cef1bbc8c385875b2da4713b542329 (diff) |
turn update links warning dialog into an infobar
Change-Id: Ib53c21d9ea76af11ed9af2115af7cd617c0f149b
Reviewed-on: https://gerrit.libreoffice.org/47823
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/docshell/docsh4.cxx | 91 | ||||
-rw-r--r-- | sc/source/ui/inc/docsh.hxx | 2 |
2 files changed, 59 insertions, 34 deletions
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 9534919842b7..a847445f6051 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -32,6 +32,7 @@ using namespace ::com::sun::star; #include <editeng/flstitem.hxx> #include <editeng/langitem.hxx> #include <sfx2/fcontnr.hxx> +#include <sfx2/infobar.hxx> #include <sfx2/linkmgr.hxx> #include <sfx2/objface.hxx> #include <sfx2/docfile.hxx> @@ -112,6 +113,40 @@ using namespace ::com::sun::star; #include <memory> #include <sfx2/notebookbar/SfxNotebookBar.hxx> +void ScDocShell::ReloadAllLinks() +{ + aDocument.SetLinkFormulaNeedingCheck(false); + getEmbeddedObjectContainer().setUserAllowsLinkUpdate(true); + + ReloadTabLinks(); + aDocument.UpdateExternalRefLinks(GetActiveDialogParent()); + + bool bAnyDde = aDocument.GetDocLinkManager().updateDdeOrOleOrWebServiceLinks(GetActiveDialogParent()); + + if (bAnyDde) + { + // calculate formulas and paint like in the TrackTimeHdl + aDocument.TrackFormulas(); + Broadcast(SfxHint(SfxHintId::ScDataChanged)); + + // Should FID_DATACHANGED become asynchronous some time + // (e.g., with Invalidate at Window), an update needs to be forced here. + } + + aDocument.UpdateAreaLinks(); +} + +IMPL_LINK_NOARG( ScDocShell, ReloadAllLinksHdl, Button*, void ) +{ + ReloadAllLinks(); + + ScTabViewShell* pViewSh = GetBestViewShell(); + SfxViewFrame* pViewFrame = pViewSh ? pViewSh->GetFrame() : nullptr; + if (pViewFrame) + pViewFrame->RemoveInfoBar("enablecontent"); + SAL_WARN_IF(!pViewFrame, "sc", "expected there to be a ViewFrame"); +} + void ScDocShell::Execute( SfxRequest& rReq ) { const SfxItemSet* pReqArgs = rReq.GetArgs(); @@ -408,14 +443,10 @@ void ScDocShell::Execute( SfxRequest& rReq ) break; case SID_UPDATETABLINKS: { - comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = getEmbeddedObjectContainer(); - rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true); - ScDocument& rDoc = GetDocument(); ScLkUpdMode nSet = rDoc.GetLinkMode(); - sal_uInt16 nDlgRet=RET_NO; if(nSet==LM_UNKNOWN) { ScAppOptions aAppOptions=SC_MOD()->GetAppOptions(); @@ -441,43 +472,35 @@ void ScDocShell::Execute( SfxRequest& rReq ) nSet = LM_NEVER; } - if(nSet==LM_ON_DEMAND) + if (nSet == LM_ALWAYS) { - ScopedVclPtrInstance<QueryBox> aBox( GetActiveDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_RELOAD_TABLES) ); - - nDlgRet=aBox->Execute(); + ReloadAllLinks(); + rReq.Done(); } - - if (nDlgRet == RET_YES || nSet==LM_ALWAYS) + else if (nSet == LM_NEVER) { - ReloadTabLinks(); - aDocument.UpdateExternalRefLinks(GetActiveDialogParent()); - - bool bAnyDde = aDocument.GetDocLinkManager().updateDdeOrOleOrWebServiceLinks(GetActiveDialogParent()); - - if (bAnyDde) + getEmbeddedObjectContainer().setUserAllowsLinkUpdate(false); + rReq.Ignore(); + } + else if (nSet == LM_ON_DEMAND) + { + ScTabViewShell* pViewSh = GetBestViewShell(); + SfxViewFrame* pViewFrame = pViewSh ? pViewSh->GetFrame() : nullptr; + if (pViewFrame) { - // calculate formulas and paint like in the TrackTimeHdl - aDocument.TrackFormulas(); - Broadcast(SfxHint(SfxHintId::ScDataChanged)); - - // Should FID_DATACHANGED become asynchronous some time - // (e.g., with Invalidate at Window), an update needs to be forced here. + pViewFrame->RemoveInfoBar("enablecontent"); + auto pInfoBar = pViewFrame->AppendInfoBar("enablecontent", ScGlobal::GetRscString(STR_RELOAD_TABLES), InfoBarType::Warning); + if (pInfoBar) + { + VclPtrInstance<PushButton> xBtn(&pViewFrame->GetWindow()); + xBtn->SetText(ScResId(STR_ENABLE_CONTENT)); + xBtn->SetSizePixel(xBtn->GetOptimalSize()); + xBtn->SetClickHdl(LINK(this, ScDocShell, ReloadAllLinksHdl)); + pInfoBar->addButton(xBtn); + } } - - aDocument.UpdateAreaLinks(); - - //! test for error rReq.Done(); } - else - { - rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false); - rReq.Ignore(); - } - - rDoc.SetLinkFormulaNeedingCheck(false); } break; diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index d457bb8ab04d..50bcf63dd37f 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -291,6 +291,7 @@ public: virtual void ReconnectDdeLink(SfxObjectShell& rServer) override; void UpdateLinks() override; + void ReloadAllLinks(); void ReloadTabLinks(); void SetFormulaOptions( const ScFormulaOptions& rOpt, bool bForLoading = false ); @@ -328,6 +329,7 @@ public: void UnlockDocument(); DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper*, void ); + DECL_LINK( ReloadAllLinksHdl, Button*, void ); virtual SfxStyleSheetBasePool* GetStyleSheetPool() override; |