diff options
-rw-r--r-- | vcl/inc/osx/salinst.h | 3 | ||||
-rw-r--r-- | vcl/inc/qt5/Qt5Instance.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/salinst.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkinst.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/win/salinst.h | 3 | ||||
-rw-r--r-- | vcl/osx/salmenu.cxx | 14 | ||||
-rw-r--r-- | vcl/qt5/Qt5Instance.cxx | 6 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 7 | ||||
-rw-r--r-- | vcl/source/window/menu.cxx | 14 | ||||
-rw-r--r-- | vcl/source/window/menufloatingwindow.cxx | 1 | ||||
-rw-r--r-- | vcl/source/window/menuitemlist.cxx | 7 | ||||
-rw-r--r-- | vcl/source/window/menuitemlist.hxx | 4 | ||||
-rw-r--r-- | vcl/source/window/menuwindow.cxx | 1 | ||||
-rw-r--r-- | vcl/unx/gtk/gtkinst.cxx | 13 | ||||
-rw-r--r-- | vcl/win/window/salmenu.cxx | 24 |
15 files changed, 35 insertions, 71 deletions
diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h index 18f8630b0f27..a19e9e423f9b 100644 --- a/vcl/inc/osx/salinst.h +++ b/vcl/inc/osx/salinst.h @@ -120,8 +120,7 @@ public: virtual bool AnyInput( VclInputFlags nType ) override; virtual SalMenu* CreateMenu( bool bMenuBar, Menu* pVCLMenu ) override; virtual void DestroyMenu( SalMenu* ) override; - virtual SalMenuItem* CreateMenuItem( const SalItemParams* pItemData ) override; - virtual void DestroyMenuItem( SalMenuItem* ) override; + virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams & rItemData ) override; virtual OpenGLContext* CreateOpenGLContext() override; virtual OUString GetConnectionIdentifier() override; virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx index aea3e792bfa0..16e22098cd09 100644 --- a/vcl/inc/qt5/Qt5Instance.hxx +++ b/vcl/inc/qt5/Qt5Instance.hxx @@ -82,8 +82,7 @@ public: virtual SalMenu* CreateMenu(bool, Menu*) override; virtual void DestroyMenu(SalMenu* pMenu) override; - virtual SalMenuItem* CreateMenuItem(const SalItemParams*) override; - virtual void DestroyMenuItem(SalMenuItem* pItem) override; + virtual std::unique_ptr<SalMenuItem> CreateMenuItem(const SalItemParams&) override; virtual SalTimer* CreateSalTimer() override; virtual SalSystem* CreateSalSystem() override; diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx index c8f330350ad4..3924ee3d497f 100644 --- a/vcl/inc/salinst.hxx +++ b/vcl/inc/salinst.hxx @@ -154,8 +154,7 @@ public: // menus virtual SalMenu* CreateMenu( bool bMenuBar, Menu* pMenu ); virtual void DestroyMenu( SalMenu* pMenu); - virtual SalMenuItem* CreateMenuItem( const SalItemParams* pItemData ); - virtual void DestroyMenuItem( SalMenuItem* pItem ); + virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams& pItemData ); // may return NULL to disable session management, only used by X11 backend virtual std::unique_ptr<SalSession> CreateSalSession(); diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index 25d3ff020886..499bacadd5b4 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -200,8 +200,7 @@ public: virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) override; virtual SalMenu* CreateMenu( bool, Menu* ) override; virtual void DestroyMenu( SalMenu* pMenu ) override; - virtual SalMenuItem* CreateMenuItem( const SalItemParams* ) override; - virtual void DestroyMenuItem( SalMenuItem* pItem ) override; + virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams& ) override; virtual SalTimer* CreateSalTimer() override; virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override; virtual std::unique_ptr<SalVirtualDevice> diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h index 4274f731ee2b..e96fbc5b56b0 100644 --- a/vcl/inc/win/salinst.h +++ b/vcl/inc/win/salinst.h @@ -74,8 +74,7 @@ public: virtual bool AnyInput( VclInputFlags nType ) override; virtual SalMenu* CreateMenu( bool bMenuBar, Menu* ) override; virtual void DestroyMenu( SalMenu* ) override; - virtual SalMenuItem* CreateMenuItem( const SalItemParams* pItemData ) override; - virtual void DestroyMenuItem( SalMenuItem* ) override; + virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams & rItemData ) override; virtual OpenGLContext* CreateOpenGLContext() override; virtual OUString GetConnectionIdentifier() override; virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override; diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx index c12eb41c236f..ff400fdd4810 100644 --- a/vcl/osx/salmenu.cxx +++ b/vcl/osx/salmenu.cxx @@ -233,19 +233,11 @@ void AquaSalInstance::DestroyMenu( SalMenu* pSalMenu ) delete pSalMenu; } -SalMenuItem* AquaSalInstance::CreateMenuItem( const SalItemParams* pItemData ) +std::unique_ptr<SalMenuItem> AquaSalInstance::CreateMenuItem( const SalItemParams & rItemData ) { - if( !pItemData ) - return nullptr; + AquaSalMenuItem *pSalMenuItem = new AquaSalMenuItem( &rItemData ); - AquaSalMenuItem *pSalMenuItem = new AquaSalMenuItem( pItemData ); - - return pSalMenuItem; -} - -void AquaSalInstance::DestroyMenuItem( SalMenuItem* pSalMenuItem ) -{ - delete pSalMenuItem; + return std::unique_ptr<SalMenuItem>(pSalMenuItem); } /* diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx index 8585ea851c88..705137c16c50 100644 --- a/vcl/qt5/Qt5Instance.cxx +++ b/vcl/qt5/Qt5Instance.cxx @@ -120,13 +120,11 @@ SalMenu* Qt5Instance::CreateMenu(bool bMenuBar, Menu* pVCLMenu) void Qt5Instance::DestroyMenu(SalMenu* pMenu) { delete pMenu; } -SalMenuItem* Qt5Instance::CreateMenuItem(const SalItemParams* pItemData) +std::unique_ptr<SalMenuItem> Qt5Instance::CreateMenuItem(const SalItemParams& rItemData) { - return new Qt5MenuItem(pItemData); + return std::unique_ptr<SalMenuItem>(new Qt5MenuItem(&rItemData)); } -void Qt5Instance::DestroyMenuItem(SalMenuItem* pItem) { delete pItem; } - SalTimer* Qt5Instance::CreateSalTimer() { return new Qt5Timer(); } SalSystem* Qt5Instance::CreateSalSystem() { return new SvpSalSystem(); } diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 1b35c8be0461..d5ac7c95e513 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -98,16 +98,11 @@ void SalInstance::DestroyMenu( SalMenu* pMenu ) OSL_ENSURE( pMenu == nullptr, "DestroyMenu called with non-native menus" ); } -SalMenuItem* SalInstance::CreateMenuItem( const SalItemParams* ) +std::unique_ptr<SalMenuItem> SalInstance::CreateMenuItem( const SalItemParams & ) { return nullptr; } -void SalInstance::DestroyMenuItem( SalMenuItem* pItem ) -{ - OSL_ENSURE( pItem == nullptr, "DestroyMenu called with non-native menus" ); -} - bool SalInstance::CallEventCallback( void const * pEvent, int nBytes ) { return m_pEventInst.is() && m_pEventInst->dispatchEvent( pEvent, nBytes ); diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index a0cdd3b7f3de..ce19d83b85de 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -431,7 +431,7 @@ MenuItemData* Menu::NbcInsertItem(sal_uInt16 nId, MenuItemBits nBits, // update native menu if (ImplGetSalMenu() && pData->pSalMenuItem) - ImplGetSalMenu()->InsertItem(pData->pSalMenuItem, nPos); + ImplGetSalMenu()->InsertItem(pData->pSalMenuItem.get(), nPos); return pData; } @@ -514,7 +514,7 @@ void Menu::InsertSeparator(const OString &rIdent, sal_uInt16 nPos) size_t itemPos = ( nPos != MENU_APPEND ) ? nPos : pItemList->size() - 1; MenuItemData *pData = pItemList->GetDataFromPos( itemPos ); if( ImplGetSalMenu() && pData && pData->pSalMenuItem ) - ImplGetSalMenu()->InsertItem( pData->pSalMenuItem, nPos ); + ImplGetSalMenu()->InsertItem( pData->pSalMenuItem.get(), nPos ); mpLayoutData.reset(); @@ -763,9 +763,9 @@ void Menu::SetPopupMenu( sal_uInt16 nItemId, PopupMenu* pMenu ) if( ImplGetSalMenu() && pData->pSalMenuItem ) { if( pMenu ) - ImplGetSalMenu()->SetSubMenu( pData->pSalMenuItem, pMenu->ImplGetSalMenu(), nPos ); + ImplGetSalMenu()->SetSubMenu( pData->pSalMenuItem.get(), pMenu->ImplGetSalMenu(), nPos ); else - ImplGetSalMenu()->SetSubMenu( pData->pSalMenuItem, nullptr, nPos ); + ImplGetSalMenu()->SetSubMenu( pData->pSalMenuItem.get(), nullptr, nPos ); } oldSubMenu.disposeAndClear(); @@ -798,7 +798,7 @@ void Menu::SetAccelKey( sal_uInt16 nItemId, const KeyCode& rKeyCode ) // update native menu if( ImplGetSalMenu() && pData->pSalMenuItem ) - ImplGetSalMenu()->SetAccelerator( nPos, pData->pSalMenuItem, rKeyCode, rKeyCode.GetName() ); + ImplGetSalMenu()->SetAccelerator( nPos, pData->pSalMenuItem.get(), rKeyCode, rKeyCode.GetName() ); } KeyCode Menu::GetAccelKey( sal_uInt16 nItemId ) const @@ -998,7 +998,7 @@ void Menu::SetItemText( sal_uInt16 nItemId, const OUString& rStr ) ImplSetMenuItemData( pData ); // update native menu if( ImplGetSalMenu() && pData->pSalMenuItem ) - ImplGetSalMenu()->SetItemText( nPos, pData->pSalMenuItem, rStr ); + ImplGetSalMenu()->SetItemText( nPos, pData->pSalMenuItem.get(), rStr ); vcl::Window* pWin = ImplGetWindow(); mpLayoutData.reset(); @@ -1037,7 +1037,7 @@ void Menu::SetItemImage( sal_uInt16 nItemId, const Image& rImage ) // update native menu if( ImplGetSalMenu() && pData->pSalMenuItem ) - ImplGetSalMenu()->SetItemImage( nPos, pData->pSalMenuItem, rImage ); + ImplGetSalMenu()->SetItemImage( nPos, pData->pSalMenuItem.get(), rImage ); } Image Menu::GetItemImage( sal_uInt16 nItemId ) const diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx index ea4cb3bae3ca..62c357173adc 100644 --- a/vcl/source/window/menufloatingwindow.cxx +++ b/vcl/source/window/menufloatingwindow.cxx @@ -21,6 +21,7 @@ #include "menuitemlist.hxx" #include "menubarwindow.hxx" +#include <salmenu.hxx> #include <svdata.hxx> #include <vcl/decoview.hxx> #include <vcl/settings.hxx> diff --git a/vcl/source/window/menuitemlist.cxx b/vcl/source/window/menuitemlist.cxx index f9306c864249..7778a8004b53 100644 --- a/vcl/source/window/menuitemlist.cxx +++ b/vcl/source/window/menuitemlist.cxx @@ -34,8 +34,7 @@ MenuItemData::~MenuItemData() { if (aUserValueReleaseFunc) aUserValueReleaseFunc(nUserValue); - if( pSalMenuItem ) - ImplGetSVData()->mpDefInst->DestroyMenuItem( pSalMenuItem ); + pSalMenuItem.reset(); pSubMenu.disposeAndClear(); } @@ -73,7 +72,7 @@ MenuItemData* MenuItemList::Insert( aSalMIData.aText = rStr; // Native-support: returns NULL if not supported - pData->pSalMenuItem = ImplGetSVData()->mpDefInst->CreateMenuItem( &aSalMIData ); + pData->pSalMenuItem = ImplGetSVData()->mpDefInst->CreateMenuItem( aSalMIData ); if( nPos < maItemList.size() ) { maItemList.insert( maItemList.begin() + nPos, std::unique_ptr<MenuItemData>(pData) ); @@ -106,7 +105,7 @@ void MenuItemList::InsertSeparator(const OString &rIdent, size_t nPos) aSalMIData.aImage = Image(); // Native-support: returns NULL if not supported - pData->pSalMenuItem = ImplGetSVData()->mpDefInst->CreateMenuItem( &aSalMIData ); + pData->pSalMenuItem = ImplGetSVData()->mpDefInst->CreateMenuItem( aSalMIData ); if( nPos < maItemList.size() ) { maItemList.insert( maItemList.begin() + nPos, std::unique_ptr<MenuItemData>(pData) ); diff --git a/vcl/source/window/menuitemlist.hxx b/vcl/source/window/menuitemlist.hxx index 300908eee447..c25eae263dac 100644 --- a/vcl/source/window/menuitemlist.hxx +++ b/vcl/source/window/menuitemlist.hxx @@ -54,7 +54,7 @@ struct MenuItemData Size aSz; // only temporarily valid OUString aAccessibleName; // accessible name - SalMenuItem* pSalMenuItem; // access to native menu + std::unique_ptr<SalMenuItem> pSalMenuItem; // access to native menu MenuItemData() : nId(0) @@ -68,7 +68,6 @@ struct MenuItemData , bVisible(false) , bIsTemporary(false) , bHiddenOnGUI(false) - , pSalMenuItem(nullptr) { } MenuItemData( const OUString& rStr ) @@ -85,7 +84,6 @@ struct MenuItemData , bVisible(false) , bIsTemporary(false) , bHiddenOnGUI(false) - , pSalMenuItem(nullptr) { } ~MenuItemData(); diff --git a/vcl/source/window/menuwindow.cxx b/vcl/source/window/menuwindow.cxx index 4577f38abdc1..2244a84ddeb0 100644 --- a/vcl/source/window/menuwindow.cxx +++ b/vcl/source/window/menuwindow.cxx @@ -20,6 +20,7 @@ #include "menuwindow.hxx" #include "menuitemlist.hxx" +#include <salmenu.hxx> #include <vcl/help.hxx> #include <vcl/menu.hxx> #include <vcl/settings.hxx> diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx index 926ef9b3f9d0..e61acedf3cd9 100644 --- a/vcl/unx/gtk/gtkinst.cxx +++ b/vcl/unx/gtk/gtkinst.cxx @@ -371,24 +371,17 @@ void GtkInstance::DestroyMenu( SalMenu* pMenu ) delete pMenu; } -SalMenuItem* GtkInstance::CreateMenuItem( const SalItemParams* pItemData ) +std::unique_ptr<SalMenuItem> GtkInstance::CreateMenuItem( const SalItemParams & rItemData ) { EnsureInit(); - return new GtkSalMenuItem( pItemData ); -} - -void GtkInstance::DestroyMenuItem( SalMenuItem* pItem ) -{ - EnsureInit(); - delete pItem; + return std::unique_ptr<SalMenuItem>(new GtkSalMenuItem( &rItemData )); } #else // not ENABLE_GMENU_INTEGRATION SalMenu* GtkInstance::CreateMenu( bool, Menu* ) { return nullptr; } void GtkInstance::DestroyMenu( SalMenu* ) {} -SalMenuItem* GtkInstance::CreateMenuItem( const SalItemParams* ) { return nullptr; } -void GtkInstance::DestroyMenuItem( SalMenuItem* ) {} +std::unique_ptr<SalMenuItem> GtkInstance::CreateMenuItem( const SalItemParams & ) { return nullptr; } #endif diff --git a/vcl/win/window/salmenu.cxx b/vcl/win/window/salmenu.cxx index 1339f80afa3d..56c8ca2ff92d 100644 --- a/vcl/win/window/salmenu.cxx +++ b/vcl/win/window/salmenu.cxx @@ -65,16 +65,13 @@ void WinSalInstance::DestroyMenu( SalMenu* pSalMenu ) delete pSalMenu; } -SalMenuItem* WinSalInstance::CreateMenuItem( const SalItemParams* pItemData ) +std::unique_ptr<SalMenuItem> WinSalInstance::CreateMenuItem( const SalItemParams & rItemData ) { - if( !pItemData ) - return nullptr; - WinSalMenuItem *pSalMenuItem = new WinSalMenuItem(); memset( &pSalMenuItem->mInfo, 0, sizeof( MENUITEMINFOW ) ); pSalMenuItem->mInfo.cbSize = sizeof( MENUITEMINFOW ); - if( pItemData->eType == MenuItemType::SEPARATOR ) + if( rItemData.eType == MenuItemType::SEPARATOR ) { // separator pSalMenuItem->mInfo.fMask = MIIM_TYPE; @@ -83,10 +80,10 @@ SalMenuItem* WinSalInstance::CreateMenuItem( const SalItemParams* pItemData ) else { // item - pSalMenuItem->mText = pItemData->aText; - pSalMenuItem->mpMenu = pItemData->pMenu; - pSalMenuItem->maBitmap= !!pItemData->aImage ? pItemData->aImage.GetBitmapEx().GetBitmap() : Bitmap(); - pSalMenuItem->mnId = pItemData->nId; + pSalMenuItem->mText = rItemData.aText; + pSalMenuItem->mpMenu = rItemData.pMenu; + pSalMenuItem->maBitmap= !!rItemData.aImage ? rItemData.aImage.GetBitmapEx().GetBitmap() : Bitmap(); + pSalMenuItem->mnId = rItemData.nId; // 'translate' mnemonics pSalMenuItem->mText = pSalMenuItem->mText.replaceAll( "~", "&" ); @@ -96,16 +93,11 @@ SalMenuItem* WinSalInstance::CreateMenuItem( const SalItemParams* pItemData ) pSalMenuItem->mInfo.dwTypeData = o3tl::toW(const_cast<sal_Unicode *>(pSalMenuItem->mText.getStr())); pSalMenuItem->mInfo.cch = pSalMenuItem->mText.getLength(); - pSalMenuItem->mInfo.wID = pItemData->nId; + pSalMenuItem->mInfo.wID = rItemData.nId; pSalMenuItem->mInfo.dwItemData = reinterpret_cast<ULONG_PTR>(pSalMenuItem); // user data } - return pSalMenuItem; -} - -void WinSalInstance::DestroyMenuItem( SalMenuItem* pSalMenuItem ) -{ - delete pSalMenuItem; + return std::unique_ptr<SalMenuItem>(pSalMenuItem); } static void ImplDrawMenuBar( SalMenu *pMenu ) |