diff options
author | Christian Lippka <cl@openoffice.org> | 2001-03-29 11:37:04 +0000 |
---|---|---|
committer | Christian Lippka <cl@openoffice.org> | 2001-03-29 11:37:04 +0000 |
commit | 34707538cd0552d08aa428f07872c96e72e415d1 (patch) | |
tree | 7a91873230a6c7862a898f0f9ccb7736afddbb63 /svx/source | |
parent | 2815ea8b1eab8f443d7b5efa72e5c298695c4041 (diff) |
#85194# added listener for table components so they dispose when model is destroyed
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/unodraw/UnoNameItemTable.cxx | 23 | ||||
-rw-r--r-- | svx/source/unodraw/UnoNameItemTable.hxx | 15 | ||||
-rw-r--r-- | svx/source/unodraw/unomtabl.cxx | 36 |
3 files changed, 66 insertions, 8 deletions
diff --git a/svx/source/unodraw/UnoNameItemTable.cxx b/svx/source/unodraw/UnoNameItemTable.cxx index 5401bfd2035e..e45c4d4dbc46 100644 --- a/svx/source/unodraw/UnoNameItemTable.cxx +++ b/svx/source/unodraw/UnoNameItemTable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: UnoNameItemTable.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: cl $ $Date: 2001-03-06 18:19:37 $ + * last change: $Author: cl $ $Date: 2001-03-29 12:37:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,10 +89,19 @@ SvxUnoNameItemTable::SvxUnoNameItemTable( SdrModel* pModel, USHORT nWhich, BYTE mpStylePool( ( pModel && pModel->GetStyleSheetPool()) ? &pModel->GetStyleSheetPool()->GetPool() : NULL ), mnWhich( nWhich ), mnMemberId( nMemberId ) { + if( pModel ) + StartListening( *pModel ); } SvxUnoNameItemTable::~SvxUnoNameItemTable() throw() { + if( mpModel ) + EndListening( *mpModel ); + dispose(); +} + +void SvxUnoNameItemTable::dispose() +{ ItemPoolVector::iterator aIter = maItemSetVector.begin(); const ItemPoolVector::iterator aEnd = maItemSetVector.end(); @@ -101,6 +110,16 @@ SvxUnoNameItemTable::~SvxUnoNameItemTable() throw() delete (*aIter).first; delete (*aIter++).second; } + + maItemSetVector.clear(); +} + +void SvxUnoNameItemTable::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw() +{ + const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); + + if( pSdrHint && HINT_MODELCLEARED == pSdrHint->GetKind() ) + dispose(); } sal_Bool SAL_CALL SvxUnoNameItemTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) diff --git a/svx/source/unodraw/UnoNameItemTable.hxx b/svx/source/unodraw/UnoNameItemTable.hxx index ceb615953c54..6f76e7fcd3ab 100644 --- a/svx/source/unodraw/UnoNameItemTable.hxx +++ b/svx/source/unodraw/UnoNameItemTable.hxx @@ -2,9 +2,9 @@ * * $RCSfile: UnoNameItemTable.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: armin $ $Date: 2001-03-08 09:46:26 $ + * last change: $Author: cl $ $Date: 2001-03-29 12:37:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,6 +75,10 @@ #include <vector> #endif +#ifndef _SFXLSTNER_HXX +#include <svtools/lstner.hxx> +#endif + #ifndef _SVX_XIT_HXX #include "xit.hxx" #endif @@ -86,7 +90,8 @@ class SfxItemPool; class SfxItemSet; typedef std::vector< std::pair< SfxItemSet*, SfxItemSet*> > ItemPoolVector; -class SvxUnoNameItemTable : public cppu::WeakImplHelper2< com::sun::star::container::XNameContainer, com::sun::star::lang::XServiceInfo > +class SvxUnoNameItemTable : public cppu::WeakImplHelper2< com::sun::star::container::XNameContainer, com::sun::star::lang::XServiceInfo >, + public SfxListener { private: SdrModel* mpModel; @@ -102,6 +107,10 @@ public: virtual ~SvxUnoNameItemTable() throw(); virtual NameOrIndex* createItem() const throw() = 0; + void dispose(); + + // SfxListener + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw (); // XServiceInfo virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) throw( com::sun::star::uno::RuntimeException); diff --git a/svx/source/unodraw/unomtabl.cxx b/svx/source/unodraw/unomtabl.cxx index 522cdb8aca0f..eb85693cfb4e 100644 --- a/svx/source/unodraw/unomtabl.cxx +++ b/svx/source/unodraw/unomtabl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unomtabl.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: cl $ $Date: 2001-02-23 21:33:15 $ + * last change: $Author: cl $ $Date: 2001-03-29 12:37:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -83,6 +83,10 @@ #include <svtools/itemset.hxx> #endif +#ifndef _SFXLSTNER_HXX +#include <svtools/lstner.hxx> +#endif + #ifndef _SVX_XLNEDIT_HXX //autogen #include <xlnedit.hxx> #endif @@ -105,7 +109,8 @@ using namespace ::cppu; typedef std::vector< std::pair< SfxItemSet*, SfxItemSet*> > ItemPoolVector; -class SvxUnoMarkerTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo > +class SvxUnoMarkerTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo >, + public SfxListener { private: SdrModel* mpModel; @@ -118,6 +123,11 @@ public: SvxUnoMarkerTable( SdrModel* pModel ) throw(); virtual ~SvxUnoMarkerTable() throw(); + void dispose(); + + // SfxListener + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw (); + // XServiceInfo virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException); @@ -145,10 +155,19 @@ SvxUnoMarkerTable::SvxUnoMarkerTable( SdrModel* pModel ) throw() mpStylePool( ( pModel && pModel->GetStyleSheetPool() ) ? &pModel->GetStyleSheetPool()->GetPool() : NULL ), mpModelPool( pModel ? &pModel->GetItemPool() : (SfxItemPool*)NULL ) { + if( pModel ) + StartListening( *pModel ); } SvxUnoMarkerTable::~SvxUnoMarkerTable() throw() { + if( mpModel ) + EndListening( *mpModel ); + dispose(); +} + +void SvxUnoMarkerTable::dispose() +{ ItemPoolVector::iterator aIter = maItemSetVector.begin(); const ItemPoolVector::iterator aEnd = maItemSetVector.end(); @@ -157,6 +176,17 @@ SvxUnoMarkerTable::~SvxUnoMarkerTable() throw() delete (*aIter).first; delete (*aIter++).second; } + + maItemSetVector.clear(); +} + +// SfxListener +void SvxUnoMarkerTable::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw() +{ + const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); + + if( pSdrHint && HINT_MODELCLEARED == pSdrHint->GetKind() ) + dispose(); } sal_Bool SAL_CALL SvxUnoMarkerTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) |