fdo#46808, Adapt frame::GlobalEventBroadcaster UNO service to new style

Create a merged XGlobalEventBroadcaster interface for this service to implement.
Which is backwards-compatible, but does not require creating a new service.

Also add two interfaces to the IDL, which the service already implemented,
and existing client code already used.

Change-Id: Ib7a9a30c0e50146ef621f3fe5227f8aad3190516
This commit is contained in:
Noel Grandin
2012-09-07 15:14:55 +02:00
committed by Stephan Bergmann
parent 526e007bb6
commit cd693ff598
18 changed files with 139 additions and 118 deletions

View File

@@ -21,6 +21,7 @@
#include "doceventnotifier.hxx" #include "doceventnotifier.hxx"
#include "scriptdocument.hxx" #include "scriptdocument.hxx"
#include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
#include <com/sun/star/document/XEventBroadcaster.hpp> #include <com/sun/star/document/XEventBroadcaster.hpp>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
@@ -44,11 +45,13 @@ namespace basctl
using ::com::sun::star::document::XEventBroadcaster; using ::com::sun::star::document::XEventBroadcaster;
using ::com::sun::star::document::XEventListener; using ::com::sun::star::document::XEventListener;
using ::com::sun::star::document::EventObject; using ::com::sun::star::document::EventObject;
using ::com::sun::star::uno::XComponentContext;
using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::Exception;
using ::com::sun::star::frame::XModel; using ::com::sun::star::frame::XModel;
using ::com::sun::star::frame::GlobalEventBroadcaster;
using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY;
/** === end UNO using === **/ /** === end UNO using === **/
namespace csslang = ::com::sun::star::lang; namespace csslang = ::com::sun::star::lang;
@@ -210,10 +213,7 @@ namespace basctl
{ {
Reference< com::sun::star::uno::XComponentContext > aContext( Reference< com::sun::star::uno::XComponentContext > aContext(
comphelper::getProcessComponentContext() ); comphelper::getProcessComponentContext() );
xBroadcaster.set( xBroadcaster.set( GlobalEventBroadcaster::create(aContext), UNO_QUERY_THROW );
aContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.frame.GlobalEventBroadcaster", aContext ),
UNO_QUERY_THROW );
} }
void ( SAL_CALL XEventBroadcaster::*listenerAction )( const Reference< XEventListener >& ) = void ( SAL_CALL XEventBroadcaster::*listenerAction )( const Reference< XEventListener >& ) =

View File

@@ -29,6 +29,7 @@
#include <svtools/svmedit.hxx> #include <svtools/svmedit.hxx>
#include <tools/diagnose_ex.h> #include <tools/diagnose_ex.h>
#include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/document/XEventsSupplier.hpp>
#include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
#include <com/sun/star/frame/XModuleManager.hpp> #include <com/sun/star/frame/XModuleManager.hpp>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
@@ -91,20 +92,15 @@ SvxEventConfigPage::SvxEventConfigPage( Window *pParent, const SfxItemSet& rSet,
uno::Reference< document::XEventsSupplier > xSupplier; uno::Reference< document::XEventsSupplier > xSupplier;
xSupplier = uno::Reference< document::XEventsSupplier > ( xSupplier = uno::Reference< document::XEventsSupplier > (
::comphelper::getProcessServiceFactory()->createInstance( frame::GlobalEventBroadcaster::create(::comphelper::getProcessComponentContext()),
OUString(RTL_CONSTASCII_USTRINGPARAM( uno::UNO_QUERY_THROW );
"com.sun.star.frame.GlobalEventBroadcaster" )) ),
uno::UNO_QUERY );
sal_uInt16 nPos(0); sal_uInt16 nPos(0);
if ( xSupplier.is() ) m_xAppEvents = xSupplier->getEvents();
{ nPos = aSaveInListBox.InsertEntry(
m_xAppEvents = xSupplier->getEvents(); utl::ConfigManager::getProductName() );
nPos = aSaveInListBox.InsertEntry( aSaveInListBox.SetEntryData( nPos, new bool(true) );
utl::ConfigManager::getProductName() ); aSaveInListBox.SelectEntryPos( nPos, sal_True );
aSaveInListBox.SetEntryData( nPos, new bool(true) );
aSaveInListBox.SelectEntryPos( nPos, sal_True );
}
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

View File

@@ -43,6 +43,7 @@
#include "migration.hxx" #include "migration.hxx"
#include <svtools/javacontext.hxx> #include <svtools/javacontext.hxx>
#include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
#include <com/sun/star/frame/XSessionManagerListener.hpp> #include <com/sun/star/frame/XSessionManagerListener.hpp>
#include <com/sun/star/frame/XSynchronousDispatch.hpp> #include <com/sun/star/frame/XSynchronousDispatch.hpp>
#include <com/sun/star/document/CorruptedFilterConfigurationException.hpp> #include <com/sun/star/document/CorruptedFilterConfigurationException.hpp>
@@ -1531,8 +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 >
( xSMgr->createInstance( ( css::frame::GlobalEventBroadcaster::create(comphelper::ComponentContext(xSMgr).getUNOContext()), UNO_QUERY );
rtl::OUString( "com.sun.star.frame.GlobalEventBroadcaster" ) ), UNO_QUERY );
/* 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

View File

@@ -36,6 +36,7 @@
#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/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/GraphicProvider.hpp>
#include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <com/sun/star/task/XJob.hpp> #include <com/sun/star/task/XJob.hpp>
@@ -255,17 +256,8 @@ UpdateCheckUI::getGlobalEventBroadcaster() const throw (uno::RuntimeException)
UNISTRING( "UpdateCheckUI: empty component context" ), UNISTRING( "UpdateCheckUI: empty component context" ),
uno::Reference< uno::XInterface >() ); uno::Reference< uno::XInterface >() );
uno::Reference< lang::XMultiComponentFactory > xServiceManager(m_xContext->getServiceManager());
if( !xServiceManager.is() )
throw uno::RuntimeException(
UNISTRING( "UpdateCheckUI: unable to obtain service manager from component context" ),
uno::Reference< uno::XInterface >() );
return uno::Reference<document::XEventBroadcaster> ( return uno::Reference<document::XEventBroadcaster> (
xServiceManager->createInstanceWithContext( frame::GlobalEventBroadcaster::create(m_xContext),
UNISTRING( "com.sun.star.frame.GlobalEventBroadcaster" ),
m_xContext),
uno::UNO_QUERY_THROW); uno::UNO_QUERY_THROW);
} }

View File

@@ -48,6 +48,7 @@
#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>
@@ -249,7 +250,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(m_xSMGR); /* LateInitListener* pLateInit = */ new LateInitListener(comphelper::ComponentContext(m_xSMGR).getUNOContext());
} }
// ------------------------------------------ // ------------------------------------------

View File

@@ -34,6 +34,8 @@
#include "lateinitlistener.hxx" #include "lateinitlistener.hxx"
#include "lateinitthread.hxx" #include "lateinitthread.hxx"
#include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
namespace filter{ namespace filter{
namespace config{ namespace config{
@@ -43,9 +45,8 @@ namespace css = ::com::sun::star;
LateInitListener::LateInitListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR) LateInitListener::LateInitListener(const css::uno::Reference< css::uno::XComponentContext >& rxContext)
: BaseLock( ) : BaseLock( )
, m_xSMGR (xSMGR)
{ {
// important to do so ... // important to do so ...
// Otherwise the temp. reference to ourselves // Otherwise the temp. reference to ourselves
@@ -53,7 +54,7 @@ LateInitListener::LateInitListener(const css::uno::Reference< css::lang::XMultiS
osl_atomic_increment( &m_refCount ); osl_atomic_increment( &m_refCount );
m_xBroadcaster = css::uno::Reference< css::document::XEventBroadcaster >( m_xBroadcaster = css::uno::Reference< css::document::XEventBroadcaster >(
m_xSMGR->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.GlobalEventBroadcaster" ))), css::frame::GlobalEventBroadcaster::create(rxContext),
css::uno::UNO_QUERY_THROW); css::uno::UNO_QUERY_THROW);
m_xBroadcaster->addEventListener(static_cast< css::document::XEventListener* >(this)); m_xBroadcaster->addEventListener(static_cast< css::document::XEventListener* >(this));

View File

@@ -52,10 +52,6 @@ class LateInitListener : public BaseLock // must be the first one to guarantee r
private: private:
/** @short reference to an uno service manager, which can be used
to create own needed services. */
css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
/** @short reference to the global event broadcaster, which is usde to find /** @short reference to the global event broadcaster, which is usde to find
out, when the first office document was opened successfully. */ out, when the first office document was opened successfully. */
css::uno::Reference< css::document::XEventBroadcaster > m_xBroadcaster; css::uno::Reference< css::document::XEventBroadcaster > m_xBroadcaster;
@@ -75,11 +71,11 @@ class LateInitListener : public BaseLock // must be the first one to guarantee r
on the global event broadcaster to get the information, when on the global event broadcaster to get the information, when
loading of the first document was finished. loading of the first document was finished.
@param xSMGR @param rxContext
reference to a service manager, which can be used to create reference to a component context, which can be used to create
own needed uno services. own needed uno services.
*/ */
LateInitListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR); LateInitListener(const css::uno::Reference< css::uno::XComponentContext >& rxContext);
//--------------------------------------- //---------------------------------------

View File

@@ -26,27 +26,29 @@
* *
************************************************************************/ ************************************************************************/
#include <com/sun/star/frame/XConfigManager.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/document/XGraphicObjectResolver.hpp> #include <com/sun/star/document/XGraphicObjectResolver.hpp>
#include <com/sun/star/document/XEmbeddedObjectResolver.hpp> #include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
#include <com/sun/star/xml/XImportFilter.hpp> #include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
#include <com/sun/star/xml/XExportFilter.hpp> #include <com/sun/star/frame/XConfigManager.hpp>
#include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/frame/XComponentLoader.hpp>
#include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/io/XActiveDataSource.hpp>
#include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/document/XFilter.hpp>
#include <comphelper/oslfile2streamwrap.hxx>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/system/SystemShellExecute.hpp> #include <com/sun/star/system/SystemShellExecute.hpp>
#include <com/sun/star/system/SystemShellExecuteFlags.hpp> #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/xml/XImportFilter.hpp>
#include <com/sun/star/xml/XExportFilter.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include "com/sun/star/ui/dialogs/TemplateDescription.hpp" #include <comphelper/componentcontext.hxx>
#include <comphelper/oslfile2streamwrap.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <sfx2/filedlghelper.hxx> #include <sfx2/filedlghelper.hxx>
@@ -186,12 +188,9 @@ XMLFilterTestDialog::XMLFilterTestDialog( Window* pParent, ResMgr& rResMgr, cons
if( xCfgMgr.is() ) if( xCfgMgr.is() )
sDTDPath = xCfgMgr->substituteVariables( sDTDPath ); sDTDPath = xCfgMgr->substituteVariables( sDTDPath );
mxGlobalBroadcaster = Reference < XEventBroadcaster >::query( mxMSF->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.GlobalEventBroadcaster" )) ) ); mxGlobalBroadcaster = Reference < XEventBroadcaster >( GlobalEventBroadcaster::create(comphelper::ComponentContext(mxMSF).getUNOContext()), UNO_QUERY_THROW );
if ( mxGlobalBroadcaster.is() ) mxGlobalEventListener = new GlobalEventListenerImpl( this );
{ mxGlobalBroadcaster->addEventListener( mxGlobalEventListener );
mxGlobalEventListener = new GlobalEventListenerImpl( this );
mxGlobalBroadcaster->addEventListener( mxGlobalEventListener );
}
} }
catch( const Exception& ) catch( const Exception& )
{ {

View File

@@ -133,6 +133,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/frame,\
DispatchHelper \ DispatchHelper \
DispatchRecorderSupplier \ DispatchRecorderSupplier \
DocumentTemplates \ DocumentTemplates \
GlobalEventBroadcaster \
MediaTypeDetectionHelper \ MediaTypeDetectionHelper \
ModuleManager \ ModuleManager \
UICommandDescription \ UICommandDescription \
@@ -814,7 +815,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/frame,\
FrameLoader \ FrameLoader \
FrameLoaderFactory \ FrameLoaderFactory \
FramesContainer \ FramesContainer \
GlobalEventBroadcaster \
LayoutManager \ LayoutManager \
PopupMenuController \ PopupMenuController \
PopupMenuControllerFactory \ PopupMenuControllerFactory \
@@ -2522,6 +2522,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/frame,\
XFrameSetModel \ XFrameSetModel \
XFrames \ XFrames \
XFramesSupplier \ XFramesSupplier \
XGlobalEventBroadcaster \
XInterceptorInfo \ XInterceptorInfo \
XLayoutManager \ XLayoutManager \
XLayoutManagerEventBroadcaster \ XLayoutManagerEventBroadcaster \

View File

@@ -19,11 +19,10 @@
#ifndef __com_sun_star_frame_GlobalEventBroadcaster_idl__ #ifndef __com_sun_star_frame_GlobalEventBroadcaster_idl__
#define __com_sun_star_frame_GlobalEventBroadcaster_idl__ #define __com_sun_star_frame_GlobalEventBroadcaster_idl__
#include <com/sun/star/document/XEventBroadcaster.idl> #include <com/sun/star/frame/XGlobalEventBroadcaster.idl>
#include <com/sun/star/document/XEventsSupplier.idl>
module com { module sun { module star { module frame { module com { module sun { module star { module frame {
/** /**
This service offers the document event functionality that can be found at any This service offers the document event functionality that can be found at any
@@ -32,17 +31,7 @@
documents. documents.
*/ */
service GlobalEventBroadcaster service GlobalEventBroadcaster : XGlobalEventBroadcaster;
{
/** makes it possible to register listeners which are called whenever
a document event occurs in any document
*/
interface ::com::sun::star::document::XEventsSupplier;
/** access to bound event handlers
*/
interface ::com::sun::star::document::XEventBroadcaster;
};
}; }; }; }; }; }; }; };

View File

@@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef __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>
module com { module sun { module star { module frame {
/**
Provides a unified interface for the GlobalEventBroadcaster service to implement.
*/
interface XGlobalEventBroadcaster
{
/** makes it possible to register listeners which are called whenever
a document event occurs in any document
*/
interface ::com::sun::star::document::XEventsSupplier;
/** access to bound event handlers
*/
interface ::com::sun::star::document::XEventBroadcaster;
interface ::com::sun::star::container::XSet;
interface ::com::sun::star::document::XEventListener;
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -21,6 +21,7 @@
#include <sfx2/app.hxx> #include <sfx2/app.hxx>
#include <com/sun/star/frame/XTerminateListener.hpp> #include <com/sun/star/frame/XTerminateListener.hpp>
#include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
#include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -111,14 +112,12 @@ void SAL_CALL SfxTerminateListener_Impl::notifyTermination( const EventObject& a
pApp->Get_Impl()->pAppDispatch->ReleaseAll(); pApp->Get_Impl()->pAppDispatch->ReleaseAll();
pApp->Get_Impl()->pAppDispatch->release(); pApp->Get_Impl()->pAppDispatch->release();
css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory(); css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
css::uno::Reference< css::document::XEventListener > xGlobalBroadcaster(xSMGR->createInstance("com.sun.star.frame.GlobalEventBroadcaster"), css::uno::UNO_QUERY); css::uno::Reference< css::frame::XGlobalEventBroadcaster > xGlobalBroadcaster = css::frame::GlobalEventBroadcaster::create(xContext);
if (xGlobalBroadcaster.is())
{ css::document::EventObject aEvent2;
css::document::EventObject aEvent2; aEvent2.EventName = "OnCloseApp";
aEvent2.EventName = "OnCloseApp"; xGlobalBroadcaster->notifyEvent(aEvent2);
xGlobalBroadcaster->notifyEvent(aEvent2);
}
delete pApp; delete pApp;
Application::Quit(); Application::Quit();

View File

@@ -44,6 +44,7 @@
#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/container/XNameReplace.hpp> #include <com/sun/star/container/XNameReplace.hpp>
#include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/document/XEventsSupplier.hpp>
#include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
#include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Reference.hxx>
@@ -231,8 +232,8 @@ void PropagateEvent_Impl( SfxObjectShell *pDoc, rtl::OUString aEventName, const
else else
{ {
xSupplier = uno::Reference < document::XEventsSupplier > xSupplier = uno::Reference < document::XEventsSupplier >
( ::comphelper::getProcessServiceFactory()->createInstance( ( frame::GlobalEventBroadcaster::create(::comphelper::getProcessComponentContext()),
rtl::OUString("com.sun.star.frame.GlobalEventBroadcaster")), uno::UNO_QUERY ); uno::UNO_QUERY );
} }
if ( xSupplier.is() ) if ( xSupplier.is() )

View File

@@ -25,6 +25,7 @@
#include <svl/eitem.hxx> #include <svl/eitem.hxx>
#include <svl/stritem.hxx> #include <svl/stritem.hxx>
#include <svl/intitem.hxx> #include <svl/intitem.hxx>
#include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
#include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/XFrame.hpp>
@@ -147,20 +148,16 @@ void impl_addToModelCollection(const css::uno::Reference< css::frame::XModel >&
if (!xModel.is()) if (!xModel.is())
return; return;
css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory(); css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
css::uno::Reference< css::container::XSet > xModelCollection( css::uno::Reference< css::frame::XGlobalEventBroadcaster > xModelCollection =
xSMGR->createInstance(::rtl::OUString("com.sun.star.frame.GlobalEventBroadcaster")), css::frame::GlobalEventBroadcaster::create(xContext);
css::uno::UNO_QUERY); try
if (xModelCollection.is())
{ {
try xModelCollection->insert(css::uno::makeAny(xModel));
{ }
xModelCollection->insert(css::uno::makeAny(xModel)); catch ( uno::Exception& )
} {
catch ( uno::Exception& ) OSL_FAIL( "The document seems to be in the collection already!\n" );
{
OSL_FAIL( "The document seems to be in the collection already!\n" );
}
} }
} }

View File

@@ -28,6 +28,7 @@
#include <com/sun/star/document/XDocumentEventBroadcaster.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/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/task/XJobExecutor.hpp> #include <com/sun/star/task/XJobExecutor.hpp>
#include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Reference.hxx>
@@ -39,7 +40,6 @@
#include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implbase4.hxx> #include <cppuhelper/implbase4.hxx>
#include <cppuhelper/implbase7.hxx>
#include <comphelper/sequenceashashmap.hxx> #include <comphelper/sequenceashashmap.hxx>
#include <comphelper/sequenceasvector.hxx> #include <comphelper/sequenceasvector.hxx>
#include <sfx2/sfxuno.hxx> #include <sfx2/sfxuno.hxx>
@@ -173,13 +173,11 @@ class ModelCollectionEnumeration : public ModelCollectionMutexBase
//============================================================================= //=============================================================================
class SfxGlobalEvents_Impl : public ModelCollectionMutexBase class SfxGlobalEvents_Impl : public ModelCollectionMutexBase
, public ::cppu::WeakImplHelper7< ::com::sun::star::lang::XServiceInfo , public ::cppu::WeakImplHelper4< ::com::sun::star::lang::XServiceInfo
, ::com::sun::star::document::XEventsSupplier , ::com::sun::star::frame::XGlobalEventBroadcaster
, ::com::sun::star::document::XEventBroadcaster
, ::com::sun::star::document::XDocumentEventBroadcaster , ::com::sun::star::document::XDocumentEventBroadcaster
, ::com::sun::star::document::XEventListener
, ::com::sun::star::document::XDocumentEventListener , ::com::sun::star::document::XDocumentEventListener
, ::com::sun::star::container::XSet > >
{ {
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMGR; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMGR;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > m_xEvents; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > m_xEvents;

View File

@@ -39,12 +39,12 @@
#include "comphelper/documentinfo.hxx" #include "comphelper/documentinfo.hxx"
#include "comphelper/namedvaluecollection.hxx" #include "comphelper/namedvaluecollection.hxx"
#include "comphelper/processfactory.hxx"
#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/container/XEnumerationAccess.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/XStorable.hpp" #include "com/sun/star/frame/XStorable.hpp"
#include "com/sun/star/frame/ModuleManager.hpp" #include "com/sun/star/frame/ModuleManager.hpp"
#include "com/sun/star/lang/DisposedException.hpp" #include "com/sun/star/lang/DisposedException.hpp"
@@ -112,10 +112,10 @@ void SAL_CALL OfficeDocumentsManager::OfficeDocumentsCloseListener::disposing(
//========================================================================= //=========================================================================
OfficeDocumentsManager::OfficeDocumentsManager( OfficeDocumentsManager::OfficeDocumentsManager(
const uno::Reference< lang::XMultiServiceFactory > & xSMgr, const uno::Reference< uno::XComponentContext > & rxContext,
OfficeDocumentsEventListener * pDocEventListener ) OfficeDocumentsEventListener * pDocEventListener )
: m_xSMgr( xSMgr ), : m_xContext( rxContext ),
m_xDocEvtNotifier( createDocumentEventNotifier( xSMgr ) ), m_xDocEvtNotifier( createDocumentEventNotifier( rxContext ) ),
m_pDocEventListener( pDocEventListener ), m_pDocEventListener( pDocEventListener ),
m_xDocCloseListener( new OfficeDocumentsCloseListener( this ) ) m_xDocCloseListener( new OfficeDocumentsCloseListener( this ) )
{ {
@@ -460,15 +460,12 @@ void SAL_CALL OfficeDocumentsManager::disposing(
// static // static
uno::Reference< document::XEventBroadcaster > uno::Reference< document::XEventBroadcaster >
OfficeDocumentsManager::createDocumentEventNotifier( OfficeDocumentsManager::createDocumentEventNotifier(
const uno::Reference< lang::XMultiServiceFactory >& rXSMgr ) const uno::Reference< uno::XComponentContext >& rxContext )
{ {
uno::Reference< uno::XInterface > xIfc; uno::Reference< uno::XInterface > xIfc;
try try
{ {
xIfc = rXSMgr->createInstance( xIfc = frame::GlobalEventBroadcaster::create(rxContext);
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.frame.GlobalEventBroadcaster" ) ) );
} }
catch ( uno::Exception const & ) catch ( uno::Exception const & )
{ {
@@ -702,8 +699,7 @@ bool OfficeDocumentsManager::isBasicIDE(
{ {
try try
{ {
m_xModuleMgr = frame::ModuleManager::create( m_xModuleMgr = frame::ModuleManager::create( m_xContext );
comphelper::getComponentContext(m_xSMgr));
} }
catch ( uno::Exception const & ) catch ( uno::Exception const & )
{ {

View File

@@ -123,7 +123,7 @@ namespace tdoc_ucp {
public: public:
OfficeDocumentsManager( OfficeDocumentsManager(
const com::sun::star::uno::Reference< const com::sun::star::uno::Reference<
com::sun::star::lang::XMultiServiceFactory > & xSMgr, com::sun::star::uno::XComponentContext > & rxContext,
OfficeDocumentsEventListener * pDocEventListener ); OfficeDocumentsEventListener * pDocEventListener );
virtual ~OfficeDocumentsManager(); virtual ~OfficeDocumentsManager();
@@ -162,7 +162,7 @@ namespace tdoc_ucp {
com::sun::star::document::XEventBroadcaster > com::sun::star::document::XEventBroadcaster >
createDocumentEventNotifier( createDocumentEventNotifier(
const com::sun::star::uno::Reference< const com::sun::star::uno::Reference<
com::sun::star::lang::XMultiServiceFactory >& rXSMgr ); com::sun::star::uno::XComponentContext >& rxContext );
void buildDocumentsList(); void buildDocumentsList();
@@ -193,7 +193,7 @@ namespace tdoc_ucp {
osl::Mutex m_aMtx; osl::Mutex m_aMtx;
com::sun::star::uno::Reference< com::sun::star::uno::Reference<
com::sun::star::lang::XMultiServiceFactory > m_xSMgr; 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::document::XEventBroadcaster > m_xDocEvtNotifier;
com::sun::star::uno::Reference< com::sun::star::uno::Reference<

View File

@@ -38,6 +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 "ucbhelper/contentidentifier.hxx" #include "ucbhelper/contentidentifier.hxx"
#include "tdoc_provider.hxx" #include "tdoc_provider.hxx"
@@ -60,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( xSMgr, this ) ), m_xDocsMgr( new OfficeDocumentsManager( comphelper::ComponentContext(xSMgr).getUNOContext(), this ) ),
m_xStgElemFac( new StorageElementFactory( xSMgr, m_xDocsMgr ) ) m_xStgElemFac( new StorageElementFactory( xSMgr, m_xDocsMgr ) )
{ {
} }