basctl/source/basicide/macrodlg.cxx |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 7667dda435b2671f1d78e967669fa0fe725b5af6
Author: Julien Nabet <[email protected]>
Date:   Sat May 26 22:38:24 2018 +0200

    tdf#117825: check if macros are allowed when double-click one
    
    Change-Id: I4ebb38bdac543995ee7e73dbd67ff5f1402d1a0a
    Reviewed-on: https://gerrit.libreoffice.org/54867
    Tested-by: Jenkins <[email protected]>
    Reviewed-by: Julien Nabet <[email protected]>

diff --git a/basctl/source/basicide/macrodlg.cxx 
b/basctl/source/basicide/macrodlg.cxx
index 986dfecb635e..ca0b9161de7d 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -460,10 +460,23 @@ void MacroChooser::CheckButtons()
 
 IMPL_LINK_NOARG(MacroChooser, MacroDoubleClickHdl, SvTreeListBox*, bool)
 {
+    SbMethod* pMethod = GetMacro();
+    SbModule* pModule = pMethod ? pMethod->GetModule() : nullptr;
+    StarBASIC* pBasic = pModule ? 
static_cast<StarBASIC*>(pModule->GetParent()) : nullptr;
+    BasicManager* pBasMgr = pBasic ? FindBasicManager(pBasic) : nullptr;
+    ScriptDocument 
aDocument(ScriptDocument::getDocumentForBasicManager(pBasMgr));
+    if (aDocument.isDocument() && !aDocument.allowMacros())
+    {
+        std::unique_ptr<weld::MessageDialog> xError(
+            Application::CreateMessageDialog(GetFrameWeld(), 
VclMessageType::Warning,
+                                             VclButtonsType::Ok, 
IDEResId(RID_STR_CANNOTRUNMACRO)));
+        xError->run();
+        return false;
+    }
+
     StoreMacroDescription();
     if (nMode == Recording)
     {
-        SbMethod* pMethod = GetMacro();
         if (pMethod && !QueryReplaceMacro(pMethod->GetName(), GetFrameWeld()))
             return false;
     }
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to