summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-09-07 15:14:55 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-09-27 10:30:42 +0200
commitcd693ff598bbabba66d8ca353a32bcbd81a5b12b (patch)
tree525e9fe8fdd44e6ccba4f61e999aeb1332d2b896 /sfx2
parent526e007bb6340e2c4a2cb96f5612ba268fcd5583 (diff)
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
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/appinit.cxx15
-rw-r--r--sfx2/source/config/evntconf.cxx5
-rw-r--r--sfx2/source/doc/objstor.cxx23
-rw-r--r--sfx2/source/inc/eventsupplier.hxx10
4 files changed, 24 insertions, 29 deletions
diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx
index d5f776b6e384..0a778788b7fc 100644
--- a/sfx2/source/appl/appinit.cxx
+++ b/sfx2/source/appl/appinit.cxx
@@ -21,6 +21,7 @@
#include <sfx2/app.hxx>
#include <com/sun/star/frame/XTerminateListener.hpp>
#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/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->release();
- css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
- css::uno::Reference< css::document::XEventListener > xGlobalBroadcaster(xSMGR->createInstance("com.sun.star.frame.GlobalEventBroadcaster"), css::uno::UNO_QUERY);
- if (xGlobalBroadcaster.is())
- {
- css::document::EventObject aEvent2;
- aEvent2.EventName = "OnCloseApp";
- xGlobalBroadcaster->notifyEvent(aEvent2);
- }
+ css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+ css::uno::Reference< css::frame::XGlobalEventBroadcaster > xGlobalBroadcaster = css::frame::GlobalEventBroadcaster::create(xContext);
+
+ css::document::EventObject aEvent2;
+ aEvent2.EventName = "OnCloseApp";
+ xGlobalBroadcaster->notifyEvent(aEvent2);
delete pApp;
Application::Quit();
diff --git a/sfx2/source/config/evntconf.cxx b/sfx2/source/config/evntconf.cxx
index f5aee6c35eb2..22ef4d0acf01 100644
--- a/sfx2/source/config/evntconf.cxx
+++ b/sfx2/source/config/evntconf.cxx
@@ -44,6 +44,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/container/XNameReplace.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/Reference.hxx>
@@ -231,8 +232,8 @@ void PropagateEvent_Impl( SfxObjectShell *pDoc, rtl::OUString aEventName, const
else
{
xSupplier = uno::Reference < document::XEventsSupplier >
- ( ::comphelper::getProcessServiceFactory()->createInstance(
- rtl::OUString("com.sun.star.frame.GlobalEventBroadcaster")), uno::UNO_QUERY );
+ ( frame::GlobalEventBroadcaster::create(::comphelper::getProcessComponentContext()),
+ uno::UNO_QUERY );
}
if ( xSupplier.is() )
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 9e7407a7ea65..b9b5f0480551 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -25,6 +25,7 @@
#include <svl/eitem.hxx>
#include <svl/stritem.hxx>
#include <svl/intitem.hxx>
+#include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/frame/XModel.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())
return;
- css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
- css::uno::Reference< css::container::XSet > xModelCollection(
- xSMGR->createInstance(::rtl::OUString("com.sun.star.frame.GlobalEventBroadcaster")),
- css::uno::UNO_QUERY);
- if (xModelCollection.is())
+ css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+ css::uno::Reference< css::frame::XGlobalEventBroadcaster > xModelCollection =
+ css::frame::GlobalEventBroadcaster::create(xContext);
+ try
{
- try
- {
- xModelCollection->insert(css::uno::makeAny(xModel));
- }
- catch ( uno::Exception& )
- {
- OSL_FAIL( "The document seems to be in the collection already!\n" );
- }
+ xModelCollection->insert(css::uno::makeAny(xModel));
+ }
+ catch ( uno::Exception& )
+ {
+ OSL_FAIL( "The document seems to be in the collection already!\n" );
}
}
diff --git a/sfx2/source/inc/eventsupplier.hxx b/sfx2/source/inc/eventsupplier.hxx
index 9b2793a33f06..6bd1f284ee36 100644
--- a/sfx2/source/inc/eventsupplier.hxx
+++ b/sfx2/source/inc/eventsupplier.hxx
@@ -28,6 +28,7 @@
#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
#include <com/sun/star/document/XDocumentEventListener.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/task/XJobExecutor.hpp>
#include <com/sun/star/uno/Reference.hxx>
@@ -39,7 +40,6 @@
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implbase4.hxx>
-#include <cppuhelper/implbase7.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/sequenceasvector.hxx>
#include <sfx2/sfxuno.hxx>
@@ -173,13 +173,11 @@ class ModelCollectionEnumeration : public ModelCollectionMutexBase
//=============================================================================
class SfxGlobalEvents_Impl : public ModelCollectionMutexBase
- , public ::cppu::WeakImplHelper7< ::com::sun::star::lang::XServiceInfo
- , ::com::sun::star::document::XEventsSupplier
- , ::com::sun::star::document::XEventBroadcaster
+ , public ::cppu::WeakImplHelper4< ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::frame::XGlobalEventBroadcaster
, ::com::sun::star::document::XDocumentEventBroadcaster
- , ::com::sun::star::document::XEventListener
, ::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::container::XNameReplace > m_xEvents;