diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-12-29 15:21:07 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-12-29 14:40:46 +0100 |
commit | 907fd292c19868b78bcf51ae896e4daffa452ec0 (patch) | |
tree | 69f8690c09190333d8489c974c4ccefea84705da /sfx2 | |
parent | 2a881af4e93f8744bc6bea43f3a06fa531626c22 (diff) |
Small refactor
Use a bit more modern flags with MENUITEMINFOW, and simplify
MYITEM destruction.
Change-Id: I015e09b875fafcd287bbf45cdc20cf83d2c3e502
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127679
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/shutdowniconw32.cxx | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index 3c0c62359fe9..13ef8aa07058 100644 --- a/sfx2/source/appl/shutdowniconw32.cxx +++ b/sfx2/source/appl/shutdowniconw32.cxx @@ -79,12 +79,12 @@ static void OnDrawItem(HWND hwnd, LPDRAWITEMSTRUCT lpdis); namespace { -typedef struct tagMYITEM +struct MYITEM { OUString text; OUString module; UINT iconId; -} MYITEM; +}; } @@ -95,35 +95,32 @@ static void addMenuItem( HMENU hMenu, UINT id, UINT iconId, const OUString& text mi.cbSize = sizeof( mi ); if( id == static_cast<UINT>( -1 ) ) { - mi.fMask=MIIM_TYPE; + mi.fMask=MIIM_FTYPE; mi.fType=MFT_SEPARATOR; } else { if( bOwnerdraw ) { - mi.fMask=MIIM_TYPE | MIIM_STATE | MIIM_ID | MIIM_DATA; + mi.fMask=MIIM_FTYPE | MIIM_STATE | MIIM_ID | MIIM_DATA; mi.fType=MFT_OWNERDRAW; - mi.fState=MFS_ENABLED; - mi.wID = id; MYITEM *pMyItem = new MYITEM; pMyItem->text = text; pMyItem->iconId = iconId; pMyItem->module = module; - mi.dwItemData = reinterpret_cast<DWORD_PTR>(pMyItem); + mi.dwItemData = reinterpret_cast<ULONG_PTR>(pMyItem); } else { - mi.fMask=MIIM_TYPE | MIIM_STATE | MIIM_ID | MIIM_DATA; - mi.fType=MFT_STRING; - mi.fState=MFS_ENABLED; - mi.wID = id; + mi.fMask=MIIM_STRING | MIIM_STATE | MIIM_ID; mi.dwTypeData = o3tl::toW( const_cast<sal_Unicode *>(text.getStr())); mi.cch = text.getLength(); } + mi.fState = MFS_ENABLED; + mi.wID = id; if ( IDM_TEMPLATE == id ) mi.fState |= MFS_DEFAULT; } @@ -211,18 +208,13 @@ static void deleteSystrayMenu( HMENU hMenu ) return; MENUITEMINFOW mi = {}; - int pos=0; mi.cbSize = sizeof( mi ); mi.fMask = MIIM_DATA; - while( GetMenuItemInfoW( hMenu, pos++, true, &mi ) ) + for (UINT pos = 0; GetMenuItemInfoW(hMenu, pos, true, &mi); ++pos) { - MYITEM *pMyItem = reinterpret_cast<MYITEM*>(mi.dwItemData); - if( pMyItem ) - { - pMyItem->text.clear(); + if (MYITEM* pMyItem = reinterpret_cast<MYITEM*>(mi.dwItemData)) delete pMyItem; - } mi.fMask = MIIM_DATA; } } |