1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vcl/svapp.hxx> 28cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 29cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 30cdf0e10cSrcweir #include <svx/dataaccessdescriptor.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <unodispatch.hxx> 33cdf0e10cSrcweir #include <unobaseclass.hxx> 34cdf0e10cSrcweir #include <view.hxx> 35cdf0e10cSrcweir #include <cmdid.h> 36cdf0e10cSrcweir #include "wrtsh.hxx" 37cdf0e10cSrcweir #include "dbmgr.hxx" 38cdf0e10cSrcweir 39cdf0e10cSrcweir 40cdf0e10cSrcweir using namespace ::com::sun::star; 41cdf0e10cSrcweir using namespace rtl; 42cdf0e10cSrcweir using namespace vos; 43cdf0e10cSrcweir 44cdf0e10cSrcweir const char* cURLStart = ".uno:DataSourceBrowser/"; 45cdf0e10cSrcweir const char* cURLFormLetter = ".uno:DataSourceBrowser/FormLetter"; 46cdf0e10cSrcweir const char* cURLInsertContent = ".uno:DataSourceBrowser/InsertContent";//data into fields 47cdf0e10cSrcweir const char* cURLInsertColumns = ".uno:DataSourceBrowser/InsertColumns";//data into text 48cdf0e10cSrcweir const char* cURLDocumentDataSource = ".uno:DataSourceBrowser/DocumentDataSource";//current data source of the document 49cdf0e10cSrcweir const sal_Char* cInternalDBChangeNotification = ".uno::Writer/DataSourceChanged"; 50cdf0e10cSrcweir /*-- 07.11.00 13:25:51--------------------------------------------------- 51cdf0e10cSrcweir 52cdf0e10cSrcweir -----------------------------------------------------------------------*/ 53cdf0e10cSrcweir SwXDispatchProviderInterceptor::SwXDispatchProviderInterceptor(SwView& rVw) : 54cdf0e10cSrcweir m_pView(&rVw) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir uno::Reference< frame::XFrame> xUnoFrame = m_pView->GetViewFrame()->GetFrame().GetFrameInterface(); 57cdf0e10cSrcweir m_xIntercepted = uno::Reference< frame::XDispatchProviderInterception>(xUnoFrame, uno::UNO_QUERY); 58cdf0e10cSrcweir if(m_xIntercepted.is()) 59cdf0e10cSrcweir { 60cdf0e10cSrcweir m_refCount++; 61cdf0e10cSrcweir m_xIntercepted->registerDispatchProviderInterceptor((frame::XDispatchProviderInterceptor*)this); 62cdf0e10cSrcweir // this should make us the top-level dispatch-provider for the component, via a call to our 63cdf0e10cSrcweir // setDispatchProvider we should have got an fallback for requests we (i.e. our master) cannot fullfill 64cdf0e10cSrcweir uno::Reference< lang::XComponent> xInterceptedComponent(m_xIntercepted, uno::UNO_QUERY); 65cdf0e10cSrcweir if (xInterceptedComponent.is()) 66cdf0e10cSrcweir xInterceptedComponent->addEventListener((lang::XEventListener*)this); 67cdf0e10cSrcweir m_refCount--; 68cdf0e10cSrcweir } 69cdf0e10cSrcweir } 70cdf0e10cSrcweir /*-- 07.11.00 13:25:51--------------------------------------------------- 71cdf0e10cSrcweir 72cdf0e10cSrcweir -----------------------------------------------------------------------*/ 73cdf0e10cSrcweir SwXDispatchProviderInterceptor::~SwXDispatchProviderInterceptor() 74cdf0e10cSrcweir { 75cdf0e10cSrcweir } 76cdf0e10cSrcweir /*-- 07.11.00 13:25:51--------------------------------------------------- 77cdf0e10cSrcweir 78cdf0e10cSrcweir -----------------------------------------------------------------------*/ 79cdf0e10cSrcweir uno::Reference< frame::XDispatch > SwXDispatchProviderInterceptor::queryDispatch( 80cdf0e10cSrcweir const util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags ) 81cdf0e10cSrcweir throw(uno::RuntimeException) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir DispatchMutexLock_Impl aLock(*this); 84cdf0e10cSrcweir uno::Reference< frame::XDispatch> xResult; 85cdf0e10cSrcweir // create some dispatch ... 86cdf0e10cSrcweir if(m_pView && !aURL.Complete.compareToAscii(cURLStart, 23)) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir if(!aURL.Complete.compareToAscii(cURLFormLetter) || 89cdf0e10cSrcweir !aURL.Complete.compareToAscii(cURLInsertContent) || 90cdf0e10cSrcweir !aURL.Complete.compareToAscii(cURLInsertColumns)|| 91cdf0e10cSrcweir !aURL.Complete.compareToAscii(cURLDocumentDataSource)) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir if(!m_xDispatch.is()) 94cdf0e10cSrcweir m_xDispatch = new SwXDispatch(*m_pView); 95cdf0e10cSrcweir xResult = m_xDispatch; 96cdf0e10cSrcweir } 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir // ask our slave provider 100cdf0e10cSrcweir if (!xResult.is() && m_xSlaveDispatcher.is()) 101cdf0e10cSrcweir xResult = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags); 102cdf0e10cSrcweir 103cdf0e10cSrcweir return xResult; 104cdf0e10cSrcweir } 105cdf0e10cSrcweir /*-- 07.11.00 13:25:52--------------------------------------------------- 106cdf0e10cSrcweir 107cdf0e10cSrcweir -----------------------------------------------------------------------*/ 108cdf0e10cSrcweir uno::Sequence< uno::Reference< frame::XDispatch > > SwXDispatchProviderInterceptor::queryDispatches( 109cdf0e10cSrcweir const uno::Sequence< frame::DispatchDescriptor >& aDescripts ) throw(uno::RuntimeException) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir DispatchMutexLock_Impl aLock(*this); 112cdf0e10cSrcweir uno::Sequence< uno::Reference< frame::XDispatch> > aReturn(aDescripts.getLength()); 113cdf0e10cSrcweir uno::Reference< frame::XDispatch>* pReturn = aReturn.getArray(); 114cdf0e10cSrcweir const frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray(); 115cdf0e10cSrcweir for (sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir *pReturn = queryDispatch(pDescripts->FeatureURL, 118cdf0e10cSrcweir pDescripts->FrameName, pDescripts->SearchFlags); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir return aReturn; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir /*-- 07.11.00 13:25:52--------------------------------------------------- 123cdf0e10cSrcweir 124cdf0e10cSrcweir -----------------------------------------------------------------------*/ 125cdf0e10cSrcweir uno::Reference< frame::XDispatchProvider > SwXDispatchProviderInterceptor::getSlaveDispatchProvider( ) 126cdf0e10cSrcweir throw(uno::RuntimeException) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir DispatchMutexLock_Impl aLock(*this); 129cdf0e10cSrcweir return m_xSlaveDispatcher; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir /*-- 07.11.00 13:25:52--------------------------------------------------- 132cdf0e10cSrcweir 133cdf0e10cSrcweir -----------------------------------------------------------------------*/ 134cdf0e10cSrcweir void SwXDispatchProviderInterceptor::setSlaveDispatchProvider( 135cdf0e10cSrcweir const uno::Reference< frame::XDispatchProvider >& xNewDispatchProvider ) throw(uno::RuntimeException) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir DispatchMutexLock_Impl aLock(*this); 138cdf0e10cSrcweir m_xSlaveDispatcher = xNewDispatchProvider; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir /*-- 07.11.00 13:25:52--------------------------------------------------- 141cdf0e10cSrcweir 142cdf0e10cSrcweir -----------------------------------------------------------------------*/ 143cdf0e10cSrcweir uno::Reference< frame::XDispatchProvider > SwXDispatchProviderInterceptor::getMasterDispatchProvider( ) 144cdf0e10cSrcweir throw(uno::RuntimeException) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir DispatchMutexLock_Impl aLock(*this); 147cdf0e10cSrcweir return m_xMasterDispatcher; 148cdf0e10cSrcweir } 149cdf0e10cSrcweir /*-- 07.11.00 13:25:52--------------------------------------------------- 150cdf0e10cSrcweir 151cdf0e10cSrcweir -----------------------------------------------------------------------*/ 152cdf0e10cSrcweir void SwXDispatchProviderInterceptor::setMasterDispatchProvider( 153cdf0e10cSrcweir const uno::Reference< frame::XDispatchProvider >& xNewSupplier ) throw(uno::RuntimeException) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir DispatchMutexLock_Impl aLock(*this); 156cdf0e10cSrcweir m_xMasterDispatcher = xNewSupplier; 157cdf0e10cSrcweir } 158cdf0e10cSrcweir /*-- 07.11.00 13:25:53--------------------------------------------------- 159cdf0e10cSrcweir 160cdf0e10cSrcweir -----------------------------------------------------------------------*/ 161cdf0e10cSrcweir void SwXDispatchProviderInterceptor::disposing( const lang::EventObject& ) 162cdf0e10cSrcweir throw(uno::RuntimeException) 163cdf0e10cSrcweir { 164cdf0e10cSrcweir DispatchMutexLock_Impl aLock(*this); 165cdf0e10cSrcweir if (m_xIntercepted.is()) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir m_xIntercepted->releaseDispatchProviderInterceptor((frame::XDispatchProviderInterceptor*)this); 168cdf0e10cSrcweir uno::Reference< lang::XComponent> xInterceptedComponent(m_xIntercepted, uno::UNO_QUERY); 169cdf0e10cSrcweir if (xInterceptedComponent.is()) 170cdf0e10cSrcweir xInterceptedComponent->removeEventListener((lang::XEventListener*)this); 171cdf0e10cSrcweir m_xDispatch = 0; 172cdf0e10cSrcweir } 173cdf0e10cSrcweir m_xIntercepted = NULL; 174cdf0e10cSrcweir } 175cdf0e10cSrcweir /* -----------------------------01.10.2001 14:31------------------------------ 176cdf0e10cSrcweir 177cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 178cdf0e10cSrcweir const uno::Sequence< sal_Int8 > & SwXDispatchProviderInterceptor::getUnoTunnelId() 179cdf0e10cSrcweir { 180cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); 181cdf0e10cSrcweir return aSeq; 182cdf0e10cSrcweir } 183cdf0e10cSrcweir /* -----------------------------01.10.2001 14:31------------------------------ 184cdf0e10cSrcweir 185cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 186cdf0e10cSrcweir sal_Int64 SwXDispatchProviderInterceptor::getSomething( 187cdf0e10cSrcweir const uno::Sequence< sal_Int8 >& aIdentifier ) 188cdf0e10cSrcweir throw(uno::RuntimeException) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir if( aIdentifier.getLength() == 16 191cdf0e10cSrcweir && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 192cdf0e10cSrcweir aIdentifier.getConstArray(), 16 ) ) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this )); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir return 0; 197cdf0e10cSrcweir } 198cdf0e10cSrcweir /* -----------------------------01.10.2001 14:32------------------------------ 199cdf0e10cSrcweir 200cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 201cdf0e10cSrcweir void SwXDispatchProviderInterceptor::Invalidate() 202cdf0e10cSrcweir { 203cdf0e10cSrcweir DispatchMutexLock_Impl aLock(*this); 204cdf0e10cSrcweir if (m_xIntercepted.is()) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir m_xIntercepted->releaseDispatchProviderInterceptor((frame::XDispatchProviderInterceptor*)this); 207cdf0e10cSrcweir uno::Reference< lang::XComponent> xInterceptedComponent(m_xIntercepted, uno::UNO_QUERY); 208cdf0e10cSrcweir if (xInterceptedComponent.is()) 209cdf0e10cSrcweir xInterceptedComponent->removeEventListener((lang::XEventListener*)this); 210cdf0e10cSrcweir m_xDispatch = 0; 211cdf0e10cSrcweir } 212cdf0e10cSrcweir m_xIntercepted = NULL; 213cdf0e10cSrcweir m_pView = 0; 214cdf0e10cSrcweir } 215cdf0e10cSrcweir /* -----------------------------07.11.00 14:26-------------------------------- 216cdf0e10cSrcweir 217cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 218cdf0e10cSrcweir SwXDispatch::SwXDispatch(SwView& rVw) : 219cdf0e10cSrcweir m_pView(&rVw), 220cdf0e10cSrcweir m_bOldEnable(sal_False), 221cdf0e10cSrcweir m_bListenerAdded(sal_False) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir } 224cdf0e10cSrcweir /*-- 07.11.00 14:26:13--------------------------------------------------- 225cdf0e10cSrcweir 226cdf0e10cSrcweir -----------------------------------------------------------------------*/ 227cdf0e10cSrcweir SwXDispatch::~SwXDispatch() 228cdf0e10cSrcweir { 229cdf0e10cSrcweir if(m_bListenerAdded && m_pView) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir uno::Reference<view::XSelectionSupplier> xSupplier = m_pView->GetUNOObject(); 232cdf0e10cSrcweir uno::Reference<view::XSelectionChangeListener> xThis = this; 233cdf0e10cSrcweir xSupplier->removeSelectionChangeListener(xThis); 234cdf0e10cSrcweir } 235cdf0e10cSrcweir } 236cdf0e10cSrcweir /*-- 07.11.00 14:26:13--------------------------------------------------- 237cdf0e10cSrcweir 238cdf0e10cSrcweir -----------------------------------------------------------------------*/ 239cdf0e10cSrcweir void SwXDispatch::dispatch( 240cdf0e10cSrcweir const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs ) throw(uno::RuntimeException) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir if(!m_pView) 243cdf0e10cSrcweir throw uno::RuntimeException(); 244cdf0e10cSrcweir SwWrtShell& rSh = m_pView->GetWrtShell(); 245cdf0e10cSrcweir SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr(); 246cdf0e10cSrcweir if(!aURL.Complete.compareToAscii(cURLInsertContent)) 247cdf0e10cSrcweir { 248cdf0e10cSrcweir ::svx::ODataAccessDescriptor aDescriptor(aArgs); 249cdf0e10cSrcweir SwMergeDescriptor aMergeDesc( DBMGR_MERGE, rSh, aDescriptor ); 250cdf0e10cSrcweir pNewDBMgr->MergeNew(aMergeDesc); 251cdf0e10cSrcweir } 252cdf0e10cSrcweir else if(!aURL.Complete.compareToAscii(cURLInsertColumns)) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir pNewDBMgr->InsertText(rSh, aArgs); 255cdf0e10cSrcweir } 256cdf0e10cSrcweir else if(!aURL.Complete.compareToAscii(cURLFormLetter)) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir SfxUsrAnyItem aDBProperties(FN_PARAM_DATABASE_PROPERTIES, uno::makeAny(aArgs)); 259cdf0e10cSrcweir m_pView->GetViewFrame()->GetDispatcher()->Execute( 260cdf0e10cSrcweir FN_MAILMERGE_WIZARD, 261cdf0e10cSrcweir SFX_CALLMODE_ASYNCHRON, 262cdf0e10cSrcweir &aDBProperties, 0L); 263cdf0e10cSrcweir // pNewDBMgr->ExecuteFormLetter(rSh, aArgs); 264cdf0e10cSrcweir } 265cdf0e10cSrcweir else if(!aURL.Complete.compareToAscii(cURLDocumentDataSource)) 266cdf0e10cSrcweir { 267cdf0e10cSrcweir OSL_ENSURE(sal_False, "SwXDispatch::dispatch: this URL is not to be dispatched!"); 268cdf0e10cSrcweir } 269cdf0e10cSrcweir else if(!aURL.Complete.compareToAscii(cInternalDBChangeNotification)) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir frame::FeatureStateEvent aEvent; 272cdf0e10cSrcweir aEvent.IsEnabled = sal_True; 273cdf0e10cSrcweir aEvent.Source = *(cppu::OWeakObject*)this; 274cdf0e10cSrcweir 275cdf0e10cSrcweir const SwDBData& rData = m_pView->GetWrtShell().GetDBDesc(); 276cdf0e10cSrcweir ::svx::ODataAccessDescriptor aDescriptor; 277cdf0e10cSrcweir aDescriptor.setDataSource(rData.sDataSource); 278cdf0e10cSrcweir aDescriptor[::svx::daCommand] <<= rData.sCommand; 279cdf0e10cSrcweir aDescriptor[::svx::daCommandType] <<= rData.nCommandType; 280cdf0e10cSrcweir 281cdf0e10cSrcweir aEvent.State <<= aDescriptor.createPropertyValueSequence(); 282cdf0e10cSrcweir aEvent.IsEnabled = rData.sDataSource.getLength() > 0; 283cdf0e10cSrcweir 284cdf0e10cSrcweir StatusListenerList::iterator aListIter = m_aListenerList.begin(); 285cdf0e10cSrcweir for(aListIter = m_aListenerList.begin(); aListIter != m_aListenerList.end(); ++aListIter) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir StatusStruct_Impl aStatus = *aListIter; 288cdf0e10cSrcweir if(!aStatus.aURL.Complete.compareToAscii(cURLDocumentDataSource)) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir aEvent.FeatureURL = aStatus.aURL; 291cdf0e10cSrcweir aStatus.xListener->statusChanged( aEvent ); 292cdf0e10cSrcweir } 293cdf0e10cSrcweir } 294cdf0e10cSrcweir } 295cdf0e10cSrcweir else 296cdf0e10cSrcweir throw uno::RuntimeException(); 297cdf0e10cSrcweir 298cdf0e10cSrcweir } 299cdf0e10cSrcweir /*-- 07.11.00 14:26:13--------------------------------------------------- 300cdf0e10cSrcweir 301cdf0e10cSrcweir -----------------------------------------------------------------------*/ 302cdf0e10cSrcweir void SwXDispatch::addStatusListener( 303cdf0e10cSrcweir const uno::Reference< frame::XStatusListener >& xControl, const util::URL& aURL ) throw(uno::RuntimeException) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir if(!m_pView) 306cdf0e10cSrcweir throw uno::RuntimeException(); 307cdf0e10cSrcweir ShellModes eMode = m_pView->GetShellMode(); 308cdf0e10cSrcweir sal_Bool bEnable = SHELL_MODE_TEXT == eMode || 309cdf0e10cSrcweir SHELL_MODE_LIST_TEXT == eMode || 310cdf0e10cSrcweir SHELL_MODE_TABLE_TEXT == eMode || 311cdf0e10cSrcweir SHELL_MODE_TABLE_LIST_TEXT == eMode; 312cdf0e10cSrcweir 313cdf0e10cSrcweir m_bOldEnable = bEnable; 314cdf0e10cSrcweir frame::FeatureStateEvent aEvent; 315cdf0e10cSrcweir aEvent.IsEnabled = bEnable; 316cdf0e10cSrcweir aEvent.Source = *(cppu::OWeakObject*)this; 317cdf0e10cSrcweir aEvent.FeatureURL = aURL; 318cdf0e10cSrcweir 319cdf0e10cSrcweir // one of the URLs requires a special state .... 320cdf0e10cSrcweir if (!aURL.Complete.compareToAscii(cURLDocumentDataSource)) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir const SwDBData& rData = m_pView->GetWrtShell().GetDBDesc(); 323cdf0e10cSrcweir 324cdf0e10cSrcweir ::svx::ODataAccessDescriptor aDescriptor; 325cdf0e10cSrcweir aDescriptor.setDataSource(rData.sDataSource); 326cdf0e10cSrcweir aDescriptor[::svx::daCommand] <<= rData.sCommand; 327cdf0e10cSrcweir aDescriptor[::svx::daCommandType] <<= rData.nCommandType; 328cdf0e10cSrcweir 329cdf0e10cSrcweir aEvent.State <<= aDescriptor.createPropertyValueSequence(); 330cdf0e10cSrcweir aEvent.IsEnabled = rData.sDataSource.getLength() > 0; 331cdf0e10cSrcweir } 332cdf0e10cSrcweir 333cdf0e10cSrcweir 334cdf0e10cSrcweir xControl->statusChanged( aEvent ); 335cdf0e10cSrcweir 336cdf0e10cSrcweir StatusListenerList::iterator aListIter = m_aListenerList.begin(); 337cdf0e10cSrcweir StatusStruct_Impl aStatus; 338cdf0e10cSrcweir aStatus.xListener = xControl; 339cdf0e10cSrcweir aStatus.aURL = aURL; 340cdf0e10cSrcweir m_aListenerList.insert(aListIter, aStatus); 341cdf0e10cSrcweir 342cdf0e10cSrcweir if(!m_bListenerAdded) 343cdf0e10cSrcweir { 344cdf0e10cSrcweir uno::Reference<view::XSelectionSupplier> xSupplier = m_pView->GetUNOObject(); 345cdf0e10cSrcweir uno::Reference<view::XSelectionChangeListener> xThis = this; 346cdf0e10cSrcweir xSupplier->addSelectionChangeListener(xThis); 347cdf0e10cSrcweir m_bListenerAdded = sal_True; 348cdf0e10cSrcweir } 349cdf0e10cSrcweir } 350cdf0e10cSrcweir /*-- 07.11.00 14:26:15--------------------------------------------------- 351cdf0e10cSrcweir 352cdf0e10cSrcweir -----------------------------------------------------------------------*/ 353cdf0e10cSrcweir void SwXDispatch::removeStatusListener( 354cdf0e10cSrcweir const uno::Reference< frame::XStatusListener >& xControl, const util::URL& ) throw(uno::RuntimeException) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir StatusListenerList::iterator aListIter = m_aListenerList.begin(); 357cdf0e10cSrcweir for(aListIter = m_aListenerList.begin(); aListIter != m_aListenerList.end(); ++aListIter) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir StatusStruct_Impl aStatus = *aListIter; 360cdf0e10cSrcweir if(aStatus.xListener.get() == xControl.get()) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir m_aListenerList.erase(aListIter); 363cdf0e10cSrcweir break; 364cdf0e10cSrcweir } 365cdf0e10cSrcweir } 366cdf0e10cSrcweir if(m_aListenerList.empty() && m_pView) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir uno::Reference<view::XSelectionSupplier> xSupplier = m_pView->GetUNOObject(); 369cdf0e10cSrcweir uno::Reference<view::XSelectionChangeListener> xThis = this; 370cdf0e10cSrcweir xSupplier->removeSelectionChangeListener(xThis); 371cdf0e10cSrcweir m_bListenerAdded = sal_False; 372cdf0e10cSrcweir } 373cdf0e10cSrcweir } 374cdf0e10cSrcweir /* -----------------------------07.03.01 10:27-------------------------------- 375cdf0e10cSrcweir 376cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 377cdf0e10cSrcweir void SwXDispatch::selectionChanged( const lang::EventObject& ) throw(uno::RuntimeException) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir ShellModes eMode = m_pView->GetShellMode(); 380cdf0e10cSrcweir sal_Bool bEnable = SHELL_MODE_TEXT == eMode || 381cdf0e10cSrcweir SHELL_MODE_LIST_TEXT == eMode || 382cdf0e10cSrcweir SHELL_MODE_TABLE_TEXT == eMode || 383cdf0e10cSrcweir SHELL_MODE_TABLE_LIST_TEXT == eMode; 384cdf0e10cSrcweir if(bEnable != m_bOldEnable) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir m_bOldEnable = bEnable; 387cdf0e10cSrcweir frame::FeatureStateEvent aEvent; 388cdf0e10cSrcweir aEvent.IsEnabled = bEnable; 389cdf0e10cSrcweir aEvent.Source = *(cppu::OWeakObject*)this; 390cdf0e10cSrcweir 391cdf0e10cSrcweir StatusListenerList::iterator aListIter = m_aListenerList.begin(); 392cdf0e10cSrcweir for(aListIter = m_aListenerList.begin(); aListIter != m_aListenerList.end(); ++aListIter) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir StatusStruct_Impl aStatus = *aListIter; 395cdf0e10cSrcweir aEvent.FeatureURL = aStatus.aURL; 396cdf0e10cSrcweir if (0 != aStatus.aURL.Complete.compareToAscii(cURLDocumentDataSource)) 397cdf0e10cSrcweir // the document's data source does not depend on the selection, so it's state does not change here 398cdf0e10cSrcweir aStatus.xListener->statusChanged( aEvent ); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir } 401cdf0e10cSrcweir } 402cdf0e10cSrcweir /* -----------------------------07.03.01 10:46-------------------------------- 403cdf0e10cSrcweir 404cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 405cdf0e10cSrcweir void SwXDispatch::disposing( const lang::EventObject& rSource ) throw(uno::RuntimeException) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir uno::Reference<view::XSelectionSupplier> xSupplier(rSource.Source, uno::UNO_QUERY); 408cdf0e10cSrcweir uno::Reference<view::XSelectionChangeListener> xThis = this; 409cdf0e10cSrcweir xSupplier->removeSelectionChangeListener(xThis); 410cdf0e10cSrcweir m_bListenerAdded = sal_False; 411cdf0e10cSrcweir 412cdf0e10cSrcweir lang::EventObject aObject; 413cdf0e10cSrcweir aObject.Source = (cppu::OWeakObject*)this; 414cdf0e10cSrcweir StatusListenerList::iterator aListIter = m_aListenerList.begin(); 415cdf0e10cSrcweir for(; aListIter != m_aListenerList.end(); ++aListIter) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir StatusStruct_Impl aStatus = *aListIter; 418cdf0e10cSrcweir aStatus.xListener->disposing(aObject); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir m_pView = 0; 421cdf0e10cSrcweir } 422cdf0e10cSrcweir /* -----------------------------12.07.01 13:30-------------------------------- 423cdf0e10cSrcweir 424cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 425cdf0e10cSrcweir const sal_Char* SwXDispatch::GetDBChangeURL() 426cdf0e10cSrcweir { 427cdf0e10cSrcweir return cInternalDBChangeNotification; 428cdf0e10cSrcweir } 429cdf0e10cSrcweir /* -----------------------------09.09.2002 08:48------------------------------ 430cdf0e10cSrcweir 431cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 432cdf0e10cSrcweir SwXDispatchProviderInterceptor::DispatchMutexLock_Impl::DispatchMutexLock_Impl( 433cdf0e10cSrcweir SwXDispatchProviderInterceptor& ) : 434cdf0e10cSrcweir // aGuard(rInterceptor.m_aMutex) #102295# solar mutex has to be used currently 435cdf0e10cSrcweir aGuard(Application::GetSolarMutex()) 436cdf0e10cSrcweir { 437cdf0e10cSrcweir } 438cdf0e10cSrcweir /* -----------------------------09.09.2002 08:48------------------------------ 439cdf0e10cSrcweir 440cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 441cdf0e10cSrcweir SwXDispatchProviderInterceptor::DispatchMutexLock_Impl::~DispatchMutexLock_Impl() 442cdf0e10cSrcweir { 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445