summaryrefslogtreecommitdiffstats
path: root/framework/source/accelerators/acceleratorconfiguration.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'framework/source/accelerators/acceleratorconfiguration.cxx')
-rw-r--r--framework/source/accelerators/acceleratorconfiguration.cxx70
1 files changed, 37 insertions, 33 deletions
diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx
index 90b393ace7fd..4f34dfc0141b 100644
--- a/framework/source/accelerators/acceleratorconfiguration.cxx
+++ b/framework/source/accelerators/acceleratorconfiguration.cxx
@@ -51,19 +51,23 @@
#include <svtools/acceleratorexecute.hxx>
#include <sal/log.hxx>
#include <rtl/ustrbuf.hxx>
+#include <o3tl/string_view.hxx>
-constexpr OUStringLiteral PRESET_DEFAULT = u"default";
-constexpr OUStringLiteral TARGET_CURRENT = u"current";
+constexpr OUString PRESET_DEFAULT = u"default"_ustr;
+constexpr OUString TARGET_CURRENT = u"current"_ustr;
namespace framework
{
- constexpr OUStringLiteral CFG_ENTRY_SECONDARY = u"SecondaryKeys";
- constexpr OUStringLiteral CFG_PROP_COMMAND = u"Command";
+ constexpr OUString CFG_ENTRY_SECONDARY = u"SecondaryKeys"_ustr;
+ constexpr OUString CFG_PROP_COMMAND = u"Command"_ustr;
static OUString lcl_getKeyString(const css::awt::KeyEvent& aKeyEvent)
{
const sal_Int32 nBeginIndex = 4; // "KEY_" is the prefix of an identifier...
- OUStringBuffer sKeyBuffer((KeyMapping::get().mapCodeToIdentifier(aKeyEvent.KeyCode)).subView(nBeginIndex));
+ OUString sKey(KeyMapping::get().mapCodeToIdentifier(aKeyEvent.KeyCode));
+ if (sKey.getLength() < nBeginIndex) // dead key
+ return OUString();
+ OUStringBuffer sKeyBuffer(sKey.subView(nBeginIndex));
if ( (aKeyEvent.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT )
sKeyBuffer.append("_SHIFT");
@@ -460,7 +464,8 @@ AcceleratorCache& XMLBasedAcceleratorConfiguration::impl_getCFG(bool bWriteAcces
return m_aReadCache;
}
-OUString XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const
+// static
+OUString XMLBasedAcceleratorConfiguration::impl_ts_getLocale()
{
OUString sISOLocale = officecfg::Setup::L10N::ooLocale::get();
@@ -475,8 +480,8 @@ OUString XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const
*
*******************************************************************************/
-XCUBasedAcceleratorConfiguration::XCUBasedAcceleratorConfiguration(const css::uno::Reference< css::uno::XComponentContext >& xContext)
- : m_xContext (xContext )
+XCUBasedAcceleratorConfiguration::XCUBasedAcceleratorConfiguration(css::uno::Reference< css::uno::XComponentContext > xContext)
+ : m_xContext (std::move(xContext ))
{
m_xCfg.set(
::comphelper::ConfigurationHelper::openConfig( m_xContext, "org.openoffice.Office.Accelerators", ::comphelper::EConfigurationModes::AllLocales ),
@@ -613,10 +618,9 @@ void SAL_CALL XCUBasedAcceleratorConfiguration::removeKeyEvent(const css::awt::K
if (rPrimaryCache.hasKey(aKeyEvent))
{
- OUString sDelCommand = rPrimaryCache.getCommandByKey(aKeyEvent);
- if (!sDelCommand.isEmpty())
+ OUString sOriginalCommand = rPrimaryCache.getCommandByKey(aKeyEvent);
+ if (!sOriginalCommand.isEmpty())
{
- OUString sOriginalCommand = rPrimaryCache.getCommandByKey(aKeyEvent);
if (rSecondaryCache.hasCommand(sOriginalCommand))
{
AcceleratorCache::TKeyList lSecondaryKeys = rSecondaryCache.getKeysByCommand(sOriginalCommand);
@@ -959,7 +963,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( bool bPreferred, const css:
}
const OUString sIsoLang = impl_ts_getLocale();
- static const OUStringLiteral sDefaultLocale(u"en-US");
+ static constexpr OUStringLiteral sDefaultLocale(u"en-US");
css::uno::Reference< css::container::XNameAccess > xKey;
css::uno::Reference< css::container::XNameAccess > xCommand;
@@ -1009,8 +1013,8 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( bool bPreferred, const css:
css::awt::KeyEvent aKeyEvent;
sal_Int32 nIndex = 0;
- OUString sKeyCommand = sKey.getToken(0, '_', nIndex);
- aKeyEvent.KeyCode = KeyMapping::get().mapIdentifierToCode("KEY_" + sKeyCommand);
+ std::u16string_view sKeyCommand = o3tl::getToken(sKey, 0, '_', nIndex);
+ aKeyEvent.KeyCode = KeyMapping::get().mapIdentifierToCode(OUString::Concat("KEY_") + sKeyCommand);
const sal_Int32 nToken = 4;
bool bValid = true;
@@ -1020,20 +1024,20 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( bool bPreferred, const css:
if (nIndex < 0)
break;
- OUString sToken = sKey.getToken(0, '_', nIndex);
- if (sToken.isEmpty())
+ std::u16string_view sToken = o3tl::getToken(sKey, 0, '_', nIndex);
+ if (sToken.empty())
{
bValid = false;
break;
}
- if ( sToken == "SHIFT" )
+ if ( sToken == u"SHIFT" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::SHIFT;
- else if ( sToken == "MOD1" )
+ else if ( sToken == u"MOD1" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD1;
- else if ( sToken == "MOD2" )
+ else if ( sToken == u"MOD2" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD2;
- else if ( sToken == "MOD3" )
+ else if ( sToken == u"MOD3" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD3;
else
{
@@ -1152,7 +1156,7 @@ void XCUBasedAcceleratorConfiguration::insertKeyToConfiguration( const css::awt:
{
xFac.set(xModules, css::uno::UNO_QUERY);
xInst = xFac->createInstance();
- xModules->insertByName(m_sModuleCFG, css::uno::makeAny(xInst));
+ xModules->insertByName(m_sModuleCFG, css::uno::Any(xInst));
}
xModules->getByName(m_sModuleCFG) >>= xContainer;
}
@@ -1164,16 +1168,16 @@ void XCUBasedAcceleratorConfiguration::insertKeyToConfiguration( const css::awt:
{
xFac.set(xContainer, css::uno::UNO_QUERY);
xInst = xFac->createInstance();
- xContainer->insertByName(sKey, css::uno::makeAny(xInst));
+ xContainer->insertByName(sKey, css::uno::Any(xInst));
}
xContainer->getByName(sKey) >>= xKey;
xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
OUString sLocale = impl_ts_getLocale();
if ( !xCommand->hasByName(sLocale) )
- xCommand->insertByName(sLocale, css::uno::makeAny(sCommand));
+ xCommand->insertByName(sLocale, css::uno::Any(sCommand));
else
- xCommand->replaceByName(sLocale, css::uno::makeAny(sCommand));
+ xCommand->replaceByName(sLocale, css::uno::Any(sCommand));
}
void XCUBasedAcceleratorConfiguration::removeKeyFromConfiguration( const css::awt::KeyEvent& aKeyEvent, const bool bPreferred )
@@ -1219,11 +1223,10 @@ void XCUBasedAcceleratorConfiguration::reloadChanged( const OUString& sPrimarySe
}
css::awt::KeyEvent aKeyEvent;
- OUString sKeyIdentifier;
sal_Int32 nIndex = 0;
- sKeyIdentifier = sKey.getToken(0, '_', nIndex);
- aKeyEvent.KeyCode = KeyMapping::get().mapIdentifierToCode("KEY_"+sKeyIdentifier);
+ std::u16string_view sKeyIdentifier = o3tl::getToken(sKey, 0, '_', nIndex);
+ aKeyEvent.KeyCode = KeyMapping::get().mapIdentifierToCode(OUString::Concat("KEY_") + sKeyIdentifier);
const int nToken = 4;
for (sal_Int32 i = 0; i < nToken; ++i)
@@ -1231,14 +1234,14 @@ void XCUBasedAcceleratorConfiguration::reloadChanged( const OUString& sPrimarySe
if ( nIndex < 0 )
break;
- OUString sToken = sKey.getToken(0, '_', nIndex);
- if ( sToken == "SHIFT" )
+ std::u16string_view sToken = o3tl::getToken(sKey, 0, '_', nIndex);
+ if ( sToken == u"SHIFT" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::SHIFT;
- else if ( sToken == "MOD1" )
+ else if ( sToken == u"MOD1" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD1;
- else if ( sToken == "MOD2" )
+ else if ( sToken == u"MOD2" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD2;
- else if ( sToken == "MOD3" )
+ else if ( sToken == u"MOD3" )
aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD3;
}
@@ -1309,7 +1312,8 @@ AcceleratorCache& XCUBasedAcceleratorConfiguration::impl_getCFG(bool bPreferred,
}
}
-OUString XCUBasedAcceleratorConfiguration::impl_ts_getLocale() const
+// static
+OUString XCUBasedAcceleratorConfiguration::impl_ts_getLocale()
{
OUString sISOLocale = officecfg::Setup::L10N::ooLocale::get();