summaryrefslogtreecommitdiff
path: root/uui
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-10-02 15:03:12 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-10-04 14:42:52 +0200
commitc25cb8a641723ab098980bb842caf75c0dc9b059 (patch)
treee264e2727309789e06147a7275b91abd05f9fcff /uui
parent0f3f9cb63056715845d9c3565bde69470c73efb2 (diff)
fdo#46808, Adapt task::InteractionHandler UNO service to new style
Since we don't need to expose XInitialisation, we can make the new-style service implement XInteractionHandler2. Change-Id: Ib27beed1c12df17592c6472d6f58c233d2c41558
Diffstat (limited to 'uui')
-rw-r--r--uui/source/iahndl.cxx55
-rw-r--r--uui/source/iahndl.hxx8
-rw-r--r--uui/source/interactionhandler.cxx18
-rw-r--r--uui/source/interactionhandler.hxx6
4 files changed, 37 insertions, 50 deletions
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx
index 127f7d42737c..e09256d9027e 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -34,6 +34,7 @@
#include "com/sun/star/task/ErrorCodeIOException.hpp"
#include "com/sun/star/task/ErrorCodeRequest.hpp"
#include "com/sun/star/task/FutureDocumentVersionProductUpdateRequest.hpp"
+#include "com/sun/star/task/InteractionHandler.hpp"
#include "com/sun/star/task/XInteractionAbort.hpp"
#include "com/sun/star/task/XInteractionApprove.hpp"
#include "com/sun/star/task/XInteractionAskLater.hpp"
@@ -72,6 +73,7 @@
#include "vcl/svapp.hxx"
#include "unotools/configmgr.hxx"
#include "toolkit/helper/vclunohelper.hxx"
+#include "comphelper/processfactory.hxx"
#include "comphelper/namedvaluecollection.hxx"
#include "typelib/typedescription.hxx"
#include "unotools/confignode.hxx"
@@ -99,6 +101,7 @@ using ::com::sun::star::task::FutureDocumentVersionProductUpdateRequest;
using ::com::sun::star::uno::XInterface;
using ::com::sun::star::lang::XInitialization;
using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::task::InteractionHandler;
using ::com::sun::star::task::XInteractionHandler2;
using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::Any;
@@ -129,10 +132,12 @@ public:
UUIInteractionHelper::UUIInteractionHelper(
uno::Reference< lang::XMultiServiceFactory > const & rServiceFactory,
- uno::Sequence< uno::Any > const & rArguments)
+ uno::Reference< awt::XWindow > const & rxWindowParam,
+ const OUString & rContextParam)
SAL_THROW(()):
m_xServiceFactory(rServiceFactory),
- m_aProperties(rArguments)
+ m_xWindowParam(rxWindowParam),
+ m_aContextParam(rContextParam)
{
}
@@ -1092,58 +1097,24 @@ uno::Reference< awt::XWindow>
UUIInteractionHelper::getParentXWindow() const
SAL_THROW(())
{
- osl::MutexGuard aGuard(m_aPropertyMutex);
- ::comphelper::NamedValueCollection aProperties( m_aProperties );
- if ( aProperties.has( "Parent" ) )
- {
- uno::Reference< awt::XWindow > xWindow;
- OSL_VERIFY( aProperties.get( "Parent" ) >>= xWindow );
- return xWindow;
- }
- return 0;
+ return m_xWindowParam;
}
rtl::OUString
UUIInteractionHelper::getContextProperty()
SAL_THROW(())
{
- osl::MutexGuard aGuard(m_aPropertyMutex);
- for (sal_Int32 i = 0; i < m_aProperties.getLength(); ++i)
- {
- beans::PropertyValue aProperty;
- if ((m_aProperties[i] >>= aProperty) && aProperty.Name == "Context" )
- {
- rtl::OUString aContext;
- aProperty.Value >>= aContext;
- return aContext;
- }
- }
- return rtl::OUString();
+ return m_aContextParam;
}
uno::Reference< task::XInteractionHandler >
UUIInteractionHelper::getInteractionHandler()
SAL_THROW((uno::RuntimeException))
{
- uno::Reference< task::XInteractionHandler > xIH;
- try
- {
- xIH.set(m_xServiceFactory->createInstanceWithArguments(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.task.InteractionHandler")),
- m_aProperties),
- uno::UNO_QUERY);
- }
- catch (uno::Exception const &)
- {}
-
- if (!xIH.is())
- throw uno::RuntimeException(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "unable to instanciate Interaction Handler service")),
- uno::Reference< uno::XInterface >());
+ uno::Reference< task::XInteractionHandler > xIH(
+ InteractionHandler::createWithParentAndContext(comphelper::getComponentContext(m_xServiceFactory),
+ m_xWindowParam, m_aContextParam),
+ UNO_QUERY_THROW);
return xIH;
}
diff --git a/uui/source/iahndl.hxx b/uui/source/iahndl.hxx
index 358bdd5d58ae..3266f0b90216 100644
--- a/uui/source/iahndl.hxx
+++ b/uui/source/iahndl.hxx
@@ -88,7 +88,8 @@ class UUIInteractionHelper
private:
mutable osl::Mutex m_aPropertyMutex;
::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory;
- ::com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_aProperties;
+ ::com::sun::star::uno::Reference< com::sun::star::awt::XWindow > m_xWindowParam;
+ const OUString m_aContextParam;
StringHashMap m_aTypedCustomHandlers;
UUIInteractionHelper(UUIInteractionHelper &); // not implemented
void operator =(UUIInteractionHelper); // not implemented
@@ -97,8 +98,9 @@ public:
UUIInteractionHelper(
com::sun::star::uno::Reference<
com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory,
- com::sun::star::uno::Sequence<
- com::sun::star::uno::Any > const & rArguments)
+ com::sun::star::uno::Reference<
+ com::sun::star::awt::XWindow > const & rxWindow,
+ const OUString & rContextParam)
SAL_THROW(());
UUIInteractionHelper(
com::sun::star::uno::Reference<
diff --git a/uui/source/interactionhandler.cxx b/uui/source/interactionhandler.cxx
index 4054a3825f2c..821b03e632a8 100644
--- a/uui/source/interactionhandler.cxx
+++ b/uui/source/interactionhandler.cxx
@@ -19,6 +19,8 @@
#include "iahndl.hxx"
#include "interactionhandler.hxx"
+#include "comphelper/namedvaluecollection.hxx"
+#include "com/sun/star/awt/XWindow.hpp"
using namespace com::sun::star;
@@ -67,7 +69,21 @@ UUIInteractionHandler::initialize(
throw (uno::Exception)
{
delete m_pImpl;
- m_pImpl = new UUIInteractionHelper(m_xServiceFactory, rArguments);
+
+ uno::Reference< awt::XWindow > xWindow;
+ rtl::OUString aContext;
+ ::comphelper::NamedValueCollection aProperties( rArguments );
+ if ( aProperties.has( "Parent" ) )
+ {
+ OSL_VERIFY( aProperties.get( "Parent" ) >>= xWindow );
+ }
+ if ( aProperties.has( "Context" ) )
+ {
+ OSL_VERIFY( aProperties.get( "Context" ) >>= aContext );
+ }
+
+
+ m_pImpl = new UUIInteractionHelper(m_xServiceFactory, xWindow, aContext);
}
void SAL_CALL
diff --git a/uui/source/interactionhandler.hxx b/uui/source/interactionhandler.hxx
index 39acd8624a22..8d2147b74641 100644
--- a/uui/source/interactionhandler.hxx
+++ b/uui/source/interactionhandler.hxx
@@ -20,16 +20,14 @@
#ifndef UUI_INTERACTIONHANDLER_HXX
#define UUI_INTERACTIONHANDLER_HXX
-#include "com/sun/star/lang/XInitialization.hpp"
#include "com/sun/star/lang/XServiceInfo.hpp"
#include "com/sun/star/task/XInteractionHandler2.hpp"
-#include "cppuhelper/implbase3.hxx"
+#include "cppuhelper/implbase2.hxx"
class UUIInteractionHelper;
class UUIInteractionHandler:
- public cppu::WeakImplHelper3< com::sun::star::lang::XServiceInfo,
- com::sun::star::lang::XInitialization,
+ public cppu::WeakImplHelper2< com::sun::star::lang::XServiceInfo,
com::sun::star::task::XInteractionHandler2 >
{
public: