summaryrefslogtreecommitdiff
path: root/framework/source/uielement/uicommanddescription.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'framework/source/uielement/uicommanddescription.cxx')
-rw-r--r--framework/source/uielement/uicommanddescription.cxx83
1 files changed, 42 insertions, 41 deletions
diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx
index 90051358f5be..0b8bad8ccdfa 100644
--- a/framework/source/uielement/uicommanddescription.cxx
+++ b/framework/source/uielement/uicommanddescription.cxx
@@ -39,6 +39,7 @@
#include <vcl/mnemonic.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/string.hxx>
@@ -54,7 +55,7 @@ using namespace ::com::sun::star::frame;
const char CONFIGURATION_ROOT_ACCESS[] = "/org.openoffice.Office.UI.";
// Special resource URLs to retrieve additional information
-constexpr OUStringLiteral PRIVATE_RESOURCE_URL = u"private:";
+constexpr OUString PRIVATE_RESOURCE_URL = u"private:"_ustr;
const sal_Int32 COMMAND_PROPERTY_IMAGE = 1;
const sal_Int32 COMMAND_PROPERTY_ROTATE = 2;
@@ -70,7 +71,7 @@ namespace {
class ConfigurationAccess_UICommand : // Order is necessary for right initialization!
public ::cppu::WeakImplHelper<XNameAccess,XContainerListener>
{
- osl::Mutex m_aMutex;
+ std::mutex m_aMutex;
public:
ConfigurationAccess_UICommand( std::u16string_view aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XComponentContext >& rxContext );
virtual ~ConfigurationAccess_UICommand() override;
@@ -119,7 +120,7 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa
Any getSequenceFromCache( const OUString& aCommandURL );
Any getInfoFromCommand( const OUString& rCommandURL );
- void fillInfoFromResult( CmdToInfoMap& rCmdInfo, const OUString& aLabel );
+ static void fillInfoFromResult( CmdToInfoMap& rCmdInfo, const OUString& aLabel );
Sequence< OUString > getAllCommands();
void fillCache();
void addGenericInfoToCache();
@@ -175,7 +176,7 @@ ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( std::u16string_vie
ConfigurationAccess_UICommand::~ConfigurationAccess_UICommand()
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
if ( xContainer.is() )
xContainer->removeContainerListener(m_xConfigListener);
@@ -187,7 +188,7 @@ ConfigurationAccess_UICommand::~ConfigurationAccess_UICommand()
// XNameAccess
Any ConfigurationAccess_UICommand::getByNameImpl( const OUString& rCommandURL )
{
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
if ( !m_bConfigAccessInitialized )
{
initializeConfigAccess();
@@ -202,11 +203,11 @@ Any ConfigurationAccess_UICommand::getByNameImpl( const OUString& rCommandURL )
addGenericInfoToCache();
if ( rCommandURL.equalsIgnoreAsciiCase( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDIMAGELIST ))
- return makeAny( m_aCommandImageList );
+ return Any( m_aCommandImageList );
else if ( rCommandURL.equalsIgnoreAsciiCase( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDROTATEIMAGELIST ))
- return makeAny( m_aCommandRotateImageList );
+ return Any( m_aCommandRotateImageList );
else if ( rCommandURL.equalsIgnoreAsciiCase( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDMIRRORIMAGELIST ))
- return makeAny( m_aCommandMirrorImageList );
+ return Any( m_aCommandMirrorImageList );
else
return Any();
}
@@ -248,6 +249,7 @@ sal_Bool SAL_CALL ConfigurationAccess_UICommand::hasElements()
return true;
}
+// static
void ConfigurationAccess_UICommand::fillInfoFromResult( CmdToInfoMap& rCmdInfo, const OUString& aLabel )
{
OUString aStr(aLabel.replaceAll("%PRODUCTNAME", utl::ConfigManager::getProductName()));
@@ -265,25 +267,26 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman
if ( !pIter->second.bCommandNameCreated )
fillInfoFromResult( pIter->second, pIter->second.aLabel );
- Sequence< PropertyValue > aPropSeq( 8 );
- aPropSeq[0].Name = "Label";
- aPropSeq[0].Value = !pIter->second.aContextLabel.isEmpty() ?
- makeAny( pIter->second.aContextLabel ): makeAny( pIter->second.aLabel );
- aPropSeq[1].Name = "Name";
- aPropSeq[1].Value <<= pIter->second.aCommandName;
- aPropSeq[2].Name = "Popup";
- aPropSeq[2].Value <<= pIter->second.bPopup;
- aPropSeq[3].Name = m_aPropProperties;
- aPropSeq[3].Value <<= pIter->second.nProperties;
- aPropSeq[4].Name = "PopupLabel";
- aPropSeq[4].Value <<= pIter->second.aPopupLabel;
- aPropSeq[5].Name = "TooltipLabel";
- aPropSeq[5].Value <<= pIter->second.aTooltipLabel;
- aPropSeq[6].Name = "TargetURL";
- aPropSeq[6].Value <<= pIter->second.aTargetURL;
- aPropSeq[7].Name = "IsExperimental";
- aPropSeq[7].Value <<= pIter->second.bIsExperimental;
- return makeAny( aPropSeq );
+ static constexpr OUString sLabel = u"Label"_ustr;
+ static constexpr OUString sName = u"Name"_ustr;
+ static constexpr OUString sPopup = u"Popup"_ustr;
+ static constexpr OUString sPopupLabel = u"PopupLabel"_ustr;
+ static constexpr OUString sTooltipLabel = u"TooltipLabel"_ustr;
+ static constexpr OUString sTargetURL = u"TargetURL"_ustr;
+ static constexpr OUString sIsExperimental = u"IsExperimental"_ustr;
+ Sequence< PropertyValue > aPropSeq{
+ comphelper::makePropertyValue(sLabel, !pIter->second.aContextLabel.isEmpty()
+ ? Any(pIter->second.aContextLabel)
+ : Any(pIter->second.aLabel)),
+ comphelper::makePropertyValue(sName, pIter->second.aCommandName),
+ comphelper::makePropertyValue(sPopup, pIter->second.bPopup),
+ comphelper::makePropertyValue(m_aPropProperties, pIter->second.nProperties),
+ comphelper::makePropertyValue(sPopupLabel, pIter->second.aPopupLabel),
+ comphelper::makePropertyValue(sTooltipLabel, pIter->second.aTooltipLabel),
+ comphelper::makePropertyValue(sTargetURL, pIter->second.aTargetURL),
+ comphelper::makePropertyValue(sIsExperimental, pIter->second.bIsExperimental)
+ };
+ return Any( aPropSeq );
}
return Any();
@@ -430,7 +433,7 @@ Any ConfigurationAccess_UICommand::getInfoFromCommand( const OUString& rCommandU
Sequence< OUString > ConfigurationAccess_UICommand::getAllCommands()
{
// SAFE
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
if ( !m_bConfigAccessInitialized )
{
@@ -521,21 +524,21 @@ void ConfigurationAccess_UICommand::initializeConfigAccess()
// container.XContainerListener
void SAL_CALL ConfigurationAccess_UICommand::elementInserted( const ContainerEvent& )
{
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
m_bCacheFilled = false;
fillCache();
}
void SAL_CALL ConfigurationAccess_UICommand::elementRemoved( const ContainerEvent& )
{
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
m_bCacheFilled = false;
fillCache();
}
void SAL_CALL ConfigurationAccess_UICommand::elementReplaced( const ContainerEvent& )
{
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
m_bCacheFilled = false;
fillCache();
}
@@ -545,7 +548,7 @@ void SAL_CALL ConfigurationAccess_UICommand::disposing( const EventObject& aEven
{
// SAFE
// remove our reference to the config access
- osl::MutexGuard g(m_aMutex);
+ std::unique_lock g(m_aMutex);
Reference< XInterface > xIfac1( aEvent.Source, UNO_QUERY );
Reference< XInterface > xIfac2( m_xConfigAccess, UNO_QUERY );
@@ -570,8 +573,7 @@ void UICommandDescription::ensureGenericUICommandsForLanguage(const LanguageTag&
}
UICommandDescription::UICommandDescription(const Reference< XComponentContext >& rxContext)
- : UICommandDescription_BASE(m_aMutex)
- , m_aPrivateResourceURL(PRIVATE_RESOURCE_URL)
+ : m_aPrivateResourceURL(PRIVATE_RESOURCE_URL)
, m_xContext(rxContext)
{
SvtSysLocale aSysLocale;
@@ -589,14 +591,13 @@ UICommandDescription::UICommandDescription(const Reference< XComponentContext >&
}
UICommandDescription::UICommandDescription(const Reference< XComponentContext >& rxContext, bool)
- : UICommandDescription_BASE(m_aMutex)
- , m_xContext(rxContext)
+ : m_xContext(rxContext)
{
}
UICommandDescription::~UICommandDescription()
{
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
m_aModuleToCommandFileMap.clear();
m_aUICommandsHashMap.clear();
m_xGenericUICommands.clear();
@@ -614,7 +615,7 @@ void UICommandDescription::impl_fillElements(const char* _pName)
if ( m_xModuleManager->getByName( aModuleIdentifier ) >>= aSeq )
{
OUString aCommandStr;
- for ( PropertyValue const & prop : std::as_const(aSeq) )
+ for (PropertyValue const& prop : aSeq)
{
if ( prop.Name.equalsAscii(_pName) )
{
@@ -642,7 +643,7 @@ Any SAL_CALL UICommandDescription::getByName( const OUString& aName )
const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
Any a;
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
ModuleToCommandFileMap::const_iterator pM2CIter = m_aModuleToCommandFileMap.find( aName );
if ( pM2CIter != m_aModuleToCommandFileMap.end() )
@@ -687,14 +688,14 @@ Any SAL_CALL UICommandDescription::getByName( const OUString& aName )
Sequence< OUString > SAL_CALL UICommandDescription::getElementNames()
{
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
return comphelper::mapKeysToSequence( m_aModuleToCommandFileMap );
}
sal_Bool SAL_CALL UICommandDescription::hasByName( const OUString& aName )
{
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
ModuleToCommandFileMap::const_iterator pIter = m_aModuleToCommandFileMap.find( aName );
return ( pIter != m_aModuleToCommandFileMap.end() );