summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-20 15:03:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-21 15:18:57 +0200
commitac80f048f2bb23651ddc3c6608e9ef24635698d7 (patch)
tree925ece62dd2e859170d1267d8e7122c4f9b762e8 /comphelper
parentb5450f4afe2af6620fbbbdf686853dfa3293ff90 (diff)
loplugin:flatten in basctl..configmgr
Change-Id: I674cad57ce30a885e126d3bcc921f8fcb53dc36d Reviewed-on: https://gerrit.libreoffice.org/42577 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/container/IndexedPropertyValuesContainer.cxx92
-rw-r--r--comphelper/source/eventattachermgr/eventattachermgr.cxx16
-rw-r--r--comphelper/source/misc/mimeconfighelper.cxx17
-rw-r--r--comphelper/source/streaming/seqinputstreamserv.cxx20
-rw-r--r--comphelper/source/xml/ofopxmlhelper.cxx13
5 files changed, 70 insertions, 88 deletions
diff --git a/comphelper/source/container/IndexedPropertyValuesContainer.cxx b/comphelper/source/container/IndexedPropertyValuesContainer.cxx
index d577ebe1ca24..1853ba71918b 100644
--- a/comphelper/source/container/IndexedPropertyValuesContainer.cxx
+++ b/comphelper/source/container/IndexedPropertyValuesContainer.cxx
@@ -70,47 +70,15 @@ IndexedPropertyValuesContainer::IndexedPropertyValuesContainer() throw()
void SAL_CALL IndexedPropertyValuesContainer::insertByIndex( sal_Int32 nIndex, const css::uno::Any& aElement )
{
sal_Int32 nSize(maProperties.size());
- if ((nSize >= nIndex) && (nIndex >= 0))
- {
- uno::Sequence<beans::PropertyValue> aProps;
- if (!(aElement >>= aProps))
- throw lang::IllegalArgumentException();
- if (nSize == nIndex)
- maProperties.push_back(aProps);
- else
- {
- IndexedPropertyValues::iterator aItr;
- if ((nIndex * 2) < nSize)
- {
- aItr = maProperties.begin();
- sal_Int32 i(0);
- while(i < nIndex)
- {
- ++i;
- ++aItr;
- }
- }
- else
- {
- aItr = maProperties.end();
- sal_Int32 i(nSize);
- while(i > nIndex)
- {
- --i;
- --aItr;
- }
- }
- maProperties.insert(aItr, aProps);
- }
- }
- else
+ if ((nSize < nIndex) || (nIndex < 0))
throw lang::IndexOutOfBoundsException();
-}
-void SAL_CALL IndexedPropertyValuesContainer::removeByIndex( sal_Int32 nIndex )
-{
- sal_Int32 nSize(maProperties.size());
- if ((nIndex < nSize) && (nIndex >= 0))
+ uno::Sequence<beans::PropertyValue> aProps;
+ if (!(aElement >>= aProps))
+ throw lang::IllegalArgumentException();
+ if (nSize == nIndex)
+ maProperties.push_back(aProps);
+ else
{
IndexedPropertyValues::iterator aItr;
if ((nIndex * 2) < nSize)
@@ -133,25 +101,51 @@ void SAL_CALL IndexedPropertyValuesContainer::removeByIndex( sal_Int32 nIndex )
--aItr;
}
}
- maProperties.erase(aItr);
+ maProperties.insert(aItr, aProps);
}
- else
- throw lang::IndexOutOfBoundsException();
}
-// XIndexReplace
-void SAL_CALL IndexedPropertyValuesContainer::replaceByIndex( sal_Int32 nIndex, const css::uno::Any& aElement )
+void SAL_CALL IndexedPropertyValuesContainer::removeByIndex( sal_Int32 nIndex )
{
sal_Int32 nSize(maProperties.size());
- if ((nIndex < nSize) && (nIndex >= 0))
+ if ((nIndex >= nSize) || (nIndex < 0))
+ throw lang::IndexOutOfBoundsException();
+
+ IndexedPropertyValues::iterator aItr;
+ if ((nIndex * 2) < nSize)
{
- uno::Sequence<beans::PropertyValue> aProps;
- if (!(aElement >>= aProps))
- throw lang::IllegalArgumentException();
- maProperties[nIndex] = aProps;
+ aItr = maProperties.begin();
+ sal_Int32 i(0);
+ while(i < nIndex)
+ {
+ ++i;
+ ++aItr;
+ }
}
else
+ {
+ aItr = maProperties.end();
+ sal_Int32 i(nSize);
+ while(i > nIndex)
+ {
+ --i;
+ --aItr;
+ }
+ }
+ maProperties.erase(aItr);
+}
+
+// XIndexReplace
+void SAL_CALL IndexedPropertyValuesContainer::replaceByIndex( sal_Int32 nIndex, const css::uno::Any& aElement )
+{
+ sal_Int32 nSize(maProperties.size());
+ if ((nIndex >= nSize) || (nIndex < 0))
throw lang::IndexOutOfBoundsException();
+
+ uno::Sequence<beans::PropertyValue> aProps;
+ if (!(aElement >>= aProps))
+ throw lang::IllegalArgumentException();
+ maProperties[nIndex] = aProps;
}
// XIndexAccess
diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx
index 19f755c866b7..578d5fd1a6a9 100644
--- a/comphelper/source/eventattachermgr/eventattachermgr.cxx
+++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx
@@ -221,10 +221,9 @@ void AttacherAllListener_Impl::convertToEventReturn( Any & rRet, const Type & rR
}
else if( !rRet.getValueType().equals( rRetType ) )
{
- if( mxManager->xConverter.is() )
- rRet = mxManager->xConverter->convertTo( rRet, rRetType );
- else
+ if( !mxManager->xConverter.is() )
throw CannotConvertException();
+ rRet = mxManager->xConverter->convertTo( rRet, rRetType );
}
}
@@ -541,14 +540,11 @@ void SAL_CALL ImplEventAttacherManager::attach(sal_Int32 nIndex, const Reference
if( static_cast< std::deque< AttacherIndex_Impl >::size_type>(nIndex) >= aIndex.size() )
{
// read older files
- if( nVersion == 1 )
- {
- insertEntry( nIndex );
- attach( nIndex, xObject, Helper );
- return;
- }
- else
+ if( nVersion != 1 )
throw IllegalArgumentException();
+ insertEntry( nIndex );
+ attach( nIndex, xObject, Helper );
+ return;
}
std::deque< AttacherIndex_Impl >::iterator aCurrentPosition = aIndex.begin() + nIndex;
diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx
index a923fdcbbcbc..a347072dec66 100644
--- a/comphelper/source/misc/mimeconfighelper.cxx
+++ b/comphelper/source/misc/mimeconfighelper.cxx
@@ -307,17 +307,14 @@ uno::Sequence< beans::NamedValue > MimeConfigurationHelper::GetObjPropsFromConfi
if ( aObjPropNames[nInd] == "ObjectVerbs" )
{
uno::Sequence< OUString > aVerbShortcuts;
- if ( xObjectProps->getByName( aObjPropNames[nInd] ) >>= aVerbShortcuts )
- {
- uno::Sequence< embed::VerbDescriptor > aVerbDescriptors( aVerbShortcuts.getLength() );
- for ( sal_Int32 nVerbI = 0; nVerbI < aVerbShortcuts.getLength(); nVerbI++ )
- if ( !GetVerbByShortcut( aVerbShortcuts[nVerbI], aVerbDescriptors[nVerbI] ) )
- throw uno::RuntimeException();
-
- aResult[nInd+1].Value <<= aVerbDescriptors;
- }
- else
+ if ( !(xObjectProps->getByName( aObjPropNames[nInd] ) >>= aVerbShortcuts) )
throw uno::RuntimeException();
+ uno::Sequence< embed::VerbDescriptor > aVerbDescriptors( aVerbShortcuts.getLength() );
+ for ( sal_Int32 nVerbI = 0; nVerbI < aVerbShortcuts.getLength(); nVerbI++ )
+ if ( !GetVerbByShortcut( aVerbShortcuts[nVerbI], aVerbDescriptors[nVerbI] ) )
+ throw uno::RuntimeException();
+
+ aResult[nInd+1].Value <<= aVerbDescriptors;
}
else
aResult[nInd+1].Value = xObjectProps->getByName( aObjPropNames[nInd] );
diff --git a/comphelper/source/streaming/seqinputstreamserv.cxx b/comphelper/source/streaming/seqinputstreamserv.cxx
index 0bee70b8f303..7fa619442318 100644
--- a/comphelper/source/streaming/seqinputstreamserv.cxx
+++ b/comphelper/source/streaming/seqinputstreamserv.cxx
@@ -194,20 +194,18 @@ void SAL_CALL SequenceInputStreamService::initialize( const uno::Sequence< css::
1 );
uno::Sequence< sal_Int8 > aSeq;
- if ( aArguments[0] >>= aSeq )
- {
- uno::Reference< io::XInputStream > xInputStream(
- static_cast< ::cppu::OWeakObject* >( new ::comphelper::SequenceInputStream( aSeq ) ),
- uno::UNO_QUERY_THROW );
- uno::Reference< io::XSeekable > xSeekable( xInputStream, uno::UNO_QUERY_THROW );
- m_xInputStream = xInputStream;
- m_xSeekable = xSeekable;
- m_bInitialized = true;
- }
- else
+ if ( !(aArguments[0] >>= aSeq) )
throw lang::IllegalArgumentException( "Unexpected type of argument!",
static_cast< ::cppu::OWeakObject* >(this),
1 );
+
+ uno::Reference< io::XInputStream > xInputStream(
+ static_cast< ::cppu::OWeakObject* >( new ::comphelper::SequenceInputStream( aSeq ) ),
+ uno::UNO_QUERY_THROW );
+ uno::Reference< io::XSeekable > xSeekable( xInputStream, uno::UNO_QUERY_THROW );
+ m_xInputStream = xInputStream;
+ m_xSeekable = xSeekable;
+ m_bInitialized = true;
}
} // anonymous namespace
diff --git a/comphelper/source/xml/ofopxmlhelper.cxx b/comphelper/source/xml/ofopxmlhelper.cxx
index 58e4a0fbc7a2..0d4e164a2f66 100644
--- a/comphelper/source/xml/ofopxmlhelper.cxx
+++ b/comphelper/source/xml/ofopxmlhelper.cxx
@@ -145,18 +145,15 @@ void WriteRelationsInfoSequence(
uno::Reference< css::xml::sax::XAttributeList > xAttrList( pAttrList );
for( sal_Int32 nSecInd = 0; nSecInd < aSequence[nInd].getLength(); nSecInd++ )
{
- if ( aSequence[nInd][nSecInd].First == "Id"
- || aSequence[nInd][nSecInd].First == "Type"
- || aSequence[nInd][nSecInd].First == "TargetMode"
- || aSequence[nInd][nSecInd].First == "Target" )
- {
- pAttrList->AddAttribute( aSequence[nInd][nSecInd].First, aCDATAString, aSequence[nInd][nSecInd].Second );
- }
- else
+ if ( !(aSequence[nInd][nSecInd].First == "Id"
+ || aSequence[nInd][nSecInd].First == "Type"
+ || aSequence[nInd][nSecInd].First == "TargetMode"
+ || aSequence[nInd][nSecInd].First == "Target") )
{
// TODO/LATER: should the extensions be allowed?
throw lang::IllegalArgumentException();
}
+ pAttrList->AddAttribute( aSequence[nInd][nSecInd].First, aCDATAString, aSequence[nInd][nSecInd].Second );
}
xWriter->startElement( aRelElement, xAttrList );