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 "requeststringresolver.hxx"
25cdf0e10cSrcweir #include "iahndl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir using namespace com::sun;
28cdf0e10cSrcweir 
UUIInteractionRequestStringResolver(star::uno::Reference<star::lang::XMultiServiceFactory> const & rServiceFactory)29cdf0e10cSrcweir UUIInteractionRequestStringResolver::UUIInteractionRequestStringResolver(
30cdf0e10cSrcweir     star::uno::Reference< star::lang::XMultiServiceFactory > const &
31cdf0e10cSrcweir         rServiceFactory)
32cdf0e10cSrcweir     SAL_THROW(())
33cdf0e10cSrcweir         : m_xServiceFactory(rServiceFactory),
34cdf0e10cSrcweir           m_pImpl(new UUIInteractionHelper(rServiceFactory))
35cdf0e10cSrcweir {
36cdf0e10cSrcweir }
37cdf0e10cSrcweir 
~UUIInteractionRequestStringResolver()38cdf0e10cSrcweir UUIInteractionRequestStringResolver::~UUIInteractionRequestStringResolver()
39cdf0e10cSrcweir {
40cdf0e10cSrcweir     delete m_pImpl;
41cdf0e10cSrcweir }
42cdf0e10cSrcweir 
43cdf0e10cSrcweir rtl::OUString SAL_CALL
getImplementationName()44cdf0e10cSrcweir UUIInteractionRequestStringResolver::getImplementationName()
45cdf0e10cSrcweir     throw (star::uno::RuntimeException)
46cdf0e10cSrcweir {
47cdf0e10cSrcweir     return rtl::OUString::createFromAscii(m_aImplementationName);
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir sal_Bool SAL_CALL
supportsService(rtl::OUString const & rServiceName)51cdf0e10cSrcweir UUIInteractionRequestStringResolver::supportsService(
52cdf0e10cSrcweir         rtl::OUString const & rServiceName)
53cdf0e10cSrcweir     throw (star::uno::RuntimeException)
54cdf0e10cSrcweir {
55cdf0e10cSrcweir     star::uno::Sequence< rtl::OUString >
56cdf0e10cSrcweir         aNames(getSupportedServiceNames_static());
57cdf0e10cSrcweir     for (sal_Int32 i = 0; i < aNames.getLength(); ++i)
58cdf0e10cSrcweir         if (aNames[i] == rServiceName)
59cdf0e10cSrcweir             return true;
60cdf0e10cSrcweir     return false;
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir star::uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames()64cdf0e10cSrcweir UUIInteractionRequestStringResolver::getSupportedServiceNames()
65cdf0e10cSrcweir     throw (star::uno::RuntimeException)
66cdf0e10cSrcweir {
67cdf0e10cSrcweir     return getSupportedServiceNames_static();
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir star::beans::Optional< rtl::OUString > SAL_CALL
getStringFromInformationalRequest(const star::uno::Reference<star::task::XInteractionRequest> & Request)71cdf0e10cSrcweir UUIInteractionRequestStringResolver::getStringFromInformationalRequest(
72cdf0e10cSrcweir     const star::uno::Reference<
73cdf0e10cSrcweir         star::task::XInteractionRequest >& Request )
74cdf0e10cSrcweir     throw (star::uno::RuntimeException)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     try
77cdf0e10cSrcweir     {
78cdf0e10cSrcweir         return m_pImpl->getStringFromRequest(Request);
79cdf0e10cSrcweir     }
80cdf0e10cSrcweir     catch (star::uno::RuntimeException const & ex)
81cdf0e10cSrcweir     {
82cdf0e10cSrcweir         throw star::uno::RuntimeException(ex.Message, *this);
83cdf0e10cSrcweir     }
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir char const UUIInteractionRequestStringResolver::m_aImplementationName[]
87cdf0e10cSrcweir     = "com.sun.star.comp.uui.UUIInteractionRequestStringResolver";
88cdf0e10cSrcweir 
89cdf0e10cSrcweir star::uno::Sequence< rtl::OUString >
getSupportedServiceNames_static()90cdf0e10cSrcweir UUIInteractionRequestStringResolver::getSupportedServiceNames_static()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir     star::uno::Sequence< rtl::OUString > aNames(1);
93cdf0e10cSrcweir     aNames[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
94cdf0e10cSrcweir                     "com.sun.star.task.InteractionRequestStringResolver"));
95cdf0e10cSrcweir     return aNames;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir star::uno::Reference< star::uno::XInterface > SAL_CALL
createInstance(star::uno::Reference<star::lang::XMultiServiceFactory> const & rServiceFactory)99cdf0e10cSrcweir UUIInteractionRequestStringResolver::createInstance(
100cdf0e10cSrcweir     star::uno::Reference< star::lang::XMultiServiceFactory > const &
101cdf0e10cSrcweir         rServiceFactory)
102cdf0e10cSrcweir     SAL_THROW((star::uno::Exception))
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     try
105cdf0e10cSrcweir     {
106cdf0e10cSrcweir         return *new UUIInteractionRequestStringResolver(rServiceFactory);
107cdf0e10cSrcweir     }
108cdf0e10cSrcweir     catch (std::bad_alloc const &)
109cdf0e10cSrcweir     {
110cdf0e10cSrcweir         throw star::uno::RuntimeException(
111cdf0e10cSrcweir 	    rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
112cdf0e10cSrcweir 	    0);
113cdf0e10cSrcweir     }
114cdf0e10cSrcweir }
115