summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorGökay Şatır <gokaysatir@collabora.com>2023-02-16 16:47:22 +0300
committerMiklos Vajna <vmiklos@collabora.com>2023-05-23 15:40:57 +0200
commitd4bc98c5bf8d099ab1df32cc8ac30169ac537e62 (patch)
tree84f830febb400fa16c05b0e44e30b20d001aec65 /desktop
parentef76718e7146b9c7c878d598d2e9b5125b278d69 (diff)
[API CHANGE] Add createShortCutManager function to uiconfigurationmanager.
We need to have different accelerator classes for differnt languages. This PR creates a new accelerator class for different languages. Since current code uses single instance for accelerators, i needed to add a create function. Also we now have an unordered map for different languages and modules. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147157 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148680 Tested-by: Miklos Vajna <vmiklos@collabora.com> Change-Id: Ia646f20b3206f430ece614fc127e8b748044e4c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151798 Tested-by: Jenkins
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx48
1 files changed, 48 insertions, 0 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