[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - framework/inc framework/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Tue Sep 8 08:55:26 UTC 2020
framework/inc/uielement/uicommanddescription.hxx | 7 +
framework/source/uiconfiguration/uicategorydescription.cxx | 11 +-
framework/source/uielement/uicommanddescription.cxx | 50 +++++++++----
3 files changed, 50 insertions(+), 18 deletions(-)
New commits:
commit ce28e812b7b00f1d6c99a0c1ce76ddbd5a1a3a0e
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Sep 3 21:07:22 2020 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Sep 8 10:54:52 2020 +0200
lok: make labels and tooltips translated for commands
In the online we can have multiple sessions with
different languages so load cached translations only
if match current language
Change-Id: I6fcf23f1c340c0c0daffa8862f0b74e4e458c1fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102016
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/framework/inc/uielement/uicommanddescription.hxx b/framework/inc/uielement/uicommanddescription.hxx
index d2eb672cd71d..bf575113bbf9 100644
--- a/framework/inc/uielement/uicommanddescription.hxx
+++ b/framework/inc/uielement/uicommanddescription.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_FRAMEWORK_INC_UIELEMENT_UICOMMANDDESCRIPTION_HXX
#include <unordered_map>
+#include <map>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/frame/XModuleManager2.hpp>
@@ -30,6 +31,7 @@
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <rtl/ustring.hxx>
+#include <i18nlangtag/languagetag.hxx>
namespace framework
{
@@ -81,12 +83,13 @@ public:
protected:
UICommandDescription( const css::uno::Reference< css::uno::XComponentContext>& rxContext, bool );
void impl_fillElements(const sal_Char* _pName);
+ void ensureGenericUICommandsForLanguage(const LanguageTag& rLanguage);
OUString m_aPrivateResourceURL;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
ModuleToCommandFileMap m_aModuleToCommandFileMap;
- UICommandsHashMap m_aUICommandsHashMap;
- css::uno::Reference< css::container::XNameAccess > m_xGenericUICommands;
+ std::map<LanguageTag, UICommandsHashMap> m_aUICommandsHashMap;
+ std::map<LanguageTag, css::uno::Reference< css::container::XNameAccess > > m_xGenericUICommands;
css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
};
diff --git a/framework/source/uiconfiguration/uicategorydescription.cxx b/framework/source/uiconfiguration/uicategorydescription.cxx
index f7b1d3665033..d390a3e3301a 100644
--- a/framework/source/uiconfiguration/uicategorydescription.cxx
+++ b/framework/source/uiconfiguration/uicategorydescription.cxx
@@ -36,6 +36,7 @@
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <unotools/configmgr.hxx>
+#include <unotools/syslocale.hxx>
#include <vcl/mnemonic.hxx>
#include <comphelper/propertysequence.hxx>
@@ -373,16 +374,18 @@ public:
UICategoryDescription::UICategoryDescription( const Reference< XComponentContext >& rxContext ) :
UICommandDescription(rxContext,true)
{
+ LanguageTag aCurrentLanguage = SvtSysLocale().GetUILanguageTag();
Reference< XNameAccess > xEmpty;
OUString aGenericCategories( "GenericCategories" );
- m_xGenericUICommands = new ConfigurationAccess_UICategory( aGenericCategories, xEmpty, rxContext );
+ m_xGenericUICommands[aCurrentLanguage] = new ConfigurationAccess_UICategory( aGenericCategories, xEmpty, rxContext );
// insert generic categories mappings
m_aModuleToCommandFileMap.emplace( OUString("generic"), aGenericCategories );
- UICommandsHashMap::iterator pCatIter = m_aUICommandsHashMap.find( aGenericCategories );
- if ( pCatIter != m_aUICommandsHashMap.end() )
- pCatIter->second = m_xGenericUICommands;
+ auto& rMap = m_aUICommandsHashMap[aCurrentLanguage];
+ UICommandsHashMap::iterator pCatIter = rMap.find( aGenericCategories );
+ if ( pCatIter != rMap.end() )
+ pCatIter->second = m_xGenericUICommands[aCurrentLanguage];
impl_fillElements("ooSetupFactoryCmdCategoryConfigRef");
}
diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx
index 02e41f47fcb3..73b21626ea32 100644
--- a/framework/source/uielement/uicommanddescription.cxx
+++ b/framework/source/uielement/uicommanddescription.cxx
@@ -34,6 +34,7 @@
#include <rtl/ustrbuf.hxx>
#include <cppuhelper/implbase.hxx>
#include <unotools/configmgr.hxx>
+#include <unotools/syslocale.hxx>
#include <vcl/mnemonic.hxx>
#include <comphelper/propertysequence.hxx>
@@ -554,21 +555,34 @@ void SAL_CALL ConfigurationAccess_UICommand::disposing( const EventObject& aEven
}
}
+void UICommandDescription::ensureGenericUICommandsForLanguage(const LanguageTag& rLanguage)
+{
+ auto xGenericUICommands = m_xGenericUICommands.find(rLanguage);
+ if (xGenericUICommands == m_xGenericUICommands.end())
+ {
+ Reference< XNameAccess > xEmpty;
+ OUString aGenericUICommand( "GenericCommands" );
+ m_xGenericUICommands[rLanguage] = new ConfigurationAccess_UICommand( aGenericUICommand, xEmpty, m_xContext );
+ }
+}
+
UICommandDescription::UICommandDescription(const Reference< XComponentContext >& rxContext)
: UICommandDescription_BASE(m_aMutex)
, m_aPrivateResourceURL(PRIVATE_RESOURCE_URL)
, m_xContext(rxContext)
{
- Reference< XNameAccess > xEmpty;
+ LanguageTag aCurrentLanguage = SvtSysLocale().GetUILanguageTag();
OUString aGenericUICommand( "GenericCommands" );
- m_xGenericUICommands = new ConfigurationAccess_UICommand( aGenericUICommand, xEmpty, m_xContext );
+
+ ensureGenericUICommandsForLanguage(aCurrentLanguage);
impl_fillElements("ooSetupFactoryCommandConfigRef");
// insert generic commands
- UICommandsHashMap::iterator pIter = m_aUICommandsHashMap.find( aGenericUICommand );
- if ( pIter != m_aUICommandsHashMap.end() )
- pIter->second = m_xGenericUICommands;
+ auto& rMap = m_aUICommandsHashMap[aCurrentLanguage];
+ UICommandsHashMap::iterator pIter = rMap.find( aGenericUICommand );
+ if ( pIter != rMap.end() )
+ pIter->second = m_xGenericUICommands[aCurrentLanguage];
}
UICommandDescription::UICommandDescription(const Reference< XComponentContext >& rxContext, bool)
@@ -610,15 +624,18 @@ void UICommandDescription::impl_fillElements(const sal_Char* _pName)
m_aModuleToCommandFileMap.emplace( aModuleIdentifier, aCommandStr );
// Create second mapping Command File ==> commands instance
- UICommandsHashMap::iterator pIter = m_aUICommandsHashMap.find( aCommandStr );
- if ( pIter == m_aUICommandsHashMap.end() )
- m_aUICommandsHashMap.emplace( aCommandStr, Reference< XNameAccess >() );
+ LanguageTag aCurrentLanguage = SvtSysLocale().GetUILanguageTag();
+ auto& rMap = m_aUICommandsHashMap[aCurrentLanguage];
+ UICommandsHashMap::iterator pIter = rMap.find( aCommandStr );
+ if ( pIter == rMap.end() )
+ rMap.emplace( aCommandStr, Reference< XNameAccess >() );
}
} // for ( sal_Int32 i = 0; i < aElementNames.getLength(); i++ )
}
Any SAL_CALL UICommandDescription::getByName( const OUString& aName )
{
+ LanguageTag aCurrentLanguage = SvtSysLocale().GetUILanguageTag();
Any a;
osl::MutexGuard g(rBHelper.rMutex);
@@ -627,16 +644,23 @@ Any SAL_CALL UICommandDescription::getByName( const OUString& aName )
if ( pM2CIter != m_aModuleToCommandFileMap.end() )
{
OUString aCommandFile( pM2CIter->second );
- UICommandsHashMap::iterator pIter = m_aUICommandsHashMap.find( aCommandFile );
- if ( pIter != m_aUICommandsHashMap.end() )
+ auto pMapIter = m_aUICommandsHashMap.find( aCurrentLanguage );
+ if ( pMapIter == m_aUICommandsHashMap.end() )
+ impl_fillElements("ooSetupFactoryCommandConfigRef");
+
+ auto& rMap = m_aUICommandsHashMap[aCurrentLanguage];
+ UICommandsHashMap::iterator pIter = rMap.find( aCommandFile );
+ if ( pIter != rMap.end() )
{
if ( pIter->second.is() )
a <<= pIter->second;
else
{
+ ensureGenericUICommandsForLanguage(aCurrentLanguage);
+
Reference< XNameAccess > xUICommands;
ConfigurationAccess_UICommand* pUICommands = new ConfigurationAccess_UICommand( aCommandFile,
- m_xGenericUICommands,
+ m_xGenericUICommands[aCurrentLanguage],
m_xContext );
xUICommands.set( static_cast< cppu::OWeakObject* >( pUICommands ),UNO_QUERY );
pIter->second = xUICommands;
@@ -646,8 +670,10 @@ Any SAL_CALL UICommandDescription::getByName( const OUString& aName )
}
else if ( !m_aPrivateResourceURL.isEmpty() && aName.startsWith( m_aPrivateResourceURL ) )
{
+ ensureGenericUICommandsForLanguage(aCurrentLanguage);
+
// special keys to retrieve information about a set of commands
- return m_xGenericUICommands->getByName( aName );
+ return m_xGenericUICommands[aCurrentLanguage]->getByName( aName );
}
else
{
More information about the Libreoffice-commits
mailing list