diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2019-11-22 10:51:20 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2019-11-23 01:48:55 +0100 |
commit | 32dcf3f0fdafcf44457842a8aa4f54d30d856ca9 (patch) | |
tree | e7371a77f05b64541b1d1f4b41b97dd79cd43e28 /cui/source | |
parent | 5ac711f83bc795bbcc459c9d56bf9ee91b78fd3c (diff) |
treeopt.cxx: Simplify 'ModuleMap' handling
Use 'OUString' instead of 'const char*' for
'ModuleToGroupNameMap_Impl.m_pModule', and
simplify the iteration using range-based for.
Change-Id: I1756bc6ac8b163a68b79d6900738362db010d8a9
Reviewed-on: https://gerrit.libreoffice.org/83488
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/options/treeopt.cxx | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index f2a4fd4bb2d7..0195856932c7 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -134,11 +134,10 @@ namespace { struct ModuleToGroupNameMap_Impl { - const char* m_pModule; + OUString m_pModule; OUString m_sGroupName; sal_uInt16 m_nNodeId; }; - } static ModuleToGroupNameMap_Impl ModuleMap[] = @@ -155,40 +154,30 @@ static ModuleToGroupNameMap_Impl ModuleMap[] = { "Draw", OUString(), SID_SD_GRAPHIC_OPTIONS }, { "Charts", OUString(), SID_SCH_EDITOPTIONS }, { "Base", OUString(), SID_SB_STARBASEOPTIONS }, - - { nullptr, OUString(), 0xFFFF } }; static void setGroupName( const OUString& rModule, const OUString& rGroupName ) { - sal_uInt16 nIndex = 0; - while ( ModuleMap[ nIndex ].m_pModule ) + for (ModuleToGroupNameMap_Impl& rEntry : ModuleMap) { - OUString sTemp = - OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule ); - if ( sTemp == rModule ) + if ( rEntry.m_pModule == rModule ) { - ModuleMap[ nIndex ].m_sGroupName = rGroupName; + rEntry.m_sGroupName = rGroupName; break; } - ++nIndex; } } static OUString getGroupName( const OUString& rModule, bool bForced ) { OUString sGroupName; - sal_uInt16 nIndex = 0; - while ( ModuleMap[ nIndex ].m_pModule ) + for (const ModuleToGroupNameMap_Impl& rEntry : ModuleMap) { - OUString sTemp = - OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule ); - if ( sTemp == rModule ) + if ( rEntry.m_pModule == rModule ) { - sGroupName = ModuleMap[ nIndex ].m_sGroupName; + sGroupName = rEntry.m_sGroupName; break; } - ++nIndex; } if ( sGroupName.isEmpty() && bForced ) @@ -213,24 +202,20 @@ static OUString getGroupName( const OUString& rModule, bool bForced ) static void deleteGroupNames() { - sal_uInt16 nIndex = 0; - while ( ModuleMap[ nIndex ].m_pModule ) - ModuleMap[ nIndex++ ].m_sGroupName.clear(); + for (ModuleToGroupNameMap_Impl& rEntry : ModuleMap) + rEntry.m_sGroupName.clear(); } static sal_uInt16 getGroupNodeId( const OUString& rModule ) { - sal_uInt16 nNodeId = 0xFFFF, nIndex = 0; - while ( ModuleMap[ nIndex ].m_pModule ) + sal_uInt16 nNodeId = 0xFFFF; + for (const ModuleToGroupNameMap_Impl& rEntry : ModuleMap) { - OUString sTemp = - OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule ); - if ( sTemp == rModule ) + if ( rEntry.m_pModule == rModule ) { - nNodeId = ModuleMap[ nIndex ].m_nNodeId; + nNodeId = rEntry.m_nNodeId; break; } - ++nIndex; } return nNodeId; |