summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lange <tl@openoffice.org>2000-11-02 12:35:27 +0000
committerThomas Lange <tl@openoffice.org>2000-11-02 12:35:27 +0000
commit19712b019a0e2cd11ff1397fc5e1d3847915a8e3 (patch)
tree76baf6acb215650eee070caca820cde8f0e070b9
parent1428d662dc8207b1e3b242b7c08be21ab3317e37 (diff)
XTerminateListener now used to release references on application exit
-rw-r--r--sw/inc/dlelstnr.hxx53
-rw-r--r--sw/source/ui/uno/dlelstnr.cxx66
2 files changed, 93 insertions, 26 deletions
diff --git a/sw/inc/dlelstnr.hxx b/sw/inc/dlelstnr.hxx
index e3679f0b533b..a9724d255a1e 100644
--- a/sw/inc/dlelstnr.hxx
+++ b/sw/inc/dlelstnr.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dlelstnr.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tl $ $Date: 2000-10-27 11:43:40 $
+ * last change: $Author: tl $ $Date: 2000-11-02 13:35:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,16 +64,30 @@
#include <cppuhelper/weak.hxx>
-#ifndef _COM_SUN_STAR_LINGUISTIC_XDICTIONARYLIST_HPP_
-#include <com/sun/star/linguistic2/XDictionaryList.hpp>
-#endif
#ifndef _COM_SUN_STAR_LINGUISTIC2_XDICTIONARYLISTEVENTLISTENER_HPP_
#include <com/sun/star/linguistic2/XDictionaryListEventListener.hpp>
#endif
-#ifndef _CPPUHELPER_IMPLBASE1_HXX_
-#include <cppuhelper/implbase1.hxx> // helper for implementations
+#ifndef _COM_SUN_STAR_FRAME_XTERMINATELISTENER_HPP_
+#include <com/sun/star/frame/XTerminateListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_
+#include <com/sun/star/frame/XDesktop.hpp>
#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx> // helper for implementations
+#endif
+
+
+namespace com { namespace sun { namespace star {
+ namespace linguistic2 {
+ class XDictionaryList;
+ }
+ namespace frame {
+ class XTerminateListener;
+ }
+} } }
+
///////////////////////////////////////////////////////////////////////////
// SwDicListEvtListener
// is a XDictionaryListEventListener that triggers spellchecking
@@ -81,12 +95,15 @@
// dictionaries of the dictionary list were made.
//
-class SwDicListEvtListener : public cppu::WeakImplHelper1
-<
- ::com::sun::star::linguistic2::XDictionaryListEventListener
->
+class SwDicListEvtListener :
+ public cppu::WeakImplHelper2
+ <
+ ::com::sun::star::linguistic2::XDictionaryListEventListener,
+ ::com::sun::star::frame::XTerminateListener
+ >
{
-private:
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XDesktop > xDesktop;
::com::sun::star::uno::Reference<
::com::sun::star::linguistic2::XDictionaryList > xDicList;
@@ -102,13 +119,21 @@ public:
// XEventListener
virtual void SAL_CALL disposing(
- const ::com::sun::star::lang::EventObject& rSource )
+ const ::com::sun::star::lang::EventObject& rEventObj )
throw(::com::sun::star::uno::RuntimeException);
// XDictionaryListEventListener
virtual void SAL_CALL processDictionaryListEvent(
- const ::com::sun::star::linguistic2::DictionaryListEvent& aDicListEvent)
+ const ::com::sun::star::linguistic2::DictionaryListEvent& rDicListEvent)
throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination(
+ const ::com::sun::star::lang::EventObject& rEventObj )
+ throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL notifyTermination(
+ const ::com::sun::star::lang::EventObject& rEventObj )
+ throw(::com::sun::star::uno::RuntimeException);
};
diff --git a/sw/source/ui/uno/dlelstnr.cxx b/sw/source/ui/uno/dlelstnr.cxx
index 5b779434e5ed..5c3ed8737710 100644
--- a/sw/source/ui/uno/dlelstnr.cxx
+++ b/sw/source/ui/uno/dlelstnr.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dlelstnr.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tl $ $Date: 2000-10-27 12:30:35 $
+ * last change: $Author: tl $ $Date: 2000-11-02 13:35:27 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -69,6 +69,15 @@
#ifndef _COM_SUN_STAR_LINGUISTIC2_DICTIONARYLISTEVENTFLAGS_HPP_
#include <com/sun/star/linguistic2/DictionaryListEventFlags.hpp>
#endif
+#ifndef _COM_SUN_STAR_LINGUISTIC_XDICTIONARYLIST_HPP_
+#include <com/sun/star/linguistic2/XDictionaryList.hpp>
+#endif
+
+#include <com/sun/star/uno/Reference.h>
+
+#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_
+#include <unotools/processfactory.hxx>
+#endif
#ifndef _VOS_MUTEX_HXX_
#include <vos/mutex.hxx>
@@ -87,8 +96,10 @@
#include <swmodule.hxx>
#endif
+using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::linguistic2;
@@ -103,18 +114,23 @@ SwDicListEvtListener::SwDicListEvtListener(
{
xDicList->addDictionaryListEventListener( this, sal_False );
}
+
+ Reference< XMultiServiceFactory > xMgr( utl::getProcessServiceFactory() );
+ if (xMgr.is())
+ {
+ OUString aSvcName( OUString::createFromAscii(
+ "com.sun.star.frame.Desktop" ) );
+ xDesktop = Reference< frame::XDesktop >(
+ xMgr->createInstance( aSvcName ), UNO_QUERY );
+ if (xDesktop.is())
+ xDesktop->addTerminateListener( this );
+ }
}
/* -----------------------------17.03.00 09:07--------------------------------
---------------------------------------------------------------------------*/
SwDicListEvtListener::~SwDicListEvtListener()
{
- ::vos::OGuard aGuard(Application::GetSolarMutex());
-
- if (xDicList.is())
- {
- xDicList->removeDictionaryListEventListener( this );
- }
}
/* -----------------------------17.03.00 09:06--------------------------------
@@ -122,12 +138,12 @@ SwDicListEvtListener::~SwDicListEvtListener()
---------------------------------------------------------------------------*/
void SwDicListEvtListener::processDictionaryListEvent(
- const DictionaryListEvent& aDicListEvent)
+ const DictionaryListEvent& rDicListEvent)
throw( RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- sal_Int16 nEvt = aDicListEvent.nCondensedEvent;
+ sal_Int16 nEvt = rDicListEvent.nCondensedEvent;
sal_Bool bIsSpellWrong = ( nEvt & DictionaryListEventFlags::ADD_POS_ENTRY )
|| ( nEvt & DictionaryListEventFlags::DEL_NEG_ENTRY )
@@ -142,14 +158,40 @@ void SwDicListEvtListener::processDictionaryListEvent(
void SAL_CALL SwDicListEvtListener::disposing(
- const EventObject& rSource )
+ const EventObject& rEventObj )
throw(RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- if (xDicList.is() && rSource.Source == xDicList)
+ if (xDicList.is() && rEventObj.Source == xDicList)
{
xDicList = 0;
}
}
+
+void SAL_CALL SwDicListEvtListener::queryTermination(
+ const EventObject& rEventObj )
+ throw(TerminationVetoException, RuntimeException)
+{
+ //vos::OGuard aGuard(Application::GetSolarMutex());
+}
+
+
+void SAL_CALL SwDicListEvtListener::notifyTermination(
+ const EventObject& rEventObj )
+ throw(RuntimeException)
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+
+ if (xDesktop.is() && rEventObj.Source == xDesktop)
+ {
+ if (xDicList.is())
+ {
+ xDicList->removeDictionaryListEventListener( this );
+ xDicList = NULL;
+ }
+ xDesktop = NULL;
+ }
+}
+