diff options
author | Noel Grandin <noel@peralex.com> | 2016-01-28 14:56:59 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-01-29 10:54:23 +0200 |
commit | ba03604b55e757d31aef3c676e177a7b7101cf20 (patch) | |
tree | f389193085ae19dafeb5df9e9e78a1d693d4d7e3 /comphelper | |
parent | 0a1267d2c7096037ca1999f4d4c741e045d38f5c (diff) |
sequence->vector in AttachedObject_Impl
Change-Id: I457de7e83554fbea0a9c5a50c628664fa3887df4
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/eventattachermgr/eventattachermgr.cxx | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx index 2f2fb5d03883..1be6f430a650 100644 --- a/comphelper/source/eventattachermgr/eventattachermgr.cxx +++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx @@ -64,7 +64,7 @@ namespace comphelper struct AttachedObject_Impl { Reference< XInterface > xTarget; - Sequence< Reference< XEventListener > > aAttachedListenerSeq; + std::vector< Reference< XEventListener > > aAttachedListenerSeq; Any aHelper; }; @@ -439,17 +439,13 @@ void SAL_CALL ImplEventAttacherManager::registerScriptEvent // register new new Event for( auto& rObj : aIt->aObjList ) { - // resize - sal_Int32 nPos = rObj.aAttachedListenerSeq.getLength(); - rObj.aAttachedListenerSeq.realloc( nPos + 1 ); - Reference< XEventListener >* pArray = rObj.aAttachedListenerSeq.getArray(); Reference< XAllListener > xAll = new AttacherAllListener_Impl( this, ScriptEvent.ScriptType, ScriptEvent.ScriptCode ); try { - pArray[nPos] = xAttacher->attachSingleEventListener( rObj.xTarget, xAll, + rObj.aAttachedListenerSeq.push_back( xAttacher->attachSingleEventListener( rObj.xTarget, xAll, rObj.aHelper, ScriptEvent.ListenerType, - ScriptEvent.AddListenerParam, ScriptEvent.EventMethod ); + ScriptEvent.AddListenerParam, ScriptEvent.EventMethod ) ); } catch( Exception& ) { @@ -604,7 +600,7 @@ void SAL_CALL ImplEventAttacherManager::attach(sal_Int32 nIndex, const Reference aCurrentPosition->aObjList.push_back( aTmp ); AttachedObject_Impl & rCurObj = aCurrentPosition->aObjList.back(); - rCurObj.aAttachedListenerSeq = Sequence< Reference< XEventListener > >( aCurrentPosition->aEventList.size() ); + rCurObj.aAttachedListenerSeq = std::vector< Reference< XEventListener > >( aCurrentPosition->aEventList.size() ); if (aCurrentPosition->aEventList.empty()) return; @@ -628,8 +624,8 @@ void SAL_CALL ImplEventAttacherManager::attach(sal_Int32 nIndex, const Reference try { - rCurObj.aAttachedListenerSeq = - xAttacher->attachMultipleEventListeners(rCurObj.xTarget, aEvents); + rCurObj.aAttachedListenerSeq = comphelper::sequenceToContainer<std::vector<Reference< XEventListener >>>( + xAttacher->attachMultipleEventListeners(rCurObj.xTarget, aEvents)); } catch (const Exception&) { @@ -654,17 +650,15 @@ void SAL_CALL ImplEventAttacherManager::detach(sal_Int32 nIndex, const Reference { if( aObjIt->xTarget == xObject ) { - Reference< XEventListener > * pArray = aObjIt->aAttachedListenerSeq.getArray(); - sal_Int32 i = 0; for( const auto& rEvt : aCurrentPosition->aEventList ) { - if( pArray[i].is() ) + if( aObjIt->aAttachedListenerSeq[i].is() ) { try { - xAttacher->removeListener( aObjIt->xTarget, rEvt.ListenerType, - rEvt.AddListenerParam, pArray[i] ); + xAttacher->removeListener( aObjIt->xTarget, rEvt.ListenerType, + rEvt.AddListenerParam, aObjIt->aAttachedListenerSeq[i] ); } catch( Exception& ) { |