summaryrefslogtreecommitdiff
path: root/vbahelper/source/msforms/vbalistcontrolhelper.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vbahelper/source/msforms/vbalistcontrolhelper.cxx')
-rw-r--r--vbahelper/source/msforms/vbalistcontrolhelper.cxx90
1 files changed, 45 insertions, 45 deletions
diff --git a/vbahelper/source/msforms/vbalistcontrolhelper.cxx b/vbahelper/source/msforms/vbalistcontrolhelper.cxx
index 07187e56b621..58884dbf62fc 100644
--- a/vbahelper/source/msforms/vbalistcontrolhelper.cxx
+++ b/vbahelper/source/msforms/vbalistcontrolhelper.cxx
@@ -88,47 +88,47 @@ uno::Any ListPropListener::getValueEvent()
void
ListControlHelper::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex )
{
- if ( pvargItem.hasValue() )
- {
- uno::Sequence< OUString > sList;
- m_xProps->getPropertyValue( "StringItemList" ) >>= sList;
+ if ( !pvargItem.hasValue() )
+ return;
- sal_Int32 nIndex = sList.getLength();
+ uno::Sequence< OUString > sList;
+ m_xProps->getPropertyValue( "StringItemList" ) >>= sList;
- if ( pvargIndex.hasValue() )
- pvargIndex >>= nIndex;
+ sal_Int32 nIndex = sList.getLength();
- OUString sString = getAnyAsString( pvargItem );
+ if ( pvargIndex.hasValue() )
+ pvargIndex >>= nIndex;
- // if no index specified or item is to be appended to end of
- // list just realloc the array and set the last item
- if ( nIndex == sList.getLength() )
- {
- sal_Int32 nOldSize = sList.getLength();
- sList.realloc( nOldSize + 1 );
- sList[ nOldSize ] = sString;
- }
- else
- {
- // just copy those elements above the one to be inserted
- std::vector< OUString > sVec;
- // reserve just the amount we need to copy
- sVec.reserve( sList.getLength() - nIndex + 1);
+ OUString sString = getAnyAsString( pvargItem );
- // insert the new element
- sVec.push_back( sString );
+ // if no index specified or item is to be appended to end of
+ // list just realloc the array and set the last item
+ if ( nIndex == sList.getLength() )
+ {
+ sal_Int32 nOldSize = sList.getLength();
+ sList.realloc( nOldSize + 1 );
+ sList[ nOldSize ] = sString;
+ }
+ else
+ {
+ // just copy those elements above the one to be inserted
+ std::vector< OUString > sVec;
+ // reserve just the amount we need to copy
+ sVec.reserve( sList.getLength() - nIndex + 1);
- // point at first element to copy
- sVec.insert( sVec.end(), std::next(sList.begin(), nIndex), sList.end() );
+ // insert the new element
+ sVec.push_back( sString );
- sList.realloc( sList.getLength() + 1 );
+ // point at first element to copy
+ sVec.insert( sVec.end(), std::next(sList.begin(), nIndex), sList.end() );
- // point at first element to be overwritten
- std::copy(sVec.begin(), sVec.end(), std::next(sList.begin(), nIndex));
- }
+ sList.realloc( sList.getLength() + 1 );
- m_xProps->setPropertyValue( "StringItemList", uno::makeAny( sList ) );
+ // point at first element to be overwritten
+ std::copy(sVec.begin(), sVec.end(), std::next(sList.begin(), nIndex));
}
+
+ m_xProps->setPropertyValue( "StringItemList", uno::makeAny( sList ) );
}
void
@@ -136,25 +136,25 @@ ListControlHelper::removeItem( const uno::Any& index )
{
sal_Int32 nIndex = 0;
// for int index
- if ( index >>= nIndex )
+ if ( !(index >>= nIndex) )
+ return;
+
+ uno::Sequence< OUString > sList;
+ m_xProps->getPropertyValue( "StringItemList" ) >>= sList;
+ if( nIndex < 0 || nIndex > ( sList.getLength() - 1 ) )
+ throw uno::RuntimeException( "Invalid index" , uno::Reference< uno::XInterface > () );
+ if( sList.hasElements() )
{
- uno::Sequence< OUString > sList;
- m_xProps->getPropertyValue( "StringItemList" ) >>= sList;
- if( nIndex < 0 || nIndex > ( sList.getLength() - 1 ) )
- throw uno::RuntimeException( "Invalid index" , uno::Reference< uno::XInterface > () );
- if( sList.hasElements() )
+ if( sList.getLength() == 1 )
{
- if( sList.getLength() == 1 )
- {
- Clear();
- return;
- }
-
- comphelper::removeElementAt(sList, nIndex);
+ Clear();
+ return;
}
- m_xProps->setPropertyValue( "StringItemList", uno::makeAny( sList ) );
+ comphelper::removeElementAt(sList, nIndex);
}
+
+ m_xProps->setPropertyValue( "StringItemList", uno::makeAny( sList ) );
}
void