diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-22 08:56:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-22 12:46:56 +0100 |
commit | 06ad764cfb36ece7f054ecb786cc0395346a6a68 (patch) | |
tree | f67c2045e736fbbdb67d18255380b2d9288d75e4 /sfx2/source/view/sfxbasecontroller.cxx | |
parent | a73494cf130866d4e678a1f421df56cdba7441d8 (diff) |
improve function-local statics in scripting..svtools
Change-Id: Idf3785a1fbc6fc5b8efbdc4cd363047709f3af91
Reviewed-on: https://gerrit.libreoffice.org/63782
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source/view/sfxbasecontroller.cxx')
-rw-r--r-- | sfx2/source/view/sfxbasecontroller.cxx | 74 |
1 files changed, 29 insertions, 45 deletions
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index a15f07f3831c..697a78450279 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -113,56 +113,40 @@ struct GroupIDToCommandGroup sal_Int16 const nCommandGroup; }; -static bool bGroupIDMapInitialized = false; -static const GroupIDToCommandGroup GroupIDCommandGroupMap[] = -{ - { SfxGroupId::Intern , frame::CommandGroup::INTERNAL }, - { SfxGroupId::Application , frame::CommandGroup::APPLICATION }, - { SfxGroupId::Document , frame::CommandGroup::DOCUMENT }, - { SfxGroupId::View , frame::CommandGroup::VIEW }, - { SfxGroupId::Edit , frame::CommandGroup::EDIT }, - { SfxGroupId::Macro , frame::CommandGroup::MACRO }, - { SfxGroupId::Options , frame::CommandGroup::OPTIONS }, - { SfxGroupId::Math , frame::CommandGroup::MATH }, - { SfxGroupId::Navigator , frame::CommandGroup::NAVIGATOR }, - { SfxGroupId::Insert , frame::CommandGroup::INSERT }, - { SfxGroupId::Format , frame::CommandGroup::FORMAT }, - { SfxGroupId::Template , frame::CommandGroup::TEMPLATE }, - { SfxGroupId::Text , frame::CommandGroup::TEXT }, - { SfxGroupId::Frame , frame::CommandGroup::FRAME }, - { SfxGroupId::Graphic , frame::CommandGroup::GRAPHIC }, - { SfxGroupId::Table , frame::CommandGroup::TABLE }, - { SfxGroupId::Enumeration , frame::CommandGroup::ENUMERATION }, - { SfxGroupId::Data , frame::CommandGroup::DATA }, - { SfxGroupId::Special , frame::CommandGroup::SPECIAL }, - { SfxGroupId::Image , frame::CommandGroup::IMAGE }, - { SfxGroupId::Chart , frame::CommandGroup::CHART }, - { SfxGroupId::Explorer , frame::CommandGroup::EXPLORER }, - { SfxGroupId::Connector , frame::CommandGroup::CONNECTOR }, - { SfxGroupId::Modify , frame::CommandGroup::MODIFY }, - { SfxGroupId::Drawing , frame::CommandGroup::DRAWING }, - { SfxGroupId::Controls , frame::CommandGroup::CONTROLS }, - { SfxGroupId::NONE, 0 } -}; - typedef std::unordered_map< SfxGroupId, sal_Int16 > GroupHashMap; sal_Int16 MapGroupIDToCommandGroup( SfxGroupId nGroupID ) { - static GroupHashMap s_aHashMap; - - if ( !bGroupIDMapInitialized ) + static GroupHashMap s_aHashMap { - sal_Int32 i = 0; - while ( GroupIDCommandGroupMap[i].nGroupID != SfxGroupId::NONE ) - { - s_aHashMap.emplace( - GroupIDCommandGroupMap[i].nGroupID, - GroupIDCommandGroupMap[i].nCommandGroup ); - ++i; - } - bGroupIDMapInitialized = true; - } + { SfxGroupId::Intern , frame::CommandGroup::INTERNAL }, + { SfxGroupId::Application , frame::CommandGroup::APPLICATION }, + { SfxGroupId::Document , frame::CommandGroup::DOCUMENT }, + { SfxGroupId::View , frame::CommandGroup::VIEW }, + { SfxGroupId::Edit , frame::CommandGroup::EDIT }, + { SfxGroupId::Macro , frame::CommandGroup::MACRO }, + { SfxGroupId::Options , frame::CommandGroup::OPTIONS }, + { SfxGroupId::Math , frame::CommandGroup::MATH }, + { SfxGroupId::Navigator , frame::CommandGroup::NAVIGATOR }, + { SfxGroupId::Insert , frame::CommandGroup::INSERT }, + { SfxGroupId::Format , frame::CommandGroup::FORMAT }, + { SfxGroupId::Template , frame::CommandGroup::TEMPLATE }, + { SfxGroupId::Text , frame::CommandGroup::TEXT }, + { SfxGroupId::Frame , frame::CommandGroup::FRAME }, + { SfxGroupId::Graphic , frame::CommandGroup::GRAPHIC }, + { SfxGroupId::Table , frame::CommandGroup::TABLE }, + { SfxGroupId::Enumeration , frame::CommandGroup::ENUMERATION }, + { SfxGroupId::Data , frame::CommandGroup::DATA }, + { SfxGroupId::Special , frame::CommandGroup::SPECIAL }, + { SfxGroupId::Image , frame::CommandGroup::IMAGE }, + { SfxGroupId::Chart , frame::CommandGroup::CHART }, + { SfxGroupId::Explorer , frame::CommandGroup::EXPLORER }, + { SfxGroupId::Connector , frame::CommandGroup::CONNECTOR }, + { SfxGroupId::Modify , frame::CommandGroup::MODIFY }, + { SfxGroupId::Drawing , frame::CommandGroup::DRAWING }, + { SfxGroupId::Controls , frame::CommandGroup::CONTROLS }, + }; + GroupHashMap::const_iterator pIter = s_aHashMap.find( nGroupID ); if ( pIter != s_aHashMap.end() ) |