Kaydet (Commit) 272f0e97 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Improvements on previous commit

* Made XGlobalEventBroadcaster inherit document::XDocumentEventBroadcaster/
  Listener replacements for obsolete document::XEventBroadcaster/Listener.  This
  means some client sides unfortunately still need to use UNO_QUERY_THROW to
  obtain the obsolete interfaces; those client sides should be cleaned up to use
  the replacement interfaces instead.

* Added @since tag (even to unpublished entities, on "it doesn't hurt" grounds).

* Made client sides use XGlobalEventBroadcaster directly instead of querying for
  its super-interfaces.

* Replaced new uses of comphelper::ComponentContext::getUNOContext with
  comphelper::getComponentContext (see 03a9f139
  "ComponentContext::getUnoContext -> getComponentContext simplification;" I
  intend to get rid of comphelper/componentcontext.hxx much sooner than of
  comphelper/processfactory.hxx).

Change-Id: I6d971ebdaea83d0c3fa9ba299fb6b37e58cdfe9b
üst cd693ff5
...@@ -89,11 +89,10 @@ SvxEventConfigPage::SvxEventConfigPage( Window *pParent, const SfxItemSet& rSet, ...@@ -89,11 +89,10 @@ SvxEventConfigPage::SvxEventConfigPage( Window *pParent, const SfxItemSet& rSet,
aSaveInListBox.SetSelectHdl( LINK( this, SvxEventConfigPage, aSaveInListBox.SetSelectHdl( LINK( this, SvxEventConfigPage,
SelectHdl_Impl ) ); SelectHdl_Impl ) );
uno::Reference< document::XEventsSupplier > xSupplier; uno::Reference< frame::XGlobalEventBroadcaster > xSupplier;
xSupplier = uno::Reference< document::XEventsSupplier > ( xSupplier =
frame::GlobalEventBroadcaster::create(::comphelper::getProcessComponentContext()), frame::GlobalEventBroadcaster::create(::comphelper::getProcessComponentContext());
uno::UNO_QUERY_THROW );
sal_uInt16 nPos(0); sal_uInt16 nPos(0);
m_xAppEvents = xSupplier->getEvents(); m_xAppEvents = xSupplier->getEvents();
......
...@@ -1532,7 +1532,7 @@ int Desktop::Main() ...@@ -1532,7 +1532,7 @@ int Desktop::Main()
// create service for loadin SFX (still needed in startup) // create service for loadin SFX (still needed in startup)
pExecGlobals->xGlobalBroadcaster = Reference < css::document::XEventListener > pExecGlobals->xGlobalBroadcaster = Reference < css::document::XEventListener >
( css::frame::GlobalEventBroadcaster::create(comphelper::ComponentContext(xSMgr).getUNOContext()), UNO_QUERY ); ( css::frame::GlobalEventBroadcaster::create(comphelper::getComponentContext(xSMgr)), UNO_QUERY_THROW );
/* ensure existance of a default window that messages can be dispatched to /* ensure existance of a default window that messages can be dispatched to
This is for the benefit of testtool which uses PostUserEvent extensively This is for the benefit of testtool which uses PostUserEvent extensively
...@@ -1567,12 +1567,9 @@ int Desktop::Main() ...@@ -1567,12 +1567,9 @@ int Desktop::Main()
// keep a language options instance... // keep a language options instance...
pExecGlobals->pLanguageOptions.reset( new SvtLanguageOptions(sal_True)); pExecGlobals->pLanguageOptions.reset( new SvtLanguageOptions(sal_True));
if (pExecGlobals->xGlobalBroadcaster.is()) css::document::EventObject aEvent;
{ aEvent.EventName = ::rtl::OUString("OnStartApp");
css::document::EventObject aEvent; pExecGlobals->xGlobalBroadcaster->notifyEvent(aEvent);
aEvent.EventName = ::rtl::OUString("OnStartApp");
pExecGlobals->xGlobalBroadcaster->notifyEvent(aEvent);
}
SetSplashScreenProgress(50); SetSplashScreenProgress(50);
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
#include <com/sun/star/beans/Property.hpp> #include <com/sun/star/beans/Property.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/document/CorruptedFilterConfigurationException.hpp> #include <com/sun/star/document/CorruptedFilterConfigurationException.hpp>
#include <comphelper/componentcontext.hxx>
#include <comphelper/sequenceasvector.hxx> #include <comphelper/sequenceasvector.hxx>
#include <comphelper/locale.hxx> #include <comphelper/locale.hxx>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
...@@ -250,7 +249,7 @@ void FilterCache::load(EFillState eRequired, ...@@ -250,7 +249,7 @@ void FilterCache::load(EFillState eRequired,
// and starts a thread, which calls loadAll() at this filter cache. // and starts a thread, which calls loadAll() at this filter cache.
// Note: Its not a leak to create this listener with new here. // Note: Its not a leak to create this listener with new here.
// It kills itself after working! // It kills itself after working!
/* LateInitListener* pLateInit = */ new LateInitListener(comphelper::ComponentContext(m_xSMGR).getUNOContext()); /* LateInitListener* pLateInit = */ new LateInitListener(comphelper::getComponentContext(m_xSMGR));
} }
// ------------------------------------------ // ------------------------------------------
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include <com/sun/star/xml/XExportFilter.hpp> #include <com/sun/star/xml/XExportFilter.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <comphelper/componentcontext.hxx>
#include <comphelper/oslfile2streamwrap.hxx> #include <comphelper/oslfile2streamwrap.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
...@@ -188,7 +187,7 @@ XMLFilterTestDialog::XMLFilterTestDialog( Window* pParent, ResMgr& rResMgr, cons ...@@ -188,7 +187,7 @@ XMLFilterTestDialog::XMLFilterTestDialog( Window* pParent, ResMgr& rResMgr, cons
if( xCfgMgr.is() ) if( xCfgMgr.is() )
sDTDPath = xCfgMgr->substituteVariables( sDTDPath ); sDTDPath = xCfgMgr->substituteVariables( sDTDPath );
mxGlobalBroadcaster = Reference < XEventBroadcaster >( GlobalEventBroadcaster::create(comphelper::ComponentContext(mxMSF).getUNOContext()), UNO_QUERY_THROW ); mxGlobalBroadcaster = Reference < XEventBroadcaster >( GlobalEventBroadcaster::create(comphelper::getComponentContext(mxMSF)), UNO_QUERY_THROW );
mxGlobalEventListener = new GlobalEventListenerImpl( this ); mxGlobalEventListener = new GlobalEventListenerImpl( this );
mxGlobalBroadcaster->addEventListener( mxGlobalEventListener ); mxGlobalBroadcaster->addEventListener( mxGlobalEventListener );
} }
......
...@@ -19,15 +19,17 @@ ...@@ -19,15 +19,17 @@
#ifndef __com_sun_star_frame_XGlobalEventBroadcaster_idl__ #ifndef __com_sun_star_frame_XGlobalEventBroadcaster_idl__
#define __com_sun_star_frame_XGlobalEventBroadcaster_idl__ #define __com_sun_star_frame_XGlobalEventBroadcaster_idl__
#include <com/sun/star/document/XEventBroadcaster.idl>
#include <com/sun/star/document/XEventsSupplier.idl>
#include <com/sun/star/container/XSet.idl> #include <com/sun/star/container/XSet.idl>
#include <com/sun/star/document/XDocumentEventBroadcaster.idl>
#include <com/sun/star/document/XDocumentEventListener.idl>
#include <com/sun/star/document/XEventsSupplier.idl>
module com { module sun { module star { module frame {
module com { module sun { module star { module frame {
/** /**
Provides a unified interface for the GlobalEventBroadcaster service to implement. Provides a unified interface for the GlobalEventBroadcaster service to implement.
@since LibreOffice 3.7
*/ */
interface XGlobalEventBroadcaster interface XGlobalEventBroadcaster
...@@ -39,11 +41,11 @@ interface XGlobalEventBroadcaster ...@@ -39,11 +41,11 @@ interface XGlobalEventBroadcaster
/** access to bound event handlers /** access to bound event handlers
*/ */
interface ::com::sun::star::document::XEventBroadcaster; interface ::com::sun::star::document::XDocumentEventBroadcaster;
interface ::com::sun::star::container::XSet; interface ::com::sun::star::container::XSet;
interface ::com::sun::star::document::XEventListener; interface ::com::sun::star::document::XDocumentEventListener;
}; };
......
...@@ -113,7 +113,7 @@ void SAL_CALL SfxTerminateListener_Impl::notifyTermination( const EventObject& a ...@@ -113,7 +113,7 @@ void SAL_CALL SfxTerminateListener_Impl::notifyTermination( const EventObject& a
pApp->Get_Impl()->pAppDispatch->release(); pApp->Get_Impl()->pAppDispatch->release();
css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
css::uno::Reference< css::frame::XGlobalEventBroadcaster > xGlobalBroadcaster = css::frame::GlobalEventBroadcaster::create(xContext); css::uno::Reference< css::document::XEventListener > xGlobalBroadcaster(css::frame::GlobalEventBroadcaster::create(xContext), css::uno::UNO_QUERY_THROW);
css::document::EventObject aEvent2; css::document::EventObject aEvent2;
aEvent2.EventName = "OnCloseApp"; aEvent2.EventName = "OnCloseApp";
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <com/sun/star/container/XSet.hpp> #include <com/sun/star/container/XSet.hpp>
#include <com/sun/star/document/XEventListener.hpp> #include <com/sun/star/document/XEventListener.hpp>
#include <com/sun/star/document/XEventBroadcaster.hpp> #include <com/sun/star/document/XEventBroadcaster.hpp>
#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
#include <com/sun/star/document/XDocumentEventListener.hpp> #include <com/sun/star/document/XDocumentEventListener.hpp>
#include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/document/XEventsSupplier.hpp>
#include <com/sun/star/frame/XGlobalEventBroadcaster.hpp> #include <com/sun/star/frame/XGlobalEventBroadcaster.hpp>
...@@ -38,7 +37,6 @@ ...@@ -38,7 +37,6 @@
#include <cppuhelper/weak.hxx> #include <cppuhelper/weak.hxx>
#include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implbase4.hxx> #include <cppuhelper/implbase4.hxx>
#include <comphelper/sequenceashashmap.hxx> #include <comphelper/sequenceashashmap.hxx>
#include <comphelper/sequenceasvector.hxx> #include <comphelper/sequenceasvector.hxx>
...@@ -172,11 +170,12 @@ class ModelCollectionEnumeration : public ModelCollectionMutexBase ...@@ -172,11 +170,12 @@ class ModelCollectionEnumeration : public ModelCollectionMutexBase
}; };
//============================================================================= //=============================================================================
//TODO: remove support of obsolete document::XEventBroadcaster/Listener
class SfxGlobalEvents_Impl : public ModelCollectionMutexBase class SfxGlobalEvents_Impl : public ModelCollectionMutexBase
, public ::cppu::WeakImplHelper4< ::com::sun::star::lang::XServiceInfo , public ::cppu::WeakImplHelper4< ::com::sun::star::lang::XServiceInfo
, ::com::sun::star::frame::XGlobalEventBroadcaster , ::com::sun::star::frame::XGlobalEventBroadcaster
, ::com::sun::star::document::XDocumentEventBroadcaster , ::com::sun::star::document::XEventBroadcaster
, ::com::sun::star::document::XDocumentEventListener , ::com::sun::star::document::XEventListener
> >
{ {
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMGR; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMGR;
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include "com/sun/star/awt/XTopWindow.hpp" #include "com/sun/star/awt/XTopWindow.hpp"
#include "com/sun/star/beans/XPropertySet.hpp" #include "com/sun/star/beans/XPropertySet.hpp"
#include "com/sun/star/container/XEnumerationAccess.hpp" #include "com/sun/star/document/XEventBroadcaster.hpp"
#include "com/sun/star/document/XStorageBasedDocument.hpp" #include "com/sun/star/document/XStorageBasedDocument.hpp"
#include "com/sun/star/frame/GlobalEventBroadcaster.hpp" #include "com/sun/star/frame/GlobalEventBroadcaster.hpp"
#include "com/sun/star/frame/XStorable.hpp" #include "com/sun/star/frame/XStorable.hpp"
...@@ -115,16 +115,14 @@ OfficeDocumentsManager::OfficeDocumentsManager( ...@@ -115,16 +115,14 @@ OfficeDocumentsManager::OfficeDocumentsManager(
const uno::Reference< uno::XComponentContext > & rxContext, const uno::Reference< uno::XComponentContext > & rxContext,
OfficeDocumentsEventListener * pDocEventListener ) OfficeDocumentsEventListener * pDocEventListener )
: m_xContext( rxContext ), : m_xContext( rxContext ),
m_xDocEvtNotifier( createDocumentEventNotifier( rxContext ) ), m_xDocEvtNotifier( frame::GlobalEventBroadcaster::create( rxContext ) ),
m_pDocEventListener( pDocEventListener ), m_pDocEventListener( pDocEventListener ),
m_xDocCloseListener( new OfficeDocumentsCloseListener( this ) ) m_xDocCloseListener( new OfficeDocumentsCloseListener( this ) )
{ {
if ( m_xDocEvtNotifier.is() ) // Order is important (multithreaded environment)
{ uno::Reference< document::XEventBroadcaster >(
// Order is important (multithreaded environment) m_xDocEvtNotifier, uno::UNO_QUERY_THROW )->addEventListener( this );
m_xDocEvtNotifier->addEventListener( this ); buildDocumentsList();
buildDocumentsList();
}
} }
//========================================================================= //=========================================================================
...@@ -141,8 +139,8 @@ OfficeDocumentsManager::~OfficeDocumentsManager() ...@@ -141,8 +139,8 @@ OfficeDocumentsManager::~OfficeDocumentsManager()
//========================================================================= //=========================================================================
void OfficeDocumentsManager::destroy() void OfficeDocumentsManager::destroy()
{ {
if ( m_xDocEvtNotifier.is() ) uno::Reference< document::XEventBroadcaster >(
m_xDocEvtNotifier->removeEventListener( this ); m_xDocEvtNotifier, uno::UNO_QUERY_THROW )->removeEventListener( this );
} }
//========================================================================= //=========================================================================
...@@ -457,53 +455,10 @@ void SAL_CALL OfficeDocumentsManager::disposing( ...@@ -457,53 +455,10 @@ void SAL_CALL OfficeDocumentsManager::disposing(
// //
//========================================================================= //=========================================================================
// static
uno::Reference< document::XEventBroadcaster >
OfficeDocumentsManager::createDocumentEventNotifier(
const uno::Reference< uno::XComponentContext >& rxContext )
{
uno::Reference< uno::XInterface > xIfc;
try
{
xIfc = frame::GlobalEventBroadcaster::create(rxContext);
}
catch ( uno::Exception const & )
{
// handled below.
}
OSL_ENSURE(
xIfc.is(),
"Could not instanciate com.sun.star.frame.GlobalEventBroadcaster" );
if ( xIfc.is() )
{
uno::Reference< document::XEventBroadcaster > xBC(
xIfc, uno::UNO_QUERY );
OSL_ENSURE(
xBC.is(),
"com.sun.star.frame.GlobalEventBroadcaster does not implement "
"interface com.sun.star.document.XEventBroadcaster!" );
return xBC;
}
else
return uno::Reference< document::XEventBroadcaster >();
}
//=========================================================================
void OfficeDocumentsManager::buildDocumentsList() void OfficeDocumentsManager::buildDocumentsList()
{ {
OSL_ENSURE( m_xDocEvtNotifier.is(),
"OfficeDocumentsManager::buildDocumentsList - "
"No document event notifier!" );
uno::Reference< container::XEnumerationAccess > xEnumAccess(
m_xDocEvtNotifier, uno::UNO_QUERY_THROW );
uno::Reference< container::XEnumeration > xEnum uno::Reference< container::XEnumeration > xEnum
= xEnumAccess->createEnumeration(); = m_xDocEvtNotifier->createEnumeration();
osl::MutexGuard aGuard( m_aMtx ); osl::MutexGuard aGuard( m_aMtx );
......
...@@ -35,11 +35,11 @@ ...@@ -35,11 +35,11 @@
#include "cppuhelper/implbase1.hxx" #include "cppuhelper/implbase1.hxx"
#include "com/sun/star/document/XEventBroadcaster.hpp"
#include "com/sun/star/document/XEventListener.hpp" #include "com/sun/star/document/XEventListener.hpp"
#include "com/sun/star/embed/XStorage.hpp" #include "com/sun/star/embed/XStorage.hpp"
#include "com/sun/star/frame/XModel.hpp" #include "com/sun/star/frame/XModel.hpp"
#include "com/sun/star/frame/XModuleManager2.hpp" #include "com/sun/star/frame/XModuleManager2.hpp"
#include "com/sun/star/frame/XGlobalEventBroadcaster.hpp"
#include "com/sun/star/util/XCloseListener.hpp" #include "com/sun/star/util/XCloseListener.hpp"
namespace tdoc_ucp { namespace tdoc_ucp {
...@@ -158,12 +158,6 @@ namespace tdoc_ucp { ...@@ -158,12 +158,6 @@ namespace tdoc_ucp {
queryStorageTitle( const rtl::OUString & rDocId ); queryStorageTitle( const rtl::OUString & rDocId );
private: private:
static com::sun::star::uno::Reference<
com::sun::star::document::XEventBroadcaster >
createDocumentEventNotifier(
const com::sun::star::uno::Reference<
com::sun::star::uno::XComponentContext >& rxContext );
void buildDocumentsList(); void buildDocumentsList();
bool bool
...@@ -195,7 +189,7 @@ namespace tdoc_ucp { ...@@ -195,7 +189,7 @@ namespace tdoc_ucp {
com::sun::star::uno::Reference< com::sun::star::uno::Reference<
com::sun::star::uno::XComponentContext > m_xContext; com::sun::star::uno::XComponentContext > m_xContext;
com::sun::star::uno::Reference< com::sun::star::uno::Reference<
com::sun::star::document::XEventBroadcaster > m_xDocEvtNotifier; com::sun::star::frame::XGlobalEventBroadcaster > m_xDocEvtNotifier;
com::sun::star::uno::Reference< com::sun::star::uno::Reference<
com::sun::star::frame::XModuleManager2 > m_xModuleMgr; com::sun::star::frame::XModuleManager2 > m_xModuleMgr;
DocumentList m_aDocs; DocumentList m_aDocs;
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include "com/sun/star/container/XNameAccess.hpp" #include "com/sun/star/container/XNameAccess.hpp"
#include "com/sun/star/embed/XStorage.hpp" #include "com/sun/star/embed/XStorage.hpp"
#include "comphelper/componentcontext.hxx" #include "comphelper/processfactory.hxx"
#include "ucbhelper/contentidentifier.hxx" #include "ucbhelper/contentidentifier.hxx"
#include "tdoc_provider.hxx" #include "tdoc_provider.hxx"
...@@ -61,7 +61,7 @@ using namespace tdoc_ucp; ...@@ -61,7 +61,7 @@ using namespace tdoc_ucp;
ContentProvider::ContentProvider( ContentProvider::ContentProvider(
const uno::Reference< lang::XMultiServiceFactory >& xSMgr ) const uno::Reference< lang::XMultiServiceFactory >& xSMgr )
: ::ucbhelper::ContentProviderImplHelper( xSMgr ), : ::ucbhelper::ContentProviderImplHelper( xSMgr ),
m_xDocsMgr( new OfficeDocumentsManager( comphelper::ComponentContext(xSMgr).getUNOContext(), this ) ), m_xDocsMgr( new OfficeDocumentsManager( comphelper::getComponentContext(xSMgr), this ) ),
m_xStgElemFac( new StorageElementFactory( xSMgr, m_xDocsMgr ) ) m_xStgElemFac( new StorageElementFactory( xSMgr, m_xDocsMgr ) )
{ {
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment