merged tag ooo/DEV300_m102
[LibreOffice.git] / uui / source / interactionhandler.cxx
blobef4b3f7b0a7111d7d165cab91c538b7882ffc3e4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #include "iahndl.hxx"
29 #include "interactionhandler.hxx"
31 using namespace com::sun::star;
33 UUIInteractionHandler::UUIInteractionHandler(
34 uno::Reference< lang::XMultiServiceFactory > const &
35 rServiceFactory)
36 SAL_THROW(())
37 : m_xServiceFactory(rServiceFactory),
38 m_pImpl(new UUIInteractionHelper(m_xServiceFactory))
42 UUIInteractionHandler::~UUIInteractionHandler()
44 delete m_pImpl;
47 rtl::OUString SAL_CALL UUIInteractionHandler::getImplementationName()
48 throw (uno::RuntimeException)
50 return rtl::OUString::createFromAscii(m_aImplementationName);
53 sal_Bool SAL_CALL
54 UUIInteractionHandler::supportsService(rtl::OUString const & rServiceName)
55 throw (uno::RuntimeException)
57 uno::Sequence< rtl::OUString >
58 aNames(getSupportedServiceNames_static());
59 for (sal_Int32 i = 0; i < aNames.getLength(); ++i)
60 if (aNames[i] == rServiceName)
61 return true;
62 return false;
65 uno::Sequence< rtl::OUString > SAL_CALL
66 UUIInteractionHandler::getSupportedServiceNames()
67 throw (uno::RuntimeException)
69 return getSupportedServiceNames_static();
72 void SAL_CALL
73 UUIInteractionHandler::initialize(
74 uno::Sequence< uno::Any > const & rArguments)
75 throw (uno::Exception)
77 delete m_pImpl;
78 m_pImpl = new UUIInteractionHelper(m_xServiceFactory, rArguments);
81 void SAL_CALL
82 UUIInteractionHandler::handle(
83 uno::Reference< task::XInteractionRequest > const & rRequest)
84 throw (uno::RuntimeException)
86 try
88 m_pImpl->handleRequest(rRequest);
90 catch (uno::RuntimeException const & ex)
92 throw uno::RuntimeException(ex.Message, *this);
96 ::sal_Bool SAL_CALL UUIInteractionHandler::handleInteractionRequest(
97 const uno::Reference< task::XInteractionRequest >& _Request ) throw ( uno::RuntimeException )
99 try
101 return m_pImpl->handleRequest( _Request );
103 catch (uno::RuntimeException const & ex)
105 throw uno::RuntimeException( ex.Message, *this );
107 return sal_False;
110 char const UUIInteractionHandler::m_aImplementationName[]
111 = "com.sun.star.comp.uui.UUIInteractionHandler";
113 uno::Sequence< rtl::OUString >
114 UUIInteractionHandler::getSupportedServiceNames_static()
116 uno::Sequence< rtl::OUString > aNames(3);
117 aNames[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
118 "com.sun.star.task.InteractionHandler"));
119 // added to indicate support for configuration.backend.MergeRecoveryRequest
120 aNames[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
121 "com.sun.star.configuration.backend.InteractionHandler"));
122 aNames[2] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
123 "com.sun.star.uui.InteractionHandler"));
124 // for backwards compatibility
125 return aNames;
128 uno::Reference< uno::XInterface > SAL_CALL
129 UUIInteractionHandler::createInstance(
130 uno::Reference< lang::XMultiServiceFactory > const &
131 rServiceFactory)
132 SAL_THROW((uno::Exception))
136 return *new UUIInteractionHandler(rServiceFactory);
138 catch (std::bad_alloc const &)
140 throw uno::RuntimeException(
141 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),