summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-27 09:11:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-27 11:02:56 +0200
commitcc1ed7fbce20f90650f96acc2846b6f232c8ab0f (patch)
treefcd441cdf9568861363894f63107967adf571f81 /framework
parentb50f595b34585f2927adfd44b4eaaafb8f600972 (diff)
loplugin:flatten in various
Change-Id: I42dca691ffadbddad38a7e8f978b1da9d5d9a7b0 Reviewed-on: https://gerrit.libreoffice.org/42842 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/helper/propertysetcontainer.cxx83
-rw-r--r--framework/source/fwi/uielement/itemcontainer.cxx56
-rw-r--r--framework/source/fwi/uielement/rootitemcontainer.cxx54
-rw-r--r--framework/source/uiconfiguration/windowstateconfiguration.cxx175
-rw-r--r--framework/source/uielement/menubarwrapper.cxx12
-rw-r--r--framework/source/uielement/statusbarwrapper.cxx23
6 files changed, 185 insertions, 218 deletions
diff --git a/framework/source/fwe/helper/propertysetcontainer.cxx b/framework/source/fwe/helper/propertysetcontainer.cxx
index 9f856691e343..5051d776f470 100644
--- a/framework/source/fwe/helper/propertysetcontainer.cxx
+++ b/framework/source/fwe/helper/propertysetcontainer.cxx
@@ -79,64 +79,54 @@ void SAL_CALL PropertySetContainer::insertByIndex( sal_Int32 Index, const css::u
sal_Int32 nSize = m_aPropertySetVector.size();
- if ( nSize >= Index )
+ if ( nSize < Index )
+ throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+
+ Reference< XPropertySet > aPropertySetElement;
+
+ if ( !(Element >>= aPropertySetElement) )
{
- Reference< XPropertySet > aPropertySetElement;
-
- if ( Element >>= aPropertySetElement )
- {
- if ( nSize == Index )
- m_aPropertySetVector.push_back( aPropertySetElement );
- else
- {
- PropertySetVector::iterator aIter = m_aPropertySetVector.begin();
- aIter += Index;
- m_aPropertySetVector.insert( aIter, aPropertySetElement );
- }
- }
- else
- {
- throw IllegalArgumentException(
- WRONG_TYPE_EXCEPTION,
- static_cast<OWeakObject *>(this), 2 );
- }
+ throw IllegalArgumentException(
+ WRONG_TYPE_EXCEPTION,
+ static_cast<OWeakObject *>(this), 2 );
}
+
+ if ( nSize == Index )
+ m_aPropertySetVector.push_back( aPropertySetElement );
else
- throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+ {
+ PropertySetVector::iterator aIter = m_aPropertySetVector.begin();
+ aIter += Index;
+ m_aPropertySetVector.insert( aIter, aPropertySetElement );
+ }
}
void SAL_CALL PropertySetContainer::removeByIndex( sal_Int32 nIndex )
{
SolarMutexGuard g;
- if ( (sal_Int32)m_aPropertySetVector.size() > nIndex )
- {
- m_aPropertySetVector.erase(m_aPropertySetVector.begin() + nIndex);
- }
- else
+ if ( !((sal_Int32)m_aPropertySetVector.size() > nIndex) )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+
+ m_aPropertySetVector.erase(m_aPropertySetVector.begin() + nIndex);
}
// XIndexReplace
void SAL_CALL PropertySetContainer::replaceByIndex( sal_Int32 Index, const css::uno::Any& Element )
{
- if ( (sal_Int32)m_aPropertySetVector.size() > Index )
+ if ( !((sal_Int32)m_aPropertySetVector.size() > Index) )
+ throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+
+ Reference< XPropertySet > aPropertySetElement;
+
+ if ( !(Element >>= aPropertySetElement) )
{
- Reference< XPropertySet > aPropertySetElement;
-
- if ( Element >>= aPropertySetElement )
- {
- m_aPropertySetVector[ Index ] = aPropertySetElement;
- }
- else
- {
- throw IllegalArgumentException(
- WRONG_TYPE_EXCEPTION,
- static_cast<OWeakObject *>(this), 2 );
- }
+ throw IllegalArgumentException(
+ WRONG_TYPE_EXCEPTION,
+ static_cast<OWeakObject *>(this), 2 );
}
- else
- throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+
+ m_aPropertySetVector[ Index ] = aPropertySetElement;
}
// XIndexAccess
@@ -151,15 +141,10 @@ Any SAL_CALL PropertySetContainer::getByIndex( sal_Int32 Index )
{
SolarMutexGuard g;
- if ( (sal_Int32)m_aPropertySetVector.size() > Index )
- {
- Any a;
-
- a <<= m_aPropertySetVector[ Index ];
- return a;
- }
- else
+ if ( (sal_Int32)m_aPropertySetVector.size() <= Index )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+
+ return Any(m_aPropertySetVector[ Index ]);
}
// XElementAccess
diff --git a/framework/source/fwi/uielement/itemcontainer.cxx b/framework/source/fwi/uielement/itemcontainer.cxx
index fd9149376162..ec57f33b07a4 100644
--- a/framework/source/fwi/uielement/itemcontainer.cxx
+++ b/framework/source/fwi/uielement/itemcontainer.cxx
@@ -166,60 +166,54 @@ sal_Int32 SAL_CALL ItemContainer::getCount()
Any SAL_CALL ItemContainer::getByIndex( sal_Int32 Index )
{
ShareGuard aLock( m_aShareMutex );
- 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] );
}
// XIndexContainer
void SAL_CALL ItemContainer::insertByIndex( sal_Int32 Index, const Any& aItem )
{
Sequence< PropertyValue > aSeq;
- if ( aItem >>= aSeq )
+ if ( !(aItem >>= aSeq) )
+ throw IllegalArgumentException( WRONG_TYPE_EXCEPTION,
+ static_cast<OWeakObject *>(this), 2 );
+
+ ShareGuard aLock( m_aShareMutex );
+ if ( sal_Int32( m_aItemVector.size()) == Index )
+ m_aItemVector.push_back( aSeq );
+ else if ( sal_Int32( m_aItemVector.size()) >Index )
{
- ShareGuard aLock( m_aShareMutex );
- if ( sal_Int32( m_aItemVector.size()) == Index )
- m_aItemVector.push_back( aSeq );
- else if ( sal_Int32( m_aItemVector.size()) >Index )
- {
- std::vector< Sequence< PropertyValue > >::iterator aIter = m_aItemVector.begin();
- aIter += Index;
- m_aItemVector.insert( aIter, aSeq );
- }
- else
- throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+ std::vector< Sequence< PropertyValue > >::iterator aIter = m_aItemVector.begin();
+ aIter += Index;
+ m_aItemVector.insert( aIter, aSeq );
}
else
- throw IllegalArgumentException( WRONG_TYPE_EXCEPTION,
- static_cast<OWeakObject *>(this), 2 );
+ throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
}
void SAL_CALL ItemContainer::removeByIndex( sal_Int32 nIndex )
{
ShareGuard aLock( m_aShareMutex );
- if ( (sal_Int32)m_aItemVector.size() > nIndex )
- {
- m_aItemVector.erase(m_aItemVector.begin() + nIndex);
- }
- else
+ if ( (sal_Int32)m_aItemVector.size() <= nIndex )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+
+ m_aItemVector.erase(m_aItemVector.begin() + nIndex);
}
void SAL_CALL ItemContainer::replaceByIndex( sal_Int32 Index, const Any& aItem )
{
Sequence< PropertyValue > aSeq;
- if ( aItem >>= aSeq )
- {
- ShareGuard aLock( m_aShareMutex );
- if ( sal_Int32( m_aItemVector.size()) > Index )
- m_aItemVector[Index] = aSeq;
- else
- throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
- }
- else
+ if ( !(aItem >>= aSeq) )
throw IllegalArgumentException( WRONG_TYPE_EXCEPTION,
static_cast<OWeakObject *>(this), 2 );
+
+ ShareGuard aLock( m_aShareMutex );
+ if ( !(sal_Int32( m_aItemVector.size()) > Index) )
+ throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+
+ m_aItemVector[Index] = aSeq;
}
} // namespace framework
diff --git a/framework/source/fwi/uielement/rootitemcontainer.cxx b/framework/source/fwi/uielement/rootitemcontainer.cxx
index 5b065a835f3c..72f41e761a1e 100644
--- a/framework/source/fwi/uielement/rootitemcontainer.cxx
+++ b/framework/source/fwi/uielement/rootitemcontainer.cxx
@@ -182,58 +182,52 @@ sal_Int32 SAL_CALL RootItemContainer::getCount()
Any SAL_CALL RootItemContainer::getByIndex( sal_Int32 Index )
{
ShareGuard aLock( m_aShareMutex );
- 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] );
}
// XIndexContainer
void SAL_CALL RootItemContainer::insertByIndex( sal_Int32 Index, const Any& aItem )
{
Sequence< PropertyValue > aSeq;
- if ( aItem >>= aSeq )
+ if ( !(aItem >>= aSeq) )
+ throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, static_cast<OWeakObject *>(this), 2 );
+
+ ShareGuard aLock( m_aShareMutex );
+ if ( sal_Int32( m_aItemVector.size()) == Index )
+ m_aItemVector.push_back( aSeq );
+ else if ( sal_Int32( m_aItemVector.size()) >Index )
{
- ShareGuard aLock( m_aShareMutex );
- if ( sal_Int32( m_aItemVector.size()) == Index )
- m_aItemVector.push_back( aSeq );
- else if ( sal_Int32( m_aItemVector.size()) >Index )
- {
- std::vector< Sequence< PropertyValue > >::iterator aIter = m_aItemVector.begin();
- aIter += Index;
- m_aItemVector.insert( aIter, aSeq );
- }
- else
- throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+ std::vector< Sequence< PropertyValue > >::iterator aIter = m_aItemVector.begin();
+ aIter += Index;
+ m_aItemVector.insert( aIter, aSeq );
}
else
- throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, static_cast<OWeakObject *>(this), 2 );
+ throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
}
void SAL_CALL RootItemContainer::removeByIndex( sal_Int32 nIndex )
{
ShareGuard aLock( m_aShareMutex );
- if ( (sal_Int32)m_aItemVector.size() > nIndex )
- {
- m_aItemVector.erase(m_aItemVector.begin() + nIndex);
- }
- else
+ if ( (sal_Int32)m_aItemVector.size() <= nIndex )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+
+ m_aItemVector.erase(m_aItemVector.begin() + nIndex);
}
void SAL_CALL RootItemContainer::replaceByIndex( sal_Int32 Index, const Any& aItem )
{
Sequence< PropertyValue > aSeq;
- if ( aItem >>= aSeq )
- {
- ShareGuard aLock( m_aShareMutex );
- if ( sal_Int32( m_aItemVector.size()) > Index )
- m_aItemVector[Index] = aSeq;
- else
- throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
- }
- else
+ if ( !(aItem >>= aSeq) )
throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, static_cast<OWeakObject *>(this), 2 );
+
+ ShareGuard aLock( m_aShareMutex );
+ if ( !(sal_Int32( m_aItemVector.size()) > Index) )
+ throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
+
+ m_aItemVector[Index] = aSeq;
}
Reference< XInterface > SAL_CALL RootItemContainer::createInstanceWithContext( const Reference< XComponentContext >& )
diff --git a/framework/source/uiconfiguration/windowstateconfiguration.cxx b/framework/source/uiconfiguration/windowstateconfiguration.cxx
index 024fa761e823..97c71e7a39b4 100644
--- a/framework/source/uiconfiguration/windowstateconfiguration.cxx
+++ b/framework/source/uiconfiguration/windowstateconfiguration.cxx
@@ -359,61 +359,60 @@ void SAL_CALL ConfigurationAccess_WindowState::insertByName( const OUString& rRe
osl::ResettableMutexGuard g(m_aMutex);
Sequence< PropertyValue > aPropSet;
- if ( aPropertySet >>= aPropSet )
+ if ( !(aPropertySet >>= aPropSet) )
+ throw IllegalArgumentException();
+
+ ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
+ if ( pIter != m_aResourceURLToInfoCache.end() )
+ throw ElementExistException();
+ else
{
- ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
- if ( pIter != m_aResourceURLToInfoCache.end() )
- throw ElementExistException();
- else
+ if ( !m_bConfigAccessInitialized )
{
- if ( !m_bConfigAccessInitialized )
- {
- impl_initializeConfigAccess();
- m_bConfigAccessInitialized = true;
- }
+ impl_initializeConfigAccess();
+ m_bConfigAccessInitialized = true;
+ }
- // Try to ask our configuration access
- if ( m_xConfigAccess.is() )
+ // Try to ask our configuration access
+ if ( m_xConfigAccess.is() )
+ {
+ if ( m_xConfigAccess->hasByName( rResourceURL ) )
+ throw ElementExistException();
+ else
{
- if ( m_xConfigAccess->hasByName( rResourceURL ) )
- throw ElementExistException();
- else
+ WindowStateInfo aWinStateInfo;
+ impl_fillStructFromSequence( aWinStateInfo, aPropSet );
+ m_aResourceURLToInfoCache.emplace( rResourceURL, aWinStateInfo );
+
+ // insert must be write-through => insert element into configuration
+ Reference< XNameContainer > xNameContainer( m_xConfigAccess, UNO_QUERY );
+ if ( xNameContainer.is() )
{
- WindowStateInfo aWinStateInfo;
- impl_fillStructFromSequence( aWinStateInfo, aPropSet );
- m_aResourceURLToInfoCache.emplace( rResourceURL, aWinStateInfo );
+ Reference< XSingleServiceFactory > xFactory( m_xConfigAccess, UNO_QUERY );
+ g.clear();
- // insert must be write-through => insert element into configuration
- Reference< XNameContainer > xNameContainer( m_xConfigAccess, UNO_QUERY );
- if ( xNameContainer.is() )
+ try
{
- Reference< XSingleServiceFactory > xFactory( m_xConfigAccess, UNO_QUERY );
- g.clear();
-
- try
- {
- Reference< XPropertySet > xPropSet( xFactory->createInstance(), UNO_QUERY );
- if ( xPropSet.is() )
- {
- Any a;
- impl_putPropertiesFromStruct( aWinStateInfo, xPropSet );
- a <<= xPropSet;
- xNameContainer->insertByName( rResourceURL, a );
- Reference< XChangesBatch > xFlush( xFactory, UNO_QUERY );
- if ( xFlush.is() )
- xFlush->commitChanges();
- }
- }
- catch ( const Exception& )
+ Reference< XPropertySet > xPropSet( xFactory->createInstance(), UNO_QUERY );
+ if ( xPropSet.is() )
{
+ Any a;
+ impl_putPropertiesFromStruct( aWinStateInfo, xPropSet );
+ a <<= xPropSet;
+ xNameContainer->insertByName( rResourceURL, a );
+ Reference< XChangesBatch > xFlush( xFactory, UNO_QUERY );
+ if ( xFlush.is() )
+ xFlush->commitChanges();
}
}
+ catch ( const Exception& )
+ {
+ }
}
}
}
}
- else
- throw IllegalArgumentException();
+
}
// XNameReplace
@@ -423,68 +422,66 @@ void SAL_CALL ConfigurationAccess_WindowState::replaceByName( const OUString& rR
osl::ResettableMutexGuard g(m_aMutex);
Sequence< PropertyValue > aPropSet;
- if ( aPropertySet >>= aPropSet )
+ if ( !(aPropertySet >>= aPropSet) )
+ throw IllegalArgumentException();
+
+ ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
+ if ( pIter != m_aResourceURLToInfoCache.end() )
+ {
+ WindowStateInfo& rWinStateInfo = pIter->second;
+ impl_fillStructFromSequence( rWinStateInfo, aPropSet );
+ m_bModified = true;
+ }
+ else
{
- ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
- if ( pIter != m_aResourceURLToInfoCache.end() )
+ if ( !m_bConfigAccessInitialized )
{
- WindowStateInfo& rWinStateInfo = pIter->second;
- impl_fillStructFromSequence( rWinStateInfo, aPropSet );
- m_bModified = true;
+ impl_initializeConfigAccess();
+ m_bConfigAccessInitialized = true;
}
- else
- {
- if ( !m_bConfigAccessInitialized )
- {
- impl_initializeConfigAccess();
- m_bConfigAccessInitialized = true;
- }
- // Try to ask our configuration access
- Reference< XNameAccess > xNameAccess;
- Any a( m_xConfigAccess->getByName( rResourceURL ));
+ // Try to ask our configuration access
+ Reference< XNameAccess > xNameAccess;
+ Any a( m_xConfigAccess->getByName( rResourceURL ));
- if ( a >>= xNameAccess )
- {
- WindowStateInfo& rWinStateInfo( impl_insertCacheAndReturnWinState( rResourceURL, xNameAccess ));
- impl_fillStructFromSequence( rWinStateInfo, aPropSet );
- m_bModified = true;
- pIter = m_aResourceURLToInfoCache.find( rResourceURL );
- }
- else
- throw NoSuchElementException();
- }
+ if ( !(a >>= xNameAccess) )
+ throw NoSuchElementException();
+
+ WindowStateInfo& rWinStateInfo( impl_insertCacheAndReturnWinState( rResourceURL, xNameAccess ));
+ impl_fillStructFromSequence( rWinStateInfo, aPropSet );
+ m_bModified = true;
+ pIter = m_aResourceURLToInfoCache.find( rResourceURL );
- if ( m_bModified && pIter != m_aResourceURLToInfoCache.end() )
+ }
+
+ if ( m_bModified && pIter != m_aResourceURLToInfoCache.end() )
+ {
+ Reference< XNameContainer > xNameContainer( m_xConfigAccess, UNO_QUERY );
+ if ( xNameContainer.is() )
{
- Reference< XNameContainer > xNameContainer( m_xConfigAccess, UNO_QUERY );
- if ( xNameContainer.is() )
- {
- WindowStateInfo aWinStateInfo( pIter->second );
- OUString aResourceURL( pIter->first );
- m_bModified = false;
- g.clear();
+ WindowStateInfo aWinStateInfo( pIter->second );
+ OUString aResourceURL( pIter->first );
+ m_bModified = false;
+ g.clear();
- try
+ try
+ {
+ Reference< XPropertySet > xPropSet;
+ if ( xNameContainer->getByName( aResourceURL ) >>= xPropSet )
{
- Reference< XPropertySet > xPropSet;
- if ( xNameContainer->getByName( aResourceURL ) >>= xPropSet )
- {
- impl_putPropertiesFromStruct( aWinStateInfo, xPropSet );
+ impl_putPropertiesFromStruct( aWinStateInfo, xPropSet );
- Reference< XChangesBatch > xFlush( m_xConfigAccess, UNO_QUERY );
- if ( xFlush.is() )
- xFlush->commitChanges();
- }
- }
- catch ( const Exception& )
- {
+ Reference< XChangesBatch > xFlush( m_xConfigAccess, UNO_QUERY );
+ if ( xFlush.is() )
+ xFlush->commitChanges();
}
}
+ catch ( const Exception& )
+ {
+ }
}
}
- else
- throw IllegalArgumentException();
+
}
// container.XContainerListener
diff --git a/framework/source/uielement/menubarwrapper.cxx b/framework/source/uielement/menubarwrapper.cxx
index 9fc4ccee6167..68357213e697 100644
--- a/framework/source/uielement/menubarwrapper.cxx
+++ b/framework/source/uielement/menubarwrapper.cxx
@@ -277,14 +277,12 @@ Any SAL_CALL MenuBarWrapper::getByName(
fillPopupControllerCache();
PopupControllerCache::const_iterator pIter = m_aPopupControllerCache.find( aName );
- if ( pIter != m_aPopupControllerCache.end() )
- {
- uno::Reference< frame::XDispatchProvider > xDispatchProvider;
- xDispatchProvider = pIter->second.m_xDispatchProvider;
- return uno::makeAny( xDispatchProvider );
- }
- else
+ if ( pIter == m_aPopupControllerCache.end() )
throw container::NoSuchElementException();
+
+ uno::Reference< frame::XDispatchProvider > xDispatchProvider;
+ xDispatchProvider = pIter->second.m_xDispatchProvider;
+ return uno::makeAny( xDispatchProvider );
}
Sequence< OUString > SAL_CALL MenuBarWrapper::getElementNames()
diff --git a/framework/source/uielement/statusbarwrapper.cxx b/framework/source/uielement/statusbarwrapper.cxx
index 2cf60b555e1a..003d6b5b00ba 100644
--- a/framework/source/uielement/statusbarwrapper.cxx
+++ b/framework/source/uielement/statusbarwrapper.cxx
@@ -69,19 +69,18 @@ void SAL_CALL StatusBarWrapper::dispose()
m_aListenerContainer.disposeAndClear( aEvent );
SolarMutexGuard g;
- if ( !m_bDisposed )
- {
- if ( m_xStatusBarManager.is() )
- m_xStatusBarManager->dispose();
- m_xStatusBarManager.clear();
- m_xConfigSource.clear();
- m_xConfigData.clear();
- m_xContext.clear();
-
- m_bDisposed = true;
- }
- else
+ if ( m_bDisposed )
throw DisposedException();
+
+ if ( m_xStatusBarManager.is() )
+ m_xStatusBarManager->dispose();
+ m_xStatusBarManager.clear();
+ m_xConfigSource.clear();
+ m_xConfigData.clear();
+ m_xContext.clear();
+
+ m_bDisposed = true;
+
}
// XInitialization