diff options
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/eventattachermgr/eventattachermgr.cxx | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx index e9d52290d460..4db4e60b71d5 100644 --- a/comphelper/source/eventattachermgr/eventattachermgr.cxx +++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx @@ -693,32 +693,34 @@ void SAL_CALL ImplEventAttacherManager::attach(sal_Int32 nIndex, const Reference AttachedObject_Impl & rCurObj = aCurrentPosition->aObjList.back(); rCurObj.aAttachedListenerSeq = Sequence< Reference< XEventListener > >( aCurrentPosition->aEventList.size() ); - if (!aCurrentPosition->aEventList.empty()) + if (aCurrentPosition->aEventList.empty()) + return; + + Sequence<com::sun::star::script::EventListener> aEvents(aCurrentPosition->aEventList.size()); + std::deque<ScriptEventDescriptor>::iterator itr = aCurrentPosition->aEventList.begin(); + std::deque<ScriptEventDescriptor>::iterator itrEnd = aCurrentPosition->aEventList.end(); + ::com::sun::star::script::EventListener* p = aEvents.getArray(); + size_t i = 0; + for (; itr != itrEnd; ++itr) { - Sequence<com::sun::star::script::EventListener> aEvents(aCurrentPosition->aEventList.size()); - std::deque<ScriptEventDescriptor>::iterator itr = aCurrentPosition->aEventList.begin(); - std::deque<ScriptEventDescriptor>::iterator itrEnd = aCurrentPosition->aEventList.end(); - ::com::sun::star::script::EventListener* p = aEvents.getArray(); - size_t i = 0; - for (; itr != itrEnd; ++itr) - { - com::sun::star::script::EventListener aListener; - aListener.AllListener = - new AttacherAllListener_Impl(this, itr->ScriptType, itr->ScriptCode); - aListener.Helper = rCurObj.aHelper; - aListener.ListenerType = itr->ListenerType; - aListener.EventMethod = itr->EventMethod; - aListener.AddListenerParam = itr->AddListenerParam; - p[i++] = aListener; - } + com::sun::star::script::EventListener aListener; + aListener.AllListener = + new AttacherAllListener_Impl(this, itr->ScriptType, itr->ScriptCode); + aListener.Helper = rCurObj.aHelper; + aListener.ListenerType = itr->ListenerType; + aListener.EventMethod = itr->EventMethod; + aListener.AddListenerParam = itr->AddListenerParam; + p[i++] = aListener; + } - try - { - rCurObj.aAttachedListenerSeq = xAttacher->attachMultipleEventListeners(rCurObj.xTarget, aEvents); - } - catch (const Exception&) - { - } + try + { + rCurObj.aAttachedListenerSeq = + xAttacher->attachMultipleEventListeners(rCurObj.xTarget, aEvents); + } + catch (const Exception&) + { + // Fail gracefully. } } |