Kaydet (Commit) 85696df0 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Fixed a crash due to invalid index for Sequence.

With this, 3.81 sec -> 1.2 sec.
üst 98dc4bb8
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#include <com/sun/star/reflection/XIdlMethod.hpp> #include <com/sun/star/reflection/XIdlMethod.hpp>
#include <com/sun/star/script/XTypeConverter.hpp> #include <com/sun/star/script/XTypeConverter.hpp>
#include <com/sun/star/script/XEngineListener.hpp> #include <com/sun/star/script/XEngineListener.hpp>
#include <com/sun/star/script/XEventAttacher.hpp> #include <com/sun/star/script/XEventAttacher2.hpp>
#include <com/sun/star/script/XEventAttacherManager.hpp> #include <com/sun/star/script/XEventAttacherManager.hpp>
#include <com/sun/star/script/XScriptListener.hpp> #include <com/sun/star/script/XScriptListener.hpp>
#include <cppuhelper/weak.hxx> #include <cppuhelper/weak.hxx>
...@@ -103,7 +103,7 @@ class ImplEventAttacherManager ...@@ -103,7 +103,7 @@ class ImplEventAttacherManager
// Container fuer die ScriptListener // Container fuer die ScriptListener
OInterfaceContainerHelper aScriptListeners; OInterfaceContainerHelper aScriptListeners;
// EventAttacher-Instanz // EventAttacher-Instanz
Reference< XEventAttacher > xAttacher; Reference< XEventAttacher2 > xAttacher;
Reference< XMultiServiceFactory > mxSMgr; Reference< XMultiServiceFactory > mxSMgr;
Reference< XIdlReflection > mxCoreReflection; Reference< XIdlReflection > mxCoreReflection;
Reference< XIntrospection > mxIntrospection; Reference< XIntrospection > mxIntrospection;
...@@ -403,7 +403,7 @@ ImplEventAttacherManager::ImplEventAttacherManager( const Reference< XIntrospect ...@@ -403,7 +403,7 @@ ImplEventAttacherManager::ImplEventAttacherManager( const Reference< XIntrospect
Reference< XInterface > xIFace( rSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.EventAttacher" )) ) ); Reference< XInterface > xIFace( rSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.EventAttacher" )) ) );
if ( xIFace.is() ) if ( xIFace.is() )
{ {
xAttacher = Reference< XEventAttacher >::query( xIFace ); xAttacher = Reference< XEventAttacher2 >::query( xIFace );
} }
xIFace = rSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.Converter" )) ); xIFace = rSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.Converter" )) );
if ( xIFace.is() ) if ( xIFace.is() )
...@@ -692,28 +692,33 @@ void SAL_CALL ImplEventAttacherManager::attach(sal_Int32 nIndex, const Reference ...@@ -692,28 +692,33 @@ void SAL_CALL ImplEventAttacherManager::attach(sal_Int32 nIndex, const Reference
//::std::deque< AttachedObject_Impl >::iterator aObjIt = (*aIt).aObjList.back(); //::std::deque< AttachedObject_Impl >::iterator aObjIt = (*aIt).aObjList.back();
AttachedObject_Impl & rCurObj = aCurrentPosition->aObjList.back(); AttachedObject_Impl & rCurObj = aCurrentPosition->aObjList.back();
rCurObj.aAttachedListenerSeq = Sequence< Reference< XEventListener > >( aCurrentPosition->aEventList.size() ); rCurObj.aAttachedListenerSeq = Sequence< Reference< XEventListener > >( aCurrentPosition->aEventList.size() );
Reference< XEventListener > * pArray = rCurObj.aAttachedListenerSeq.getArray();
::std::deque< ScriptEventDescriptor >::iterator aEvtIt = aCurrentPosition->aEventList.begin(); if (!aCurrentPosition->aEventList.empty())
::std::deque< ScriptEventDescriptor >::iterator aEvtEnd = aCurrentPosition->aEventList.end();
sal_Int32 i = 0;
while( aEvtIt != aEvtEnd )
{ {
Reference< XAllListener > xAll = Sequence<com::sun::star::script::EventListener> aEvents(aCurrentPosition->aEventList.size());
new AttacherAllListener_Impl( this, (*aEvtIt).ScriptType, (*aEvtIt).ScriptCode ); std::deque<ScriptEventDescriptor>::iterator itr = aCurrentPosition->aEventList.begin();
Reference< XEventListener > xAdapter; std::deque<ScriptEventDescriptor>::iterator itrEnd = aCurrentPosition->aEventList.end();
try ::com::sun::star::script::EventListener* p = aEvents.getArray();
size_t i = 0;
for (; itr != itrEnd; ++itr)
{ {
xAdapter = xAttacher->attachSingleEventListener( rCurObj.xTarget, xAll, com::sun::star::script::EventListener aListener;
rCurObj.aHelper, (*aEvtIt).ListenerType, aListener.AllListener =
(*aEvtIt).AddListenerParam, (*aEvtIt).EventMethod ); 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;
} }
catch( Exception& )
try
{
rCurObj.aAttachedListenerSeq = xAttacher->attachMultipleEventListeners(rCurObj.xTarget, aEvents);
}
catch (const Exception&)
{ {
} }
pArray[i++] = xAdapter;
++aEvtIt;
} }
} }
......
...@@ -743,6 +743,7 @@ Sequence< Reference<XEventListener> > EventAttacherImpl::attachListeners( ...@@ -743,6 +743,7 @@ Sequence< Reference<XEventListener> > EventAttacherImpl::attachListeners(
return Sequence< Reference<XEventListener> >(); return Sequence< Reference<XEventListener> >();
Sequence< Reference<XEventListener> > aRet(nCount); Sequence< Reference<XEventListener> > aRet(nCount);
Reference<XEventListener>* pArray = aRet.getArray();
for (sal_Int32 i = 0; i < nCount; ++i) for (sal_Int32 i = 0; i < nCount; ++i)
{ {
...@@ -846,7 +847,7 @@ Sequence< Reference<XEventListener> > EventAttacherImpl::attachListeners( ...@@ -846,7 +847,7 @@ Sequence< Reference<XEventListener> > EventAttacherImpl::attachListeners(
// Anything else is not supported // Anything else is not supported
} }
} }
aRet[nCount] = xRet; pArray[i] = xRet;
} }
return aRet; return aRet;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment