diff options
author | Carsten Driesner <cd@openoffice.org> | 2009-11-25 14:05:01 +0000 |
---|---|---|
committer | Carsten Driesner <cd@openoffice.org> | 2009-11-25 14:05:01 +0000 |
commit | f565a4b3d9b47ca3336df4f8d8d56d4e2dcceec5 (patch) | |
tree | d774b9392f6da0954920458a4b736c8bdc67e1cc /framework | |
parent | 875ac20478f16e5107acb222c0b851b99d2e0f27 (diff) |
#i107087# TabWindowService must set member pointer to zero on VCLEVENT_OBJECT_DYING. The window life time is controlled by the docking window! Adding missing RemoveEventListener call.
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/classes/fwktabwindow.hxx | 1 | ||||
-rw-r--r-- | framework/inc/services/tabwindowservice.hxx | 91 | ||||
-rw-r--r-- | framework/source/classes/fwktabwindow.cxx | 6 | ||||
-rw-r--r-- | framework/source/services/tabwindowservice.cxx | 27 |
4 files changed, 71 insertions, 54 deletions
diff --git a/framework/inc/classes/fwktabwindow.hxx b/framework/inc/classes/fwktabwindow.hxx index 80e4b8144bb0..ecd9acecd7b9 100644 --- a/framework/inc/classes/fwktabwindow.hxx +++ b/framework/inc/classes/fwktabwindow.hxx @@ -125,6 +125,7 @@ public: ~FwkTabWindow(); void AddEventListener( const Link& rEventListener ); + void RemoveEventListener( const Link& rEventListener ); FwkTabPage* AddTabPage( sal_Int32 nIndex, const css::uno::Sequence< css::beans::NamedValue >& rProperties ); void ActivatePage( sal_Int32 nIndex ); void RemovePage( sal_Int32 nIndex ); diff --git a/framework/inc/services/tabwindowservice.hxx b/framework/inc/services/tabwindowservice.hxx index 8423a01f1793..f6b930906ca3 100644 --- a/framework/inc/services/tabwindowservice.hxx +++ b/framework/inc/services/tabwindowservice.hxx @@ -48,13 +48,13 @@ #include <macros/xinterface.hxx> #include <macros/xtypeprovider.hxx> #include <macros/xserviceinfo.hxx> -#include <general.h>
+#include <general.h> #include <stdtypes.h> -
+ //_________________________________________________________________________________________________________________ // interface includes //_________________________________________________________________________________________________________________ -
+ #include <com/sun/star/awt/XSimpleTabController.hpp> #include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -62,7 +62,7 @@ //_________________________________________________________________________________________________________________ // other includes //_________________________________________________________________________________________________________________ -
+ #include <cppuhelper/weak.hxx> #include <vcl/window.hxx> @@ -81,31 +81,31 @@ namespace framework{ //_________________________________________________________________________________________________________________ struct TTabPageInfo -{
- public:
- - TTabPageInfo()
- : m_nIndex ( -1 )
- , m_bCreated (sal_False)
- , m_pPage ( NULL )
- , m_lProperties ( )
- {}
-
- TTabPageInfo(::sal_Int32 nID)
- : m_nIndex ( nID )
- , m_bCreated (sal_False)
- , m_pPage ( NULL )
- , m_lProperties ( )
- {}
-
- public:
- - ::sal_Int32 m_nIndex;
+{ + public: + + TTabPageInfo() + : m_nIndex ( -1 ) + , m_bCreated (sal_False) + , m_pPage ( NULL ) + , m_lProperties ( ) + {} + + TTabPageInfo(::sal_Int32 nID) + : m_nIndex ( nID ) + , m_bCreated (sal_False) + , m_pPage ( NULL ) + , m_lProperties ( ) + {} + + public: + + ::sal_Int32 m_nIndex; ::sal_Bool m_bCreated; FwkTabPage* m_pPage; css::uno::Sequence< css::beans::NamedValue > m_lProperties; -};
-
+}; + typedef ::std::hash_map< ::sal_Int32 , TTabPageInfo , Int32HashCode , @@ -118,10 +118,11 @@ typedef ::std::hash_map< ::sal_Int32 , class TabWindowService : public css::lang::XTypeProvider , public css::lang::XServiceInfo , public css::awt::XSimpleTabController + , public css::lang::XComponent , public ThreadHelpBase , public TransactionBase - , public PropertySetHelper
- , public ::cppu::OWeakObject
+ , public PropertySetHelper + , public ::cppu::OWeakObject { //------------------------------------------------------------------------------------------------------------- // public methods @@ -132,7 +133,7 @@ class TabWindowService : public css::lang::XTypeProvider //--------------------------------------------------------------------------------------------------------- // constructor / destructor //--------------------------------------------------------------------------------------------------------- -
+ TabWindowService( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); virtual ~TabWindowService(); @@ -186,8 +187,8 @@ class TabWindowService : public css::lang::XTypeProvider DECL_DLLPRIVATE_LINK( EventListener, VclSimpleEvent * ); - void impl_checkTabIndex (::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException);
- TTabPageInfoHash::iterator impl_getTabPageInfo(::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException);
+ void impl_checkTabIndex (::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException); + TTabPageInfoHash::iterator impl_getTabPageInfo(::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException); FwkTabWindow* mem_TabWin (); /* ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); @@ -203,26 +204,26 @@ class TabWindowService : public css::lang::XTypeProvider private: /// reference to factory, which has created this instance - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
-
+ css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + /// the tab window as XWindow ( to hold window* alive !) - css::uno::Reference< css::awt::XWindow > m_xTabWin;
-
- /// the VCL tab window
- FwkTabWindow* m_pTabWin;
-
- /// container of inserted tab pages
- TTabPageInfoHash m_lTabPageInfos;
-
+ css::uno::Reference< css::awt::XWindow > m_xTabWin; + + /// the VCL tab window + FwkTabWindow* m_pTabWin; + + /// container of inserted tab pages + TTabPageInfoHash m_lTabPageInfos; + /// container of the added TabListener ::cppu::OMultiTypeInterfaceContainerHelper m_lListener; -
+ /// counter of the tabpage indexes - ::sal_Int32 m_nPageIndexCounter;
-
+ ::sal_Int32 m_nPageIndexCounter; + /// index of the current active page ::sal_Int32 m_nCurrentPageIndex; -
+ /// title of the tabcontrolled window ::rtl::OUString m_sTitle; diff --git a/framework/source/classes/fwktabwindow.cxx b/framework/source/classes/fwktabwindow.cxx index d737a2d77308..c841e6fb0b8d 100644 --- a/framework/source/classes/fwktabwindow.cxx +++ b/framework/source/classes/fwktabwindow.cxx @@ -65,7 +65,6 @@ namespace framework { // class FwkTabControl --------------------------------------------------- - FwkTabControl::FwkTabControl( Window* pParent, const ResId& rResId ) : TabControl( pParent, rResId ) @@ -336,6 +335,11 @@ void FwkTabWindow::AddEventListener( const Link& rEventListener ) m_aTabCtrl.AddEventListener( rEventListener ); } +void FwkTabWindow::RemoveEventListener( const Link& rEventListener ) +{ + m_aTabCtrl.RemoveEventListener( rEventListener ); +} + // ----------------------------------------------------------------------- FwkTabPage* FwkTabWindow::AddTabPage( sal_Int32 nIndex, const uno::Sequence< beans::NamedValue >& rProperties ) diff --git a/framework/source/services/tabwindowservice.cxx b/framework/source/services/tabwindowservice.cxx index fb3c08876687..af026ee2afb0 100644 --- a/framework/source/services/tabwindowservice.cxx +++ b/framework/source/services/tabwindowservice.cxx @@ -75,18 +75,20 @@ namespace framework{ // css::uno::XInterface, XTypeProvider, XServiceInfo //***************************************************************************************************************** -DEFINE_XINTERFACE_5 ( TabWindowService , +DEFINE_XINTERFACE_6 ( TabWindowService , OWeakObject , DIRECT_INTERFACE(css::lang::XTypeProvider ), DIRECT_INTERFACE(css::lang::XServiceInfo ), + DIRECT_INTERFACE(css::lang::XComponent), DIRECT_INTERFACE(css::awt::XSimpleTabController), DIRECT_INTERFACE(css::beans::XPropertySet ), DIRECT_INTERFACE(css::beans::XPropertySetInfo ) ) -DEFINE_XTYPEPROVIDER_5 ( TabWindowService , +DEFINE_XTYPEPROVIDER_6 ( TabWindowService , css::lang::XTypeProvider , css::lang::XServiceInfo , + css::lang::XComponent , css::awt::XSimpleTabController , css::beans::XPropertySet , css::beans::XPropertySetInfo @@ -100,7 +102,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( TabWindowService , DEFINE_INIT_SERVICE ( TabWindowService, { - impl_initializePropInfo();
+ impl_initializePropInfo(); m_aTransactionManager.setWorkingMode( E_WORK ); } ) @@ -141,7 +143,7 @@ TabWindowService::TabWindowService( const css::uno::Reference< css::lang::XMulti // destructor //***************************************************************************************************************** TabWindowService::~TabWindowService() -{
+{ } //***************************************************************************************************************** @@ -286,8 +288,11 @@ void SAL_CALL TabWindowService::dispose() m_lListener.disposeAndClear (aEvent); + if (m_pTabWin) + m_pTabWin->RemoveEventListener( LINK( this, TabWindowService, EventListener ) ); + m_pTabWin = NULL; - m_xTabWin.clear (); + m_xTabWin.clear(); } //***************************************************************************************************************** @@ -357,6 +362,7 @@ css::uno::Any SAL_CALL TabWindowService::impl_getPropertyValue(const ::rtl::OUSt //***************************************************************************************************************** IMPL_LINK( TabWindowService, EventListener, VclSimpleEvent*, pEvent ) { + if ( !pEvent && !pEvent->ISA(VclWindowEvent)) return 0; @@ -369,6 +375,11 @@ IMPL_LINK( TabWindowService, EventListener, VclSimpleEvent*, pEvent ) if (nEventId == VCLEVENT_OBJECT_DYING) { m_lListener.disposeAndClear (aEvent); + + m_pTabWin->RemoveEventListener( LINK( this, TabWindowService, EventListener ) ); + m_pTabWin = NULL; + m_xTabWin.clear(); + return 0; } @@ -454,9 +465,9 @@ FwkTabWindow* TabWindowService::mem_TabWin () FwkTabWindow* pWin = NULL; if ( ! m_xTabWin.is ()) - {
- Window* pFakeParent = dynamic_cast< Window* >(Application::GetDefaultDevice ());
-
+ { + Window* pFakeParent = dynamic_cast< Window* >(Application::GetDefaultDevice ()); + m_pTabWin = new FwkTabWindow (pFakeParent); m_xTabWin = VCLUnoHelper::GetInterface (m_pTabWin); |