diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-07 15:34:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-07 19:28:23 +0200 |
commit | 8544e0a20bd8f8d8c918f91f90768019fa8099d7 (patch) | |
tree | 95175d6b1174d4d1caea0eceacf2bcfedde90627 | |
parent | ca21e8618f446733ab5d046178ebb47c2d204840 (diff) |
m_aVerbTable can be a std::map
instead of using the heavyweight Sequence datastructures
Change-Id: Ica6b30490f2a1b4367acbf0341ecc86701c21926
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93641
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | embeddedobj/source/commonembedding/embedobj.cxx | 6 | ||||
-rw-r--r-- | embeddedobj/source/commonembedding/miscobj.cxx | 31 | ||||
-rw-r--r-- | embeddedobj/source/inc/commonembobj.hxx | 3 |
3 files changed, 11 insertions, 29 deletions
diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx index 6250555e05ec..abc43f42736f 100644 --- a/embeddedobj/source/commonembedding/embedobj.cxx +++ b/embeddedobj/source/commonembedding/embedobj.cxx @@ -74,9 +74,9 @@ awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt sal_Int32 OCommonEmbeddedObject::ConvertVerbToState_Impl( sal_Int32 nVerb ) { - for ( sal_Int32 nInd = 0; nInd < m_aVerbTable.getLength(); nInd++ ) - if ( m_aVerbTable[nInd][0] == nVerb ) - return m_aVerbTable[nInd][1]; + auto it = m_aVerbTable.find( nVerb ); + if (it != m_aVerbTable.end()) + return it->second; throw lang::IllegalArgumentException(); // TODO: unexpected verb provided } diff --git a/embeddedobj/source/commonembedding/miscobj.cxx b/embeddedobj/source/commonembedding/miscobj.cxx index 71f79fabd96d..3363a02bfd02 100644 --- a/embeddedobj/source/commonembedding/miscobj.cxx +++ b/embeddedobj/source/commonembedding/miscobj.cxx @@ -161,50 +161,31 @@ void OCommonEmbeddedObject::CommonInit_Impl( const uno::Sequence< beans::NamedVa m_pIntermediateStatesSeqs[4][0][0] = embed::EmbedStates::RUNNING; // verbs table - sal_Int32 nVerbTableSize = 0; for ( sal_Int32 nVerbInd = 0; nVerbInd < m_aObjectVerbs.getLength(); nVerbInd++ ) { if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_PRIMARY ) { - m_aVerbTable.realloc( ++nVerbTableSize ); - m_aVerbTable[nVerbTableSize - 1].realloc( 2 ); - m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID; - m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::UI_ACTIVE; + m_aVerbTable.insert( { m_aObjectVerbs[nVerbInd].VerbID, embed::EmbedStates::UI_ACTIVE } ); } else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_SHOW ) { - m_aVerbTable.realloc( ++nVerbTableSize ); - m_aVerbTable[nVerbTableSize - 1].realloc( 2 ); - m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID; - m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::UI_ACTIVE; + m_aVerbTable.insert( { m_aObjectVerbs[nVerbInd].VerbID, embed::EmbedStates::UI_ACTIVE } ); } else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_OPEN ) { - m_aVerbTable.realloc( ++nVerbTableSize ); - m_aVerbTable[nVerbTableSize - 1].realloc( 2 ); - m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID; - m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::ACTIVE; + m_aVerbTable.insert( { m_aObjectVerbs[nVerbInd].VerbID, embed::EmbedStates::ACTIVE } ); } else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_IPACTIVATE ) { - m_aVerbTable.realloc( ++nVerbTableSize ); - m_aVerbTable[nVerbTableSize - 1].realloc( 2 ); - m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID; - m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::INPLACE_ACTIVE; + m_aVerbTable.insert( { m_aObjectVerbs[nVerbInd].VerbID, embed::EmbedStates::INPLACE_ACTIVE } ); } else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_UIACTIVATE ) { - m_aVerbTable.realloc( ++nVerbTableSize ); - m_aVerbTable[nVerbTableSize - 1].realloc( 2 ); - m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID; - m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::UI_ACTIVE; + m_aVerbTable.insert( { m_aObjectVerbs[nVerbInd].VerbID, embed::EmbedStates::UI_ACTIVE } ); } else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_HIDE ) { - m_aVerbTable.realloc( ++nVerbTableSize ); - m_aVerbTable[nVerbTableSize - 1].realloc( 2 ); - m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID; - m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::RUNNING; + m_aVerbTable.insert( { m_aObjectVerbs[nVerbInd].VerbID, embed::EmbedStates::RUNNING } ); } } } diff --git a/embeddedobj/source/inc/commonembobj.hxx b/embeddedobj/source/inc/commonembobj.hxx index b2c9acd9ec1e..0246e7f3f3bc 100644 --- a/embeddedobj/source/inc/commonembobj.hxx +++ b/embeddedobj/source/inc/commonembobj.hxx @@ -35,6 +35,7 @@ #include <com/sun/star/chart2/XDefaultSizeTransmitter.hpp> #include <cppuhelper/weak.hxx> #include <rtl/ref.hxx> +#include <map> namespace com { namespace sun { namespace star { namespace embed { @@ -111,7 +112,7 @@ protected: css::uno::Sequence< sal_Int32 > m_aAcceptedStates; css::uno::Sequence< sal_Int32 > m_pIntermediateStatesSeqs[NUM_SUPPORTED_STATES][NUM_SUPPORTED_STATES]; - css::uno::Sequence< css::uno::Sequence< sal_Int32 > > m_aVerbTable; + std::map< sal_Int32, sal_Int32 > m_aVerbTable; css::uno::Reference< css::embed::XEmbeddedClient > m_xClientSite; |