diff options
-rw-r--r-- | sw/source/ui/inc/unodispatch.hxx | 41 | ||||
-rw-r--r-- | sw/source/ui/uiview/view.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/uno/unodispatch.cxx | 131 | ||||
-rw-r--r-- | sw/source/ui/uno/unotxvw.cxx | 19 |
4 files changed, 141 insertions, 55 deletions
diff --git a/sw/source/ui/inc/unodispatch.hxx b/sw/source/ui/inc/unodispatch.hxx index 768155f79bd9..91499b0e9527 100644 --- a/sw/source/ui/inc/unodispatch.hxx +++ b/sw/source/ui/inc/unodispatch.hxx @@ -2,9 +2,9 @@ * * $RCSfile: unodispatch.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: os $ $Date: 2000-11-07 14:41:19 $ + * last change: $Author: os $ $Date: 2001-03-07 13:42:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,15 +67,16 @@ #ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDERINTERCEPTOR_HPP_ #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> #endif +#ifndef _COM_SUN_STAR_VIEW_XSELECTIONCHANGELISTENER_HPP_ +#include <com/sun/star/view/XSelectionChangeListener.hpp> +#endif #ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_ #include <com/sun/star/frame/XDispatch.hpp> #endif #ifndef _CPPUHELPER_IMPLBASE2_HXX_ #include <cppuhelper/implbase2.hxx> #endif -#ifndef _CPPUHELPER_IMPLBASE1_HXX_ -#include <cppuhelper/implbase1.hxx> -#endif +#include <list> class SwView; //--------------------------------------------------------------------------------------------------------------------- @@ -92,9 +93,7 @@ class SwXDispatchProviderInterceptor : public cppu::WeakImplHelper2 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xSlaveDispatcher; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xMasterDispatcher; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> m_xFormLetterDispatch; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> m_xInsertContentDispatch; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> m_xInsertColumnsDispatch; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> m_xDispatch; SwView& m_rView; @@ -116,21 +115,35 @@ public: virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); }; //--------------------------------------------------------------------------------------------------------------------- -class SwXDispatch : public cppu::WeakImplHelper1 +struct StatusStruct_Impl +{ + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener> xListener; + ::com::sun::star::util::URL aURL; +}; +typedef std::list< StatusStruct_Impl > StatusListenerList; +class SwXDispatch : public cppu::WeakImplHelper2 < - ::com::sun::star::frame::XDispatch + ::com::sun::star::frame::XDispatch, + ::com::sun::star::view::XSelectionChangeListener > { - SwView& m_rView; - sal_uInt16 m_nSlot; - + SwView& m_rView; + StatusListenerList m_aListenerList; + sal_Bool m_bOldEnable; + sal_Bool m_bListenerAdded; public: - SwXDispatch(SwView& rView, sal_uInt16 nSlotId); + SwXDispatch(SwView& rView); ~SwXDispatch(); virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl, const ::com::sun::star::util::URL& aURL ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl, const ::com::sun::star::util::URL& aURL ) throw(::com::sun::star::uno::RuntimeException); + + //XSelectionChangeListener + virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException); + + //XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); }; #endif diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index 967dfe24ef6a..11fa9f01b1d5 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -2,9 +2,9 @@ * * $RCSfile: view.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: jp $ $Date: 2000-11-30 22:37:02 $ + * last change: $Author: os $ $Date: 2001-03-07 13:44:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -616,6 +616,7 @@ IMPL_LINK( SwView, TimeoutHdl, Timer *, EMPTYARG ) SelectShell(); bAttrChgNotified = sal_False; + GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged(); DBG_PROFSTOP(viewhdl); return 0; diff --git a/sw/source/ui/uno/unodispatch.cxx b/sw/source/ui/uno/unodispatch.cxx index 144103b9c93b..4de41e202086 100644 --- a/sw/source/ui/uno/unodispatch.cxx +++ b/sw/source/ui/uno/unodispatch.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unodispatch.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: os $ $Date: 2000-11-13 08:34:02 $ + * last change: $Author: os $ $Date: 2001-03-07 13:43:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,12 +84,16 @@ #include "wrtsh.hxx" #include "dbmgr.hxx" +#ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_ +#include <com/sun/star/view/XSelectionSupplier.hpp> +#endif using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::util; using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::view; using namespace rtl; using namespace vos; @@ -137,23 +141,13 @@ Reference< XDispatch > SwXDispatchProviderInterceptor::queryDispatch( // create some dispatch ... if(!aURL.Complete.compareToAscii(cURLStart, 23)) { - if(!aURL.Complete.compareToAscii(cURLFormLetter)) - { - if(!m_xFormLetterDispatch.is()) - m_xFormLetterDispatch = new SwXDispatch(m_rView, FN_DB_FORM_LETTER ); - xResult = m_xFormLetterDispatch; - } - else if(!aURL.Complete.compareToAscii(cURLInsertContent)) - { - if(!m_xInsertContentDispatch.is()) - m_xInsertContentDispatch = new SwXDispatch(m_rView, FN_DB_INSERT_CONTENT); - xResult = m_xInsertContentDispatch; - } - else if(!aURL.Complete.compareToAscii(cURLInsertColumns)) + if(!aURL.Complete.compareToAscii(cURLFormLetter) || + !aURL.Complete.compareToAscii(cURLInsertContent) || + !aURL.Complete.compareToAscii(cURLInsertColumns)) { - if(!m_xInsertColumnsDispatch.is()) - m_xInsertColumnsDispatch = new SwXDispatch(m_rView, FN_DB_INSERT_COLUMNS); - xResult = m_xInsertColumnsDispatch; + if(!m_xDispatch.is()) + m_xDispatch = new SwXDispatch(m_rView); + xResult = m_xDispatch; } } @@ -229,18 +223,17 @@ void SwXDispatchProviderInterceptor::disposing( const EventObject& Source ) Reference< XComponent> xInterceptedComponent(m_xIntercepted, UNO_QUERY); if (xInterceptedComponent.is()) xInterceptedComponent->removeEventListener((XEventListener*)this); - m_xFormLetterDispatch = 0; - m_xInsertContentDispatch = 0; - m_xInsertColumnsDispatch = 0; + m_xDispatch = 0; } m_xIntercepted = NULL; } /* -----------------------------07.11.00 14:26-------------------------------- ---------------------------------------------------------------------------*/ -SwXDispatch::SwXDispatch(SwView& rVw, sal_uInt16 nSlotId) : +SwXDispatch::SwXDispatch(SwView& rVw) : m_rView(rVw), - m_nSlot(nSlotId) + m_bOldEnable(sal_False), + m_bListenerAdded(sal_False) { } /*-- 07.11.00 14:26:13--------------------------------------------------- @@ -248,6 +241,12 @@ SwXDispatch::SwXDispatch(SwView& rVw, sal_uInt16 nSlotId) : -----------------------------------------------------------------------*/ SwXDispatch::~SwXDispatch() { + if(m_bListenerAdded) + { + Reference<XSelectionSupplier> xSupplier = m_rView.GetUNOObject(); + Reference<XSelectionChangeListener> xThis = this; + xSupplier->removeSelectionChangeListener(xThis); + } } /*-- 07.11.00 14:26:13--------------------------------------------------- @@ -279,19 +278,32 @@ void SwXDispatch::dispatch( void SwXDispatch::addStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) throw(RuntimeException) { + ShellModes eMode = m_rView.GetShellMode(); + sal_Bool bEnable = SEL_TEXT == eMode || + SEL_LIST_TEXT == eMode || + SEL_TABLE_TEXT == eMode || + SEL_TABLE_LIST_TEXT == eMode; + + m_bOldEnable = bEnable; FeatureStateEvent aEvent; - aEvent.IsEnabled = sal_True; + aEvent.IsEnabled = bEnable; aEvent.Source = *(cppu::OWeakObject*)this; aEvent.FeatureURL = aURL; xControl->statusChanged( aEvent ); -#ifdef DBG_UTIL - static BOOL bShowError = TRUE; - if(bShowError) + + StatusListenerList::iterator aListIter = m_aListenerList.begin(); + StatusStruct_Impl aStatus; + aStatus.xListener = xControl; + aStatus.aURL = aURL; + m_aListenerList.insert(aListIter, aStatus); + + if(!m_bListenerAdded) { - DBG_ERROR("void SwXDispatch::addStatusListener: not implemented") - bShowError=FALSE; + Reference<XSelectionSupplier> xSupplier = m_rView.GetUNOObject(); + Reference<XSelectionChangeListener> xThis = this; + xSupplier->addSelectionChangeListener(xThis); + m_bListenerAdded = sal_True; } -#endif } /*-- 07.11.00 14:26:15--------------------------------------------------- @@ -299,12 +311,59 @@ void SwXDispatch::addStatusListener( void SwXDispatch::removeStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) throw(RuntimeException) { -#ifdef DBG_UTIL - static BOOL bShowError = TRUE; - if(bShowError) + StatusListenerList::iterator aListIter = m_aListenerList.begin(); + for(aListIter = m_aListenerList.begin(); aListIter != m_aListenerList.end(); ++aListIter) { - DBG_ERROR("void SwXDispatch::removeStatusListener: not implemented") - bShowError=FALSE; + StatusStruct_Impl aStatus = *aListIter; + if(aStatus.xListener.get() == xControl.get()) + { + m_aListenerList.erase(aListIter); + break; + } + } + if(m_aListenerList.empty()) + { + Reference<XSelectionSupplier> xSupplier = m_rView.GetUNOObject(); + Reference<XSelectionChangeListener> xThis = this; + xSupplier->removeSelectionChangeListener(xThis); + m_bListenerAdded = sal_False; } -#endif } +/* -----------------------------07.03.01 10:27-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwXDispatch::selectionChanged( const EventObject& aEvent ) throw(RuntimeException) +{ + ShellModes eMode = m_rView.GetShellMode(); + sal_Bool bEnable = SEL_TEXT == eMode || + SEL_LIST_TEXT == eMode || + SEL_TABLE_TEXT == eMode || + SEL_TABLE_LIST_TEXT == eMode; + if(bEnable != m_bOldEnable) + { + m_bOldEnable = bEnable; + FeatureStateEvent aEvent; + aEvent.IsEnabled = bEnable; + sal_Bool Requery = FALSE; + aEvent.Source = *(cppu::OWeakObject*)this; + + StatusListenerList::iterator aListIter = m_aListenerList.begin(); + for(aListIter = m_aListenerList.begin(); aListIter != m_aListenerList.end(); ++aListIter) + { + StatusStruct_Impl aStatus = *aListIter; + aEvent.FeatureURL = aStatus.aURL; + aStatus.xListener->statusChanged( aEvent ); + } + } +} +/* -----------------------------07.03.01 10:46-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwXDispatch::disposing( const EventObject& rSource ) throw(RuntimeException) +{ + Reference<XSelectionSupplier> xSupplier(rSource.Source, UNO_QUERY); + Reference<XSelectionChangeListener> xThis = this; + xSupplier->removeSelectionChangeListener(xThis); + m_bListenerAdded = sal_False; +} + diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 4d16c955ce88..1f6b0d9caaa8 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unotxvw.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: os $ $Date: 2001-02-19 07:28:26 $ + * last change: $Author: os $ $Date: 2001-03-07 13:46:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -268,10 +268,23 @@ SwXTextView::~SwXTextView() } if(pxTextViewCursor) { - text::XTextViewCursor* pCrsr = pxTextViewCursor->get(); + text::XTextViewCursor* pCrsr = pxTextViewCursor->get(); ((SwXTextViewCursor*)pCrsr)->Invalidate(); delete pxTextViewCursor; } + sal_uInt16 nCount = aSelChangedListeners.Count(); + if(nCount) + { + m_refCount++; //prevent second d'tor call + Reference< uno::XInterface > xInt = (cppu::OWeakObject*)(SfxBaseController*)this; + lang::EventObject aEvent(xInt); + for ( sal_uInt16 i = nCount; i--; ) + { + Reference< view::XSelectionChangeListener > *pObj = aSelChangedListeners[i]; + (*pObj)->disposing(aEvent); + } + m_refCount--; + } } /* -----------------------------18.05.00 10:18-------------------------------- |