summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/source/lib/init.cxx48
-rw-r--r--framework/IwyuFilter_framework.yaml2
-rw-r--r--framework/source/uiconfiguration/moduleuicfgsupplier.cxx6
-rw-r--r--framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx10
-rw-r--r--framework/source/uiconfiguration/uiconfigurationmanager.cxx10
-rw-r--r--include/sfx2/app.hxx4
-rw-r--r--include/sfx2/lokhelper.hxx3
-rw-r--r--include/svtools/acceleratorexecute.hxx2
-rw-r--r--offapi/UnoApi_offapi.mk2
-rw-r--r--offapi/com/sun/star/ui/ModuleUIConfigurationManager.idl2
-rw-r--r--offapi/com/sun/star/ui/UIConfigurationManager.idl2
-rw-r--r--offapi/com/sun/star/ui/XModuleUIConfigurationManager3.idl41
-rw-r--r--offapi/com/sun/star/ui/XUIConfigurationManager3.idl39
-rw-r--r--sfx2/source/appl/app.cxx5
-rw-r--r--sfx2/source/inc/appdata.hxx2
-rw-r--r--sfx2/source/view/lokhelper.cxx12
-rw-r--r--sfx2/source/view/viewsh.cxx41
-rw-r--r--svtools/source/misc/acceleratorexecute.cxx27
18 files changed, 244 insertions, 14 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7cd3304a2185..8561760febce 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -217,6 +217,10 @@
#include <unotools/viewoptions.hxx>
#include <vcl/settings.hxx>
+#include <officecfg/Setup.hxx>
+#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
+#include <svtools/acceleratorexecute.hxx>
+
using namespace css;
using namespace vcl;
using namespace desktop;
@@ -7147,6 +7151,47 @@ static void lo_status_indicator_callback(void *data, comphelper::LibreOfficeKit:
}
}
+/// Used by preloadData (LibreOfficeKit) for providing different shortcuts for different languages.
+static void preLoadShortCutAccelerators()
+{
+ std::unordered_map<OUString, css::uno::Reference<com::sun::star::ui::XAcceleratorConfiguration>>& acceleratorConfs = SfxLokHelper::getAcceleratorConfs();
+ css::uno::Sequence<OUString> installedLocales(officecfg::Setup::Office::InstalledLocales::get()->getElementNames());
+ OUString actualLang = officecfg::Setup::L10N::ooLocale::get();
+
+ for (sal_Int32 i = 0; i < installedLocales.getLength(); i++)
+ {
+ OUString language = LanguageTag(installedLocales[i]).getLocale().Language;
+
+ if (!comphelper::LibreOfficeKit::isAllowlistedLanguage(language))
+ {
+ // Language is listed by COOL and also installed in core. We can create the short cut accelerator.
+
+ // Set the UI language to current one, before creating the accelerator.
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
+ officecfg::Setup::L10N::ooLocale::set(installedLocales[i], batch);
+ batch->commit();
+
+ // Supported module names: Writer, Calc, Draw, Impress
+ std::vector<OUString> supportedModuleNames = { "com.sun.star.text.TextDocument", "com.sun.star.sheet.SpreadsheetDocument", "com.sun.star.drawing.DrawingDocument", "com.sun.star.presentation.PresentationDocument" };
+ // Create the accelerators.
+ for (std::size_t j = 0; j < supportedModuleNames.size(); j++)
+ {
+ OUString key = supportedModuleNames[j] + installedLocales[i];
+ acceleratorConfs[key] = svt::AcceleratorExecute::lok_createNewAcceleratorConfiguration(::comphelper::getProcessComponentContext(), supportedModuleNames[j]);
+ }
+ }
+ else
+ {
+ std::cerr << "Language is installed in core but not in the list of COOL languages: " << language << "\n";
+ }
+ }
+
+ // Set the UI language back to default one.
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
+ officecfg::Setup::L10N::ooLocale::set(actualLang, batch);
+ batch->commit();
+}
+
/// Used only by LibreOfficeKit when used by Online to pre-initialize
static void preloadData()
{
@@ -7210,6 +7255,9 @@ static void preloadData()
ImageTree &images = ImageTree::get();
images.getImageUrl("forcefed.png", "style", "FO_oo");
+ std::cerr << "Preload short cut accelerators\n";
+ preLoadShortCutAccelerators();
+
std::cerr << "Preload languages\n";
// force load language singleton
diff --git a/framework/IwyuFilter_framework.yaml b/framework/IwyuFilter_framework.yaml
index 88b8dfae4ae3..3d69d4315137 100644
--- a/framework/IwyuFilter_framework.yaml
+++ b/framework/IwyuFilter_framework.yaml
@@ -40,7 +40,7 @@ excludelist:
- com/sun/star/beans/PropertyValue.hpp
framework/source/fwe/helper/configimporter.cxx:
# Actually used
- - com/sun/star/ui/XUIConfigurationManager2.hpp
+ - com/sun/star/ui/XUIConfigurationManager3.hpp
framework/source/fwe/helper/undomanagerhelper.cxx:
# Actually used
- com/sun/star/document/XUndoManager.hpp
diff --git a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
index cdbd647c3108..f127c81d7fb9 100644
--- a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
+++ b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
@@ -28,7 +28,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/ui/XUIConfigurationManager.hpp>
-#include <com/sun/star/ui/XModuleUIConfigurationManager2.hpp>
+#include <com/sun/star/ui/XModuleUIConfigurationManager3.hpp>
#include <com/sun/star/frame/XModuleManager2.hpp>
#include <comphelper/compbase.hxx>
@@ -80,7 +80,7 @@ public:
private:
virtual void disposing(std::unique_lock<std::mutex>&) final override;
- typedef std::unordered_map< OUString, css::uno::Reference< css::ui::XModuleUIConfigurationManager2 > > ModuleToModuleCfgMgr;
+ typedef std::unordered_map< OUString, css::uno::Reference< css::ui::XModuleUIConfigurationManager3 > > ModuleToModuleCfgMgr;
//TODO_AS void impl_initStorages();
@@ -99,7 +99,7 @@ ModuleUIConfigurationManagerSupplier::ModuleUIConfigurationManagerSupplier( cons
Reference< XNameAccess > xNameAccess( m_xModuleMgr, UNO_QUERY_THROW );
const Sequence< OUString > aNameSeq = xNameAccess->getElementNames();
for ( const OUString& rName : aNameSeq )
- m_aModuleToModuleUICfgMgrMap.emplace( rName, Reference< XModuleUIConfigurationManager2 >() );
+ m_aModuleToModuleUICfgMgrMap.emplace( rName, Reference< XModuleUIConfigurationManager3 >() );
}
catch(...)
{
diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
index a75b84e7457f..dfa73e9bd39a 100644
--- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
@@ -30,7 +30,7 @@
#include <com/sun/star/ui/UIElementType.hpp>
#include <com/sun/star/ui/ConfigurationEvent.hpp>
#include <com/sun/star/ui/ModuleAcceleratorConfiguration.hpp>
-#include <com/sun/star/ui/XModuleUIConfigurationManager2.hpp>
+#include <com/sun/star/ui/XModuleUIConfigurationManager3.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/IllegalAccessException.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
@@ -83,7 +83,7 @@ namespace {
class ModuleUIConfigurationManager : public cppu::WeakImplHelper<
css::lang::XServiceInfo,
css::lang::XComponent,
- css::ui::XModuleUIConfigurationManager2 >
+ css::ui::XModuleUIConfigurationManager3 >
{
public:
ModuleUIConfigurationManager(
@@ -125,6 +125,7 @@ public:
virtual void SAL_CALL insertSettings( const OUString& NewResourceURL, const css::uno::Reference< css::container::XIndexAccess >& aNewData ) override;
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getImageManager() override;
virtual css::uno::Reference< css::ui::XAcceleratorConfiguration > SAL_CALL getShortCutManager() override;
+ virtual css::uno::Reference< css::ui::XAcceleratorConfiguration > SAL_CALL createShortCutManager() override;
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getEventsManager() override;
// XModuleUIConfigurationManager
@@ -1422,6 +1423,11 @@ Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getImageManager()
return Reference< XInterface >( static_cast<cppu::OWeakObject*>(m_xModuleImageManager.get()), UNO_QUERY );
}
+Reference< ui::XAcceleratorConfiguration > SAL_CALL ModuleUIConfigurationManager::createShortCutManager()
+{
+ return ui::ModuleAcceleratorConfiguration::createWithModuleIdentifier(m_xContext, m_aModuleIdentifier);
+}
+
Reference< ui::XAcceleratorConfiguration > SAL_CALL ModuleUIConfigurationManager::getShortCutManager()
{
SolarMutexGuard g;
diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
index e0527d481504..c3e2bc7ca9e1 100644
--- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
@@ -40,7 +40,7 @@
#include <com/sun/star/ui/ConfigurationEvent.hpp>
#include <com/sun/star/ui/DocumentAcceleratorConfiguration.hpp>
#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
-#include <com/sun/star/ui/XUIConfigurationManager2.hpp>
+#include <com/sun/star/ui/XUIConfigurationManager3.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -73,7 +73,7 @@ namespace {
class UIConfigurationManager : public ::cppu::WeakImplHelper<
css::lang::XServiceInfo ,
- css::ui::XUIConfigurationManager2 >
+ css::ui::XUIConfigurationManager3 >
{
public:
virtual OUString SAL_CALL getImplementationName() override
@@ -113,6 +113,7 @@ public:
virtual void SAL_CALL insertSettings( const OUString& NewResourceURL, const css::uno::Reference< css::container::XIndexAccess >& aNewData ) override;
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getImageManager() override;
virtual css::uno::Reference< css::ui::XAcceleratorConfiguration > SAL_CALL getShortCutManager() override;
+ virtual css::uno::Reference< css::ui::XAcceleratorConfiguration > SAL_CALL createShortCutManager() override;
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getEventsManager() override;
// XUIConfigurationPersistence
@@ -1137,6 +1138,11 @@ Reference< XInterface > SAL_CALL UIConfigurationManager::getImageManager()
return Reference< XInterface >( static_cast<cppu::OWeakObject*>(m_xImageManager.get()), UNO_QUERY );
}
+Reference< XAcceleratorConfiguration > SAL_CALL UIConfigurationManager::createShortCutManager()
+{
+ return DocumentAcceleratorConfiguration::createWithDocumentRoot(m_xContext, m_xDocConfigStorage);
+}
+
Reference< XAcceleratorConfiguration > SAL_CALL UIConfigurationManager::getShortCutManager()
{
// SAFE ->
diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx
index 73198c056aec..5ed6fbc0dc57 100644
--- a/include/sfx2/app.hxx
+++ b/include/sfx2/app.hxx
@@ -27,6 +27,8 @@
#include <svl/poolitem.hxx>
#include <vcl/bitmapex.hxx>
#include <tools/link.hxx>
+#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
+#include <unordered_map>
#include <sfx2/shell.hxx>
@@ -176,6 +178,8 @@ public:
SAL_DLLPRIVATE SfxChildWinFactory* GetChildWinFactoryById(sal_uInt16 nId) const;
SAL_DLLPRIVATE std::vector<SfxViewFrame*>& GetViewFrames_Impl() const;
SAL_DLLPRIVATE std::vector<SfxViewShell*>& GetViewShells_Impl() const;
+ /* unordered_map<ModuleName+Language, acceleratorConfigurationClassInstance> */
+ SAL_DLLPRIVATE std::unordered_map<OUString, css::uno::Reference<css::ui::XAcceleratorConfiguration>>& GetAcceleratorConfs_Impl() const;
SAL_DLLPRIVATE std::vector<SfxObjectShell*>& GetObjectShells_Impl() const;
SAL_DLLPRIVATE void SetViewFrame_Impl(SfxViewFrame *pViewFrame);
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index b572ddf076b5..d975b4ade2bf 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -23,6 +23,7 @@
#include <rtl/string.hxx>
#include <optional>
#include <string_view>
+#include <sfx2/app.hxx>
struct SFX2_DLLPUBLIC LokMouseEventData
{
@@ -51,6 +52,8 @@ namespace com::sun::star::ui { struct ContextChangeEventObject; };
class SFX2_DLLPUBLIC SfxLokHelper
{
public:
+ /// Gets the short cut accelerators.
+ static std::unordered_map<OUString, css::uno::Reference<com::sun::star::ui::XAcceleratorConfiguration>>& getAcceleratorConfs();
/// Create a new view shell from the current view frame.
/// This assumes a single document is ever loaded.
static int createView();
diff --git a/include/svtools/acceleratorexecute.hxx b/include/svtools/acceleratorexecute.hxx
index 5acf9bcd2560..141c9ec8597f 100644
--- a/include/svtools/acceleratorexecute.hxx
+++ b/include/svtools/acceleratorexecute.hxx
@@ -176,6 +176,8 @@ class SVT_DLLPUBLIC AcceleratorExecute final
static css::uno::Reference< css::ui::XAcceleratorConfiguration > st_openModuleConfig(const css::uno::Reference< css::uno::XComponentContext >& rxContext ,
const css::uno::Reference< css::frame::XFrame >& xFrame);
+ static css::uno::Reference<css::ui::XAcceleratorConfiguration> lok_createNewAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& rxContext, OUString sModule);
+ void lok_setModuleConfig(css::uno::Reference<css::ui::XAcceleratorConfiguration> acceleratorConfig);
/** TODO document me */
static css::uno::Reference< css::ui::XAcceleratorConfiguration > st_openDocConfig(const css::uno::Reference< css::frame::XModel >& xModel);
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 7ee71bb984c1..4a42279b2c54 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -4058,6 +4058,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/ui,\
XImageManager \
XModuleUIConfigurationManager \
XModuleUIConfigurationManager2 \
+ XModuleUIConfigurationManager3 \
XModuleUIConfigurationManagerSupplier \
XPanel \
XPanels \
@@ -4070,6 +4071,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/ui,\
XUIConfigurationListener \
XUIConfigurationManager \
XUIConfigurationManager2 \
+ XUIConfigurationManager3 \
XUIConfigurationManagerSupplier \
XUIConfigurationPersistence \
XUIConfigurationStorage \
diff --git a/offapi/com/sun/star/ui/ModuleUIConfigurationManager.idl b/offapi/com/sun/star/ui/ModuleUIConfigurationManager.idl
index 6fe18b254fc6..56fd37bcbfef 100644
--- a/offapi/com/sun/star/ui/ModuleUIConfigurationManager.idl
+++ b/offapi/com/sun/star/ui/ModuleUIConfigurationManager.idl
@@ -36,7 +36,7 @@ module com { module sun { module star { module ui {
@since OOo 2.0
*/
-service ModuleUIConfigurationManager : XModuleUIConfigurationManager2
+service ModuleUIConfigurationManager : XModuleUIConfigurationManager3
{
/** provides a function to initialize a module user interface configuration manager instance.
diff --git a/offapi/com/sun/star/ui/UIConfigurationManager.idl b/offapi/com/sun/star/ui/UIConfigurationManager.idl
index bff584dcdb83..c0ae1683f106 100644
--- a/offapi/com/sun/star/ui/UIConfigurationManager.idl
+++ b/offapi/com/sun/star/ui/UIConfigurationManager.idl
@@ -25,7 +25,7 @@ module com { module sun { module star { module ui {
@since OOo 2.0
*/
-service UIConfigurationManager : XUIConfigurationManager2;
+service UIConfigurationManager : XUIConfigurationManager3;
}; }; }; };
diff --git a/offapi/com/sun/star/ui/XModuleUIConfigurationManager3.idl b/offapi/com/sun/star/ui/XModuleUIConfigurationManager3.idl
new file mode 100644
index 000000000000..494de200b2e9
--- /dev/null
+++ b/offapi/com/sun/star/ui/XModuleUIConfigurationManager3.idl
@@ -0,0 +1,41 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+module com { module sun { module star { module ui {
+
+/**
+ Provides a unified interface for the ModuleUIConfigurationManager service.
+
+ @since LibreOffice 7.6
+*/
+interface XModuleUIConfigurationManager3
+{
+ interface com::sun::star::ui::XModuleUIConfigurationManager2;
+
+ /**
+ Creates a new configuration manager in case there are different views with different languages.
+ This function enables those views to have short cut keys specific to the languages.
+ */
+ com::sun::star::ui::XAcceleratorConfiguration createShortCutManager();
+};
+
+
+}; }; }; };
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/ui/XUIConfigurationManager3.idl b/offapi/com/sun/star/ui/XUIConfigurationManager3.idl
new file mode 100644
index 000000000000..73652fc6c8ef
--- /dev/null
+++ b/offapi/com/sun/star/ui/XUIConfigurationManager3.idl
@@ -0,0 +1,39 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+module com { module sun { module star { module ui {
+
+/**
+ @since LibreOffice 7.6
+*/
+interface XUIConfigurationManager3
+{
+ interface com::sun::star::ui::XUIConfigurationManager2;
+
+ /**
+ Creates a new configuration manager in case there are different views with different languages.
+ This function enables those views to have short cut keys specific to the languages.
+ */
+ com::sun::star::ui::XAcceleratorConfiguration createShortCutManager();
+};
+
+
+}; }; }; };
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx
index 41a637a5d913..c5a1d1614145 100644
--- a/sfx2/source/appl/app.cxx
+++ b/sfx2/source/appl/app.cxx
@@ -367,6 +367,11 @@ std::vector<SfxViewShell*>& SfxApplication::GetViewShells_Impl() const
return pImpl->maViewShells;
}
+std::unordered_map<OUString, css::uno::Reference<css::ui::XAcceleratorConfiguration>>& SfxApplication::GetAcceleratorConfs_Impl() const
+{
+ return pImpl->maAcceleratorConfs;
+}
+
std::vector<SfxObjectShell*>& SfxApplication::GetObjectShells_Impl() const
{
return pImpl->maObjShells;
diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx
index 7f2c99d6332a..6362d05d093d 100644
--- a/sfx2/source/inc/appdata.hxx
+++ b/sfx2/source/inc/appdata.hxx
@@ -32,6 +32,7 @@
#include <sfx2/msgpool.hxx>
#include <o3tl/enumarray.hxx>
#include "sfxpicklist.hxx"
+#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
#include <bitset.hxx>
#include <memory>
@@ -98,6 +99,7 @@ public:
maStbCtrlFactories;
std::vector<SfxViewFrame*> maViewFrames;
std::vector<SfxViewShell*> maViewShells;
+ std::unordered_map<OUString, css::uno::Reference<css::ui::XAcceleratorConfiguration>> maAcceleratorConfs;
std::vector<SfxObjectShell*>
maObjShells;
std::unique_ptr<SfxBasicManagerHolder>
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 22b5ccc10b34..ad78f01e7398 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -25,7 +25,6 @@
#include <vcl/commandevent.hxx>
#include <vcl/window.hxx>
#include <sal/log.hxx>
-#include <sfx2/app.hxx>
#include <sfx2/msg.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/request.hxx>
@@ -108,6 +107,11 @@ int SfxLokHelper::createView()
return createView(pViewShell->GetViewFrame(), pViewShell->GetDocId());
}
+std::unordered_map<OUString, css::uno::Reference<com::sun::star::ui::XAcceleratorConfiguration>>& SfxLokHelper::getAcceleratorConfs()
+{
+ return SfxApplication::GetOrCreate()->GetAcceleratorConfs_Impl();
+}
+
int SfxLokHelper::createView(int nDocId)
{
const SfxApplication* pApp = SfxApplication::Get();
@@ -168,13 +172,13 @@ void SfxLokHelper::setView(int nId)
{
DisableCallbacks dc;
+ if (pViewShell == SfxViewShell::Current())
+ return;
+
// update the current LOK language and locale for the dialog tunneling
comphelper::LibreOfficeKit::setLanguageTag(pViewShell->GetLOKLanguageTag());
comphelper::LibreOfficeKit::setLocale(pViewShell->GetLOKLocale());
- if (pViewShell == SfxViewShell::Current())
- return;
-
SfxViewFrame& rViewFrame = pViewShell->GetViewFrame();
rViewFrame.MakeActive_Impl(false);
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 911629bb8e30..934a12f0b5ba 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -47,6 +47,7 @@
#include <com/sun/star/view/XRenderable.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
#include <comphelper/diagnose_ex.hxx>
#include <tools/urlobj.hxx>
@@ -90,6 +91,7 @@
#include <vector>
#include <libxml/xmlwriter.h>
#include <toolkit/awt/vclxmenu.hxx>
+#include <unordered_map>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -1396,11 +1398,50 @@ void SfxViewShell::Notify( SfxBroadcaster& rBC,
bool SfxViewShell::ExecKey_Impl(const KeyEvent& aKey)
{
+ bool setModuleConfig = false; // In case libreofficekit is active, we will re-set the module config class.
if (!pImpl->m_xAccExec)
{
pImpl->m_xAccExec = ::svt::AcceleratorExecute::createAcceleratorHelper();
pImpl->m_xAccExec->init(::comphelper::getProcessComponentContext(),
rFrame.GetFrame().GetFrameInterface());
+ setModuleConfig = true;
+ }
+
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ // Get the module name.
+ css::uno::Reference< css::uno::XComponentContext > xContext (::comphelper::getProcessComponentContext());
+ css::uno::Reference< css::frame::XModuleManager2 > xModuleManager(css::frame::ModuleManager::create(xContext));
+ OUString sModule = xModuleManager->identify(rFrame.GetFrame().GetFrameInterface());
+
+ // Get the language name.
+ OUString viewLang = GetLOKLanguageTag().getBcp47();
+
+ // Merge them & have a key.
+ OUString key = sModule + viewLang;
+
+ // Check it in configurations map. Create a configuration manager if there isn't one for the key.
+ std::unordered_map<OUString, css::uno::Reference<com::sun::star::ui::XAcceleratorConfiguration>>& acceleratorConfs = SfxApplication::Get()->GetAcceleratorConfs_Impl();
+ if (acceleratorConfs.find(key) == acceleratorConfs.end())
+ {
+ // Create a new configuration manager for the module.
+
+ OUString actualLang = officecfg::Setup::L10N::ooLocale::get();
+
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
+ officecfg::Setup::L10N::ooLocale::set(viewLang, batch);
+ batch->commit();
+
+ // We have set the language. Time to create the config manager.
+ acceleratorConfs[key] = svt::AcceleratorExecute::lok_createNewAcceleratorConfiguration(::comphelper::getProcessComponentContext(), sModule);
+
+ std::shared_ptr<comphelper::ConfigurationChanges> batch2(comphelper::ConfigurationChanges::create());
+ officecfg::Setup::L10N::ooLocale::set(actualLang, batch2);
+ batch2->commit();
+ }
+
+ if (setModuleConfig)
+ pImpl->m_xAccExec->lok_setModuleConfig(acceleratorConfs[key]);
}
return pImpl->m_xAccExec->execute(aKey.GetKeyCode());
diff --git a/svtools/source/misc/acceleratorexecute.cxx b/svtools/source/misc/acceleratorexecute.cxx
index 23f2b3cdacdf..134db44efc1d 100644
--- a/svtools/source/misc/acceleratorexecute.cxx
+++ b/svtools/source/misc/acceleratorexecute.cxx
@@ -24,6 +24,8 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+#include <com/sun/star/ui/XUIConfigurationManager3.hpp>
+#include <com/sun/star/ui/XModuleUIConfigurationManager3.hpp>
#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/awt/KeyModifier.hpp>
@@ -38,6 +40,8 @@
#include <vcl/lok.hxx>
#include <rtl/ref.hxx>
+#include <comphelper/lok.hxx>
+
namespace svt
{
@@ -406,6 +410,29 @@ css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::st
return xAccCfg;
}
+css::uno::Reference<css::ui::XAcceleratorConfiguration> AcceleratorExecute::lok_createNewAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& rxContext, OUString sModule)
+{
+ css::uno::Reference< css::ui::XModuleUIConfigurationManagerSupplier > xUISupplier(css::ui::theModuleUIConfigurationManagerSupplier::get(rxContext));
+
+ try
+ {
+ css::uno::Reference<css::ui::XUIConfigurationManager> xUIManager = xUISupplier->getUIConfigurationManager(sModule);
+
+ css::ui::XModuleUIConfigurationManager3* t = static_cast<css::ui::XModuleUIConfigurationManager3*>(xUIManager.get());
+
+ // Return new short cut manager in case current view's language is different from previous ones.
+ return t->createShortCutManager();
+ }
+ catch(const css::container::NoSuchElementException&)
+ {}
+
+ return css::uno::Reference<css::ui::XAcceleratorConfiguration>();
+}
+
+void AcceleratorExecute::lok_setModuleConfig(css::uno::Reference<css::ui::XAcceleratorConfiguration> acceleratorConfig)
+{
+ this->m_xModuleCfg = acceleratorConfig;
+}
css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::st_openDocConfig(const css::uno::Reference< css::frame::XModel >& xModel)
{