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