cui/source/customize/cfgutil.cxx |   35 +++++++++++++++++++++++++++++++++++
 stoc/source/javavm/javavm.cxx    |    7 +++++++
 2 files changed, 42 insertions(+)

New commits:
commit b2d156b6ef3845a2f1f390b1c9b7c202187e6b85
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sat Oct 6 15:28:37 2018 +0300
Commit:     Mike Kaganski <[email protected]>
CommitDate: Mon Oct 8 13:13:52 2018 +0200

    tdf#120362: Don't ask user to enable JVM when enumerating scripts
    
    Since it wasn't an explicit user's intention to run something that requires
    JVM, asking to enable it in case it's disabled is nonsense, and it happened
    every first time in a LO session when user wanted to start e.g. Basic macro
    using Tools->Macros->Run Macro... tool.
    
    Change-Id: I5afae804e183c185472d41a2d419ec80b7955110
    Reviewed-on: https://gerrit.libreoffice.org/61465
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index 4e89b9c7a2d4..56d91c1eaf82 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -65,6 +65,7 @@
 #include <vcl/help.hxx>
 #include <vcl/vclmedit.hxx>
 #include <o3tl/make_unique.hxx>
+#include <uno/current_context.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -541,6 +542,36 @@ namespace
     }
 }
 
+namespace
+{
+class NoEnableJavaInteractionContext : public 
cppu::WeakImplHelper<css::uno::XCurrentContext>
+{
+public:
+    explicit NoEnableJavaInteractionContext(
+        css::uno::Reference<css::uno::XCurrentContext> const& xContext)
+        : mxContext(xContext)
+    {
+    }
+    NoEnableJavaInteractionContext(const NoEnableJavaInteractionContext&) = 
delete;
+    NoEnableJavaInteractionContext& operator=(const 
NoEnableJavaInteractionContext&) = delete;
+
+private:
+    virtual ~NoEnableJavaInteractionContext() override {}
+
+    virtual css::uno::Any SAL_CALL getValueByName(OUString const& Name) 
override
+    {
+        if (Name == "DontEnableJava")
+            return css::uno::Any(true);
+        else if (mxContext.is())
+            return mxContext->getValueByName(Name);
+        else
+            return css::uno::Any();
+    }
+
+    css::uno::Reference<css::uno::XCurrentContext> mxContext;
+};
+
+} // namespace
 
 void SfxConfigGroupListBox::FillScriptList(const css::uno::Reference< 
css::script::browse::XBrowseNode >& xRootNode,
                                            SvTreeListEntry* pParentEntry, bool 
bCheapChildrenOnDemand)
@@ -548,6 +579,10 @@ void SfxConfigGroupListBox::FillScriptList(const 
css::uno::Reference< css::scrip
     try {
         if ( xRootNode->hasChildNodes() )
         {
+            // tdf#120362: Don't ask to enable disabled Java when filling 
script list
+            css::uno::ContextLayer layer(
+                new 
NoEnableJavaInteractionContext(css::uno::getCurrentContext()));
+
             Sequence< Reference< browse::XBrowseNode > > children =
                 xRootNode->getChildNodes();
             bool bIsRootNode = false;
diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx
index 968e776be2a0..2bf1fbf55229 100644
--- a/stoc/source/javavm/javavm.cxx
+++ b/stoc/source/javavm/javavm.cxx
@@ -778,6 +778,13 @@ JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 
> const & rProcessId)
         }
         case JFW_E_JAVA_DISABLED:
         {
+            bool bDontEnableJava = false;
+            auto xContext(css::uno::getCurrentContext());
+            if (xContext.is())
+                xContext->getValueByName("DontEnableJava") >>= bDontEnableJava;
+            if (bDontEnableJava)
+                return css::uno::Any();
+
             //QueryBox:
             //%PRODUCTNAME requires a Java runtime environment (JRE) to perform
             //this task. However, use of a JRE has been disabled. Do you want 
to
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to