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