summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-21 11:53:59 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 08:29:29 +0200
commit4af6c0948be47d7816eb1b6f2137b70aba639f0d (patch)
tree3965a1709f531229a6faaeef2e9d4026a30332b8 /framework
parent7b45044fd14661202c658923842dd629cf52961c (diff)
loplugin:flatten in filter..i18npool
Change-Id: I9024b8b614a4de83a4d927e1918f6d4904a7fccb Reviewed-on: https://gerrit.libreoffice.org/42592 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework')
-rw-r--r--framework/source/fwe/xml/xmlnamespaces.cxx19
-rw-r--r--framework/source/fwi/uielement/constitemcontainer.cxx5
-rw-r--r--framework/source/services/ContextChangeEventMultiplexer.cxx5
-rw-r--r--framework/source/services/substitutepathvars.cxx9
-rw-r--r--framework/source/uiconfiguration/graphicnameaccess.cxx5
-rw-r--r--framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx301
-rw-r--r--framework/source/uiconfiguration/uiconfigurationmanager.cxx112
7 files changed, 215 insertions, 241 deletions
diff --git a/framework/source/fwe/xml/xmlnamespaces.cxx b/framework/source/fwe/xml/xmlnamespaces.cxx
index c13c0bbbf163..a505a2101094 100644
--- a/framework/source/fwe/xml/xmlnamespaces.cxx
+++ b/framework/source/fwe/xml/xmlnamespaces.cxx
@@ -98,16 +98,13 @@ OUString XMLNamespaces::applyNSToAttributeName( const OUString& aName ) const
int index;
if (( index = aName.indexOf( ':' )) > 0 )
{
- if ( aName.getLength() > index+1 )
- {
- OUString aAttributeName = getNamespaceValue( aName.copy( 0, index )) + "^" + aName.copy( index+1);
- return aAttributeName;
- }
- else
+ if ( aName.getLength() <= index+1 )
{
// attribute with namespace but without name "namespace:" is not allowed!!
throw SAXException( "Attribute has no name only preceding namespace!", Reference< XInterface >(), Any() );
}
+ OUString aAttributeName = getNamespaceValue( aName.copy( 0, index )) + "^" + aName.copy( index+1);
+ return aAttributeName;
}
return aName;
@@ -135,13 +132,12 @@ OUString XMLNamespaces::applyNSToElementName( const OUString& aName ) const
if ( index > 0 )
{
- if ( aName.getLength() > index+1 )
- aElementName += aName.copy( index+1 );
- else
+ if ( aName.getLength() <= index+1 )
{
// attribute with namespace but without a name is not allowed (e.g. "cfg:" )
throw SAXException( "Attribute has no name only preceding namespace!", Reference< XInterface >(), Any() );
}
+ aElementName += aName.copy( index+1 );
}
else
aElementName += aName;
@@ -157,13 +153,12 @@ OUString XMLNamespaces::getNamespaceValue( const OUString& aNamespace ) const
{
NamespaceMap::const_iterator p;
p = m_aNamespaceMap.find( aNamespace );
- if ( p != m_aNamespaceMap.end() )
- return p->second;
- else
+ if ( p == m_aNamespaceMap.end() )
{
// namespace not defined => throw exception!
throw SAXException( "XML namespace used but not defined!", Reference< XInterface >(), Any() );
}
+ return p->second;
}
}
diff --git a/framework/source/fwi/uielement/constitemcontainer.cxx b/framework/source/fwi/uielement/constitemcontainer.cxx
index 811e33ba89cb..efe3167c81a9 100644
--- a/framework/source/fwi/uielement/constitemcontainer.cxx
+++ b/framework/source/fwi/uielement/constitemcontainer.cxx
@@ -204,10 +204,9 @@ sal_Int32 SAL_CALL ConstItemContainer::getCount()
Any SAL_CALL ConstItemContainer::getByIndex( sal_Int32 Index )
{
- if ( sal_Int32( m_aItemVector.size()) > Index )
- return makeAny( m_aItemVector[Index] );
- else
+ if ( sal_Int32( m_aItemVector.size()) <= Index )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+ return makeAny( m_aItemVector[Index] );
}
// XPropertySet
diff --git a/framework/source/services/ContextChangeEventMultiplexer.cxx b/framework/source/services/ContextChangeEventMultiplexer.cxx
index ac579eeee802..59eca7c933a6 100644
--- a/framework/source/services/ContextChangeEventMultiplexer.cxx
+++ b/framework/source/services/ContextChangeEventMultiplexer.cxx
@@ -156,14 +156,13 @@ void SAL_CALL ContextChangeEventMultiplexer::addContextChangeEventListener (
if (pFocusDescriptor != nullptr)
{
ListenerContainer& rContainer (pFocusDescriptor->maListeners);
- if (::std::find(rContainer.begin(), rContainer.end(), rxListener) == rContainer.end())
- rContainer.push_back(rxListener);
- else
+ if (::std::find(rContainer.begin(), rContainer.end(), rxListener) != rContainer.end())
{
// The listener was added for the same event focus
// previously. That is an error.
throw cssl::IllegalArgumentException("listener added twice", static_cast<XWeak*>(this), 0);
}
+ rContainer.push_back(rxListener);
}
// Send out an initial event that informs the new listener about
diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
index 44a17f6ac6b7..7aea555232a6 100644
--- a/framework/source/services/substitutepathvars.cxx
+++ b/framework/source/services/substitutepathvars.cxx
@@ -590,15 +590,12 @@ OUString const & SubstitutePathVariables::impl_getSubstituteVariableValue( const
VarNameToIndexMap::const_iterator pNTOIIter = m_aPreDefVarMap.find( ( nPos == -1 ) ? aVariable : rVariable );
// Fixed/Predefined variable
- if ( pNTOIIter != m_aPreDefVarMap.end() )
- {
- PreDefVariable nIndex = pNTOIIter->second;
- return m_aPreDefVars.m_FixedVar[(sal_Int32)nIndex];
- }
- else
+ if ( pNTOIIter == m_aPreDefVarMap.end() )
{
throw NoSuchElementException("Unknown variable!", static_cast<cppu::OWeakObject *>(this));
}
+ PreDefVariable nIndex = pNTOIIter->second;
+ return m_aPreDefVars.m_FixedVar[(sal_Int32)nIndex];
}
void SubstitutePathVariables::SetPredefinedPathVariables()
diff --git a/framework/source/uiconfiguration/graphicnameaccess.cxx b/framework/source/uiconfiguration/graphicnameaccess.cxx
index bdd4c1f2445c..fbc1d8ed43f2 100644
--- a/framework/source/uiconfiguration/graphicnameaccess.cxx
+++ b/framework/source/uiconfiguration/graphicnameaccess.cxx
@@ -43,10 +43,9 @@ void GraphicNameAccess::addElement( const OUString& rName, const uno::Reference<
uno::Any SAL_CALL GraphicNameAccess::getByName( const OUString& aName )
{
NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.find( aName );
- if ( pIter != m_aNameToElementMap.end() )
- return uno::makeAny( pIter->second );
- else
+ if ( pIter == m_aNameToElementMap.end() )
throw container::NoSuchElementException();
+ return uno::makeAny( pIter->second );
}
uno::Sequence< OUString > SAL_CALL GraphicNameAccess::getElementNames()
diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
index 96299c2bd83b..403e045c99f8 100644
--- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
@@ -1188,94 +1188,91 @@ void SAL_CALL ModuleUIConfigurationManager::replaceSettings( const OUString& Res
throw DisposedException();
UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
- if ( pDataSettings )
+ if ( !pDataSettings )
+ throw NoSuchElementException();
+ if ( !pDataSettings->bDefaultNode )
{
- if ( !pDataSettings->bDefaultNode )
- {
- // we have a settings entry in our user-defined layer - replace
- Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings;
-
- // Create a copy of the data if the container is not const
- Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
- if ( xReplace.is() )
- pDataSettings->xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
- else
- pDataSettings->xSettings = aNewData;
- pDataSettings->bDefault = false;
- pDataSettings->bModified = true;
- m_bModified = true;
-
- // Modify type container
- UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
- rElementType.bModified = true;
-
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
+ // we have a settings entry in our user-defined layer - replace
+ Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings;
- // Create event to notify listener about replaced element settings
- ui::ConfigurationEvent aEvent;
- aEvent.ResourceURL = ResourceURL;
- aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
- aEvent.ReplacedElement <<= xOldSettings;
- aEvent.Element <<= pDataSettings->xSettings;
+ // Create a copy of the data if the container is not const
+ Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
+ if ( xReplace.is() )
+ pDataSettings->xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
+ else
+ pDataSettings->xSettings = aNewData;
+ pDataSettings->bDefault = false;
+ pDataSettings->bModified = true;
+ m_bModified = true;
- aGuard.clear();
+ // Modify type container
+ UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
+ rElementType.bModified = true;
- implts_notifyContainerListener( aEvent, NotifyOp_Replace );
- }
+ Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ Reference< XInterface > xIfac( xThis, UNO_QUERY );
+
+ // Create event to notify listener about replaced element settings
+ ui::ConfigurationEvent aEvent;
+ aEvent.ResourceURL = ResourceURL;
+ aEvent.Accessor <<= xThis;
+ aEvent.Source = xIfac;
+ aEvent.ReplacedElement <<= xOldSettings;
+ aEvent.Element <<= pDataSettings->xSettings;
+
+ aGuard.clear();
+
+ implts_notifyContainerListener( aEvent, NotifyOp_Replace );
+ }
+ else
+ {
+ // we have no settings in our user-defined layer - insert
+ UIElementData aUIElementData;
+
+ aUIElementData.bDefault = false;
+ aUIElementData.bDefaultNode = false;
+ aUIElementData.bModified = true;
+
+ // Create a copy of the data if the container is not const
+ Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
+ if ( xReplace.is() )
+ aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
else
- {
- // we have no settings in our user-defined layer - insert
- UIElementData aUIElementData;
+ aUIElementData.xSettings = aNewData;
+ aUIElementData.aName = RetrieveNameFromResourceURL( ResourceURL ) + m_aXMLPostfix;
+ aUIElementData.aResourceURL = ResourceURL;
+ m_bModified = true;
- aUIElementData.bDefault = false;
- aUIElementData.bDefaultNode = false;
- aUIElementData.bModified = true;
-
- // Create a copy of the data if the container is not const
- Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
- if ( xReplace.is() )
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
- else
- aUIElementData.xSettings = aNewData;
- aUIElementData.aName = RetrieveNameFromResourceURL( ResourceURL ) + m_aXMLPostfix;
- aUIElementData.aResourceURL = ResourceURL;
- m_bModified = true;
-
- // Modify type container
- UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
- rElementType.bModified = true;
-
- UIElementDataHashMap& rElements = rElementType.aElementsHashMap;
-
- // Check our user element settings hash map as it can already contain settings that have been set to default!
- // If no node can be found, we have to insert it.
- UIElementDataHashMap::iterator pIter = rElements.find( ResourceURL );
- if ( pIter != rElements.end() )
- pIter->second = aUIElementData;
- else
- rElements.emplace( ResourceURL, aUIElementData );
-
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
+ // Modify type container
+ UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
+ rElementType.bModified = true;
- // Create event to notify listener about replaced element settings
- ui::ConfigurationEvent aEvent;
+ UIElementDataHashMap& rElements = rElementType.aElementsHashMap;
- aEvent.ResourceURL = ResourceURL;
- aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
- aEvent.ReplacedElement <<= pDataSettings->xSettings;
- aEvent.Element <<= aUIElementData.xSettings;
+ // Check our user element settings hash map as it can already contain settings that have been set to default!
+ // If no node can be found, we have to insert it.
+ UIElementDataHashMap::iterator pIter = rElements.find( ResourceURL );
+ if ( pIter != rElements.end() )
+ pIter->second = aUIElementData;
+ else
+ rElements.emplace( ResourceURL, aUIElementData );
- aGuard.clear();
+ Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ Reference< XInterface > xIfac( xThis, UNO_QUERY );
- implts_notifyContainerListener( aEvent, NotifyOp_Replace );
- }
+ // Create event to notify listener about replaced element settings
+ ui::ConfigurationEvent aEvent;
+
+ aEvent.ResourceURL = ResourceURL;
+ aEvent.Accessor <<= xThis;
+ aEvent.Source = xIfac;
+ aEvent.ReplacedElement <<= pDataSettings->xSettings;
+ aEvent.Element <<= aUIElementData.xSettings;
+
+ aGuard.clear();
+
+ implts_notifyContainerListener( aEvent, NotifyOp_Replace );
}
- else
- throw NoSuchElementException();
}
}
@@ -1301,65 +1298,62 @@ void SAL_CALL ModuleUIConfigurationManager::removeSettings( const OUString& Reso
"ResourceURL: " + ResourceURL, nullptr );
UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
- if ( pDataSettings )
+ if ( !pDataSettings )
+ throw NoSuchElementException( "The settings data cannot be found. "
+ "ResourceURL: " + ResourceURL, nullptr );
+ // If element settings are default, we don't need to change anything!
+ if ( pDataSettings->bDefault )
+ return;
+ else
{
- // If element settings are default, we don't need to change anything!
- if ( pDataSettings->bDefault )
- return;
- else
- {
- Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings;
- pDataSettings->bDefault = true;
+ Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings;
+ pDataSettings->bDefault = true;
- // check if this is a default layer node
- if ( !pDataSettings->bDefaultNode )
- pDataSettings->bModified = true; // we have to remove this node from the user layer!
- pDataSettings->xSettings.clear();
- m_bModified = true; // user layer must be written
+ // check if this is a default layer node
+ if ( !pDataSettings->bDefaultNode )
+ pDataSettings->bModified = true; // we have to remove this node from the user layer!
+ pDataSettings->xSettings.clear();
+ m_bModified = true; // user layer must be written
- // Modify type container
- UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
- rElementType.bModified = true;
+ // Modify type container
+ UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
+ rElementType.bModified = true;
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ Reference< XInterface > xIfac( xThis, UNO_QUERY );
- // Check if we have settings in the default layer which replaces the user-defined one!
- UIElementData* pDefaultDataSettings = impl_findUIElementData( ResourceURL, nElementType );
- if ( pDefaultDataSettings )
- {
- // Create event to notify listener about replaced element settings
- ui::ConfigurationEvent aEvent;
+ // Check if we have settings in the default layer which replaces the user-defined one!
+ UIElementData* pDefaultDataSettings = impl_findUIElementData( ResourceURL, nElementType );
+ if ( pDefaultDataSettings )
+ {
+ // Create event to notify listener about replaced element settings
+ ui::ConfigurationEvent aEvent;
- aEvent.ResourceURL = ResourceURL;
- aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
- aEvent.Element <<= xRemovedSettings;
- aEvent.ReplacedElement <<= pDefaultDataSettings->xSettings;
+ aEvent.ResourceURL = ResourceURL;
+ aEvent.Accessor <<= xThis;
+ aEvent.Source = xIfac;
+ aEvent.Element <<= xRemovedSettings;
+ aEvent.ReplacedElement <<= pDefaultDataSettings->xSettings;
- aGuard.clear();
+ aGuard.clear();
- implts_notifyContainerListener( aEvent, NotifyOp_Replace );
- }
- else
- {
- // Create event to notify listener about removed element settings
- ui::ConfigurationEvent aEvent;
+ implts_notifyContainerListener( aEvent, NotifyOp_Replace );
+ }
+ else
+ {
+ // Create event to notify listener about removed element settings
+ ui::ConfigurationEvent aEvent;
- aEvent.ResourceURL = ResourceURL;
- aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
- aEvent.Element <<= xRemovedSettings;
+ aEvent.ResourceURL = ResourceURL;
+ aEvent.Accessor <<= xThis;
+ aEvent.Source = xIfac;
+ aEvent.Element <<= xRemovedSettings;
- aGuard.clear();
+ aGuard.clear();
- implts_notifyContainerListener( aEvent, NotifyOp_Remove );
- }
+ implts_notifyContainerListener( aEvent, NotifyOp_Remove );
}
}
- else
- throw NoSuchElementException( "The settings data cannot be found. "
- "ResourceURL: " + ResourceURL, nullptr );
}
}
@@ -1380,47 +1374,44 @@ void SAL_CALL ModuleUIConfigurationManager::insertSettings( const OUString& NewR
throw DisposedException();
UIElementData* pDataSettings = impl_findUIElementData( NewResourceURL, nElementType );
- if ( !pDataSettings )
- {
- UIElementData aUIElementData;
+ if ( !(!pDataSettings) )
+ throw ElementExistException();
+ UIElementData aUIElementData;
- aUIElementData.bDefault = false;
- aUIElementData.bDefaultNode = false;
- aUIElementData.bModified = true;
+ aUIElementData.bDefault = false;
+ aUIElementData.bDefaultNode = false;
+ aUIElementData.bModified = true;
- // Create a copy of the data if the container is not const
- Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
- if ( xReplace.is() )
- aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
- else
- aUIElementData.xSettings = aNewData;
- aUIElementData.aName = RetrieveNameFromResourceURL( NewResourceURL ) + m_aXMLPostfix;
- aUIElementData.aResourceURL = NewResourceURL;
- m_bModified = true;
+ // Create a copy of the data if the container is not const
+ Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
+ if ( xReplace.is() )
+ aUIElementData.xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
+ else
+ aUIElementData.xSettings = aNewData;
+ aUIElementData.aName = RetrieveNameFromResourceURL( NewResourceURL ) + m_aXMLPostfix;
+ aUIElementData.aResourceURL = NewResourceURL;
+ m_bModified = true;
- UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
- rElementType.bModified = true;
+ UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
+ rElementType.bModified = true;
- UIElementDataHashMap& rElements = rElementType.aElementsHashMap;
- rElements.emplace( NewResourceURL, aUIElementData );
+ UIElementDataHashMap& rElements = rElementType.aElementsHashMap;
+ rElements.emplace( NewResourceURL, aUIElementData );
- Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings );
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings );
+ Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- // Create event to notify listener about removed element settings
- ui::ConfigurationEvent aEvent;
+ // Create event to notify listener about removed element settings
+ ui::ConfigurationEvent aEvent;
- aEvent.ResourceURL = NewResourceURL;
- aEvent.Accessor <<= xThis;
- aEvent.Source = xThis;
- aEvent.Element <<= xInsertSettings;
+ aEvent.ResourceURL = NewResourceURL;
+ aEvent.Accessor <<= xThis;
+ aEvent.Source = xThis;
+ aEvent.Element <<= xInsertSettings;
- aGuard.clear();
+ aGuard.clear();
- implts_notifyContainerListener( aEvent, NotifyOp_Insert );
- }
- else
- throw ElementExistException();
+ implts_notifyContainerListener( aEvent, NotifyOp_Insert );
}
}
diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
index dcfd7227bc98..06b267a48700 100644
--- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
@@ -957,44 +957,41 @@ void SAL_CALL UIConfigurationManager::replaceSettings( const OUString& ResourceU
throw DisposedException();
UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
- if ( pDataSettings && !pDataSettings->bDefault )
- {
- // we have a settings entry in our user-defined layer - replace
- Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings;
+ if ( !pDataSettings || pDataSettings->bDefault )
+ throw NoSuchElementException();
+ // we have a settings entry in our user-defined layer - replace
+ Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings;
- // Create a copy of the data if the container is not const
- Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
- if ( xReplace.is() )
- pDataSettings->xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
- else
- pDataSettings->xSettings = aNewData;
+ // Create a copy of the data if the container is not const
+ Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
+ if ( xReplace.is() )
+ pDataSettings->xSettings.set( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
+ else
+ pDataSettings->xSettings = aNewData;
- pDataSettings->bDefault = false;
- pDataSettings->bModified = true;
- m_bModified = true;
+ pDataSettings->bDefault = false;
+ pDataSettings->bModified = true;
+ m_bModified = true;
- // Modify type container
- UIElementType& rElementType = m_aUIElements[nElementType];
- rElementType.bModified = true;
+ // Modify type container
+ UIElementType& rElementType = m_aUIElements[nElementType];
+ rElementType.bModified = true;
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ Reference< XInterface > xIfac( xThis, UNO_QUERY );
- // Create event to notify listener about replaced element settings
- ConfigurationEvent aEvent;
+ // Create event to notify listener about replaced element settings
+ ConfigurationEvent aEvent;
- aEvent.ResourceURL = ResourceURL;
- aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
- aEvent.ReplacedElement <<= xOldSettings;
- aEvent.Element <<= pDataSettings->xSettings;
+ aEvent.ResourceURL = ResourceURL;
+ aEvent.Accessor <<= xThis;
+ aEvent.Source = xIfac;
+ aEvent.ReplacedElement <<= xOldSettings;
+ aEvent.Element <<= pDataSettings->xSettings;
- aGuard.clear();
+ aGuard.clear();
- implts_notifyContainerListener( aEvent, NotifyOp_Replace );
- }
- else
- throw NoSuchElementException();
+ implts_notifyContainerListener( aEvent, NotifyOp_Replace );
}
}
@@ -1020,44 +1017,41 @@ void SAL_CALL UIConfigurationManager::removeSettings( const OUString& ResourceUR
"ResourceURL: " + ResourceURL, nullptr );
UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
- if ( pDataSettings )
+ if ( !pDataSettings )
+ throw NoSuchElementException( "The settings data cannot be found. "
+ "ResourceURL: " + ResourceURL, nullptr);
+ // If element settings are default, we don't need to change anything!
+ if ( pDataSettings->bDefault )
+ return;
+ else
{
- // If element settings are default, we don't need to change anything!
- if ( pDataSettings->bDefault )
- return;
- else
- {
- Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings;
- pDataSettings->bDefault = true;
+ Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings;
+ pDataSettings->bDefault = true;
- // check if this is a default layer node
- pDataSettings->bModified = true; // we have to remove this node from the user layer!
- pDataSettings->xSettings.clear();
- m_bModified = true; // user layer must be written
+ // check if this is a default layer node
+ pDataSettings->bModified = true; // we have to remove this node from the user layer!
+ pDataSettings->xSettings.clear();
+ m_bModified = true; // user layer must be written
- // Modify type container
- UIElementType& rElementType = m_aUIElements[nElementType];
- rElementType.bModified = true;
+ // Modify type container
+ UIElementType& rElementType = m_aUIElements[nElementType];
+ rElementType.bModified = true;
- Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- Reference< XInterface > xIfac( xThis, UNO_QUERY );
+ Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
+ Reference< XInterface > xIfac( xThis, UNO_QUERY );
- // Create event to notify listener about removed element settings
- ConfigurationEvent aEvent;
+ // Create event to notify listener about removed element settings
+ ConfigurationEvent aEvent;
- aEvent.ResourceURL = ResourceURL;
- aEvent.Accessor <<= xThis;
- aEvent.Source = xIfac;
- aEvent.Element <<= xRemovedSettings;
+ aEvent.ResourceURL = ResourceURL;
+ aEvent.Accessor <<= xThis;
+ aEvent.Source = xIfac;
+ aEvent.Element <<= xRemovedSettings;
- aGuard.clear();
+ aGuard.clear();
- implts_notifyContainerListener( aEvent, NotifyOp_Remove );
- }
+ implts_notifyContainerListener( aEvent, NotifyOp_Remove );
}
- else
- throw NoSuchElementException( "The settings data cannot be found. "
- "ResourceURL: " + ResourceURL, nullptr);
}
}