summaryrefslogtreecommitdiffstats
path: root/framework/source/uiconfiguration/uiconfigurationmanager.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'framework/source/uiconfiguration/uiconfigurationmanager.cxx')
-rw-r--r--framework/source/uiconfiguration/uiconfigurationmanager.cxx108
1 files changed, 52 insertions, 56 deletions
diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
index b3b443b99d5c..c1a24e598615 100644
--- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
@@ -51,8 +51,10 @@
#include <comphelper/interfacecontainer4.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/servicehelper.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <sal/log.hxx>
+#include <o3tl/string_view.hxx>
#include <mutex>
#include <string_view>
@@ -89,7 +91,7 @@ public:
return {"com.sun.star.ui.UIConfigurationManager"};
}
- explicit UIConfigurationManager( const css::uno::Reference< css::uno::XComponentContext > & rxContext );
+ explicit UIConfigurationManager( css::uno::Reference< css::uno::XComponentContext > xContext );
// XComponent
virtual void SAL_CALL dispose() override;
@@ -111,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
@@ -135,8 +138,8 @@ private:
struct UIElementInfo
{
- UIElementInfo( const OUString& rResourceURL, const OUString& rUIName ) :
- aResourceURL( rResourceURL), aUIName( rUIName ) {}
+ UIElementInfo( OUString _aResourceURL, OUString _aUIName ) :
+ aResourceURL(std::move( _aResourceURL)), aUIName(std::move( _aUIName )) {}
OUString aResourceURL;
OUString aUIName;
};
@@ -211,20 +214,19 @@ std::u16string_view UIELEMENTTYPENAMES[] =
u"" UIELEMENTTYPE_TOOLPANEL_NAME
};
-const char RESOURCEURL_PREFIX[] = "private:resource/";
-const sal_Int32 RESOURCEURL_PREFIX_SIZE = 17;
+constexpr std::u16string_view RESOURCEURL_PREFIX = u"private:resource/";
-sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL )
+sal_Int16 RetrieveTypeFromResourceURL( std::u16string_view aResourceURL )
{
- if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) &&
- ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
+ if (( o3tl::starts_with(aResourceURL, RESOURCEURL_PREFIX ) ) &&
+ ( aResourceURL.size() > RESOURCEURL_PREFIX.size() ))
{
- OUString aTmpStr = aResourceURL.copy( RESOURCEURL_PREFIX_SIZE );
- sal_Int32 nIndex = aTmpStr.indexOf( '/' );
- if (( nIndex > 0 ) && ( aTmpStr.getLength() > nIndex ))
+ std::u16string_view aTmpStr = aResourceURL.substr( RESOURCEURL_PREFIX.size() );
+ size_t nIndex = aTmpStr.find( '/' );
+ if (( nIndex > 0 ) && ( aTmpStr.size() > nIndex ))
{
- OUString aTypeStr( aTmpStr.copy( 0, nIndex ));
+ std::u16string_view aTypeStr( aTmpStr.substr( 0, nIndex ));
for ( int i = 0; i < UIElementType::COUNT; i++ )
{
if ( aTypeStr == UIELEMENTTYPENAMES[i] )
@@ -236,14 +238,14 @@ sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL )
return UIElementType::UNKNOWN;
}
-OUString RetrieveNameFromResourceURL( const OUString& aResourceURL )
+OUString RetrieveNameFromResourceURL( std::u16string_view aResourceURL )
{
- if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) &&
- ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
+ if (( o3tl::starts_with(aResourceURL, RESOURCEURL_PREFIX ) ) &&
+ ( aResourceURL.size() > RESOURCEURL_PREFIX.size() ))
{
- sal_Int32 nIndex = aResourceURL.lastIndexOf( '/' );
- if (( nIndex > 0 ) && (( nIndex+1 ) < aResourceURL.getLength()))
- return aResourceURL.copy( nIndex+1 );
+ size_t nIndex = aResourceURL.rfind( '/' );
+ if ( (nIndex > 0) && (nIndex != std::u16string_view::npos) && (( nIndex+1 ) < aResourceURL.size()) )
+ return OUString(aResourceURL.substr( nIndex+1 ));
}
return OUString();
@@ -300,11 +302,11 @@ void UIConfigurationManager::impl_preloadUIElementTypeList( sal_Int16 nElementTy
sal_Int32 nIndex = rElementName.lastIndexOf( '.' );
if (( nIndex > 0 ) && ( nIndex < rElementName.getLength() ))
{
- OUString aExtension( rElementName.copy( nIndex+1 ));
- OUString aUIElementName( rElementName.copy( 0, nIndex ));
+ std::u16string_view aExtension( rElementName.subView( nIndex+1 ));
+ std::u16string_view aUIElementName( rElementName.subView( 0, nIndex ));
- if (!aUIElementName.isEmpty() &&
- ( aExtension.equalsIgnoreAsciiCase("xml")))
+ if (!aUIElementName.empty() &&
+ ( o3tl::equalsIgnoreAsciiCase(aExtension, u"xml")))
{
aUIElementData.aResourceURL = aResURLPrefix + aUIElementName;
aUIElementData.aName = rElementName;
@@ -349,7 +351,7 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType,
{
MenuConfiguration aMenuCfg( m_xContext );
Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream ));
- auto pRootItemContainer = comphelper::getFromUnoTunnel<RootItemContainer>( xContainer );
+ auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xContainer.get() );
if ( pRootItemContainer )
aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
else
@@ -368,7 +370,7 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType,
{
Reference< XIndexContainer > xIndexContainer( new RootItemContainer() );
ToolBoxConfiguration::LoadToolBox( m_xContext, xInputStream, xIndexContainer );
- auto pRootItemContainer = comphelper::getFromUnoTunnel<RootItemContainer>( xIndexContainer );
+ auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xIndexContainer.get() );
aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
return;
}
@@ -385,7 +387,7 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType,
{
Reference< XIndexContainer > xIndexContainer( new RootItemContainer() );
StatusBarConfiguration::LoadStatusBar( m_xContext, xInputStream, xIndexContainer );
- auto pRootItemContainer = comphelper::getFromUnoTunnel<RootItemContainer>( xIndexContainer );
+ auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xIndexContainer.get() );
aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
return;
}
@@ -669,12 +671,12 @@ void UIConfigurationManager::impl_Initialize()
}
}
-UIConfigurationManager::UIConfigurationManager( const css::uno::Reference< css::uno::XComponentContext > & rxContext ) :
+UIConfigurationManager::UIConfigurationManager( css::uno::Reference< css::uno::XComponentContext > xContext ) :
m_bReadOnly( true )
, m_bModified( false )
, m_bDisposed( false )
, m_aPropUIName( "UIName" )
- , m_xContext( rxContext )
+ , m_xContext(std::move( xContext ))
{
// Make sure we have a default initialized entry for every layer and user interface element type!
// The following code depends on this!
@@ -866,11 +868,11 @@ Sequence< Sequence< PropertyValue > > SAL_CALL UIConfigurationManager::getUIElem
sal_Int32 n = 0;
for (auto const& elem : aUIElementInfoCollection)
{
- Sequence< PropertyValue > aUIElementInfo{
+ aElementInfoSeq[n++] =
+ {
comphelper::makePropertyValue("ResourceURL", elem.second.aResourceURL),
comphelper::makePropertyValue(m_aPropUIName, elem.second.aUIName)
};
- aElementInfoSeq[n++] = aUIElementInfo;
}
return comphelper::containerToSequence(aElementInfoSeq);
@@ -965,14 +967,13 @@ void SAL_CALL UIConfigurationManager::replaceSettings( const OUString& ResourceU
rElementType.bModified = true;
Reference< XUIConfigurationManager > xThis(this);
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
// Create event to notify listener about replaced element settings
ConfigurationEvent aEvent;
aEvent.ResourceURL = ResourceURL;
aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
+ aEvent.Source.set(xThis, UNO_QUERY);
aEvent.ReplacedElement <<= xOldSettings;
aEvent.Element <<= pDataSettings->xSettings;
@@ -1025,14 +1026,14 @@ void SAL_CALL UIConfigurationManager::removeSettings( const OUString& ResourceUR
rElementType.bModified = true;
Reference< XUIConfigurationManager > xThis(this);
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
// Create event to notify listener about removed element settings
ConfigurationEvent aEvent;
aEvent.ResourceURL = ResourceURL;
aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
+ aEvent.Source.set(xThis, UNO_QUERY);
+
aEvent.Element <<= xRemovedSettings;
aGuard.clear();
@@ -1098,14 +1099,13 @@ void SAL_CALL UIConfigurationManager::insertSettings( const OUString& NewResourc
Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings );
Reference< XUIConfigurationManager > xThis(this);
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
// Create event to notify listener about removed element settings
ConfigurationEvent aEvent;
aEvent.ResourceURL = NewResourceURL;
aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
+ aEvent.Source.set(xThis, UNO_QUERY);
aEvent.Element <<= xInsertSettings;
aGuard.clear();
@@ -1136,6 +1136,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 ->
@@ -1346,29 +1351,20 @@ sal_Bool SAL_CALL UIConfigurationManager::isReadOnly()
void UIConfigurationManager::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp )
{
std::unique_lock aGuard(m_mutex);
- comphelper::OInterfaceIteratorHelper4 pIterator( aGuard, m_aConfigListeners );
- while ( pIterator.hasMoreElements() )
- {
- try
+ m_aConfigListeners.forEach(aGuard, [&eOp, &aEvent](const css::uno::Reference<XUIConfigurationListener>& l) {
+ switch ( eOp )
{
- switch ( eOp )
- {
- case NotifyOp_Replace:
- pIterator.next()->elementReplaced( aEvent );
- break;
- case NotifyOp_Insert:
- pIterator.next()->elementInserted( aEvent );
- break;
- case NotifyOp_Remove:
- pIterator.next()->elementRemoved( aEvent );
- break;
- }
- }
- catch( const css::uno::RuntimeException& )
- {
- pIterator.remove(aGuard);
+ case NotifyOp_Replace:
+ l->elementReplaced( aEvent );
+ break;
+ case NotifyOp_Insert:
+ l->elementInserted( aEvent );
+ break;
+ case NotifyOp_Remove:
+ l->elementRemoved( aEvent );
+ break;
}
- }
+ });
}
}