summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2017-05-17 22:58:30 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2017-05-18 00:30:50 +0300
commit7e6b62825032ff6610ab83c3e4f3b7085d2def0c (patch)
tree7ce14c57bcf0e5d54bf9d5c14c80ade2799286f2 /framework
parent29dd77c749f6bdae19ba1e81b0470f9009c42537 (diff)
Use WeakComponentImplHelper for MenuBarManager
Change-Id: Ia0c47186f5f266d512c02e92d7983872e207f878
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/uielement/menubarmanager.hxx18
-rw-r--r--framework/source/uielement/menubarmanager.cxx101
2 files changed, 41 insertions, 78 deletions
diff --git a/framework/inc/uielement/menubarmanager.hxx b/framework/inc/uielement/menubarmanager.hxx
index aab70b1f12be..4f3a1ac5163d 100644
--- a/framework/inc/uielement/menubarmanager.hxx
+++ b/framework/inc/uielement/menubarmanager.hxx
@@ -51,9 +51,8 @@
#include <vcl/accel.hxx>
#include <vcl/timer.hxx>
#include <toolkit/awt/vclxmenu.hxx>
-#include <cppuhelper/implbase.hxx>
-#include <cppuhelper/weakref.hxx>
-#include <cppuhelper/interfacecontainer.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/compbase.hxx>
#include <framework/addonsoptions.hxx>
namespace framework
@@ -67,11 +66,11 @@ struct PopupControllerEntry
typedef std::unordered_map< OUString, PopupControllerEntry, OUStringHash > PopupControllerCache;
class MenuBarManager:
- public cppu::WeakImplHelper<
+ protected cppu::BaseMutex,
+ public cppu::WeakComponentImplHelper<
css::frame::XStatusListener,
css::frame::XFrameActionListener,
css::ui::XUIConfigurationListener,
- css::lang::XComponent,
css::awt::XSystemDependentMenuPeer>
{
protected:
@@ -95,11 +94,6 @@ class MenuBarManager:
virtual ~MenuBarManager() override;
- // XComponent
- virtual void SAL_CALL dispose() override;
- virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
- virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
-
// XStatusListener
virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override;
@@ -145,6 +139,7 @@ class MenuBarManager:
DECL_LINK( Deactivate, Menu *, bool );
DECL_LINK( AsyncSettingsHdl, Timer *, void );
+ void SAL_CALL disposing() override;
void RemoveListener();
void RequestImages();
void RetrieveImageManagers();
@@ -191,7 +186,6 @@ class MenuBarManager:
void Init(const css::uno::Reference< css::frame::XFrame >& rFrame,Menu* pAddonMenu,bool _bHandlePopUp);
void SetHdl();
- bool m_bDisposed;
bool m_bDeleteMenu;
bool m_bActive;
bool m_bIsBookmarkMenu;
@@ -207,8 +201,6 @@ class MenuBarManager:
css::uno::Reference< css::container::XNameAccess > m_xUICommandLabels;
css::uno::Reference< css::frame::XUIControllerFactory > m_xPopupMenuControllerFactory;
::std::vector< MenuItemHandler* > m_aMenuItemHandlerVector;
- osl::Mutex m_mutex;
- ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchProvider;
css::uno::Reference< css::ui::XImageManager > m_xDocImageManager;
css::uno::Reference< css::ui::XImageManager > m_xModuleImageManager;
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index 8a187f204152..3a1b2bd4d157 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -71,10 +71,7 @@
#include <vcl/menu.hxx>
#include <vcl/settings.hxx>
#include <vcl/commandinfoprovider.hxx>
-#include <osl/mutex.hxx>
#include <osl/file.hxx>
-#include <cppuhelper/implbase.hxx>
-#include <cppuhelper/queryinterface.hxx>
#include <svtools/acceleratorexecute.hxx>
#include <svtools/miscopt.hxx>
#include <uielement/menubarmerger.hxx>
@@ -127,12 +124,11 @@ MenuBarManager::MenuBarManager(
const Reference< XDispatchProvider >& rDispatchProvider,
const OUString& rModuleIdentifier,
Menu* pMenu, bool bDelete, bool bHasMenuBar ):
- m_bDisposed( false )
+ WeakComponentImplHelper( m_aMutex )
, m_bRetrieveImages( false )
, m_bAcceleratorCfg( false )
, m_bModuleIdentified( false )
, m_bHasMenuBar( bHasMenuBar )
- , m_aListenerContainer( m_mutex )
, m_xContext(rxContext)
, m_xURLTransformer(_xURLTransformer)
, m_sIconTheme( SvtMiscOptions().GetIconTheme() )
@@ -148,12 +144,11 @@ MenuBarManager::MenuBarManager(
const Reference< XURLTransformer >& _xURLTransformer,
Menu* pAddonMenu,
bool popup):
- m_bDisposed( false )
+ WeakComponentImplHelper( m_aMutex )
, m_bRetrieveImages( true )
, m_bAcceleratorCfg( false )
, m_bModuleIdentified( false )
, m_bHasMenuBar( true )
- , m_aListenerContainer( m_mutex )
, m_xContext(rxContext)
, m_xURLTransformer(_xURLTransformer)
, m_sIconTheme( SvtMiscOptions().GetIconTheme() )
@@ -166,7 +161,7 @@ Any SAL_CALL MenuBarManager::getMenuHandle( const Sequence< sal_Int8 >& /*Proces
{
SolarMutexGuard aSolarGuard;
- if ( m_bDisposed )
+ if ( rBHelper.bDisposed || rBHelper.bInDispose )
throw css::lang::DisposedException();
Any a;
@@ -203,7 +198,7 @@ void MenuBarManager::Destroy()
{
SolarMutexGuard aGuard;
- if ( !m_bDisposed )
+ if ( !rBHelper.bDisposed )
{
// stop asynchronous settings timer and
// release defered item container reference
@@ -230,69 +225,45 @@ void MenuBarManager::Destroy()
}
// XComponent
-void SAL_CALL MenuBarManager::dispose()
+void SAL_CALL MenuBarManager::disposing()
{
Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
- EventObject aEvent( xThis );
- m_aListenerContainer.disposeAndClear( aEvent );
+ SolarMutexGuard g;
+ Destroy();
+ if ( m_xDocImageManager.is() )
{
- SolarMutexGuard g;
- Destroy();
- m_bDisposed = true;
-
- if ( m_xDocImageManager.is() )
+ try
{
- try
- {
- m_xDocImageManager->removeConfigurationListener(
- Reference< XUIConfigurationListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
- }
- catch ( const Exception& )
- {
- }
+ m_xDocImageManager->removeConfigurationListener(
+ Reference< XUIConfigurationListener >(
+ static_cast< OWeakObject* >( this ), UNO_QUERY ));
}
- if ( m_xModuleImageManager.is() )
+ catch ( const Exception& )
{
- try
- {
- m_xModuleImageManager->removeConfigurationListener(
- Reference< XUIConfigurationListener >(
- static_cast< OWeakObject* >( this ), UNO_QUERY ));
- }
- catch ( const Exception& )
- {
- }
}
- m_xDocImageManager.clear();
- m_xModuleImageManager.clear();
- m_xGlobalAcceleratorManager.clear();
- m_xModuleAcceleratorManager.clear();
- m_xDocAcceleratorManager.clear();
- m_xUICommandLabels.clear();
- m_xPopupMenuControllerFactory.clear();
- m_xContext.clear();
}
-}
-
-void SAL_CALL MenuBarManager::addEventListener( const Reference< XEventListener >& xListener )
-{
- SolarMutexGuard g;
-
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
- if ( m_bDisposed )
- throw DisposedException();
-
- m_aListenerContainer.addInterface( cppu::UnoType<XEventListener>::get(), xListener );
-}
-
-void SAL_CALL MenuBarManager::removeEventListener( const Reference< XEventListener >& xListener )
-{
- SolarMutexGuard g;
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
- m_aListenerContainer.removeInterface( cppu::UnoType<XEventListener>::get(), xListener );
+ if ( m_xModuleImageManager.is() )
+ {
+ try
+ {
+ m_xModuleImageManager->removeConfigurationListener(
+ Reference< XUIConfigurationListener >(
+ static_cast< OWeakObject* >( this ), UNO_QUERY ));
+ }
+ catch ( const Exception& )
+ {
+ }
+ }
+ m_xDocImageManager.clear();
+ m_xModuleImageManager.clear();
+ m_xGlobalAcceleratorManager.clear();
+ m_xModuleAcceleratorManager.clear();
+ m_xDocAcceleratorManager.clear();
+ m_xUICommandLabels.clear();
+ m_xPopupMenuControllerFactory.clear();
+ m_xContext.clear();
}
void SAL_CALL MenuBarManager::elementInserted( const css::ui::ConfigurationEvent& Event )
@@ -300,7 +271,7 @@ void SAL_CALL MenuBarManager::elementInserted( const css::ui::ConfigurationEvent
SolarMutexGuard g;
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- if ( m_bDisposed )
+ if ( rBHelper.bDisposed || rBHelper.bInDispose )
return;
sal_Int16 nImageType = sal_Int16();
@@ -325,7 +296,7 @@ void SAL_CALL MenuBarManager::frameAction( const FrameActionEvent& Action )
{
SolarMutexGuard g;
- if ( m_bDisposed )
+ if ( rBHelper.bDisposed || rBHelper.bInDispose )
throw css::lang::DisposedException();
if ( Action.Action == FrameAction_CONTEXT_CHANGED )
@@ -356,7 +327,7 @@ void SAL_CALL MenuBarManager::statusChanged( const FeatureStateEvent& Event )
SolarMutexGuard aSolarGuard;
{
- if ( m_bDisposed )
+ if ( rBHelper.bDisposed || rBHelper.bInDispose )
return;
// We have to check all menu entries as there can be identical entries in a popup menu.