[Libreoffice-commits] core.git: include/sfx2 sc/inc sc/source

Caolán McNamara caolanm at redhat.com
Sat Jan 13 14:39:18 UTC 2018


 include/sfx2/infobar.hxx         |    2 
 sc/inc/strings.hrc               |    2 
 sc/source/ui/docshell/docsh4.cxx |   91 ++++++++++++++++++++++++---------------
 sc/source/ui/inc/docsh.hxx       |    2 
 4 files changed, 62 insertions(+), 35 deletions(-)

New commits:
commit ff5cb6cb34e42b290affc75703a93de1d24d0bc6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 12 16:12:59 2018 +0000

    turn update links warning dialog into an infobar
    
    Change-Id: Ib53c21d9ea76af11ed9af2115af7cd617c0f149b
    Reviewed-on: https://gerrit.libreoffice.org/47823
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx
index 23953a1a7bf7..ac8c43e75b4b 100644
--- a/include/sfx2/infobar.hxx
+++ b/include/sfx2/infobar.hxx
@@ -46,7 +46,7 @@ class SFX2_DLLPUBLIC SfxInfoBarContainerChild : public SfxChildWindow
 
 /** Class representing a single InfoBar to be added in a SfxInfoBarContainerWindow.
   */
-class SfxInfoBarWindow : public vcl::Window
+class SFX2_DLLPUBLIC SfxInfoBarWindow : public vcl::Window
 {
     private:
         OUString                           m_sId;
diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index 5491a39eedbf..2d3ad92c3c6b 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -328,6 +328,8 @@
 #define STR_ZTEST_Z_CRITICAL_ONE_TAIL               NC_("STR_ZTEST_Z_CRITICAL_ONE_TAIL", "z Critical one-tail")
 #define STR_ZTEST_P_TWO_TAIL                        NC_("STR_ZTEST_P_TWO_TAIL", "P (Z<=z) two-tail")
 #define STR_ZTEST_Z_CRITICAL_TWO_TAIL               NC_("STR_ZTEST_Z_CRITICAL_TWO_TAIL", "z Critical two-tail")
+/*infobar for allowing links to update or not*/
+#define STR_ENABLE_CONTENT                          NC_("STR_ENABLE_CONTENT", "Enable Content")
 
 #endif
 
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;
 


More information about the Libreoffice-commits mailing list