summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basctl/source/basicide/baside2.cxx7
-rw-r--r--basic/source/comp/exprtree.cxx16
-rw-r--r--cui/source/customize/cfgutil.cxx6
-rw-r--r--cui/source/dialogs/scriptdlg.cxx6
-rw-r--r--include/comphelper/DisableInteractionHelper.hxx49
-rw-r--r--include/comphelper/SetFlagContextHelper.hxx63
-rw-r--r--scripting/source/provider/MasterScriptProvider.cxx6
7 files changed, 91 insertions, 62 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index e8bac4aa19af..af35a3a3dc7b 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -36,6 +36,7 @@
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/ui/dialogs/FilePicker.hpp>
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <comphelper/SetFlagContextHelper.hxx>
#include <comphelper/string.hxx>
#include <svl/srchdefs.hxx>
#include <svtools/ehdl.hxx>
@@ -282,7 +283,11 @@ void ModulWindow::CheckCompileBasic()
bool bWasModified = GetBasic()->IsModified();
- bDone = m_xModule->Compile();
+ {
+ // tdf#106529: only use strict compilation mode when compiling from the IDE
+ css::uno::ContextLayer layer(comphelper::NewFlagContext("BasicStrict"));
+ bDone = m_xModule->Compile();
+ }
if ( !bWasModified )
GetBasic()->SetModified(false);
diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx
index a7f5188aa075..a5d149a6c0ef 100644
--- a/basic/source/comp/exprtree.cxx
+++ b/basic/source/comp/exprtree.cxx
@@ -22,6 +22,7 @@
#include <parser.hxx>
#include <basic/sbx.hxx>
#include <expr.hxx>
+#include <uno/current_context.hxx>
SbiExpression::SbiExpression( SbiParser* p, SbiExprType t,
SbiExprMode eMode, const KeywordSymbolInfo* pKeywordSymbolInfo )
@@ -1033,6 +1034,21 @@ SbiExprListPtr SbiExprList::ParseParameters( SbiParser* pParser, bool bStandalon
{
if( ( pExprList->bBracket && eTok == RPAREN ) || SbiTokenizer::IsEoln( eTok ) )
{
+ // tdf#80731
+ if (SbiTokenizer::IsEoln(eTok) && pExprList->bBracket)
+ {
+ // tdf#106529: only fail here in strict mode (i.e. when compiled from IDE), and
+ // allow legacy code with missing closing parenthesis when started e.g. from
+ // extensions and event handlers
+ bool bCheckStrict = false;
+ if (auto xContext = css::uno::getCurrentContext())
+ xContext->getValueByName("BasicStrict") >>= bCheckStrict;
+ if (bCheckStrict)
+ {
+ pParser->Error(ERRCODE_BASIC_EXPECTED, RPAREN);
+ pExprList->bError = true;
+ }
+ }
break;
}
pParser->Error( pExprList->bBracket ? ERRCODE_BASIC_BAD_BRACKETS : ERRCODE_BASIC_EXPECTED, COMMA );
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index 0549e04cfbf5..1d94255e73eb 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -40,7 +40,7 @@
#include <strings.hrc>
#include <bitmaps.hlst>
#include <sfx2/minfitem.hxx>
-#include <comphelper/DisableInteractionHelper.hxx>
+#include <comphelper/SetFlagContextHelper.hxx>
#include <comphelper/documentinfo.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/sequenceashashmap.hxx>
@@ -52,7 +52,6 @@
#include <vcl/commandinfoprovider.hxx>
#include <vcl/help.hxx>
#include <vcl/svapp.hxx>
-#include <uno/current_context.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -487,8 +486,7 @@ void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::scrip
if ( xRootNode->hasChildNodes() )
{
// tdf#120362: Don't ask to enable disabled Java when filling script list
- css::uno::ContextLayer layer(
- new comphelper::NoEnableJavaInteractionContext(css::uno::getCurrentContext()));
+ css::uno::ContextLayer layer(comphelper::NoEnableJavaInteractionContext());
Sequence< Reference< browse::XBrowseNode > > children =
xRootNode->getChildNodes();
diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx
index fc6d7ec407fe..12da15e0c2b6 100644
--- a/cui/source/dialogs/scriptdlg.cxx
+++ b/cui/source/dialogs/scriptdlg.cxx
@@ -24,7 +24,6 @@
#include <sfx2/objsh.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
-#include <uno/current_context.hxx>
#include <strings.hrc>
#include <bitmaps.hlst>
@@ -47,7 +46,7 @@
#include <com/sun/star/script/XInvocation.hpp>
#include <com/sun/star/document/XEmbeddedScripts.hpp>
-#include <comphelper/DisableInteractionHelper.hxx>
+#include <comphelper/SetFlagContextHelper.hxx>
#include <comphelper/documentinfo.hxx>
#include <comphelper/processfactory.hxx>
@@ -255,8 +254,7 @@ SvxScriptOrgDialog::getLangNodeFromRootNode( Reference< browse::XBrowseNode > co
};
{
// First try without Java interaction, to avoid warnings for non-JRE-dependent providers
- css::uno::ContextLayer layer(
- new comphelper::NoEnableJavaInteractionContext(css::uno::getCurrentContext()));
+ css::uno::ContextLayer layer(comphelper::NoEnableJavaInteractionContext());
langNode = tryFind();
}
if (!langNode)
diff --git a/include/comphelper/DisableInteractionHelper.hxx b/include/comphelper/DisableInteractionHelper.hxx
deleted file mode 100644
index 3082a1406dfe..000000000000
--- a/include/comphelper/DisableInteractionHelper.hxx
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_COMPHELPER_DISABLEINTERACTIONHELPER_HXX
-#define INCLUDED_COMPHELPER_DISABLEINTERACTIONHELPER_HXX
-
-#include <cppuhelper/implbase.hxx>
-#include <com/sun/star/uno/XCurrentContext.hpp>
-
-namespace comphelper
-{
-class NoEnableJavaInteractionContext final : 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 comphelper
-
-#endif // INCLUDED_COMPHELPER_DISABLEINTERACTIONHELPER_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/SetFlagContextHelper.hxx b/include/comphelper/SetFlagContextHelper.hxx
new file mode 100644
index 000000000000..d209e398aeab
--- /dev/null
+++ b/include/comphelper/SetFlagContextHelper.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_COMPHELPER_SETFLAGCONTEXTHELPER_HXX
+#define INCLUDED_COMPHELPER_SETFLAGCONTEXTHELPER_HXX
+
+#include <com/sun/star/uno/XCurrentContext.hpp>
+#include <cppuhelper/implbase.hxx>
+#include <uno/current_context.hxx>
+
+namespace comphelper
+{
+// Used to flag some named value to be true for all code running in this context
+class SetFlagContext final : public cppu::WeakImplHelper<css::uno::XCurrentContext>
+{
+public:
+ explicit SetFlagContext(const OUString& sName,
+ css::uno::Reference<css::uno::XCurrentContext> const& xContext)
+ : m_sName(sName)
+ , mxNextContext(xContext)
+ {
+ }
+ SetFlagContext(const SetFlagContext&) = delete;
+ SetFlagContext& operator=(const SetFlagContext&) = delete;
+
+ virtual css::uno::Any SAL_CALL getValueByName(OUString const& Name) override
+ {
+ if (Name == m_sName)
+ return css::uno::Any(true);
+ else if (mxNextContext.is())
+ return mxNextContext->getValueByName(Name);
+ else
+ return css::uno::Any();
+ }
+
+private:
+ OUString m_sName;
+ css::uno::Reference<css::uno::XCurrentContext> mxNextContext;
+};
+
+// Returns a new context that reports the named value to be true
+inline css::uno::Reference<css::uno::XCurrentContext> NewFlagContext(const OUString& sName)
+{
+ return new SetFlagContext(sName, css::uno::getCurrentContext());
+}
+
+// A specialization for preventing "Java must be enabled" interaction
+inline css::uno::Reference<css::uno::XCurrentContext> NoEnableJavaInteractionContext()
+{
+ return NewFlagContext("DontEnableJava");
+}
+
+} // namespace comphelper
+
+#endif // INCLUDED_COMPHELPER_SETFLAGCONTEXTHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx
index 9367ea4c4236..41d64c0704f2 100644
--- a/scripting/source/provider/MasterScriptProvider.cxx
+++ b/scripting/source/provider/MasterScriptProvider.cxx
@@ -18,7 +18,7 @@
*/
-#include <comphelper/DisableInteractionHelper.hxx>
+#include <comphelper/SetFlagContextHelper.hxx>
#include <comphelper/documentinfo.hxx>
#include <cppuhelper/implementationentry.hxx>
@@ -26,7 +26,6 @@
#include <cppuhelper/factory.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <tools/diagnose_ex.h>
-#include <uno/current_context.hxx>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/lang/EventObject.hpp>
@@ -479,8 +478,7 @@ template <typename Proc> bool FindProviderAndApply(ProviderCache& rCache, Proc p
// This allows us to avoid useless user interaction in case when other provider
// (not JVM) actually handles the operation.
{
- css::uno::ContextLayer layer(
- new comphelper::NoEnableJavaInteractionContext(css::uno::getCurrentContext()));
+ css::uno::ContextLayer layer(comphelper::NoEnableJavaInteractionContext());
bSuccess = pass();
}
// 2. Now retry asking to enable JVM in case we didn't succeed first time