summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-10-12 08:57:24 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-10-23 11:45:47 +0200
commit5aa2cd1d3f85958917f47523ee430af11ac1751d (patch)
tree0a5e62c012841e51410500c5b6a52db1938c5ed3 /framework
parentf4776bf465ee682f65d1e978b031c928d9d310a5 (diff)
fdo#46808, use service constructor for uri::UriReferenceFactory
Change-Id: I4e72bf5880fa28cb96d93ede7730a63220af7fa6
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/dispatch/popupmenudispatcher.hxx4
-rw-r--r--framework/source/dispatch/popupmenudispatcher.cxx75
2 files changed, 63 insertions, 16 deletions
diff --git a/framework/inc/dispatch/popupmenudispatcher.hxx b/framework/inc/dispatch/popupmenudispatcher.hxx
index b534a0797d13..f1ee756e09cc 100644
--- a/framework/inc/dispatch/popupmenudispatcher.hxx
+++ b/framework/inc/dispatch/popupmenudispatcher.hxx
@@ -94,7 +94,7 @@ class PopupMenuDispatcher : // interfaces
public:
// constructor / destructor
- PopupMenuDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
+ PopupMenuDispatcher( const css::uno::Reference< css::uno::XComponentContext >& xContext );
// XInterface, XTypeProvider, XServiceInfo
FWK_DECLARE_XINTERFACE
@@ -146,7 +146,7 @@ class PopupMenuDispatcher : // interfaces
css::uno::WeakReference< css::frame::XFrame > m_xWeakFrame ; /// css::uno::WeakReference to frame (Don't use a hard css::uno::Reference. Owner can't delete us then!)
css::uno::Reference< css::container::XNameAccess > m_xPopupCtrlQuery ; /// reference to query for popup controller
css::uno::Reference< css::uri::XUriReferenceFactory > m_xUriRefFactory ; /// reference to the uri reference factory
- css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// factory shared with our owner to create new services!
+ css::uno::Reference< css::uno::XComponentContext > m_xContext ; /// factory shared with our owner to create new services!
IMPL_ListenerHashContainer m_aListenerContainer; /// hash table for listener at specified URLs
sal_Bool m_bAlreadyDisposed ; /// Protection against multiple disposing calls.
sal_Bool m_bActivateListener ; /// dispatcher is listener for frame activation
diff --git a/framework/source/dispatch/popupmenudispatcher.cxx b/framework/source/dispatch/popupmenudispatcher.cxx
index 9e7b210900fc..c13e80f47c7d 100644
--- a/framework/source/dispatch/popupmenudispatcher.cxx
+++ b/framework/source/dispatch/popupmenudispatcher.cxx
@@ -43,7 +43,9 @@
#include <com/sun/star/lang/WrappedTargetException.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/uri/UriReferenceFactory.hpp>
+#include <comphelper/componentcontext.hxx>
#include <ucbhelper/content.hxx>
#include <osl/mutex.hxx>
#include <rtl/ustrbuf.hxx>
@@ -70,12 +72,12 @@ const sal_Int32 PROTOCOL_LENGTH = 19;
// constructor
//*****************************************************************************************************************
PopupMenuDispatcher::PopupMenuDispatcher(
- const uno::Reference< XMultiServiceFactory >& xFactory )
+ const uno::Reference< XComponentContext >& xContext )
// Init baseclasses first
: ThreadHelpBase ( &Application::GetSolarMutex() )
, OWeakObject ( )
// Init member
- , m_xFactory ( xFactory )
+ , m_xContext ( xContext )
, m_aListenerContainer ( m_aLock.getShareableOslMutex() )
, m_bAlreadyDisposed ( sal_False )
, m_bActivateListener ( sal_False )
@@ -116,10 +118,61 @@ DEFINE_XTYPEPROVIDER_7 ( PopupMenuDispatcher ,
XFrameActionListener
)
-DEFINE_XSERVICEINFO_MULTISERVICE( PopupMenuDispatcher ,
- ::cppu::OWeakObject ,
- SERVICENAME_PROTOCOLHANDLER ,
- IMPLEMENTATIONNAME_POPUPMENUDISPATCHER )
+::rtl::OUString SAL_CALL PopupMenuDispatcher::getImplementationName() throw( css::uno::RuntimeException )
+{
+ return impl_getStaticImplementationName();
+}
+
+sal_Bool SAL_CALL PopupMenuDispatcher::supportsService( const ::rtl::OUString& sServiceName )
+ throw( css::uno::RuntimeException )
+{
+ return ::comphelper::findValue(getSupportedServiceNames(), sServiceName, sal_True).getLength() != 0;
+}
+
+css::uno::Sequence< ::rtl::OUString > SAL_CALL PopupMenuDispatcher::getSupportedServiceNames()
+ throw( css::uno::RuntimeException )
+{
+ return impl_getStaticSupportedServiceNames();
+}
+
+css::uno::Sequence< ::rtl::OUString > PopupMenuDispatcher::impl_getStaticSupportedServiceNames()
+{
+ css::uno::Sequence< ::rtl::OUString > seqServiceNames( 1 );
+ seqServiceNames.getArray() [0] = SERVICENAME_PROTOCOLHANDLER;
+ return seqServiceNames;
+}
+
+::rtl::OUString PopupMenuDispatcher::impl_getStaticImplementationName()
+{
+ return IMPLEMENTATIONNAME_POPUPMENUDISPATCHER;
+}
+
+css::uno::Reference< css::uno::XInterface >
+SAL_CALL PopupMenuDispatcher::impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager )
+throw( css::uno::Exception )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework","Ocke.Janssen@sun.com",U2B(IMPLEMENTATIONNAME_POPUPMENUDISPATCHER).getStr());
+ /* create new instance of service */
+ PopupMenuDispatcher* pClass = new PopupMenuDispatcher( comphelper::getComponentContext(xServiceManager) );
+ /* hold it alive by increasing his ref count!!! */
+ css::uno::Reference< css::uno::XInterface > xService( static_cast< ::cppu::OWeakObject* >(pClass), css::uno::UNO_QUERY );
+ /* initialize new service instance ... he can use his own refcount ... we hold it! */
+ pClass->impl_initService();
+ /* return new created service as reference */
+ return xService;
+}
+
+css::uno::Reference< css::lang::XSingleServiceFactory >
+PopupMenuDispatcher::impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager )
+{
+ css::uno::Reference< css::lang::XSingleServiceFactory > xReturn (
+ cppu::createSingleFactory ( xServiceManager,
+ PopupMenuDispatcher::impl_getStaticImplementationName() ,
+ PopupMenuDispatcher::impl_createInstance ,
+ PopupMenuDispatcher::impl_getStaticSupportedServiceNames() )
+ );
+ return xReturn;
+}
DEFINE_INIT_SERVICE(PopupMenuDispatcher,
{
@@ -333,7 +386,7 @@ SAL_CALL PopupMenuDispatcher::disposing( const EventObject& ) throw( RuntimeExce
}
// Forget our factory.
- m_xFactory = uno::Reference< XMultiServiceFactory >();
+ m_xContext = uno::Reference< XComponentContext >();
}
}
@@ -379,13 +432,7 @@ void PopupMenuDispatcher::impl_CreateUriRefFactory()
{
if ( !m_xUriRefFactory.is() )
{
- rtl::OUString aUriRefFactoryService(
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.uri.UriReferenceFactory" ));
-
- m_xUriRefFactory = css::uno::Reference< css::uri::XUriReferenceFactory >(
- m_xFactory->createInstance( aUriRefFactoryService ),
- css::uno::UNO_QUERY);
-
+ m_xUriRefFactory = css::uri::UriReferenceFactory::create( m_xContext );
}
}