summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-04-30 14:24:06 +0200
committerAndras Timar <andras.timar@collabora.com>2020-05-13 10:56:03 +0200
commit4761a0ba7e7f3ca9c4ed8c343c92f85038258600 (patch)
tree3218a121bd91121a65b4138e63041b91d5ad8935 /toolkit
parent09c15ac9c916b33f33a7b0f65ea93efc2015721f (diff)
Revert "remove some "optimisation" insanity in ScriptEventContainer"
This broke the event order in basic dialog xml, which in turn broke macro signatures. This reverts commit 85f08e3e34bea01456eaf8989ac4f77d3900d5c5. Change-Id: I49ef2eb200571a0fd862770abc4331b6ea053e2b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93209 Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93607 Tested-by: Jenkins
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/source/controls/eventcontainer.cxx56
1 files changed, 38 insertions, 18 deletions
diff --git a/toolkit/source/controls/eventcontainer.cxx b/toolkit/source/controls/eventcontainer.cxx
index 24b832020bbb..14f6e15b89ca 100644
--- a/toolkit/source/controls/eventcontainer.cxx
+++ b/toolkit/source/controls/eventcontainer.cxx
@@ -43,33 +43,33 @@ Type ScriptEventContainer::getElementType()
sal_Bool ScriptEventContainer::hasElements()
{
- return !mHashMap.empty();
+ bool bRet = (mnElementCount > 0);
+ return bRet;
}
// Methods XNameAccess
Any ScriptEventContainer::getByName( const OUString& aName )
{
- auto aIt = mHashMap.find( aName );
+ NameContainerNameMap::iterator aIt = mHashMap.find( aName );
if( aIt == mHashMap.end() )
{
throw NoSuchElementException();
}
- return aIt->second;
+ sal_Int32 iHashResult = (*aIt).second;
+ Any aRetAny = mValues[ iHashResult ];
+ return aRetAny;
}
Sequence< OUString > ScriptEventContainer::getElementNames()
{
- Sequence<OUString> aRet(mHashMap.size());
- int i = 0;
- for (auto const & pair : mHashMap)
- aRet[i++] = pair.first;
- return aRet;
+ return mNames;
}
sal_Bool ScriptEventContainer::hasByName( const OUString& aName )
{
- auto aIt = mHashMap.find( aName );
- return aIt != mHashMap.end();
+ NameContainerNameMap::iterator aIt = mHashMap.find( aName );
+ bool bRet = ( aIt != mHashMap.end() );
+ return bRet;
}
@@ -80,13 +80,14 @@ void ScriptEventContainer::replaceByName( const OUString& aName, const Any& aEle
if( mType != aAnyType )
throw IllegalArgumentException();
- auto aIt = mHashMap.find( aName );
+ NameContainerNameMap::iterator aIt = mHashMap.find( aName );
if( aIt == mHashMap.end() )
{
throw NoSuchElementException();
}
- Any aOldElement = aIt->second;
- aIt->second = aElement;
+ sal_Int32 iHashResult = (*aIt).second;
+ Any aOldElement = mValues[ iHashResult ];
+ mValues[ iHashResult ] = aElement;
// Fire event
ContainerEvent aEvent;
@@ -105,13 +106,18 @@ void ScriptEventContainer::insertByName( const OUString& aName, const Any& aElem
if( mType != aAnyType )
throw IllegalArgumentException();
- auto aIt = mHashMap.find( aName );
+ NameContainerNameMap::iterator aIt = mHashMap.find( aName );
if( aIt != mHashMap.end() )
{
throw ElementExistException();
}
- mHashMap[ aName ] = aElement;
+ sal_Int32 nCount = mNames.getLength();
+ mNames.realloc( nCount + 1 );
+ mValues.resize( nCount + 1 );
+ mNames.getArray()[ nCount ] = aName;
+ mValues[ nCount ] = aElement;
+ mHashMap[ aName ] = nCount;
// Fire event
ContainerEvent aEvent;
@@ -123,20 +129,33 @@ void ScriptEventContainer::insertByName( const OUString& aName, const Any& aElem
void ScriptEventContainer::removeByName( const OUString& Name )
{
- auto aIt = mHashMap.find( Name );
+ NameContainerNameMap::iterator aIt = mHashMap.find( Name );
if( aIt == mHashMap.end() )
{
throw NoSuchElementException();
}
+ sal_Int32 iHashResult = (*aIt).second;
+ Any aOldElement = mValues[ iHashResult ];
+
// Fire event
ContainerEvent aEvent;
aEvent.Source = *this;
- aEvent.Element = aIt->second;
+ aEvent.Element = aOldElement;
aEvent.Accessor <<= Name;
maContainerListeners.elementRemoved( aEvent );
mHashMap.erase( aIt );
+ sal_Int32 iLast = mNames.getLength() - 1;
+ if( iLast != iHashResult )
+ {
+ OUString* pNames = mNames.getArray();
+ pNames[ iHashResult ] = pNames[ iLast ];
+ mValues[ iHashResult ] = mValues[ iLast ];
+ mHashMap[ pNames[ iHashResult ] ] = iHashResult;
+ }
+ mNames.realloc( iLast );
+ mValues.resize( iLast );
}
// Methods XContainer
@@ -152,7 +171,8 @@ void ScriptEventContainer::removeContainerListener( const css::uno::Reference< c
ScriptEventContainer::ScriptEventContainer()
- : mType( cppu::UnoType<ScriptEventDescriptor>::get() ),
+ : mnElementCount( 0 ),
+ mType( cppu::UnoType<ScriptEventDescriptor>::get() ),
maContainerListeners( *this )
{
}