1*859212d1SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*859212d1SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*859212d1SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*859212d1SAndrew Rist * distributed with this work for additional information 6*859212d1SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*859212d1SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*859212d1SAndrew Rist * "License"); you may not use this file except in compliance 9*859212d1SAndrew Rist * with the License. You may obtain a copy of the License at 10*859212d1SAndrew Rist * 11*859212d1SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*859212d1SAndrew Rist * 13*859212d1SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*859212d1SAndrew Rist * software distributed under the License is distributed on an 15*859212d1SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*859212d1SAndrew Rist * KIND, either express or implied. See the License for the 17*859212d1SAndrew Rist * specific language governing permissions and limitations 18*859212d1SAndrew Rist * under the License. 19*859212d1SAndrew Rist * 20*859212d1SAndrew Rist *************************************************************/ 21*859212d1SAndrew Rist 22*859212d1SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "iahndl.hxx" 25cdf0e10cSrcweir #include "interactionhandler.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir using namespace com::sun::star; 28cdf0e10cSrcweir UUIInteractionHandler(uno::Reference<lang::XMultiServiceFactory> const & rServiceFactory)29cdf0e10cSrcweirUUIInteractionHandler::UUIInteractionHandler( 30cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > const & 31cdf0e10cSrcweir rServiceFactory) 32cdf0e10cSrcweir SAL_THROW(()) 33cdf0e10cSrcweir : m_xServiceFactory(rServiceFactory), 34cdf0e10cSrcweir m_pImpl(new UUIInteractionHelper(m_xServiceFactory)) 35cdf0e10cSrcweir { 36cdf0e10cSrcweir } 37cdf0e10cSrcweir ~UUIInteractionHandler()38cdf0e10cSrcweirUUIInteractionHandler::~UUIInteractionHandler() 39cdf0e10cSrcweir { 40cdf0e10cSrcweir delete m_pImpl; 41cdf0e10cSrcweir } 42cdf0e10cSrcweir getImplementationName()43cdf0e10cSrcweirrtl::OUString SAL_CALL UUIInteractionHandler::getImplementationName() 44cdf0e10cSrcweir throw (uno::RuntimeException) 45cdf0e10cSrcweir { 46cdf0e10cSrcweir return rtl::OUString::createFromAscii(m_aImplementationName); 47cdf0e10cSrcweir } 48cdf0e10cSrcweir 49cdf0e10cSrcweir sal_Bool SAL_CALL supportsService(rtl::OUString const & rServiceName)50cdf0e10cSrcweirUUIInteractionHandler::supportsService(rtl::OUString const & rServiceName) 51cdf0e10cSrcweir throw (uno::RuntimeException) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir uno::Sequence< rtl::OUString > 54cdf0e10cSrcweir aNames(getSupportedServiceNames_static()); 55cdf0e10cSrcweir for (sal_Int32 i = 0; i < aNames.getLength(); ++i) 56cdf0e10cSrcweir if (aNames[i] == rServiceName) 57cdf0e10cSrcweir return true; 58cdf0e10cSrcweir return false; 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames()62cdf0e10cSrcweirUUIInteractionHandler::getSupportedServiceNames() 63cdf0e10cSrcweir throw (uno::RuntimeException) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir return getSupportedServiceNames_static(); 66cdf0e10cSrcweir } 67cdf0e10cSrcweir 68cdf0e10cSrcweir void SAL_CALL initialize(uno::Sequence<uno::Any> const & rArguments)69cdf0e10cSrcweirUUIInteractionHandler::initialize( 70cdf0e10cSrcweir uno::Sequence< uno::Any > const & rArguments) 71cdf0e10cSrcweir throw (uno::Exception) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir delete m_pImpl; 74cdf0e10cSrcweir m_pImpl = new UUIInteractionHelper(m_xServiceFactory, rArguments); 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir void SAL_CALL handle(uno::Reference<task::XInteractionRequest> const & rRequest)78cdf0e10cSrcweirUUIInteractionHandler::handle( 79cdf0e10cSrcweir uno::Reference< task::XInteractionRequest > const & rRequest) 80cdf0e10cSrcweir throw (uno::RuntimeException) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir try 83cdf0e10cSrcweir { 84cdf0e10cSrcweir m_pImpl->handleRequest(rRequest); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir catch (uno::RuntimeException const & ex) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir throw uno::RuntimeException(ex.Message, *this); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir } 91cdf0e10cSrcweir handleInteractionRequest(const uno::Reference<task::XInteractionRequest> & _Request)92cdf0e10cSrcweir::sal_Bool SAL_CALL UUIInteractionHandler::handleInteractionRequest( 93cdf0e10cSrcweir const uno::Reference< task::XInteractionRequest >& _Request ) throw ( uno::RuntimeException ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir try 96cdf0e10cSrcweir { 97cdf0e10cSrcweir return m_pImpl->handleRequest( _Request ); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir catch (uno::RuntimeException const & ex) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir throw uno::RuntimeException( ex.Message, *this ); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir return sal_False; 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir char const UUIInteractionHandler::m_aImplementationName[] 107cdf0e10cSrcweir = "com.sun.star.comp.uui.UUIInteractionHandler"; 108cdf0e10cSrcweir 109cdf0e10cSrcweir uno::Sequence< rtl::OUString > getSupportedServiceNames_static()110cdf0e10cSrcweirUUIInteractionHandler::getSupportedServiceNames_static() 111cdf0e10cSrcweir { 112cdf0e10cSrcweir uno::Sequence< rtl::OUString > aNames(3); 113cdf0e10cSrcweir aNames[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 114cdf0e10cSrcweir "com.sun.star.task.InteractionHandler")); 115cdf0e10cSrcweir // added to indicate support for configuration.backend.MergeRecoveryRequest 116cdf0e10cSrcweir aNames[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 117cdf0e10cSrcweir "com.sun.star.configuration.backend.InteractionHandler")); 118cdf0e10cSrcweir aNames[2] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 119cdf0e10cSrcweir "com.sun.star.uui.InteractionHandler")); 120cdf0e10cSrcweir // for backwards compatibility 121cdf0e10cSrcweir return aNames; 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL createInstance(uno::Reference<lang::XMultiServiceFactory> const & rServiceFactory)125cdf0e10cSrcweirUUIInteractionHandler::createInstance( 126cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > const & 127cdf0e10cSrcweir rServiceFactory) 128cdf0e10cSrcweir SAL_THROW((uno::Exception)) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir try 131cdf0e10cSrcweir { 132cdf0e10cSrcweir return *new UUIInteractionHandler(rServiceFactory); 133cdf0e10cSrcweir } 134cdf0e10cSrcweir catch (std::bad_alloc const &) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir throw uno::RuntimeException( 137cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")), 138cdf0e10cSrcweir 0); 139cdf0e10cSrcweir } 140cdf0e10cSrcweir } 141